RRethy/nvim-treesitter-endwise

Segfault on HEAD with endwise enabled.

dsully opened this issue · 2 comments

nvim-treesitter-endwise is causing a segfault using Neovim @ HEAD. See: neovim/neovim#18079 for the details.

Can nvim_get_mode() be used in this plugin instead of FFI?

API functions cannot be used, see

-- vim.fn.mode() may fail if we call it outside schedule_wrap. To get
-- around this, we call Neovim internal C functions directly.
-- This is needed because a user can have press <CR> in a different mode
-- (e.g. command-line mode) which then puts them into insert mode and
-- triggers <CR>, this will trigger on_key twice and the callback to
-- schedule_wrap will both trigger while in insert mode, this will lead to
-- two `end` tokens added. We check the mode before we schedule_wrap our
-- callback to ensure we only react to insert mode <CR>.
The FFI call was to fix #9.

I see that the signature of get_mode has changed which is unfortunate. I'll have to think about how to go about fixing this.

Edit: It seems like vim.api.nvim_get_mode() doesn't error as I thought it would based on neovim/neovim#17273 but it seems I misunderstood.