summaryrefslogtreecommitdiff
path: root/scratch
diff options
context:
space:
mode:
authorTJ DeVries <devries.timothyj@gmail.com>2021-04-06 19:59:42 -0400
committerGitHub <noreply@github.com>2021-04-06 19:59:42 -0400
commit0b2c801978e9cfc9b6351fc9f037ff2ba93805bd (patch)
tree1a5deff0a60cedcbae81a3883f0a0269c3b90c35 /scratch
parentd0cf646f65746415294f570ec643ffd0101ca3ab (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')
-rw-r--r--scratch/buffer_highlights.lua24
-rw-r--r--scratch/short_buf.lua4
2 files changed, 28 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
diff --git a/scratch/short_buf.lua b/scratch/short_buf.lua
new file mode 100644
index 0000000..387b2b5
--- /dev/null
+++ b/scratch/short_buf.lua
@@ -0,0 +1,4 @@
+local x = {}
+print(x); print("wow");
+
+local function other() end