removes root_dir in favor of root_markers
This commit is contained in:
parent
3d0fd6065a
commit
0062bf43e3
1 changed files with 1 additions and 34 deletions
|
|
@ -45,40 +45,7 @@ return {
|
||||||
}, nil, bufnr)
|
}, nil, bufnr)
|
||||||
end, {})
|
end, {})
|
||||||
end,
|
end,
|
||||||
root_dir = function(bufnr, on_dir)
|
root_markers = eslint_config_files,
|
||||||
-- The project root is where the LSP can be started from
|
|
||||||
-- As stated in the documentation above, this LSP supports monorepos and simple projects.
|
|
||||||
-- We select then from the project root, which is identified by the presence of a package
|
|
||||||
-- manager lock file.
|
|
||||||
local root_markers = { "package-lock.json", "yarn.lock", "pnpm-lock.yaml", "bun.lockb", "bun.lock", "deno.lock" }
|
|
||||||
-- Give the root markers equal priority by wrapping them in a table
|
|
||||||
root_markers = vim.fn.has("nvim-0.11.3") == 1 and { root_markers } or root_markers
|
|
||||||
local project_root = vim.fs.root(bufnr, root_markers)
|
|
||||||
if not project_root then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- We know that the buffer is using ESLint if it has a config file
|
|
||||||
-- in its directory tree.
|
|
||||||
--
|
|
||||||
-- Eslint used to support package.json files as config files, but it doesn't anymore.
|
|
||||||
-- We keep this for backward compatibility.
|
|
||||||
local filename = vim.api.nvim_buf_get_name(bufnr)
|
|
||||||
local eslint_config_files_with_package_json =
|
|
||||||
utils.insert_package_json(eslint_config_files, "eslintConfig", filename)
|
|
||||||
local is_buffer_using_eslint = vim.fs.find(eslint_config_files_with_package_json, {
|
|
||||||
path = filename,
|
|
||||||
type = "file",
|
|
||||||
limit = 1,
|
|
||||||
upward = true,
|
|
||||||
stop = vim.fs.dirname(project_root),
|
|
||||||
})[1]
|
|
||||||
if not is_buffer_using_eslint then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
on_dir(project_root)
|
|
||||||
end,
|
|
||||||
-- Refer to https://github.com/Microsoft/vscode-eslint#settings-options for documentation.
|
-- Refer to https://github.com/Microsoft/vscode-eslint#settings-options for documentation.
|
||||||
settings = {
|
settings = {
|
||||||
validate = "on",
|
validate = "on",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue