fix: improve nvim performance

This commit is contained in:
Fabio Lenherr 2023-02-21 19:54:42 +01:00
parent 670014885b
commit fdcb340766
7 changed files with 115 additions and 173 deletions

View file

@ -1,6 +1,6 @@
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
--
require("settings.plugins")
require("settings.options")
require("settings.cmp")
@ -19,18 +19,19 @@ require("settings.telescope")
require("settings.vimtex")
require("settings.keymaps")
require("settings.barbar")
-- simple plugins that don't make sense to put in a seperate file, would clutter too much
require("gitsigns").setup()
require("feline").setup()
require("impatient").enable_profile()
require('Comment').setup()
require("toggleterm").setup({
autochdir = true,
})
require('leap').add_default_mappings()
require("nvim-highlight-colors").setup {
render = 'background', -- or 'foreground' or 'first_column'
enable_named_colors = true,
enable_tailwind = true,
}
--
-- -- simple plugins that don't make sense to put in a seperate file, would clutter too much
-- -- require("gitsigns").setup()
require("feline").setup()
require("impatient").enable_profile()
require('Comment').setup()
require("toggleterm").setup({
autochdir = true,
})
require('leap').add_default_mappings()
require("nvim-highlight-colors").setup {
render = 'background', -- or 'foreground' or 'first_column'
enable_named_colors = true,
enable_tailwind = true,
}
-- require('neoscroll').setup()

View file

@ -3,72 +3,9 @@ if not status_ok then
return
end
vim.g.indent_blankline_buftype_exclude = { "terminal", "nofile" }
vim.g.indent_blankline_filetype_exclude = {
"help",
"startify",
"dashboard",
"packer",
"neogitstatus",
"NvimTree",
"Trouble",
vim.opt.list = true
require("indent_blankline").setup {
space_char_blankline = " ",
show_current_context = true,
show_current_context_start = true,
}
vim.g.indentLine_enabled = 1
-- vim.g.indent_blankline_char = "│"
vim.g.indent_blankline_char = ""
-- vim.g.indent_blankline_char = "▎"
vim.g.indent_blankline_show_trailing_blankline_indent = false
vim.g.indent_blankline_show_first_indent_level = true
vim.g.indent_blankline_use_treesitter = true
vim.g.indent_blankline_show_current_context = true
vim.g.indent_blankline_context_patterns = {
"class",
"return",
"function",
"def",
"method",
"^if",
"^else",
"^else if",
"^elif",
"^while",
"jsx_element",
"^for",
"^object",
"^table",
"block",
"arguments",
"if_statement",
"else_clause",
"jsx_element",
"jsx_self_closing_element",
"try_statement",
"catch_clause",
"import_statement",
"operation_type",
}
-- HACK: work-around for https://github.com/lukas-reineke/indent-blankline.nvim/issues/59
vim.wo.colorcolumn = "99999"
-- vim.cmd [[highlight IndentBlanklineIndent1 guifg=#E06C75 gui=nocombine]]
-- vim.cmd [[highlight IndentBlanklineIndent2 guifg=#E5C07B gui=nocombine]]
-- vim.cmd [[highlight IndentBlanklineIndent3 guifg=#98C379 gui=nocombine]]
-- vim.cmd [[highlight IndentBlanklineIndent4 guifg=#56B6C2 gui=nocombine]]
-- vim.cmd [[highlight IndentBlanklineIndent5 guifg=#61AFEF gui=nocombine]]
-- vim.cmd [[highlight IndentBlanklineIndent6 guifg=#C678DD gui=nocombine]]
-- vim.opt.list = true
-- vim.opt.listchars:append "space:⋅"
-- vim.opt.listchars:append "space:"
-- vim.opt.listchars:append "eol:↴"
indent_blankline.setup({
show_end_of_line = true,
space_char_blankline = " ",
show_current_context = true,
show_current_context_start = true,
-- char_highlight_list = {
-- "IndentBlanklineIndent1",
-- "IndentBlanklineIndent2",
-- "IndentBlanklineIndent3",
-- },
})

View file

@ -1,109 +1,113 @@
local status_ok, _ = pcall(require, "lspconfig")
if not status_ok then
return
return
end
require("mason").setup({
ui = {
icons = {
package_installed = "",
package_pending = "",
package_uninstalled = "",
},
},
ui = {
icons = {
package_installed = "",
package_pending = "",
package_uninstalled = "",
},
},
})
require("mason-lspconfig").setup({
ensure_installed = {
"cssls", -- css
"html", -- html
"clangd", -- cpp / c
"lua_ls", -- lua
"pyright", -- python
"cmake", -- cmake
"bashls", -- shell
"ansiblels", -- ansible
"marksman", -- markdown
"asm_lsp", -- assembly
"tsserver", -- js and ts
"ltex", -- latex
"jdtls", -- jafuck
"gopls", -- yet another gargabe collector
"sqls", -- sql
"taplo", -- toml
"lemminx", -- xml
"yamlls", -- yaml
"bashls", -- shell
},
automatic_installation = true,
ensure_installed = {
"cssls", -- css
"html", -- html
"clangd", -- cpp / c
"lua_ls", -- lua
"pyright", -- python
"cmake", -- cmake
"bashls", -- shell
"ansiblels", -- ansible
"marksman", -- markdown
"asm_lsp", -- assembly
"tsserver", -- js and ts
"ltex", -- latex
"jdtls", -- jafuck
"gopls", -- yet another gargabe collector
"sqls", -- sql
"taplo", -- toml
"lemminx", -- xml
"yamlls", -- yaml
"bashls", -- shell
},
automatic_installation = true,
})
local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
capabilities.textDocument.completion.completionItem.snippetSupport = true
-- LSP
-- require("lsp-format").setup {}
require("lsp-inlayhints").setup()
require("lsp-inlayhints").setup {}
local on_attach = function(client, bufnr)
vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
local optslsp = { noremap = false, silent = true, buffer = bufnr }
-- require("lsp-format").on_attach(client)
require("lsp-inlayhints").on_attach(client, bufnr)
vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
local optslsp = { noremap = false, silent = true, buffer = bufnr }
-- require("lsp-format").on_attach(client)
require("lsp-inlayhints").on_attach(client, bufnr)
end
require("rust-tools").setup({
server = {
standalone = false,
root_dir = require('lspconfig').util.find_git_ancestor,
loadOutputiDirs = false,
}
server = {
standalone = false,
root_dir = require('lspconfig').util.find_git_ancestor,
loadOutputiDirs = false,
},
tools = {
inlay_hints = {
auto = false
}
}
})
require("mason-lspconfig").setup_handlers({
function(server_name) -- default handler (optional)
require("lspconfig")[server_name].setup({
capabilities = capabilities,
on_attach = on_attach,
vim.lsp.diagnostic.on_publish_diagnostics, {
-- Disable virtual_text
virtual_text = true,
}
function(server_name) -- default handler (optional)
require("lspconfig")[server_name].setup({
capabilities = capabilities,
on_attach = on_attach,
vim.lsp.diagnostic.on_publish_diagnostics, {
-- Disable virtual_text
virtual_text = true,
}
})
end,
['tsserver'] = function()
require('lspconfig').tsserver.setup {
settings = {
typescript = {
inlayHints = {
includeInlayParameterNameHints = 'all',
includeInlayParameterNameHintsWhenArgumentMatchesName = false,
includeInlayFunctionParameterTypeHints = true,
includeInlayVariableTypeHints = true,
includeInlayPropertyDeclarationTypeHints = true,
includeInlayFunctionLikeReturnTypeHints = true,
includeInlayEnumMemberValueHints = true,
}
},
javascript = {
inlayHints = {
includeInlayParameterNameHints = 'all',
includeInlayParameterNameHintsWhenArgumentMatchesName = false,
includeInlayFunctionParameterTypeHints = true,
includeInlayVariableTypeHints = true,
includeInlayPropertyDeclarationTypeHints = true,
includeInlayFunctionLikeReturnTypeHints = true,
includeInlayEnumMemberValueHints = true,
}
}
},
capabilities = capabilities,
on_attach = on_attach,
vim.lsp.diagnostic.on_publish_diagnostics, {
virtual_text = true,
}
}
end,
})
end,
['tsserver'] = function()
require('lspconfig').tsserver.setup {
settings = {
typescript = {
inlayHints = {
includeInlayParameterNameHints = 'all',
includeInlayParameterNameHintsWhenArgumentMatchesName = true,
includeInlayFunctionParameterTypeHints = true,
includeInlayVariableTypeHints = true,
includeInlayPropertyDeclarationTypeHints = true,
includeInlayFunctionLikeReturnTypeHints = true,
includeInlayEnumMemberValueHints = true,
}
},
javascript = {
inlayHints = {
includeInlayParameterNameHints = 'all',
includeInlayParameterNameHintsWhenArgumentMatchesName = true,
includeInlayFunctionParameterTypeHints = true,
includeInlayVariableTypeHints = true,
includeInlayPropertyDeclarationTypeHints = true,
includeInlayFunctionLikeReturnTypeHints = true,
includeInlayEnumMemberValueHints = true,
}
}
},
capabilities = capabilities,
on_attach = on_attach,
vim.lsp.diagnostic.on_publish_diagnostics, {
virtual_text = true,
}
}
end,
})

View file

@ -242,13 +242,10 @@ vim.api.nvim_create_autocmd("BufEnter", {
local function open_nvim_tree(data)
-- buffer is a [No Name]
local no_name = data.file == "" and vim.bo[data.buf].buftype == ""
-- buffer is a directory
local directory = vim.fn.isdirectory(data.file) == 1
if not no_name and not directory then
if not directory then
return
end

View file

@ -14,7 +14,7 @@ local options = {
timeoutlen = 200, -- time to wait for a mapped sequence to complete (in milliseconds)
undofile = true, -- enable persistent undoi updatetime = 300, -- faster completion (4000ms default)
writebackup = false, -- if a file is being edited by another program (or was written to file while editing with another program), it is not allowed to be edited
expandtab = true, -- convert tabs to spaces
-- expandtab = true, -- convert tabs to spaces
shiftwidth = 2, -- the number of spaces inserted for each indentation
tabstop = 2, -- insert 2 spaces for a tab
scrolloff = 8,
@ -25,6 +25,7 @@ local options = {
mousemodel = "popup_setpos",
shell = "/usr/bin/zsh",
autochdir = true,
lazyredraw = true,
}
vim.g.mkdp_browser = '/usr/bin/firefox'

View file

@ -55,5 +55,6 @@ Plug('lvimuser/lsp-inlayhints.nvim') -- inlay hints
Plug('preservim/tagbar') -- tags on the right
Plug('ggandor/leap.nvim') -- special movement
Plug('brenoprata10/nvim-highlight-colors') -- colors
Plug('karb94/neoscroll.nvim')
vim.call("plug#end")