1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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)
|