Updated config

This commit is contained in:
2024-03-03 17:47:02 +01:00
parent 4ac1314fad
commit acfceb3c65
18 changed files with 207 additions and 87 deletions

View File

@ -1,9 +1,6 @@
return {
"neovim/nvim-lspconfig",
event = { "BufReadPre", "BufNewFile" },
dependencies = {
"folke/neodev.nvim",
},
opts = {
servers = {
clangd = {},
@ -12,8 +9,18 @@ return {
lua_ls = {
settings = {
Lua = {
completion = {
callSnippet = "Replace",
},
runtime = {
version = "LuaJIT",
},
workspace = {
checkThirdParty = false,
library = {
"${3rd}/luv/library",
unpack(vim.api.nvim_get_runtime_file("", true)),
},
},
},
},
@ -21,8 +28,6 @@ return {
},
},
config = function(_, opts)
require("neodev").setup()
-- Servers
local servers = opts.servers
@ -42,5 +47,37 @@ return {
name = "DiagnosticSign" .. name
vim.fn.sign_define(name, { text = icon, texthl = name, numhl = "" })
end
-- 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,
})
end,
}