From fddc63b5387bf2961e4f9b623cad9549f4a6c808 Mon Sep 17 00:00:00 2001 From: Wynd Date: Sat, 8 Jun 2024 13:16:34 +0300 Subject: [PATCH] Added lualine, updated most nvim plugins, added some extra rules for markdown files and taplo --- .config/nvim/after/ftplugin/markdown.lua | 15 ++++++ .config/nvim/lazy-lock.json | 49 ++++++++++--------- .config/nvim/lua/nvwynd/autocmds.lua | 5 ++ .config/nvim/lua/nvwynd/keymaps.lua | 2 +- .../nvim/lua/nvwynd/plugins/formatting.lua | 3 +- .config/nvim/lua/nvwynd/plugins/lsp.lua | 4 ++ .../nvim/lua/nvwynd/plugins/treesitter.lua | 1 - .config/nvim/lua/nvwynd/plugins/ui.lua | 45 +++++++++++++++++ 8 files changed, 97 insertions(+), 27 deletions(-) diff --git a/.config/nvim/after/ftplugin/markdown.lua b/.config/nvim/after/ftplugin/markdown.lua index cc0160c..b3eb61e 100644 --- a/.config/nvim/after/ftplugin/markdown.lua +++ b/.config/nvim/after/ftplugin/markdown.lua @@ -1,7 +1,22 @@ -- get only the currently used buffer in the current window and set the options for it local winid = vim.api.nvim_get_current_win() +local bufnr = vim.api.nvim_get_current_buf() + local wo = vim.wo[winid][0] +local bo = vim.bo[bufnr] wo.spell = true +bo.textwidth = 120 vim.cmd.highlight({ "SpellBad", "gui=undercurl", "guifg=#DA6464" }) + +local conform = require("conform") + +-- if a formatter is enabled for this filetype then ignore .editorconfig file +-- as we assume a formatter specific config +for _, f in ipairs(conform.list_formatters(bufnr)) do + if f.available then + vim.b.editorconfig = false + break + end +end diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index 9448cc3..456ed3a 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -1,35 +1,36 @@ { "Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" }, - "LuaSnip": { "branch": "master", "commit": "8f3d3465ba5c7ade0a8adb41eca5736f291a3fa8" }, - "catppuccin": { "branch": "main", "commit": "a1439ad7c584efb3d0ce14ccb835967f030450fe" }, + "LuaSnip": { "branch": "master", "commit": "50fcf17db7c75af80e6b6109acfbfb4504768780" }, + "catppuccin": { "branch": "main", "commit": "5215ea59df6d0a7e27da9a5cd1165e06d1b04cbe" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, - "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, - "conform.nvim": { "branch": "master", "commit": "4660e534bf7678ee0f85879aa75fdcb6855612c2" }, - "dressing.nvim": { "branch": "master", "commit": "5162edb1442a729a885c45455a07e9a89058be2f" }, - "fidget.nvim": { "branch": "main", "commit": "1ba38e4cbb24683973e00c2e36f53ae64da38ef5" }, - "image.nvim": { "branch": "master", "commit": "cdf1be9c708e75be936cc42d8122b748a51482e4" }, - "lazy.nvim": { "branch": "main", "commit": "3f13f080434ac942b150679223d54f5ca91e0d52" }, + "conform.nvim": { "branch": "master", "commit": "069e971295a34a810484b7b2ef54b3c735214181" }, + "dressing.nvim": { "branch": "master", "commit": "e3714c8049b2243e792492c4149e4cc395c68eb9" }, + "fidget.nvim": { "branch": "main", "commit": "ef99df04a1c53a453602421bc0f756997edc8289" }, + "image.nvim": { "branch": "master", "commit": "a2a0849e0b3dbed90f9283603cedb683bda5d4d1" }, + "lazy.nvim": { "branch": "main", "commit": "eb4957442e3182f051b0ae11da32e06d22c190e3" }, "lazydev.nvim": { "branch": "main", "commit": "107231114623e2c4f90c626ec83b3120816b554e" }, - "lsp-zero.nvim": { "branch": "v3.x", "commit": "b93f040edd57888cd6a1e7d9dee47dddc4463f8f" }, + "lsp-zero.nvim": { "branch": "v3.x", "commit": "16de3b18c5f7b6230d89b8e64ce9a4801b6f8d08" }, "lspkind.nvim": { "branch": "master", "commit": "1735dd5a5054c1fb7feaf8e8658dbab925f4f0cf" }, + "lualine.nvim": { "branch": "master", "commit": "0a5a66803c7407767b799067986b4dc3036e1983" }, "luvit-meta": { "branch": "main", "commit": "ce76f6f6cdc9201523a5875a4471dcfe0186eb60" }, - "neo-tree.nvim": { "branch": "v3.x", "commit": "7aad1bf3f6b849cbf108e02c55ad4d701cb4d33a" }, - "nui.nvim": { "branch": "main", "commit": "cbd2668414331c10039278f558630ed19b93e69b" }, - "nvim-autopairs": { "branch": "master", "commit": "4f41e5940bc0443fdbe5f995e2a596847215cd2a" }, - "nvim-cmp": { "branch": "main", "commit": "8f3c541407e691af6163e2447f3af1bd6e17f9a3" }, - "nvim-lspconfig": { "branch": "master", "commit": "7133e85c3df14a387da8942c094c7edddcdef309" }, - "nvim-notify": { "branch": "master", "commit": "5371f4bfc1f6d3adf4fe9d62cd3a9d44356bfd15" }, - "nvim-surround": { "branch": "main", "commit": "79aaa42da1f698ed31bcbe7f83081f69dca7ba17" }, - "nvim-treesitter": { "branch": "master", "commit": "0883ff05655117a3fc79ab295a640c4984cfd415" }, - "nvim-ts-autotag": { "branch": "main", "commit": "531f48334c422222aebc888fd36e7d109cb354cd" }, - "nvim-web-devicons": { "branch": "master", "commit": "beb6367ab8496c9e43f22e0252735fdadae1872d" }, - "plenary.nvim": { "branch": "master", "commit": "08e301982b9a057110ede7a735dd1b5285eb341f" }, - "telescope.nvim": { "branch": "master", "commit": "35f94f0ef32d70e3664a703cefbe71bd1456d899" }, - "todo-comments.nvim": { "branch": "main", "commit": "a7e39ae9e74f2c8c6dc4eea6d40c3971ae84752d" }, - "trouble.nvim": { "branch": "main", "commit": "b9cf677f20bb2faa2dacfa870b084e568dca9572" }, + "neo-tree.nvim": { "branch": "v3.x", "commit": "29f7c215332ba95e470811c380ddbce2cebe2af4" }, + "nui.nvim": { "branch": "main", "commit": "322978c734866996274467de084a95e4f9b5e0b1" }, + "nvim-autopairs": { "branch": "master", "commit": "c15de7e7981f1111642e7e53799e1211d4606cb9" }, + "nvim-cmp": { "branch": "main", "commit": "a110e12d0b58eefcf5b771f533fc2cf3050680ac" }, + "nvim-lspconfig": { "branch": "master", "commit": "92166b89ab4b3d60f24e58170cac53b7141fd032" }, + "nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" }, + "nvim-surround": { "branch": "main", "commit": "ae876ab0f8d41213131c3ed4eeb4c48328f45e12" }, + "nvim-treesitter": { "branch": "master", "commit": "c1e1e24b6433d4539bad9f5daa207df39633071b" }, + "nvim-ts-autotag": { "branch": "main", "commit": "6eb4120a1aadef07ac312f1c4bc6456712220007" }, + "nvim-web-devicons": { "branch": "master", "commit": "b4b302d6ae229f67df7a87ef69fa79473fe788a9" }, + "plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" }, + "telescope.nvim": { "branch": "master", "commit": "3a743491e5c6be0ed0aa8c31c6905df8f66179ba" }, + "todo-comments.nvim": { "branch": "main", "commit": "70a93ce66083699571adc361166504b03cc39c2b" }, + "trouble.nvim": { "branch": "main", "commit": "806c50491078b66daf13c408042f2e74da46d0ff" }, "twilight.nvim": { "branch": "main", "commit": "8b7b50c0cb2dc781b2f4262a5ddd57571556d1e4" }, - "which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" }, + "which-key.nvim": { "branch": "main", "commit": "0099511294f16b81c696004fa6a403b0ae61f7a0" }, "zen-mode.nvim": { "branch": "main", "commit": "78557d972b4bfbb7488e17b5703d25164ae64e6a" } } \ No newline at end of file diff --git a/.config/nvim/lua/nvwynd/autocmds.lua b/.config/nvim/lua/nvwynd/autocmds.lua index c60f2a1..7b51dc8 100644 --- a/.config/nvim/lua/nvwynd/autocmds.lua +++ b/.config/nvim/lua/nvwynd/autocmds.lua @@ -13,3 +13,8 @@ vim.api.nvim_create_user_command("ListPlugins", function() print("Error opening file: " .. err) end end, {}) + +vim.api.nvim_create_user_command("CountWords", function() + local words = vim.fn.wordcount()["words"] + print("Words: " .. words) +end, {}) diff --git a/.config/nvim/lua/nvwynd/keymaps.lua b/.config/nvim/lua/nvwynd/keymaps.lua index 6145c10..ce0d34b 100644 --- a/.config/nvim/lua/nvwynd/keymaps.lua +++ b/.config/nvim/lua/nvwynd/keymaps.lua @@ -37,7 +37,7 @@ map("n", "gr", "Telescope lsp_references", { desc = "[G]oto [R]eference map("n", "gI", "Telescope lsp_implementations", { desc = "[G]oto [I]mplementations" }) map("n", "gD", vim.lsp.buf.declaration, { desc = "[G]oto [D]eclaration" }) map("n", "", function() - vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled()) + vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({ bufnr = 0 })) end, { desc = "Toggle Inlay Hint" }) map("n", "ca", vim.lsp.buf.code_action, { desc = "[C]ode [A]ction" }) map("n", "ws", require("telescope.builtin").lsp_dynamic_workspace_symbols, { desc = "[W]orkspace [S]ymbols" }) diff --git a/.config/nvim/lua/nvwynd/plugins/formatting.lua b/.config/nvim/lua/nvwynd/plugins/formatting.lua index 4c14b79..8dc09e6 100644 --- a/.config/nvim/lua/nvwynd/plugins/formatting.lua +++ b/.config/nvim/lua/nvwynd/plugins/formatting.lua @@ -25,11 +25,12 @@ return { scss = { "prettier" }, markdown = { "dprint" }, zig = { "zigfmt" }, + toml = { "taplo" }, }, format_on_save = { timeout_ms = 500, lsp_fallback = true, - quiet = true, + -- quiet = true, }, }, init = function() diff --git a/.config/nvim/lua/nvwynd/plugins/lsp.lua b/.config/nvim/lua/nvwynd/plugins/lsp.lua index 45c7b83..dbee90a 100644 --- a/.config/nvim/lua/nvwynd/plugins/lsp.lua +++ b/.config/nvim/lua/nvwynd/plugins/lsp.lua @@ -38,6 +38,10 @@ return { }, }) + lspconfig.taplo.setup({ + capabilities = capabilities, + }) + -- HTMX -- lspconfig.htmx.setup({ -- capabilities = capabilities, diff --git a/.config/nvim/lua/nvwynd/plugins/treesitter.lua b/.config/nvim/lua/nvwynd/plugins/treesitter.lua index 9011a36..c2d1a17 100644 --- a/.config/nvim/lua/nvwynd/plugins/treesitter.lua +++ b/.config/nvim/lua/nvwynd/plugins/treesitter.lua @@ -42,7 +42,6 @@ return { sync_install = false, highlight = { enable = true }, indent = { enable = true }, - autotag = { enable = true }, }) end, }, diff --git a/.config/nvim/lua/nvwynd/plugins/ui.lua b/.config/nvim/lua/nvwynd/plugins/ui.lua index a9bab49..e3d975f 100644 --- a/.config/nvim/lua/nvwynd/plugins/ui.lua +++ b/.config/nvim/lua/nvwynd/plugins/ui.lua @@ -1,3 +1,28 @@ +local function has_lsp() + local buf = vim.api.nvim_get_current_buf() + local clients = vim.lsp.get_clients({ bufnr = buf }) + + return #clients > 0 +end + +local function language_servers() + local buf = vim.api.nvim_get_current_buf() + local clients = vim.lsp.get_clients({ bufnr = buf }) + + -- Shouldn't happen as we have the above has_lsp func but just in case + if #clients == 0 then + return "none" + end + + local names = "" + + for _, client in ipairs(clients) do + names = names .. client.name .. " " + end + + return names +end + return { { "stevearc/dressing.nvim", @@ -8,4 +33,24 @@ return { "rcarriga/nvim-notify", opts = {}, }, + + { + "nvim-lualine/lualine.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + opts = { + options = { + disabled_filetypes = { "neo-tree" }, + globalstatus = true, + }, + sections = { + lualine_y = { + "progress", + { + language_servers, + cond = has_lsp, + }, + }, + }, + }, + }, }