tangled
alpha
login
or
join now
boltless.me
/
nvim_rocks
0
fork
atom
neovim configuration using rocks.nvim plugin manager
0
fork
atom
overview
issues
pulls
pipelines
feat(utils): api to load local tree-sitter parsers
Seongmin Lee
1 year ago
628c84cd
9e8584bf
+25
2 changed files
expand all
collapse all
unified
split
lua
plugins
rest.lua
utils
init.lua
+2
lua/plugins/rest.lua
···
1
1
---@module 'rest-nvim'
2
2
3
3
+
-- require("utils").load_local_parser("http")
4
4
+
3
5
---@type rest.Opts
4
6
vim.g.rest_nvim = {
5
7
highlight = {
+23
lua/utils/init.lua
···
52
52
})
53
53
end
54
54
55
55
+
---@param lang string
56
56
+
---@param filetype string?
57
57
+
function M.load_local_parser(lang, filetype)
58
58
+
filetype = filetype or lang
59
59
+
local parser = string.format("$HOME/.cache/tree-sitter/lib/%s.so", lang)
60
60
+
if vim.fn.has("macunix") == 1 then
61
61
+
parser = string.format("$HOME/Library/Caches/tree-sitter/lib/%s.dylib", lang)
62
62
+
end
63
63
+
vim.treesitter.language.add(lang, {
64
64
+
path = vim.fs.normalize(parser),
65
65
+
filetype = "http",
66
66
+
})
67
67
+
if not vim.treesitter.language.get_lang(filetype) then
68
68
+
vim.treesitter.language.register(lang, filetype)
69
69
+
end
70
70
+
vim.api.nvim_create_autocmd("FileType", {
71
71
+
pattern = filetype,
72
72
+
callback = function (ev)
73
73
+
vim.treesitter.start(ev.buf, lang)
74
74
+
end
75
75
+
})
76
76
+
end
77
77
+
55
78
return M