Repository navigation
Expand file tree
/
Copy pathmini-cursorword.txt
More file actions
109 lines (85 loc) · 4.42 KB
/
Copy pathmini-cursorword.txt
File metadata and controls
109 lines (85 loc) · 4.42 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
==============================================================================
------------------------------------------------------------------------------
*mini.cursorword*
*MiniCursorword*
Autohighlight word under cursor with customizable delay. Current word under
cursor can be highlighted differently. Highlighting is triggered only if
current cursor character is a |[:keyword:]|. "Word under cursor" is meant
as in Vim's |<cword>|: something user would get as 'iw' text object.
Highlighting stops in insert and terminal modes.
# Setup~
This module needs a setup with `require('mini.cursorword').setup({})`
(replace `{}` with your `config` table). It will create global Lua table
`MiniCursorword` which you can use for scripting or manually (with
`:lua MiniCursorword.*`).
See |MiniCursorword.config| for `config` structure and default values.
You can override runtime config settings locally to buffer inside
`vim.b.minicursorword_config` which should have same structure as
`MiniCursorword.config`. See |mini.nvim-buffer-local-config| for more details.
# Highlight groups~
* `MiniCursorword` - highlight group of cursor word. Default: plain underline.
* `MiniCursorwordCurrent` - highlight group of a current word under
cursor. It will be displayed on top of `MiniCursorword`
(so `:hi clear MiniCursorwordCurrent` will lead to showing
`MiniCursorword` highlight group). Note: To not highlight it, use
`:hi! MiniCursorwordCurrent gui=nocombine guifg=NONE guibg=NONE` .
To change any highlight group, modify it directly with |:highlight|.
# Disabling~
To disable core functionality, set `g:minicursorword_disable` (globally) or
`b:minicursorword_disable` (for a buffer) to `v:true`. Considering high
number of different scenarios and customization intentions, writing exact
rules for disabling module's functionality is left to user. See
|mini.nvim-disabling-recipes| for common recipes. Note: after disabling
there might be highlighting left; it will be removed after next
highlighting update.
Module-specific disabling:
- Don't show highlighting if cursor is on the word that is in a blocklist
of current filetype. In this example, blocklist for "lua" is "local" and
"require" words, for "javascript" - "import":
>
_G.cursorword_blocklist = function()
local curword = vim.fn.expand('<cword>')
local filetype = vim.api.nvim_buf_get_option(0, 'filetype')
-- Add any disabling global or filetype-specific logic here
local blocklist = {}
if filetype == 'lua' then
blocklist = { 'local', 'require' }
elseif filetype == 'javascript' then
blocklist = { 'import' }
end
vim.b.minicursorword_disable = vim.tbl_contains(blocklist, curword)
end
-- Make sure to add this autocommand *before* calling module's `setup()`.
vim.cmd('au CursorMoved * lua _G.cursorword_blocklist()')
------------------------------------------------------------------------------
*MiniCursorword.setup()*
`MiniCursorword.setup`({config})
Module setup
Parameters~
{config} `(table|nil)` Module config table. See |MiniCursorword.config|.
Usage~
`require('mini.cursorword').setup({})` (replace `{}` with your `config` table)
------------------------------------------------------------------------------
*MiniCursorword.config*
`MiniCursorword.config`
Module config
Default values:
>
MiniCursorword.config = {
-- Delay (in ms) between when cursor moved and when highlighting appeared
delay = 100,
}
<
------------------------------------------------------------------------------
*MiniCursorword.auto_highlight()*
`MiniCursorword.auto_highlight`()
Auto highlight word under cursor
Designed to be used with |autocmd|. No need to use it directly,
everything is setup in |MiniCursorword.setup|.
------------------------------------------------------------------------------
*MiniCursorword.auto_unhighlight()*
`MiniCursorword.auto_unhighlight`()
Auto unhighlight word under cursor
Designed to be used with |autocmd|. No need to use it directly, everything
is setup in |MiniCursorword.setup|.
vim:tw=78:ts=8:noet:ft=help:norl: