From db02e1b978837be2d645500401ff9e4cd62a0d75 Mon Sep 17 00:00:00 2001 From: nabekou29 Date: Sun, 22 Dec 2024 02:46:49 +0900 Subject: [PATCH] fix: ignore node_modules in searching translation file --- lua/js-i18n/reference_table.lua | 1 + lua/js-i18n/translation_source.lua | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lua/js-i18n/reference_table.lua b/lua/js-i18n/reference_table.lua index ae18483..6546a7f 100644 --- a/lua/js-i18n/reference_table.lua +++ b/lua/js-i18n/reference_table.lua @@ -42,6 +42,7 @@ function ReferenceTable:load_all() end return entry:match("%.jsx?$") or entry:match("%.tsx?$") end, + respect_gitignore = true, on_insert = function(path) self:load_path(path) end, diff --git a/lua/js-i18n/translation_source.lua b/lua/js-i18n/translation_source.lua index 6a34005..a47b290 100644 --- a/lua/js-i18n/translation_source.lua +++ b/lua/js-i18n/translation_source.lua @@ -28,7 +28,13 @@ function M.get_translation_files(dir) local regexps = get_translation_source_regex() scan.scan_dir(dir, { - search_pattern = "%.json$", + search_pattern = function(entry) + if entry:match("node_modules") then + return false + end + return entry:match("%.json$") + end, + respect_gitignore = true, on_insert = function(path) for _, regexp in ipairs(regexps) do local match_s = regexp:match_str(path) @@ -39,6 +45,7 @@ function M.get_translation_files(dir) end end, }) + return result end