aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/treesitter/language.lua
diff options
context:
space:
mode:
authorThomas Vigouroux <thomas.vigouroux@protonmail.com>2022-07-25 12:23:04 +0200
committerThomas Vigouroux <thomas.vigouroux@protonmail.com>2022-08-22 15:34:10 +0200
commit3c1d70f20b5d5bad3bec121e589187d15f325a9b (patch)
tree3c15e309b30fa5f243d7d7e5e952ce58e6eaf126 /runtime/lua/vim/treesitter/language.lua
parent15a768eeb02e2af39eead1ea1eb4a5a60710d6fb (diff)
downloadrneovim-3c1d70f20b5d5bad3bec121e589187d15f325a9b.tar.gz
rneovim-3c1d70f20b5d5bad3bec121e589187d15f325a9b.tar.bz2
rneovim-3c1d70f20b5d5bad3bec121e589187d15f325a9b.zip
feat(treesitter): allow customizing language symbol name
Diffstat (limited to 'runtime/lua/vim/treesitter/language.lua')
-rw-r--r--runtime/lua/vim/treesitter/language.lua14
1 files changed, 7 insertions, 7 deletions
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