summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosé Juan Loeza Sierra <jj@xz6ze.com>2025-11-08 12:53:30 -0800
committerJosé Juan Loeza Sierra <jj@xz6ze.com>2025-11-08 12:53:57 -0800
commit668a8a6d5f38fe161d32b7ee1d04976fc0408723 (patch)
tree67ddb7e4096ce08e4b5b1546059f44644a35a7d0
parentd400a29e7a903f60f5547dae9f30450556f9115d (diff)
create and add custom spellcheck plugin
much credit to this post: https://www.reddit.com/r/neovim/comments/1fwqc8t/how_to_enable_spell_check_for_only_specific_files/
-rw-r--r--dot-config/nvim/lua/spellcheck.lua37
-rw-r--r--dot-config/nvim/plugin/spellcheck.lua5
2 files changed, 42 insertions, 0 deletions
diff --git a/dot-config/nvim/lua/spellcheck.lua b/dot-config/nvim/lua/spellcheck.lua
new file mode 100644
index 0000000..8ebc8c5
--- /dev/null
+++ b/dot-config/nvim/lua/spellcheck.lua
@@ -0,0 +1,37 @@
+-- To enable spellchecking
+--
+-- Credits
+-- https://www.reddit.com/r/neovim/comments/1fwqc8t/how_to_enable_spell_check_for_only_specific_files/
+
+local M = {}
+
+local default_config = {
+ filetypes = { "markdown" },
+}
+
+local function enable_spell(config)
+ config = config or default_config
+
+ -- Set global spell to false initially for all files
+ vim.opt.spell = false
+
+ -- Create augroup
+ vim.api.nvim_create_augroup("Spellcheck", { clear = true })
+
+ -- Create autocommand to enable spellcheck
+ vim.api.nvim_create_autocmd({ "FileType" }, {
+ group = "Spellcheck", -- Grouping for easier management
+ pattern = config.filetypes, -- Only for these filetypes
+ callback = function()
+ vim.opt_local.spell = true -- Enable spellcheck
+ vim.opt_local.spelllang = "en_us" -- Set language
+ end,
+ desc = "Enable spellcheck for defined filetypes",
+ })
+end
+
+function M.setup(config)
+ enable_spell(config)
+end
+
+return M
diff --git a/dot-config/nvim/plugin/spellcheck.lua b/dot-config/nvim/plugin/spellcheck.lua
new file mode 100644
index 0000000..21bffb1
--- /dev/null
+++ b/dot-config/nvim/plugin/spellcheck.lua
@@ -0,0 +1,5 @@
+-- Enable custom spellcheck plugin
+
+require("spellcheck").setup({
+ filetypes = { "gitcommit", "markdown", "plaintext", "text", "typst" },
+})