https://github.com/chrisgrieser/nvim-recorder
Enhance the usage of macros in Neovim.
Science Score: 36.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
✓Academic publication links
Links to: researchgate.net -
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (9.7%) to scientific vocabulary
Keywords
Keywords from Contributors
Repository
Enhance the usage of macros in Neovim.
Basic Info
Statistics
- Stars: 264
- Watchers: 4
- Forks: 12
- Open Issues: 1
- Releases: 0
Topics
Metadata Files
README.md
nvim-recorder 📹
Enhance the usage of macros in Neovim.
Features
- Simplified controls: One key to start and stop recording, a second key for
playing the macro. Instead of
qa … q @a @@, you just doq … q Q Q.[^1] - Macro Breakpoints for easier debugging of macros. Breakpoints can also be set after the recording and are automatically ignored when triggering a macro with a count.
- Status line components: Particularly useful if you use
cmdheight=0where the recording status is not visible. - Macro-to-Mapping: Copy a macro, so you can save it as a mapping.
- Various quality-of-life features: notifications with macro content, the ability to cancel a recording, a command to edit macros,
- Performance Optimizations for large macros: When the macro is triggered with a high count, temporarily enable some performance improvements.
- Uses up-to-date nvim features like
vim.notify. This means you can get confirmation notices with plugins like nvim-notify.
Setup
Installation
``lua
-- lazy.nvim
{
"chrisgrieser/nvim-recorder",
dependencies = "rcarriga/nvim-notify", -- optional
opts = {}, -- required even with default settings, since it callssetup()`
},
-- packer use { "chrisgrieser/nvim-recorder", requires = "rcarriga/nvim-notify", -- optional config = function() require("recorder").setup() end, } ```
Calling setup() (or lazy's opts) is required.
Configuration
```lua -- default values require("recorder").setup { -- Named registers where macros are saved (single lowercase letters only). -- The first register is the default register used as macro-slot after -- startup. slots = { "a", "b" },
-- specify one of options:
-- [static] -> use static slots, this is default behaviour
-- [rotate] -> rotates through letters specified in slots[]
dynamicSlots = "static",
mapping = {
startStopRecording = "q",
playMacro = "Q",
switchSlot = "<C-q>",
editMacro = "cq",
deleteAllMacros = "dq",
yankMacro = "yq",
-- ⚠️ this should be a string you don't use in insert mode during a macro
addBreakPoint = "##",
},
-- Clears all macros-slots on startup.
clear = false,
-- Log level used for non-critical notifications; mostly relevant for nvim-notify.
-- (Note that by default, nvim-notify does not show the levels `trace` & `debug`.)
logLevel = vim.log.levels.INFO, -- :help vim.log.levels
-- If enabled, only essential notifications are sent.
-- If you do not use a plugin like nvim-notify, set this to `true`
-- to remove otherwise annoying messages.
lessNotifications = false,
-- Use nerdfont icons in the status bar components and keymap descriptions
useNerdfontIcons = true,
-- Performance optimizations for macros with high count. When `playMacro` is
-- triggered with a count higher than the threshold, nvim-recorder
-- temporarily changes changes some settings for the duration of the macro.
performanceOpts = {
countThreshold = 100,
lazyredraw = true, -- enable lazyredraw (see `:h lazyredraw`)
noSystemClipboard = true, -- remove `+`/`*` from clipboard option
autocmdEventsIgnore = { -- temporarily ignore these autocmd events
"TextChangedI",
"TextChanged",
"InsertLeave",
"InsertEnter",
"InsertCharPre",
},
},
-- [experimental] partially share keymaps with nvim-dap.
-- (See README for further explanations.)
dapSharedKeymaps = false,
} ```
If you want to handle multiple macros or use cmdheight=0, it is recommended to
also set up the status line components:
Status Line Components
``lua
-- Indicates whether you are currently recording. Useful if you are using
--cmdheight=0`, where recording-status is not visible.
require("recorder").recordingStatus()
-- Displays non-empty macro-slots (registers) and indicates the selected ones.
-- Only displayed when not recording. Slots with breakpoints get an extra #.
require("recorder").displaySlots()
```
[!TIP] Use with the config
clear = trueto see recordings you made this session.
Example for adding the status line components to lualine:
lua
lualine_y = {
{ require("recorder").displaySlots },
},
lualine_z = {
{ require("recorder").recordingStatus },
},
[!TIP] Put the components in different status line segments, so they have a different color, making the recording status more distinguishable from saved recordings
Basic Usage
startStopRecording: Starts recording to the current macro slot (so you do not need to specify a register). Press again to end the recording.playMacro: Plays the macro in the current slot (without the need to specify a register).switchSlot: Cycles through the registers you specified in the configuration. Also show a notification with the slot and its content. (The currently selected slot can be seen in the status line component.)editMacro: Edit the macro recorded in the active slot. (Be aware that these are the keystrokes in "encoded" form.)yankMacro: Copies the current macro in decoded form that can be used to create a mapping from it. Breakpoints are removed from the copied macro.deleteAllMacros: Copies the current macro in decoded form that can be used to
[!TIP] For recursive macros (playing a macro inside a macro), you can still use the default command
@a.
Advanced Usage
Performance Optimizations
Running macros with a high count can be demanding on the system and result in
lags. For this reason, nvim-recorder provides some performance optimizations
that are temporarily enabled when a macro with a high count is run.
Note that these optimizations do have some potential drawbacks.
- lazyredraw disables
redrawing of the screen, which makes it harder to notice edge cases not
considered in the macro. It may also appear as if the screen is frozen for a
while.
- Disabling the system clipboard is mostly safe, if you do not intend to copy
content to it with the macro.
- Ignoring auto-commands is not recommended, when you rely on certain plugin
functionality during the macro, since it can potentially disrupt those
plugins' effect.
Macro Breakpoints
nvim-recorder allows you to set breakpoints in your macros which can be
helpful for debugging macros. Breakpoints are automatically ignored when you
trigger the macro with a count.
Setting Breakpoints
- During a recording: press the addBreakPoint key (default: ##) in normal
mode
- After a recording: use editMacro and add or remove the ## manually.
Playing Macros with Breakpoints
- Using the playMacro key, the macro automatically stops at the next
breakpoint. The next time you press playMacro, the next segment of the macro
is played.
- Starting a new recording, editing a macro, yanking a macro, or switching macro
slot all reset the sequence, meaning that playMacro starts from the
beginning again.
[!TIP] You can do other things in between playing segments of the macro, like moving a few characters to the left or right. That way you can also use breakpoints to manually correct irregularities.
Ignoring Breakpoints
When you play the macro with a count (for example 50Q), breakpoints are
automatically ignored.
[!TIP] Add a count of 1 (
1Q) to play a macro once and still ignore breakpoints.
Shared Keybindings with nvim-dap
If you are using nvim-dap, you can
use dapSharedKeymaps = true to set up the following shared keybindings:
1. addBreakPoint maps to dap.toggle_breakpoint() outside
a recording. During a recording, it adds a macro breakpoint instead.
2. playMacro maps to dap.continue() if there is at least one
DAP-breakpoint. If there is no DAP-breakpoint, plays the current
macro-slot instead.
Note that this feature is experimental, since the respective API from nvim-dap is non-public and can be changed without deprecation notice.
Lazy-loading the plugin
nvim-recorder is best lazy-loaded on the mappings for startStopRecording and
playMacro. However, adding the status line components to lualine will cause the
plugin to load before you start or play a recording.
To avoid this, the statusline components need to be loaded only in the plugin's
config. The drawback of this method is that no component is shown when until
you start or play a recording (which you can completely disregard when you set
clear = true, though).
Nonetheless, the plugin is pretty lightweight (~400 lines of code), so not lazy-loading it should not have a big impact.
```lua -- minimal config for lazy-loading with lazy.nvim { "chrisgrieser/nvim-recorder", dependencies = "rcarriga/nvim-notify", keys = { -- these must match the keys in the mapping config below { "q", desc = " Start Recording" }, { "Q", desc = " Play Recording" }, }, config = function() require("recorder").setup({ mapping = { startStopRecording = "q", playMacro = "Q", }, })
local lualineZ = require("lualine").get_config().sections.lualine_z or {}
local lualineY = require("lualine").get_config().sections.lualine_y or {}
table.insert(lualineZ, { require("recorder").recordingStatus })
table.insert(lualineY, { require("recorder").displaySlots })
require("lualine").setup {
tabline = {
lualine_y = lualineY,
lualine_z = lualineZ,
},
}
end,
}, ```
About the developer
In my day job, I am a sociologist studying the social mechanisms underlying the digital economy. For my PhD project, I investigate the governance of the app economy and how software ecosystems manage the tension between innovation and compatibility. If you are interested in this subject, feel free to get in touch.
[^1]: As opposed to vim, Neovim already allows you to use Q to play the last
recorded macro. Considering this,
the simplified controls really only save you one keystroke for one-off
macros. However, as opposed to Neovim's built-in controls, you can still
keep using Q for playing the not-most-recently recorded macro.
Owner
- Name: Chris Grieser
- Login: chrisgrieser
- Kind: user
- Location: Berlin, Germany
- Company: Technical University of Berlin
- Website: https://chris-grieser.de/
- Repositories: 189
- Profile: https://github.com/chrisgrieser
Researcher in sociology & software developer
GitHub Events
Total
- Issues event: 2
- Watch event: 35
- Delete event: 4
- Issue comment event: 19
- Push event: 30
- Pull request review event: 6
- Pull request review comment event: 6
- Pull request event: 13
- Fork event: 2
- Create event: 3
Last Year
- Issues event: 2
- Watch event: 35
- Delete event: 4
- Issue comment event: 19
- Push event: 30
- Pull request review event: 6
- Pull request review comment event: 6
- Pull request event: 13
- Fork event: 2
- Create event: 3
Committers
Last synced: 9 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| pseudometa | 7****r | 190 |
| Rishikesh Vaishnav | r****v@g****m | 3 |
| Francis Bélanger | f****r@u****m | 2 |
| dependabot[bot] | 4****] | 1 |
| daru | d****r@p****e | 1 |
| Tyler Saunders | 4****s | 1 |
| Conor Sinclair | c****r@s****e | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 16
- Total pull requests: 19
- Average time to close issues: about 1 month
- Average time to close pull requests: about 5 hours
- Total issue authors: 15
- Total pull request authors: 8
- Average comments per issue: 1.25
- Average comments per pull request: 2.0
- Merged pull requests: 13
- Bot issues: 0
- Bot pull requests: 6
Past Year
- Issues: 2
- Pull requests: 11
- Average time to close issues: N/A
- Average time to close pull requests: about 8 hours
- Issue authors: 2
- Pull request authors: 3
- Average comments per issue: 0.0
- Average comments per pull request: 2.27
- Merged pull requests: 7
- Bot issues: 0
- Bot pull requests: 6
Top Authors
Issue Authors
- al1-ce (2)
- rcholla (1)
- C-Sinclair (1)
- sudo-tee (1)
- harrisoncramer (1)
- aidancz (1)
- Ajaymamtora (1)
- soupersauce (1)
- shk3t (1)
- tylersaunders (1)
- serhez (1)
- chrisgrieser (1)
- jondkinney (1)
- ror6ax (1)
- nishantpillai5 (1)
Pull Request Authors
- rish987 (8)
- dependabot[bot] (7)
- Darukutsu (4)
- nishantpillai5 (2)
- tylersaunders (1)
- AndresYague (1)
- C-Sinclair (1)
- sudo-tee (1)
Top Labels
Issue Labels
Pull Request Labels
Dependencies
- actions/checkout v2 composite
- kdheepak/panvimdoc main composite
- stefanzweifel/git-auto-commit-action v4 composite
- amannn/action-semantic-pull-request v5 composite
- actions/stale v8 composite
- JohnnyMorganz/stylua-action v2 composite
- actions/checkout v3 composite