onivim / oni

Oni: Modern Modal Editing - powered by Neovim
https://www.onivim.io
MIT License
11.35k stars 299 forks source link

Some event handlers with specific file patterns don't get triggered #2250

Open numirias opened 6 years ago

numirias commented 6 years ago

Oni Version: 0.3.4 Neovim Version (Linux only): 0.2.2 Operating System: 4.16.10-1-ARCH x86_64 GNU/Linux

Describe your issue

I'm developing a Python plugin for Neovim which does some initialization on VimEnter/BufEnter when editing Python files. However, the event handlers don't get triggered inside Oni when they are limited to a file pattern.

Expected behaviour

The event handlers for VimEnter, GUIEnter and BufEnter should be triggered when Oni starts up with e.g.:

$ oni existing_file.py

Actual behaviour

None of the events seems to get raised.

Steps to reproduce

Take this sample plugin:

import neovim

@neovim.plugin
class Plugin:

    def __init__(self, nvim):
        self.nvim = nvim

    @neovim.autocmd('BufEnter', pattern='*.py')
    def event_buf_enter(self):
        self.nvim.err_write('BufEnter triggered!\n')

Install the plugin and start Oni with a file argument:

$ oni existing_file.py

The event handler will not be triggered unless you change the pattern argument to *.

(Reference ticket: numirias/semshi/issues/10)

oni-bot[bot] commented 6 years ago

Hello and welcome to the Oni repository! Thanks for opening your first issue here. To help us out, please make sure to include as much detail as possible - including screenshots and logs, if possible.

CrossR commented 6 years ago

I'm having a bit of look into this (slightly slower than I'd like due to being away from my PC due to a cancelled train).

First thing I've noticed is that opening things the "Oni" way (That QuickOpen/Sidebar/Opening with Open) doesn't print the 'BufEnter triggered!\n' message. However, opening files with :e my_file.py works just fine and triggers the event. It looks like in some fashion our events are not launching these events? Not fully sure why that would be the case, but I'll keep looking.

akinsho commented 6 years ago

@CrossR I wonder if when opens a file the oni way if a bufEnter is triggered considering those events go via the neovim api, I'm wondering if its possible our events don't aka calls via the api don't result in a normal neovim event? tbh if thats the case could be the cause of a lot of weird behaviour

GeorgeTG commented 6 years ago

I've found the reason why this happens but it comes down as a bigger problem so I'm gonna open a separate issue. (#2323 )