This repository has been archived on 2024-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/common/neovim/lua/lsp.lua

93 lines
3.2 KiB
Lua
Raw Normal View History

2022-04-15 12:52:46 -05:00
local lsp = require 'lspconfig'
2022-03-09 11:50:01 -06:00
-- local coq = require'coq'
2021-06-11 21:32:54 -05:00
2022-03-09 11:50:01 -06:00
-- TODO: replace with nvim lsp bindings for jumping to next linting issue?
--vim.api.nvim_set_keymap('n', '[d', '<cmd>)<CR>', opts)
2021-06-11 21:32:54 -05:00
2022-03-09 11:50:01 -06:00
local opts = {
noremap = true,
silent = true,
}
2021-06-11 21:32:54 -05:00
2022-04-15 12:52:46 -05:00
local lsp_format = require 'lsp-format'
2022-03-28 09:57:47 -05:00
local on_attach = function(client, bufnr)
lsp_format.on_attach(client)
2022-03-09 11:50:01 -06:00
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>e', '<cmd>lua vim.diagnostic.open_float()<cr>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'g]', '<cmd>lua vim.diagnostic.goto_next()<cr>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'g[', '<cmd>lua vim.diagnostic.goto_prev()<cr>', opts)
2021-06-11 21:32:54 -05:00
2022-04-15 12:52:46 -05:00
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<C-a>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'i', '<C-a>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>f', '<cmd>lua vim.lsp.buf.formatting_seq_sync()<CR>', opts)
2021-06-11 21:32:54 -05:00
end
2022-04-15 12:52:46 -05:00
local capabilities = require 'cmp_nvim_lsp'.update_capabilities(vim.lsp.protocol.make_client_capabilities())
2022-03-09 11:50:01 -06:00
local common_config = {
2022-04-15 12:52:46 -05:00
capabilities = capabilities,
2022-03-09 11:50:01 -06:00
on_attach = on_attach,
flags = {
debounce_text_changes = 150
},
}
2021-06-11 21:32:54 -05:00
--[[
2022-05-25 11:38:52 -05:00
set els_path ~/.local/share/nvim/lsp_servers/elixir
curl -fLO https://github.com/elixir-lsp/elixir-ls/releases/latest/download/elixir-ls.zip
2022-05-25 11:38:52 -05:00
mkdir -p $els_path
unzip elixir-ls.zip -d $els_path/elixir-ls/
chmod +x $els_path/elixir-ls/language_server.sh
]]
2022-03-09 11:50:01 -06:00
local lsp_configs = {
2022-03-28 09:57:47 -05:00
gopls = {},
2022-03-09 11:50:01 -06:00
elixirls = {
2022-04-15 12:52:46 -05:00
cmd = { vim.fn.expand '~/.local/share/nvim/lsp_servers/elixir/elixir-ls/language_server.sh' },
settings = {
elixirLS = {
dialyzerEnabled = true,
fetchDeps = false,
}
}
2022-03-09 11:50:01 -06:00
},
2022-03-09 12:54:46 -06:00
sumneko_lua = {
settings = {
Lua = {
diagnostics = {
2022-04-15 12:52:46 -05:00
globals = { 'vim' }
2022-03-09 12:54:46 -06:00
}
}
}
},
2022-03-09 11:50:01 -06:00
vimls = {},
rust_analyzer = {},
2022-05-25 11:38:52 -05:00
-- tsserver = {},
2022-04-12 10:56:01 -05:00
pylsp = {},
2022-03-28 09:47:54 -05:00
denols = {
root_dir = lsp.util.root_pattern("deno.json"),
},
2021-06-11 21:32:54 -05:00
}
2022-03-09 11:50:01 -06:00
for server, config in pairs(lsp_configs) do
2022-04-15 12:52:46 -05:00
for k, v in pairs(common_config) do config[k] = v end
2022-03-09 11:50:01 -06:00
lsp[server].setup(config)
end
2021-06-11 21:32:54 -05:00
2022-05-23 21:04:16 -05:00
require'nvim-lsp-installer'.setup{
automatic_installation = true,
}