diff options
author | Thomas Vigouroux <thomas.vigouroux@protonmail.com> | 2022-07-25 12:23:04 +0200 |
---|---|---|
committer | Thomas Vigouroux <thomas.vigouroux@protonmail.com> | 2022-08-22 15:34:10 +0200 |
commit | 3c1d70f20b5d5bad3bec121e589187d15f325a9b (patch) | |
tree | 3c15e309b30fa5f243d7d7e5e952ce58e6eaf126 /runtime | |
parent | 15a768eeb02e2af39eead1ea1eb4a5a60710d6fb (diff) | |
download | rneovim-3c1d70f20b5d5bad3bec121e589187d15f325a9b.tar.gz rneovim-3c1d70f20b5d5bad3bec121e589187d15f325a9b.tar.bz2 rneovim-3c1d70f20b5d5bad3bec121e589187d15f325a9b.zip |
feat(treesitter): allow customizing language symbol name
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/doc/treesitter.txt | 12 | ||||
-rw-r--r-- | runtime/lua/vim/treesitter/language.lua | 14 |
2 files changed, 15 insertions, 11 deletions
diff --git a/runtime/doc/treesitter.txt b/runtime/doc/treesitter.txt index 52531a1525..06409f9980 100644 --- a/runtime/doc/treesitter.txt +++ b/runtime/doc/treesitter.txt @@ -387,16 +387,20 @@ inspect_language({lang}) *inspect_language()* Parameters: ~ {lang} The language. -require_language({lang}, {path}, {silent}) *require_language()* + *require_language()* +require_language({lang}, {path}, {silent}, {symbol_name}) Asserts that the provided language is installed, and optionally provide a path for the parser Parsers are searched in the `parser` runtime directory. Parameters: ~ - {lang} The language the parser should parse - {path} Optional path the parser is located at - {silent} Don't throw an error if language not found + {lang} (string) The language the parser should parse + {path} (string|nil) Optional path the parser is located at + {silent} (boolean|nil) Don't throw an error if language not + found + {symbol_name} (string|nil) Internal symbol name for the language to + load ============================================================================== diff --git a/runtime/lua/vim/treesitter/language.lua b/runtime/lua/vim/treesitter/language.lua index dfb6f5be84..d14b825603 100644 --- a/runtime/lua/vim/treesitter/language.lua +++ b/runtime/lua/vim/treesitter/language.lua @@ -6,10 +6,11 @@ local M = {} --- --- Parsers are searched in the `parser` runtime directory. --- ----@param lang The language the parser should parse ----@param path Optional path the parser is located at ----@param silent Don't throw an error if language not found -function M.require_language(lang, path, silent) +---@param lang string The language the parser should parse +---@param path string|nil Optional path the parser is located at +---@param silent boolean|nil Don't throw an error if language not found +---@param symbol_name string|nil Internal symbol name for the language to load +function M.require_language(lang, path, silent, symbol_name) if vim._ts_has_language(lang) then return true end @@ -21,7 +22,6 @@ function M.require_language(lang, path, silent) return false end - -- TODO(bfredl): help tag? error("no parser for '" .. lang .. "' language, see :help treesitter-parsers") end path = paths[1] @@ -29,10 +29,10 @@ function M.require_language(lang, path, silent) if silent then return pcall(function() - vim._ts_add_language(path, lang) + vim._ts_add_language(path, lang, symbol_name) end) else - vim._ts_add_language(path, lang) + vim._ts_add_language(path, lang, symbol_name) end return true |