Some checks failed
		
		
	
	Detach Plugins / check (FlyGrep.vim) (push) Has been cancelled
				
			Detach Plugins / check (GitHub.vim) (push) Has been cancelled
				
			Detach Plugins / check (JavaUnit.vim) (push) Has been cancelled
				
			Detach Plugins / check (SourceCounter.vim) (push) Has been cancelled
				
			Detach Plugins / check (cpicker.nvim) (push) Has been cancelled
				
			Detach Plugins / check (dein-ui.vim) (push) Has been cancelled
				
			Detach Plugins / check (git.vim) (push) Has been cancelled
				
			Detach Plugins / check (iedit.vim) (push) Has been cancelled
				
			Detach Plugins / check (scrollbar.vim) (push) Has been cancelled
				
			Detach Plugins / check (vim-chat) (push) Has been cancelled
				
			Detach Plugins / check (vim-cheat) (push) Has been cancelled
				
			Detach Plugins / check (vim-todo) (push) Has been cancelled
				
			Detach Plugins / check (xmake.vim) (push) Has been cancelled
				
			test / Linux (nvim, nightly) (push) Has been cancelled
				
			test / Linux (nvim, v0.3.8) (push) Has been cancelled
				
			test / Linux (nvim, v0.4.0) (push) Has been cancelled
				
			test / Linux (nvim, v0.4.2) (push) Has been cancelled
				
			test / Linux (nvim, v0.4.3) (push) Has been cancelled
				
			test / Linux (nvim, v0.4.4) (push) Has been cancelled
				
			test / Linux (nvim, v0.5.0) (push) Has been cancelled
				
			test / Linux (nvim, v0.5.1) (push) Has been cancelled
				
			test / Linux (nvim, v0.6.0) (push) Has been cancelled
				
			test / Linux (nvim, v0.6.1) (push) Has been cancelled
				
			test / Linux (nvim, v0.7.0) (push) Has been cancelled
				
			test / Linux (nvim, v0.7.2) (push) Has been cancelled
				
			test / Linux (nvim, v0.8.0) (push) Has been cancelled
				
			test / Linux (nvim, v0.8.1) (push) Has been cancelled
				
			test / Linux (nvim, v0.8.2) (push) Has been cancelled
				
			test / Linux (nvim, v0.8.3) (push) Has been cancelled
				
			test / Linux (nvim, v0.9.0) (push) Has been cancelled
				
			test / Linux (nvim, v0.9.1) (push) Has been cancelled
				
			test / Linux (true, vim, v7.4.052) (push) Has been cancelled
				
			test / Linux (true, vim, v7.4.1689) (push) Has been cancelled
				
			test / Linux (true, vim, v7.4.629) (push) Has been cancelled
				
			test / Linux (true, vim, v8.0.0027) (push) Has been cancelled
				
			test / Linux (true, vim, v8.0.0183) (push) Has been cancelled
				
			test / Linux (vim, nightly) (push) Has been cancelled
				
			test / Linux (vim, v8.0.0184) (push) Has been cancelled
				
			test / Linux (vim, v8.0.1453) (push) Has been cancelled
				
			test / Linux (vim, v8.1.2269) (push) Has been cancelled
				
			test / Linux (vim, v8.2.2434) (push) Has been cancelled
				
			test / Linux (vim, v8.2.3995) (push) Has been cancelled
				
			test / Windows (nvim, nightly) (push) Has been cancelled
				
			test / Windows (nvim, v0.3.8) (push) Has been cancelled
				
			test / Windows (nvim, v0.4.2) (push) Has been cancelled
				
			test / Windows (nvim, v0.4.3) (push) Has been cancelled
				
			test / Windows (nvim, v0.4.4) (push) Has been cancelled
				
			test / Windows (nvim, v0.5.0) (push) Has been cancelled
				
			test / Windows (nvim, v0.5.1) (push) Has been cancelled
				
			test / Windows (nvim, v0.6.0) (push) Has been cancelled
				
			test / Windows (nvim, v0.6.1) (push) Has been cancelled
				
			test / Windows (nvim, v0.7.0) (push) Has been cancelled
				
			test / Windows (nvim, v0.7.2) (push) Has been cancelled
				
			test / Windows (nvim, v0.8.0) (push) Has been cancelled
				
			test / Windows (nvim, v0.8.1) (push) Has been cancelled
				
			test / Windows (nvim, v0.8.2) (push) Has been cancelled
				
			test / Windows (nvim, v0.8.3) (push) Has been cancelled
				
			test / Windows (nvim, v0.9.0) (push) Has been cancelled
				
			test / Windows (nvim, v0.9.1) (push) Has been cancelled
				
			test / Windows (vim, nightly) (push) Has been cancelled
				
			test / Windows (vim, v7.4.1185) (push) Has been cancelled
				
			test / Windows (vim, v7.4.1689) (push) Has been cancelled
				
			test / Windows (vim, v8.0.0027) (push) Has been cancelled
				
			test / Windows (vim, v8.0.1453) (push) Has been cancelled
				
			test / Windows (vim, v8.1.2269) (push) Has been cancelled
				
			test / Windows (vim, v8.2.2434) (push) Has been cancelled
				
			test / Windows (vim, v8.2.3995) (push) Has been cancelled
				
			docker / docker (push) Has been cancelled
				
			mirror / check (coding) (push) Has been cancelled
				
			mirror / check (gitee) (push) Has been cancelled
				
			mirror / check (gitlab) (push) Has been cancelled
				
			
		
			
				
	
	
		
			87 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			Lua
		
	
	
	
	
	
			
		
		
	
	
			87 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			Lua
		
	
	
	
	
	
require "nvim-treesitter.highlight" -- yes, this is necessary to set the hlmap
 | 
						|
local highlighter = require "vim.treesitter.highlighter"
 | 
						|
local configs = require "nvim-treesitter.configs"
 | 
						|
local parsers = require "nvim-treesitter.parsers"
 | 
						|
local ts = vim.treesitter
 | 
						|
 | 
						|
local function check_assertions(file)
 | 
						|
  local buf = vim.fn.bufadd(file)
 | 
						|
  vim.fn.bufload(file)
 | 
						|
  local lang = parsers.get_buf_lang(buf)
 | 
						|
  assert.same(
 | 
						|
    1,
 | 
						|
    vim.fn.executable "highlight-assertions",
 | 
						|
    '"highlight-assertions" not executable!'
 | 
						|
      .. ' Get it via "cargo install --git https://github.com/theHamsta/highlight-assertions"'
 | 
						|
  )
 | 
						|
  local assertions = vim.fn.json_decode(
 | 
						|
    vim.fn.system(
 | 
						|
      "highlight-assertions -p '" .. configs.get_parser_install_dir() .. "/" .. lang .. ".so'" .. " -s '" .. file .. "'"
 | 
						|
    )
 | 
						|
  )
 | 
						|
  local parser = parsers.get_parser(buf, lang)
 | 
						|
 | 
						|
  local self = highlighter.new(parser, {})
 | 
						|
  local top_level_root = parser:parse()[1]:root()
 | 
						|
 | 
						|
  for _, assertion in ipairs(assertions) do
 | 
						|
    local row = assertion.position.row
 | 
						|
    local col = assertion.position.column
 | 
						|
 | 
						|
    local neg_assert = assertion.expected_capture_name:match "^!"
 | 
						|
    assertion.expected_capture_name = neg_assert and assertion.expected_capture_name:sub(2)
 | 
						|
      or assertion.expected_capture_name
 | 
						|
    local found = false
 | 
						|
    self.tree:for_each_tree(function(tstree, tree)
 | 
						|
      if not tstree then
 | 
						|
        return
 | 
						|
      end
 | 
						|
      local root = tstree:root()
 | 
						|
      --- If there are multiple tree with the smallest range possible
 | 
						|
      --- Check all of them to see if they fit or not
 | 
						|
      if not ts.is_in_node_range(root, row, col) or root == top_level_root then
 | 
						|
        return
 | 
						|
      end
 | 
						|
      if assertion.expected_capture_name == tree:lang() then
 | 
						|
        found = true
 | 
						|
      end
 | 
						|
    end, true)
 | 
						|
    if neg_assert then
 | 
						|
      assert.False(
 | 
						|
        found,
 | 
						|
        "Error in at "
 | 
						|
          .. file
 | 
						|
          .. ":"
 | 
						|
          .. (row + 1)
 | 
						|
          .. ":"
 | 
						|
          .. (col + 1)
 | 
						|
          .. ': expected "'
 | 
						|
          .. assertion.expected_capture_name
 | 
						|
          .. '" not to be injected here!'
 | 
						|
      )
 | 
						|
    else
 | 
						|
      assert.True(
 | 
						|
        found,
 | 
						|
        "Error in at "
 | 
						|
          .. file
 | 
						|
          .. ":"
 | 
						|
          .. (row + 1)
 | 
						|
          .. ":"
 | 
						|
          .. (col + 1)
 | 
						|
          .. ': expected "'
 | 
						|
          .. assertion.expected_capture_name
 | 
						|
          .. '" to be injected here!'
 | 
						|
      )
 | 
						|
    end
 | 
						|
  end
 | 
						|
end
 | 
						|
 | 
						|
describe("injections", function()
 | 
						|
  local files = vim.fn.split(vim.fn.glob "tests/query/injections/**/*.*")
 | 
						|
  for _, file in ipairs(files) do
 | 
						|
    it(file, function()
 | 
						|
      check_assertions(file)
 | 
						|
    end)
 | 
						|
  end
 | 
						|
end)
 |