Skip to content

Commit

Permalink
fix(plugin): read lines until grammar name is found
Browse files Browse the repository at this point in the history
Closes #7
  • Loading branch information
ObserverOfTime committed Nov 16, 2024
1 parent d777a9e commit 377893a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions plugin/tstest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ vim.treesitter.query.add_directive("set-language-from-grammar!", function(_, _,
end
if is_file(grammar_json) == 1 then
local file = assert(io.open(grammar_json))
local _, name = file:read("l", "l")
metadata["injection.language"] = name:sub(12, #name - 2)
local line
repeat
line = file:read("*l")
until line:find([["name":]], 1, true)
metadata["injection.language"] = line:sub(12, #line - 2)
_cache[test_dir] = metadata["injection.language"]
file:close()
end
Expand Down

0 comments on commit 377893a

Please sign in to comment.