From c8f3d194b6c446d2c14c5406be49ad9f409deb34 Mon Sep 17 00:00:00 2001 From: erius Date: Tue, 3 Dec 2024 08:04:28 +0300 Subject: [PATCH] lsp updates --- .config/nvim/lazy-lock.json | 42 ++++++++++++++--------------- .config/nvim/lua/config/keymaps.lua | 3 +++ .config/nvim/lua/config/options.lua | 1 - .config/nvim/lua/plugins/lsp.lua | 32 +++++++++++++++++----- .config/nvim/lua/plugins/tree.lua | 8 +++--- 5 files changed, 54 insertions(+), 32 deletions(-) diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index 4dbb113..2fa4b0a 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -1,33 +1,33 @@ { "LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" }, - "bufferline.nvim": { "branch": "main", "commit": "2e3c8cc5a57ddd32f1edd2ffd2ccb10c09421f6c" }, + "bufferline.nvim": { "branch": "main", "commit": "5c528bee3dd797d5bd6bae5f229411939b25b203" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, - "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, - "conform.nvim": { "branch": "master", "commit": "f5bd8419f8a29451e20bdb1061a54fe13d5c8de3" }, - "friendly-snippets": { "branch": "main", "commit": "00ebcaa159e817150bd83bfe2d51fa3b3377d5c4" }, - "go.nvim": { "branch": "master", "commit": "8389adb56ab124b75d858df5f87b741eaca7b8b3" }, - "guihua.lua": { "branch": "master", "commit": "225db770e36aae6a1e9e3a65578095c8eb4038d3" }, - "langmapper.nvim": { "branch": "main", "commit": "62cc28b4ebc5f47e6d4a6b5dd478c93b812f7187" }, - "lazy.nvim": { "branch": "main", "commit": "48b52b5cfcf8f88ed0aff8fde573a5cc20b1306d" }, - "lualine.nvim": { "branch": "master", "commit": "b431d228b7bbcdaea818bdc3e25b8cdbe861f056" }, + "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, + "conform.nvim": { "branch": "master", "commit": "a203480a350b03092e473bf3001733d547160a73" }, + "friendly-snippets": { "branch": "main", "commit": "de8fce94985873666bd9712ea3e49ee17aadb1ed" }, + "go.nvim": { "branch": "master", "commit": "6368756601a358b1491ac2ff10d0e2939a76df5e" }, + "guihua.lua": { "branch": "master", "commit": "d783191eaa75215beae0c80319fcce5e6b3beeda" }, + "langmapper.nvim": { "branch": "main", "commit": "efeffd2a0add17ad04c69beb81b68329cd445eeb" }, + "lazy.nvim": { "branch": "main", "commit": "56ead98e05bb37a4ec28930a54d836d033cf00f2" }, + "lualine.nvim": { "branch": "master", "commit": "2a5bae925481f999263d6f5ed8361baef8df4f83" }, "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "482350b050bd413931c2cdd4857443c3da7d57cb" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "8e46de9241d3997927af12196bd8faa0ed08c29a" }, "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, - "nvim": { "branch": "main", "commit": "4fd72a9ab64b393c2c22b168508fd244877fec96" }, - "nvim-autopairs": { "branch": "master", "commit": "19606af7c039271d5aa96bceff101e7523af3136" }, - "nvim-cmp": { "branch": "main", "commit": "ae644feb7b67bf1ce4260c231d1d4300b19c6f30" }, - "nvim-lspconfig": { "branch": "master", "commit": "3ad562700d0615818bf358268ac8914f6ce2b079" }, - "nvim-neoclip.lua": { "branch": "main", "commit": "709c97fabec9da7d04f7d2f5e207423af8c02871" }, - "nvim-surround": { "branch": "main", "commit": "ec2dc7671067e0086cdf29c2f5df2dd909d5f71f" }, - "nvim-tree.lua": { "branch": "master", "commit": "ea55ef12036897fdc4476b115a395d2a34965c82" }, - "nvim-treesitter": { "branch": "master", "commit": "2d8f0f37c4056022b6643cbe8671319881f8b369" }, - "nvim-web-devicons": { "branch": "master", "commit": "3722e3d1fb5fe1896a104eb489e8f8651260b520" }, - "plenary.nvim": { "branch": "master", "commit": "ec289423a1693aeae6cd0d503bac2856af74edaa" }, + "nvim": { "branch": "main", "commit": "faf15ab0201b564b6368ffa47b56feefc92ce3f4" }, + "nvim-autopairs": { "branch": "master", "commit": "b464658e9b880f463b9f7e6ccddd93fb0013f559" }, + "nvim-cmp": { "branch": "main", "commit": "ed31156aa2cc14e3bc066c59357cc91536a2bc01" }, + "nvim-lspconfig": { "branch": "master", "commit": "e8f9c46c99e1901167a92ab13e2357158e5aabdb" }, + "nvim-neoclip.lua": { "branch": "main", "commit": "32e05f2d23dc5b6a284a688c0535a83d1bfc633f" }, + "nvim-surround": { "branch": "main", "commit": "9f0cb495f25bff32c936062d85046fbda0c43517" }, + "nvim-tree.lua": { "branch": "master", "commit": "ca7c4c33cac2ad66ec69d45e465379716ef0cc97" }, + "nvim-treesitter": { "branch": "master", "commit": "4d035005d338e4b1eb71a175bd44974e2f64740f" }, + "nvim-web-devicons": { "branch": "master", "commit": "edbe0a65cfacbbfff6a4a1e98ddd60c28c560509" }, + "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, "sqlite.lua": { "branch": "master", "commit": "d0ffd703b56d090d213b497ed4eb840495f14a11" }, "telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, - "trouble.nvim": { "branch": "main", "commit": "6efc446226679fda0547c0fd6a7892fd5f5b15d8" }, + "trouble.nvim": { "branch": "main", "commit": "46cf952fc115f4c2b98d4e208ed1e2dce08c9bf6" }, "vim-be-good": { "branch": "master", "commit": "4fa57b7957715c91326fcead58c1fa898b9b3625" } } diff --git a/.config/nvim/lua/config/keymaps.lua b/.config/nvim/lua/config/keymaps.lua index 4e4feab..50980aa 100644 --- a/.config/nvim/lua/config/keymaps.lua +++ b/.config/nvim/lua/config/keymaps.lua @@ -7,3 +7,6 @@ vim.keymap.set('n', '', '') vim.keymap.set('n', '', '') vim.keymap.set('n', '', '') vim.keymap.set('n', '', ':lua vim.lsp.buf.code_action()') +vim.keymap.set('n', '', ':lua vim.lsp.buf.hover()') +vim.keymap.set('n', '', ':lua vim.lsp.buf.rename()') +vim.keymap.set('n', '', ':lua vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled(), { bufnr })') diff --git a/.config/nvim/lua/config/options.lua b/.config/nvim/lua/config/options.lua index 99f6daa..19ce0ac 100644 --- a/.config/nvim/lua/config/options.lua +++ b/.config/nvim/lua/config/options.lua @@ -22,4 +22,3 @@ vim.opt.incsearch = true vim.opt.hlsearch = false vim.opt.ignorecase = true vim.opt.smartcase = true - diff --git a/.config/nvim/lua/plugins/lsp.lua b/.config/nvim/lua/plugins/lsp.lua index 95df1d1..fc0bc5d 100644 --- a/.config/nvim/lua/plugins/lsp.lua +++ b/.config/nvim/lua/plugins/lsp.lua @@ -37,7 +37,7 @@ return { unpack = unpack or table.unpack local line, col = unpack(vim.api.nvim_win_get_cursor(0)) return col ~= 0 and - vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil + vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil end local cmp = require('cmp') @@ -48,6 +48,10 @@ return { luasnip.lsp_expand(args.body) end }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered() + }, mapping = cmp.mapping.preset.insert({ [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), @@ -87,12 +91,26 @@ return { config = function() local lspconfig = require('lspconfig') local lsp_capabilities = require('cmp_nvim_lsp').default_capabilities() - lspconfig.lua_ls.setup({ capabilities = lsp_capabilities }) - lspconfig.rust_analyzer.setup({ capabilities = lsp_capabilities }) - lspconfig.gopls.setup({ capabilities = lsp_capabilities }) - lspconfig.typst_lsp.setup({ capabilities = lsp_capabilities }) - lspconfig.clangd.setup({ capabilities = lsp_capabilities }) - lspconfig.cmake.setup({ capabilities = lsp_capabilities }) + local servers = { 'lua_ls', 'pylsp', 'gopls', 'typst_lsp', 'clangd', 'cmake' } + for _, lsp in ipairs(servers) do + lspconfig[lsp].setup({ + capabilities = lsp_capabilities + }) + end + lspconfig['omnisharp'].setup({ + cmd = { "/home/egor/.local/share/nvim/mason/bin/omnisharp" }, + capabilities = lsp_capabilities + }) + lspconfig['rust_analyzer'].setup({ + capabilities = lsp_capabilities, + settings = { + ['rust-analyzer'] = { + inlayHints = { + typeHints = { enable = true } + } + } + } + }) end }, } diff --git a/.config/nvim/lua/plugins/tree.lua b/.config/nvim/lua/plugins/tree.lua index 3d77aa7..34275e9 100644 --- a/.config/nvim/lua/plugins/tree.lua +++ b/.config/nvim/lua/plugins/tree.lua @@ -3,16 +3,18 @@ return { dependencies = { 'nvim-tree/nvim-web-devicons' }, - config = function () + config = function() vim.g.loaded_netrw = 1 vim.g.loaded_netrwPlugin = 1 vim.keymap.set('n', 'e', ':NvimTreeToggle') require('nvim-tree').setup({ filters = { - dotfiles = true + dotfiles = false, + git_ignored = false, + custom = { '^.git$' } } }) - vim.api.nvim_create_autocmd({"QuitPre"}, { + vim.api.nvim_create_autocmd({ "QuitPre" }, { callback = function() vim.cmd("NvimTreeClose") end, }) end