unblevable / quick-scope

Lightning fast left-right movement in Vim
MIT License
1.43k stars 54 forks source link

Highlighting Stays On #72

Closed ChiliConSql closed 4 months ago

ChiliConSql commented 3 years ago

Even though I set let g:qs_highlight_on_keys = ['f', 'F', 't', 'T'] the highlighting is always on.

I am using Neovim v.0.4.4

bradford-smith94 commented 3 years ago

I installed Neovim (v0.4.4) and did not reproduce this.

I used the init.vim configuration of:

set runtimepath^=~/.vim runtimepath+=~/.vim/after
let &packpath = &runtimepath
source ~/.vimrc

in order to run with my Vim config (which has the highlight on keys set in it - line 108) as suggested by the Neovim help.

My current guess is that it could be a configuration error or conflict with another plugin or setting, I suggest you try to determine the minimal configuration file that will reproduce the issue.

ChiliConSql commented 3 years ago

@bradford-smith94 thank you for your input.

It looks like the issue is "where" I put the directive. If I put it in nvimrc after initializing the plugin, it works. But if I put it in "plugins" folder, it doesn't, even though opening a file and issuing: :echo g:qs_highlight_on_keys produces the correct result of ['f', 'F', 't', 'T'].

Any idea why, and where can I place this directive outside of nvimrc/init.vim.?

bradford-smith94 commented 3 years ago

Sure, the why is most likely because of the order in which the vim/nvim configuration files are sourced. When the quick-scope plugin file is sourced is when it checks for the value of g:qs_highlight_on_keys, so if your settings file is sourced after that it will not matter what you set it to. This particular value isn't setup to be changed or toggled at runtime so it isn't checked anywhere else in the code, but that could be a possible enhancement.

The builtin help page :help initialization can provide more detail on the order that files are loaded, specifically the :help load-plugins section applies here, although the help page doesn't seem to provide much information on how the plugins are ordered themselves.

You can use the command :scriptnames to see the order in which vim/nvim has processed files, the goal here would be to get the file that contains the g:qs_highlight_on_keys setting to be loaded before .../quick-scope/plugin/quick_scope.vim (the ... changes depending on where your plugins are installed). I'm not exactly sure how much you can do to force vim/nvim to load your file first, but it might be worth it to experiment with changing the name of the file (I would guess that some sort of alphabetical loading might take place, but my :scriptnames output doesn't seem to be ordered).

If nothing else works you can put the file in a place that vim/nvim will not automatically load (I like to use ~/.vim/custom/ for this purpose) and then explicitly source that file in your vimrc/init.vim so that it loads before vim/nvim move on to processing plugin files.

gerazov commented 3 years ago

This should be in the README :wink:

bradford-smith94 commented 4 months ago

Added a note to README, also see #98.

Closing this issue, as it is now linked in README so finding the relevant discussion should be possible.