diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index 60c3abdd..19a186cd 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -106,7 +106,7 @@ "persistent-breakpoints.nvim": { "branch": "main", "commit": "db2ad5974b0435cb806cd287e7525219d6ac4bd3" }, "plenary.nvim": { "branch": "master", "commit": "55d9fe89e33efd26f532ef20223e5f9430c8b0c0" }, "presence.nvim": { "branch": "main", "commit": "87c857a56b7703f976d3a5ef15967d80508df6e6" }, - "rainbow-delimiters.nvim": { "branch": "master", "commit": "f7a55274a74053ccfafc24005b6f46303d543288" }, + "rainbow-delimiters.nvim": { "branch": "master", "commit": "18d1350ec3897e7282b4cbf78ef6f50191ae78f8" }, "refactoring.nvim": { "branch": "master", "commit": "28c5a33a0c489eb559396d9424b042ccfdb03b14" }, "rustaceanvim": { "branch": "master", "commit": "f36e3a62b81b9a4ebd1771e6ee81fb5d85383af8" }, "satellite.nvim": { "branch": "main", "commit": "1a20861227eba8bf2d8282ab4ec5fc071e8b20e2" }, diff --git a/.config/nvim/lazyvim.json b/.config/nvim/lazyvim.json index 6c61c4f8..a0306112 100644 --- a/.config/nvim/lazyvim.json +++ b/.config/nvim/lazyvim.json @@ -91,4 +91,5 @@ "NEWS.md": "2123" }, "version": 2 -} \ No newline at end of file +} + diff --git a/.config/nvim/lua/plugins/extras/linting/cspell.lua b/.config/nvim/lua/plugins/extras/linting/cspell.lua index 46e1b47a..71e905cf 100644 --- a/.config/nvim/lua/plugins/extras/linting/cspell.lua +++ b/.config/nvim/lua/plugins/extras/linting/cspell.lua @@ -1,14 +1,29 @@ return { - "mfussenegger/nvim-lint", - opts = { - linters_by_ft = { - ["*"] = { "cspell" }, - }, - linters = { - cspell = { - condition = function(ctx) - return vim.fs.find({ "cspell.json" }, { path = ctx.filename, upward = true })[1] - end, + { + "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 = { + linters_by_ft = { + ["*"] = { "cspell" }, + }, + linters = { + cspell = { + condition = function(ctx) + if vim.fs.find({ "cspell.json" }, { path = ctx.filename, upward = true })[1] then + -- stylua: ignore + vim.keymap.set("n", "!", function() require("util.cspell").addWordToDictionary() end, { desc = "Add Word to Dictionary", silent = true }) + return true + else + return false + end + end, + }, }, }, }, diff --git a/.config/nvim/lua/util/cspell.lua b/.config/nvim/lua/util/cspell.lua new file mode 100644 index 00000000..2f02635e --- /dev/null +++ b/.config/nvim/lua/util/cspell.lua @@ -0,0 +1,27 @@ +local M = {} + +function M.addWordToDictionary() + local word = vim.fn.expand("") + local dictionary_path = require("lazyvim.util.root").get() .. "/cspell-tool.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 diff --git a/.config/nvim/spell/en.utf-8.spl b/.config/nvim/spell/en.utf-8.spl deleted file mode 100644 index e4b1e1cc..00000000 Binary files a/.config/nvim/spell/en.utf-8.spl and /dev/null differ