mirror of
https://github.com/chenasraf/vim-matchup.git
synced 2026-05-18 01:38:57 +00:00
Use ts syn skip if available
This commit is contained in:
@@ -26,6 +26,12 @@ function! matchup#loader#init_buffer() abort " {{{1
|
||||
let l:has_ts = 1
|
||||
endif
|
||||
|
||||
let l:has_ts_hl = 0
|
||||
if has('nvim-0.5.0') && empty(&syntax)
|
||||
\ && matchup#ts_engine#is_hl_enabled(bufnr('%'))
|
||||
let l:has_ts_hl = 1
|
||||
endif
|
||||
|
||||
" initialize lists of delimiter pairs and regular expressions
|
||||
" this is the data obtained from parsing b:match_words
|
||||
let b:matchup_delim_lists = s:init_delim_lists(!l:has_ts)
|
||||
@@ -35,7 +41,7 @@ function! matchup#loader#init_buffer() abort " {{{1
|
||||
let b:matchup_delim_re = s:init_delim_regexes()
|
||||
|
||||
" process b:match_skip
|
||||
if l:has_ts
|
||||
if l:has_ts_hl
|
||||
let b:matchup_delim_skip
|
||||
\ = "matchup#ts_syntax#skip_expr(line('.'), col('.'))"
|
||||
else
|
||||
|
||||
@@ -21,6 +21,13 @@ function! matchup#ts_engine#is_enabled(bufnr) abort
|
||||
return +s:forward('is_enabled', a:bufnr)
|
||||
endfunction
|
||||
|
||||
function! matchup#ts_engine#is_hl_enabled(bufnr) abort
|
||||
if !has('nvim-0.5.0')
|
||||
return 0
|
||||
endif
|
||||
return +s:forward('is_hl_enabled', a:bufnr)
|
||||
endfunction
|
||||
|
||||
let s:attached = {}
|
||||
|
||||
function! matchup#ts_engine#attach(bufnr, lang) abort
|
||||
|
||||
@@ -23,6 +23,12 @@ function M.is_enabled(bufnr)
|
||||
return configs.is_enabled('matchup', lang)
|
||||
end
|
||||
|
||||
function M.is_hl_enabled(bufnr)
|
||||
bufnr = bufnr or api.nvim_get_current_buf()
|
||||
local lang = parsers.get_buf_lang(bufnr)
|
||||
return configs.is_enabled('highlight', lang)
|
||||
end
|
||||
|
||||
function M.get_matches(bufnr)
|
||||
return queries.get_matches(bufnr, 'matchup')
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user