🐛 fix(nvim): cspell, typos and white_space are now dynamically added

This commit is contained in:
Sergio Laín 2024-01-07 01:45:28 +01:00
parent a5b271fec2
commit fcae01ad40
No known key found for this signature in database
GPG key ID: 14C9B8080681777B
3 changed files with 26 additions and 26 deletions

View file

@ -1,8 +1,8 @@
return {
"stevearc/conform.nvim",
opts = {
formatters_by_ft = {
["_"] = { "trim_whitespace" },
},
},
opts = function(_, opts)
opts.formatters_by_ft["_"] = opts.formatters_by_ft["_"] or {}
table.insert(opts.formatters_by_ft["_"], "trim_whitespace")
return opts
end,
}

View file

@ -8,23 +8,23 @@ return {
},
{
"mfussenegger/nvim-lint",
opts = {
linters_by_ft = {
["*"] = { "cspell" },
},
linters = {
cspell = {
condition = function(ctx)
if vim.fs.find({ "cspell.json" }, { path = ctx.filename, upward = true })[1] then
opts = function(_, opts)
opts.linters_by_ft["*"] = opts.linters_by_ft["*"] or {}
table.insert(opts.linters_by_ft["*"], "cspell")
opts.linters.cspell = {
condition = function(ctx)
if vim.fs.find({ "cspell.json" }, { path = ctx.filename, upward = true })[1] then
-- stylua: ignore
vim.keymap.set("n", "<leader>!", function() require("util.cspell").addWordToDictionary() end, { desc = "Add Word to Dictionary", silent = true })
return true
else
return false
end
end,
},
},
},
return true
else
return false
end
end,
}
return opts
end,
},
}

View file

@ -8,10 +8,10 @@ return {
},
{
"mfussenegger/nvim-lint",
opts = {
linters_by_ft = {
["*"] = { "typos" },
},
},
opts = function(_, opts)
opts.linters_by_ft["*"] = opts.linters_by_ft["*"] or {}
table.insert(opts.linters_by_ft["*"], "typos")
return opts
end,
},
}