aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorkiyan42 <yazdani.kiyan@protonmail.com>2020-04-21 19:28:23 +0200
committerkiyan42 <yazdani.kiyan@protonmail.com>2020-04-21 19:28:23 +0200
commitb4ca1c4f785ddda8a0dca9dfff9aab5ab8107fe7 (patch)
treecd8ba8fe9110e8622ef5c968e46f97aa3828b669 /lua
parentrefacto/feat: enable csharp install, fix clone (diff)
downloadnvim-treesitter-b4ca1c4f785ddda8a0dca9dfff9aab5ab8107fe7.tar
nvim-treesitter-b4ca1c4f785ddda8a0dca9dfff9aab5ab8107fe7.tar.gz
nvim-treesitter-b4ca1c4f785ddda8a0dca9dfff9aab5ab8107fe7.tar.bz2
nvim-treesitter-b4ca1c4f785ddda8a0dca9dfff9aab5ab8107fe7.tar.lz
nvim-treesitter-b4ca1c4f785ddda8a0dca9dfff9aab5ab8107fe7.tar.xz
nvim-treesitter-b4ca1c4f785ddda8a0dca9dfff9aab5ab8107fe7.tar.zst
nvim-treesitter-b4ca1c4f785ddda8a0dca9dfff9aab5ab8107fe7.zip
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.
Diffstat (limited to 'lua')
-rw-r--r--lua/nvim-treesitter/install.lua29
1 files 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