✨ feat(nvim): use nvim native spelling instead of cspell
This commit is contained in:
parent
13723533a7
commit
7d6afd5bee
5 changed files with 7 additions and 57 deletions
|
@ -33,3 +33,6 @@ go.root_spec = {
|
|||
|
||||
-- Show last command in the status line
|
||||
o.showcmd = false
|
||||
|
||||
-- Enable spell checking
|
||||
o.spell = true
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
}
|
|
@ -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
|
4
.config/nvim/spell/en.utf-8.add
Normal file
4
.config/nvim/spell/en.utf-8.add
Normal file
|
@ -0,0 +1,4 @@
|
|||
repl
|
||||
EditorConfig
|
||||
cmd
|
||||
dir
|
BIN
.config/nvim/spell/en.utf-8.add.spl
Normal file
BIN
.config/nvim/spell/en.utf-8.add.spl
Normal file
Binary file not shown.
Loading…
Add table
Reference in a new issue