Adoption of QMK caps word feature for neovim. Provides a better experience for typing SCREAMING_SNAKE_CASE words automatically disables at the end of the word.
demo.mp4
Automatically disables at the end of the word using vim.o.iskeyword
- Automatically disables on exiting insert mode
- Replaces "-" with "_" so you can type snake-case words instead
The plugin is optimized for lazy loading. You can use any plugin manager you want.
lazy.nvim:
{
"dmtrKovalenko/caps-word.nvim",
lazy = true,
opts = {},
keys = {
{
mode = { "i", "n" },
"<C-s>",
"<cmd>lua require('caps-word').toggle()<CR>",
},
},
},
List of options you can use with default values:
{
-- Automatically changes `-` to `_` when caps word is activated
auto_underscore_inject = true,
-- Does not turn the caps mode off on number input
enable_numbers_in_caps = true,
-- Provide custom vim match regex for detecting end of the word (default is vim.o.iskeyword)
match_word_string = nil,
-- Callback when caps word mode is activated
enter_callback = nil,
-- Callback when caps word mode is deactivated
exit_callback = nil,
}
Simply use a keybinding to toggle the caps word mode, type your constant and press <space>
, or any other non-word character. The mode will be ✨ automatically ✨ disabled and you can continue typing as usual.
You can use the callbacks provided in the options to send a notifications or print messages in the status line.
{
"dmtrKovalenko/caps-word.nvim",
dir = "~/dev/caps-word.nvim",
lazy = true,
opts = {
enter_callback = function()
vim.notify("Caps Word: On", "info", { title = "Caps Word" })
end,
exit_callback = function()
vim.notify("Caps Word: Off", "info", { title = "Caps Word" })
end,
},
keys = {
{
mode = { "i", "n" },
"<C-s>",
"<cmd>lua require('caps-word').toggle()<CR>",
},
},
},
No, if you absolutely like it, but I did because:
- QMK caps word does not know about your keybindings in insert mode and breaks them by changing the emitted keys
- it can't disable itself on insert leave, which is useful
- this plugin is buffer-local which helps when jumping between splits
If you like this little tool subscribe to my Twitter/X for more updates on my open source work.