From ddbcbcbe498330735b2ecae5ac98b3058f4e41db Mon Sep 17 00:00:00 2001 From: V1OL3TF0X Date: Fri, 17 Apr 2026 19:00:58 +0200 Subject: [PATCH 1/4] (feat): update oxfmt and oxlint to detect vite plus --- lsp/oxfmt.lua | 7 +++++-- lsp/oxlint.lua | 13 ++++++++++++- lua/lspconfig/util.lua | 7 +++++-- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/lsp/oxfmt.lua b/lsp/oxfmt.lua index e2a7666035..7336a2ae56 100644 --- a/lsp/oxfmt.lua +++ b/lsp/oxfmt.lua @@ -51,8 +51,11 @@ return { -- Oxfmt resolves configuration by walking upward and using the nearest config file -- to the file being processed. We therefore compute the root directory by locating -- the closest `.oxfmtrc.json` / `.oxfmtrc.jsonc` / `oxfmt.config.ts` (or `package.json` fallback) above the buffer. - local root_markers = - util.insert_package_json({ '.oxfmtrc.json', '.oxfmtrc.jsonc', 'oxfmt.config.ts' }, 'oxfmt', fname) + local root_markers = util.insert_package_json( + { '.oxfmtrc.json', '.oxfmtrc.jsonc', 'oxfmt.config.ts' }, + { 'oxfmt', 'vite%-plus' }, + fname + ) on_dir(vim.fs.dirname(vim.fs.find(root_markers, { path = fname, upward = true })[1])) end, } diff --git a/lsp/oxlint.lua b/lsp/oxlint.lua index 06d395fe82..69166bccb9 100644 --- a/lsp/oxlint.lua +++ b/lsp/oxlint.lua @@ -17,6 +17,7 @@ --- The default `on_attach` function provides an `:LspOxlintFixAll` command which --- can be used to fix all fixable diagnostics. See the `eslint` config entry for --- an example of how to use this to automatically fix all errors on write. +local util = require 'lspconfig.util' local function oxlint_conf_mentions_typescript(root_dir) local fn = vim.fs.joinpath(root_dir, '.oxlintrc.json') @@ -49,7 +50,17 @@ return { 'svelte', 'astro', }, - root_markers = { '.oxlintrc.json', '.oxlintrc.jsonc', 'oxlint.config.ts' }, + root_dir = function(bufnr, on_dir) + local fname = vim.api.nvim_buf_get_name(bufnr) + + local root_markers = util.insert_package_json( + { '.oxlintrc.json', '.oxlintrc.jsonc', 'oxlint.config.ts' }, + { 'oxfmt', 'vite%-plus' }, + fname + ) + on_dir(vim.fs.dirname(vim.fs.find(root_markers, { path = fname, upward = true })[1])) + end, + workspace_required = true, on_attach = function(client, bufnr) vim.api.nvim_buf_create_user_command(bufnr, 'LspOxlintFixAll', function() diff --git a/lua/lspconfig/util.lua b/lua/lspconfig/util.lua index 2282e3e26a..7c1afed62a 100644 --- a/lua/lspconfig/util.lua +++ b/lua/lspconfig/util.lua @@ -55,17 +55,20 @@ end --- --- @param root_files string[] List of root-marker files to append to. --- @param new_names string[] Potential root-marker filenames (e.g. `{ 'package.json', 'package.json5' }`) to inspect for the given `field`. ---- @param field string Field to search for in the given `new_names` files. +--- @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) 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 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 line:find(field) then + if vim.iter(fields):any(function(s) + return line:find(s) + end) then root_files[#root_files + 1] = vim.fs.basename(f) break end From 29be06f70a16c126fa522b7dcad2da3c782f68a6 Mon Sep 17 00:00:00 2001 From: V1OL3TF0X Date: Fri, 17 Apr 2026 19:04:09 +0200 Subject: [PATCH 2/4] fix typo --- lsp/oxlint.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lsp/oxlint.lua b/lsp/oxlint.lua index 69166bccb9..8e18c559d3 100644 --- a/lsp/oxlint.lua +++ b/lsp/oxlint.lua @@ -55,7 +55,7 @@ return { local root_markers = util.insert_package_json( { '.oxlintrc.json', '.oxlintrc.jsonc', 'oxlint.config.ts' }, - { 'oxfmt', 'vite%-plus' }, + { 'oxlint', 'vite%-plus' }, fname ) on_dir(vim.fs.dirname(vim.fs.find(root_markers, { path = fname, upward = true })[1])) From 67282295e90401fd140547b06390530eb03f2b08 Mon Sep 17 00:00:00 2001 From: V1OL3TF0X Date: Fri, 17 Apr 2026 19:13:00 +0200 Subject: [PATCH 3/4] (fix): consistent spaces --- lsp/oxlint.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/lsp/oxlint.lua b/lsp/oxlint.lua index 8e18c559d3..f82696c237 100644 --- a/lsp/oxlint.lua +++ b/lsp/oxlint.lua @@ -60,7 +60,6 @@ return { ) on_dir(vim.fs.dirname(vim.fs.find(root_markers, { path = fname, upward = true })[1])) end, - workspace_required = true, on_attach = function(client, bufnr) vim.api.nvim_buf_create_user_command(bufnr, 'LspOxlintFixAll', function() From db5382e3eb04313bf7d82090f181a5ec36ca0013 Mon Sep 17 00:00:00 2001 From: V1OL3TF0X Date: Fri, 17 Apr 2026 22:53:30 +0200 Subject: [PATCH 4/4] feat: add vite config to root markers forgot that vite config can be also a marker if it has vite-plus import, added --- lsp/oxfmt.lua | 1 + lsp/oxlint.lua | 1 + 2 files changed, 2 insertions(+) diff --git a/lsp/oxfmt.lua b/lsp/oxfmt.lua index 7336a2ae56..1c299cf01e 100644 --- a/lsp/oxfmt.lua +++ b/lsp/oxfmt.lua @@ -56,6 +56,7 @@ return { { 'oxfmt', 'vite%-plus' }, fname ) + root_markers = util.root_markers_with_field(root_markers, { 'vite.config.ts' }, 'vite%-plus', fname) on_dir(vim.fs.dirname(vim.fs.find(root_markers, { path = fname, upward = true })[1])) end, } diff --git a/lsp/oxlint.lua b/lsp/oxlint.lua index f82696c237..4030071e93 100644 --- a/lsp/oxlint.lua +++ b/lsp/oxlint.lua @@ -58,6 +58,7 @@ return { { 'oxlint', 'vite%-plus' }, fname ) + root_markers = util.root_markers_with_field(root_markers, { 'vite.config.ts' }, 'vite%-plus', fname) on_dir(vim.fs.dirname(vim.fs.find(root_markers, { path = fname, upward = true })[1])) end, workspace_required = true,