1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-03 00:00:04 +08:00

Add option filetree_direction (#2661)

This commit is contained in:
Wang Shidong 2019-03-14 00:03:35 +08:00 committed by GitHub
parent 35be464401
commit f55fac7c2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 380 additions and 320 deletions

View File

@ -501,6 +501,13 @@ let g:spacevim_simple_mode = 0
" you can also use nerdtree or defx
let g:spacevim_filemanager = 'vimfiler'
""
" Config the direction of file tree. Default is 'right'. you can also set to
" 'left'.
"
" NOTE: if it is 'left', the tagbar will be move to right.
let g:spacevim_filetree_direction = 'right'
let g:spacevim_sidebar_direction = ''
""
" The default plugin manager of SpaceVim.

View File

@ -189,7 +189,7 @@ function! SpaceVim#layers#core#config() abort
" TODO: fix all these command
call SpaceVim#mapping#space#def('nnoremap', ['f', 't'], 'Defx', 'toggle_file_tree', 1)
call SpaceVim#mapping#space#def('nnoremap', ['f', 'T'], 'Defx -no-toggle', 'show_file_tree', 1)
call SpaceVim#mapping#space#def('nnoremap', ['f', 'o'], 'Defx -find', 'open_file_tree', 1)
call SpaceVim#mapping#space#def('nnoremap', ['f', 'o'], "Defx -no-toggle -search=`expand('%:p')` `getcwd()`", 'open_file_tree', 1)
call SpaceVim#mapping#space#def('nnoremap', ['b', 't'], 'Defx -no-toggle', 'show_file_tree_at_buffer_dir', 1)
endif
call SpaceVim#mapping#space#def('nnoremap', ['f', 'y'], 'call zvim#util#CopyToClipboard()', 'show-and-copy-buffer-filename', 1)

View File

@ -10,10 +10,16 @@
let s:SYS = SpaceVim#api#import('system')
if g:spacevim_filetree_direction ==# 'right'
let s:direction = 'rightbelow'
else
let s:direction = 'leftabove'
endif
call defx#custom#option('_', {
\ 'winwidth': g:spacevim_sidebar_width,
\ 'split': 'vertical',
\ 'direction': 'botright',
\ 'direction': s:direction,
\ 'show_ignored_files': 0,
\ 'buffer_name': '',
\ 'toggle': 1,

View File

@ -1,5 +1,9 @@
let s:VCOP = SpaceVim#api#import('vim#compatible')
let g:NERDTreeWinPos=get(g:,'NERDTreeWinPos',spacevim_sidebar_direction)
if g:spacevim_filetree_direction ==# 'right'
let g:NERDTreeWinPos = 'rightbelow'
else
let g:NERDTreeWinPos = 'leftabove'
endif
let g:NERDTreeWinSize=get(g:,'NERDTreeWinSize',31)
let g:NERDTreeChDirMode=get(g:,'NERDTreeChDirMode',1)
augroup nerdtree_zvim

View File

@ -1,5 +1,9 @@
let g:tagbar_width = get(g:, 'tagbar_width', g:spacevim_sidebar_width)
let g:tagbar_left = get(g:, 'tagbar_left', 1)
if g:spacevim_filetree_direction ==# 'right'
let g:tagbar_left = 1
else
let g:tagbar_left = 0
endif
let g:tagbar_sort = get(g:, 'tagbar_sort', 0)
let g:tagbar_compact = get(g:, 'tagbar_compact', 1)
let g:tagbar_map_showproto = get(g:, 'tagbar_map_showproto', '')

View File

@ -11,7 +11,11 @@ let g:vimfiler_tree_closed_icon = get(g:, 'vimfiler_tree_closed_icon', '+')
let g:vimfiler_file_icon = get(g:, 'vimfiler_file_icon', '')
let g:vimfiler_readonly_file_icon = get(g:, 'vimfiler_readonly_file_icon', '*')
let g:vimfiler_marked_file_icon = get(g:, 'vimfiler_marked_file_icon', '√')
if g:spacevim_filetree_direction ==# 'right'
let g:vimfiler_direction = get(g:, 'vimfiler_direction', 'rightbelow')
else
let g:vimfiler_direction = 'leftabove'
endif
"let g:vimfiler_preview_action = 'auto_preview'
let g:vimfiler_ignore_pattern = get(g:, 'vimfiler_ignore_pattern', [
\ '^\.git$',

View File

@ -569,6 +569,12 @@ plugins will be installed.
The default file manager of SpaceVim. Default is 'vimfiler'. you can also use
nerdtree or defx
*g:spacevim_filetree_direction*
Config the direction of file tree. Default is 'right'. you can also set to
'left'.
NOTE: if it is 'left', the tagbar will be move to right.
*g:spacevim_plugin_manager_processes*
Set the max process of SpaceVim plugin manager

View File

@ -228,11 +228,13 @@ SpaceVim 默认安装了一些插件,如果需要禁用某个插件,可以
由于 toml 配置的局限性SpaceVim 提供了两种启动函数 `bootstrap_before``bootstrap_after`,在该函数内可以使用 Vim script。
可通过 `~/.SpaceVim.d/init.toml``[options]` 片段中的这两个选项 `bootstrap_before``bootstrap_after` 来指定函数名称,例如:
```toml
[options]
bootstrap_before = "myspacevim#before"
bootstrap_after = "myspacevim#after"
```
启动函数文件应放置在 Vim &runtimepath 的 autoload 文件夹内。例如:
文件名:`~/.SpaceVim.d/autoload/myspacevim.vim`
@ -307,6 +309,7 @@ SpaceVim 的[模块首页](../layers/)。
1. 禁用内置上游插件
比如,调试内置语法检查插件 neomake.vim
```toml
[options]
disabled_plugins = ["neomake.vim"]
@ -314,14 +317,17 @@ SpaceVim 的[模块首页](../layers/)。
2. 添加自己 fork 的插件
修改配置文件 `init.toml`,加入以下部分,来添加自己 fork 的版本:
```toml
[[custom_plugins]]
name = 'wsdjeg/neomake.vim'
# note: you need to disable merged feature
merged = false
```
或者添加本地克隆版本
使用 `bootstrap_before` 函数来添加本地路径:
```vim
function! myspacevim#before() abort
set rtp+=~/path/to/your/localplugin
@ -383,6 +389,7 @@ SpaceVim 在终端下默认使用了真色,因此使用之前需要确认下
[options]
guifont = "SauceCodePro Nerd Font Mono:h11"
```
如果指定的字体不存在,将会使用系统默认的字体,此外,这一选项在终端下是无效的,终端下修改字体,需要修改终端自身配置。
### 界面元素切换
@ -636,7 +643,7 @@ SpaceVim has mapped normal `q` as smart buffer close, the normal func of `q`
can be get by `<leader> q r`
| 快捷键 | 模式 | 功能描述 |
| --------------------- | ------------- | ------------------------------------------------------------------------------ |
| ------------------- | ------------- | ------------------------------------------------------------------------------ |
| `<leader>`+`y` | Visual | Copy selection to X11 clipboard ("+y) |
| `Ctrl-c` | Normal | Copy full path of current buffer to X11 clipboard |
| `<leader>`+`Ctrl-c` | Normal | Copy github.com url of current buffer to X11 clipboard(if it is a github repo) |
@ -672,7 +679,7 @@ can be get by `<leader> q r`
### Editor UI
| Key | Mode | Action |
| ----------------------- | ------------- | ---------------------------------------------------------------- |
| ----------------------------------------------- | ------------- | ---------------------------------------------------------------- |
| `<F2>` | _All_ | Toggle tagbar |
| `<F3>` | _All_ | Toggle Vimfiler |
| `<leader>` + num | Normal | Jump to the buffer with the num index |
@ -978,7 +985,7 @@ Denite/Unite 是一个强大的信息筛选浏览器,这类似于 Emacs 中的
窗口操作相关快捷键(以 `SPC w` 为前缀)
| 快捷键 | 功能描述 |
| ---------------------- | ------------------------------------------------------------------------------ |
| ---------------------------------------- | ------------------------------------------------------------------------------ |
| `SPC w`<Tab>` | 在同一标签内进行窗口切换 |
| `SPC w =` | 对齐分离的窗口 |
| `SPC w b` | force the focus back to the minibuffer (TODO) |
@ -1094,12 +1101,16 @@ SpaceVim 相关的快捷键均以 `SPC f v` 为前缀,这便于快速访问 Sp
#### 文件树
SpaceVim 使用 vimfiler 作为默认的文件树插件,默认的快捷键是 `F3`, SpaceVim 也提供了另外一组快捷键 `SPC f t``SPC f T` 来打开文件树,如果需要使用 nerdtree 作为默认文件树,需要在 `~/.SpaceVim.d/init.toml``[options]` 片段中修改选项 vimfiler
SpaceVim 使用 vimfiler 作为默认的文件树插件,默认的快捷键是 `F3`, SpaceVim 也提供了另外一组快捷键 `SPC f t``SPC f T` 来打开文件树。
如果需要修改默认文件树插件,需要在 `~/.SpaceVim.d/init.toml``[options]` 片段中修改选项 `filemanager`
```toml
[options]
# 默认值为 vimfiler
filemanager = "nerdtree"
# 文件树插件可选值包括:
# - vimfiler (默认)
# - nerdtree
# - defx
filemanager = "defx"
```
SpaceVim 的文件树提供了版本控制信息的接口,但是这一特性需要分析文件夹内容,
@ -1108,12 +1119,20 @@ SpaceVim 的文件树提供了版本控制信息的接口,但是这一特性
![file-tree](https://user-images.githubusercontent.com/13142418/26881817-279225b2-4bcb-11e7-8872-7e4bd3d1c84e.png)
默认情况下文件树是在窗口的右边打开,如果需要设置文件树默认在左边,需要修改 `filetree_direction` 选项。
需要注意的是,当设置文件树在左边时,函数列表 tagbar 将会在右边。
```toml
[options]
filetree_direction = "left"
```
##### 文件树中的常用操作
文件树中主要以 `hjkl` 为核心,这类似于 [vifm](https://github.com/vifm) 中常用的快捷键:
| 快捷键 | 功能描述 |
| -------------------- | ---------------------------- |
| -------------------- | ------------------------------ |
| `<F3>` / `SPC f t` | 切换文件树 |
| **文件树内的快捷键** | |
| `<Left>` / `h` | 移至父目录,并关闭文件夹 |
@ -1140,7 +1159,7 @@ SpaceVim 的文件树提供了版本控制信息的接口,但是这一特性
如果只有一个可编辑窗口,则在该窗口中打开选择的文件,否则则需要指定窗口来打开文件:
| 快捷键 | 功能描述 |
| ---------------- | ---------------- |
| --------------- | ---------------- |
| `l` / `<Enter>` | 打开文件 |
| `sg` | 分屏打开文件 |
| `sv` | 垂直分屏打开文件 |
@ -1150,7 +1169,7 @@ SpaceVim 的文件树提供了版本控制信息的接口,但是这一特性
在 Normal 模式下按下 `g` 之后,如果你不记得快捷键出现按键延迟,那么快捷键导航将会提示你所有以 `g` 为前缀的快捷键。
| 快捷键 | 功能描述 |
| --------- | ----------------------------------------------- |
| ---------- | ----------------------------------------------- |
| `g #` | 反向搜索光标下的词 |
| `g $` | 跳向本行最右侧字符 |
| `g &` | 针对所有行重复执行上一次 ":s" 命令 |
@ -1400,7 +1419,7 @@ endfunction
##### 在工程中进行搜索
| 快捷键 | 功能描述 |
| -------------------- | --------------------------------------------------- |
| ------------------- | --------------------------------------------------- |
| `SPC /` / `SPC s p` | search with the first found tool |
| `SPC *` / `SPC s P` | search with the first found tool with default input |
| `SPC s a p` | ag |
@ -1459,7 +1478,7 @@ endfunction
FlyGrep 缓冲区的按键绑定:
| 快捷键 | 功能描述 |
| ----------------- | --------------------------------- |
| ------------------- | --------------------------------- |
| `<Esc>` | close FlyGrep buffer |
| `<Enter>` | open file at the cursor line |
| `<Tab>` | move cursor line down |
@ -1491,7 +1510,7 @@ It is also possible to change the range of the navigation on the fly to:
Navigation between the highlighted symbols can be done with the commands:
| 快捷键 | 功能描述 |
| ----------- | ---------------------------------------------------------------------------- |
| --------- | ---------------------------------------------------------------------------- |
| `*` | initiate navigation transient state on current symbol and jump forwards |
| `#` | initiate navigation transient state on current symbol and jump backwards |
| `SPC s e` | edit all occurrences of the current symbol |
@ -1523,7 +1542,7 @@ In highlight symbol transient state:
文本相关的命令 (以 `x` 开头)
| 快捷键 | 功能描述 |
| -------------- | -------------------------------------------------------------------- |
| ------------- | -------------------------------------------------------------------- |
| `SPC x a &` | 基于分隔符 & 进行文本对齐 |
| `SPC x a (` | 基本分隔符 ( 进行文本对齐 |
| `SPC x a )` | 基本分隔符 ) 进行文本对齐 |
@ -1629,10 +1648,9 @@ SpaceVim uses a powerful iedit mode to quick edit multiple occurrences of a symb
**State transitions:**
| 快捷键 | From | to |
| ----------- | ------------- | ------------ |
| --------- | ------------- | ------------ |
| `SPC s e` | Normal/Visual | iedit-Normal |
**在 iedit-Normal 模式中:**
`iedit-Normal` 模式继承自一般模式, 下面所列举的是 `iedit-Normal` 模式专属的快捷键。
@ -1657,11 +1675,10 @@ SpaceVim uses a powerful iedit mode to quick edit multiple occurrences of a symb
| `p` | 替换所有 occurrences 为最后复制的文本 |
| `<Tab>` | toggle current occurrence |
**In iedit-Insert mode:**
| 快捷键 | 功能描述 |
| ----------- | ------------------------ |
| --------- | ------------------------ |
| `<Esc>` | 回到 `iedit-Normal` 模式 |
| `<Left>` | 左移光标 |
| `<Right>` | 右移光标 |
@ -1673,7 +1690,7 @@ SpaceVim uses a powerful iedit mode to quick edit multiple occurrences of a symb
注释 (comment) 通过工具 [nerdcommenter](https://github.com/scrooloose/nerdcommenter) 来处理,它用下面的按键来界定范围。
| 快捷键 | 功能描述 |
| ----------- | ----------------------------- |
| --------- | ----------------------------- |
| `SPC ;` | 进入注释操作模式 |
| `SPC c h` | 隐藏/显示注释 |
| `SPC c l` | 注释/反注释当前行 |
@ -1766,13 +1783,13 @@ SpaceVim 中的工程通过 vim-projectionisst 和 vim-rooter 进行管理。当
工程管理的命令以 `p` 开头:
| 快捷键 | 功能描述 |
| ----------- | ----------------------------------------------- |
| --------- | ----------------------------------------------- |
| `SPC p '` | 在当前工程的根目录打开 shell需要 shell 模块) |
#### 在工程中搜索文件
| 快捷键 | 功能描述 |
| ----------- | -------------------------------------------- |
| --------- | -------------------------------------------- |
| `SPC p f` | 在当前工程中查找文件 |
| `SPC p /` | 在当前工程中搜索文件fuzzy search for text) |
| `SPC p k` | 关闭当前工程的所有缓冲区 |
@ -1807,27 +1824,27 @@ export PATH=$PATH:$HOME/.SpaceVim/bin
### issues
Achievements | Account
----- | -----
[100th issue(issue)](https://github.com/SpaceVim/SpaceVim/issues/100) | [BenBergman](https://github.com/BenBergman)
[1000th issue(PR)](https://github.com/SpaceVim/SpaceVim/issues/1000) | [sei40kr](https://github.com/sei40kr)
[2000th issue(PR)](https://github.com/SpaceVim/SpaceVim/issues/2000) | [nikolaussucher](https://github.com/nikolaussucher)
| Achievements | Account |
| --------------------------------------------------------------------- | --------------------------------------------------- |
| [100th issue(issue)](https://github.com/SpaceVim/SpaceVim/issues/100) | [BenBergman](https://github.com/BenBergman) |
| [1000th issue(PR)](https://github.com/SpaceVim/SpaceVim/issues/1000) | [sei40kr](https://github.com/sei40kr) |
| [2000th issue(PR)](https://github.com/SpaceVim/SpaceVim/issues/2000) | [nikolaussucher](https://github.com/nikolaussucher) |
### Stars, forks and watchers
Achievements | Account
----- | -----
First stargazers | [monkeydterry](https://github.com/monkeydterry)
100th stargazers | [robertofarrell](https://github.com/robertofarrell)
1000th stargazers | [linsongze](https://github.com/linsongze)
2000th stargazers | [fated](https://github.com/fated)
3000th stargazers | [urso](https://github.com/urso)
4000th stargazers | [wanghe4096](https://github.com/wanghe4096)
5000th stargazers | [xxxxha](https://github.com/xxxxha)
6000th stargazers | [corenel](https://github.com/corenel)
7000th stargazers | [mohab1989](https://github.com/mohab1989)
8000th stargazers | [chocopowwwa](https://github.com/chocopowwwa)
9000th stargazers | [mffathurr](https://github.com/mffathurr)
| Achievements | Account |
| ----------------- | --------------------------------------------------- |
| First stargazers | [monkeydterry](https://github.com/monkeydterry) |
| 100th stargazers | [robertofarrell](https://github.com/robertofarrell) |
| 1000th stargazers | [linsongze](https://github.com/linsongze) |
| 2000th stargazers | [fated](https://github.com/fated) |
| 3000th stargazers | [urso](https://github.com/urso) |
| 4000th stargazers | [wanghe4096](https://github.com/wanghe4096) |
| 5000th stargazers | [xxxxha](https://github.com/xxxxha) |
| 6000th stargazers | [corenel](https://github.com/corenel) |
| 7000th stargazers | [mohab1989](https://github.com/mohab1989) |
| 8000th stargazers | [chocopowwwa](https://github.com/chocopowwwa) |
| 9000th stargazers | [mffathurr](https://github.com/mffathurr) |
<!-- SpaceVim Achievements end -->

View File

@ -1134,12 +1134,16 @@ Convenient key bindings are located under the prefix `SPC f v` to quickly naviga
SpaceVim uses vimfiler as the default file tree, and the default key binding is `<F3>`.
And SpaceVim also provides `SPC f t` and `SPC f T` to open the file tree.
To replace the file explorer to nerdtree:
To change the filemanager plugin:
```toml
[options]
# The default value is vimfiler.
filemanager = "nerdtree"
# file manager plugins supported in SpaceVim:
# - vimfiler (default)
# - nerdtree
# - defx
filemanager = "defx"
```
VCS integration is supported, there will be a column status, this feature maybe make vimfiler slow, so it is not enabled by default.
@ -1148,6 +1152,14 @@ Here is a picture for this feature:
![file-tree](https://user-images.githubusercontent.com/13142418/26881817-279225b2-4bcb-11e7-8872-7e4bd3d1c84e.png)
There is also an option to config the direction of file tree, by default it is right. To move the file tree to the left,
you can use `filetree_direction` option:
```toml
[options]
filetree_direction = "left"
```
##### File tree navigation
Navigation is centered on the `hjkl` keys with the hope of providing a fast navigation experience like in [vifm](https://github.com/vifm):