2023-12-28 18:15:39 +01:00
|
|
|
local on_attach = function(_, bufnr)
|
|
|
|
local bufmap = function(keys, func)
|
|
|
|
vim.keymap.set("n", keys, func, { buffer = bufnr })
|
|
|
|
end
|
|
|
|
|
|
|
|
bufmap("<leader>r", vim.lsp.buf.rename)
|
|
|
|
bufmap("<leader>a", vim.lsp.buf.code_action)
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
bufmap("K", vim.lsp.buf.hover)
|
|
|
|
|
|
|
|
vim.api.nvim_buf_create_user_command(bufnr, "Format", function(_)
|
|
|
|
vim.lsp.buf.format()
|
|
|
|
end, {})
|
|
|
|
end
|
|
|
|
|
|
|
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
|
|
|
capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities)
|
|
|
|
|
|
|
|
require("lspconfig").lua_ls.setup({
|
|
|
|
on_attach = on_attach,
|
|
|
|
capabilities = capabilities,
|
|
|
|
root_dir = function()
|
|
|
|
return vim.loop.cwd()
|
|
|
|
end,
|
|
|
|
settings = {
|
|
|
|
Lua = {
|
|
|
|
workspace = { checkThirdParty = false },
|
|
|
|
telemetry = { enable = false },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
2024-05-01 14:10:56 +02:00
|
|
|
require("lspconfig").nixd.setup({
|
2023-12-28 18:15:39 +01:00
|
|
|
on_attach = on_attach,
|
|
|
|
capabilities = capabilities,
|
|
|
|
})
|
2024-05-24 13:58:42 +02:00
|
|
|
|
2024-12-02 20:15:01 +01:00
|
|
|
require("lspconfig").ts_lsp.setup({
|
2024-05-24 13:58:42 +02:00
|
|
|
on_attach = on_attach,
|
|
|
|
capabilities = capabilities,
|
|
|
|
})
|
|
|
|
|
|
|
|
require("lspconfig").eslint.setup({
|
|
|
|
settings = {
|
|
|
|
packageManager = "yarn",
|
|
|
|
},
|
|
|
|
on_attach = function(client, bufnr)
|
|
|
|
vim.api.nvim_create_autocmd("BufWritePre", {
|
|
|
|
buffer = bufnr,
|
|
|
|
command = "EslintFixAll",
|
|
|
|
})
|
|
|
|
vim.api.nvim_create_autocmd("BufWritePost", {
|
|
|
|
callback = function()
|
|
|
|
vim.lsp.buf.format()
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
end,
|
|
|
|
})
|
2024-11-17 15:19:54 +01:00
|
|
|
|
|
|
|
require("lspconfig").clangd.setup({
|
|
|
|
on_attach = function(client, bufnr)
|
|
|
|
client.server_capabilities.signatureHelpProvider = false
|
|
|
|
on_attach(client, bufnr)
|
|
|
|
end,
|
|
|
|
capabilities = capabilities,
|
|
|
|
})
|