🐛 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 { return {
"stevearc/conform.nvim", "stevearc/conform.nvim",
opts = { opts = function(_, opts)
formatters_by_ft = { opts.formatters_by_ft["_"] = opts.formatters_by_ft["_"] or {}
["_"] = { "trim_whitespace" }, table.insert(opts.formatters_by_ft["_"], "trim_whitespace")
}, return opts
}, end,
} }

View file

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

View file

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