folke / flash.nvim

Navigate your code with search labels, enhanced character motions and Treesitter integration
Apache License 2.0
2.57k stars 34 forks source link

Error when setting up 2-char jump #199

Closed neur1n closed 1 year ago

neur1n commented 1 year ago

I'm following the example in README.md to set up 2-char jump, but there is an error which is caused by the following code: https://github.com/folke/flash.nvim/blob/967117690bd677cb7b6a87f0bc0077d2c0be3a27/lua/flash/search/init.lua#L48

When NeoVim starts up, local line is nil since vim.api.nvim_buf_get_lines returns an empty table. Please checkout this comment for more details.

Is this a bug or am I loading flash.nvim incorrectly (using vim-plug)? Your help will be much appreciated.

IndianBoy42 commented 1 year ago

I think you are loading flash.nvim incorrectly, specifically setting up the keymap incorrectly. Because there is no reason for that line (or the function containing it) to be called on startup (ie when buf_get_lines would return an empty table) it should only be called when you actually start a jump

neur1n commented 1 year ago

You are correct. My keymap was missing function() ... end or <cmd> ... <cr>. Thanks!