Improve ts syn test

Fix
This commit is contained in:
Andy K. Massimino
2021-10-05 22:48:55 -04:00
parent 5498747940
commit 79254a238e
5 changed files with 40 additions and 4 deletions

View File

@@ -36,6 +36,11 @@ function! matchup#loader#init_buffer() abort " {{{1
if has('nvim-0.5.0') && empty(&syntax)
\ && matchup#ts_engine#is_hl_enabled(bufnr('%'))
let l:has_ts_hl = 1
if matchup#ts_engine#get_option(
\ bufnr('%'), 'additional_vim_regex_highlighting')
set syntax=ON
endif
endif
" initialize lists of delimiter pairs and regular expressions

View File

@@ -322,7 +322,8 @@ end
function M.get_option(bufnr, opt_name)
local config = configs.get_module('matchup')
local lang = parsers.get_buf_lang(bufnr)
if opt_name == 'include_match_words' then
if (opt_name == 'include_match_words'
or opt_name == 'additional_vim_regex_highlighting') then
return opt_tbl_for_lang(config[opt_name], lang)
end
error('invalid option ' .. opt_name)
@@ -330,9 +331,9 @@ end
function M.attach(bufnr, lang)
-- local parser = parsers.get_parser(bufnr, lang)
local config = configs.get_module('matchup')
-- local config = configs.get_module('matchup')
if opt_tbl_for_lang(config.additional_vim_regex_highlighting, lang)
if M.get_option(bufnr, 'additional_vim_regex_highlighting')
and api.nvim_buf_get_option(bufnr, 'syntax') == '' then
api.nvim_buf_set_option(bufnr, 'syntax', 'ON')
end

View File

@@ -1,5 +1,5 @@
RANDOM := $(shell bash -c 'echo $$RANDOM')
COVER = covimerage run --append --no-report \
COVER = covimerage -q run --append --no-report \
--data-file $(CURDIR)/cov.tmp/_$(RANDOM)_coverage_covimerage_$@ \
--source $(CURDIR)/../../autoload \
--source $(CURDIR)/../../plugin

View File

@@ -9,3 +9,4 @@ test:
@MODE=0 $(MYVIM) -u test.vim
@MODE=1 $(MYVIM) -u test.vim
@MODE=2 $(MYVIM) -u test.vim
@MODE=3 $(MYVIM) -u test.vim

View File

@@ -2,9 +2,12 @@ set nocompatible
source ../common/bootstrap.vim
if !$TESTS_ENABLE_TREESITTER && $MODE > 0
echo 'Exiting'
call matchup#test#finished()
endif
let s:expect_ts_engine = +$TESTS_ENABLE_TREESITTER
if $MODE == 1
lua <<EOF
require'nvim-treesitter.configs'.setup {
@@ -22,10 +25,36 @@ elseif $MODE == 2
}
}
EOF
elseif $MODE == 3
lua <<EOF
require'nvim-treesitter.configs'.setup {
highlight = { enable = true },
matchup = { enable = false }
}
EOF
let s:expect_ts_engine = 0
endif
silent edit example.rb
" manually reload match-up for the buffer since the tree-sitter
" configuration may not have been initialized properly before
call matchup#loader#init_buffer()
if s:expect_ts_engine
call assert_equal(2, len(b:matchup_active_engines.delim_all))
endif
if $MODE == 2
call assert_false(empty(&syntax))
endif
" if syntax is not available, we should use ts-based skip
if empty(&syntax)
call assert_true(b:matchup_delim_skip =~# 'ts_syntax')
endif
function! s:match_test(pos, check) abort
call matchup#pos#set_cursor(a:pos)
normal %