mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-09 13:40:04 +08:00
feat(lang#python): add more lsp key bindings
Problem: Only a few lsp shortcuts are defined for python. Solution: add more lsp key bindings 1. SPC l x: show references 2. SPC l s: show line diagnostics 3. SPC l w l: list workspace folder 4. SPC l w a: add workspace folder 5. SPC l w r: remove workspace folder
This commit is contained in:
parent
447728eb6f
commit
309728bcf2
@ -62,6 +62,19 @@
|
|||||||
" SPC l s s send selection text
|
" SPC l s s send selection text
|
||||||
" <
|
" <
|
||||||
"
|
"
|
||||||
|
" If the lsp layer is enabled for python, the following key bindings can
|
||||||
|
" be used:
|
||||||
|
" >
|
||||||
|
" key binding Description
|
||||||
|
" SPC l e rename symbol
|
||||||
|
" SPC l x show references
|
||||||
|
" SPC l s show line diagnostics
|
||||||
|
" SPC l d show document
|
||||||
|
" K show document
|
||||||
|
" SPC l w l list workspace folder
|
||||||
|
" SPC l w a add workspace folder
|
||||||
|
" SPC l w r remove workspace folder
|
||||||
|
" <
|
||||||
|
|
||||||
|
|
||||||
if exists('s:enabled_linters')
|
if exists('s:enabled_linters')
|
||||||
@ -122,13 +135,13 @@ function! SpaceVim#layers#lang#python#config() abort
|
|||||||
augroup end
|
augroup end
|
||||||
endif
|
endif
|
||||||
" }}}
|
" }}}
|
||||||
let g:deoplete#sources#jedi#enable_typeinfo = s:enable_typeinfo
|
let g:deoplete#sources#jedi#enable_typeinfo = s:enable_typeinfo
|
||||||
call SpaceVim#plugins#runner#reg_runner('python',
|
call SpaceVim#plugins#runner#reg_runner('python',
|
||||||
\ {
|
\ {
|
||||||
\ 'exe' : function('s:getexe'),
|
\ 'exe' : function('s:getexe'),
|
||||||
\ 'opt' : ['-'],
|
\ 'opt' : ['-'],
|
||||||
\ 'usestdin' : 1,
|
\ 'usestdin' : 1,
|
||||||
\ })
|
\ })
|
||||||
call SpaceVim#mapping#gd#add('python', function('s:go_to_def'))
|
call SpaceVim#mapping#gd#add('python', function('s:go_to_def'))
|
||||||
call SpaceVim#mapping#space#regesit_lang_mappings('python', function('s:language_specified_mappings'))
|
call SpaceVim#mapping#space#regesit_lang_mappings('python', function('s:language_specified_mappings'))
|
||||||
call SpaceVim#layers#edit#add_ft_head_tamplate('python', s:python_file_head)
|
call SpaceVim#layers#edit#add_ft_head_tamplate('python', s:python_file_head)
|
||||||
@ -141,8 +154,12 @@ function! SpaceVim#layers#lang#python#config() abort
|
|||||||
elseif executable('python3')
|
elseif executable('python3')
|
||||||
call SpaceVim#plugins#repl#reg('python', ['python3', '-i'])
|
call SpaceVim#plugins#repl#reg('python', ['python3', '-i'])
|
||||||
endif
|
endif
|
||||||
let g:neomake_python_enabled_makers = s:enabled_linters
|
if SpaceVim#layers#lsp#check_server('pyright') || SpaceVim#layers#lsp#check_filetype('python')
|
||||||
let g:neomake_python_python_exe = s:python_interpreter
|
let g:neomake_python_enabled_makers = []
|
||||||
|
else
|
||||||
|
let g:neomake_python_enabled_makers = s:enabled_linters
|
||||||
|
let g:neomake_python_python_exe = s:python_interpreter
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:language_specified_mappings() abort
|
function! s:language_specified_mappings() abort
|
||||||
@ -198,12 +215,24 @@ function! s:language_specified_mappings() abort
|
|||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
if SpaceVim#layers#lsp#check_filetype('python')
|
if SpaceVim#layers#lsp#check_filetype('python')
|
||||||
|
\ || SpaceVim#layers#lsp#check_server('pyright')
|
||||||
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'],
|
||||||
\ 'call SpaceVim#lsp#show_doc()', 'show_document', 1)
|
\ 'call SpaceVim#lsp#show_doc()', 'show-document', 1)
|
||||||
|
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'x'],
|
||||||
|
\ 'call SpaceVim#lsp#references()', 'show-references', 1)
|
||||||
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'e'],
|
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'e'],
|
||||||
\ 'call SpaceVim#lsp#rename()', 'rename symbol', 1)
|
\ 'call SpaceVim#lsp#rename()', 'rename-symbol', 1)
|
||||||
|
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 's'],
|
||||||
|
\ 'call SpaceVim#lsp#show_line_diagnostics()', 'show-line-diagnostics', 1)
|
||||||
|
let g:_spacevim_mappings_space.l.w = {'name' : '+Workspace'}
|
||||||
|
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'w', 'l'],
|
||||||
|
\ 'call SpaceVim#lsp#list_workspace_folder()', 'list-workspace-folder', 1)
|
||||||
|
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'w', 'a'],
|
||||||
|
\ 'call SpaceVim#lsp#add_workspace_folder()', 'add-workspace-folder', 1)
|
||||||
|
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'w', 'r'],
|
||||||
|
\ 'call SpaceVim#lsp#remove_workspace_folder()', 'remove-workspace-folder', 1)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Format on save
|
" Format on save
|
||||||
|
@ -3552,6 +3552,19 @@ This layer also provides REPL support for python, the key bindings are:
|
|||||||
SPC l s s send selection text
|
SPC l s s send selection text
|
||||||
<
|
<
|
||||||
|
|
||||||
|
If the lsp layer is enabled for python, the following key bindings can be
|
||||||
|
used:
|
||||||
|
>
|
||||||
|
key binding Description
|
||||||
|
SPC l e rename symbol
|
||||||
|
SPC l x show references
|
||||||
|
SPC l s show line diagnostics
|
||||||
|
SPC l d show document
|
||||||
|
K show document
|
||||||
|
SPC l w l list workspace folder
|
||||||
|
SPC l w a add workspace folder
|
||||||
|
SPC l w r remove workspace folder
|
||||||
|
<
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
LANG#RACKET *SpaceVim-layers-lang-racket*
|
LANG#RACKET *SpaceVim-layers-lang-racket*
|
||||||
|
Loading…
Reference in New Issue
Block a user