Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ Disabling this option will make the word highlight persist over window switches
let g:vim_current_word#highlight_only_in_focused_window = 1
```

##### Whitelist filetypes:

To allow only in specific filetypes, add this variable to your vimrc:
```vim
let g:vim_current_word#included_filetypes = ['ruby']
```

##### Blacklist filetypes:

To avoid specific filetypes, add this variable to your vimrc:
Expand Down
9 changes: 8 additions & 1 deletion autoload/vim_current_word.vim
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,14 @@ endfunction
function! vim_current_word#pre_highlight()
call vim_current_word#clear_current_word_matches()
let l:vim_current_word_disabled_in_this_buffer = get(b:, 'vim_current_word_disabled_in_this_buffer', 0)
if !g:vim_current_word#enabled || index(g:vim_current_word#excluded_filetypes, &filetype) >= 0 || l:vim_current_word_disabled_in_this_buffer | return 0 | endif
if !g:vim_current_word#enabled || index(g:vim_current_word#excluded_filetypes, &filetype) >= 0 || l:vim_current_word_disabled_in_this_buffer || (len(g:vim_current_word#included_filetypes) > 0 && index(g:vim_current_word#included_filetypes, &filetype) == -1)
return 0
end
if len(g:vim_current_word#included_filetypes) > 0
if index(g:vim_current_word#included_filetypes, &filetype) == -1
return 0
end
end
if g:vim_current_word#highlight_delay
call vim_current_word#schedule_highlight()
else
Expand Down
1 change: 1 addition & 0 deletions plugin/vim_current_word.vim
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ let g:vim_current_word#highlight_current_word = get(g:, 'vim_current_word#highli
let g:vim_current_word#highlight_only_in_focused_window = get(g:, 'vim_current_word#highlight_only_in_focused_window', 1)
let g:vim_current_word#highlight_delay = get(g:, 'vim_current_word#highlight_delay', 0)
let g:vim_current_word#excluded_filetypes = get(g:, 'vim_current_word#excluded_filetypes', [])
let g:vim_current_word#included_filetypes = get(g:, 'vim_current_word#included_filetypes', [])

augroup vim_current_word
autocmd!
Expand Down