diff options
| author | TJ DeVries <devries.timothyj@gmail.com> | 2021-04-06 19:59:42 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-06 19:59:42 -0400 |
| commit | 0b2c801978e9cfc9b6351fc9f037ff2ba93805bd (patch) | |
| tree | 1a5deff0a60cedcbae81a3883f0a0269c3b90c35 /scratch/buffer_highlights.lua | |
| parent | d0cf646f65746415294f570ec643ffd0101ca3ab (diff) | |
feat: buf highlights for current buffer fuzzy find (#732)
* feat: Add buffer highlights from treesitter
* fix: Handle not having tree sitter in some buffers
* fixup
* fixup
* fixup: move back to old node
Diffstat (limited to 'scratch/buffer_highlights.lua')
| -rw-r--r-- | scratch/buffer_highlights.lua | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/scratch/buffer_highlights.lua b/scratch/buffer_highlights.lua new file mode 100644 index 0000000..ee9edae --- /dev/null +++ b/scratch/buffer_highlights.lua @@ -0,0 +1,24 @@ +local a = vim.api + +local ns = a.nvim_create_namespace("treesitter/highlighter") +print(ns) +local bufnr = 0 + +-- P(a.nvim_buf_get_extmarks(bufnr, ns, 0, -1, { details = true })) + +local parser = vim.treesitter.get_parser(bufnr, "lua") +local query = vim.treesitter.get_query("lua", "highlights") +P(query) + +local root = parser:parse()[1]:root() +print("root", root) + +local highlighter = vim.treesitter.highlighter.new(parser) +local highlighter_query = highlighter:get_query("lua") + +for id, node, metadata in query:iter_captures(root, bufnr, 0, -1) do + local row1, col1, row2, col2 = node:range() + print(highlighter_query.hl_cache[id]) + -- print(id, node, metadata, vim.treesitter.get_node_text(node, bufnr)) + -- print(">>>>", row1, col1, row2, col2) +end |
