2023-11-30 15:59:49 +00:00
|
|
|
require("lsp-format").setup({})
|
2023-10-30 20:37:23 +00:00
|
|
|
|
2023-11-10 10:20:35 +00:00
|
|
|
local on_attach = function(client, bufnr)
|
2023-11-30 15:59:49 +00:00
|
|
|
local bufmap = function(keys, func)
|
|
|
|
vim.keymap.set("n", keys, func, { buffer = bufnr })
|
|
|
|
end
|
2023-10-30 20:37:23 +00:00
|
|
|
|
2023-11-30 15:59:49 +00:00
|
|
|
bufmap("<leader>r", vim.lsp.buf.rename)
|
|
|
|
bufmap("<leader>a", vim.lsp.buf.code_action)
|
2023-10-30 20:37:23 +00:00
|
|
|
|
2023-11-30 15:59:49 +00:00
|
|
|
bufmap("gd", vim.lsp.buf.definition)
|
|
|
|
bufmap("gD", vim.lsp.buf.declaration)
|
|
|
|
bufmap("gI", vim.lsp.buf.implementation)
|
|
|
|
bufmap("<leader>D", vim.lsp.buf.type_definition)
|
2023-10-30 20:37:23 +00:00
|
|
|
|
2023-11-30 15:59:49 +00:00
|
|
|
bufmap("gr", require("telescope.builtin").lsp_references)
|
|
|
|
bufmap("<leader>s", require("telescope.builtin").lsp_document_symbols)
|
|
|
|
bufmap("<leader>S", require("telescope.builtin").lsp_dynamic_workspace_symbols)
|
2023-10-30 20:37:23 +00:00
|
|
|
|
2023-11-30 15:59:49 +00:00
|
|
|
bufmap("K", vim.lsp.buf.hover)
|
2023-10-30 20:37:23 +00:00
|
|
|
|
2023-11-30 15:59:49 +00:00
|
|
|
vim.api.nvim_buf_create_user_command(bufnr, "Format", function(_)
|
|
|
|
vim.lsp.buf.format()
|
|
|
|
end, {})
|
2023-10-30 20:37:23 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
2023-11-30 15:59:49 +00:00
|
|
|
capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities)
|
|
|
|
|
|
|
|
require("neodev").setup()
|
|
|
|
require("lspconfig").nil_ls.setup({
|
|
|
|
on_attach = on_attach,
|
|
|
|
capabilities = capabilities,
|
|
|
|
})
|
|
|
|
require("lspconfig").pyright.setup({
|
|
|
|
on_attach = on_attach,
|
|
|
|
capabilities = capabilities,
|
|
|
|
})
|
|
|
|
require("lspconfig").gopls.setup({
|
|
|
|
on_attach = on_attach,
|
|
|
|
capabilities = capabilities,
|
|
|
|
})
|
|
|
|
require("lspconfig").terraformls.setup({
|
|
|
|
on_attach = on_attach,
|
|
|
|
capabilities = capabilities,
|
|
|
|
})
|
|
|
|
|
|
|
|
-- require'lspconfig'.efm.setup {
|
|
|
|
-- on_attach = require("lsp-format").on_attach,
|
|
|
|
-- init_options = {documentFormatting = true},
|
|
|
|
-- settings = {
|
|
|
|
-- languages = {
|
|
|
|
-- lua = {{formatCommand = "lua-format -i", formatStdin = true}},
|
|
|
|
-- nix = {{formatCommand = "nixfmt", formatStdin = true}}
|
|
|
|
-- }
|
|
|
|
-- },
|
|
|
|
-- filetypes = {"lua", "nix"}
|
|
|
|
-- }
|