From a7810728d2727120fe73df49618a8c72949371e8 Mon Sep 17 00:00:00 2001 From: kiyan42 Date: Tue, 21 Apr 2020 19:10:01 +0200 Subject: refacto/feat: enable csharp install, fix clone - clone only master at depth 1 to avoid long download from huge repos. - use ft to specify folder name to clone so csharp can be cloned and used properly. --- lua/nvim-treesitter/install.lua | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lua/nvim-treesitter/install.lua b/lua/nvim-treesitter/install.lua index 62405bae1..1d4785522 100644 --- a/lua/nvim-treesitter/install.lua +++ b/lua/nvim-treesitter/install.lua @@ -72,11 +72,11 @@ M.repositories = { url = "https://github.com/tree-sitter/tree-sitter-swift", files = { "src/parser.c" }, }, - -- TODO: find a way to install c-sharp and typescript properly - -- csharp = { - -- url = "https://github.com/tree-sitter/tree-sitter-c-sharp", - -- files = { "src/parser.c", "src/scanner.c" }, - -- }, + csharp = { + url = "https://github.com/tree-sitter/tree-sitter-c-sharp", + files = { "src/parser.c", "src/scanner.c" }, + }, + -- TODO: find a way to install typescript properly } local function get_package_path() @@ -120,7 +120,8 @@ local function iter_cmd(cmd_list, i, ft) end local function run_install(cache_folder, package_path, ft, repo) - local project_repo = cache_folder..'/tree-sitter-'..ft + local project_name = 'tree-sitter-'..ft + local project_repo = cache_folder..'/'..project_name local parser_lib_name = package_path.."/parser/"..ft..".so" local command_list = { { @@ -134,7 +135,7 @@ local function run_install(cache_folder, package_path, ft, repo) info = 'Downloading...', err = 'Error during download, please verify your internet connection', opts = { - args = { 'clone', repo.url }, + args = { 'clone', '--single-branch', '--branch', 'master', '--depth', '1', repo.url, project_name }, cwd = cache_folder, }, }, -- cgit v1.2.3-70-g09d2 From b4ca1c4f785ddda8a0dca9dfff9aab5ab8107fe7 Mon Sep 17 00:00:00 2001 From: kiyan42 Date: Tue, 21 Apr 2020 19:28:23 +0200 Subject: feat: add typescript install - add repo.location for typescript and compile at that location - typescript and tsx must be installed separately as two different parsers. --- lua/nvim-treesitter/install.lua | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/lua/nvim-treesitter/install.lua b/lua/nvim-treesitter/install.lua index 1d4785522..b8d72dfbc 100644 --- a/lua/nvim-treesitter/install.lua +++ b/lua/nvim-treesitter/install.lua @@ -76,7 +76,16 @@ M.repositories = { url = "https://github.com/tree-sitter/tree-sitter-c-sharp", files = { "src/parser.c", "src/scanner.c" }, }, - -- TODO: find a way to install typescript properly + typescript = { + url = "https://github.com/tree-sitter/tree-sitter-typescript", + files = { "src/parser.c", "src/scanner.c" }, + location = "tree-sitter-typescript/typescript" + }, + tsx = { + url = "https://github.com/tree-sitter/tree-sitter-typescript", + files = { "src/parser.c", "src/scanner.c" }, + location = "tree-sitter-tsx/tsx" + } } local function get_package_path() @@ -122,6 +131,8 @@ end local function run_install(cache_folder, package_path, ft, repo) local project_name = 'tree-sitter-'..ft 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 command_list = { { @@ -145,13 +156,13 @@ local function run_install(cache_folder, package_path, ft, repo) err = 'Error during compilation', opts = { args = { '-o', 'parser.so', '-shared', '-lstdc++', unpack(repo.files), '-Os', '-I./src' }, - cwd = project_repo + cwd = compile_location } }, { cmd = 'mv', opts = { - args = { project_repo..'/parser.so', parser_lib_name } + args = { compile_location..'/parser.so', parser_lib_name } } }, { @@ -207,17 +218,19 @@ function M.checkhealth() if fn.executable('git') == 0 then health_error('`git` executable not found.', { - 'Install it with your package manager.', - 'Check that your `$PATH` is set correctly.'}) + 'Install it with your package manager.', + 'Check that your `$PATH` is set correctly.' + }) else health_ok('`git` executable found.') end if fn.executable('cc') == 0 then health_error('`cc` executable not found.', { - 'Install `gcc` with your package manager.', - 'Install `clang` with your package manager.', - 'Check that your `$PATH` is set correctly.'}) + 'Install `gcc` with your package manager.', + 'Install `clang` with your package manager.', + 'Check that your `$PATH` is set correctly.' + }) else health_ok('`cc` executable found.') end -- cgit v1.2.3-70-g09d2