nvim/lsp/oxfmt.lua
Simon Lasbrugnas a2e5555c64
fix(lsp)!: actually use the root lsp/ folder and remove
lua/custom/lsp/** configs

This commit removes the need for nvim-lspconfig which is replaced by the
vim.lsp API.

The lsp/ folder is a copy of nvim-lspconfig's lsp/ folder as it makes it
easy to modify LSP configurations on the fly.

Conform: biome has been replaced with oxfmt
2026-02-02 16:16:06 +01:00

52 lines
1.3 KiB
Lua

--- @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,
}