diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/treesitter/highlight_spec.lua | 89 |
1 files changed, 88 insertions, 1 deletions
diff --git a/test/functional/treesitter/highlight_spec.lua b/test/functional/treesitter/highlight_spec.lua index 2bf230fe69..7f2b5751ae 100644 --- a/test/functional/treesitter/highlight_spec.lua +++ b/test/functional/treesitter/highlight_spec.lua @@ -681,6 +681,12 @@ describe('treesitter highlighting (C)', function() ((identifier) @Identifier (#set! conceal "") (#eq? @Identifier "lstate")) + + ((call_expression + function: (identifier) @function + arguments: (argument_list) @arguments) + (#eq? @function "multiqueue_put") + (#set! @function conceal "V")) ]]}}) ]=] @@ -697,7 +703,7 @@ describe('treesitter highlighting (C)', function() | LuaRef cb = nlua_ref(, 1); | | - multiqueue_put(main_loop.events, nlua_schedule_event, | + {11:V}(main_loop.events, nlua_schedule_event, | 1, (void *)(ptrdiff_t)cb); | return 0; | ^} | @@ -758,6 +764,44 @@ describe('treesitter highlighting (C)', function() end) end) +describe('treesitter highlighting (lua)', function() + local screen + + before_each(function() + screen = Screen.new(65, 18) + screen:attach() + screen:set_default_attr_ids { + [1] = { bold = true, foreground = Screen.colors.Blue }, + [2] = { foreground = Screen.colors.DarkCyan }, + [3] = { foreground = Screen.colors.Magenta }, + [4] = { foreground = Screen.colors.SlateBlue }, + [5] = { bold = true, foreground = Screen.colors.Brown }, + } + end) + + it('supports language injections', function() + insert [[ + local ffi = require('ffi') + ffi.cdef("int (*fun)(int, char *);") + ]] + + exec_lua [[ + vim.bo.filetype = 'lua' + vim.treesitter.start() + ]] + + screen:expect { + grid = [[ + {5:local} {2:ffi} {5:=} {4:require(}{3:'ffi'}{4:)} | + {2:ffi}{4:.}{2:cdef}{4:(}{3:"}{4:int}{3: }{4:(}{5:*}{3:fun}{4:)(int,}{3: }{4:char}{3: }{5:*}{4:);}{3:"}{4:)} | + ^ | + {1:~ }|*14 + | + ]], + } + end) +end) + describe('treesitter highlighting (help)', function() local screen @@ -891,3 +935,46 @@ vim.cmd([[ } end) end) + +describe('treesitter highlighting (markdown)', function() + local screen + + before_each(function() + screen = Screen.new(40, 6) + screen:attach() + screen:set_default_attr_ids { + [1] = { foreground = Screen.colors.Blue1 }, + [2] = { bold = true, foreground = Screen.colors.Blue1 }, + [3] = { bold = true, foreground = Screen.colors.Brown }, + [4] = { foreground = Screen.colors.Cyan4 }, + [5] = { foreground = Screen.colors.Magenta1 }, + } + end) + + it('supports hyperlinks', function() + local url = 'https://example.com' + insert(string.format('[This link text](%s) is a hyperlink.', url)) + exec_lua([[ + vim.bo.filetype = 'markdown' + vim.treesitter.start() + ]]) + + screen:expect { + grid = [[ + {4:[}{6:This link text}{4:](}{7:https://example.com}{4:)} is| + a hyperlink^. | + {2:~ }|*3 + | + ]], + attr_ids = { + [1] = { foreground = Screen.colors.Blue1 }, + [2] = { bold = true, foreground = Screen.colors.Blue1 }, + [3] = { bold = true, foreground = Screen.colors.Brown }, + [4] = { foreground = Screen.colors.Cyan4 }, + [5] = { foreground = Screen.colors.Magenta }, + [6] = { foreground = Screen.colors.Cyan4, url = url }, + [7] = { underline = true, foreground = Screen.colors.SlateBlue }, + }, + } + end) +end) |