From a97af306c4e9c9a6fa7c886c0ffe3079822c5203 Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Fri, 20 Aug 2021 11:11:24 -0400 Subject: feat(performance): Major performance improvements using async v2 from @oberblastmeister (#987) * start: Working w/ async jobs * short circuit to using bad finder if you pass writer. --- scratch/ts_example.lua | 51 -------------------------------------------------- 1 file changed, 51 deletions(-) delete mode 100644 scratch/ts_example.lua (limited to 'scratch/ts_example.lua') 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) -- cgit v1.2.3