diff options
| author | VI0L3TF0X <73484028+V1OL3TF0X@users.noreply.github.com> | 2026-05-21 16:36:13 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-05-21 10:36:13 -0400 |
| commit | dfbada1a311c4bf3369f8d5421369c9b6e8b888f (patch) | |
| tree | dd9fe4bb2274db1adaed41a7a2fd908a10fbe5df /lua | |
| parent | docs: update generated annotations (diff) | |
| download | nvim-lspconfig-dfbada1a311c4bf3369f8d5421369c9b6e8b888f.tar nvim-lspconfig-dfbada1a311c4bf3369f8d5421369c9b6e8b888f.tar.gz nvim-lspconfig-dfbada1a311c4bf3369f8d5421369c9b6e8b888f.tar.bz2 nvim-lspconfig-dfbada1a311c4bf3369f8d5421369c9b6e8b888f.tar.lz nvim-lspconfig-dfbada1a311c4bf3369f8d5421369c9b6e8b888f.tar.xz nvim-lspconfig-dfbada1a311c4bf3369f8d5421369c9b6e8b888f.tar.zst nvim-lspconfig-dfbada1a311c4bf3369f8d5421369c9b6e8b888f.zip | |
fix(oxc): fix oxlint, oxfmt vite plus config search #4434
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/lspconfig/util.lua | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/lua/lspconfig/util.lua b/lua/lspconfig/util.lua index 7c1afed6..d2994d28 100644 --- a/lua/lspconfig/util.lua +++ b/lua/lspconfig/util.lua @@ -57,18 +57,36 @@ end --- @param new_names string[] Potential root-marker filenames (e.g. `{ 'package.json', 'package.json5' }`) to inspect for the given `field`. --- @param field string | string[] Field(s) to search for in the given `new_names` files. --- @param fname string Full path of the current buffer name to start searching upwards from. -function M.root_markers_with_field(root_files, new_names, field, fname) +--- @param match_mode? 'all' | 'any' Match mode - all or any field passed as `field` +function M.root_markers_with_field(root_files, new_names, field, fname, match_mode) local path = vim.fn.fnamemodify(fname, ':h') local found = vim.fs.find(new_names, { path = path, upward = true, type = 'file' }) local fields = type(field) == 'string' and { field } or field - + local to_find = vim.deepcopy(fields) + local matcher = (match_mode or 'any') == 'any' + and function(line) + return vim.iter(fields):any(function(s) + return line:find(s) + end) + end + or function(line) + to_find = vim + .iter(to_find) + :filter(function(s) + return not line:find(s) + end) + :totable() + if #to_find == 0 then + to_find = vim.deepcopy(files) + return true + end + return false + end for _, f in ipairs(found or {}) do -- Match the given `field`. local file = assert(io.open(f, 'r')) for line in file:lines() do - if vim.iter(fields):any(function(s) - return line:find(s) - end) then + if matcher(line) then root_files[#root_files + 1] = vim.fs.basename(f) break end |
