feat(config): add ability to add custom lsp server options
This commit is contained in:
parent
f4e75710ea
commit
8dde6a3f09
2 changed files with 18 additions and 4 deletions
|
@ -35,12 +35,20 @@ config.lsp = {
|
||||||
-- enable/disable server + formatting
|
-- enable/disable server + formatting
|
||||||
eslint = false,
|
eslint = false,
|
||||||
|
|
||||||
-- enable non-default servers (todo: support for custom server configs)
|
-- enable non-default servers, use default lsp config
|
||||||
|
-- check here for configs that will be used: https://github.com/williamboman/nvim-lsp-installer/tree/main/lua/nvim-lsp-installer/servers
|
||||||
rust_analyzer = true,
|
rust_analyzer = true,
|
||||||
|
|
||||||
tsserver = {
|
tsserver = {
|
||||||
-- disable formatting
|
-- disable formatting
|
||||||
format = false,
|
format = false,
|
||||||
|
-- OR add/override server options
|
||||||
|
opts = {
|
||||||
|
on_attach = function(client, bufnr) end,
|
||||||
|
flags = {
|
||||||
|
debounce_text_changes = 150,
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
efm = {
|
efm = {
|
||||||
|
|
|
@ -51,17 +51,16 @@ for _, requested_server in pairs(requested_servers) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- print(vim.inspect(requested_servers))
|
|
||||||
-- print(vim.inspect(disabled_servers))
|
|
||||||
|
|
||||||
lsp_installer.on_server_ready(function(server)
|
lsp_installer.on_server_ready(function(server)
|
||||||
local opts = default_config
|
local opts = default_config
|
||||||
|
|
||||||
|
-- disable server if config disabled server list says so
|
||||||
opts.autostart = true
|
opts.autostart = true
|
||||||
if vim.tbl_contains(disabled_servers, server.name) then
|
if vim.tbl_contains(disabled_servers, server.name) then
|
||||||
opts.autostart = false
|
opts.autostart = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- set up default cosmic options
|
||||||
if server.name == 'tsserver' then
|
if server.name == 'tsserver' then
|
||||||
opts = vim.tbl_deep_extend('force', opts, require('cosmic.lsp.providers.tsserver'))
|
opts = vim.tbl_deep_extend('force', opts, require('cosmic.lsp.providers.tsserver'))
|
||||||
elseif server.name == 'efm' then
|
elseif server.name == 'efm' then
|
||||||
|
@ -72,6 +71,13 @@ lsp_installer.on_server_ready(function(server)
|
||||||
opts = vim.tbl_deep_extend('force', opts, require('cosmic.lsp.providers.eslint'))
|
opts = vim.tbl_deep_extend('force', opts, require('cosmic.lsp.providers.eslint'))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- override options if user definds them
|
||||||
|
if config.lsp.servers[server.name] then
|
||||||
|
if config.lsp.servers[server.name].opts ~= nil then
|
||||||
|
opts = config.lsp.servers[server.name].opts
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- This setup() function is exactly the same as lspconfig's setup function (:help lspconfig-quickstart)
|
-- This setup() function is exactly the same as lspconfig's setup function (:help lspconfig-quickstart)
|
||||||
server:setup(opts)
|
server:setup(opts)
|
||||||
vim.cmd([[ do User LspAttachBuffers ]])
|
vim.cmd([[ do User LspAttachBuffers ]])
|
||||||
|
|
Loading…
Add table
Reference in a new issue