aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2022-06-23 11:41:40 +0100
committerStephan Seitz <stephan.seitz@fau.de>2023-01-30 12:49:57 +0100
commitadeb6e02d3bd682f7bea99a988b0deadd407e888 (patch)
tree8c99bb80e6bcb3d8b2c0a581c664e1994cb860c3
parentUpdate parsers: capnp, kdl, markdown, markdown_inline, scala, thrift (diff)
downloadnvim-treesitter-adeb6e02d3bd682f7bea99a988b0deadd407e888.tar
nvim-treesitter-adeb6e02d3bd682f7bea99a988b0deadd407e888.tar.gz
nvim-treesitter-adeb6e02d3bd682f7bea99a988b0deadd407e888.tar.bz2
nvim-treesitter-adeb6e02d3bd682f7bea99a988b0deadd407e888.tar.lz
nvim-treesitter-adeb6e02d3bd682f7bea99a988b0deadd407e888.tar.xz
nvim-treesitter-adeb6e02d3bd682f7bea99a988b0deadd407e888.tar.zst
nvim-treesitter-adeb6e02d3bd682f7bea99a988b0deadd407e888.zip
fix: better support for custom parsers
If the user changes the parser_config by modifing the table returned by get_parser_configs(), then internally mark the config so when we install we 1) don't use the revision pointed to by the lockfile, and 2) always download the parser via git.
-rw-r--r--lua/nvim-treesitter/install.lua12
1 files changed, 10 insertions, 2 deletions
diff --git a/lua/nvim-treesitter/install.lua b/lua/nvim-treesitter/install.lua
index c0128130b..53efff5fd 100644
--- a/lua/nvim-treesitter/install.lua
+++ b/lua/nvim-treesitter/install.lua
@@ -96,6 +96,8 @@ local function is_ignored_parser(lang)
return vim.tbl_contains(configs.get_ignored_parser_installs(), lang)
end
+--- @param lang string
+--- @return string|nil
local function get_revision(lang)
if #lockfile == 0 then
load_lockfile()
@@ -106,7 +108,9 @@ local function get_revision(lang)
return install_info.revision
end
- return (lockfile[lang] and lockfile[lang].revision)
+ if lockfile[lang] then
+ return lockfile[lang].revision
+ end
end
---@param lang string
@@ -358,7 +362,11 @@ local function run_install(cache_folder, install_folder, lang, repo, with_sync,
) .. '" are not executable.')
return
end
- local revision = configs.get_update_strategy() == "lockfile" and get_revision(lang)
+
+ local revision = repo.revision
+ if not revision and configs.get_update_strategy() == "lockfile" then
+ revision = get_revision(lang)
+ end
local command_list = {}
if not from_local_path then