diff options
| author | Steven Sojka <Steven.Sojka@tdameritrade.com> | 2020-06-25 13:26:31 -0500 |
|---|---|---|
| committer | Kiyan Yazdani <yazdani.kiyan@protonmail.com> | 2020-06-30 08:21:01 +0200 |
| commit | 058e8d2296515041be982c6f23c119ec6b6d1ba9 (patch) | |
| tree | d4d7b1d05b3b1d420d41a468460336d3d3ec3971 /lua/nvim-treesitter/utils.lua | |
| parent | 180ad9a1a8c1212d9839bdbe97c11137b48a7064 (diff) | |
feat(refactor): highlight usages module
Diffstat (limited to 'lua/nvim-treesitter/utils.lua')
| -rw-r--r-- | lua/nvim-treesitter/utils.lua | 17 |
1 files changed, 17 insertions, 0 deletions
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 |
