From e8027c8c7f384b56ebc5272307a7af2bf8607999 Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 18 Sep 2026 17:45:45 +0200 Subject: [PATCH] primitive spell checking --- nvim/.config/nvim/README.md | 1 + .../.config/nvim/lua/romanzy/custom/spell.lua | 35 +++++++++++++++++++ nvim/.config/nvim/lua/romanzy/keymaps.lua | 1 + nvim/.config/nvim/lua/romanzy/options.lua | 1 - nvim/.config/nvim/lua/romanzy/plugins.lua | 1 + .../.config/nvim/lua/romanzy/plugins/mini.lua | 27 ++++++++------ 6 files changed, 54 insertions(+), 12 deletions(-) create mode 100644 nvim/.config/nvim/lua/romanzy/custom/spell.lua diff --git a/nvim/.config/nvim/README.md b/nvim/.config/nvim/README.md index 8f11b0a..cd66c18 100644 --- a/nvim/.config/nvim/README.md +++ b/nvim/.config/nvim/README.md @@ -57,6 +57,7 @@ Git shortcuts: Toggle shortcuts: - `tw` toggle soft wrap +- `ts` toggle spell checking - `ti` toggle inline diagnostics - `tv` toggle virtual diagnostics - `th` — toggle the expanded hunk view diff --git a/nvim/.config/nvim/lua/romanzy/custom/spell.lua b/nvim/.config/nvim/lua/romanzy/custom/spell.lua new file mode 100644 index 0000000..c6e3342 --- /dev/null +++ b/nvim/.config/nvim/lua/romanzy/custom/spell.lua @@ -0,0 +1,35 @@ +local M = {} + +--- Toggle spell checking for the current window. +function M.toggle() + if vim.bo.buftype == "terminal" then + return + end + + vim.opt_local.spell = not vim.wo.spell + vim.cmd("redrawstatus") +end + +function M.setup() + vim.opt.spelllang = { "en_us" } + vim.opt.spell = true + + local group = vim.api.nvim_create_augroup("RomanzySpell", { clear = true }) + + vim.api.nvim_create_autocmd("FileType", { + group = group, + pattern = "terminal", + callback = function() + vim.opt_local.spell = false + end, + }) + + vim.api.nvim_create_autocmd("TermOpen", { + group = group, + callback = function() + vim.cmd("setfiletype terminal") + end, + }) +end + +return M diff --git a/nvim/.config/nvim/lua/romanzy/keymaps.lua b/nvim/.config/nvim/lua/romanzy/keymaps.lua index f725fd9..775866a 100644 --- a/nvim/.config/nvim/lua/romanzy/keymaps.lua +++ b/nvim/.config/nvim/lua/romanzy/keymaps.lua @@ -31,6 +31,7 @@ map("n", "lg", "LazyGit", { desc = "open lazygit" }) map("n", "dv", "DiffviewOpen", { desc = "open diffview" }) map("n", "dc", "DiffviewClose", { desc = "close diffview" }) map("n", "tw", require("romanzy.custom.wrap").toggle, { desc = "toggle soft wrap" }) +map("n", "ts", require("romanzy.custom.spell").toggle, { desc = "toggle spell checking" }) map("n", "th", function() MiniDiff.toggle_overlay() end, { desc = "toggle hunk view" }) diff --git a/nvim/.config/nvim/lua/romanzy/options.lua b/nvim/.config/nvim/lua/romanzy/options.lua index b9c2327..cb0ef65 100644 --- a/nvim/.config/nvim/lua/romanzy/options.lua +++ b/nvim/.config/nvim/lua/romanzy/options.lua @@ -32,7 +32,6 @@ o.incsearch = true -- Updates search m o.completeopt = { "menuone", "noinsert", "fuzzy", "nosort" } -- Enables fuzzy completion matching. o.pumheight = 8 -- Limits the completion popup menu size. o.updatetime = 50 -- Reduces idle delay for swap and CursorHold events. -o.spelllang = { "en_us" } -- Uses US English for spell checking. o.shell = "bash" -- Runs shell commands through bash. -- Only show the invisible characters inside the code editing buffers diff --git a/nvim/.config/nvim/lua/romanzy/plugins.lua b/nvim/.config/nvim/lua/romanzy/plugins.lua index d0c1349..b6d20e2 100644 --- a/nvim/.config/nvim/lua/romanzy/plugins.lua +++ b/nvim/.config/nvim/lua/romanzy/plugins.lua @@ -9,4 +9,5 @@ require("romanzy.plugins.nvim-treesitter") require("romanzy.plugins.conform") require("romanzy.plugins.lsp") require("romanzy.plugins.codamheader") +require("romanzy.custom.spell").setup() require("romanzy.custom.tabline").setup() diff --git a/nvim/.config/nvim/lua/romanzy/plugins/mini.lua b/nvim/.config/nvim/lua/romanzy/plugins/mini.lua index 9133fd7..158409a 100644 --- a/nvim/.config/nvim/lua/romanzy/plugins/mini.lua +++ b/nvim/.config/nvim/lua/romanzy/plugins/mini.lua @@ -77,24 +77,29 @@ vim.api.nvim_create_autocmd("ColorScheme", { callback = set_mini_diff_highlights, }) -local function statusline_filetype() - local filetype = vim.bo.filetype - if filetype == "" then - return "" - end - - local icon = MiniIcons.get("filetype", filetype) - return icon .. " " .. filetype -end - -- Custom de-cluttered status line output. The default was waaay to noisy local function statusline_active() + local function statusline_filetype() + local filetype = vim.bo.filetype + if filetype == "" then + return "" + end + + local icon = MiniIcons.get("filetype", filetype) + return icon .. " " .. filetype + end + + local function statusline_spell() + return vim.wo.spell and "spell" or "" + end + local mode, mode_hl = statusline.section_mode({ trunc_width = 120 }) local git_info = statusline.section_git({ trunc_width = 40 }) -- local diff_info = statusline.section_diff({ trunc_width = 75 }) -- local diagnostics = statusline.section_diagnostics({ trunc_width = 75 }) local lsp = statusline.section_lsp({ trunc_width = 75 }) local filename = statusline.section_filename({ trunc_width = 140 }) + local spell = statusline_spell() local fileinfo = statusline_filetype() local search = statusline.section_searchcount({ trunc_width = 75 }) @@ -104,7 +109,7 @@ local function statusline_active() "%<", { hl = "MiniStatuslineFilename", strings = { filename } }, "%=", - { hl = "MiniStatuslineFileinfo", strings = { fileinfo } }, + { hl = "MiniStatuslineFileinfo", strings = { spell, fileinfo } }, { hl = mode_hl, strings = { search } }, }) end