✨ feat(nvim): added biome linter and formatter extra
This commit is contained in:
parent
18fd0d391a
commit
fa6ec57b7d
3 changed files with 61 additions and 8 deletions
|
@ -45,7 +45,7 @@
|
|||
"plugins.extras.editor.telescope.zoxide",
|
||||
"plugins.extras.editor.terminal.floaterm",
|
||||
"plugins.extras.formatting.isort",
|
||||
"plugins.extras.formatting.prettier",
|
||||
"plugins.extras.formatting.prettier-extended",
|
||||
"plugins.extras.formatting.rustfmt",
|
||||
"plugins.extras.formatting.trim_newlines",
|
||||
"plugins.extras.formatting.trim_whitespace",
|
||||
|
@ -58,6 +58,7 @@
|
|||
"plugins.extras.lang.sql",
|
||||
"plugins.extras.lang.web.html-css",
|
||||
"plugins.extras.lang.web.typescript-extended",
|
||||
"plugins.extras.linting.biome",
|
||||
"plugins.extras.linting.cspell",
|
||||
"plugins.extras.linting.eslint-extended",
|
||||
"plugins.extras.linting.shellcheck",
|
||||
|
|
57
.config/nvim/lua/plugins/extras/linting/biome.lua
Normal file
57
.config/nvim/lua/plugins/extras/linting/biome.lua
Normal file
|
@ -0,0 +1,57 @@
|
|||
return {
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
opts = function(_, opts)
|
||||
opts.ensure_installed = opts.ensure_installed or {}
|
||||
vim.list_extend(opts.ensure_installed, { "biome" })
|
||||
end,
|
||||
},
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
opts = {
|
||||
servers = {
|
||||
biome = {
|
||||
root_dir = require("lspconfig").util.root_pattern("biome.json"),
|
||||
single_file_support = false,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"stevearc/conform.nvim",
|
||||
opts = function(_, opts)
|
||||
--- Extend the conform plugin config and add given formatters
|
||||
---@param tbl table<string, conform.FormatterUnit[]> Table of filetype to formatters mappings
|
||||
local function add_formatters(tbl)
|
||||
for ft, formatters in pairs(tbl) do
|
||||
if opts.formatters_by_ft[ft] == nil then
|
||||
opts.formatters_by_ft[ft] = formatters
|
||||
else
|
||||
vim.list_extend(opts.formatters_by_ft[ft], formatters)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
add_formatters({
|
||||
["jsonc"] = { "biome" },
|
||||
["json"] = { "biome" },
|
||||
["javascript"] = { "biome" },
|
||||
["typescript"] = { "biome" },
|
||||
["typescriptreact"] = { "biome" },
|
||||
["javascriptreact"] = { "biome" },
|
||||
})
|
||||
opts.formatters = {
|
||||
biome = {
|
||||
condition = function(self, ctx)
|
||||
return vim.fs.find({ "biome.json" }, { path = ctx.filename, upward = true })[1]
|
||||
end,
|
||||
},
|
||||
prettier = {
|
||||
condition = function(self, ctx)
|
||||
return not vim.fs.find({ "biome.json" }, { path = ctx.filename, upward = true })[1]
|
||||
end,
|
||||
},
|
||||
}
|
||||
end,
|
||||
},
|
||||
}
|
|
@ -4,19 +4,14 @@
|
|||
"enabled": true
|
||||
},
|
||||
"formatter": {
|
||||
"enabled": true,
|
||||
"lineWidth": 120,
|
||||
"indentStyle": "space",
|
||||
"indentWidth": 2,
|
||||
"formatWithErrors": true
|
||||
},
|
||||
"javascript": {
|
||||
"globals": [
|
||||
"ObjC",
|
||||
"Application",
|
||||
"delay",
|
||||
"Path",
|
||||
"$"
|
||||
]
|
||||
"globals": ["ObjC", "Application", "delay", "Path", "$"]
|
||||
},
|
||||
"linter": {
|
||||
"enabled": true,
|
||||
|
|
Loading…
Add table
Reference in a new issue