mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-04-14 23:49:19 +08:00
feat(ctrlg): add ctrl-g
key binding to display project info
This commit is contained in:
parent
4066e71ffa
commit
ca969ce065
@ -231,6 +231,11 @@ function! SpaceVim#default#keyBindings() abort
|
||||
" Start new line
|
||||
inoremap <S-Return> <C-o>o
|
||||
|
||||
if maparg('<c-g>', 'n') == ''
|
||||
nnoremap <silent> <c-g> :<c-u>call SpaceVim#plugins#ctrlg#display()<cr>
|
||||
endif
|
||||
|
||||
|
||||
" Improve scroll, credits: https://github.com/Shougo
|
||||
nnoremap <expr> zz (winline() == (winheight(0)+1) / 2) ?
|
||||
\ 'zt' : (winline() == &scrolloff + 1) ? 'zb' : 'zz'
|
||||
|
41
autoload/SpaceVim/plugins/ctrlg.vim
Normal file
41
autoload/SpaceVim/plugins/ctrlg.vim
Normal file
@ -0,0 +1,41 @@
|
||||
"=============================================================================
|
||||
" ctrlg.vim --- display info via Ctrl-g
|
||||
" Copyright (c) 2016-2019 Wang Shidong & Contributors
|
||||
" Author: Wang Shidong < wsdjeg@outlook.com >
|
||||
" URL: https://spacevim.org
|
||||
" License: GPLv3
|
||||
"=============================================================================
|
||||
if exists('s:loaded')
|
||||
finish
|
||||
endif
|
||||
let s:loaded = 1
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
let s:win = has("win32") || has("win64") || has("win16")
|
||||
let s:lang = exists("$LANG") ? tolower($LANG[:1]) : 'en'
|
||||
|
||||
function! SpaceVim#plugins#ctrlg#display() abort
|
||||
|
||||
let pwd = getcwd()
|
||||
|
||||
if isdirectory('.git')
|
||||
let project_name = printf('[%s]', fnamemodify(pwd, ':t'))
|
||||
else
|
||||
let project_name = ''
|
||||
endif
|
||||
|
||||
let file = fnamemodify(expand('%'), '.')
|
||||
|
||||
if !empty(project_name)
|
||||
echohl Constant | echo project_name
|
||||
endif
|
||||
echohl WarningMsg | echon " >> "
|
||||
echohl Special | echon pwd
|
||||
echohl WarningMsg | echon " >> "
|
||||
echohl Directory | echon file
|
||||
endfun
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
@ -73,6 +73,7 @@ description: "General documentation about how to use SpaceVim, including the qui
|
||||
- [Commands starting with `z`](#commands-starting-with-z)
|
||||
- [Advanced usage](#advanced-usage)
|
||||
- [Managing projects](#managing-projects)
|
||||
- [Show project info on cmdline](#show-project-info-on-cmdline)
|
||||
- [Searching files in project](#searching-files-in-project)
|
||||
- [Custom alternate file](#custom-alternate-file)
|
||||
- [Bookmarks management](#bookmarks-management)
|
||||
@ -1955,6 +1956,10 @@ Project manager commands start with `p`:
|
||||
| ------------ | ----------------------------------------------------- |
|
||||
| `SPC p '` | open a shell in project’s root (need the shell layer) |
|
||||
|
||||
#### Show project info on cmdline
|
||||
|
||||
By default the key binding `Ctrl-g` will display the information of current project on command line.
|
||||
|
||||
#### Searching files in project
|
||||
|
||||
| Key Bindings | Descriptions |
|
||||
|
Loading…
x
Reference in New Issue
Block a user