From e51a2652dabfb2daedffee3a1511dd9c5f075eec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20La=C3=ADn?= Date: Sat, 24 Feb 2024 01:24:24 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(nvim):=20add=20new=20keymap=20?= =?UTF-8?q?to=20show=20linters=20attached=20to=20current=20buffer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .config/nvim/lua/config/keymaps.lua | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/.config/nvim/lua/config/keymaps.lua b/.config/nvim/lua/config/keymaps.lua index 5356ac1d..5eeed383 100644 --- a/.config/nvim/lua/config/keymaps.lua +++ b/.config/nvim/lua/config/keymaps.lua @@ -17,7 +17,8 @@ map("n", "l", "") map("n", "ll", "Lazy", { desc = "Lazy" }) -- stylua: ignore start map("n", "ld", function() vim.fn.system({ "xdg-open", "https://lazyvim.org" }) end, { desc = "LazyVim Docs" }) -map("n", "lr", function() vim.fn.system({ "xdg-open", "https://github.com/LazyVim/LazyVim" }) end, { desc = "LazyVim Repo" }) +map("n", "lr", function() vim.fn.system({ "xdg-open", "https://github.com/LazyVim/LazyVim" }) end, + { desc = "LazyVim Repo" }) map("n", "lx", "LazyExtras", { desc = "Extras" }) map("n", "lc", function() Util.news.changelog() end, { desc = "LazyVim Changelog" }) map("n", "lu", function() require("lazy").update() end, { desc = "Lazy Update" }) @@ -91,6 +92,25 @@ map("n", "[/", "?\\S\\zs\\s*╭zt", { desc = "Prev block comment" }) -- Plugin Info map("n", "cif", "LazyFormatInfo", { desc = "Formatting" }) map("n", "cic", "ConformInfo", { desc = "Conform" }) +local linters = function() + local linters_attached = require("lint").linters_by_ft[vim.bo.filetype] + local buf_linters = {} + + if not linters_attached then + vim.notify("No linters attached", vim.log.levels.WARN, { title = "Linter" }) + return + end + + for _, linter in pairs(linters_attached) do + table.insert(buf_linters, linter) + end + + local unique_client_names = table.concat(buf_linters, ", ") + local linters = string.format("%s", unique_client_names) + + vim.notify(linters, vim.log.levels.INFO, { title = "Linter" }) +end +map("n", "ciL", linters, { desc = "Lint" }) map("n", "cir", "LazyRoot", { desc = "Root" }) -- U for redo