From 2526baf4cc5ea540188345c856adb162ce102674 Mon Sep 17 00:00:00 2001 From: Thomas Vigouroux Date: Sun, 19 Apr 2020 09:45:54 +0200 Subject: feat: add parsers module and better match iter The `parsers` module manages parsers for us, for now only in a really basic way. iter_prepared_mathes iters on an enhanced versions of the matches, where captures are directly accessible via their names to allow things like : ((itentifier) @def.first (identifier) @def.last) To be handled like this in lua: match.def.first match.def.last Also adds a `set!` predicate to allow setting data within the prepared match (see queries/lua/locals.scm) for examples. --- lua/nvim-treesitter/lib.lua | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 lua/nvim-treesitter/lib.lua (limited to 'lua/nvim-treesitter/lib.lua') diff --git a/lua/nvim-treesitter/lib.lua b/lua/nvim-treesitter/lib.lua deleted file mode 100644 index 328e4a57..00000000 --- a/lua/nvim-treesitter/lib.lua +++ /dev/null @@ -1,19 +0,0 @@ --- Treesitter utils - -local api = vim.api -local ts = vim.treesitter - -local M = {} - -local function read_query_file(fname) - return table.concat(vim.fn.readfile(fname), '\n') -end - -function M.get_query(ft, query_name) - local query_files = api.nvim_get_runtime_file(string.format('queries/%s/%s.scm', ft, query_name), false) - if #query_files > 0 then - return ts.parse_query(ft, read_query_file(query_files[1])) - end -end - -return M -- cgit v1.2.3