mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-23 20:10:05 +08:00
Fix language specified mapping api
This commit is contained in:
parent
6faeaa4462
commit
2fa63b900e
@ -67,6 +67,7 @@ function! SpaceVim#autocmds#init() abort
|
||||
au FileType gitcommit au! BufEnter COMMIT_EDITMSG call setpos('.', [0, 1, 1, 0])
|
||||
au StdinReadPost * call s:disable_welcome()
|
||||
autocmd InsertEnter * call s:fixindentline()
|
||||
autocmd BufEnter,FileType * call SpaceVim#mapping#space#refrashLSPC()
|
||||
if executable('synclient') && g:spacevim_auto_disable_touchpad
|
||||
let s:touchpadoff = 0
|
||||
autocmd InsertEnter * call s:disable_touchpad()
|
||||
|
@ -59,60 +59,7 @@ function! SpaceVim#layers#lang#java#plugins() abort
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#lang#java#config() abort
|
||||
function! s:java_mappings() abort
|
||||
let g:_spacevim_mappings_space.l = {'name' : '+Language Specified'}
|
||||
if g:spacevim_enable_insert_leader
|
||||
inoremap <silent> <buffer> <leader>UU <esc>bgUwea
|
||||
inoremap <silent> <buffer> <leader>uu <esc>bguwea
|
||||
inoremap <silent> <buffer> <leader>ua <esc>bgulea
|
||||
inoremap <silent> <buffer> <leader>Ua <esc>bgUlea
|
||||
endif
|
||||
nmap <silent><buffer> <F4> <Plug>(JavaComplete-Imports-Add)
|
||||
imap <silent><buffer> <F4> <Plug>(JavaComplete-Imports-Add)
|
||||
nmap <silent><buffer> <leader>jI <Plug>(JavaComplete-Imports-AddMissing)
|
||||
nmap <silent><buffer> <leader>jR <Plug>(JavaComplete-Imports-RemoveUnused)
|
||||
nmap <silent><buffer> <leader>ji <Plug>(JavaComplete-Imports-AddSmart)
|
||||
nmap <silent><buffer> <leader>jii <Plug>(JavaComplete-Imports-Add)
|
||||
|
||||
imap <silent><buffer> <C-j>I <Plug>(JavaComplete-Imports-AddMissing)
|
||||
imap <silent><buffer> <C-j>R <Plug>(JavaComplete-Imports-RemoveUnused)
|
||||
imap <silent><buffer> <C-j>i <Plug>(JavaComplete-Imports-AddSmart)
|
||||
imap <silent><buffer> <C-j>ii <Plug>(JavaComplete-Imports-Add)
|
||||
|
||||
nmap <silent><buffer> <leader>jM <Plug>(JavaComplete-Generate-AbstractMethods)
|
||||
|
||||
imap <silent><buffer> <C-j>jM <Plug>(JavaComplete-Generate-AbstractMethods)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','M'], '<Plug>(JavaComplete-Generate-AbstractMethods)', 'Generate abstract methods', 0)
|
||||
|
||||
nmap <silent><buffer> <leader>jA <Plug>(JavaComplete-Generate-Accessors)
|
||||
nmap <silent><buffer> <leader>js <Plug>(JavaComplete-Generate-AccessorSetter)
|
||||
nmap <silent><buffer> <leader>jg <Plug>(JavaComplete-Generate-AccessorGetter)
|
||||
nmap <silent><buffer> <leader>ja <Plug>(JavaComplete-Generate-AccessorSetterGetter)
|
||||
nmap <silent><buffer> <leader>jts <Plug>(JavaComplete-Generate-ToString)
|
||||
nmap <silent><buffer> <leader>jeq <Plug>(JavaComplete-Generate-EqualsAndHashCode)
|
||||
nmap <silent><buffer> <leader>jc <Plug>(JavaComplete-Generate-Constructor)
|
||||
nmap <silent><buffer> <leader>jcc <Plug>(JavaComplete-Generate-DefaultConstructor)
|
||||
|
||||
imap <silent><buffer> <C-j>s <Plug>(JavaComplete-Generate-AccessorSetter)
|
||||
imap <silent><buffer> <C-j>g <Plug>(JavaComplete-Generate-AccessorGetter)
|
||||
imap <silent><buffer> <C-j>a <Plug>(JavaComplete-Generate-AccessorSetterGetter)
|
||||
|
||||
vmap <silent><buffer> <leader>js <Plug>(JavaComplete-Generate-AccessorSetter)
|
||||
vmap <silent><buffer> <leader>jg <Plug>(JavaComplete-Generate-AccessorGetter)
|
||||
vmap <silent><buffer> <leader>ja <Plug>(JavaComplete-Generate-AccessorSetterGetter)
|
||||
let g:neoformat_enabled_java = ['googlefmt']
|
||||
let g:neoformat_java_googlefmt = {
|
||||
\ 'exe': 'java',
|
||||
\ 'args': ['-jar', get(g:,'spacevim_layer_lang_java_formatter', '')],
|
||||
\ 'replace': 0,
|
||||
\ 'stdin': 0,
|
||||
\ 'no_append': 0,
|
||||
\ }
|
||||
try
|
||||
let g:neoformat_enabled_java += neoformat#formatters#java#enabled()
|
||||
catch
|
||||
endtry
|
||||
endfunction
|
||||
call SpaceVim#mapping#space#regesit_lang_mappings('java', funcref('s:language_specified_mappings'))
|
||||
augroup SpaceVim_lang_java
|
||||
au!
|
||||
autocmd FileType java setlocal omnifunc=javacomplete#Complete
|
||||
@ -122,4 +69,61 @@ function! SpaceVim#layers#lang#java#config() abort
|
||||
augroup END
|
||||
endfunction
|
||||
|
||||
function! s:language_specified_mappings() abort
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','M'], '<Plug>(JavaComplete-Generate-AbstractMethods)', 'Generate abstract methods', 0)
|
||||
endfunction
|
||||
|
||||
function! s:java_mappings() abort
|
||||
let g:_spacevim_mappings_space.l = {'name' : '+Language Specified'}
|
||||
if g:spacevim_enable_insert_leader
|
||||
inoremap <silent> <buffer> <leader>UU <esc>bgUwea
|
||||
inoremap <silent> <buffer> <leader>uu <esc>bguwea
|
||||
inoremap <silent> <buffer> <leader>ua <esc>bgulea
|
||||
inoremap <silent> <buffer> <leader>Ua <esc>bgUlea
|
||||
endif
|
||||
nmap <silent><buffer> <F4> <Plug>(JavaComplete-Imports-Add)
|
||||
imap <silent><buffer> <F4> <Plug>(JavaComplete-Imports-Add)
|
||||
nmap <silent><buffer> <leader>jI <Plug>(JavaComplete-Imports-AddMissing)
|
||||
nmap <silent><buffer> <leader>jR <Plug>(JavaComplete-Imports-RemoveUnused)
|
||||
nmap <silent><buffer> <leader>ji <Plug>(JavaComplete-Imports-AddSmart)
|
||||
nmap <silent><buffer> <leader>jii <Plug>(JavaComplete-Imports-Add)
|
||||
|
||||
imap <silent><buffer> <C-j>I <Plug>(JavaComplete-Imports-AddMissing)
|
||||
imap <silent><buffer> <C-j>R <Plug>(JavaComplete-Imports-RemoveUnused)
|
||||
imap <silent><buffer> <C-j>i <Plug>(JavaComplete-Imports-AddSmart)
|
||||
imap <silent><buffer> <C-j>ii <Plug>(JavaComplete-Imports-Add)
|
||||
|
||||
nmap <silent><buffer> <leader>jM <Plug>(JavaComplete-Generate-AbstractMethods)
|
||||
|
||||
imap <silent><buffer> <C-j>jM <Plug>(JavaComplete-Generate-AbstractMethods)
|
||||
|
||||
nmap <silent><buffer> <leader>jA <Plug>(JavaComplete-Generate-Accessors)
|
||||
nmap <silent><buffer> <leader>js <Plug>(JavaComplete-Generate-AccessorSetter)
|
||||
nmap <silent><buffer> <leader>jg <Plug>(JavaComplete-Generate-AccessorGetter)
|
||||
nmap <silent><buffer> <leader>ja <Plug>(JavaComplete-Generate-AccessorSetterGetter)
|
||||
nmap <silent><buffer> <leader>jts <Plug>(JavaComplete-Generate-ToString)
|
||||
nmap <silent><buffer> <leader>jeq <Plug>(JavaComplete-Generate-EqualsAndHashCode)
|
||||
nmap <silent><buffer> <leader>jc <Plug>(JavaComplete-Generate-Constructor)
|
||||
nmap <silent><buffer> <leader>jcc <Plug>(JavaComplete-Generate-DefaultConstructor)
|
||||
|
||||
imap <silent><buffer> <C-j>s <Plug>(JavaComplete-Generate-AccessorSetter)
|
||||
imap <silent><buffer> <C-j>g <Plug>(JavaComplete-Generate-AccessorGetter)
|
||||
imap <silent><buffer> <C-j>a <Plug>(JavaComplete-Generate-AccessorSetterGetter)
|
||||
|
||||
vmap <silent><buffer> <leader>js <Plug>(JavaComplete-Generate-AccessorSetter)
|
||||
vmap <silent><buffer> <leader>jg <Plug>(JavaComplete-Generate-AccessorGetter)
|
||||
vmap <silent><buffer> <leader>ja <Plug>(JavaComplete-Generate-AccessorSetterGetter)
|
||||
let g:neoformat_enabled_java = ['googlefmt']
|
||||
let g:neoformat_java_googlefmt = {
|
||||
\ 'exe': 'java',
|
||||
\ 'args': ['-jar', get(g:,'spacevim_layer_lang_java_formatter', '')],
|
||||
\ 'replace': 0,
|
||||
\ 'stdin': 0,
|
||||
\ 'no_append': 0,
|
||||
\ }
|
||||
try
|
||||
let g:neoformat_enabled_java += neoformat#formatters#java#enabled()
|
||||
catch
|
||||
endtry
|
||||
endfunction
|
||||
" vim:set et sw=2 cc=80:
|
||||
|
@ -91,9 +91,9 @@ function! SpaceVim#layers#lang#lisp#config() abort
|
||||
\ ['n', '<c-n>', ':call vlime#ui#input#NextHistoryItem("forward")<cr>'],
|
||||
\ ],
|
||||
\ }
|
||||
call SpaceVim#mapping#space#regesit_lang_mappings('lisp', funcref('s:lisp'))
|
||||
augroup LocalVlimeKeys
|
||||
autocmd!
|
||||
autocmd FileType lisp call s:lisp()
|
||||
autocmd FileType vlime_sldb call s:vlime_sldb()
|
||||
autocmd FileType vlime_repl call s:vlime_repl()
|
||||
autocmd FileType vlime_inspector call s:vlime_inspector()
|
||||
@ -109,7 +109,6 @@ endfunction
|
||||
|
||||
|
||||
fu! s:lisp()
|
||||
let g:_spacevim_mappings_space.l = {'name' : '+Language Specified'}
|
||||
let g:_spacevim_mappings_space.l.c = {'name' : '+Connection Management'}
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','c', 'c'], "call VlimeConnectREPL()", 'Connect to Vlime server', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','c', 's'], "call VlimeSelectCurConnection()", 'Switch Vlime connections', 1)
|
||||
|
@ -286,6 +286,20 @@ function! s:windows_layout_toggle() abort
|
||||
wincmd w
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
let s:language_specified_mappings = {}
|
||||
function! SpaceVim#mapping#space#refrashLSPC()
|
||||
let g:_spacevim_mappings_space.l = {'name' : '+Language Specified'}
|
||||
if !empty(&filetype) && has_key(s:language_specified_mappings, &filetype)
|
||||
call call(s:language_specified_mappings[&filetype], [])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#mapping#space#regesit_lang_mappings(ft, func)
|
||||
call extend(s:language_specified_mappings, {a:ft : a:func})
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#mapping#space#langSPC(m, keys, cmd, desc, is_cmd) abort
|
||||
if s:has_map_to_spc()
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user