-
Notifications
You must be signed in to change notification settings - Fork 0
Custom Operator
Johnny M. Salas edited this page May 2, 2022
·
1 revision
Add LUA functions as custom repeatable vim operators. Using shake.nvim
you get:
- Custom key binding to apply the function on:
- Current line
- Until end of line
- Given a vim object, like
aw
orp
- The current word, using LSP rename. Affecting the definition and its references
Suppose constant, camel and dash cases were setup using the following code
-- keys order: 'line', 'eol', 'visual', 'operator', 'lsp_rename'
shake.register_keys(shake.api.to_constant_case, {'crnn', 'crN', 'crn', 'crn', 'cRn'})
shake.register_keys(shake.api.to_camel_case, {'crcc', 'crC', 'crc', 'crc', 'cRc'})
shake.register_keys(shake.api.to_dash_case, {'crdd', 'crD', 'crd', 'crd', 'cRd'})
Or using the shortcut, which is linewise less readable, but easier to read when many functions are registered in the same block
-- keys order: 'line', 'eol', 'visual', 'operator', 'lsp_rename'
shake.register_keys(shake.api.to_constant_case, {'crnn', 'crN', 'crn', 'crn', 'cRn'})
The following examples are based on the shown configuration
Convert whole line
crnn
Convert until end of line
crN
Convert visual selection
Given the current vim mode is visual
, use crn
LSP
It is possible to change the case, not only of the word under the cursor, but its definition and usages via LSP.
Hovering the text to change, use cRn