From 0430df7d54022a26a28f2b782c89489628d8ba25 Mon Sep 17 00:00:00 2001 From: Leonardo Mora <66377812+LeonardoMor@users.noreply.github.com> Date: Tue, 9 Jul 2024 07:12:18 -0600 Subject: [PATCH] Install all linters (#309) * fix(nvim-lint): add/correct some linters Squashed commit of the following: commit 5d6c844978b0b7a8acfc607cbfdab3dfb63d8392 Author: Leonardo Mora Date: Mon Jul 8 12:09:01 2024 -0600 feat(nvim-lint): add snyk and htmlhint See: https://github.com/rshkarin/mason-nvim-lint/issues/8 commit 984d655b220a3b235b81fcbcc6c3eb0c3d9a0e0c Author: Leonardo Mora Date: Mon Jul 8 11:57:02 2024 -0600 fix(nvim-lint): correct ansible-lint mapping See: https://github.com/rshkarin/mason-nvim-lint/pull/9 commit 806b42fa650f97a8bac445bd727552261dee81ec Author: Leonardo Mora Date: Mon Jul 8 11:55:03 2024 -0600 feat(nvim-lint): add checkmake Linter for Makefiles. See: https://github.com/rshkarin/mason-nvim-lint/pull/10 commit a376b63f49fd02f3502b006108fc373b1efb5611 Author: Leonardo Mora Date: Sun Jul 7 19:41:15 2024 -0600 refactor(formatters): better name * fix(MasonInstallAll): fix linters installation. Fixes #308 * refactor(get_pkgs): expose this function I find this extremely useful. So added this to have access to this table. * refactor(get_pkgs): consider data when handling duplicates The way it was, you could end up with duplicates introduced by the incoming data list. * refactor: no need to re-assign the source table when using vim.list_extend --- lua/nvchad/mason/init.lua | 16 ++++++++-------- lua/nvchad/mason/names.lua | 5 ++++- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/lua/nvchad/mason/init.lua b/lua/nvchad/mason/init.lua index 6f00e644..ed9372ff 100644 --- a/lua/nvchad/mason/init.lua +++ b/lua/nvchad/mason/init.lua @@ -1,22 +1,22 @@ local M = {} local masonames = require "nvchad.mason.names" -local get_pkgs = function(data) +M.get_pkgs = function(data) local tools = {} local lsps = require("lspconfig.util").available_servers() - tools = vim.list_extend(tools, lsps) + vim.list_extend(tools, lsps) local conform_exists, conform = pcall(require, "conform") if conform_exists then local formatters = conform.list_all_formatters() - local formatters_names = vim.tbl_map(function(formatter) + local formatter_names = vim.tbl_map(function(formatter) return formatter.name end, formatters) - tools = vim.list_extend(tools, formatters_names) + vim.list_extend(tools, formatter_names) end local lint_exists, lint = pcall(require, "lint") @@ -25,11 +25,11 @@ local get_pkgs = function(data) local linters = lint.linters_by_ft for _, v in pairs(linters) do - table.insert(tools, v[1]) + vim.list_extend(tools, v) end end - local pkgs = {} + local pkgs = data or {} -- rm duplicates for _, v in pairs(tools) do @@ -38,7 +38,7 @@ local get_pkgs = function(data) end end - return vim.list_extend(pkgs, data or {}) + return pkgs end M.install_all = function(data) @@ -47,7 +47,7 @@ M.install_all = function(data) local mr = require "mason-registry" mr.refresh(function() - for _, tool in ipairs(get_pkgs(data)) do + for _, tool in ipairs(M.get_pkgs(data)) do local p = mr.get_package(tool) if not p:is_installed() then diff --git a/lua/nvchad/mason/names.lua b/lua/nvchad/mason/names.lua index 885b8324..cd5c8d3f 100644 --- a/lua/nvchad/mason/names.lua +++ b/lua/nvchad/mason/names.lua @@ -332,7 +332,7 @@ return { -- nvim-lint actionlint = "actionlint", - ansible_lint = "ansible_lint", + ansible_lint = "ansible-lint", buf_lint = "buf", ["cfn_lint"] = "cfn-lint", checkstyle = "checkstyle", @@ -346,6 +346,7 @@ return { gdlint = "gdtoolkit", golangcilint = "golangci-lint", hadolint = "hadolint", + htmlhint = "htmlhint", jsonlint = "jsonlint", luacheck = "luacheck", mypy = "mypy", @@ -358,6 +359,7 @@ return { revive = "revive", rstcheck = "rstcheck", selene = "selene", + snyk = "snyk", solhint = "solhint", tfsec = "tfsec", trivy = "trivy", @@ -365,4 +367,5 @@ return { vint = "vint", vulture = "vulture", yamllint = "yamllint", + checkmake = "checkmake", }