robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
1d5b3b5b4c
master
1local n =require ( 'test.functional.testnvim' )() 2 3local exec_lua =n . exec_lua 4 5local M ={} 6 7---@param language string 8---@param query_string string 9function M . run_query ( language , query_string ) 10return exec_lua ( function ( lang , query_str ) 11local query =vim . treesitter . query . parse ( lang , query_str ) 12local parser =vim . treesitter . get_parser () 13local tree =parser : parse ()[ 1 ] 14local Range =require ( 'vim.treesitter._range' ) 15local res ={} 16for id , node , metadata in query : iter_captures ( tree : root (), 0 ) do 17table . insert ( res , { 18query . captures [ id ], 19{ Range . unpack4 ( vim . treesitter . get_range ( node , 0 , metadata [ id ])) } , 20} ) 21end 22return res 23end , language , query_string ) 24end 25 26return M