2022-08-23 19:22:35 +03:00
|
|
|
-- Pairs of server name and settings.
|
|
|
|
-- This is iterated through and every
|
|
|
|
-- server is setup with lspconfig
|
|
|
|
Servers = {
|
|
|
|
html = {},
|
|
|
|
jsonls = {},
|
|
|
|
lemminx = {},
|
|
|
|
marksman = {},
|
|
|
|
yamlls = {},
|
2022-08-26 13:10:03 +03:00
|
|
|
taplo = {},
|
2022-08-23 19:22:35 +03:00
|
|
|
tsserver = {},
|
|
|
|
sumneko_lua = {
|
|
|
|
Lua = {
|
|
|
|
runtime = {
|
|
|
|
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
|
2022-08-24 00:01:06 +03:00
|
|
|
version = 'LuaJIT'
|
2022-08-23 19:22:35 +03:00
|
|
|
},
|
|
|
|
diagnostics = {
|
|
|
|
-- Get the language server to recognize the `vim` global
|
|
|
|
globals = {'vim'}
|
|
|
|
},
|
|
|
|
workspace = {
|
|
|
|
-- Make the server aware of Neovim runtime files
|
|
|
|
library = vim.api.nvim_get_runtime_file('', true)
|
|
|
|
},
|
|
|
|
-- Do not send telemetry data containing a randomized but unique identifier
|
|
|
|
telemetry = {enable = false}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-23 19:14:09 +03:00
|
|
|
M = {}
|
2022-08-23 17:56:24 +03:00
|
|
|
|
2022-08-24 00:01:06 +03:00
|
|
|
function M.map_keys()
|
|
|
|
-- Register keybindings via which-key
|
|
|
|
-- to get documentation in which-key
|
|
|
|
local wk = require('which-key')
|
|
|
|
wk.register({
|
|
|
|
g = {
|
|
|
|
name = "Go to",
|
|
|
|
d = {vim.lsp.buf.definition, "Definition"},
|
|
|
|
D = {vim.lsp.buf.declaration, "Declaration"},
|
|
|
|
i = {vim.lsp.buf.implementation, "Implementation"},
|
|
|
|
r = {vim.lsp.buf.references, "References"}
|
|
|
|
},
|
|
|
|
['<leader>'] = {
|
|
|
|
name = "Leader",
|
|
|
|
w = {
|
|
|
|
name = "Workspace",
|
|
|
|
a = {vim.lsp.buf.add_workspace_folder, "Add folder"},
|
|
|
|
r = {vim.lsp.buf.remove_workspace_folder, "Remove folder"},
|
|
|
|
l = {
|
|
|
|
function()
|
|
|
|
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
|
|
|
end, "List folders"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
D = {vim.lsp.buf.type_definition, "Type definition"},
|
|
|
|
rn = {vim.lsp.buf.rename, "Rename symbol"},
|
|
|
|
ca = {vim.lsp.buf.code_action, "Code action"},
|
|
|
|
e = {vim.diagnostic.open_float, "Open diagnostics"},
|
|
|
|
f = {vim.lsp.buf.format, "Format"}
|
|
|
|
},
|
|
|
|
K = {vim.lsp.buf.hover, "Hover"},
|
|
|
|
['['] = {d = {vim.diagnostic.goto_prev, "Previous diagnostic"}},
|
|
|
|
[']'] = {d = {vim.diagnostic.goto_next, "Next diagnostic"}}
|
2022-08-23 17:56:24 +03:00
|
|
|
|
2022-08-24 00:01:06 +03:00
|
|
|
})
|
2022-08-23 17:56:24 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
function M.setup()
|
|
|
|
|
2022-08-24 00:01:06 +03:00
|
|
|
local function on_attach()
|
2022-08-23 19:14:09 +03:00
|
|
|
-- Setup lsp signature plugin
|
|
|
|
require('lsp_signature').setup {}
|
2022-08-23 17:56:24 +03:00
|
|
|
|
2022-08-23 19:14:09 +03:00
|
|
|
-- Setup keybinds
|
2022-08-24 00:01:06 +03:00
|
|
|
M.map_keys()
|
2022-08-23 19:14:09 +03:00
|
|
|
end
|
2022-08-23 17:56:24 +03:00
|
|
|
|
2022-08-24 00:01:06 +03:00
|
|
|
-- Update capabilities
|
|
|
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
|
|
|
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
|
|
|
|
|
2022-08-23 19:14:09 +03:00
|
|
|
-- Setup every defined server
|
2022-08-23 19:22:35 +03:00
|
|
|
for server, settings in pairs(Servers) do
|
2022-08-23 19:14:09 +03:00
|
|
|
require('lspconfig')[server].setup {
|
|
|
|
on_attach = on_attach,
|
|
|
|
settings = settings,
|
2022-08-24 00:01:06 +03:00
|
|
|
-- Inform lsp server about client
|
|
|
|
-- capabilities
|
|
|
|
capabilities = capabilities
|
2022-08-23 19:14:09 +03:00
|
|
|
}
|
|
|
|
end
|
2022-08-23 17:56:24 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
return M
|