fix formatting/linting for BCR

This commit is contained in:
Thomas Ruoff
2025-09-24 14:32:16 +02:00
parent 759a11b96a
commit 8c31a26105
3 changed files with 13 additions and 38 deletions

View File

@@ -2,7 +2,7 @@ return {
-- Autoformat
'stevearc/conform.nvim',
event = { 'BufWritePre', 'BufNewFile' },
cmd = { 'ConformInfo' },
lazy = false,
keys = {
{
'<leader>f',
@@ -12,32 +12,17 @@ return {
},
},
opts = {
log_level = vim.log.levels.DEBUG,
notify_on_error = true,
format_on_save = function(bufnr)
-- Disable "format_on_save lsp_fallback" for languages that don't
-- have a well standardized coding style. You can add additional
-- languages here or re-enable it for the disabled ones.
local disable_filetypes = { c = true, cpp = true }
if disable_filetypes[vim.bo[bufnr].filetype] then
return nil
else
return {
format_on_save = {
timeout_ms = 500,
lsp_format = 'fallback',
}
end
end,
lsp_format = 'first',
},
formatters_by_ft = {
lua = { 'stylua' },
-- Conform can also run multiple formatters sequentially
-- python = { "isort", "black" },
--
-- You can use 'stop_after_first' to run the first available formatter from the list
javascript = { 'eslint_d', 'prettierd', 'prettier' },
javascriptreact = { 'eslint_d', 'prettierd', 'prettier' },
typescript = { 'eslint_d', 'prettierd', 'prettier' },
typescriptreact = { 'eslint_d', 'prettierd', 'prettier' },
css = { 'stylelint' },
json = { 'eslint_d' },
['*'] = { 'codespell', 'trim_whitespace' },
},
},
}

View File

@@ -5,27 +5,15 @@ return {
local lint = require 'lint'
lint.linters_by_ft = {
make = { 'checkmake' },
javascript = { 'eslint_d' },
javascriptreact = { 'eslint_d' },
typescript = { 'eslint_d' },
typescriptreact = { 'eslint_d' },
}
-- Configure eslint_d to use current working directory as root
lint.linters.eslint_d.cwd = function()
return vim.fn.getcwd()
end
-- Create autocommand which carries out the actual linting
-- on the specified events.
local lint_augroup = vim.api.nvim_create_augroup('lint', { clear = true })
vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave' }, {
group = lint_augroup,
callback = function()
-- Only run the linter in buffers that you can modify in order to
-- avoid superfluous noise, notably within the handy LSP pop-ups that
-- describe the hovered symbol using Markdown.
if vim.bo.modifiable then lint.try_lint(nil, { ignore_errors = true }) end
if vim.bo.modifiable then lint.try_lint(nil, { ignore_errors = false, cwd = vim.fn.getcwd() }) end
end,
})
end,

View File

@@ -201,7 +201,8 @@ return {
-- ts_ls = {},
--
vtsls = {
--vtsls = { },
ts_ls = {
root_dir = function(bufnr, cb)
local fname = vim.api.nvim_buf_get_name(bufnr)
@@ -222,7 +223,7 @@ return {
if root then return cb(root) end
end
local default_markers = { 'tsconfig.json', 'package.json', 'jsconfig.json', '.git' }
local default_markers = { 'tsconfig.json', '.git' }
local root = vim.fs.root(fname, default_markers)
cb(root)
end,
@@ -253,6 +254,7 @@ return {
},
},
eslint = { enable = true },
bashls = { enable = true },
cssls = { enable = true },
html = { enable = true },