feat(nvim): debloat setup, tweak lsp
This commit is contained in:
parent
a1d56b8afd
commit
8e4e909be2
6 changed files with 407 additions and 385 deletions
|
@ -1,13 +1,13 @@
|
|||
-- vim:fdm=marker
|
||||
pcall(require, "impatient")
|
||||
pcall(require, "plugins")
|
||||
pcall(require, "lsp")
|
||||
require("impatient")
|
||||
require("plugins")
|
||||
require("lsp")
|
||||
|
||||
-- true colors
|
||||
vim.o.termguicolors = true
|
||||
-- map leader to space
|
||||
vim.g.mapleader = " "
|
||||
vim.o.cmdheight = 0
|
||||
vim.o.cmdheight = 1
|
||||
-- line numbers
|
||||
vim.o.mouse = ""
|
||||
vim.o.number = true
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
require("bufferline").setup({
|
||||
options = {
|
||||
show_close_icon = false,
|
||||
separator_style = "slant",
|
||||
separator_style = "thin",
|
||||
show_buffer_close_icons = false,
|
||||
offsets = { { filetype = "NvimTree" } },
|
||||
left_mouse_command = "buffer %d",
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
local home = os.getenv("HOME")
|
||||
local db = require("dashboard")
|
||||
|
||||
db.custom_header = function()
|
||||
local cringe = {
|
||||
"Have fun coding!",
|
||||
"Sisyphus wasn't forbidden to smile.",
|
||||
"Pro tip: Run :q! to exit. Now!",
|
||||
"neovim got rid of the :smile command.",
|
||||
"Pro tip: You can use :q to exit. Do it. Now!",
|
||||
}
|
||||
local random_cringe = cringe[math.random(#cringe)]
|
||||
return {
|
||||
|
@ -34,34 +33,48 @@ db.custom_header = function()
|
|||
}
|
||||
end
|
||||
|
||||
local padding = 25
|
||||
local function pad(string)
|
||||
local str = string
|
||||
for _ = 1, padding - #string do
|
||||
str = str .. " "
|
||||
end
|
||||
return str
|
||||
end
|
||||
|
||||
db.custom_center = {
|
||||
{
|
||||
icon = " ",
|
||||
desc = "Open Projects ",
|
||||
desc = pad("Open Projects"),
|
||||
action = "Telescope project",
|
||||
shortcut = "SPC f p",
|
||||
},
|
||||
{
|
||||
icon = " ",
|
||||
desc = "Find File ",
|
||||
desc = pad("Find File"),
|
||||
action = "Telescope find_files find_command=rg,--hidden,--files",
|
||||
shortcut = "SPC f f",
|
||||
},
|
||||
{
|
||||
icon = " ",
|
||||
desc = "File Browser ",
|
||||
desc = pad("File Browser"),
|
||||
action = "Telescope file_browser",
|
||||
shortcut = "SPC f b",
|
||||
},
|
||||
{
|
||||
icon = " ",
|
||||
desc = "Find word ",
|
||||
desc = pad("Find word"),
|
||||
action = "Telescope live_grep",
|
||||
shortcut = "SPC f g",
|
||||
},
|
||||
{
|
||||
icon = " ",
|
||||
desc = "Open Settings ",
|
||||
desc = pad("Open Settings"),
|
||||
action = function()
|
||||
vim.cmd("cd " .. home .. "/.config/nvim/")
|
||||
vim.cmd("edit init.lua")
|
||||
local confpath = vim.fn.resolve(vim.fn.stdpath("config"))
|
||||
require("telescope.builtin").find_files({ cwd = confpath })
|
||||
end,
|
||||
shortcut = "SPC f s",
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -3,10 +3,10 @@ function string.starts(self, str)
|
|||
end
|
||||
|
||||
local conceal = function()
|
||||
local home = os.getenv("HOME")
|
||||
local home = vim.fn.expand("$HOME") .. "/Code/"
|
||||
local blacklist = {
|
||||
[home .. "/git/work"] = "Using nvim at work.",
|
||||
[home .. "/git/freelance"] = "Using nvim to freelance.",
|
||||
[vim.fn.resolve(home .. "work")] = "Using nvim at work.",
|
||||
[vim.fn.resolve(home .. "freelance")] = "Using nvim to freelance.",
|
||||
[vim.fn.resolve(vim.fn.stdpath("config"))] = "Stuck in the hell of nvim config.",
|
||||
}
|
||||
|
||||
|
|
|
@ -14,10 +14,27 @@ vim.opt.completeopt = "menu,menuone,noselect"
|
|||
|
||||
local present, cmp = pcall(require, "cmp")
|
||||
if not present or not cmp then
|
||||
vim.pretty_print("cmp not found")
|
||||
return
|
||||
end
|
||||
|
||||
local has_words_before = function()
|
||||
local line, col = table.unpack(vim.api.nvim_win_get_cursor(0))
|
||||
return col ~= 0
|
||||
and vim.api
|
||||
.nvim_buf_get_lines(0, line - 1, line, true)[1]
|
||||
:sub(col, col)
|
||||
:match("%s")
|
||||
== nil
|
||||
end
|
||||
|
||||
local feedkey = function(key, mode)
|
||||
vim.api.nvim_feedkeys(
|
||||
vim.api.nvim_replace_termcodes(key, true, true, true),
|
||||
mode,
|
||||
true
|
||||
)
|
||||
end
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
|
@ -29,19 +46,30 @@ cmp.setup({
|
|||
documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
["<C-b>"] = cmp.mapping.scroll_docs(-4),
|
||||
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
["<C-e>"] = cmp.mapping.abort(),
|
||||
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
-- This little snippet will confirm with tab, and if no entry is selected, will confirm the first item
|
||||
if cmp.visible() then
|
||||
local entry = cmp.get_selected_entry()
|
||||
if not entry then
|
||||
cmp.select_next_item({ behavior = cmp.SelectBehavior.Select })
|
||||
cmp.select_next_item()
|
||||
elseif vim.fn["vsnip#available"](1) == 1 then
|
||||
feedkey("<Plug>(vsnip-expand-or-jump)", "")
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
cmp.confirm()
|
||||
fallback() -- The fallback function sends a already mapped key. In this case, it's probably `<Tab>`.
|
||||
end
|
||||
else
|
||||
fallback()
|
||||
end, { "i", "s" }),
|
||||
|
||||
["<S-Tab>"] = cmp.mapping(function()
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif vim.fn["vsnip#jumpable"](-1) == 1 then
|
||||
feedkey("<Plug>(vsnip-jump-prev)", "")
|
||||
end
|
||||
end, { "i", "s", "c" }),
|
||||
end, { "i", "s" }),
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = "nvim_lsp" },
|
||||
|
@ -187,6 +215,3 @@ local toggle_formatters = function()
|
|||
end
|
||||
|
||||
vim.api.nvim_create_user_command("ToggleFormatters", toggle_formatters, {})
|
||||
|
||||
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
|
||||
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done())
|
||||
|
|
|
@ -1,23 +1,4 @@
|
|||
local ensure_packer = function()
|
||||
local fn = vim.fn
|
||||
local install_path = fn.stdpath("data")
|
||||
.. "/site/pack/packer/start/packer.nvim"
|
||||
if fn.empty(fn.glob(install_path)) > 0 then
|
||||
fn.system({
|
||||
"git",
|
||||
"clone",
|
||||
"--depth",
|
||||
"1",
|
||||
"https://github.com/wbthomason/packer.nvim",
|
||||
install_path,
|
||||
})
|
||||
vim.cmd([[packadd packer.nvim]])
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local packer_bootstrap = ensure_packer()
|
||||
local packer = require("packer")
|
||||
|
||||
-- auto-compile when lua files in `~/.config/nvim/*` change
|
||||
vim.api.nvim_create_autocmd("BufWritePost", {
|
||||
|
@ -32,7 +13,8 @@ vim.api.nvim_create_autocmd("BufWritePost", {
|
|||
end,
|
||||
})
|
||||
|
||||
return require("packer").startup(function(use)
|
||||
return packer.startup({
|
||||
function(use)
|
||||
-- Packer managing itself
|
||||
use("wbthomason/packer.nvim")
|
||||
-- startup time or some shit
|
||||
|
@ -91,13 +73,38 @@ return require("packer").startup(function(use)
|
|||
end,
|
||||
})
|
||||
|
||||
-- bottom bar
|
||||
use({
|
||||
"feline-nvim/feline.nvim",
|
||||
requires = "kyazdani42/nvim-web-devicons",
|
||||
after = { "catppuccin" },
|
||||
"nvim-lualine/lualine.nvim",
|
||||
requires = { "kyazdani42/nvim-web-devicons", opt = true },
|
||||
config = function()
|
||||
require("config/feline")
|
||||
require("lualine").setup({
|
||||
options = {
|
||||
theme = "catppuccin",
|
||||
component_separators = { left = "", right = "" },
|
||||
section_separators = { left = "", right = "" },
|
||||
},
|
||||
sections = {
|
||||
lualine_x = {
|
||||
{
|
||||
"diagnostics",
|
||||
sources = { "nvim_lsp" },
|
||||
-- Displays diagnostics for the defined severity types
|
||||
sections = { "error", "warn", "info", "hint" },
|
||||
diagnostics_color = {
|
||||
-- Same values as the general color option can be used here.
|
||||
error = "DiagnosticError", -- Changes diagnostics' error color.
|
||||
warn = "DiagnosticWarn", -- Changes diagnostics' warn color.
|
||||
info = "DiagnosticInfo", -- Changes diagnostics' info color.
|
||||
hint = "DiagnosticHint", -- Changes diagnostics' hint color.
|
||||
},
|
||||
symbols = { error = "E", warn = "W", info = "I", hint = "H" },
|
||||
colored = true, -- Displays diagnostics status in color if set to true.
|
||||
update_in_insert = false, -- Update diagnostics in insert mode.
|
||||
always_visible = false, -- Show diagnostics even if there are none.
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
})
|
||||
|
||||
|
@ -134,9 +141,6 @@ return require("packer").startup(function(use)
|
|||
|
||||
-- syntax
|
||||
use("alker0/chezmoi.vim")
|
||||
use("ron-rs/ron.vim")
|
||||
use("elkowar/yuck.vim")
|
||||
|
||||
-- tooling
|
||||
use("gpanders/editorconfig.nvim")
|
||||
-- read and write encrypted pgp files
|
||||
|
@ -157,14 +161,22 @@ return require("packer").startup(function(use)
|
|||
})
|
||||
use("ggandor/lightspeed.nvim")
|
||||
|
||||
use("windwp/nvim-autopairs")
|
||||
use({
|
||||
"windwp/nvim-autopairs",
|
||||
config = function()
|
||||
require("nvim-autopairs").setup({})
|
||||
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
|
||||
local cmp = require("cmp")
|
||||
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done())
|
||||
end,
|
||||
})
|
||||
use({
|
||||
"windwp/nvim-ts-autotag",
|
||||
config = function()
|
||||
require("nvim-ts-autotag").setup()
|
||||
end,
|
||||
})
|
||||
--
|
||||
|
||||
-- git
|
||||
use("tpope/vim-fugitive")
|
||||
-- why not both?
|
||||
|
@ -176,13 +188,6 @@ return require("packer").startup(function(use)
|
|||
end,
|
||||
})
|
||||
use("dhruvasagar/vim-table-mode")
|
||||
use({
|
||||
"kyazdani42/nvim-tree.lua",
|
||||
config = function()
|
||||
require("nvim-tree").setup({ update_cwd = true })
|
||||
Map("n", "<C-n>", ":NvimTreeToggle<CR>")
|
||||
end,
|
||||
})
|
||||
use({
|
||||
"nvchad/nvim-colorizer.lua",
|
||||
config = function()
|
||||
|
@ -215,10 +220,15 @@ return require("packer").startup(function(use)
|
|||
requires = "nvim-lua/plenary.nvim",
|
||||
config = function()
|
||||
Map("n", "<leader>fr", "<cmd>Telescope asynctasks all<CR>")
|
||||
Map("n", "<leader>fb", "<cmd>Telescope buffers<CR>")
|
||||
Map("n", "<leader>fb", "<cmd>Telescope file_browser<CR>")
|
||||
Map("n", "<leader>ff", "<cmd>Telescope find_files<CR>")
|
||||
Map("n", "<leader>fg", "<cmd>Telescope live_grep<CR>")
|
||||
Map("n", "<leader>fh", "<cmd>Telescope help_tags<CR>")
|
||||
Map("n", "<leader>fp", "<cmd>Telescope project<CR>")
|
||||
Map("n", "<leader>fs", function()
|
||||
local confpath = vim.fn.resolve(vim.fn.stdpath("config"))
|
||||
require("telescope.builtin").find_files({ cwd = confpath })
|
||||
end)
|
||||
end,
|
||||
})
|
||||
use({
|
||||
|
@ -252,12 +262,6 @@ return require("packer").startup(function(use)
|
|||
require("telescope").load_extension("project")
|
||||
end,
|
||||
})
|
||||
use({
|
||||
"nvim-telescope/telescope-packer.nvim",
|
||||
config = function()
|
||||
require("telescope").load_extension("packer")
|
||||
end,
|
||||
})
|
||||
|
||||
use({
|
||||
"andweeb/presence.nvim",
|
||||
|
@ -267,9 +271,8 @@ return require("packer").startup(function(use)
|
|||
})
|
||||
use({ "iamcco/markdown-preview.nvim", run = "cd app && yarn install" })
|
||||
|
||||
-- external extensions
|
||||
use("williamboman/mason.nvim")
|
||||
-- LSP
|
||||
use("williamboman/mason.nvim")
|
||||
use("williamboman/mason-lspconfig.nvim")
|
||||
use("neovim/nvim-lspconfig")
|
||||
-- completion
|
||||
|
@ -346,29 +349,10 @@ return require("packer").startup(function(use)
|
|||
require("config/dashboard")
|
||||
end,
|
||||
})
|
||||
|
||||
-- automatic theme switching
|
||||
if vim.fn.has("macunix") then
|
||||
use({
|
||||
"f-person/auto-dark-mode.nvim",
|
||||
config = function()
|
||||
local auto_dark_mode = require("auto-dark-mode")
|
||||
auto_dark_mode.setup({
|
||||
---@diagnostic disable-next-line: assign-type-mismatch
|
||||
update_interval = 1000,
|
||||
set_dark_mode = function()
|
||||
vim.cmd("Catppuccin frappe")
|
||||
end,
|
||||
set_light_mode = function()
|
||||
vim.cmd("Catppuccin latte")
|
||||
end,
|
||||
config = {
|
||||
display = {
|
||||
open_fn = require("packer.util").float,
|
||||
},
|
||||
},
|
||||
})
|
||||
auto_dark_mode.init()
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
if packer_bootstrap then
|
||||
require("packer").sync()
|
||||
end
|
||||
end)
|
||||
|
|
Loading…
Reference in a new issue