2024-01-18 13:16:38 +02:00
|
|
|
import CodeMirrorControl from '../CodeMirrorControl';
|
2023-09-21 10:12:40 +02:00
|
|
|
|
2024-07-26 13:38:07 +02:00
|
|
|
interface AppCommands {
|
|
|
|
sync(): void;
|
|
|
|
}
|
|
|
|
|
|
|
|
const setupVim = (CodeMirror: CodeMirrorControl, commands: AppCommands|null) => {
|
2023-09-21 10:12:40 +02:00
|
|
|
CodeMirror.Vim.defineAction('swapLineDown', CodeMirror.commands.swapLineDown);
|
|
|
|
CodeMirror.Vim.mapCommand('<A-j>', 'action', 'swapLineDown', {}, { context: 'normal', isEdit: true });
|
|
|
|
CodeMirror.Vim.defineAction('swapLineUp', CodeMirror.commands.swapLineUp);
|
|
|
|
CodeMirror.Vim.mapCommand('<A-k>', 'action', 'swapLineUp', {}, { context: 'normal', isEdit: true });
|
|
|
|
CodeMirror.Vim.defineAction('insertListElement', CodeMirror.commands.vimInsertListElement);
|
|
|
|
CodeMirror.Vim.mapCommand('o', 'action', 'insertListElement', { after: true }, { context: 'normal', isEdit: true, interlaceInsertRepeat: true });
|
2024-07-26 13:38:07 +02:00
|
|
|
|
|
|
|
if (commands) {
|
|
|
|
CodeMirror.Vim.defineEx('write', 'w', () => {
|
|
|
|
commands.sync();
|
|
|
|
});
|
|
|
|
}
|
2023-09-21 10:12:40 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
export default setupVim;
|