mirror of
https://github.com/tomru/nvim.git
synced 2026-03-03 06:27:14 +01:00
fix formatting/linting for BCR
This commit is contained in:
@@ -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 {
|
||||
timeout_ms = 500,
|
||||
lsp_format = 'fallback',
|
||||
}
|
||||
end
|
||||
end,
|
||||
format_on_save = {
|
||||
timeout_ms = 500,
|
||||
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' },
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 },
|
||||
|
||||
Reference in New Issue
Block a user