dotfiles/.config/nvim/lua/plugins/lspconfig.lua

46 lines
2.1 KiB
Lua
Raw Normal View History

2024-03-17 12:32:47 +00:00
local lspconfig = require("lspconfig")
2022-12-13 15:43:36 +00:00
-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
2024-03-17 12:32:47 +00:00
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("UserLspConfig", {}),
callback = function(ev)
-- Enable completion triggered by <c-x><c-o>
vim.bo[ev.buf].omnifunc = "v:lua.vim.lsp.omnifunc"
vim.opt_local.signcolumn = numbers
2024-05-26 16:18:00 +01:00
local fzflua = require("fzf-lua")
2024-03-17 12:32:47 +00:00
local conform = require("conform")
2022-10-19 00:47:07 +01:00
2024-03-30 16:08:40 +00:00
local client = vim.lsp.get_client_by_id(ev.data.client_id)
client.server_capabilities.semanticTokensProvider = nil
2024-03-17 12:32:47 +00:00
-- Mappings.
local bufopts = { noremap = true, silent = true, buffer = ev.buf }
vim.keymap.set("n", "<space>e", vim.diagnostic.open_float, bufopts)
vim.keymap.set("n", "<space>q", vim.diagnostic.setloclist, bufopts)
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, bufopts)
2024-05-26 16:18:00 +01:00
vim.keymap.set("n", "gd", vim.lsp.buf.definition, bufopts)
vim.keymap.set("n", "gr", fzflua.lsp_references, bufopts)
2024-03-17 12:32:47 +00:00
vim.keymap.set("n", "K", vim.lsp.buf.hover, bufopts)
2024-05-26 16:18:00 +01:00
vim.keymap.set("n", "gi", fzflua.lsp_implementations, bufopts)
vim.keymap.set("n", "<space>k", vim.lsp.buf.signature_help, bufopts)
2024-03-17 12:32:47 +00:00
vim.keymap.set("n", "<space>D", vim.lsp.buf.type_definition, bufopts)
vim.keymap.set("n", "<space>rn", vim.lsp.buf.rename, bufopts)
vim.keymap.set("n", "<space>ca", vim.lsp.buf.code_action, bufopts)
2024-05-26 16:18:00 +01:00
vim.keymap.set("n", "<space>ge", vim.diagnostic.goto_next, bufopts)
vim.keymap.set("n", "<space>gE", vim.diagnostic.goto_prev, bufopts)
2024-03-17 12:32:47 +00:00
vim.keymap.set("n", "<space>fo", function() conform.format({ lsp_fallback = true }) end, bufopts)
end,
})
2022-10-19 00:47:07 +01:00
-- ADD NVIM CMP AS A CAPABILITY
local lsp_defaults = lspconfig.util.default_config
2024-03-17 12:32:47 +00:00
local capabilities =
vim.tbl_deep_extend("force", lsp_defaults.capabilities, require("cmp_nvim_lsp").default_capabilities())
2022-12-13 15:43:36 +00:00
2024-03-30 16:08:40 +00:00
lspconfig["hls"].setup({
capabilities = capabilities,
filetypes = { 'haskell', 'lhaskell', 'cabal' },
2024-03-17 12:32:47 +00:00
})