summaryrefslogtreecommitdiff
path: root/scratch
diff options
context:
space:
mode:
authorTJ DeVries <devries.timothyj@gmail.com>2020-12-03 12:39:59 -0500
committerTJ DeVries <devries.timothyj@gmail.com>2020-12-03 12:39:59 -0500
commitbe8f5ec8dcff357ef95d75de9e1dfb797e8556f8 (patch)
tree6f018dcef255bc387e6c68d000f70b62aba045ce /scratch
parent2e5ee9d43ed6eeb9d80e105406fa7e187f56931e (diff)
scratch: show conni
Diffstat (limited to 'scratch')
-rw-r--r--scratch/ts_example.lua51
1 files changed, 51 insertions, 0 deletions
diff --git a/scratch/ts_example.lua b/scratch/ts_example.lua
new file mode 100644
index 0000000..5d6469c
--- /dev/null
+++ b/scratch/ts_example.lua
@@ -0,0 +1,51 @@
+local uv = vim.loop
+
+local has_ts, _ = pcall(require, 'nvim-treesitter')
+if not has_ts then
+ error("ASKDLFJAKLSJFLASKDFJ")
+end
+
+local ts_highlight = require('nvim-treesitter.highlight')
+local ts_parsers = require('nvim-treesitter.parsers')
+
+local function readFile(path, callback)
+ uv.fs_open(path, "r", 438, function(err, fd)
+ assert(not err, err)
+ uv.fs_fstat(fd, function(err, stat)
+ assert(not err, err)
+ uv.fs_read(fd, stat.size, 0, function(err, data)
+ assert(not err, err)
+ uv.fs_close(fd, function(err)
+ assert(not err, err)
+ return callback(data)
+ end)
+ end)
+ end)
+ end)
+end
+
+local determine_filetype = function(filepath)
+ -- Obviously TODO
+ return "lua"
+end
+
+local filepath = "lua/telescope/init.lua"
+
+local load_ts_buffer = function(bufnr, filepath)
+ local filetype = determine_filetype(filepath)
+ if not ts_parsers.has_parser(filetype) then
+ error("TODO CONNI")
+ end
+
+ readFile(filepath, vim.schedule_wrap(function(data)
+ if not vim.api.nvim_buf_is_valid(bufnr) then
+ return
+ end
+
+ -- pcall(ts_highlight.detach, bufnr)
+ vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, vim.split(data, "\n"))
+ ts_highlight.attach(bufnr, filetype)
+ end))
+end
+
+load_ts_buffer(3, filepath)