From 5575c354ab1336159931b5d95fbcb34ae8befbdb Mon Sep 17 00:00:00 2001 From: iagorrr Date: Sat, 6 Sep 2025 10:59:45 -0300 Subject: [PATCH] feat: add spell checker for English - The plugin `spellwarn` was added, and set to support English. - The flake.nix and flake.lock was also update to include the new plugin. - A file size limit as added to avoid lag when dealing with large files (larger than 80 lines) --- flake.lock | 17 +++++++++++++ flake.nix | 5 +++- lua/plugins/spellwarn.lua | 53 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 lua/plugins/spellwarn.lua diff --git a/flake.lock b/flake.lock index 2f7a421..7a89cca 100644 --- a/flake.lock +++ b/flake.lock @@ -431,6 +431,7 @@ "plenary.nvim": "plenary.nvim", "satellite.nvim": "satellite.nvim", "snacks.nvim": "snacks.nvim", + "spellwarn.nvim": "spellwarn.nvim", "which-key.nvim": "which-key.nvim" } }, @@ -466,6 +467,22 @@ "type": "github" } }, + "spellwarn.nvim": { + "flake": false, + "locked": { + "lastModified": 1756861421, + "narHash": "sha256-c7pjWmhRqNAuJ2rq4lsrFLEM9Ypdi7eUQ08CCqXl9M0=", + "owner": "ravibrock", + "repo": "spellwarn.nvim", + "rev": "ef6a121b2fec1c4474427c6ccfd489338eb53a5b", + "type": "github" + }, + "original": { + "owner": "ravibrock", + "repo": "spellwarn.nvim", + "type": "github" + } + }, "systems": { "locked": { "lastModified": 1681028828, diff --git a/flake.nix b/flake.nix index aa79280..44a0cd9 100644 --- a/flake.nix +++ b/flake.nix @@ -5,7 +5,6 @@ nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; flake-utils.url = "github:numtide/flake-utils"; }; - outputs = { self, nixpkgs, @@ -208,6 +207,10 @@ url = "github:folke/snacks.nvim"; flake = false; }; + "spellwarn.nvim" = { + url = "github:ravibrock/spellwarn.nvim"; + flake = false; + }; "which-key.nvim" = { url = "github:folke/which-key.nvim"; flake = false; diff --git a/lua/plugins/spellwarn.lua b/lua/plugins/spellwarn.lua new file mode 100644 index 0000000..3923ca6 --- /dev/null +++ b/lua/plugins/spellwarn.lua @@ -0,0 +1,53 @@ +--[[ +-- Spell checker plugin set for English +-- +-- Usage: +-- ]s -> jump to next misspelled word +-- [s -> jump to previous misspelled word +-- z= -> show spelling suggestions +-- zg -> add word to dictionary +-- zw -> mark word as wrong +-- ]] + +local opts = { + event = { -- event(s) to refresh diagnostics on + -- "CursorHold", + -- "InsertLeave", + "TextChanged", + "TextChangedI", + "TextChangedP", + }, + enable = true, -- enable diagnostics on startup + ft_config = { -- spellcheck method: "cursor", "iter", or boolean + alpha = false, + help = false, + lazy = false, + lspinfo = false, + mason = false, + }, + ft_default = true, -- default option for unspecified file types + max_file_size = 80, -- maximum file size to check in lines (nil for no limit) + severity = { -- severity for each spelling error type (false to disable diagnostics for that type) + spellbad = "WARN", + spellcap = "HINT", + spelllocal = "HINT", + spellrare = "INFO", + }, + suggest = false, -- show spelling suggestions in diagnostic message (works best with window-style message) + num_suggest = 0, -- number of spelling suggestions shown in diagnostic message + prefix = "possible misspelling(s): ", -- prefix for each diagnostic message + diagnostic_opts = { severity_sort = true }, -- options for diagnostic display +} + +local function config() + vim.opt.spell = true + vim.opt.spelllang = { "en_us" } + + require("spellwarn").setup(opts) +end + +return { + "ravibrock/spellwarn.nvim", + lazy = false, + config = config, +}