-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathilluminate.vim
93 lines (83 loc) · 3.58 KB
/
illuminate.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
" illuminate.vim - Vim plugin for selectively illuminating other uses of current word
" Maintainer: Adam P. Regasz-Rethy (RRethy) <[email protected]>
" Version: 2.0
if exists('g:loaded_illuminate')
finish
endif
let g:loaded_illuminate = 1
if has('nvim-0.7.2') && get(g:, 'Illuminate_useDeprecated', 0) != 1
lua << EOF
if vim.fn.has('nvim-0.9') == 0 then
-- fallback to nvim-treesitter modules
local ok, ts = pcall(require, 'nvim-treesitter')
if ok then
ts.define_modules({
illuminate = {
module_path = 'illuminate.providers.treesitter',
enable = true,
disable = {},
is_supported = require('nvim-treesitter.query').has_locals,
}
})
end
end
require('illuminate.engine').start()
vim.api.nvim_create_user_command('IlluminatePause', require('illuminate').pause, { bang = true })
vim.api.nvim_create_user_command('IlluminateResume', require('illuminate').resume, { bang = true })
vim.api.nvim_create_user_command('IlluminateToggle', require('illuminate').toggle, { bang = true })
vim.api.nvim_create_user_command('IlluminatePauseBuf', require('illuminate').pause_buf, { bang = true })
vim.api.nvim_create_user_command('IlluminateResumeBuf', require('illuminate').resume_buf, { bang = true })
vim.api.nvim_create_user_command('IlluminateToggleBuf', require('illuminate').toggle_buf, { bang = true })
vim.api.nvim_create_user_command('IlluminateDebug', require('illuminate').debug, { bang = true })
if not require('illuminate.config').disable_keymaps() then
if not require('illuminate.util').has_keymap('n', '<a-n>') then
vim.keymap.set('n', '<a-n>', require('illuminate').goto_next_reference, { desc = "Move to next reference" })
end
if not require('illuminate.util').has_keymap('n', '<a-p>') then
vim.keymap.set('n', '<a-p>', require('illuminate').goto_prev_reference, { desc = "Move to previous reference" })
end
if not require('illuminate.util').has_keymap('o', '<a-i>') then
vim.keymap.set('o', '<a-i>', require('illuminate').textobj_select)
end
if not require('illuminate.util').has_keymap('x', '<a-i>') then
vim.keymap.set('x', '<a-i>', require('illuminate').textobj_select)
end
end
EOF
lua require('illuminate').set_highlight_defaults()
augroup vim_illuminate_autocmds
autocmd!
autocmd ColorScheme * lua require('illuminate').set_highlight_defaults()
augroup END
finish
end
" Highlight group(s) {{{
if !hlexists('illuminatedWord')
" this is for backwards compatibility
if !empty(get(g:, 'Illuminate_hl_link', ''))
exe get(g:, 'Illuminate_hl_link', '')
else
hi def link illuminatedWord cursorline
endif
endif
" }}}
" Autocommands {{{
if has('autocmd')
augroup illuminated_autocmd
autocmd!
autocmd CursorMoved,InsertLeave * call illuminate#on_cursor_moved()
autocmd WinLeave,BufLeave * call illuminate#on_leaving_autocmds()
autocmd CursorMovedI * call illuminate#on_cursor_moved_i()
autocmd InsertEnter * call illuminate#on_insert_entered()
augroup END
else
echoerr 'Illuminate requires Vim compiled with +autocmd'
finish
endif
" }}}
" Commands {{{
command! -nargs=0 -bang IlluminationDisable call illuminate#disable_illumination(<bang>0)
command! -nargs=0 -bang IlluminationEnable call illuminate#enable_illumination(<bang>0)
command! -nargs=0 -bang IlluminationToggle call illuminate#toggle_illumination(<bang>0)
" }}} Commands:
" vim: foldlevel=1 foldmethod=marker