aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua/treesitter_spec.lua
diff options
context:
space:
mode:
authorThomas Vigouroux <tomvig38@gmail.com>2020-10-06 09:09:28 +0200
committerThomas Vigouroux <tomvig38@gmail.com>2020-10-11 21:18:28 +0200
commitd3f544002c753062a9d2ee258c0673f54d6f8cc5 (patch)
treed8ec3146b43ff7b2dc02a9f1d34acdb5b3c0f468 /test/functional/lua/treesitter_spec.lua
parentb9776ff5b757ed051acb0ae5c6a1464cec333698 (diff)
downloadrneovim-d3f544002c753062a9d2ee258c0673f54d6f8cc5.tar.gz
rneovim-d3f544002c753062a9d2ee258c0673f54d6f8cc5.tar.bz2
rneovim-d3f544002c753062a9d2ee258c0673f54d6f8cc5.zip
treesitter: runtime queries
Runtime queries just work like ftplugins, that is: - Queries in the `after` directory are sourced _after_ the "base" query - Otherwise, the last define query takes precedence. Queries can be found in the `queries` directory. Update runtime/lua/vim/treesitter/query.lua Co-authored-by: Paul Burlumi <paul@burlumi.com>
Diffstat (limited to 'test/functional/lua/treesitter_spec.lua')
-rw-r--r--test/functional/lua/treesitter_spec.lua13
1 files changed, 11 insertions, 2 deletions
diff --git a/test/functional/lua/treesitter_spec.lua b/test/functional/lua/treesitter_spec.lua
index 74ae6cde2b..35dd6b368a 100644
--- a/test/functional/lua/treesitter_spec.lua
+++ b/test/functional/lua/treesitter_spec.lua
@@ -25,7 +25,6 @@ describe('treesitter API', function()
eq("Error executing lua: .../language.lua: no parser for 'borklang' language, see :help treesitter-parsers",
pcall_err(exec_lua, "parser = vim.treesitter.inspect_language('borklang')"))
end)
-
end)
describe('treesitter API with C parser', function()
@@ -186,6 +185,16 @@ void ui_refresh(void)
(field_expression argument: (identifier) @fieldarg)
]]
+ it("supports runtime queries", function()
+ if not check_parser() then return end
+
+ local ret = exec_lua [[
+ return require"vim.treesitter.query".get_query("c", "highlights").captures[1]
+ ]]
+
+ eq('variable', ret)
+ end)
+
it('support query and iter by capture', function()
if not check_parser() then return end
@@ -422,7 +431,7 @@ static int nlua_schedule(lua_State *const lstate)
exec_lua([[
local highlighter = vim.treesitter.highlighter
local query = ...
- test_hl = highlighter.new(query, 0, "c")
+ test_hl = highlighter.new(0, "c", query)
]], hl_query)
screen:expect{grid=[[
{2:/// Schedule Lua callback on main loop's event queue} |