mirror of
https://github.com/chenasraf/vim-matchup.git
synced 2026-05-17 17:38:01 +00:00
Add a tree-sitter test
This commit is contained in:
6
.github/workflows/neovim.yml
vendored
6
.github/workflows/neovim.yml
vendored
@@ -28,6 +28,12 @@ jobs:
|
||||
vim_version: '${{ matrix.neovim_version }}'
|
||||
vim_type: 'Neovim'
|
||||
|
||||
- name: Install nvim-treesitter
|
||||
run: git clone --depth=1 https://github.com/nvim-treesitter/nvim-treesitter.git test/vader/plugged/nvim-treesitter
|
||||
|
||||
- name: Install python treesitter module
|
||||
run: nvim --headless -Nu test/vader/minvimrc -c 'TSInstallSync python' -c 'q'
|
||||
|
||||
- name: 'Show version'
|
||||
run: nvim --version
|
||||
|
||||
|
||||
@@ -279,7 +279,7 @@ function M.attach(bufnr, lang)
|
||||
end
|
||||
|
||||
function M.detach(bufnr)
|
||||
api.nvim_call_function('matchup#ts_engine#detach', {bufnr, lang})
|
||||
api.nvim_call_function('matchup#ts_engine#detach', {bufnr})
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
@@ -12,6 +12,19 @@ let &rtp = s:path.'/test/rtp,' . &rtp
|
||||
" load other plugins, if necessary
|
||||
" let &rtp = '~/path/to/other/plugin,' . &rtp
|
||||
|
||||
if has('nvim-0.5.0')
|
||||
let &rtp = s:path.'/test/vader/plugged/nvim-treesitter,' . &rtp
|
||||
let &rtp .= ','.s:path.'/test/vader/plugged/nvim-treesitter/after'
|
||||
|
||||
lua <<EOF
|
||||
require'nvim-treesitter.configs'.setup {
|
||||
matchup = {
|
||||
enable = true
|
||||
}
|
||||
}
|
||||
EOF
|
||||
endif
|
||||
|
||||
if empty(globpath(&rtp, 'plugin/vader.vim'))
|
||||
echoerr 'vader not found'
|
||||
exit!
|
||||
|
||||
46
test/vader/ts_py_motion.vader
Normal file
46
test/vader/ts_py_motion.vader
Normal file
@@ -0,0 +1,46 @@
|
||||
Execute (Helper):
|
||||
function! TSActive()
|
||||
return exists(':TSInstall')
|
||||
endfunction
|
||||
|
||||
if TSActive()
|
||||
Log 'nvim-treesitter active'
|
||||
else
|
||||
Log 'nvim-treesitter not active'
|
||||
endif
|
||||
|
||||
Given python (A python script):
|
||||
def F(x):
|
||||
if x == 1:
|
||||
return 1
|
||||
elif x == 2:
|
||||
pass
|
||||
else:
|
||||
return 3
|
||||
return 2
|
||||
|
||||
Execute (Logs):
|
||||
Log b:matchup_active_engines
|
||||
|
||||
Before (Cursor):
|
||||
normal! 2gg^
|
||||
|
||||
Do (Move %):
|
||||
%
|
||||
Then (Verify line):
|
||||
Assert line('.') == (TSActive() ? 4 : 2)
|
||||
|
||||
Do (Move % twice):
|
||||
%%
|
||||
Then (Verify line):
|
||||
Assert line('.') == (TSActive() ? 6 : 2)
|
||||
|
||||
Do (Move % 3 times):
|
||||
%%%
|
||||
Then (Verify line):
|
||||
Assert line('.') == (TSActive() ? 2 : 2)
|
||||
|
||||
Do (Move % 4 times):
|
||||
%%%%
|
||||
Then (Verify line):
|
||||
Assert line('.') == (TSActive() ? 4 : 2)
|
||||
Reference in New Issue
Block a user