feat(refactor): highlight usages module

This commit is contained in:
Steven Sojka 2020-06-25 13:26:31 -05:00 committed by Kiyan Yazdani
parent 180ad9a1a8
commit 058e8d2296
8 changed files with 275 additions and 37 deletions

View file

@ -13,6 +13,12 @@ local function read_query_files(filenames)
return table.concat(contents, '\n')
end
local function get_query_gaurd(query)
return function(lang)
return M.get_query(lang, query) ~= nil
end
end
-- Some treesitter grammars extend others.
-- We can use that to import the queries of the base language
M.base_language_map = {
@ -21,6 +27,9 @@ M.base_language_map = {
tsx = {'typescript', 'javascript'},
}
M.has_locals = get_query_gaurd('locals')
M.has_highlights = get_query_gaurd('highlights')
function M.get_query(lang, query_name)
local query_files = api.nvim_get_runtime_file(string.format('queries/%s/%s.scm', lang, query_name), true)
local query_string = ''