X-Git-Url: https://git.r.bdr.sh/rbdr/tree-sitter-api-notation/blobdiff_plain/7e8e1a0ccb55135ae4fadf134f3cc2a5ef92e71a..f895159f06c9512d66115fb7dd2f517d4c215ba2:/lua/tree-sitter-api-notation.lua?ds=inline diff --git a/lua/tree-sitter-api-notation.lua b/lua/tree-sitter-api-notation.lua index a314a33..95d5bd5 100644 --- a/lua/tree-sitter-api-notation.lua +++ b/lua/tree-sitter-api-notation.lua @@ -2,17 +2,21 @@ local M = {} function M.setup() + local config_file_path = debug.getinfo(1).source:sub(2) + local plugin_dir = vim.fn.fnamemodify(config_file_path, ':h:h') local parser_config = require 'nvim-treesitter.parsers'.get_parser_configs() parser_config.api_notation = { install_info = { - url = 'https://git.sr.ht/~rbdr/tree-sitter-api-notation', -- local path or git repo + url = plugin_dir, files = {'src/parser.c'}, branch = 'main' } } - vim.api.nvim_create_autocmd({'BufNewFile', 'BufRead'}, { - pattern = {'*.api', '*.apinotation'}, - callback = function () vim.opt.filetype = 'api_notation' end + vim.filetype.add({ + extension = { + api = 'api_notation', + apinotation = 'api_notation' + } }) end