An open API service indexing awesome lists of open source software.

https://github.com/dmtrkovalenko/caps-word.nvim

Much better way to type SCREAMING_SNAKE_CASE words aka constants
https://github.com/dmtrkovalenko/caps-word.nvim

Last synced: about 1 year ago
JSON representation

Much better way to type SCREAMING_SNAKE_CASE words aka constants

Awesome Lists containing this project

README

          

# Caps Word for neovim

Adoption of [QMK caps word feature](https://docs.qmk.fm/features/caps_word) for neovim. Provides a better experience for typing SCREAMING_SNAKE_CASE words automatically disables at the end of the word.



Last commit


License


Repo Size


follow on Twitter

https://github.com/user-attachments/assets/be198aac-2c3a-4415-aff0-9f8913e45480

## ✨ Features

Automatically disables at the end of the word using [vim.o.iskeyword](https://neovim.io/doc/user/options.html#'iskeyword')

- Automatically disables on exiting insert mode
- Replaces "-" with "\_" so you can type snake-case words instead

## 📦 Installation

The plugin is optimized for lazy loading. You can use any plugin manager you want.

lazy.nvim:

```lua
{
"dmtrKovalenko/caps-word.nvim",
lazy = true,
opts = {},
keys = {
{
mode = { "i", "n" },
"",
"lua require('caps-word').toggle()",
},
},
},

```

## ⚙️ Configuration

List of options you can use with default values:

```lua
{
-- 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,
}

```

## 🚀 Usage

Simply use a keybinding to toggle the caps word mode, type your constant and press ``, or any other non-word character. The mode will be ✨ automatically ✨ disabled and you can continue typing as usual.

![demo gif](./demo.gif)

## ❓ FAQ

### How can I see when the plugin turns on and off?

You can use the callbacks provided in the options to send a notifications or print messages in the status line.

```lua
{
"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" },
"",
"lua require('caps-word').toggle()",
},
},
},

```

### Should I try it if I already use QMK caps word?

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

## 🏆 Self-promotion

If you like this little tool subscribe to my [Twitter/X](https://x.com/neogoose_btw) for more updates on my open source work.