jupyterlab-contrib / jupyterlab-vim

Vim notebook cell bindings for JupyterLab
https://jupyterlab-contrib.github.io/jupyterlab-vim.html
MIT License
691 stars 43 forks source link

Jupypter-vim doesn't get normal mode in cell editing. #140

Closed awesomeus closed 3 months ago

awesomeus commented 5 months ago

Description

Python 3.10.9 Jupyter lab 4.1.0 Jupyterlab-vim 4.1.3

Jupyterlab-vim doesn't work in vim mode on cell. The expected behavior is to get back to normal mode when esc is hit in insert mode. but it goes back to Jupyter command mode instead.

and lab 4.1.0, vim 4.1.3 combination gets the fail warning in connection process such that

Failed validating settings (@axlair/jupyterlab_vim:plugin): Additional properties are not allowed ('cmdModeKeys', 'enabledInEditors' were unexpected)

Failed validating 'additionalProperties' in schema:
    {'additionalProperties': False,
     'definitions': {'shortcut': {'properties': {'command': {'description': 'The '
                                                                            'new '
                                                                            'vim '
                                                                            'keybinding, '
                                                                            'or '
                                                                            "'left "
                                                                            'hand '
                                                                            "side' "
                                                                            'of '
                                                                            'the '
                                                                            'keybinding, '
                                                                            'e.g. '
                                                                            '`M`',
                                                             'title': 'Keybinding',
                                                             'type': 'string'},
                                                 'context': {'default': 'normal',
                                                             'description': 'Vim '
                                                                            'mode '
                                                                            'in '
                                                                            'which '
                                                                            'the '
                                                                            'keybinding '
                                                                            'applies',
                                                             'enum': ['normal',
                                                                      'insert',
                                                                      'visual'],
                                                             'title': 'Mode'},
                                                 'enabled': {'default': True,
                                                             'description': 'Whether '
                                                                            'this '
                                                                            'keybinding '
                                                                            'is '
                                                                            'enabled '
                                                                            'or '
                                                                            'not.',
                                                             'type': 'boolean'},
                                                 'keys': {'description': 'The '
                                                                         "'right "
                                                                         'hand '
                                                                         "side' "
                                                                         'of '
                                                                         'the '
                                                                         'keybinding '
                                                                         'to '
                                                                         'be '
                                                                         'executed, '
                                                                         'e.g. '
                                                                         '`:noh<cr>`',
                                                          'title': 'The '
                                                                   'key '
                                                                   'sequence '
                                                                   'to '
                                                                   'execute',
                                                          'type': 'string'},
                                                 'mapfn': {'default': 'map',
                                                           'description': 'Vim '
                                                                          'map '
                                                                          'function '
                                                                          'to '
                                                                          'use',
                                                           'enum': ['map',
                                                                    'noremap'],
                                                           'title': 'Map '
                                                                    'function'}},
                                  'required': ['command', 'keys'],
                                  'type': 'object'}},
     'description': 'Notebook Vim Settings',
     'jupyter.lab.menus': {'main': [{'id': 'jp-mainmenu-settings',
                                     'items': [{'rank': 38,
                                                'type': 'separator'},
                                               {'command': 'jupyterlab-vim:toggle',
                                                'rank': 38},
                                               {'rank': 38,
                                                'type': 'separator'}]}]},
     'jupyter.lab.shortcuts': [{'command': 'notebook:enter-command-mode',
                                'disabled': True,
                                'keys': ['Escape'],
                                'selector': '.jp-Notebook.jp-mod-editMode'},
                               {'command': 'notebook:undo-cell-action',
                                'keys': ['Ctrl O', 'U'],
                                'selector': ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            '.jp-Notebook.jp-mod-editMode'},
                               {'command': 'notebook:split-cell-at-cursor',
                                'keys': ['Ctrl O', '-'],
                                'selector': ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            '.jp-Notebook.jp-mod-editMode'},
                               {'command': 'vim:cut-cell-and-edit',
                                'keys': ['Ctrl O', 'D'],
                                'selector': ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            '.jp-Notebook.jp-mod-editMode'},
                               {'command': 'vim:copy-cell-and-edit',
                                'keys': ['Ctrl O', 'Y'],
                                'selector': ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            '.jp-Notebook.jp-mod-editMode'},
                               {'command': 'vim:paste-cell-and-edit',
                                'keys': ['Ctrl O', 'P'],
                                'selector': ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            '.jp-Notebook.jp-mod-editMode'},
                               {'command': 'notebook:extend-marked-cells-below',
                                'keys': ['Ctrl Shift J'],
                                'selector': ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            '.jp-Notebook.jp-mod-editMode'},
                               {'command': 'notebook:extend-marked-cells-below',
                                'keys': ['Ctrl Shift J'],
                                'selector': ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            '.jp-Notebook:focus'},
                               {'command': 'notebook:extend-marked-cells-above',
                                'keys': ['Ctrl Shift K'],
                                'selector': ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            '.jp-Notebook.jp-mod-editMode'},
                               {'command': 'notebook:extend-marked-cells-above',
                                'keys': ['Ctrl Shift K'],
                                'selector': ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            '.jp-Notebook:focus'},
                               {'command': 'notebook:insert-cell-above',
                                'keys': ['Ctrl O', 'Shift O'],
                                'selector': ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            '.jp-Notebook.jp-mod-editMode'},
                               {'command': 'notebook:insert-cell-above',
                                'keys': ['Ctrl O', 'Ctrl O'],
                                'selector': ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            '.jp-Notebook.jp-mod-editMode'},
                               {'command': 'notebook:insert-cell-below',
                                'keys': ['Ctrl O', 'O'],
                                'selector': ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            '.jp-Notebook.jp-mod-editMode'},
                               {'command': 'vim:select-below-execute-markdown',
                                'keys': ['Ctrl J'],
                                'selector': ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            '.jp-Notebook.jp-mod-editMode'},
                               {'command': 'vim:select-above-execute-markdown',
                                'keys': ['Ctrl K'],
                                'selector': ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            '.jp-Notebook.jp-mod-editMode'},
                               {'command': 'vim:leave-insert-mode',
                                'keys': ['Escape'],
                                'selector': ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            '.jp-Notebook.jp-mod-editMode'},
                               {'command': 'vim:leave-insert-mode',
                                'keys': ['Ctrl ['],
                                'selector': ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            '.jp-Notebook.jp-mod-editMode'},
                               {'command': 'vim:enter-insert-mode',
                                'keys': ['Ctrl I'],
                                'selector': ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            '.jp-Notebook:focus'},
                               {'command': 'vim:run-cell-and-edit',
                                'keys': ['Ctrl Enter'],
                                'selector': ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            '.jp-Notebook.jp-mod-editMode'},
                               {'command': 'vim:run-select-next-edit',
                                'keys': ['Shift Enter'],
                                'selector': ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            '.jp-Notebook.jp-mod-editMode'},
                               {'command': 'notebook:enter-command-mode',
                                'keys': ['Shift Escape'],
                                'selector': ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            '.jp-Notebook.jp-mod-editMode'},
                               {'command': 'vim:merge-and-edit',
                                'keys': ['Shift M'],
                                'selector': ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            '.jp-Notebook:focus'},
                               {'command': 'notebook:change-cell-to-code',
                                'keys': ['Accel 1'],
                                'selector': ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            '.jp-Notebook.jp-mod-editMode'},
                               {'command': 'notebook:change-cell-to-markdown',
                                'keys': ['Accel 2'],
                                'selector': ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            '.jp-Notebook.jp-mod-editMode'},
                               {'command': 'notebook:change-cell-to-raw',
                                'keys': ['Accel 3'],
                                'selector': ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            '.jp-Notebook.jp-mod-editMode'},
                               {'command': 'vim:select-first-cell',
                                'keys': ['Ctrl O', 'G'],
                                'selector': ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            '.jp-Notebook.jp-mod-editMode'},
                               {'command': 'vim:select-last-cell',
                                'keys': ['Ctrl O', 'Ctrl G'],
                                'selector': ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            '.jp-Notebook.jp-mod-editMode'},
                               {'command': 'vim:select-first-cell',
                                'keys': ['G', 'G'],
                                'selector': ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            '.jp-Notebook:focus'},
                               {'command': 'vim:select-last-cell',
                                'keys': ['Shift G'],
                                'selector': ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            '.jp-Notebook:focus'},
                               {'command': 'notebook:copy-cell',
                                'keys': ['Y', 'Y'],
                                'selector': ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            '.jp-Notebook:focus'},
                               {'command': 'notebook:cut-cell',
                                'keys': ['D', 'D'],
                                'selector': ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            '.jp-Notebook:focus'},
                               {'command': 'notebook:paste-cell-above',
                                'keys': ['Shift P'],
                                'selector': ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            '.jp-Notebook:focus'},
                               {'command': 'notebook:paste-cell-below',
                                'keys': ['P'],
                                'selector': ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            '.jp-Notebook:focus'},
                               {'command': 'notebook:insert-cell-below',
                                'keys': ['O'],
                                'selector': ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            '.jp-Notebook:focus'},
                               {'command': 'notebook:insert-cell-above',
                                'keys': ['Shift O'],
                                'selector': ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            '.jp-Notebook:focus'},
                               {'command': 'notebook:undo-cell-action',
                                'keys': ['U'],
                                'selector': ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            '.jp-Notebook:focus'},
                               {'command': 'notebook:move-cell-down',
                                'keys': ['Ctrl E'],
                                'selector': ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            '.jp-Notebook:focus'},
                               {'command': 'notebook:move-cell-up',
                                'keys': ['Ctrl Y'],
                                'selector': ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            '.jp-Notebook:focus'},
                               {'command': 'vim:center-cell',
                                'keys': ['Z', 'Z'],
                                'selector': ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            '.jp-Notebook:focus'},
                               {'command': 'notebook:hide-cell-code',
                                'keys': ['Z', 'C'],
                                'selector': ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            '.jp-Notebook:focus'},
                               {'command': 'notebook:show-cell-code',
                                'keys': ['Z', 'O'],
                                'selector': ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            '.jp-Notebook:focus'},
                               {'command': 'notebook:hide-all-cell-code',
                                'keys': ['Z', 'M'],
                                'selector': ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            '.jp-Notebook:focus'},
                               {'command': 'notebook:show-all-cell-code',
                                'keys': ['Z', 'R'],
                                'selector': ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            '.jp-Notebook:focus'},
                               {'command': 'vim:center-cell',
                                'keys': ['Ctrl O', 'Z', 'Z'],
                                'selector': ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            '.jp-Notebook.jp-mod-editMode'},
                               {'command': 'tooltip:launch-notebook',
                                'keys': ['Ctrl G'],
                                'selector': ".jp-NotebookPanel[data-jp-vim-mode='true'] "
                                            '.jp-Notebook.jp-mod-editMode '
                                            '.jp-InputArea-editor:not(.jp-mod-has-primary-selection)'}],
     'properties': {'enabled': {'default': True,
                                'description': 'Enable/disable notebook '
                                               'vim (may require a page '
                                               'refresh)',
                                'title': 'Enabled',
                                'type': 'boolean'},
                    'extraKeybindings': {'default': [],
                                         'items': {'$ref': '#/definitions/shortcut'},
                                         'title': 'Extra Vim Keybindings',
                                         'type': 'array'}},
     'title': 'Notebook Vim',
     'type': 'object'}

On instance:
    {'cmdModeKeys': {'escToCmdMode': False,
                     'shiftEscOverrideBrowser': True},
     'enabled': True,
     'enabledInEditors': True,
     'extraKeybindings': []}

The lastes versions combination might have some problem but I couldn't resolve it.

Thanks!

firai commented 4 months ago

I can't replicate this with jupyterlab 4.2.3, jupyterlab-vim 4.1.3 and Firefox 127.0.2 on Windows. What browser plugins do you have installed? Can you try upgrading jupyterlab?

firai commented 3 months ago

I'll close this for now since there wasn't a response. Please reopen with the requested details or open a new issue with additional details if you're still experiencing this issue.