mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-02 11:36:54 -04:00
style: fill in missing code docs wherever applicable
This commit is contained in:
parent
fceb4ed0ec
commit
853b1ab39a
17 changed files with 431 additions and 191 deletions
|
|
@ -3,6 +3,8 @@ local utils = require "nvim-treesitter.utils"
|
|||
|
||||
-- Convert path for cmd.exe on Windows.
|
||||
-- This is needed when vim.opt.shellslash is in use.
|
||||
---@param p string
|
||||
---@return string
|
||||
local function cmdpath(p)
|
||||
if vim.opt.shellslash:get() then
|
||||
local r = p:gsub("/", "\\")
|
||||
|
|
@ -14,6 +16,10 @@ end
|
|||
|
||||
local M = {}
|
||||
|
||||
---@param directory string
|
||||
---@param cwd string
|
||||
---@param info_msg string
|
||||
---@return table
|
||||
function M.select_mkdir_cmd(directory, cwd, info_msg)
|
||||
if fn.has "win32" == 1 then
|
||||
return {
|
||||
|
|
@ -38,6 +44,9 @@ function M.select_mkdir_cmd(directory, cwd, info_msg)
|
|||
end
|
||||
end
|
||||
|
||||
---@param file string
|
||||
---@param info_msg string
|
||||
---@return table
|
||||
function M.select_rm_file_cmd(file, info_msg)
|
||||
if fn.has "win32" == 1 then
|
||||
return {
|
||||
|
|
@ -60,13 +69,17 @@ function M.select_rm_file_cmd(file, info_msg)
|
|||
end
|
||||
end
|
||||
|
||||
---@param executables string[]
|
||||
---@return string|nil
|
||||
function M.select_executable(executables)
|
||||
return vim.tbl_filter(function(c)
|
||||
return vim.tbl_filter(function(c) ---@param c string
|
||||
return c ~= vim.NIL and fn.executable(c) == 1
|
||||
end, executables)[1]
|
||||
end
|
||||
|
||||
---@param repo InstallInfo
|
||||
---@param compiler string
|
||||
---@return string[]
|
||||
function M.select_compiler_args(repo, compiler)
|
||||
if string.match(compiler, "cl$") or string.match(compiler, "cl.exe$") then
|
||||
return {
|
||||
|
|
@ -98,7 +111,7 @@ function M.select_compiler_args(repo, compiler)
|
|||
"-Os",
|
||||
}
|
||||
if
|
||||
#vim.tbl_filter(function(file)
|
||||
#vim.tbl_filter(function(file) ---@param file string
|
||||
local ext = vim.fn.fnamemodify(file, ":e")
|
||||
return ext == "cc" or ext == "cpp" or ext == "cxx"
|
||||
end, repo.files) > 0
|
||||
|
|
@ -186,6 +199,12 @@ function M.select_mv_cmd(from, to, cwd)
|
|||
end
|
||||
end
|
||||
|
||||
---@param repo InstallInfo
|
||||
---@param project_name string
|
||||
---@param cache_folder string
|
||||
---@param revision string|nil
|
||||
---@param prefer_git boolean
|
||||
---@return table
|
||||
function M.select_download_commands(repo, project_name, cache_folder, revision, prefer_git)
|
||||
local can_use_tar = vim.fn.executable "tar" == 1 and vim.fn.executable "curl" == 1
|
||||
local is_github = repo.url:find("github.com", 1, true)
|
||||
|
|
@ -277,6 +296,9 @@ function M.select_download_commands(repo, project_name, cache_folder, revision,
|
|||
end
|
||||
end
|
||||
|
||||
---@param dir string
|
||||
---@param command string
|
||||
---@return string command
|
||||
function M.make_directory_change_for_command(dir, command)
|
||||
if fn.has "win32" == 1 then
|
||||
return string.format("pushd %s & %s & popd", cmdpath(dir), command)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue