mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-03 12:00:05 +08:00
Update lsp layer
This commit is contained in:
parent
752a3b3ba8
commit
2538c53658
@ -13,7 +13,7 @@ function! SpaceVim#layers#lang#javascript#plugins() abort
|
|||||||
\ ['pangloss/vim-javascript', { 'on_ft': 'javascript' }],
|
\ ['pangloss/vim-javascript', { 'on_ft': 'javascript' }],
|
||||||
\ ]
|
\ ]
|
||||||
|
|
||||||
if !s:use_lsp
|
if !SpaceVim#layers#lsp#check_filetype('javascript')
|
||||||
call add(plugins, ['ternjs/tern_for_vim', {
|
call add(plugins, ['ternjs/tern_for_vim', {
|
||||||
\ 'on_ft': 'javascript', 'build' : 'npm install' }])
|
\ 'on_ft': 'javascript', 'build' : 'npm install' }])
|
||||||
call add(plugins, ['carlitux/deoplete-ternjs', { 'on_ft': [
|
call add(plugins, ['carlitux/deoplete-ternjs', { 'on_ft': [
|
||||||
@ -23,7 +23,6 @@ function! SpaceVim#layers#lang#javascript#plugins() abort
|
|||||||
return plugins
|
return plugins
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
let s:use_lsp = 0
|
|
||||||
let s:auto_fix = 0
|
let s:auto_fix = 0
|
||||||
|
|
||||||
function! SpaceVim#layers#lang#javascript#set_variable(var) abort
|
function! SpaceVim#layers#lang#javascript#set_variable(var) abort
|
||||||
@ -46,7 +45,7 @@ function! SpaceVim#layers#lang#javascript#config() abort
|
|||||||
call SpaceVim#mapping#space#regesit_lang_mappings('javascript',
|
call SpaceVim#mapping#space#regesit_lang_mappings('javascript',
|
||||||
\ funcref('s:on_ft'))
|
\ funcref('s:on_ft'))
|
||||||
|
|
||||||
if s:use_lsp
|
if SpaceVim#layers#lsp#check_filetype('javascript')
|
||||||
call SpaceVim#lsp#reg_server('javascript', ['javascript-typescript-stdio'])
|
call SpaceVim#lsp#reg_server('javascript', ['javascript-typescript-stdio'])
|
||||||
call SpaceVim#mapping#gd#add('javascript',
|
call SpaceVim#mapping#gd#add('javascript',
|
||||||
\ function('SpaceVim#lsp#go_to_def'))
|
\ function('SpaceVim#lsp#go_to_def'))
|
||||||
@ -81,7 +80,7 @@ function! s:on_ft() abort
|
|||||||
inoremap <silent><buffer> <C-j>g <Esc>:ImportJSGoto<CR>a
|
inoremap <silent><buffer> <C-j>g <Esc>:ImportJSGoto<CR>a
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
if s:use_lsp
|
if SpaceVim#layers#lsp#check_filetype('javascript')
|
||||||
nnoremap <silent><buffer> K :call SpaceVim#lsp#show_doc()<CR>
|
nnoremap <silent><buffer> K :call SpaceVim#lsp#show_doc()<CR>
|
||||||
|
|
||||||
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'd'],
|
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'd'],
|
||||||
|
@ -62,3 +62,22 @@ function! SpaceVim#layers#lsp#config() abort
|
|||||||
" }}}
|
" }}}
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
let s:enabled_fts = []
|
||||||
|
|
||||||
|
let s:lsp_servers = {
|
||||||
|
\ 'javascript' : ['javascript-typescript-stdio'],
|
||||||
|
\ }
|
||||||
|
|
||||||
|
function! SpaceVim#layers#lsp#set_variable(var) abort
|
||||||
|
for ft in get(a:var, 'filetypes', [])
|
||||||
|
if executable(s:lsp_servers[ft][0])
|
||||||
|
call add(s:enabled_fts, ft)
|
||||||
|
else
|
||||||
|
call SpaceVim#logger#warn('Failed to enable lsp for ' . ft . ', ' . s:lsp_servers[ft][0] . 'is not executable!')
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! SpaceVim#layers#lsp#check_filetype(ft) abort
|
||||||
|
return index(s:enabled_fts, a:ft) != -1
|
||||||
|
endfunction
|
||||||
|
Loading…
Reference in New Issue
Block a user