2021-02-23 11:27:32 +00:00
|
|
|
-------------------------------------------------------------------------------
|
|
|
|
-- - LSP servers configuration -
|
|
|
|
-------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
local lspconfig = require("lspconfig")
|
|
|
|
|
|
|
|
local on_attach = function(client, bufnr)
|
2021-02-24 14:13:56 +00:00
|
|
|
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
|
|
|
|
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
|
|
|
|
|
|
|
|
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
|
|
|
|
2021-03-17 19:34:03 +00:00
|
|
|
local default_opts = {noremap = true, silent = true}
|
2021-02-24 14:13:56 +00:00
|
|
|
|
|
|
|
-- Lsp keymaps
|
|
|
|
buf_set_keymap('n', '<C-]>', '<cmd>lua vim.lsp.buf.definition()<CR>', default_opts)
|
|
|
|
buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', default_opts)
|
|
|
|
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', default_opts)
|
2021-06-11 11:15:36 +00:00
|
|
|
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', default_opts)
|
2021-02-24 14:13:56 +00:00
|
|
|
buf_set_keymap('n', '<Leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', default_opts)
|
|
|
|
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', default_opts)
|
|
|
|
buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', default_opts)
|
|
|
|
buf_set_keymap('n', '<A-CR>', '<cmd>lua vim.lsp.buf.code_action()<CR>', default_opts)
|
|
|
|
buf_set_keymap('n', '<Leader>ac', '<cmd>lua vim.lsp.buf.code_action()<CR>', default_opts)
|
|
|
|
buf_set_keymap('n', '<Leader>a', '<cmd>lua vim.lsp.buf.code_action_range()<CR>', default_opts)
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Lsp default language servers
|
2021-09-29 20:45:40 +00:00
|
|
|
local servers = { "bashls", "clangd", "cucumber_language_server", "crystalline", "dockerls", "jsonls", "pyright", "rust_analyzer", "kotlin_language_server", "mint", "vimls", "clojure_lsp", "gopls", "gdscript", "terraformls", "tsserver" }
|
2021-02-24 14:13:56 +00:00
|
|
|
for _, lsp in ipairs(servers) do
|
|
|
|
lspconfig[lsp].setup { on_attach = on_attach }
|
2021-02-23 11:27:32 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
-- Lua bultin lsp
|
2021-03-05 10:08:05 +00:00
|
|
|
require('nlua.lsp.nvim').setup(lspconfig, {
|
|
|
|
on_attach = on_attach,
|
2021-02-23 11:27:32 +00:00
|
|
|
|
2021-03-05 10:08:05 +00:00
|
|
|
-- Include globals you want to tell the LSP are real :)
|
2021-03-17 19:34:03 +00:00
|
|
|
globals = {}
|
2021-03-05 10:08:05 +00:00
|
|
|
})
|
2021-03-17 19:34:03 +00:00
|
|
|
|
|
|
|
-- Flutter tools
|
|
|
|
require('flutter-tools').setup {
|
|
|
|
lsp = {
|
|
|
|
on_attach = on_attach
|
|
|
|
}
|
|
|
|
}
|
2021-04-07 19:50:46 +00:00
|
|
|
|
|
|
|
-- Dotnet LS
|
|
|
|
local pid = vim.fn.getpid()
|
|
|
|
local omnisharp_bin = vim.fn.glob('$HOME') .. "/lsp/dotnet/omnisharp/run"
|
|
|
|
lspconfig.omnisharp.setup {
|
|
|
|
cmd = { omnisharp_bin, "--languageserver" , "--hostPID", tostring(pid) };
|
|
|
|
on_attach = on_attach;
|
|
|
|
}
|
2021-06-11 10:20:00 +00:00
|
|
|
|
2021-09-29 15:39:19 +00:00
|
|
|
-- Leminx (XML Language server)
|
|
|
|
lspconfig.lemminx.setup {
|
|
|
|
cmd = { "lemminx" };
|
|
|
|
on_attach = on_attach;
|
|
|
|
}
|
|
|
|
|
2021-06-11 10:20:00 +00:00
|
|
|
-- JDTLS (Java)
|
2021-06-11 11:00:32 +00:00
|
|
|
-- Can't be local currently, because autocommand has to be used
|
|
|
|
jdtls_on_attach = function(client, bufnr)
|
2021-06-11 10:20:00 +00:00
|
|
|
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
|
|
|
|
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
|
|
|
|
|
|
|
|
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
|
|
|
|
|
|
|
local default_opts = {noremap = true, silent = true}
|
|
|
|
|
|
|
|
on_attach(client, bufnr)
|
|
|
|
|
|
|
|
buf_set_keymap('n', '<A-CR>', "<cmd>lua require('jdtls').code_action()<CR>", default_opts)
|
|
|
|
buf_set_keymap('n', '<Leader>ac', "<cmd>lua require('jdtls').code_action()<CR>", default_opts)
|
|
|
|
end
|
2021-06-11 11:15:36 +00:00
|
|
|
|
|
|
|
return {
|
|
|
|
jdtls_on_attach = jdtls_on_attach
|
|
|
|
}
|