工具控 SpaceVim - Like spacemacs, but for vim.

wsdjeg · 发布于 2016年12月28日 · 最后由 wsdjeg 回复于 2016年12月30日 · 873 次阅读
26277

早在一年多前,我的私人配置做了修改,启用了模块化载入,不过这些模块并不是像spacemacs那样定义在不同文件中的, 而是通过vim的自身方法匹配载入的,后来看到了诸多spacemacs like vim dotfiles, 有感而发,为什么我们不可以做一个公共的框架,然后让精通不同语言的用户自己涉及自己需要的模块呢。于是,我将自己的配置 DotFiles 中vim的部分分离出来,并且放到SpaceVim组织中,希望可以将已有的各种配置进行整合。当然,默认的配置因该是最简单,适合任何人用的,这也是为了防止SpaceVim的默认配置,与用户习惯不一致。

目前项目地址是: https://github.com/SpaceVim/SpaceVim

如果有兴趣参加这个组织的,可以在仓库这一个issue 中留言。

其次, 我需要感谢:

  1. https://github.com/ctjhoa/spacevim
  2. https://github.com/Tehnix/spaceneovim

我需要感谢这两位作者所写的框架,虽然SpaceVim 注定采用和他们不一样的框架,但归结到底,原理是一致的, vim载入文件的方式,无非那么几种。

在我的配置中, 有这么一段:

"core vimrc
let g:settings.plugin_groups = []
call add(g:settings.plugin_groups, 'web')
call add(g:settings.plugin_groups, 'javascript')
call add(g:settings.plugin_groups, 'ruby')
call add(g:settings.plugin_groups, 'python')
call add(g:settings.plugin_groups, 'scala')
call add(g:settings.plugin_groups, 'go')
call add(g:settings.plugin_groups, 'scm')
call add(g:settings.plugin_groups, 'editing')
call add(g:settings.plugin_groups, 'indents')
call add(g:settings.plugin_groups, 'navigation')
call add(g:settings.plugin_groups, 'misc')

call add(g:settings.plugin_groups, 'core')
call add(g:settings.plugin_groups, 'unite')
if has('python3')
    call add(g:settings.plugin_groups, 'denite')
endif
call add(g:settings.plugin_groups, 'ctrlp')
call add(g:settings.plugin_groups, 'autocomplete')
if ! has('nvim')
    call add(g:settings.plugin_groups, 'vim')
else
    call add(g:settings.plugin_groups, 'nvim')
endif


if g:settings.vim_help_language ==# 'cn'
    call add(g:settings.plugin_groups, 'chinese')
endif
if g:settings.use_colorscheme==1
    call add(g:settings.plugin_groups, 'colorscheme')
endif
if OSX()
    call add(g:settings.plugin_groups, 'osx')
endif
if WINDOWS()
    call add(g:settings.plugin_groups, 'windows')
endif
if LINUX()
    call add(g:settings.plugin_groups, 'linux')
endif

if has('nvim')
    let g:settings.autocomplete_method = 'deoplete'
elseif has('lua')
    let g:settings.autocomplete_method = 'neocomplete'
else
    let g:settings.autocomplete_method = 'neocomplcache'
endif
if g:settings.enable_ycm
    let g:settings.autocomplete_method = 'ycm'
endif
if g:settings.enable_neocomplcache
    let g:settings.autocomplete_method = 'neocomplcache'
endif

for s:group in g:settings.plugin_groups_exclude
    let s:i = index(g:settings.plugin_groups, s:group)
    if s:i != -1
        call remove(g:settings.plugin_groups, s:i)
    endif
endfor

这也类似于spacemacs的模块化设置。

SpaceVim

Build Status

Like spacemacs, but for vim.

Features

Structure

Installl

  • vim sh mv ~/.vimrc ~/.vimrc_bak mv ~/.vim ~/.vim_bak git clone https://github.com/SpaceVim/SpaceVim.git ~/.vim
  • nvim sh git clone https://github.com/SpaceVim/SpaceVim.git ~/.config/nvim

Modular configuration

SpaceVim will load custom configuration from ~/.local.vim, here is an example:

" here are some basic customizations, please refer to the top of the vimrc file for all possible options
let g:settings.default_indent = 3
let g:settings.max_column     = 80
let g:settings.colorscheme    = 'my_awesome_colorscheme'
let g:settings.plugin_manager = 'dein'  " neobundle or dein or vim-plug

" change the default directory where all miscellaneous persistent files go
let g:settings.cache_dir = "/some/place/else"

" by default, language specific plugins are not loaded.  this can be changed with the following:
let g:settings.plugin_groups_exclude = ['ruby', 'python']

" if there are groups you want always loaded, you can use this:
let g:settings.plugin_groups_include = ['go']

" alternatively, you can set this variable to load exactly what you want
let g:settings.plugin_groups = ['core', 'web']

" if there is a particular plugin you don't like, you can define this variable to disable them entirely
let g:settings.disabled_plugins=['vim-foo', 'vim-bar']

" anything defined here are simply overrides
set wildignore+=\*/node_modules/\*
set guifont=Wingdings:h10

Unite centric work-flow

  • List all the plugins has been installed, fuzzy find what you want, default action is open the github website of current plugin. default key is <leader>lp 2016-12-29-22 31 27

  • List all the mappings and description: f<space> 2016-12-29-22 35 29

  • List all the starred repos in github.com, fuzzy find and open the website of the repo. default key is <leader>ls 2016-12-29-22 38 52

Plugin Highlights

  • Package management with caching enabled and lazy loading
  • Project-aware tabs and label
  • Vimfiler as file-manager + SSH connections
  • Go completion via vim-go and gocode
  • Javascript completion via Tern
  • PHP completion, indent, folds, syntax
  • Python jedi completion, pep8 convention
  • Languages: Ansible, css3, csv, json, less, markdown, mustache
  • Helpers: Undo tree, bookmarks, git, tmux navigation, hex editor, sessions, and much more.

Note that 90% of the plugins are lazy-loaded.

Non Lazy-Loaded Plugins

Name Description
dein.vim Dark powered Vim/Neovim plugin manager
vimproc Interactive command execution
colorschemes Awesome color-schemes
file-line Allow opening a file in a given line
neomru MRU source for Unite
cursorword Underlines word under cursor
gitbranch Lightweight git branch detection
gitgutter Shows git diffs in the gutter
tinyline Tiny great looking statusline
tagabana Central location for all tags
bookmarks Bookmarks, works independently from vim marks
tmux-navigator Seamless navigation between tmux panes and vim splits

Lazy-Loaded Plugins

Language

Name Description
html5 HTML5 omnicomplete and syntax
mustache Mustache and handlebars syntax
markdown Markdown syntax highlighting
ansible-yaml Additional support for Ansible
jinja Jinja support in vim
less Syntax for LESS
css3-syntax CSS3 syntax support to vim's built-in syntax/css.vim
csv Handling column separated data
pep8-indent Nicer Python indentation
logstash Highlights logstash configuration files
tmux vim plugin for tmux.conf
json Better JSON support
toml Syntax for TOML
i3 i3 window manager config syntax
Dockerfile syntax and snippets for Dockerfile
go Go development
jedi-vim Python jedi autocompletion library
ruby Ruby configuration files
portfile Macports portfile configuration files
javascript Enhanced Javascript syntax
javascript-indent Javascript indent script
tern Provides Tern-based JavaScript editing support
php Up-to-date PHP syntax file
phpfold PHP folding
phpcomplete Improved PHP omnicompletion
phpindent PHP official indenting
phpspec PhpSpec integration

Commands

Name Description
vimfiler Powerful file explorer
tinycomment Robust but light-weight commenting
vinarise Hex editor
syntastic Syntax checking hacks
gita An awesome git handling plugin
gista Manipulate gists in Vim
undotree Ultimate undo history visualizer
incsearch Improved incremental searching
expand-region Visually select increasingly larger regions of text
open-browser Open URI with your favorite browser
prettyprint Pretty-print vim variables
quickrun Run commands quickly
ref Integrated reference viewer
dictionary Dictionary.app interface
vimwiki Personal Wiki for Vim
thesaurus Look up words in an online thesaurus

Commands

Name Description
goyo Distraction-free writing
limelight Hyperfocus-writing
matchit Intelligent pair matching
indentline Display vertical indention lines
choosewin Choose window to use, like tmux's 'display-pane'

Completion

Name Description
delimitmate Insert mode auto-completion for quotes, parens, brackets
echodoc Print objects' documentation in echo area
deoplete Neovim: Dark powered asynchronous completion framework
neocomplete Next generation completion framework
neosnippet Contains neocomplete snippets source

Unite

Name Description
unite Unite and create user interfaces
unite-colorscheme Browse colorschemes
unite-filetype Select file type
unite-history Browse history of command/search
unite-build Build with Unite interface
unite-outline File "outline" source for unite
unite-tag Tags source for Unite
unite-quickfix Quickfix source for Unite
neossh SSH interface for plugins
unite-pull-request GitHub pull-request source for Unite
junkfile Create temporary files for memo and testing
unite-issue Issue manager for JIRA and GitHub

Operators & Text Objects

Name Description
operator-user Define your own operator easily
operator-replace Operator to replace text with register content
operator-surround Operator to enclose text objects
textobj-user Create your own text objects
textobj-multiblock Handle multiple brackets objects

Custom Key bindings

Key Mode Action
<leader>+y Normal/visual Copy selection to X11 clipboard ("+y)
<leader>+p Normal/visual Paste selection from X11 clipboard ("+p)
Ctrl+f Normal Smart page forward (C-f/C-d)
Ctrl+b Normal Smart page backwards (C-b/C-u)
Ctrl+e Normal Smart scroll down (3C-e/j)
Ctrl+y Normal Smart scroll up (3C-y/k)
Ctrl+q Normal Ctrl+w
Ctrl+x Normal Switch buffer and placement
Up,Down Normal Smart up and down
} Normal After paragraph motion go to first non-blank char (})
< Visual/Normal Indent to left and re-select
> Visual/Normal Indent to right and re-select
Tab Visual Indent to right and re-select
Shift+Tab Visual Indent to left and re-select
gp Normal Select last paste
Q/gQ Normal Disable EX-mode ()
Ctrl+a Command Navigation in command line
Ctrl+b Command Move cursor backward in command line
Ctrl+f Command Move cursor forward in command line

File Operations

Key Mode Action
<leader>+cd Normal Switch to the root directory(vim-rooter)
<leader>+w Normal/visual Write (:w)
Ctrl+s All Write (:w)
W!! Command Write as root

Editor UI

Key Mode Action
F2 All Toggle tagbar
F3 All Toggle Vimfiler
<leader>+ts Normal Toggle spell-checker (:setlocal spell!)
<leader>+tn Normal Toggle line numbers (:setlocal nonumber!)
<leader>+tl Normal Toggle hidden characters (:setlocal nolist!)
<leader>+th Normal Toggle highlighted search (:set hlsearch!)
<leader>+tw Normal Toggle wrap (:setlocal wrap! breakindent!)
g0 Normal Go to first tab (:tabfirst)
g$ Normal Go to last tab (:tablast)
gr Normal Go to preview tab (:tabprevious)
Ctrl+<Dow> Normal Move to split below (j)
Ctrl+<Up> Normal Move to upper split (k)
Ctrl+<Left> Normal Move to left split (h)
Ctrl+<Right> Normal Move to right split (l)
* Visual Search selection forwards
# Visual Search selection backwards
,+Space Normal Remove all spaces at EOL
Ctrl+r Visual Replace selection
<leader>+lj Normal Next on location list
<leader>+lk Normal Previous on location list
<leader>+S Normal/visual Source selection

Window Management

Key Mode Action
q Normal Smart buffer close
s+p Normal Split nicely
s+v Normal :split
s+g Normal :vsplit
s+t Normal Open new tab (:tabnew)
s+o Normal Close other windows (:only)
s+x Normal Remove buffer, leave blank window
s+q Normal Closes current buffer (:close)
s+Q Normal Removes current buffer (:bdelete)
Tab Normal Next window or tab
Shift+Tab Normal Previous window or tab
<leader>+sv Normal Split with previous buffer
<leader>+sg Normal Vertical split with previous buffer

Plugin: Unite

Key Mode Action
;+r Normal Resumes Unite window
;+f Normal Opens Unite file recursive search
;+i Normal Opens Unite git file search
;+g Normal Opens Unite grep with ag (the_silver_searcher)
;+u Normal Opens Unite source
;+t Normal Opens Unite tag
;+T Normal Opens Unite tag/include
;+l Normal Opens Unite location list
;+q Normal Opens Unite quick fix
;+e Normal Opens Unite register
;+j Normal Opens Unite jump, change
;+h Normal Opens Unite history/yank
;+s Normal Opens Unite session
;+o Normal Opens Unite outline
;+ma Normal Opens Unite mapping
;+me Normal Opens Unite output messages
<leader>+b Normal Opens Unite buffers, mru, bookmark
<leader>+ta Normal Opens Unite tab
<leader>+gf Normal Opens Unite file with word at cursor
<leader>+gt Normal/visual Opens Unite tag with word at cursor
<leader>+gg Visual Opens Unite navigate with word at cursor
Within Unite buffers
Ctrl+h/k/l/r Normal Un-map
Ctrl+r Normal Redraw
Ctrl+j Insert Select next line
Ctrl+k Insert Select previous line
' Normal Toggle mark current candidate, up
e Normal Run default action
Ctrl+v Normal Open in a split
Ctrl+s Normal Open in a vertical split
Ctrl+t Normal Open in a new tab
Tab Normal Ctrl+w+w
Escape Normal Exit unite
jj Insert Leave Insert mode
r Normal Replace ('search' profile) or rename
Tab Insert Unite autocompletion
Ctrl+z Normal/insert Toggle transpose window
Ctrl+w Insert Delete backward path

Plugin: VimFiler

Key Mode Action
;+e Normal Toggle file explorer
;+a Normal Toggle file explorer on current file
Within VimFiler buffers
Ctrl+j Normal Un-map
Ctrl+l Normal Un-map
E Normal Un-map
sv Normal Split edit
sg Normal Vertical split edit
p Normal Preview
i Normal Switch to directory history
Ctrl+r Normal Redraw
Ctrl+q Normal Quick look

Plugin: neocomplete

Key Mode Action
Enter Insert Smart snippet expansion
Ctrl+space Insert Autocomplete with Unite
Tab Insert/select Smart tab movement or completion
Ctrl+j/k/f/b Insert Movement in popup
Ctrl+g Insert Undo completion
Ctrl+l Insert Complete common string
Ctrl+o Insert Expand snippet
Ctrl+y Insert Close pop-up
Ctrl+e Insert Close pop-up
Ctrl+l Insert Complete common string
Ctrl+d Insert Scroll down
Ctrl+u Insert Scroll up

Plugin: TinyComment

Key Mode Action
<leader>+v Normal/visual Toggle single-line comments
<leader>+V Normal/visual Toggle comment block

Plugin: Goyo and Limelight

Key Mode Action
<leader>+G Normal Toggle distraction-free writing

Plugin: ChooseWin

Key Mode Action
- Normal Choose a window to edit
<leader>+- Normal Switch editing window with selected

Plugin: Bookmarks

Key Mode Action
m+a Normal Show list of all bookmarks
m+m Normal Toggle bookmark in current line
m+n Normal Jump to next bookmark
m+p Normal Jump to previous bookmark
m+i Normal Annotate bookmark

Plugin: Gita

Key Mode Action
<leader>+gs Normal Git status
<leader>+gd Normal Git diff
<leader>+gc Normal Git commit
<leader>+gb Normal Git blame
<leader>+gB Normal Open in browser
<leader>+gp Normal Git push

Plugin: GitGutter

Key Mode Action
<leader>+hj Normal Jump to next hunk
<leader>+hk Normal Jump to previous hunk
<leader>+hs Normal Stage hunk
<leader>+hr Normal Revert hunk
<leader>+hp Normal Preview hunk

Misc Plugins

Key Mode Action
<leader>+gu Normal Open undo tree
<leader>+i Normal Toggle indentation lines
<leader>+j Normal Start smalls
<leader>+r Normal Quickrun
<leader>+? Normal Dictionary
<leader>+W Normal Wiki
<leader>+K Normal Thesaurus

Enjoy!

共收到 14 条回复
2
huacnlee · #1 · 2016年12月29日

这个又是什么?不是同一个人么?

https://ruby-china.org/topics/31834

27
numbcoder · #2 · 2016年12月29日

#1楼 @huacnlee 另外一个轮子😅

26277
wsdjeg · #3 · 2016年12月29日

#1楼 @huacnlee 完全不是,我的配置原始仓库老早就开始搞了,只是一开始没有将vim的配置独立出来,现在独立出来,放到github组织里面搞了。

445
stephen · #4 · 2016年12月30日

建议两位作者交流下,合二为一!

7733
yukihiro_matz · #5 · 2016年12月30日

一直在用spacemacs

96
liuchengxu · #6 · 2016年12月30日

#1楼 @huacnlee #4楼 @stephen

我的语言风格显然不同~ 😭

如果没有使用过 spacemacs, 那么我想其间的理念很难一致。之所以写了 space-vim, 就是因为不太喜欢已有的 spacevim, 我觉得它在借鉴 spacemacs 的基础上不够 high level,在整体的效果上也不够漂亮与优雅。

漂亮,主观成分比较大,各凭喜好。优雅,不是繁复,复杂,亦非简单,简陋,而是简约,清丽。

俗话说,不经过调查就没有发言权。如果不使用过 spacemacs, 很难体会个中滋味。仅是从表面看,我想很难了解其细微之处。我是一个注重外表与细节体验的人,不喜欢太复杂, 更不喜欢简陋。

这只是我的个人配置,just a side project。分享出来,如果有大家喜欢,那很好,也说明其品质。如果有问题,我也期待共同讨论解决。这是一个相互学习与提高的过程,双赢的过程。

我有自己的事情,不会做与很多无用功,不会特意花很多时间消磨在这种工具上,只会按需打理。作为一个 open source project, 如果你觉得其有可重塑的价值,完全可以 fork 一份把它变成任何模样,这完全取决你自己。当然,如果你有好的想法并愿意分享,PR 也是时刻敞开的。

vim, spacemacs, IDE, 绝不冲突,解决问题才是根本。也许这些东西能够给你挣得一些 star, 但绝不是立身之本。

此外,如果观点不同,不必强求。每个人有自己的判断,不 care 的东西瞥一眼忽略即可。不要因为网络评论的成本如此低廉就随意挥洒,毫无意义。

26277
wsdjeg · #7 · 2016年12月30日

#6楼 @liuchengxu 哥们,你样样洒洒一大短话,我没看出来啥意思。 俺们是大佬粗,语文学的不好,看不太懂。 我说的很明白,我将我自己的Dotfiles分离出来,这么长时间的打磨,自然是根据我自己需求才添加的功能。大家可以看到我仓库的历史,老早就开始搞的模块话,再说了,Layer 不一定就非得按照spacemacs那样,另外,我做模块话的时候,那时和之后 我前文提到的2个仓库,甚至第二个fork的都还不存在。更别说你的项目了。你的仓库 说实话,我没看出框架和 https://github.com/ctjhoa/spacevim 以及 https://github.com/Tehnix/spaceneovim 有什么区别。倒是你的README.md 和 org 确实写的蛮好的。

26277
wsdjeg · #8 · 2016年12月30日

另外 我之所以不再自己仓库搞,而是放到组织里面,就是因为我觉得,这样的项目,不该是一个人完成的。我也不可能了解那么多种语言开发的需求。如果有兴趣,完全可以加入组织一起维护。

26277
wsdjeg · #9 · 2016年12月30日

@liuchengxu 另外,你仓库有这么一段, https://github.com/zvim/space-vim/blob/master/core/core_config.vim#L207-L257, 我没看出来和 vim-plug 这个插件里面的有啥区别, 兄弟, 做项目,咱们 不能这样。 附上 vim-plug代码 https://github.com/junegunn/vim-plug/blob/master/plug.vim#L605-L655

96
liuchengxu · #10 · 2016年12月30日

#9楼 @wsdjeg 天下文章一大抄,看你会抄不会抄。除了这个点,我还抄了很多, 什么人都有,你可以再仔细看看,说不定还抄了你的呢。 希望你能看得出来。

statusline 我也是 steal 了 vim-plug 的作者 junegunn,我还给他提了一个 issue, 你可以看这里 https://github.com/junegunn/vim-emoji/issues/23。后来 statusline 又抄了 https://github.com/sk1418/myConf/blob/master/common/.vimrc ,你可以看这里 https://www.v2ex.com/t/330610#reply24, 我也告诉了他 KentY 这招是从他那里 “偷学” 来的。

这种事情不是学术剽窃,而是自由分享,其他人完全可以 “拿来主义”。就像别人可以完全抽取 space-vim 的部分内容,作为自己的配置。只要你会抄,完全 OK.

我的时间不会浪费在这种琐碎的事情上. "做项目" ?恐怕你看的太重了,这仅仅是一个 vim 配置而已。等到有类似 spacemacs 那样的影响力再说也不迟。至于是否有必要放到组织里做件事,你可以去问一下 syl20bnr.

观点不同,看法不一,就此打住,不再回复。

24996
lilijreey · #11 · 2016年12月30日

弱弱的问一句, Emacs我个人最喜欢的是‘主模式/副模式概念’ 像是一把武器不同场景加载不同配置。 vim就没有,layout不错直至感觉该不够, 另外问下layout的加载机制是通过什么实现的?

26277
wsdjeg · #12 · 2016年12月30日

#10楼 @liuchengxu 你早该打住呢,如果不感兴趣,就不要样样洒洒的说一大断。自然会有兴趣的人。

26277
wsdjeg · #13 · 2016年12月30日

#11楼 @lilijreey 我的vim配置已经实现了这样的功能,支持全局用户配置,和就当前项目局部配置。

26277
wsdjeg · #14 · 2016年12月30日

#1楼 @huacnlee 我希望能有熟悉 vim ruby开发的用户,提供一些建议,主要是补全,重构方面的配置

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册