From ee88d19f9818e457150ab9a75a1675725cdba7df Mon Sep 17 00:00:00 2001 From: 409 Date: Wed, 31 Jul 2024 13:08:53 +0200 Subject: [PATCH] feat: added noice --- lazy-lock.json | 29 +++---- lua/409/plugins/completion.lua | 8 +- lua/409/plugins/lsp.lua | 135 +++++++++++++++++++-------------- lua/409/plugins/noice.lua | 46 +++++++++++ lua/409/plugins/statusline.lua | 10 ++- lua/409/plugins/theme.lua | 3 + lua/409/set.lua | 1 - 7 files changed, 154 insertions(+), 78 deletions(-) create mode 100644 lua/409/plugins/noice.lua diff --git a/lazy-lock.json b/lazy-lock.json index 738ab79..e43bb19 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -2,44 +2,47 @@ "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, "LuaSnip": { "branch": "master", "commit": "ce0a05ab4e2839e1c48d072c5236cce846a387bc" }, "barbecue.nvim": { "branch": "main", "commit": "cd7e7da622d68136e13721865b4d919efd6325ed" }, - "catppuccin": { "branch": "main", "commit": "0b5df9c9e641b1212b21a0762ccad4434fd41322" }, + "catppuccin": { "branch": "main", "commit": "10eda02ea4faa7d1f94e77a3410a4ae91c25c5f5" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, "cmp-nvim-lsp-signature-help": { "branch": "main", "commit": "031e6ba70b0ad5eee49fd2120ff7a2e325b17fa7" }, "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, - "conform.nvim": { "branch": "master", "commit": "797de8f79055334104cf77893cd93fe3fc2ac154" }, + "conform.nvim": { "branch": "master", "commit": "25d48271e3d4404ba017cb92a37d3a681c1ad149" }, "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" }, "dressing.nvim": { "branch": "master", "commit": "6741f1062d3dc6e4755367a7e9b347b553623f04" }, "flutter-tools.nvim": { "branch": "main", "commit": "5aa227fa083fd740184b55b5220dfabc24a25cc7" }, - "gitsigns.nvim": { "branch": "main", "commit": "f4928ba14eb6c667786ac7d69927f6aee6719f1e" }, + "gitsigns.nvim": { "branch": "main", "commit": "f074844b60f9e151970fbcdbeb8a2cd52b6ef25a" }, "harpoon": { "branch": "harpoon2", "commit": "0378a6c428a0bed6a2781d459d7943843f374bce" }, - "lazy.nvim": { "branch": "main", "commit": "839f9e78e78dc935b1188fb16583365991739c51" }, - "lspkind.nvim": { "branch": "master", "commit": "1735dd5a5054c1fb7feaf8e8658dbab925f4f0cf" }, + "lazy.nvim": { "branch": "main", "commit": "077102c5bfc578693f12377846d427f49bc50076" }, + "lsp-zero.nvim": { "branch": "v2.x", "commit": "9a686513eaaa13d737d0fec8956a18268ead8b29" }, + "lspkind.nvim": { "branch": "master", "commit": "cff4ae321a91ee3473a92ea1a8c637e3a9510aec" }, "lualine.nvim": { "branch": "master", "commit": "544dd1583f9bb27b393f598475c89809c4d5e86b" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "58bc9119ca273c0ce5a66fad1927ef0f617bd81b" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "ba9c2f0b93deb48d0a99ae0e8d8dd36f7cc286d6" }, "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, "mini.indentscope": { "branch": "main", "commit": "f0d7faa064c892b96997810afcddfadc3f2a15b3" }, "mini.surround": { "branch": "main", "commit": "3cb5b509ad34f2402df4b977be607a614c8c7524" }, - "neogen": { "branch": "main", "commit": "6de0add4805165317ab7d3d36b5cef48b1b865f3" }, + "neogen": { "branch": "main", "commit": "b2942f546c28fb27525dbdad8656549b9a28c846" }, + "noice.nvim": { "branch": "main", "commit": "448bb9c524a7601035449210838e374a30153172" }, + "nui.nvim": { "branch": "main", "commit": "61574ce6e60c815b0a0c4b5655b8486ba58089a1" }, "nvim-cmp": { "branch": "main", "commit": "d818fd0624205b34e14888358037fb6f5dc51234" }, - "nvim-lspconfig": { "branch": "master", "commit": "fa6c2a64100c6f692bbec29bbbc8ec2663c9e869" }, + "nvim-lspconfig": { "branch": "master", "commit": "fdc44768a09a65140aa00c92872a5381ad486485" }, "nvim-navic": { "branch": "master", "commit": "8649f694d3e76ee10c19255dece6411c29206a54" }, "nvim-tree-docs": { "branch": "master", "commit": "5db023d783da1e55339e5e25caaf72a59597e626" }, - "nvim-treesitter": { "branch": "master", "commit": "5f5077f8f7fa545065a0846406011cd3cc49093b" }, + "nvim-treesitter": { "branch": "master", "commit": "8e569bc4b5eee3ef011c948f92493fda2e2a6a32" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "6b5f95aa4d24f2c629a74f2c935c702b08dbde62" }, - "nvim-web-devicons": { "branch": "master", "commit": "e612de3d3a41a6b7be47f51e956dddabcbf419d9" }, + "nvim-web-devicons": { "branch": "master", "commit": "5be6c4e685618b99c3210a69375b38a1202369b4" }, "plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" }, - "tailwind-tools.nvim": { "branch": "master", "commit": "ce3ab3fd6ad05d08fbfc1ef84b3f5312cd05ee6d" }, - "telescope.nvim": { "branch": "master", "commit": "79552ef8488cb492e0f9d2bf3b4e808f57515e35" }, + "tailwind-tools.nvim": { "branch": "master", "commit": "9baed3c610bc80299046db02d26e5deb66323c36" }, + "telescope.nvim": { "branch": "master", "commit": "10b8a82b042caf50b78e619d92caf0910211973d" }, "tiny-devicons-auto-colors.nvim": { "branch": "main", "commit": "9be4af5b1bc1f26a11206ed7ce8bf44312e7941a" }, "todo-comments.nvim": { "branch": "main", "commit": "8f45f353dc3649cb9b44cecda96827ea88128584" }, "trouble.nvim": { "branch": "main", "commit": "6efc446226679fda0547c0fd6a7892fd5f5b15d8" }, "tsc.nvim": { "branch": "main", "commit": "548410076322307c80646857778aee050d903b8c" }, "undotree": { "branch": "master", "commit": "56c684a805fe948936cda0d1b19505b84ad7e065" }, "vim-dadbod": { "branch": "master", "commit": "7888cb7164d69783d3dce4e0283decd26b82538b" }, - "vim-dadbod-completion": { "branch": "master", "commit": "c3a56c652af9367c5a7b658ed7ed4dc494f430b0" }, + "vim-dadbod-completion": { "branch": "master", "commit": "c3ab458fb7c94c2fc4baae4e2cd5601eec9d27bc" }, "vim-dadbod-ui": { "branch": "master", "commit": "0f51d8de368c8c6220973e8acd156d17da746f4c" }, "vim-fugitive": { "branch": "master", "commit": "0444df68cd1cdabc7453d6bd84099458327e5513" }, "vim-illuminate": { "branch": "master", "commit": "5eeb7951fc630682c322e88a9bbdae5c224ff0aa" }, diff --git a/lua/409/plugins/completion.lua b/lua/409/plugins/completion.lua index 1462e26..9bd7738 100644 --- a/lua/409/plugins/completion.lua +++ b/lua/409/plugins/completion.lua @@ -1,8 +1,10 @@ return { - "onsails/lspkind.nvim", { "hrsh7th/nvim-cmp", - dependencies = { "onsails/lspkind.nvim" }, + dependencies = { + "onsails/lspkind.nvim", + "VonHeikemen/lsp-zero.nvim", + }, opts = function() local cmp = require("cmp") local lspkind = require("lspkind") @@ -22,7 +24,7 @@ return { { name = "nvim_lsp_signature_help" }, { name = "nvim_lua" }, { name = "vim-dadbod-completion" }, - { name = "luasnip", keyword_length = 2 }, + { name = "luasnip", keyword_length = 2 }, -- { name = "buffer", keyword_length = 3 }, }, view = { diff --git a/lua/409/plugins/lsp.lua b/lua/409/plugins/lsp.lua index 28ab467..0827600 100644 --- a/lua/409/plugins/lsp.lua +++ b/lua/409/plugins/lsp.lua @@ -1,38 +1,80 @@ return { { - "williamboman/mason-lspconfig.nvim", - opts = function() - local lspconfig = require("lspconfig") + "VonHeikemen/lsp-zero.nvim", + branch = "v2.x", + dependencies = { + { "neovim/nvim-lspconfig" }, + { + "williamboman/mason.nvim", + build = function() + pcall(vim.cmd, "MasonUpdate") + end, + }, + { "williamboman/mason-lspconfig.nvim" }, + }, + config = function() + local lsp = require("lsp-zero") - local default_capabilities = require("cmp_nvim_lsp").default_capabilities() + lsp.on_attach(function(client, bufnr) + local lsp_opts = { buffer = bufnr, remap = false } - local lsp_default_capabilities = vim.lsp.protocol.make_client_capabilities() + vim.keymap.set("n", "gd", function() + vim.lsp.buf.definition() + end, lsp_opts) + vim.keymap.set("n", "gi", function() + vim.lsp.buf.implementation() + end, lsp_opts) + vim.keymap.set("n", "K", function() + vim.lsp.buf.hover() + end, lsp_opts) + vim.keymap.set("n", "vws", function() + vim.lsp.buf.workspace_symbol() + end, lsp_opts) + vim.keymap.set("n", "vd", function() + vim.diagnostic.open_float() + end, lsp_opts) + vim.keymap.set("n", "[d", function() + vim.diagnostic.goto_next() + end, lsp_opts) + vim.keymap.set("n", "]d", function() + vim.diagnostic.goto_prev() + end, lsp_opts) + vim.keymap.set("n", "vca", function() + vim.lsp.buf.code_action() + end, lsp_opts) + vim.keymap.set("n", "vrr", function() + vim.lsp.buf.references() + end, lsp_opts) + vim.keymap.set("n", "vrn", function() + vim.lsp.buf.rename() + end, lsp_opts) + vim.keymap.set("i", "", function() + vim.lsp.buf.signature_help() + end, lsp_opts) + end) - local capabilities = vim.tbl_deep_extend("force", {}, lsp_default_capabilities, default_capabilities) - - return { - ensure_installed = { "tsserver", "rust_analyzer" }, + require("mason-lspconfig").setup({ + ensure_installed = { + "tsserver", + "eslint", + "rust_analyzer", + "lua_ls", + "jsonls", + "html", + "tailwindcss", + "pylsp", + "dockerls", + "bashls", + "marksman", + }, handlers = { - function(server_name) - lspconfig[server_name].setup({ - capabilities = capabilities, - }) - end, - ["lua_ls"] = function() - lspconfig.lua_ls.setup({ - settings = { - Lua = { - diagnostics = { - globals = { "vim" }, - }, - }, - }, - }) + lsp.default_setup, + lua_ls = function() + require("lspconfig").lua_ls.setup(lsp.nvim_lua_ls()) end, }, - } + }) end, - config = true, }, { "neovim/nvim-lspconfig", @@ -49,7 +91,7 @@ return { }, }, inlay_hints = { - enabled = true, + enabled = false, }, servers = { tsserver = { @@ -71,6 +113,8 @@ return { config = function(_, opts) vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = "single", + virtual_text = true, + silent = true, }) vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { @@ -83,38 +127,11 @@ return { local lsp_opts = { buffer = buffer, remap = false, nowait = true } local client = vim.lsp.get_client_by_id(args.data.client_id) - vim.keymap.set("n", "gd", function() - vim.lsp.buf.definition() - end, lsp_opts) - vim.keymap.set("n", "K", function() - vim.lsp.buf.hover() - end, lsp_opts) - vim.keymap.set("n", "vws", function() - vim.lsp.buf.workspace_symbol() - end, lsp_opts) - vim.keymap.set("n", "vd", function() - vim.diagnostic.open_float() - end, lsp_opts) - vim.keymap.set("n", "[d", function() - vim.diagnostic.goto_next() - end, lsp_opts) - vim.keymap.set("n", "]d", function() - vim.diagnostic.goto_prev() - end, lsp_opts) - vim.keymap.set("n", "vca", function() - vim.lsp.buf.code_action() - end, lsp_opts) - vim.keymap.set("n", "vrr", function() - vim.lsp.buf.references() - end, lsp_opts) - vim.keymap.set("n", "vrn", function() - vim.lsp.buf.rename() - end, lsp_opts) - vim.keymap.set("i", "", function() - vim.lsp.buf.signature_help() - end, lsp_opts) - - if opts.inlay_hints.enabled and client.supports_method("textDocument/inlayHint") then + if + opts.inlay_hints.enabled + and client ~= nil + and client.supports_method("textDocument/inlayHint") + then vim.lsp.inlay_hint.enable(true) end end, diff --git a/lua/409/plugins/noice.lua b/lua/409/plugins/noice.lua new file mode 100644 index 0000000..d705ca9 --- /dev/null +++ b/lua/409/plugins/noice.lua @@ -0,0 +1,46 @@ +return { + "folke/noice.nvim", + dependencies = { + "MunifTanjim/nui.nvim", + }, + event = "VeryLazy", + opts = {}, + config = function() + require("noice").setup({ + lsp = { + override = { + ["vim.lsp.util.convert_input_to_markdown_lines"] = true, + ["vim.lsp.util.stylize_markdown"] = true, + ["cmp.entry.get_documentation"] = true, + }, + hover = { + silent = true, + } + }, + presets = { + bottom_search = true, + inc_rename = false, + lsp_doc_border = true, + }, + cmdline = { + enabled = true, + view = "cmdline", + }, + messages = { + enabled = true, + }, + views = { + hover = { + border = { + style = "single", + }, + }, + mini = { + win_options = { + winblend = 0, + }, + }, + }, + }) + end, +} diff --git a/lua/409/plugins/statusline.lua b/lua/409/plugins/statusline.lua index 7bea95f..70497c4 100644 --- a/lua/409/plugins/statusline.lua +++ b/lua/409/plugins/statusline.lua @@ -62,7 +62,7 @@ return { always_divide_middle = true, globalstatus = false, refresh = { - statusline = 1000, + statusline = 100, tabline = 1000, winbar = 1000, }, @@ -70,7 +70,13 @@ return { sections = { lualine_a = { "mode" }, lualine_b = { "branch", "diff", "diagnostics" }, - lualine_c = { "filename" }, + lualine_c = { + "filename", + { + require("noice").api.statusline.mode.get, + cond = require("noice").api.statusline.mode.has, + }, + }, lualine_x = { "fileformat", "filetype" }, lualine_y = { "progress" }, lualine_z = { "location" }, diff --git a/lua/409/plugins/theme.lua b/lua/409/plugins/theme.lua index 1a2ea4a..ec7c3ee 100644 --- a/lua/409/plugins/theme.lua +++ b/lua/409/plugins/theme.lua @@ -24,6 +24,9 @@ return { vim.api.nvim_set_hl(0, "MiniIndentscopeSymbol", { fg = catppuccin_colors.surface2 }) vim.api.nvim_set_hl(0, "DiffAdd", { fg = catppuccin_colors.green, bg = "none" }) vim.api.nvim_set_hl(0, "DiffDelete", { fg = catppuccin_colors.red, bg = "none" }) + + vim.api.nvim_set_hl(0, "NoiceFormatProgressTodo", { link = "Normal" }) + vim.api.nvim_set_hl(0, "NoiceFormatProgressDone", { link = "Normal" }) end }, } diff --git a/lua/409/set.lua b/lua/409/set.lua index 357063e..58d6680 100755 --- a/lua/409/set.lua +++ b/lua/409/set.lua @@ -9,7 +9,6 @@ vim.opt.shiftwidth = 4 vim.opt.expandtab = true vim.opt.smartindent = true -vim.opt.autoindent = true vim.opt.linebreak = true vim.opt.wrap = false