Added support to use a array of regex to ignore files

This commit is contained in:
Dheisom Gomes 2022-01-28 12:02:30 -03:00
parent 8c0685d440
commit 6331a23c6b
3 changed files with 16 additions and 3 deletions

View File

@ -1,3 +1,5 @@
local config = require 'core.config'
local common = {}
@ -445,4 +447,15 @@ function common.rm(path, recursively)
return true
end
---@param filename string
---@return boolean
function common.match_ignore_files(filename)
for _, pattern in ipairs(config.ignore_files) do
if common.match_pattern(filename, pattern) then
return true
end
end
return false
end
return common

View File

@ -6,7 +6,7 @@ config.message_timeout = 5
config.mouse_wheel_scroll = 50 * SCALE
config.scroll_past_end = true
config.file_size_limit = 10
config.ignore_files = "^%."
config.ignore_files = { "^%.", "node_modules" }
config.symbol_pattern = "[%a_][%w_]*"
config.non_word_chars = " \t\n/\\()\"':,.;<>~!@#$%^&*|+=[]{}`?-"
config.undo_merge_timeout = 0.3

View File

@ -100,7 +100,7 @@ local function get_project_file_info(root, file)
if info then
info.filename = strip_leading_path(file)
return (info.size < config.file_size_limit * 1e6 and
not common.match_pattern(common.basename(info.filename), config.ignore_files)
not common.match_ignore_files(common.basename(info.filename))
and info)
end
end
@ -462,7 +462,7 @@ end
local function project_scan_add_file(dir, filepath)
for fragment in string.gmatch(filepath, "([^/\\]+)") do
if common.match_pattern(fragment, config.ignore_files) then
if common.match_ignore_files(fragment) then
return
end
end