nvim: lsp: Refactor configuration setting for clients

This commit is contained in:
Sanchayan Maity 2022-05-05 21:00:25 +05:30
parent 223ffe7505
commit ef00957fae

View file

@ -199,58 +199,49 @@ local rust_tool_opts = {
}, },
} }
nvim_lsp.clangd.setup { require('rust-tools').setup(rust_tool_opts)
on_init = on_init,
on_attach = on_attach,
capabilities = capabilities,
default_config = {
cmd = { "clangd", "--background-index", "--pch-storage=memory", "--clang-tidy", "--suggest-missing-includes", "--header-insertion=never" },
filetypes = { 'c', 'cpp' },
root_dir = function(fname)
-- We specify build/compile_commands.json as that is where the compile_commands.json
-- gets generated automatically for meson projects.
local root_pattern = util.root_pattern('build/compile_commands.json', 'compile_commands.json', 'compile_flags.txt', '.git')
local filename = util.path.is_absolute(fname) and fname or util.path.join(vim.loop.cwd(), fname)
return root_pattern(filename) or util.path.dirname(filename)
end,
}
}
nvim_lsp.hls.setup { local servers = {
on_init = on_init, clangd = {
on_attach = on_attach, default_config = {
capabilities = capabilities cmd = { "clangd", "--background-index", "--pch-storage=memory", "--clang-tidy", "--suggest-missing-includes", "--header-insertion=never" },
} filetypes = { 'c', 'cpp' },
root_dir = function(fname)
nvim_lsp.jedi_language_server.setup { -- We specify build/compile_commands.json as that is where the compile_commands.json
on_init = on_init, -- gets generated automatically for meson projects.
on_attach = on_attach, local root_pattern = util.root_pattern('build/compile_commands.json', 'compile_commands.json', 'compile_flags.txt', '.git')
capabilities = capabilities, local filename = util.path.is_absolute(fname) and fname or util.path.join(vim.loop.cwd(), fname)
init_options = { return root_pattern(filename) or util.path.dirname(filename)
completion = { end,
resolveEagerly = true, }
}, },
jediSettings = { eslint = {},
caseInsensitiveCompletion = false, hls = {},
}, jedi_language_server = {
workspace = { init_options = {
symbols = { completion = {
maxSymbols = 50 resolveEagerly = true,
},
jediSettings = {
caseInsensitiveCompletion = false,
},
workspace = {
symbols = {
maxSymbols = 50
},
}, },
}, },
}, },
tsserver = {},
} }
require('rust-tools').setup(rust_tool_opts) for client, config in pairs(servers) do
config.on_init = on_init
nvim_lsp.tsserver.setup { config.on_attach = on_attach
on_init = on_init, config.capabilities = vim.tbl_deep_extend(
on_attach = on_attach, 'keep',
capabilities = capabilities, config.capabilities or {},
} capabilities
)
nvim_lsp.eslint.setup { nvim_lsp[client].setup(config)
on_init = on_init, end
on_attach = on_attach,
capabilities = capabilities
}