From 058e8d2296515041be982c6f23c119ec6b6d1ba9 Mon Sep 17 00:00:00 2001 From: Steven Sojka Date: Thu, 25 Jun 2020 13:26:31 -0500 Subject: feat(refactor): highlight usages module --- lua/nvim-treesitter/utils.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'lua/nvim-treesitter/utils.lua') diff --git a/lua/nvim-treesitter/utils.lua b/lua/nvim-treesitter/utils.lua index 6fa15981..41833f8c 100644 --- a/lua/nvim-treesitter/utils.lua +++ b/lua/nvim-treesitter/utils.lua @@ -45,4 +45,21 @@ function M.get_cache_dir() return nil, 'Invalid cache rights, $XDG_CACHE_HOME or /tmp should be read/write' end +--- Gets a property at path +-- @param tbl the table to access +-- @param path the '.' seperated path +-- @returns the value at path or nil +function M.get_at_path(tbl, path) + local segments = vim.split(path, '.', true) + local result = tbl + + for _, segment in ipairs(segments) do + if type(result) == 'table' then + result = result[segment] + end + end + + return result +end + return M -- cgit v1.2.3