From 7d6afd5bee5d1beb7ac61a3326edf8905b3a1289 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20La=C3=ADn?= Date: Sat, 9 Mar 2024 19:22:27 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(nvim):=20use=20nvim=20native?= =?UTF-8?q?=20spelling=20instead=20of=20cspell?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .config/nvim/lua/config/options.lua | 3 ++ .../lua/plugins/extras/linting/cspell.lua | 30 ------------------ .config/nvim/lua/util/cspell.lua | 27 ---------------- .config/nvim/spell/en.utf-8.add | 4 +++ .config/nvim/spell/en.utf-8.add.spl | Bin 0 -> 103 bytes 5 files changed, 7 insertions(+), 57 deletions(-) delete mode 100644 .config/nvim/lua/plugins/extras/linting/cspell.lua delete mode 100644 .config/nvim/lua/util/cspell.lua create mode 100644 .config/nvim/spell/en.utf-8.add create mode 100644 .config/nvim/spell/en.utf-8.add.spl diff --git a/.config/nvim/lua/config/options.lua b/.config/nvim/lua/config/options.lua index 269e0a3f..fa647e3c 100644 --- a/.config/nvim/lua/config/options.lua +++ b/.config/nvim/lua/config/options.lua @@ -33,3 +33,6 @@ go.root_spec = { -- Show last command in the status line o.showcmd = false + +-- Enable spell checking +o.spell = true diff --git a/.config/nvim/lua/plugins/extras/linting/cspell.lua b/.config/nvim/lua/plugins/extras/linting/cspell.lua deleted file mode 100644 index 70b03766..00000000 --- a/.config/nvim/lua/plugins/extras/linting/cspell.lua +++ /dev/null @@ -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", "!", function() require("util.cspell").addWordToDictionary() end, { desc = "Add Word to Dictionary", silent = true }) - return true - else - return false - end - end, - } - - return opts - end, - }, -} diff --git a/.config/nvim/lua/util/cspell.lua b/.config/nvim/lua/util/cspell.lua deleted file mode 100644 index e5ea121e..00000000 --- a/.config/nvim/lua/util/cspell.lua +++ /dev/null @@ -1,27 +0,0 @@ -local M = {} - -function M.addWordToDictionary() - local word = vim.fn.expand("") - 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 diff --git a/.config/nvim/spell/en.utf-8.add b/.config/nvim/spell/en.utf-8.add new file mode 100644 index 00000000..d56b52fd --- /dev/null +++ b/.config/nvim/spell/en.utf-8.add @@ -0,0 +1,4 @@ +repl +EditorConfig +cmd +dir diff --git a/.config/nvim/spell/en.utf-8.add.spl b/.config/nvim/spell/en.utf-8.add.spl new file mode 100644 index 0000000000000000000000000000000000000000..25317d020230c926f2ece28636c4a9116ed4e3bb GIT binary patch literal 103 zcmWIZ^erw(&B-zP&%nT-%aWXuTEv*kn8L`wn90b