Save neovim buffer state as json, that can be used as part of animation inside motion canvas (see motion-canvas-editor library for additional information)
NeoVim workflow:
- Start new session with command
:MCEStartSession
(or by pressing keymap<leader>ms
) - Change viewport position with command
:MCEScrollViewportToCursor
(or by pressing keymap<leader>mz
) - Modify buffer
- Push snapshot with command
:MCEPushSnapshot
(or by pressing keymap<leader>mn
) - End session if complete, otherwise goto 2
Minimal setup with lazy.nvim package manager:
{
"sysraccoon/motion-canvas-editor.nvim",
opts = {},
}
Default configuration options:
{
viewport_height = 24, -- set viewport line count that can be present in animation
viewport_highlight = "#313244", -- set viewport indicator background color
auto_save = true, -- automatically save session when snapshot list modified
default_session_path = "mce-session.json", -- default session file name
default_commands = true, -- enable default commands
default_keymaps = true, -- enable default keymaps
}
command name | lua name | description |
---|---|---|
:MCEStartSession |
start_session |
Start new session. Fail if file exist |
:MCELoadSession |
load_session |
Load session file. Fail if file not exist |
:MCETryLoadSession |
try_load_session |
Try load session file or start new session if file not exist |
:MCEEndSession |
end_session |
End active session and save result to file |
:MCEWriteSession |
write_session |
Write snapshot to session file |
:MCEPushSnapshot |
push_snapshot |
Push current buffer to snapshot list.\ Write result to session file if 'auto_save' enabled |
:MCEScrollViewportToCursor |
scroll_viewport_to_cursor |
Scroll viewport to cursor |
mods | keys | action |
---|---|---|
n | <leader>ms |
M.start_session |
n | <leader>ma |
M.try_load_session |
n | <leader>ml |
M.load_session |
n | <leader>me |
M.end_session |
n | <leader>mw |
M.write_session |
n v x | <leader>mn |
M.push_snapshot |
n | <leader>mz |
M.scroll_viewport_to_cursor |