Skip to content

How to call a default mapping inside event_handlers[0].handler? #546

Closed
@nyngwang

Description

@nyngwang

That is, I want to enable the preview mode by default. The following way caused an error saying that the buffer is not modifiable. But if I call vim.cmd('normal! P') directly from command mode :lua ... when my cursor is at neo-tree buffer, it does work. So I think either I should use the require('neo-tree.sources.common.preview') way to call the preview()(but this way the state is missing) or the detection of event like "neo-tree buffer did get loaded" is needed?

And is it possible to return a string to my custom command defined under commands, so I can just use handler = 'my_command'?

event_handlers = {
  {
    event = 'neo_tree_buffer_enter',
    handler = function ()
      if not require('neo-tree.sources.common.preview').is_active() then
        vim.cmd('normal! P')
      end
    end
  },
},

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions