mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 19:38:20 +00:00
vim-patch:59834ba: runtime(matchparen): Add matchparen_disable_cursor_hl config option
Set the "matchparen_disable_cursor_hl" config variable to disable
highlighting the cursor with the MatchParen highlighting group.
closes: vim/vim#15984
59834ba6df
Co-authored-by: Matteo Landi <matteo@matteolandi.net>
This commit is contained in:

committed by
Christian Clason

parent
fc8e786dae
commit
baf74ef975
@@ -10,6 +10,7 @@ The functionality mentioned here is a |standard-plugin|.
|
|||||||
This plugin is only available if 'compatible' is not set.
|
This plugin is only available if 'compatible' is not set.
|
||||||
|
|
||||||
You can avoid loading this plugin by setting the "loaded_matchparen" variable: >
|
You can avoid loading this plugin by setting the "loaded_matchparen" variable: >
|
||||||
|
|
||||||
:let loaded_matchparen = 1
|
:let loaded_matchparen = 1
|
||||||
|
|
||||||
The plugin installs CursorMoved, CursorMovedI and WinEnter autocommands to
|
The plugin installs CursorMoved, CursorMovedI and WinEnter autocommands to
|
||||||
@@ -29,6 +30,16 @@ the ":highlight" command. Example: >
|
|||||||
|
|
||||||
:hi MatchParen ctermbg=blue guibg=lightblue
|
:hi MatchParen ctermbg=blue guibg=lightblue
|
||||||
|
|
||||||
|
By default the plugin will highlight both the paren under the cursor and the
|
||||||
|
matching one using the |hl-MatchParen| highlighting group. This may result in
|
||||||
|
the cursor briefly disappearing from the screen as the MatchParen colors take
|
||||||
|
over the cursor highlight. To prevent this from happening and have the plugin
|
||||||
|
only highlight the matching paren and not the one under the cursor
|
||||||
|
(effectively leaving the cursor style unchanged), you can set the
|
||||||
|
"matchparen_disable_cursor_hl" variable: >
|
||||||
|
|
||||||
|
:let matchparen_disable_cursor_hl = 1
|
||||||
|
|
||||||
The characters to be matched come from the 'matchpairs' option. You can
|
The characters to be matched come from the 'matchpairs' option. You can
|
||||||
change the value to highlight different matches. Note that not everything is
|
change the value to highlight different matches. Note that not everything is
|
||||||
possible. For example, you can't highlight single or double quotes, because
|
possible. For example, you can't highlight single or double quotes, because
|
||||||
@@ -46,10 +57,10 @@ are:
|
|||||||
closed folds.
|
closed folds.
|
||||||
- 'synmaxcol' times 2 bytes before or after the cursor to avoid a delay
|
- 'synmaxcol' times 2 bytes before or after the cursor to avoid a delay
|
||||||
in a long line with syntax highlighting.
|
in a long line with syntax highlighting.
|
||||||
- A timeout of 300 msec (60 msec in Insert mode). This can be changed with the
|
- A timeout of 300 msec (60 msec in Insert mode). This can be changed with
|
||||||
g:matchparen_timeout and g:matchparen_insert_timeout variables and their
|
the "g:matchparen_timeout" and "g:matchparen_insert_timeout" variables and
|
||||||
buffer-local equivalents b:matchparen_timeout and
|
their buffer-local equivalents "b:matchparen_timeout" and
|
||||||
b:matchparen_insert_timeout.
|
"b:matchparen_insert_timeout".
|
||||||
|
|
||||||
If you would like the |%| command to work better, the |matchit| plugin can be
|
If you would like the |%| command to work better, the |matchit| plugin can be
|
||||||
used. This plugin also helps to skip matches in comments. This is unrelated
|
used. This plugin also helps to skip matches in comments. This is unrelated
|
||||||
|
@@ -17,6 +17,9 @@ endif
|
|||||||
if !exists("g:matchparen_insert_timeout")
|
if !exists("g:matchparen_insert_timeout")
|
||||||
let g:matchparen_insert_timeout = 60
|
let g:matchparen_insert_timeout = 60
|
||||||
endif
|
endif
|
||||||
|
if !exists("g:matchparen_disable_cursor_hl")
|
||||||
|
let g:matchparen_disable_cursor_hl = 0
|
||||||
|
endif
|
||||||
|
|
||||||
let s:has_matchaddpos = exists('*matchaddpos')
|
let s:has_matchaddpos = exists('*matchaddpos')
|
||||||
|
|
||||||
@@ -189,10 +192,18 @@ func s:Highlight_Matching_Pair()
|
|||||||
" If a match is found setup match highlighting.
|
" If a match is found setup match highlighting.
|
||||||
if m_lnum > 0 && m_lnum >= stoplinetop && m_lnum <= stoplinebottom
|
if m_lnum > 0 && m_lnum >= stoplinetop && m_lnum <= stoplinebottom
|
||||||
if s:has_matchaddpos
|
if s:has_matchaddpos
|
||||||
|
if !g:matchparen_disable_cursor_hl
|
||||||
call add(w:matchparen_ids, matchaddpos('MatchParen', [[c_lnum, c_col - before], [m_lnum, m_col]], 10))
|
call add(w:matchparen_ids, matchaddpos('MatchParen', [[c_lnum, c_col - before], [m_lnum, m_col]], 10))
|
||||||
else
|
else
|
||||||
|
call add(w:matchparen_ids, matchaddpos('MatchParen', [[m_lnum, m_col]], 10))
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
if !g:matchparen_disable_cursor_hl
|
||||||
exe '3match MatchParen /\(\%' . c_lnum . 'l\%' . (c_col - before) .
|
exe '3match MatchParen /\(\%' . c_lnum . 'l\%' . (c_col - before) .
|
||||||
\ 'c\)\|\(\%' . m_lnum . 'l\%' . m_col . 'c\)/'
|
\ 'c\)\|\(\%' . m_lnum . 'l\%' . m_col . 'c\)/'
|
||||||
|
else
|
||||||
|
exe '3match MatchParen /\(\%' . m_lnum . 'l\%' . m_col . 'c\)/'
|
||||||
|
endif
|
||||||
call add(w:matchparen_ids, 3)
|
call add(w:matchparen_ids, 3)
|
||||||
endif
|
endif
|
||||||
let w:paren_hl_on = 1
|
let w:paren_hl_on = 1
|
||||||
|
Reference in New Issue
Block a user