diff options
author | Thomas Vigouroux <tomvig38@gmail.com> | 2021-03-31 17:59:42 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-31 17:59:42 +0200 |
commit | 94c2ce2ce4599622bbf65215fde876ae7fb16114 (patch) | |
tree | ce5e884e81d443056710fe12d066f2f57a681336 /test/functional/treesitter/highlight_spec.lua | |
parent | c20ae3aadbcc1210faad4cd3cf6a8444f198b19d (diff) | |
parent | d6209a7b84a12fadd90fc5b4cb5efb66e8ca8127 (diff) | |
download | rneovim-94c2ce2ce4599622bbf65215fde876ae7fb16114.tar.gz rneovim-94c2ce2ce4599622bbf65215fde876ae7fb16114.tar.bz2 rneovim-94c2ce2ce4599622bbf65215fde876ae7fb16114.zip |
Merge pull request #14252 from tjdevries/tjdevries/ts_query_overrides
ts: Add per-language query overriding
Diffstat (limited to 'test/functional/treesitter/highlight_spec.lua')
-rw-r--r-- | test/functional/treesitter/highlight_spec.lua | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/test/functional/treesitter/highlight_spec.lua b/test/functional/treesitter/highlight_spec.lua index cb73bfbbe1..1992f75413 100644 --- a/test/functional/treesitter/highlight_spec.lua +++ b/test/functional/treesitter/highlight_spec.lua @@ -472,4 +472,45 @@ describe('treesitter highlighting', function() | ]]} end) + + it("supports overriding queries, like ", function() + if pending_c_parser(pending) then return end + + insert([[ + int x = INT_MAX; + #define READ_STRING(x, y) (char_u *)read_string((x), (size_t)(y)) + #define foo void main() { \ + return 42; \ + } + ]]) + + exec_lua [[ + local injection_query = "(preproc_def (preproc_arg) @c) (preproc_function_def value: (preproc_arg) @c)" + require('vim.treesitter.query').set_query("c", "highlights", hl_query) + require('vim.treesitter.query').set_query("c", "injections", injection_query) + + vim.treesitter.highlighter.new(vim.treesitter.get_parser(0, "c")) + ]] + + screen:expect{grid=[[ + {3:int} x = {5:INT_MAX}; | + #define {5:READ_STRING}(x, y) ({3:char_u} *)read_string((x), ({3:size_t})(y))| + #define foo {3:void} main() { \ | + {4:return} {5:42}; \ | + } | + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) end) |