From ad0153fa20fd6361c334dab9c3be7f39e860a8d3 Mon Sep 17 00:00:00 2001 From: Micah Halter Date: Thu, 19 Sep 2024 13:39:19 -0400 Subject: [PATCH] refactor(nvim-lint): use new `patch_func` utility --- lua/astrocommunity/lsp/nvim-lint/init.lua | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lua/astrocommunity/lsp/nvim-lint/init.lua b/lua/astrocommunity/lsp/nvim-lint/init.lua index ad1e6f656..6d3573dd1 100644 --- a/lua/astrocommunity/lsp/nvim-lint/init.lua +++ b/lua/astrocommunity/lsp/nvim-lint/init.lua @@ -8,7 +8,7 @@ return { }, opts = {}, config = function(_, opts) - local lint = require "lint" + local lint, astrocore = require "lint", require "astrocore" lint.linters_by_ft = opts.linters_by_ft or {} for name, linter in pairs(opts.linters or {}) do @@ -28,17 +28,16 @@ return { end, linters) end - local orig_resolve_linter_by_ft = lint._resolve_linter_by_ft - lint._resolve_linter_by_ft = function(...) + lint._resolve_linter_by_ft = astrocore.patch_func(lint._resolve_linter_by_ft, function(orig, ...) local ctx = { filename = vim.api.nvim_buf_get_name(0) } ctx.dirname = vim.fn.fnamemodify(ctx.filename, ":h") - local linters = valid_linters(ctx, orig_resolve_linter_by_ft(...)) + local linters = valid_linters(ctx, orig(...)) if not linters[1] then linters = valid_linters(ctx, lint.linters_by_ft["_"]) end -- fallback - require("astrocore").list_insert_unique(linters, valid_linters(ctx, lint.linters_by_ft["*"])) -- global + astrocore.list_insert_unique(linters, valid_linters(ctx, lint.linters_by_ft["*"])) -- global return linters - end + end) lint.try_lint() -- start linter immediately local timer = vim.loop.new_timer()