moves to eslint lsp

This commit is contained in:
Dennis 2025-09-09 09:06:20 +02:00
parent 91dd752b66
commit 11eca2baa5
5 changed files with 217 additions and 71 deletions

View file

@ -16,7 +16,7 @@ end
function search_ancestors(startpath, func)
if nvim_eleven then
validate('func', func, 'function')
validate("func", func, "function")
end
if func(startpath) then
return startpath
@ -36,13 +36,13 @@ function search_ancestors(startpath, func)
end
local function escape_wildcards(path)
return path:gsub('([%[%]%?%*])', '\\%1')
return path:gsub("([%[%]%?%*])", "\\%1")
end
function strip_archive_subpath(path)
-- Matches regex from zip.vim / tar.vim
path = vim.fn.substitute(path, 'zipfile://\\(.\\{-}\\)::[^\\\\].*$', '\\1', '')
path = vim.fn.substitute(path, 'tarfile:\\(.\\{-}\\)::.*$', '\\1', '')
path = vim.fn.substitute(path, "zipfile://\\(.\\{-}\\)::[^\\\\].*$", "\\1", "")
path = vim.fn.substitute(path, "tarfile:\\(.\\{-}\\)::.*$", "\\1", "")
return path
end
@ -125,9 +125,32 @@ local function compile_project()
vim.cmd("startinsert")
end
local function root_markers_with_field(root_files, new_names, field, fname)
local path = vim.fn.fnamemodify(fname, ":h")
local found = vim.fs.find(new_names, { path = path, upward = true })
for _, f in ipairs(found or {}) do
-- Match the given `field`.
for line in io.lines(f) do
if line:find(field) then
root_files[#root_files + 1] = vim.fs.basename(f)
break
end
end
end
return root_files
end
local function insert_package_json(root_files, field, fname)
return root_markers_with_field(root_files, { "package.json", "package.json5" }, field, fname)
end
return {
compile_project = compile_project,
filter = filter,
filterReactDTS = filterReactDTS,
root_pattern = root_pattern
root_pattern = root_pattern,
insert_package_json = insert_package_json,
root_markers_with_field = root_markers_with_field,
}