From a6e93a6d7637fbd7299c8bfa2665cc4fed2aabd6 Mon Sep 17 00:00:00 2001 From: Patrick Auernig Date: Sat, 6 Jan 2024 21:44:41 +0100 Subject: [PATCH] Remove lsp-zero and merge configs into one file --- lazy-lock.json | 3 +- lua/valeth/lazy.lua | 1 - lua/valeth/plugins/{lsp => }/cmp.lua | 8 ++- .../plugins/{lsp/lspconfig.lua => lsp.lua} | 52 ++++++++++++++++--- lua/valeth/plugins/lsp/init.lua | 39 -------------- lua/valeth/plugins/lsp/mason.lua | 32 ------------ lua/valeth/plugins/{lsp => }/ufo.lua | 4 +- 7 files changed, 54 insertions(+), 85 deletions(-) rename lua/valeth/plugins/{lsp => }/cmp.lua (85%) rename lua/valeth/plugins/{lsp/lspconfig.lua => lsp.lua} (57%) delete mode 100644 lua/valeth/plugins/lsp/init.lua delete mode 100644 lua/valeth/plugins/lsp/mason.lua rename lua/valeth/plugins/{lsp => }/ufo.lua (96%) diff --git a/lazy-lock.json b/lazy-lock.json index bb5e766..9fd16be 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -12,14 +12,13 @@ "harpoon": { "branch": "master", "commit": "ccae1b9bec717ae284906b0bf83d720e59d12b91" }, "indent-blankline.nvim": { "branch": "master", "commit": "877c1db2bf957300097dd5348a665666a4d900cb" }, "lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" }, - "lsp-zero.nvim": { "branch": "v2.x", "commit": "2c1e776fd28f001438f12b1d9cee8933a0a40934" }, "lspkind.nvim": { "branch": "master", "commit": "7f26cf5e27e2bd910ce0ea00c514da2bf97423b8" }, "lualine.nvim": { "branch": "master", "commit": "566b7036f717f3d676362742630518a47f132fff" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "0989bdf4fdf7b5aa4c74131d7ffccc3f399ac788" }, "mason-nvim-dap.nvim": { "branch": "main", "commit": "f0cd12f7a8a310c58cecebddb6b219ffad1cfd0f" }, "mason.nvim": { "branch": "main", "commit": "e110bc3be1a7309617cecd77bfe4bf86ba1b8134" }, "neodev.nvim": { "branch": "main", "commit": "be8d4d4cab6c13c6a572269c9d6a63774baba9a0" }, - "neogit": { "branch": "master", "commit": "93bf00cd5db1e88ea0ca9105e83f7e97896a7cd2" }, + "neogit": { "branch": "master", "commit": "760d6d74c328ce2a38b02677bf5161999b992da2" }, "nvim-autopairs": { "branch": "master", "commit": "9fd41181693dd4106b3e414a822bb6569924de81" }, "nvim-cmp": { "branch": "main", "commit": "538e37ba87284942c1d76ed38dd497e54e65b891" }, "nvim-dap": { "branch": "master", "commit": "debd7c2f80eaf20c5f5df25db8d8c1b9b18f4421" }, diff --git a/lua/valeth/lazy.lua b/lua/valeth/lazy.lua index d47ad1a..deedfc5 100644 --- a/lua/valeth/lazy.lua +++ b/lua/valeth/lazy.lua @@ -56,7 +56,6 @@ require("lazy").setup({ }, spec = { { import = "valeth.plugins" }, - { import = "valeth.plugins.lsp" }, { import = "valeth.plugins.dap" }, } }) diff --git a/lua/valeth/plugins/lsp/cmp.lua b/lua/valeth/plugins/cmp.lua similarity index 85% rename from lua/valeth/plugins/lsp/cmp.lua rename to lua/valeth/plugins/cmp.lua index 3c561c1..9c3029d 100644 --- a/lua/valeth/plugins/lsp/cmp.lua +++ b/lua/valeth/plugins/cmp.lua @@ -21,6 +21,11 @@ spec.config = function() mode = "symbol_text", }) }, + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end + }, window = { completion = cmp.config.window.bordered() }, @@ -32,9 +37,10 @@ spec.config = function() }, sources = cmp.config.sources({ { name = "nvim_lsp" }, - { name = "path"}, + { name = "path" }, }) }) end + return spec diff --git a/lua/valeth/plugins/lsp/lspconfig.lua b/lua/valeth/plugins/lsp.lua similarity index 57% rename from lua/valeth/plugins/lsp/lspconfig.lua rename to lua/valeth/plugins/lsp.lua index b4b31a1..7e09b4a 100644 --- a/lua/valeth/plugins/lsp/lspconfig.lua +++ b/lua/valeth/plugins/lsp.lua @@ -3,19 +3,53 @@ local spec = { } spec.dependencies = { + "williamboman/mason.nvim", + "williamboman/mason-lspconfig.nvim", "nvim-telescope/telescope.nvim", "folke/neodev.nvim", + "mhartington/formatter.nvim", } spec.config = function() + -- Give me fancy diagnostic signs + vim.fn.sign_define("DiagnosticSignError ", { text = "✘" }) + vim.fn.sign_define("DiagnosticSignWarn" , { text = "▲" }) + vim.fn.sign_define("DiagnosticSignInfo ", { text = "»" }) + vim.fn.sign_define("DiagnosticSignHint", { text = "⚑" }) + + vim.diagnostic.config({ + virtual_text = false, + }) + + local mason = require("mason") + local mason_lspconfig = require("mason-lspconfig") + + mason.setup({ + ui = { + icons = { + package_installed = "✓", + package_pending = "➜", + package_uninstalled = "✗" + } + } + }) + + mason_lspconfig.setup({ + ensure_installed = { + "lua_ls", + "rust_analyzer", + } + }) + local lsp_config = require("lspconfig") - local tsb = require("telescope.builtin") local autocmd = vim.api.nvim_create_autocmd local autogroup = vim.api.nvim_create_augroup + autocmd("LspAttach", { group = autogroup("LspAttachConfig", {}), callback = function(event) + local tsb = require("telescope.builtin") local opts = { buffer = event.buf, remap = false } vim.keymap.set("n", "gd", tsb.lsp_definitions, opts) @@ -34,17 +68,19 @@ spec.config = function() require("neodev").setup() - lsp_config.lua_ls.setup { - settings = { - Lua = { + lsp_config.lua_ls.setup({ + capabilities = { + textDocument = { completion = { - callSnippet = "Replace" + completionItem = { + snippetSupport = false + } } } } - } + }) - lsp_config.rust_analyzer.setup { + lsp_config.rust_analyzer.setup({ settings = { ["rust-analyzer"] = { cargo = { @@ -56,7 +92,7 @@ spec.config = function() } } } - } + }) end return spec diff --git a/lua/valeth/plugins/lsp/init.lua b/lua/valeth/plugins/lsp/init.lua deleted file mode 100644 index 04aebf3..0000000 --- a/lua/valeth/plugins/lsp/init.lua +++ /dev/null @@ -1,39 +0,0 @@ --- TODO: figure out how to configure auto formatting and drop lsp-zero -local spec = { - "VonHeikemen/lsp-zero.nvim", - branch = "v2.x", -} - -spec.dependencies = { - "neovim/nvim-lspconfig", - "hrsh7th/nvim-cmp", - "mhartington/formatter.nvim", - "williamboman/mason.nvim", -} - -spec.config = function() - local lsp_zero = require("lsp-zero").preset({}) - - -- NOTE: Format on save does not support async formatting - lsp_zero.format_on_save({ - servers = { - ["rust_analyzer"] = { "rust" } - } - }) - - lsp_zero.setup() - - vim.diagnostic.config({ - virtual_text = false, - }) - - -- Gimme pretty icons - lsp_zero.set_sign_icons({ - error = '✘', - warn = '▲', - hint = '⚑', - info = '»' - }) -end - -return spec diff --git a/lua/valeth/plugins/lsp/mason.lua b/lua/valeth/plugins/lsp/mason.lua deleted file mode 100644 index 532d202..0000000 --- a/lua/valeth/plugins/lsp/mason.lua +++ /dev/null @@ -1,32 +0,0 @@ -local spec = { - "williamboman/mason.nvim", -} - -spec.dependencies = { - "williamboman/mason-lspconfig.nvim", - "neovim/nvim-lspconfig", -} - -spec.config = function() - local mason = require("mason") - local mason_lspconfig = require("mason-lspconfig") - - mason.setup({ - ui = { - icons = { - package_installed = "✓", - package_pending = "➜", - package_uninstalled = "✗" - } - } - }) - - mason_lspconfig.setup({ - ensure_installed = { - "lua_ls", - "rust_analyzer", - } - }) -end - -return spec diff --git a/lua/valeth/plugins/lsp/ufo.lua b/lua/valeth/plugins/ufo.lua similarity index 96% rename from lua/valeth/plugins/lsp/ufo.lua rename to lua/valeth/plugins/ufo.lua index 805fd75..66c0e18 100644 --- a/lua/valeth/plugins/lsp/ufo.lua +++ b/lua/valeth/plugins/ufo.lua @@ -23,9 +23,9 @@ spec.config = function() end }) - ufo.setup { + ufo.setup({ close_fold_kinds = {"comment", "imports"}, - } + }) end return spec