This repository has been archived by the owner on Oct 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 76
/
nvim_typescript.vim
87 lines (78 loc) · 2.84 KB
/
nvim_typescript.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
let s:local_tss = 0
function! s:check_node() abort "{{{
call health#report_start('Find Node')
if executable('node')
call health#report_ok('node is in $PATH')
else
call health#report_error('node is not in $PATH',
\ 'Typescript requires node')
endif
endfunction "}}}
function! s:check_local_tsserver() abort "{{{
call health#report_start('Find Local Typescript')
let l:localServer = getcwd().'/node_modules/.bin/tsserver'
if executable(l:localServer)
let s:local_tss = 1
call health#report_ok('local tsserver is found')
else
call health#report_warn('No local server found, using global',
\"Install typescript locally for more accurate tooling\n".
\'$ npm install typescript --save-dev')
endif
endfunction "}}}
function! s:check_global_tsserver() abort "{{{
call health#report_start('Find Global Typescript')
if executable('tsserver')
call health#report_ok('global tsserver is found')
elseif s:local_tss
call health#report_ok('No global server found but local server found')
else
call health#report_error('No global server found and no local server',
\"Install typescript globally or locally\n".
\"$ npm install -g typescript\n".
\'$ npm install typescript --save-dev')
endif
endfunction "}}}
function! s:check_config_file() abort "{{{
call health#report_start('Find tsconfg.json or jsconfig.json')
if TSFindConfig()
call health#report_ok('config is found!')
else
call health#report_error('no config file is found', [
\'See docs for info: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html',
\'Is the file named correctly?'
\])
endif
endfunction "}}}
function! s:check_deoplete() abort "{{{
call health#report_start('Check for deoplete')
if exists('g:loaded_deoplete')
call health#report_ok('Deoplete is found!')
else
call health#report_error('Deoplete is not loaded',
\ "Install Deoplete for Async completion\n".
\ 'https://github.com/Shougo/deoplete.nvim')
endif
endfunction "}}}
function! s:check_required_python_for_nvim_typescript() abort "{{{
call health#report_start('Check for python 3 bindings')
if has('python3')
call health#report_ok('has("python3") was successful')
else
call health#report_error('has("python3") was not successful', [
\ 'Please install the python3 package for neovim.',
\ 'A good guide can be found here: ' .
\ 'https://github.com/tweekmonster/nvim-python-doctor/'
\ . 'wiki/Advanced:-Using-pyenv'
\ ]
\ )
endif
endfunction "}}}
function! health#nvim_typescript#check() abort
call s:check_node()
call s:check_local_tsserver()
call s:check_global_tsserver()
call s:check_config_file()
call s:check_deoplete()
call s:check_required_python_for_nvim_typescript()
endfunction