6
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Vim に typescript の環境を作る by dein

Posted at

ドキュメントの通りだとうまく動かないのでメモ

はまったところ

  • tsconfig.json 必須
  • REAME.md にある \ 'cmd': {server_info->[&shell, &shellcmdflag, 'typescript-language-server', '--stdio']} だと --stdio が渡らない
  • asyncomplete-lsp が asyncomplete とプラグインのファイル名が同じなので asyncomplete のファイルを上書きしてしまう.

LSP サーバのインストール

npm install -g typescript typescript-language-server

dein の設定

[[plugins]]
repo = 'leafgarland/typescript-vim'

[[plugins]]
repo = 'prabirshrestha/async.vim'

[[plugins]]
repo = 'prabirshrestha/vim-lsp'
hook_add = '''
if executable('typescript-language-server')
  au User lsp_setup call lsp#register_server({
      \ 'name': 'typescript-language-server',
      \ 'cmd': {server_info->[&shell, &shellcmdflag, 'typescript-language-server --stdio']},
      \ 'root_uri':{server_info->lsp#utils#path_to_uri(lsp#utils#find_nearest_parent_file_directory(lsp#utils#get_buffer_path(), 'tsconfig.json'))},
      \ 'whitelist': ['typescript'],
      \ })
endif
let g:lsp_log_verbose = 1
let g:lsp_log_file = expand('~/vim-lsp.log')
'''

[[plugins]]
repo = 'prabirshrestha/asyncomplete.vim'
hook_add = '''
let g:asyncomplete_log_file = expand('~/asyncomplete.log')
let g:asyncomplete_auto_popup = 1
imap <c-space> <Plug>(asyncomplete_force_refresh)
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<cr>"
'''

[[plugins]]
repo = 'prabirshrestha/asyncomplete-lsp.vim'
merged = 0
6
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?