diff options
Diffstat (limited to 'scratch/ts_example.lua')
| -rw-r--r-- | scratch/ts_example.lua | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/scratch/ts_example.lua b/scratch/ts_example.lua deleted file mode 100644 index 5d6469c..0000000 --- a/scratch/ts_example.lua +++ /dev/null @@ -1,51 +0,0 @@ -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) |
