mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-02 22:30:04 +08:00
Fix type
This commit is contained in:
parent
b592fe6b8e
commit
3e486f203e
@ -72,7 +72,9 @@ let g:spacevim_vim_plug_installed = 0
|
|||||||
" >
|
" >
|
||||||
" let g:spacevim_plugin_bundle_dir = '~/.cache/vimplugs'
|
" let g:spacevim_plugin_bundle_dir = '~/.cache/vimplugs'
|
||||||
" <
|
" <
|
||||||
let g:spacevim_plugin_bundle_dir = $HOME. join(['', '.cache', 'vimfiles', ''], SpaceVim#api#import('file').separator)
|
let g:spacevim_plugin_bundle_dir
|
||||||
|
\ = $HOME. join(['', '.cache', 'vimfiles', ''],
|
||||||
|
\ SpaceVim#api#import('file').separator)
|
||||||
""
|
""
|
||||||
" Enable/Disable realtime leader guide. Default is 0.
|
" Enable/Disable realtime leader guide. Default is 0.
|
||||||
" >
|
" >
|
||||||
@ -160,7 +162,7 @@ let g:spacevim_filemanager = 'vimfiler'
|
|||||||
""
|
""
|
||||||
" The default plugin manager of SpaceVim. Default is 'dein'.
|
" The default plugin manager of SpaceVim. Default is 'dein'.
|
||||||
" Options are dein, neobundle, or vim-plug.
|
" Options are dein, neobundle, or vim-plug.
|
||||||
let g:spacevim_plugin_manager = 'dein' " neobundle or dein or vim-plug
|
let g:spacevim_plugin_manager = 'dein'
|
||||||
""
|
""
|
||||||
" Enable/Disable checkinstall on SpaceVim startup. Default is 1.
|
" Enable/Disable checkinstall on SpaceVim startup. Default is 1.
|
||||||
" >
|
" >
|
||||||
@ -249,8 +251,10 @@ let g:spacevim_src_root = 'E:\sources\'
|
|||||||
""
|
""
|
||||||
" The host file url. This option is for Chinese users who can not use
|
" The host file url. This option is for Chinese users who can not use
|
||||||
" Google and Twitter.
|
" Google and Twitter.
|
||||||
let g:spacevim_hosts_url = 'https://raw.githubusercontent.com/racaljk/hosts/master/hosts'
|
let g:spacevim_hosts_url
|
||||||
let g:spacevim_wildignore = '*/tmp/*,*.so,*.swp,*.zip,*.class,tags,*.jpg,
|
\ = 'https://raw.githubusercontent.com/racaljk/hosts/master/hosts'
|
||||||
|
let g:spacevim_wildignore
|
||||||
|
\ = '*/tmp/*,*.so,*.swp,*.zip,*.class,tags,*.jpg,
|
||||||
\*.ttf,*.TTF,*.png,*/target/*,
|
\*.ttf,*.TTF,*.png,*/target/*,
|
||||||
\.git,.svn,.hg,.DS_Store'
|
\.git,.svn,.hg,.DS_Store'
|
||||||
|
|
||||||
@ -410,4 +414,4 @@ endfunction
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
" vim:set et sw=2:
|
" vim:set et sw=2 cc=80:
|
||||||
|
@ -81,21 +81,25 @@ function! SpaceVim#default#SetOptions() abort
|
|||||||
set undodir=$HOME/.data/undofile
|
set undodir=$HOME/.data/undofile
|
||||||
set backupdir=$HOME/.data/backup
|
set backupdir=$HOME/.data/backup
|
||||||
set directory=$HOME/.data/swap
|
set directory=$HOME/.data/swap
|
||||||
set nofoldenable " no fold enable
|
|
||||||
|
" no fold enable
|
||||||
|
set nofoldenable
|
||||||
set nowritebackup
|
set nowritebackup
|
||||||
set matchtime=0
|
set matchtime=0
|
||||||
set ruler
|
set ruler
|
||||||
set showmatch
|
set showmatch
|
||||||
set showmode
|
set showmode
|
||||||
"menuone: show the pupmenu when only one match
|
"menuone: show the pupmenu when only one match
|
||||||
set completeopt=menu,menuone,longest " disable preview scratch window,
|
" disable preview scratch window,
|
||||||
set complete=.,w,b,u,t " h: 'complete'
|
set completeopt=menu,menuone,longest
|
||||||
set pumheight=15 " limit completion menu height
|
" h: 'complete'
|
||||||
|
set complete=.,w,b,u,t
|
||||||
|
" limit completion menu height
|
||||||
|
set pumheight=15
|
||||||
set scrolloff=7
|
set scrolloff=7
|
||||||
set incsearch
|
set incsearch
|
||||||
set hlsearch
|
set hlsearch
|
||||||
set laststatus=2
|
set laststatus=2
|
||||||
set completeopt=longest,menu
|
|
||||||
set wildignorecase
|
set wildignorecase
|
||||||
set mouse=
|
set mouse=
|
||||||
set hidden
|
set hidden
|
||||||
@ -154,8 +158,6 @@ endfunction
|
|||||||
function! SpaceVim#default#SetMappings() abort
|
function! SpaceVim#default#SetMappings() abort
|
||||||
|
|
||||||
"mapping
|
"mapping
|
||||||
"全局映射
|
|
||||||
"也可以通过'za'打开或者关闭折叠
|
|
||||||
imap <silent><expr><TAB> SpaceVim#mapping#tab()
|
imap <silent><expr><TAB> SpaceVim#mapping#tab()
|
||||||
smap <expr><TAB> neosnippet#expandable_or_jumpable() ? "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
|
smap <expr><TAB> neosnippet#expandable_or_jumpable() ? "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
|
||||||
inoremap <silent><expr><CR> SpaceVim#mapping#enter()
|
inoremap <silent><expr><CR> SpaceVim#mapping#enter()
|
||||||
@ -165,16 +167,12 @@ function! SpaceVim#default#SetMappings() abort
|
|||||||
inoremap <expr> <PageUp> pumvisible() ? "\<PageUp>\<C-p>\<C-n>" : "\<PageUp>"
|
inoremap <expr> <PageUp> pumvisible() ? "\<PageUp>\<C-p>\<C-n>" : "\<PageUp>"
|
||||||
imap <expr><S-TAB> pumvisible() ? "\<C-p>" : ""
|
imap <expr><S-TAB> pumvisible() ? "\<C-p>" : ""
|
||||||
smap <expr><S-TAB> pumvisible() ? "\<C-p>" : ""
|
smap <expr><S-TAB> pumvisible() ? "\<C-p>" : ""
|
||||||
"Super paste it does not work
|
|
||||||
"ino <C-v> <esc>:set paste<cr>mui<C-R>+<esc>mv'uV'v=:set nopaste<cr>
|
|
||||||
"对于没有权限的文件使用 :w!!来保存
|
|
||||||
cnoremap w!! %!sudo tee > /dev/null %
|
|
||||||
" cmap W!! w !sudo tee % >/dev/null " I can not understand
|
|
||||||
" Save a file with sudo
|
" Save a file with sudo
|
||||||
" http://forrst.com/posts/Use_w_to_sudo_write_a_file_with_Vim-uAN
|
" http://forrst.com/posts/Use_w_to_sudo_write_a_file_with_Vim-uAN
|
||||||
|
cnoremap w!! %!sudo tee > /dev/null %
|
||||||
|
|
||||||
|
|
||||||
" 映射Ctrl+上下左右来切换窗口
|
" Use Ctrl+* to jump between windows
|
||||||
nnoremap <silent><C-Right> :<C-u>wincmd l<CR>
|
nnoremap <silent><C-Right> :<C-u>wincmd l<CR>
|
||||||
nnoremap <silent><C-Left> :<C-u>wincmd h<CR>
|
nnoremap <silent><C-Left> :<C-u>wincmd h<CR>
|
||||||
nnoremap <silent><C-Up> :<C-u>wincmd k<CR>
|
nnoremap <silent><C-Up> :<C-u>wincmd k<CR>
|
||||||
@ -207,12 +205,11 @@ function! SpaceVim#default#SetMappings() abort
|
|||||||
vnoremap <silent>]<Home> dggP``
|
vnoremap <silent>]<Home> dggP``
|
||||||
|
|
||||||
|
|
||||||
"Ctrl+Shift+上下移动当前行
|
"Ctrl+Shift+Up/Down to move up and down
|
||||||
nnoremap <silent><C-S-Down> :m .+1<CR>==
|
nnoremap <silent><C-S-Down> :m .+1<CR>==
|
||||||
nnoremap <silent><C-S-Up> :m .-2<CR>==
|
nnoremap <silent><C-S-Up> :m .-2<CR>==
|
||||||
inoremap <silent><C-S-Down> <Esc>:m .+1<CR>==gi
|
inoremap <silent><C-S-Down> <Esc>:m .+1<CR>==gi
|
||||||
inoremap <silent><C-S-Up> <Esc>:m .-2<CR>==gi
|
inoremap <silent><C-S-Up> <Esc>:m .-2<CR>==gi
|
||||||
"上下移动选中的行
|
|
||||||
vnoremap <silent><C-S-Down> :m '>+1<CR>gv=gv
|
vnoremap <silent><C-S-Down> :m '>+1<CR>gv=gv
|
||||||
vnoremap <silent><C-S-Up> :m '<-2<CR>gv=gv
|
vnoremap <silent><C-S-Up> :m '<-2<CR>gv=gv
|
||||||
" download gvimfullscreen.dll from github, copy gvimfullscreen.dll to
|
" download gvimfullscreen.dll from github, copy gvimfullscreen.dll to
|
||||||
|
@ -63,10 +63,15 @@ function! SpaceVim#logger#viewLog(...) abort
|
|||||||
let l = a:0 > 0 ? a:1 : 1
|
let l = a:0 > 0 ? a:1 : 1
|
||||||
if filereadable(s:logger_file)
|
if filereadable(s:logger_file)
|
||||||
let logs = readfile(s:logger_file, '')
|
let logs = readfile(s:logger_file, '')
|
||||||
let info .= join(filter(logs, "v:val =~# '\[ SpaceVim \] \[\d\d\:\d\d\:\d\d\] \[" . s:levels[l] . "\]'"), "\n")
|
let info .= join(filter(logs,
|
||||||
|
\ "v:val =~# '\[ SpaceVim \] \[\d\d\:\d\d\:\d\d\] \["
|
||||||
|
\ . s:levels[l] . "\]'"), "\n")
|
||||||
else
|
else
|
||||||
let info .= '[ SpaceVim ] : logger file ' . s:logger_file . ' does not exists, only log for current process will be shown!'
|
let info .= '[ SpaceVim ] : logger file ' . s:logger_file
|
||||||
let info .= join(filter(s:log_temp, "v:val =~# '\[ SpaceVim \] \[\d\d\:\d\d\:\d\d\] \[" . s:levels[l] . "\]'"), "\n")
|
\ . ' does not exists, only log for current process will be shown!'
|
||||||
|
let info .= join(filter(s:log_temp,
|
||||||
|
\ "v:val =~# '\[ SpaceVim \] \[\d\d\:\d\d\:\d\d\] \["
|
||||||
|
\ . s:levels[l] . "\]'"), "\n")
|
||||||
endif
|
endif
|
||||||
let info .= "\n```\n"
|
let info .= "\n```\n"
|
||||||
return info
|
return info
|
||||||
@ -91,4 +96,4 @@ function! SpaceVim#logger#echoWarn(msg) abort
|
|||||||
echohl None
|
echohl None
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" vim:set et sw=2:
|
" vim:set et sw=2 cc=80:
|
||||||
|
@ -12,4 +12,4 @@ function! SpaceVim#util#echoWarn(msg) abort
|
|||||||
echohl None
|
echohl None
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" vim:set et sw=2:
|
" vim:set et sw=2 cc=80:
|
||||||
|
@ -10,6 +10,8 @@ permalink: "/conventions"
|
|||||||
|
|
||||||
## Viml coding style guide
|
## Viml coding style guide
|
||||||
### Portability
|
### Portability
|
||||||
|
Vim is highly configurable. Users can change many of the default settings, including the case sensitivity, the regular expression rules, the substitution rules, and more. In order for your vimscript to work for all users, follow these guidelines:
|
||||||
|
|
||||||
#### Strings
|
#### Strings
|
||||||
**Prefer single quoted strings**
|
**Prefer single quoted strings**
|
||||||
|
|
||||||
@ -23,9 +25,9 @@ Use double quoted strings when you need an escape sequence (such as "\n") or if
|
|||||||
The matching behavior depends upon the user's ignorecase and smartcase settings and on whether you compare them with the =~, =~#, or =~? family of operators. Use the =~# and =~? operator families explicitly when comparing strings unless you explicitly need to honor the user's case sensitivity settings.
|
The matching behavior depends upon the user's ignorecase and smartcase settings and on whether you compare them with the =~, =~#, or =~? family of operators. Use the =~# and =~? operator families explicitly when comparing strings unless you explicitly need to honor the user's case sensitivity settings.
|
||||||
|
|
||||||
#### Regular Expressions
|
#### Regular Expressions
|
||||||
**Prefix all regexes with \m\C.**
|
**Prefix all regexes with one of \m, \v, \M, or \V.**
|
||||||
|
|
||||||
In addition to the case sensitivity settings, regex behavior depends upon the user's nomagic setting. To make regexes act like nomagic and noignorecase are set, prepend all regexes with \m\C.
|
In addition to the case sensitivity settings, regex behavior depends upon the user's nomagic setting. To make regexes act like nomagic and noignorecase are set, prepend all regexes with one of \m, \v, \M, or \V.
|
||||||
|
|
||||||
You are welcome to use other magic levels (\v) and case sensitivities (\c) so long as they are intentional and explicit.
|
You are welcome to use other magic levels (\v) and case sensitivities (\c) so long as they are intentional and explicit.
|
||||||
|
|
||||||
@ -34,6 +36,8 @@ You are welcome to use other magic levels (\v) and case sensitivities (\c) so lo
|
|||||||
|
|
||||||
Avoid using :s[ubstitute] as it moves the cursor and prints error messages. Prefer functions (such as search()) better suited to scripts.
|
Avoid using :s[ubstitute] as it moves the cursor and prints error messages. Prefer functions (such as search()) better suited to scripts.
|
||||||
|
|
||||||
|
The meaning of the g flag depends upon the gdefault setting. If you do use :substitute you must save gdefault, set it to 0 or 1, perform the substitution, and then restore it.
|
||||||
|
|
||||||
For many vim commands, functions exist that do the same thing with fewer side effects. See :help functions() for a list of built-in functions.
|
For many vim commands, functions exist that do the same thing with fewer side effects. See :help functions() for a list of built-in functions.
|
||||||
|
|
||||||
#### Fragile commands
|
#### Fragile commands
|
||||||
@ -121,6 +125,14 @@ All key mappings should be defined in plugin/mappings.vim.
|
|||||||
|
|
||||||
Partial mappings (see :help using-<Plug>.) should be defined in plugin/plugs.vim.
|
Partial mappings (see :help using-<Plug>.) should be defined in plugin/plugs.vim.
|
||||||
|
|
||||||
|
**Always use the noremap family of commands.**
|
||||||
|
|
||||||
|
Your plugins generally shouldn't introduce mappings, but if they do, the map command respects the users existing mappings and could do anything.
|
||||||
|
|
||||||
|
#### Errors
|
||||||
|
|
||||||
|
When using catch, match the error code rather than the error text.
|
||||||
|
|
||||||
#### Settings
|
#### Settings
|
||||||
**Change settings locally**
|
**Change settings locally**
|
||||||
|
|
||||||
@ -150,14 +162,38 @@ Trailing whitespace is allowed in mappings which prep commands for user input, s
|
|||||||
- Indent continued lines by four spaces
|
- Indent continued lines by four spaces
|
||||||
- Do not align arguments of commands
|
- Do not align arguments of commands
|
||||||
|
|
||||||
```viml
|
```diff
|
||||||
command -bang MyCommand call myplugin#foo()
|
+command -bang MyCommand call myplugin#foo()
|
||||||
command MyCommand2 call myplugin#bar()
|
+command MyCommand2 call myplugin#bar()
|
||||||
|
-command -bang MyCommand call myplugin#foo()
|
||||||
command -bang MyCommand call myplugin#foo()
|
-command MyCommand2 call myplugin#bar()
|
||||||
command MyCommand2 call myplugin#bar()
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Line Continuations
|
||||||
|
- Prefer line continuations on semantic boundaries.
|
||||||
|
|
||||||
|
```diff
|
||||||
|
+command SomeLongCommand
|
||||||
|
+ \ call some#function()
|
||||||
|
-command SomeLongCommand call
|
||||||
|
- \ some#function()
|
||||||
|
```
|
||||||
|
|
||||||
|
- Place one space after the backslash denoting a line continuation.
|
||||||
|
|
||||||
|
When continuing a multi-line command a pipe can be substituted for this space as necessary, as follows:
|
||||||
|
|
||||||
|
```viml
|
||||||
|
autocommand BufEnter <buffer>
|
||||||
|
\ if !empty(s:var)
|
||||||
|
\| call some#function()
|
||||||
|
\|else
|
||||||
|
\| call some#function(s:var)
|
||||||
|
\|endif
|
||||||
|
```
|
||||||
|
|
||||||
|
- Do not continue multi-line commands when you can avoid it. Prefer function calls.
|
||||||
|
|
||||||
#### Naming
|
#### Naming
|
||||||
In general, use plugin-names-like-this, FunctionNamesLikeThis, CommandNamesLikeThis, augroup_names_like_this, variable_names_like_this.
|
In general, use plugin-names-like-this, FunctionNamesLikeThis, CommandNamesLikeThis, augroup_names_like_this, variable_names_like_this.
|
||||||
|
|
||||||
@ -185,8 +221,7 @@ Always prefix variables with their scope.
|
|||||||
- l: and v: should be used for consistency, future proofing, and to avoid subtle bugs. They are not strictly required. Add them in new code but don’t go out of your way to add them elsewhere.
|
- l: and v: should be used for consistency, future proofing, and to avoid subtle bugs. They are not strictly required. Add them in new code but don’t go out of your way to add them elsewhere.
|
||||||
|
|
||||||
|
|
||||||
|
## Thanks:
|
||||||
|
- link : https://google.github.io/styleguide/vimscriptguide.xml
|
||||||
|
- link : https://google.github.io/styleguide/vimscriptfull.xml
|
||||||
author : google
|
- link : https://github.com/noahfrederick/vim-scripting-style-guide/blob/master/doc/scripting-style.txt
|
||||||
link : https://google.github.io/styleguide/vimscriptguide.xml
|
|
||||||
|
Loading…
Reference in New Issue
Block a user