Skip to content
This repository was archived by the owner on Feb 27, 2023. It is now read-only.

Commit 0ed5d15

Browse files
committed
update myspacevim
1 parent 6fbaa13 commit 0ed5d15

File tree

9 files changed

+75
-52
lines changed

9 files changed

+75
-52
lines changed

autoload/SpaceVim/api/vim/statusline.vim

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ let s:self.__buffer = SpaceVim#api#import('vim#buffer')
1616
let s:self.__cmp = SpaceVim#api#import('vim#compatible')
1717

1818
function! s:self.check_width(len, sec, winwidth) abort
19-
" CUSTOM: Always show the cursor position in statusline
20-
return a:sec =~# '%l/%L' ? 1 : a:len + self.len(a:sec) < a:winwidth
19+
return a:len + self.len(a:sec) < a:winwidth
2120
endfunction
2221

2322
let s:self.__winid = -1

autoload/SpaceVim/layers/autocomplete.vim

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@ function! SpaceVim#layers#autocomplete#plugins() abort
5858
\ 'loadconf' : 1,
5959
\ 'on_cmd' : 'NeoSnippetEdit'}])
6060
elseif g:spacevim_snippet_engine ==# 'ultisnips'
61-
call add(plugins, ['SirVer/ultisnips',{ 'on_ft': ['snippets'], 'on_func': 'UltiSnips#ExpandSnippetOrJump', 'loadconf_before' : 1,
61+
call add(plugins, ['SirVer/ultisnips',{
62+
\ 'on_ft': ['snippets'],
63+
\ 'on_func': 'UltiSnips#ExpandSnippetOrJump',
64+
\ 'on_cmd': 'UltiSnipsEdit',
65+
\ 'loadconf_before' : 1,
6266
\ 'merged' : 0}])
6367
endif
6468
if g:spacevim_autocomplete_method ==# 'ycm'

autoload/SpaceVim/layers/chinese.vim

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ function! SpaceVim#layers#chinese#plugins() abort
2020
endfunction
2121

2222
function! SpaceVim#layers#chinese#config() abort
23-
let g:translator_default_engines = ['bing', 'youdao']
2423
let g:_spacevim_mappings.t = {'name' : '+Translate/TableMode'}
2524
call SpaceVim#mapping#def('nnoremap', '<Leader>tc', ':Translate<cr>', '', '', 'Translate in cmdline')
2625
call SpaceVim#mapping#def('vnoremap', '<Leader>tc', ':Translate<cr>', '', '', 'Translate in cmdline')

autoload/SpaceVim/layers/core.vim

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,7 @@ function! SpaceVim#layers#core#config() abort
279279
let g:_spacevim_mappings_space.p.t = {'name' : '+Tasks'}
280280
call SpaceVim#mapping#space#def('nnoremap', ['p', 'e'], 'call SpaceVim#plugins#tasks#edit()', 'edit-project-task', 1)
281281
call SpaceVim#mapping#space#def('nnoremap', ['p', 'l'], 'call SpaceVim#plugins#tasks#list()', 'list-tasks', 1)
282-
call SpaceVim#mapping#space#def('nnoremap', ['p', 'r'],
283-
\ 'call SpaceVim#plugins#runner#run_task(SpaceVim#plugins#tasks#get())', 'pick-task-to-run', 1)
282+
call SpaceVim#mapping#space#def('nnoremap', ['p', 'r'], 'call SpaceVim#plugins#runner#run_task(SpaceVim#plugins#tasks#get())', 'pick-task-to-run', 1)
284283
call SpaceVim#mapping#space#def('nnoremap', ['p', 't', 'e'], 'call SpaceVim#plugins#tasks#edit()', 'edit-project-task', 1)
285284
call SpaceVim#mapping#space#def('nnoremap', ['p', 't', 'l'], 'call SpaceVim#plugins#tasks#list()', 'list-tasks', 1)
286285
call SpaceVim#mapping#space#def('nnoremap', ['p', 't', 'c'], 'call SpaceVim#plugins#runner#clear_tasks()', 'clear-tasks', 1)

autoload/SpaceVim/layers/core/statusline.vim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919

2020
scriptencoding utf-8
2121

22-
" if exists('g:_spacevim_statusline_loaded')
23-
" finish
24-
" endif
22+
if exists('g:_spacevim_statusline_loaded')
23+
finish
24+
endif
2525

2626
let g:_spacevim_statusline_loaded = 1
2727

autoload/SpaceVim/layers/edit.vim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ function! SpaceVim#layers#edit#plugins() abort
3737
\ [g:_spacevim_root_dir . 'bundle/vim-better-whitespace', { 'on_cmd' : ['StripWhitespace', 'ToggleWhitespace', 'DisableWhitespace', 'EnableWhitespace']}],
3838
\ ['andrewradev/splitjoin.vim',{ 'on_cmd':['SplitjoinJoin', 'SplitjoinSplit'],'merged' : 0, 'loadconf' : 1}],
3939
\ ]
40-
if executable('fcitx5')
41-
call add(plugins,['520Matches/fcitx5.vim', { 'on_event' : 'InsertEnter'}])
42-
elseif executable('fcitx')
40+
if executable('fcitx')
4341
call add(plugins,[g:_spacevim_root_dir . 'bundle/fcitx.vim', { 'on_event' : 'InsertEnter'}])
42+
elseif executable('fcitx5')
43+
call add(plugins,['520Matches/fcitx5.vim', { 'on_event' : 'InsertEnter'}])
4444
endif
4545
if g:spacevim_enable_bepo_layout
4646
call add(plugins,[g:_spacevim_root_dir . 'bundle/vim-bepo', { 'merged' : 0}])

autoload/SpaceVim/layers/lang/c.vim

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ function! SpaceVim#layers#lang#c#plugins() abort
149149
endif
150150
else
151151
call add(plugins, [g:_spacevim_root_dir . 'bundle/vim-cpp-modern', { 'merged' : 0}])
152-
call add(plugins, ['t6tn4k/vim-c-posix-syntax', { 'merged' : 0}])
153152
endif
154153
return plugins
155154
endfunction

autoload/SpaceVim/layers/lang/markdown.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ endfunction
4646

4747
function! SpaceVim#layers#lang#markdown#plugins() abort
4848
let plugins = []
49-
call add(plugins, ['plasticboy/vim-markdown',{ 'on_ft' : 'markdown'}]) "comment line 872 in ftplugin/markdown.vim
49+
call add(plugins, ['plasticboy/vim-markdown',{ 'on_ft' : 'markdown'}])
5050
call add(plugins, ['mzlogin/vim-markdown-toc',{ 'on_ft' : 'markdown'}])
5151
call add(plugins, ['iamcco/mathjax-support-for-mkdp',{ 'on_ft' : 'markdown'}])
5252
call add(plugins, ['lvht/tagbar-markdown',{'merged' : 0}])

autoload/myspacevim.vim

Lines changed: 61 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function! s:file_icons()
2323
endfunction
2424

2525

26-
function! s:runner_before()
26+
function! s:code_runner()
2727
if g:spacevim_terminal_runner
2828
let g:quickrun_default_flags = {
2929
\ 'cpp': {
@@ -135,11 +135,11 @@ function! s:autocomplete_before()
135135
\ ]
136136
augroup MySpaceVimAutocomplete
137137
for ft in keys(g:ycm_semantic_triggers)
138-
exe 'autocmd FileType '.ft.' nnoremap <silent> gd :YcmCompleter GoTo<CR>'
139-
exe 'autocmd FileType '.ft.' nnoremap <silent> gr :YcmCompleter GoToReferences<CR>'
140-
exe 'autocmd FileType '.ft.' nnoremap <silent> gD :YcmCompleter GetDoc<CR>'
141-
exe 'autocmd FileType '.ft." nnoremap <silent> gR :exe 'YcmCompleter RefactorRename '.input('refactor \"'.expand('<cword>').'\" to:')<cr>"
142-
exe 'autocmd FileType '.ft.' nnoremap <silent> gt :YcmCompleter GetType<CR>'
138+
exe 'autocmd FileType '.ft.' nnoremap <silent><buffer> gd :YcmCompleter GoTo<CR>'
139+
exe 'autocmd FileType '.ft.' nnoremap <silent><buffer> gr :YcmCompleter GoToReferences<CR>'
140+
exe 'autocmd FileType '.ft.' nnoremap <silent><buffer> gD :YcmCompleter GetDoc<CR>'
141+
exe 'autocmd FileType '.ft." nnoremap <silent><buffer> gR :exe 'YcmCompleter RefactorRename '.input('refactor \"'.expand('<cword>').'\" to:')<cr>"
142+
exe 'autocmd FileType '.ft.' nnoremap <silent><buffer> gt :YcmCompleter GetType<CR>'
143143
endfor
144144
augroup END
145145
endif
@@ -205,7 +205,7 @@ function! s:checker_after()
205205
call SpaceVim#mapping#space#def('nnoremap', ['e', 'd'], 'call myspacevim#show_detailed_diagnostic()', 'Detail error information', 1)
206206
endif
207207
endfunction
208-
208+
" called by checker
209209
function! myspacevim#show_detailed_diagnostic() abort
210210
let bufnr = bufnr('YcmShowDetailedDiagnostic')
211211
let winid = bufwinid(bufnr)
@@ -274,32 +274,32 @@ endfunction
274274

275275

276276
function! s:lang_c_after()
277-
function! s:set_lang_cpp_std()
278-
let file = findfile('.ycm_extra_conf.py', '.;'.$HOME)
279-
if file !=# ''
280-
exe 'py3file '. file
281-
for thisFlag in py3eval('Settings()').flags
282-
if thisFlag =~# '-std='
283-
let b:lang_cpp_std = thisFlag
284-
endif
285-
endfor
286-
endif
287-
if get(b:, 'lang_cpp_std', '') ==# ''
288-
let b:lang_cpp_std = '-std=c++20'
289-
endif
290-
291-
let g:ale_cpp_cc_options = b:lang_cpp_std . ' -O2 -I. -fsyntax-only -fcoroutines -Wall -Wextra -Wshadow -Wfloat-equal -Wsign-conversion -Wlogical-op -Wnon-virtual-dtor -Woverloaded-virtual -Wduplicated-cond -Wduplicated-branches -Wnull-dereference -Wuseless-cast -Wdouble-promotion '
292-
let g:ale_cpp_cppcheck_options = '--enable=warning,style,performance,portability -'.b:lang_cpp_std
293-
let g:ale_cpp_clangtidy_options = ' -I. ' . b:lang_cpp_std
294-
295-
let b:QuickrunCompileCmd = substitute(b:QuickrunCompileCmd, '^\(\S*\)', '\1 '.b:lang_cpp_std, '')
296-
endfunction
297-
298-
299277
augroup MySpaceVimLangC
300278
autocmd FileType cpp call s:set_lang_cpp_std()
301279
augroup END
302280
endfunction
281+
" called by lang_c
282+
function! s:set_lang_cpp_std()
283+
let file = findfile('.ycm_extra_conf.py', '.;'.$HOME)
284+
if file !=# ''
285+
exe 'py3file '. file
286+
for thisFlag in py3eval('Settings()').flags
287+
if thisFlag =~# '-std='
288+
let b:lang_cpp_std = thisFlag
289+
endif
290+
endfor
291+
endif
292+
if get(b:, 'lang_cpp_std', '') ==# ''
293+
let b:lang_cpp_std = '-std=c++20'
294+
endif
295+
296+
let g:ale_cpp_cc_options = b:lang_cpp_std . ' -O2 -I. -fsyntax-only -fcoroutines -Wall -Wextra -Wshadow -Wfloat-equal -Wsign-conversion -Wlogical-op -Wnon-virtual-dtor -Woverloaded-virtual -Wduplicated-cond -Wduplicated-branches -Wnull-dereference -Wuseless-cast -Wdouble-promotion '
297+
let g:ale_cpp_cppcheck_options = '--enable=warning,style,performance,portability -'.b:lang_cpp_std
298+
let g:ale_cpp_clangtidy_options = ' -I. ' . b:lang_cpp_std
299+
300+
let b:QuickrunCompileCmd = substitute(b:QuickrunCompileCmd, '^\(\S*\)', '\1 '.b:lang_cpp_std, '')
301+
endfunction
302+
303303

304304
function! s:core_after()
305305
let g:matchup_matchparen_stopline = 45
@@ -312,11 +312,13 @@ function! s:core_after()
312312
nnoremap <silent><c-w>X :call SpaceVim#mapping#clear_saved_buffers()<cr>
313313
endfunction
314314

315+
315316
function! s:edit_before()
316317
let g:table_mode_auto_align = 0
317318
" let g:table_mode_disable_mappings = 1
318319
endfunction
319320

321+
320322
function! s:edit_after()
321323
let g:splitjoin_split_mapping = ''
322324
let g:splitjoin_join_mapping = ''
@@ -348,13 +350,15 @@ function! s:edit_after()
348350
call SpaceVim#mapping#space#def('vmap', ['x', 'c'], '<Plug>CountSelectionRegion', 'count in the selection region', 0, 1)
349351
endfunction
350352

353+
351354
function! s:lang_markdown_before()
352355
let g:vim_markdown_no_default_key_mappings = 1
353356
nmap [[ <Plug>Markdown_MoveToPreviousHeader
354357
nmap ]] <Plug>Markdown_MoveToNextHeader
355358
nmap [] <Plug>Markdown_MoveToCurHeader
356359
endfunction
357360

361+
358362
function! s:lang_markdown_after()
359363
let g:vim_markdown_folding_style_pythonic = 1
360364
let g:vim_markdown_emphasis_multiline = 0
@@ -381,6 +385,7 @@ function! s:lang_markdown_after()
381385
augroup END
382386
endfunction
383387

388+
384389
function! s:leaderf_before()
385390
let g:Lf_GtagsAutoGenerate = 1
386391
let g:Lf_GtagsAutoUpdate = 1
@@ -395,6 +400,7 @@ function! s:leaderf_before()
395400
let g:Lf_UseCache = 0
396401
endfunction
397402

403+
398404
function! s:tools_before()
399405
let g:rainbow_active = 1
400406
let g:rainbow_conf = {
@@ -430,21 +436,14 @@ function! s:tools_before()
430436
\}
431437
endfunction
432438

439+
433440
function! s:ui_after()
434441
let g:indentLine_char = '¦'
435442
let g:indentLine_fileTypeExclude = ['help', 'man', 'startify', 'vimfiler', 'defx']
436443
nnoremap <silent> <F1> :TagbarToggle<CR>
437444
nnoremap <silent> <F3> :Defx -direction=botright -no-focus -show-ignored-files<cr>
438445
endfunction
439446

440-
function! s:close_window(range)
441-
if a:range ==# ''
442-
quit
443-
else
444-
exe substitute(a:range, '.*\(\d\)', '\1', 'g')+1.'close'
445-
endif
446-
let &l:statusline = SpaceVim#layers#core#statusline#get(1)
447-
endfunction
448447

449448
function! s:colorscheme_before()
450449
let g:neosolarized_italic = 1
@@ -455,6 +454,7 @@ function! s:colorscheme_before()
455454
let g:palenight_terminal_italics = 1
456455
endfunction
457456

457+
458458
function! s:set_neovim_after() abort
459459
set nofoldenable
460460
set showcmd
@@ -610,12 +610,23 @@ function! s:set_neovim_after() abort
610610
let g:_spacevim_mappings_z['<Down>'] = ['normal 3<c-e>', 'scroll down one line']
611611
nnoremap z<down> 3<c-y>
612612
endfunction
613+
" called by set_neovim
614+
function! s:close_window(range)
615+
if a:range ==# ''
616+
quit
617+
else
618+
exe substitute(a:range, '.*\(\d\)', '\1', 'g')+1.'close'
619+
endif
620+
let &l:statusline = SpaceVim#layers#core#statusline#get(1)
621+
endfunction
622+
613623

614624
function! s:set_neovim_before() abort
615625
set list " 放在before防止覆盖Startify设置
616626
" set listchars=tab:▸\ ,eol:↵,trail:·,extends:↷,precedes:↶
617627
endfunction
618628

629+
619630
function! s:incsearch_after()
620631
let g:incsearch#auto_nohlsearch = 0
621632
function! s:config_easyfuzzymotion(...) abort
@@ -631,12 +642,14 @@ function! s:incsearch_after()
631642
nmap z/ <Plug>(incsearch-fuzzyword-/)
632643
endfunction
633644

645+
634646
function! s:git_after()
635647
let g:gitgutter_enabled = 0
636648
call SpaceVim#mapping#space#def('nnoremap', ['g', 'm'], 'Git branch', 'branch-manager', 1)
637649
call SpaceVim#mapping#space#def('nnoremap', ['g', 'g'], 'GitGutterToggle', 'GitGutter Buffer Toggle', 1)
638650
endfunction
639651

652+
640653
function! s:colorscheme_after()
641654
if $WSL_DISTRO_NAME !=# ''
642655
hi! SpellBad gui=underline guisp=Red
@@ -649,6 +662,7 @@ function! s:colorscheme_after()
649662
endif
650663
endfunction
651664

665+
652666
function! s:custom_plugins_before()
653667
"=============== vim-header ================="
654668
let g:header_field_author = 'Heachen Bear'
@@ -701,11 +715,13 @@ function! s:custom_plugins_before()
701715
nmap <Space>di <Plug>VimspectorBalloonEval
702716
endfunction
703717

718+
704719
function! s:custom_plugins_after()
705720
"=============== vim-header =================
706721
call SpaceVim#mapping#space#def('nnoremap', ['f', 'h'], 'AddHeader', 'add file header', 1)
707722
endfunction
708723

724+
709725
function! s:spacevim_after()
710726
augroup MySpaceVim
711727
autocmd FileType SpaceVimFlyGrep map <buffer> <c-c> <esc>
@@ -717,11 +733,17 @@ function! s:spacevim_after()
717733
augroup END
718734
endfunction
719735

736+
737+
function! s:lang_chinese_before()
738+
let g:translator_default_engines = ['bing', 'youdao']
739+
endfunction
740+
741+
720742
" ===================================================================================================
721743
function! myspacevim#before() abort
722744
call s:set_neovim_before()
723745
call s:file_icons()
724-
call s:runner_before()
746+
call s:code_runner()
725747
call s:autocomplete_before()
726748
call s:checker_before()
727749
call s:edit_before()
@@ -731,6 +753,7 @@ function! myspacevim#before() abort
731753
call s:tools_before()
732754
call s:colorscheme_before()
733755
call s:custom_plugins_before()
756+
call s:lang_chinese_before()
734757
endfunction
735758
" ===================================================================================================
736759

0 commit comments

Comments
 (0)