mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-07-25 14:01:06 +00:00
feat(linting): ability to configure global and fallback linters
This commit is contained in:
parent
f29543f2c9
commit
64d3b30914
1 changed files with 9 additions and 1 deletions
|
|
@ -7,6 +7,10 @@ return {
|
|||
events = { "BufWritePost", "BufReadPost", "InsertLeave" },
|
||||
linters_by_ft = {
|
||||
fish = { "fish" },
|
||||
-- Use the "*" filetype to run linters on all filetypes.
|
||||
-- ['*'] = { 'global linter' },
|
||||
-- Use the "_" filetype to run linters on filetypes that don't have other linters configured.
|
||||
-- ['_'] = { 'fallback linter' },
|
||||
},
|
||||
-- LazyVim extension to easily override linter options
|
||||
-- or add custom linters.
|
||||
|
|
@ -47,7 +51,11 @@ return {
|
|||
end
|
||||
|
||||
function M.lint()
|
||||
local names = lint.linters_by_ft[vim.bo.filetype] or {}
|
||||
local names = vim.tbl_flatten({ lint.linters_by_ft[vim.bo.filetype], lint.linters_by_ft["*"] }) or {}
|
||||
if #names == 0 then
|
||||
names = lint.linters_by_ft["_"] or {}
|
||||
end
|
||||
|
||||
local ctx = { filename = vim.api.nvim_buf_get_name(0) }
|
||||
ctx.dirname = vim.fn.fnamemodify(ctx.filename, ":h")
|
||||
names = vim.tbl_filter(function(name)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue