feat(refactor): add smart rename module

This commit is contained in:
Steven Sojka 2020-06-26 11:11:21 -05:00 committed by Kiyan Yazdani
parent 058e8d2296
commit 64838e51c0
5 changed files with 115 additions and 24 deletions

View file

@ -13,7 +13,9 @@ local function read_query_files(filenames)
return table.concat(contents, '\n')
end
local function get_query_gaurd(query)
-- Creates a function that checks whether a certain query exists
-- for a specific language.
local function get_query_guard(query)
return function(lang)
return M.get_query(lang, query) ~= nil
end
@ -27,8 +29,8 @@ M.base_language_map = {
tsx = {'typescript', 'javascript'},
}
M.has_locals = get_query_gaurd('locals')
M.has_highlights = get_query_gaurd('highlights')
M.has_locals = get_query_guard('locals')
M.has_highlights = get_query_guard('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)