neovim configuration using rocks.nvim plugin manager

feat(utils): api to load local tree-sitter parsers

+25
+2
lua/plugins/rest.lua
··· 1 1 ---@module 'rest-nvim' 2 2 3 + -- require("utils").load_local_parser("http") 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 + ---@param lang string 56 + ---@param filetype string? 57 + function M.load_local_parser(lang, filetype) 58 + filetype = filetype or lang 59 + local parser = string.format("$HOME/.cache/tree-sitter/lib/%s.so", lang) 60 + if vim.fn.has("macunix") == 1 then 61 + parser = string.format("$HOME/Library/Caches/tree-sitter/lib/%s.dylib", lang) 62 + end 63 + vim.treesitter.language.add(lang, { 64 + path = vim.fs.normalize(parser), 65 + filetype = "http", 66 + }) 67 + if not vim.treesitter.language.get_lang(filetype) then 68 + vim.treesitter.language.register(lang, filetype) 69 + end 70 + vim.api.nvim_create_autocmd("FileType", { 71 + pattern = filetype, 72 + callback = function (ev) 73 + vim.treesitter.start(ev.buf, lang) 74 + end 75 + }) 76 + end 77 + 55 78 return M