feat(nvim): use nvim native spelling instead of cspell

This commit is contained in:
Sergio Laín 2024-03-09 19:22:27 +01:00
parent 13723533a7
commit 7d6afd5bee
No known key found for this signature in database
GPG key ID: 14C9B8080681777B
5 changed files with 7 additions and 57 deletions

View file

@ -33,3 +33,6 @@ go.root_spec = {
-- Show last command in the status line
o.showcmd = false
-- Enable spell checking
o.spell = true

View file

@ -1,30 +0,0 @@
return {
{
"williamboman/mason.nvim",
opts = function(_, opts)
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "cspell" })
end,
},
{
"mfussenegger/nvim-lint",
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 opts
end,
},
}

View file

@ -1,27 +0,0 @@
local M = {}
function M.addWordToDictionary()
local word = vim.fn.expand("<cword>")
local dictionary_path = require("lazyvim.util.root").get() .. "/cspell-dictionary.txt"
-- Append the word to the dictionary file
local file = io.open(dictionary_path, "a")
if file then
-- Detect new line at the end of the file or not
local last_char = file:seek("end", -1)
if last_char ~= nil and last_char ~= "\n" then
word = "\n" .. word
end
file:write(word .. "")
file:close()
vim.notify("Added word to dictionary", "info", { title = "cSpell" })
-- Reload buffer to update the dictionary
vim.cmd("e!")
else
vim.notify("Could not open cSpell dictionary", "error", { title = "cSpell" })
end
end
return M

View file

@ -0,0 +1,4 @@
repl
EditorConfig
cmd
dir

Binary file not shown.