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
|
-- Autoformat
|
||||||
'stevearc/conform.nvim',
|
'stevearc/conform.nvim',
|
||||||
event = { 'BufWritePre', 'BufNewFile' },
|
event = { 'BufWritePre', 'BufNewFile' },
|
||||||
cmd = { 'ConformInfo' },
|
lazy = false,
|
||||||
keys = {
|
keys = {
|
||||||
{
|
{
|
||||||
'<leader>f',
|
'<leader>f',
|
||||||
@@ -12,32 +12,17 @@ return {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
opts = {
|
opts = {
|
||||||
|
log_level = vim.log.levels.DEBUG,
|
||||||
notify_on_error = true,
|
notify_on_error = true,
|
||||||
format_on_save = function(bufnr)
|
format_on_save = {
|
||||||
-- Disable "format_on_save lsp_fallback" for languages that don't
|
timeout_ms = 500,
|
||||||
-- have a well standardized coding style. You can add additional
|
lsp_format = 'first',
|
||||||
-- 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,
|
|
||||||
formatters_by_ft = {
|
formatters_by_ft = {
|
||||||
lua = { 'stylua' },
|
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' },
|
css = { 'stylelint' },
|
||||||
|
json = { 'eslint_d' },
|
||||||
|
['*'] = { 'codespell', 'trim_whitespace' },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,27 +5,15 @@ return {
|
|||||||
local lint = require 'lint'
|
local lint = require 'lint'
|
||||||
lint.linters_by_ft = {
|
lint.linters_by_ft = {
|
||||||
make = { 'checkmake' },
|
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
|
-- Create autocommand which carries out the actual linting
|
||||||
-- on the specified events.
|
-- on the specified events.
|
||||||
local lint_augroup = vim.api.nvim_create_augroup('lint', { clear = true })
|
local lint_augroup = vim.api.nvim_create_augroup('lint', { clear = true })
|
||||||
vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave' }, {
|
vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave' }, {
|
||||||
group = lint_augroup,
|
group = lint_augroup,
|
||||||
callback = function()
|
callback = function()
|
||||||
-- Only run the linter in buffers that you can modify in order to
|
if vim.bo.modifiable then lint.try_lint(nil, { ignore_errors = false, cwd = vim.fn.getcwd() }) end
|
||||||
-- 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
|
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
|
|||||||
@@ -201,7 +201,8 @@ return {
|
|||||||
-- ts_ls = {},
|
-- ts_ls = {},
|
||||||
--
|
--
|
||||||
|
|
||||||
vtsls = {
|
--vtsls = { },
|
||||||
|
ts_ls = {
|
||||||
root_dir = function(bufnr, cb)
|
root_dir = function(bufnr, cb)
|
||||||
local fname = vim.api.nvim_buf_get_name(bufnr)
|
local fname = vim.api.nvim_buf_get_name(bufnr)
|
||||||
|
|
||||||
@@ -222,7 +223,7 @@ return {
|
|||||||
if root then return cb(root) end
|
if root then return cb(root) end
|
||||||
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)
|
local root = vim.fs.root(fname, default_markers)
|
||||||
cb(root)
|
cb(root)
|
||||||
end,
|
end,
|
||||||
@@ -253,6 +254,7 @@ return {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
eslint = { enable = true },
|
||||||
bashls = { enable = true },
|
bashls = { enable = true },
|
||||||
cssls = { enable = true },
|
cssls = { enable = true },
|
||||||
html = { enable = true },
|
html = { enable = true },
|
||||||
|
|||||||
Reference in New Issue
Block a user