feat!: drop modules, general refactor and cleanup

This commit is contained in:
Christian Clason 2023-06-12 09:54:30 -06:00
parent c13e28f894
commit 2c8f2f2fad
829 changed files with 4905 additions and 8010 deletions

View file

@ -1,34 +1,39 @@
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 config = require('nvim-treesitter.config')
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)
local ft = vim.bo[buf].filetype
local lang = vim.treesitter.language.get_lang(ft) or ft
assert.same(
1,
vim.fn.executable "highlight-assertions",
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 .. "'"
"highlight-assertions -p '"
.. config.get_install_dir('parser')
.. '/'
.. lang
.. ".so'"
.. " -s '"
.. file
.. "'"
)
)
local parser = parsers.get_parser(buf, lang)
local parser = ts.get_parser(buf, lang)
local self = highlighter.new(parser, {})
local self = ts.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 "^!"
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
@ -49,11 +54,11 @@ local function check_assertions(file)
if neg_assert then
assert.False(
found,
"Error in at "
'Error in at '
.. file
.. ":"
.. ':'
.. (row + 1)
.. ":"
.. ':'
.. (col + 1)
.. ': expected "'
.. assertion.expected_capture_name
@ -62,11 +67,11 @@ local function check_assertions(file)
else
assert.True(
found,
"Error in at "
'Error in at '
.. file
.. ":"
.. ':'
.. (row + 1)
.. ":"
.. ':'
.. (col + 1)
.. ': expected "'
.. assertion.expected_capture_name
@ -76,8 +81,8 @@ local function check_assertions(file)
end
end
describe("injections", function()
local files = vim.fn.split(vim.fn.glob "tests/query/injections/**/*.*")
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)