dotfiles/symlinks/config/nvim/lua/lsp/servers.lua

75 lines
2.7 KiB
Lua
Raw Normal View History

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)
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-05-29 21:31:39 +00:00
local servers = { "bashls", "clangd", "jsonls", "pyright", "rust_analyzer", "kotlin_language_server", "vimls", "clojure_lsp", "gopls", "gdscript" }
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
-- JDTLS (Java)
local jdstls_on_attach = function(client, bufnr)
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
require('jdtls').start_or_attach {
cmd = {'jdtls-startup.sh'};
on_attach = jdstls_on_attach;
}