2023-08-19 17:22:56 +00:00
|
|
|
return {
|
2023-08-21 17:19:37 +00:00
|
|
|
"neovim/nvim-lspconfig",
|
|
|
|
event = { "BufReadPre", "BufNewFile" },
|
|
|
|
opts = {
|
|
|
|
servers = {
|
2023-10-20 13:55:21 +00:00
|
|
|
clangd = {},
|
2024-01-21 16:14:47 +00:00
|
|
|
gdscript = {},
|
2023-08-21 17:19:37 +00:00
|
|
|
gopls = {},
|
|
|
|
lua_ls = {
|
|
|
|
settings = {
|
|
|
|
Lua = {
|
2024-03-03 16:47:02 +00:00
|
|
|
completion = {
|
|
|
|
callSnippet = "Replace",
|
|
|
|
},
|
|
|
|
runtime = {
|
|
|
|
version = "LuaJIT",
|
|
|
|
},
|
2023-08-21 17:19:37 +00:00
|
|
|
workspace = {
|
|
|
|
checkThirdParty = false,
|
2024-03-03 16:47:02 +00:00
|
|
|
library = {
|
|
|
|
"${3rd}/luv/library",
|
|
|
|
unpack(vim.api.nvim_get_runtime_file("", true)),
|
|
|
|
},
|
2023-08-21 17:19:37 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2023-08-19 17:22:56 +00:00
|
|
|
},
|
2024-03-25 12:55:15 +00:00
|
|
|
rust_analyzer = {
|
|
|
|
settings = {
|
|
|
|
["rust-analyzer"] = {
|
|
|
|
imports = {
|
|
|
|
granularity = {
|
|
|
|
group = "module",
|
|
|
|
},
|
|
|
|
prefix = "self",
|
|
|
|
},
|
|
|
|
cargo = {
|
|
|
|
buildScripts = {
|
|
|
|
enable = true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
procMacro = {
|
|
|
|
enable = true
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2023-08-19 17:22:56 +00:00
|
|
|
},
|
2023-08-21 17:19:37 +00:00
|
|
|
},
|
|
|
|
config = function(_, opts)
|
|
|
|
-- Servers
|
|
|
|
local servers = opts.servers
|
|
|
|
|
|
|
|
for server, server_opts in pairs(servers) do
|
|
|
|
require("lspconfig")[server].setup(server_opts)
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Icons
|
|
|
|
local icons = {
|
|
|
|
Error = " ",
|
|
|
|
Warn = " ",
|
|
|
|
Hint = " ",
|
|
|
|
Info = " ",
|
|
|
|
}
|
2023-08-19 17:22:56 +00:00
|
|
|
|
2023-08-21 17:19:37 +00:00
|
|
|
for name, icon in pairs(icons) do
|
|
|
|
name = "DiagnosticSign" .. name
|
|
|
|
vim.fn.sign_define(name, { text = icon, texthl = name, numhl = "" })
|
|
|
|
end
|
2024-03-03 16:47:02 +00:00
|
|
|
|
|
|
|
-- Runs when the LSP is attached
|
|
|
|
vim.api.nvim_create_autocmd("LspAttach", {
|
|
|
|
group = vim.api.nvim_create_augroup("lsp-attach", { clear = true }),
|
|
|
|
callback = function(event)
|
|
|
|
local function map(mode, lhs, rhs, info)
|
|
|
|
vim.keymap.set(mode, lhs, rhs, { buffer = event.buf, desc = "LSP: " .. info })
|
|
|
|
end
|
|
|
|
|
|
|
|
map("n", "gr", require("telescope.builtin").lsp_references, "References")
|
|
|
|
map("n", "gd", require("telescope.builtin").lsp_definitions, "Definition")
|
|
|
|
map({ "n", "i" }, "<f1>", vim.lsp.buf.hover, "Hover")
|
|
|
|
map({ "n", "i" }, "<f2>", vim.lsp.buf.rename, "Rename")
|
|
|
|
map({ "n", "i" }, "<C-f>", vim.lsp.buf.format, "Format")
|
|
|
|
map("n", "<leader>ca", vim.lsp.buf.code_action, "Code action")
|
|
|
|
|
|
|
|
-- Highlight the word your cursor is on
|
|
|
|
-- local client = vim.lsp.get_client_by_id(event.data.client_id)
|
|
|
|
--
|
|
|
|
-- if client and client.server_capabilities.documentHighlightProvider then
|
|
|
|
-- vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
|
|
|
|
-- buffer = event.buf,
|
|
|
|
-- callback = vim.lsp.buf.document_highlight,
|
|
|
|
-- })
|
|
|
|
--
|
|
|
|
-- vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, {
|
|
|
|
-- buffer = event.buf,
|
|
|
|
-- callback = vim.lsp.buf.clear_references,
|
|
|
|
-- })
|
|
|
|
-- end
|
|
|
|
end,
|
|
|
|
})
|
2023-08-21 17:19:37 +00:00
|
|
|
end,
|
|
|
|
}
|