aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrançois Lachèse <33827360+FLchs@users.noreply.github.com>2026-01-29 22:29:02 +0100
committerGitHub <noreply@github.com>2026-01-29 22:29:02 +0100
commitbf8ede7302fcd0f09361fe03b8afa0fb001df67e (patch)
tree122b61735cb7c840f288c21b7ce1da55069a86bb
parentdocs: update configs.md (diff)
downloadnvim-lspconfig-bf8ede7302fcd0f09361fe03b8afa0fb001df67e.tar
nvim-lspconfig-bf8ede7302fcd0f09361fe03b8afa0fb001df67e.tar.gz
nvim-lspconfig-bf8ede7302fcd0f09361fe03b8afa0fb001df67e.tar.bz2
nvim-lspconfig-bf8ede7302fcd0f09361fe03b8afa0fb001df67e.tar.lz
nvim-lspconfig-bf8ede7302fcd0f09361fe03b8afa0fb001df67e.tar.xz
nvim-lspconfig-bf8ede7302fcd0f09361fe03b8afa0fb001df67e.tar.zst
nvim-lspconfig-bf8ede7302fcd0f09361fe03b8afa0fb001df67e.zip
feat(oxlint/oxfmt): adopt and fully integrate the recommended language servers (#4242)
* feat(oxlint): use new oxlint --lsp command * chores(oxlint): improve the root_dir logic to better match what oxlint does * feat(oxlint): add default init config comments * feat(oxlint): add LspOxlintFixAll command * docs(oxlint): improve docs * feat(oxfmt): add oxfmt language server * fix(oxlint): fix lint issues * Update lsp/oxfmt.lua Co-authored-by: Tim Shilov <tim@shilov.dev> * Update lsp/oxlint.lua Co-authored-by: Tim Shilov <tim@shilov.dev> * fix(oxlint/oxfmt): use root_dir as workspaceUri * fix: correct configuration after oxc release * fix: add supported Oxfmt languages * fix: add languages supported by Oxlint --------- Co-authored-by: Tim Shilov <tim@shilov.dev>
-rw-r--r--lsp/oxfmt.lua52
-rw-r--r--lsp/oxlint.lua37
2 files changed, 86 insertions, 3 deletions
diff --git a/lsp/oxfmt.lua b/lsp/oxfmt.lua
new file mode 100644
index 00000000..c0b35198
--- /dev/null
+++ b/lsp/oxfmt.lua
@@ -0,0 +1,52 @@
+--- @brief
+---
+--- https://github.com/oxc-project/oxc
+--- https://oxc.rs/docs/guide/usage/formatter.html
+---
+--- `oxfmt` is a Prettier-compatible code formatter that supports multiple languages
+--- including JavaScript, TypeScript, JSON, YAML, HTML, CSS, Markdown, and more.
+--- It can be installed via `npm`:
+---
+--- ```sh
+--- npm i -g oxfmt
+--- ```
+
+local util = require 'lspconfig.util'
+
+---@type vim.lsp.Config
+return {
+ cmd = { 'oxfmt', '--lsp' },
+ filetypes = {
+ 'javascript',
+ 'javascriptreact',
+ 'javascript.jsx',
+ 'typescript',
+ 'typescriptreact',
+ 'typescript.tsx',
+ 'toml',
+ 'json',
+ 'jsonc',
+ 'json5',
+ 'yaml',
+ 'html',
+ 'vue',
+ 'handlebars',
+ 'hbs',
+ 'css',
+ 'scss',
+ 'less',
+ 'graphql',
+ 'markdown',
+ 'mdx',
+ },
+ workspace_required = true,
+ root_dir = function(bufnr, on_dir)
+ local fname = vim.api.nvim_buf_get_name(bufnr)
+
+ -- 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` (or `package.json` fallback) above the buffer.
+ local root_markers = util.insert_package_json({ '.oxfmtrc.json' }, 'oxfmt', fname)[1]
+ 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 4585a985..ddf13eff 100644
--- a/lsp/oxlint.lua
+++ b/lsp/oxlint.lua
@@ -1,8 +1,10 @@
--- @brief
---
--- https://github.com/oxc-project/oxc
+--- https://oxc.rs/docs/guide/usage/linter.html
---
---- `oxc` is a linter / formatter for JavaScript / Typescript supporting over 500 rules from ESLint and its popular plugins
+--- `oxlint` is a linter for JavaScript / TypeScript supporting over 500 rules from ESLint and its popular plugins.
+--- It also supports linting framework files (Vue, Svelte, Astro) by analyzing their <script> blocks.
--- It can be installed via `npm`:
---
--- ```sh
@@ -13,7 +15,7 @@ local util = require 'lspconfig.util'
---@type vim.lsp.Config
return {
- cmd = { 'oxc_language_server' },
+ cmd = { 'oxlint', '--lsp' },
filetypes = {
'javascript',
'javascriptreact',
@@ -21,11 +23,40 @@ return {
'typescript',
'typescriptreact',
'typescript.tsx',
+ 'vue',
+ 'svelte',
+ 'astro',
},
workspace_required = true,
+ on_attach = function(client, bufnr)
+ vim.api.nvim_buf_create_user_command(bufnr, 'LspOxlintFixAll', function()
+ client:exec_cmd({
+ title = 'Apply Oxlint automatic fixes',
+ command = 'oxc.fixAll',
+ arguments = { { uri = vim.uri_from_bufnr(bufnr) } },
+ })
+ end, {
+ desc = 'Apply Oxlint automatic fixes',
+ })
+ end,
root_dir = function(bufnr, on_dir)
local fname = vim.api.nvim_buf_get_name(bufnr)
- local root_markers = util.insert_package_json({ '.oxlintrc.json' }, 'oxlint', fname)
+
+ -- Oxlint 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 `.oxlintrc.json` (or `package.json` fallback) above the buffer.
+ local root_markers = util.insert_package_json({ '.oxlintrc.json' }, 'oxlint', fname)[1]
on_dir(vim.fs.dirname(vim.fs.find(root_markers, { path = fname, upward = true })[1]))
end,
+ init_options = {
+ settings = {
+ -- ['run'] = 'onType',
+ -- ['configPath'] = nil,
+ -- ['tsConfigPath'] = nil,
+ -- ['unusedDisableDirectives'] = 'allow',
+ -- ['typeAware'] = false,
+ -- ['disableNestedConfig'] = false,
+ -- ['fixKind'] = 'safe_fix',
+ },
+ },
}