mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-16 10:20:11 -04:00
fix(ci): make highlight test working with markdown
This commit is contained in:
parent
7889b3aea8
commit
dada29a1e5
2 changed files with 31 additions and 30 deletions
|
|
@ -1,41 +1,28 @@
|
||||||
# H1
|
# H1
|
||||||
|
<!-- <- TSPunctSpecial -->
|
||||||
<!--
|
|
||||||
^ TSPunctSpecial
|
|
||||||
-->
|
|
||||||
|
|
||||||
## H2
|
## H2
|
||||||
|
<!-- <- TSPunctSpecial -->
|
||||||
<!--
|
|
||||||
^ TSPunctSpecial
|
|
||||||
-->
|
|
||||||
|
|
||||||
- Item 1
|
- Item 1
|
||||||
- Item 2
|
- Item 2
|
||||||
|
<!-- <- TSPunctSpecial -->
|
||||||
<!--
|
|
||||||
^ TSPunctSpecial
|
|
||||||
-->
|
|
||||||
|
|
||||||
1. Item 1
|
1. Item 1
|
||||||
2. Item 2
|
2. Item 2
|
||||||
|
<!-- <- TSPunctSpecial -->
|
||||||
|
|
||||||
<!--
|
----
|
||||||
^ TSPunctSpecial
|
<!-- ^ TSTextReference -->
|
||||||
-->
|
<!-- ^ TSURI -->
|
||||||
|
<!-- ^ TSLiteral -->
|
||||||

|
<!--^ TSPunctDelimiter -->
|
||||||
|
<!-- ^ TSPunctDelimiter -->
|
||||||
<!--
|
<!-- ^ TSPunctDelimiter -->
|
||||||
^ TSTextReference ^ TSURI ^ TSLiteral
|
|
||||||
^ TSPunctDelimiter ^ TSPunctDelimiter
|
|
||||||
^ TSPunctSpecial
|
|
||||||
-->
|
|
||||||
|
|
||||||
[link_text](#local_reference "link go brr...")
|
[link_text](#local_reference "link go brr...")
|
||||||
|
<!-- ^ TSTextReference -->
|
||||||
<!--
|
<!-- ^ TSURI -->
|
||||||
^ TSURI
|
<!-- ^ TSLiteral -->
|
||||||
^ TSTextReference ^ TSLiteral
|
<!-- <- TSPunctDelimiter -->
|
||||||
^ TSPunctDelimiter ^ TSPunctDelimiter
|
<!-- ^ TSPunctDelimiter -->
|
||||||
-->
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,10 @@ local utils = require "nvim-treesitter.utils"
|
||||||
local ts_utils = require "nvim-treesitter.ts_utils"
|
local ts_utils = require "nvim-treesitter.ts_utils"
|
||||||
local parsers = require "nvim-treesitter.parsers"
|
local parsers = require "nvim-treesitter.parsers"
|
||||||
|
|
||||||
|
local COMMENT_NODES = {
|
||||||
|
markdown = "html_block",
|
||||||
|
}
|
||||||
|
|
||||||
local function check_assertions(file)
|
local function check_assertions(file)
|
||||||
local buf = vim.fn.bufadd(file)
|
local buf = vim.fn.bufadd(file)
|
||||||
vim.fn.bufload(file)
|
vim.fn.bufload(file)
|
||||||
|
|
@ -14,15 +18,25 @@ local function check_assertions(file)
|
||||||
'"highlight-assertions" not executable!'
|
'"highlight-assertions" not executable!'
|
||||||
.. ' Get it via "cargo install --git https://github.com/theHamsta/highlight-assertions"'
|
.. ' Get it via "cargo install --git https://github.com/theHamsta/highlight-assertions"'
|
||||||
)
|
)
|
||||||
|
local comment_node = COMMENT_NODES[lang] or "comment"
|
||||||
local assertions = vim.fn.json_decode(
|
local assertions = vim.fn.json_decode(
|
||||||
vim.fn.system(
|
vim.fn.system(
|
||||||
"highlight-assertions -p '" .. utils.get_parser_install_dir() .. "/" .. lang .. ".so'" .. " -s '" .. file .. "'"
|
"highlight-assertions -p '"
|
||||||
|
.. utils.get_parser_install_dir()
|
||||||
|
.. "/"
|
||||||
|
.. lang
|
||||||
|
.. ".so'"
|
||||||
|
.. " -s '"
|
||||||
|
.. file
|
||||||
|
.. "' -c "
|
||||||
|
.. comment_node
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
local parser = parsers.get_parser(buf, lang)
|
local parser = parsers.get_parser(buf, lang)
|
||||||
|
|
||||||
local self = highlighter.new(parser, {})
|
local self = highlighter.new(parser, {})
|
||||||
|
|
||||||
|
assert.True(#assertions > 0, "No assertions detected!")
|
||||||
for _, assertion in ipairs(assertions) do
|
for _, assertion in ipairs(assertions) do
|
||||||
local row = assertion.position.row
|
local row = assertion.position.row
|
||||||
local col = assertion.position.column
|
local col = assertion.position.column
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue