mirror of
https://github.com/chenasraf/vim-matchup.git
synced 2026-05-17 17:38:01 +00:00
Allow hotfix for dotted &filetype, fixes #46
This commit is contained in:
@@ -47,7 +47,7 @@ function! matchup#loader#bufwinenter() abort " {{{1
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
function! matchup#loader#refresh_match_words() " {{{1
|
||||
function! matchup#loader#refresh_match_words() abort " {{{1
|
||||
if get(b:, 'match_words', ':') !~# ':'
|
||||
call matchup#perf#tic('refresh')
|
||||
|
||||
@@ -96,7 +96,9 @@ function! s:init_delim_lists(...) abort " {{{1
|
||||
" we don't explicitly check this, but the behavior might
|
||||
" be unpredictable if such groups are encountered.. (ref-1)
|
||||
|
||||
if exists('g:matchup_hotfix_'.&filetype)
|
||||
if exists('g:matchup_hotfix') && has_key(g:matchup_hotfix, &filetype)
|
||||
call call(g:matchup_hotfix[&filetype], [])
|
||||
elseif exists('g:matchup_hotfix_'.&filetype)
|
||||
call call(g:matchup_hotfix_{&filetype}, [])
|
||||
elseif exists('b:matchup_hotfix')
|
||||
call call(b:matchup_hotfix, [])
|
||||
|
||||
@@ -769,7 +769,7 @@ HTML
|
||||
|
||||
Customization~
|
||||
|
||||
*g:matchup_hotfix_{&filetype}* *matchup-hotfix*
|
||||
*g:matchup_hotfix[&filetype]* *matchup-hotfix*
|
||||
|
||||
For each file type, this option can be set to the string name of a function
|
||||
which will be called when loading files, prior to checking |b:match_words|
|
||||
@@ -779,7 +779,7 @@ Customization~
|
||||
function! VimHotfix()
|
||||
" customization
|
||||
endfunction
|
||||
let g:matchup_hotfix_vim = 'VimHotfix'
|
||||
let g:matchup_hotfix['vim'] = 'VimHotfix'
|
||||
|
||||
*b:matchup_hotfix*
|
||||
|
||||
|
||||
5
test/issues/46/Sample.jsx
Normal file
5
test/issues/46/Sample.jsx
Normal file
@@ -0,0 +1,5 @@
|
||||
|
||||
const Sample = <Sample prop='highlight test'>
|
||||
some body
|
||||
</Sample>;
|
||||
|
||||
26
test/issues/46/minvimrc1
Normal file
26
test/issues/46/minvimrc1
Normal file
@@ -0,0 +1,26 @@
|
||||
set nocompatible
|
||||
|
||||
" load match-up
|
||||
let s:path = simplify(expand('<sfile>:h').'/../../..')
|
||||
let &rtp = s:path.',' . &rtp
|
||||
let &rtp .= ','.s:path.'/after'
|
||||
|
||||
autocmd FileType * echo &ft | sleep 1
|
||||
|
||||
call plug#begin('~/.vim/plugged')
|
||||
Plug 'mxw/vim-jsx'
|
||||
Plug 'othree/yajs.vim'
|
||||
Plug 'othree/es.next.syntax.vim'
|
||||
call plug#end()
|
||||
|
||||
filetype plugin indent on
|
||||
syntax enable
|
||||
|
||||
" match-up options go here
|
||||
function! JsxHotfix()
|
||||
echo 'JsxHotfix'
|
||||
setlocal matchpairs=(:),{:},[:],<:>
|
||||
let b:match_words = '<\@<=\([^/][^ \t>]*\)\g{hlend}[^>]*\%(/\@<!>\|$\):<\@<=/\1>'
|
||||
endfunction
|
||||
let g:matchup_hotfix = { 'javascript.jsx': 'JsxHotfix' }
|
||||
|
||||
26
test/issues/46/minvimrc2
Normal file
26
test/issues/46/minvimrc2
Normal file
@@ -0,0 +1,26 @@
|
||||
set nocompatible
|
||||
|
||||
" load match-up
|
||||
let s:path = simplify(expand('<sfile>:h').'/../../..')
|
||||
let &rtp = s:path.',' . &rtp
|
||||
let &rtp .= ','.s:path.'/after'
|
||||
|
||||
autocmd FileType * echo &ft | sleep 1
|
||||
|
||||
call plug#begin('~/.vim/plugged')
|
||||
Plug 'mxw/vim-jsx'
|
||||
Plug 'othree/yajs.vim'
|
||||
Plug 'othree/es.next.syntax.vim'
|
||||
call plug#end()
|
||||
|
||||
filetype plugin indent on
|
||||
syntax enable
|
||||
|
||||
" match-up options go here
|
||||
function! JsxHotfix()
|
||||
echo 'JsxHotfix'
|
||||
setlocal matchpairs=(:),{:},[:],<:>
|
||||
let b:match_words = '<\@<=\([^/][^ \t>]*\)\g{hlend}[^>]*\%(/\@<!>\|$\):<\@<=/\1>'
|
||||
endfunction
|
||||
autocmd FileType javascript.jsx let b:matchup_hotfix = 'JsxHotfix'
|
||||
|
||||
Reference in New Issue
Block a user