fix: improve nvim performance
This commit is contained in:
parent
670014885b
commit
fdcb340766
7 changed files with 115 additions and 173 deletions
|
|
@ -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,
|
||||
})
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue