From de47bd1caa2f798ccc168e883277dded018701a9 Mon Sep 17 00:00:00 2001 From: Roman Date: Sun, 21 Jun 2026 23:37:15 +0200 Subject: [PATCH] minimal lsp --- nvim/.config/nvim/lua/romanzy/plugins.lua | 1 + nvim/.config/nvim/lua/romanzy/plugins/lsp.lua | 102 ++++++++++++++++++ nvim/.config/nvim/nvim-pack-lock.json | 12 +++ 3 files changed, 115 insertions(+) create mode 100644 nvim/.config/nvim/lua/romanzy/plugins/lsp.lua diff --git a/nvim/.config/nvim/lua/romanzy/plugins.lua b/nvim/.config/nvim/lua/romanzy/plugins.lua index 3ae6e93..4147ff7 100644 --- a/nvim/.config/nvim/lua/romanzy/plugins.lua +++ b/nvim/.config/nvim/lua/romanzy/plugins.lua @@ -1,2 +1,3 @@ require("romanzy.plugins.rose-pine") require("romanzy.plugins.nvim-treesitter") +require("romanzy.plugins.lsp") diff --git a/nvim/.config/nvim/lua/romanzy/plugins/lsp.lua b/nvim/.config/nvim/lua/romanzy/plugins/lsp.lua new file mode 100644 index 0000000..8bcef25 --- /dev/null +++ b/nvim/.config/nvim/lua/romanzy/plugins/lsp.lua @@ -0,0 +1,102 @@ +vim.pack.add({ + { + src = "https://github.com/mason-org/mason.nvim", + name = "mason.nvim", + }, + { + src = "https://github.com/mason-org/mason-lspconfig.nvim", + name = "mason-lspconfig.nvim", + }, + { + src = "https://github.com/neovim/nvim-lspconfig", + name = "nvim-lspconfig", + }, +}) + +local mason_lspconfig = require("mason-lspconfig") + +vim.opt.completeopt = { "menu", "menuone", "noselect", "popup", "fuzzy" } + +vim.diagnostic.config({ + severity_sort = true, + signs = true, + underline = true, + update_in_insert = false, + virtual_text = false, + float = { + border = "rounded", + source = "if_many", + }, +}) + +vim.api.nvim_create_autocmd("LspAttach", { + callback = function(ev) + local client = vim.lsp.get_client_by_id(ev.data.client_id) + if not client then + return + end + + vim.lsp.completion.enable(true, client.id, ev.buf, { + autotrigger = true, + }) + + if client:supports_method("textDocument/inlayHint") then + vim.lsp.inlay_hint.enable(true, { bufnr = ev.buf }) + end + + local opts = { buffer = ev.buf } + vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) + vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts) + vim.keymap.set("n", "grd", vim.lsp.buf.references, opts) + vim.keymap.set("n", "e", vim.diagnostic.open_float, opts) + vim.keymap.set("n", "q", vim.diagnostic.setloclist, opts) + end, +}) + +local capabilities = vim.lsp.protocol.make_client_capabilities() +local managed_servers = { + "bashls", + "clangd", + "jsonls", + "lua_ls", + "marksman", + "taplo", + "ts_ls", + "yamlls", +} +local servers = { + bashls = {}, + clangd = {}, + jsonls = {}, + marksman = {}, + taplo = {}, + ts_ls = {}, + yamlls = {}, + lua_ls = { + settings = { + Lua = { + diagnostics = { + globals = { "vim" }, + }, + runtime = { + version = "LuaJIT", + }, + workspace = { + checkThirdParty = false, + library = vim.api.nvim_get_runtime_file("", true), + }, + }, + }, + }, +} + +for server_name, config in pairs(servers) do + config.capabilities = vim.tbl_deep_extend("force", {}, capabilities, config.capabilities or {}) + vim.lsp.config(server_name, config) +end + +require("mason").setup() + +mason_lspconfig.setup({ + automatic_enable = managed_servers, +}) diff --git a/nvim/.config/nvim/nvim-pack-lock.json b/nvim/.config/nvim/nvim-pack-lock.json index 49a2fd5..3087ebb 100644 --- a/nvim/.config/nvim/nvim-pack-lock.json +++ b/nvim/.config/nvim/nvim-pack-lock.json @@ -1,5 +1,17 @@ { "plugins": { + "mason-lspconfig.nvim": { + "rev": "21c5b3ebeaa0412e28096bb0701434c51c1fbf76", + "src": "https://github.com/mason-org/mason-lspconfig.nvim" + }, + "mason.nvim": { + "rev": "2a6940af80375532e5e9e7c1f2fc6319a1b7a69d", + "src": "https://github.com/mason-org/mason.nvim" + }, + "nvim-lspconfig": { + "rev": "bfcc0171a43f22afa61d927ffe9fcb6cb85dc99e", + "src": "https://github.com/neovim/nvim-lspconfig" + }, "nvim-treesitter": { "rev": "4916d6592ede8c07973490d9322f187e07dfefac", "src": "https://github.com/nvim-treesitter/nvim-treesitter"