summaryrefslogtreecommitdiff
path: root/lua/nvim-treesitter/install.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/nvim-treesitter/install.lua')
-rw-r--r--lua/nvim-treesitter/install.lua28
1 files changed, 14 insertions, 14 deletions
diff --git a/lua/nvim-treesitter/install.lua b/lua/nvim-treesitter/install.lua
index c2eeaf76..2d33dafd 100644
--- a/lua/nvim-treesitter/install.lua
+++ b/lua/nvim-treesitter/install.lua
@@ -7,8 +7,8 @@ local parsers = require'nvim-treesitter.parsers'
local M = {}
-local function iter_cmd(cmd_list, i, ft)
- if i == #cmd_list + 1 then return print('Treesitter parser for '..ft..' has been installed') end
+local function iter_cmd(cmd_list, i, lang)
+ if i == #cmd_list + 1 then return print('Treesitter parser for '..lang..' has been installed') end
local attr = cmd_list[i]
if attr.info then print(attr.info) end
@@ -18,16 +18,16 @@ local function iter_cmd(cmd_list, i, ft)
handle = luv.spawn(attr.cmd, attr.opts, vim.schedule_wrap(function(code)
handle:close()
if code ~= 0 then return api.nvim_err_writeln(attr.err) end
- iter_cmd(cmd_list, i + 1, ft)
+ iter_cmd(cmd_list, i + 1, lang)
end))
end
-local function run_install(cache_folder, package_path, ft, repo)
- local project_name = 'tree-sitter-'..ft
+local function run_install(cache_folder, package_path, lang, repo)
+ local project_name = 'tree-sitter-'..lang
local project_repo = cache_folder..'/'..project_name
-- compile_location only needed for typescript installs.
local compile_location = cache_folder..'/'..(repo.location or project_name)
- local parser_lib_name = package_path.."/parser/"..ft..".so"
+ local parser_lib_name = package_path.."/parser/"..lang..".so"
local command_list = {
{
cmd = 'rm',
@@ -76,7 +76,7 @@ local function run_install(cache_folder, package_path, ft, repo)
}
}
- iter_cmd(command_list, 1, ft)
+ iter_cmd(command_list, 1, lang)
end
-- TODO(kyazdani): this should work on windows too
@@ -95,16 +95,16 @@ local function install(...)
local cache_folder, err = utils.get_cache_dir()
if err then return api.nvim_err_writeln(err) end
- for _, ft in ipairs({ ... }) do
- if #api.nvim_get_runtime_file('parser/'..ft..'.so', false) > 0 then
- local yesno = fn.input(ft .. ' parser already available: would you like to reinstall ? y/n: ')
+ for _, lang in ipairs({ ... }) do
+ if #api.nvim_get_runtime_file('parser/'..lang..'.so', false) > 0 then
+ local yesno = fn.input(lang .. ' parser already available: would you like to reinstall ? y/n: ')
print('\n ') -- mandatory to avoid messing up command line
if not string.match(yesno, '^y.*') then return end
end
- local parser_config = parsers.get_parser_configs()[ft]
+ local parser_config = parsers.get_parser_configs()[lang]
if not parser_config then
- return api.nvim_err_writeln('Parser not available for language '..ft)
+ return api.nvim_err_writeln('Parser not available for language '..lang)
end
local install_info = parser_config.install_info
@@ -113,7 +113,7 @@ local function install(...)
files={ install_info.files, 'table' }
}
- run_install(cache_folder, package_path, ft, install_info)
+ run_install(cache_folder, package_path, lang, install_info)
end
end
@@ -142,7 +142,7 @@ M.commands = {
"-nargs=+",
"-complete=custom,v:lua.ts_installable_parsers"
},
- description = '`:TSInstall {ft}` installs a parser under nvim-treesitter/parser/{name}.so'
+ description = '`:TSInstall {lang}` installs a parser under nvim-treesitter/parser/{lang}.so'
}
}