diff --git a/.SpaceVim.d/autoload/SpaceVim/dev/layers.vim b/.SpaceVim.d/autoload/SpaceVim/dev/layers.vim new file mode 100644 index 000000000..3e4a9ef0e --- /dev/null +++ b/.SpaceVim.d/autoload/SpaceVim/dev/layers.vim @@ -0,0 +1,44 @@ +function! SpaceVim#dev#layers#update() abort + + let [start, end] = s:find_position() + if start != 0 && end != 0 + if end - start > 1 + exe (start + 1) . ',' . (end - 1) . 'delete' + endif + call append(start, s:generate_content()) + silent! Neoformat + endif + +endfunction + +function! s:find_position() abort + let start = search('^$','bwnc') + let end = search('^$','bnwc') + return sort([start, end]) +endfunction + +function! s:generate_content() abort + let content = ['', '## Available layers', ''] + let content += s:layer_list() + return content +endfunction + +function! s:layer_list() abort + let layers = SpaceVim#util#globpath('~/.SpaceVim/', "docs/layers/**/*.md") + let list = [ + \ '| Name | Description |', + \ '| ---------- | ------------ |' + \ ] + for layer in layers + let name = split(layer, '/docs/layers')[1][:-4] . '/' + let url = 'https://spacevim.org/layers' . name + let content = readfile(layer) + if len(content) > 3 + let line = '| [' . join(split(name, '/'), '#') . '](' . url . ') | ' . content[2][14:-2] . ' | ' + else + let line = '| [' . join(split(name, '/'), '#') . '](' . url . ') | can not find Description |' + endif + call add(list, line) + endfor + return list +endfunction diff --git a/.ci/after_failure.sh b/.ci/after_failure.sh index ca758e464..19cc7786e 100755 --- a/.ci/after_failure.sh +++ b/.ci/after_failure.sh @@ -11,8 +11,10 @@ if [ "$TRAVIS_PULL_REQUEST" != "false" ] ; then git clone https://github.com/wsdjeg/GitHub.vim.git build/GitHub.vim docker run -it --rm \ -v $PWD/.ci:/.ci \ + -v $PWD/autoload/SpaceVim/api:/API/autoload/SpaceVim/api \ + -v $PWD/autoload/SpaceVim/api.vim:/API/autoload/SpaceVim/api.vim \ -v $PWD/build:/build \ - spacevim/vims neovim-stable -u .ci/common/github_commenter.vim + spacevim/vims neovim-stable -u /.ci/common/github_commenter.vim rm build_log fi elif [ "$LINT" = "vint-errors" ] ; then @@ -25,8 +27,10 @@ if [ "$TRAVIS_PULL_REQUEST" != "false" ] ; then git clone https://github.com/wsdjeg/GitHub.vim.git build/GitHub.vim docker run -it --rm \ -v $PWD/.ci:/.ci \ + -v $PWD/autoload/SpaceVim/api:/API/autoload/SpaceVim/api \ + -v $PWD/autoload/SpaceVim/api.vim:/API/autoload/SpaceVim/api.vim \ -v $PWD/build:/build \ - spacevim/vims neovim-stable -u .ci/common/github_commenter.vim + spacevim/vims neovim-stable -u /.ci/common/github_commenter.vim rm build_log fi elif [ "$LINT" = "vader" ] ; then diff --git a/.ci/after_success.sh b/.ci/after_success.sh index e69de29bb..91f5dfa2a 100755 --- a/.ci/after_success.sh +++ b/.ci/after_success.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +if [ "$TRAVIS_PULL_REQUEST" != "false" ] ; then + if [ "$LINT" = "vimlint-errors" ] ; then + VIMLINT_LOG="" + git clone https://github.com/wsdjeg/GitHub.vim.git build/GitHub.vim + docker run -it --rm \ + -v $PWD/.ci:/.ci \ + -v $PWD/autoload/SpaceVim/api:/API/autoload/SpaceVim/api \ + -v $PWD/autoload/SpaceVim/api.vim:/API/autoload/SpaceVim/api.vim \ + -v $PWD/build:/build \ + spacevim/vims neovim-stable -u /.ci/common/github_commenter.vim + elif [ "$LINT" = "vint-errors" ] ; then + VIMLINT_LOG="" + git clone https://github.com/wsdjeg/GitHub.vim.git build/GitHub.vim + docker run -it --rm \ + -v $PWD/.ci:/.ci \ + -v $PWD/autoload/SpaceVim/api:/API/autoload/SpaceVim/api \ + -v $PWD/autoload/SpaceVim/api.vim:/API/autoload/SpaceVim/api.vim \ + -v $PWD/build:/build \ + spacevim/vims neovim-stable -u /.ci/common/github_commenter.vim + elif [ "$LINT" = "vader" ] ; then + echo "" + fi +fi diff --git a/.ci/common/github_commenter.vim b/.ci/common/github_commenter.vim index 0885e967d..c09cd6fe6 100644 --- a/.ci/common/github_commenter.vim +++ b/.ci/common/github_commenter.vim @@ -1,8 +1,8 @@ exe 'set nocp' -set rtp+=build/GitHub.vim -so build/GitHub.vim/plugin/github.vim -so build/GitHub.vim/autoload/github/api/issues.vim -so build/GitHub.vim/autoload/github/api/util.vim +set rtp+=/build/GitHub.vim +set rtp+=/API +so /build/GitHub.vim/plugin/github.vim +let s:LIST = SpaceVim#api#import('data#list') let s:log = filereadable('build_log') ? system('cat build_log') : '' function! s:update_log(log, summary, new_log) abort let log = split(a:log, "\n") @@ -16,8 +16,12 @@ function! s:update_log(log, summary, new_log) abort let end = i endif endfor - return a:log . "\n" . a:new_log - + if begin != -1 && end != -1 + return s:LIST.replace(log, begin, end, split(a:new_log, "\n")) + else + return a:log . "\n" . a:new_log + endif + endfunction if !empty(s:log) if $LINT == 'vader' @@ -44,5 +48,26 @@ if !empty(s:log) \ {'body': s:update_log(s:comment.body, s:summary, s:log)}, 'SpaceVimBot', $BOTSECRET) endif endif +else + if $LINT == 'vader' + let s:summary = $VIM . ' ' . $LINT . ' build log' + else + let s:summary = $LINT . ' build log' + endif + let s:log = '
' . s:summary . "\n" . s:log . "\n
" + let s:comments = github#api#issues#List_comments('SpaceVim', 'SpaceVim',$TRAVIS_PULL_REQUEST ,'') + if !empty(s:comments) + let s:nr = 0 + for s:comment in s:comments + if s:comment.user.login ==# 'SpaceVimBot' + let s:nr = s:comment.id + break + endif + endfor + if s:nr != 0 + call github#api#issues#Edit_comment('SpaceVim','SpaceVim', s:nr, + \ {'body': s:update_log(s:comment.body, s:summary, s:log)}, 'SpaceVimBot', $BOTSECRET) + endif + endif endif quit diff --git a/.ci/script.sh b/.ci/script.sh index 13ba8ae53..bfc4ea4bb 100755 --- a/.ci/script.sh +++ b/.ci/script.sh @@ -12,9 +12,9 @@ elif [ "$LINT" = "vimlint-errors" ]; then fi for file in $(git diff --name-only HEAD dev | grep .vim$); do - /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser $file >> build_log; + /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser $file >> build_log 2>&1; done - if [[ -f build_log ]]; then + if [[ -s build_log ]]; then cat build_log exit 2 fi diff --git a/README.md b/README.md index ea50e308b..a608f8928 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ SpaceVim is a community-driven vim distribution that supports vim and Neovim. S Please star the project on github - it is a great way to show your appreciation while providing us motivation to continue working on this project. The extra visibility for the project doesn't hurt either! -![welcome-page](https://cloud.githubusercontent.com/assets/13142418/26402270/28ad72b8-40bc-11e7-945e-003f41e057be.png) +![welcome-page](https://user-images.githubusercontent.com/13142418/33793078-3446cb6e-dc76-11e7-9998-376a355557a4.png) See the [documentation](https://spacevim.org/documentation) or [the list of layers](http://spacevim.org/layers/) for more information. @@ -28,6 +28,20 @@ Here is a throughput graph of the repository for the last few weeks: [![Throughput Graph](https://graphs.waffle.io/SpaceVim/SpaceVim/throughput.svg)](https://waffle.io/SpaceVim/SpaceVim/metrics/throughput) + + +- [Requirements](#requirements) +- [Install](#install) + - [Linux and macOS](#linux-and-macos) + - [Windows](#windows) +- [Project layout](#project-layout) +- [Features](#features) +- [Blogs](#blogs) +- [Support SpaceVim](#support-spacevim) +- [Credits & Thanks](#credits--thanks) + + + ### Requirements At a minimum, SpaceVim requires `git` to be installed. For a better graphical experience, install [nerd-font](https://github.com/ryanoasis/nerd-fonts) and make sure your terminal supports [true colors](https://gist.github.com/XVilka/8346728). @@ -68,15 +82,25 @@ The easist way is to download [install.cmd](https://spacevim.org/install.cmd) an - **Great documentation:** access documentation in Vim with SPC h SPC. ![SPC h SPC](https://user-images.githubusercontent.com/13142418/31620230-48b53eea-b2c9-11e7-90d0-b717878875d4.gif) -- **Beautiful GUI:** you'll love the awesome UI and its useful features. +- **Beautiful UI:** you'll love the awesome UI and its useful features. + ![beautiful UI](https://user-images.githubusercontent.com/13142418/33804722-bc241f50-dd70-11e7-8dd8-b45827c0019c.png) - **Mnemonic key bindings:** all key bindings have mnemonic prefixes. ![mapping guide](https://user-images.githubusercontent.com/13142418/31550099-c8173ff8-b062-11e7-967e-6378a9c3b467.gif) -- **Describe key bindings:** use SPC h d k to describe key bindings. - ![describe key](https://user-images.githubusercontent.com/13142418/32134986-060a3b8a-bc2a-11e7-89a2-3ee4e616bf06.gif) +- **Describe key bindings:** use SPC h d k to describe key bindings, and find definition of key bindings. + ![describe key](https://user-images.githubusercontent.com/13142418/33804739-52dbc498-dd71-11e7-97e5-ed0fa6ec1719.gif) - **Lazy load plugins:** Lazy-load 90% of plugins with [dein.vim](https://github.com/Shougo/dein.vim) ![UI for dein](https://user-images.githubusercontent.com/13142418/31309093-36c01150-abb3-11e7-836c-3ad406bdd71a.gif) +- **Awesome statusline:** a heavily customized modular statusline. + ![statusline](https://user-images.githubusercontent.com/13142418/33804880-b9177142-dd73-11e7-82d5-1780dc27e7e3.png) - **Neovim centric:** Dark powered mode of SpaceVim +### Blogs + +- [Use Vim as a Java IDE](http://spacevim.org/use-vim-as-a-java-ide/) +- [An async code runner in SpaceVim](http://spacevim.org/async-code-runner-in-SpaceVim/) + +More posts are in the [SpaceVim's Blog](https://spacevim.org/blog/) + ### Support SpaceVim The best way to support SpaceVim is to contribute to it either by reporting bugs, helping the community on the Gitter Chat or sending pull requests. diff --git a/autoload/SpaceVim.vim b/autoload/SpaceVim.vim index 85fdaf71d..610245ea4 100644 --- a/autoload/SpaceVim.vim +++ b/autoload/SpaceVim.vim @@ -98,7 +98,7 @@ let g:spacevim_realtime_leader_guide = 1 " let g:spacevim_enable_key_frequency = 1 " < let g:spacevim_enable_key_frequency = 0 -if has('python3') +if has('python3') && SpaceVim#util#haspyxlib('neovim') "" " Set the autocomplete engine of spacevim, the default logic is: " > @@ -195,7 +195,7 @@ let g:spacevim_statusline_inactive_separator = 'arrow' " \ 'version control info' " \ ] " < -let g:spacevim_statusline_left_sections = ['winnr', 'filename', 'major mode', 'syntax checking', 'minor mode lighters', 'version control info'] +let g:spacevim_statusline_left_sections = ['winnr', 'filename', 'major mode', 'syntax checking', 'minor mode lighters', 'version control info', 'hunks'] "" " Define the right section of statusline in active windows. By default: " > @@ -254,11 +254,13 @@ let g:spacevim_warning_symbol = '⚠' " < let g:spacevim_info_symbol = '🛈' "" -" Set the SpaceVim cursor shape in the terminal. Set to 0 to prevent Nvim from -" changing the cursor shape. Set to 1 to enable non-blinking mode-sensitive -" cursor (this is the default). Set to 2 to enable blinking mode-sensitive -" cursor. Host terminal must support the DECSCUSR CSI escape sequence. -" +" Set the SpaceVim cursor shape in the terminal. +" > +" 0 : to prevent Nvim from changing the cursor shape. +" 1 : to enable non-blinking mode-sensitive cursor. +" 2 : to enable blinking mode-sensitive cursor (default). +" > +" Host terminal must support the DECSCUSR CSI escape sequence. " Depending on the terminal emulator, using this option with nvim under " tmux might require adding the following to ~/.tmux.conf: " > @@ -428,7 +430,17 @@ let g:spacevim_enable_vimfiler_gitstatus = 0 " Enable/Disable filetypeicon column in vimfiler buffer, default is 0. let g:spacevim_enable_vimfiler_filetypeicon = 0 let g:spacevim_smartcloseignorewin = ['__Tagbar__' , 'vimfiler:default'] -let g:spacevim_smartcloseignoreft = ['help', 'tagbar', 'vimfiler', 'SpaceVimRunner', 'SpaceVimQuickFix', 'HelpDescribe'] +let g:spacevim_smartcloseignoreft = [ + \ 'help', + \ 'tagbar', + \ 'vimfiler', + \ 'SpaceVimRunner', + \ 'SpaceVimREPL', + \ 'SpaceVimQuickFix', + \ 'HelpDescribe', + \ 'VebuggerShell', + \ 'VebuggerTerminal', + \ ] let g:spacevim_altmoveignoreft = ['Tagbar' , 'vimfiler'] let g:spacevim_enable_javacomplete2_py = 0 let g:spacevim_src_root = 'E:\sources\' @@ -637,6 +649,8 @@ function! SpaceVim#end() abort set norelativenumber endif + let &shiftwidth = g:spacevim_default_indent + if g:spacevim_realtime_leader_guide nnoremap :LeaderGuide get(g:, 'mapleader', '\') vnoremap :LeaderGuideVisual get(g:, 'mapleader', '\') diff --git a/autoload/SpaceVim/api/bash/complete.vim b/autoload/SpaceVim/api/bash/complete.vim index 816586861..a52f02137 100644 --- a/autoload/SpaceVim/api/bash/complete.vim +++ b/autoload/SpaceVim/api/bash/complete.vim @@ -7,7 +7,7 @@ let s:COP = SpaceVim#api#import('vim#compatible') " this is for vim command completion function! s:self.complete(ArgLead, CmdLine, CursorPos) abort - if a:CmdLine =~ '^[^ ]*$' + if a:CmdLine =~ '^\s\{0,\}\w\+$' return s:COP.systemlist('compgen -c ' . a:CmdLine) endif let result = s:COP.systemlist([s:completer, a:CmdLine]) @@ -18,7 +18,7 @@ endfunction " this is for vim input() function! s:self.complete_input(ArgLead, CmdLine, CursorPos) abort - if a:CmdLine =~ '^[^ ]*$' + if a:CmdLine =~ '^\s\{0,\}\w\+$' return s:COP.systemlist('compgen -c ' . a:CmdLine) endif let result = s:COP.systemlist([s:completer, a:CmdLine]) diff --git a/autoload/SpaceVim/api/data/list.vim b/autoload/SpaceVim/api/data/list.vim index dfe247a40..888948978 100644 --- a/autoload/SpaceVim/api/data/list.vim +++ b/autoload/SpaceVim/api/data/list.vim @@ -10,6 +10,7 @@ function! SpaceVim#api#data#list#get() abort \ 'has' : '', \ 'has_index' : '', \ 'listpart' : '', + \ 'replace' : '', \ }, \ "function('s:' . v:key)" \ ) @@ -101,4 +102,12 @@ function! s:has_index(list, index) abort return 0 <= a:index && a:index < len(a:list) endfunction +function! s:replace(list, begin, end, re_list) + if a:begin <= a:end && a:begin >= 0 && a:end < len(a:list) + return a:list[:a:begin - 1] + a:re_list + a:list[a:end + 1:] + else + return a:list + endif +endf + " vim:set et sw=2 cc=80: diff --git a/autoload/SpaceVim/api/file.vim b/autoload/SpaceVim/api/file.vim index c97cee22d..688a9b7e3 100644 --- a/autoload/SpaceVim/api/file.vim +++ b/autoload/SpaceVim/api/file.vim @@ -28,7 +28,7 @@ let s:file_node_extensions = { \ 'json' : '', \ 'js' : '', \ 'jsx' : '', - \ 'rb' : '', + \ 'rb' : '', \ 'php' : '', \ 'py' : '', \ 'pyc' : '', diff --git a/autoload/SpaceVim/api/job.vim b/autoload/SpaceVim/api/job.vim index d07fa4511..026c194c2 100644 --- a/autoload/SpaceVim/api/job.vim +++ b/autoload/SpaceVim/api/job.vim @@ -190,7 +190,11 @@ function! s:self.send(id, data) abort if has_key(self.jobs, a:id) let job = get(self.jobs, a:id) let chanel = job_getchannel(job) - call ch_sendraw(chanel, a:data . "\n") + if type(a:data) == type('') + call ch_sendraw(chanel, a:data . "\n") + else + call ch_sendraw(chanel, join(a:data, "\n")) + endif else call self.warn('No job with such id') endif diff --git a/autoload/SpaceVim/api/transient_state.vim b/autoload/SpaceVim/api/transient_state.vim index 10bda30f7..7709cc5b8 100644 --- a/autoload/SpaceVim/api/transient_state.vim +++ b/autoload/SpaceVim/api/transient_state.vim @@ -4,217 +4,239 @@ let s:self._keys = {} let s:self._on_syntax = '' let s:self._title = 'Transient State' let s:self._handle_inputs = {} +let s:self._is_quit = [] function! s:self.open() abort - noautocmd botright split __transient_state__ - let self._bufid = bufnr('%') - setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline nospell nonu norelativenumber - set filetype=TransientState - " let save_tve = &t_ve - " setlocal t_ve= - " setlocal nomodifiable - " setf SpaceVimFlyGrep - " let &t_ve = save_tve - if !empty(self._on_syntax) && type(self._on_syntax) ==# 2 - call call(self._on_syntax, []) + noautocmd botright split __transient_state__ + let self._bufid = bufnr('%') + setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline nospell nonu norelativenumber + set filetype=TransientState + " let save_tve = &t_ve + " setlocal t_ve= + " setlocal nomodifiable + " setf SpaceVimFlyGrep + " let &t_ve = save_tve + if !empty(self._on_syntax) && type(self._on_syntax) ==# 2 + call call(self._on_syntax, []) + else + hi def link SpaceVim_Transient_State_Exit Keyword + hi def link SpaceVim_Transient_State_Notexit Number + hi def link SpaceVim_Transient_State_Title Title + endif + call setline(1, self._title) + let b:transient_state_title = self._title + call append(line('$'), '') + call self.highlight_title() + call self._update_content() + call append(line('$'), '') + call append(line('$'), '[KEY] exits state [KEY] will not exit') + call self.highlight_keys(1, line('$') - 1, 1, 4) + call self.highlight_keys(0, line('$') - 1, 21, 24) + if winheight(0) > line('$') + exe 'resize ' . line('$') + endif + " move to prvious window + wincmd p + while 1 + redraw! + let char = self._getchar() + if char ==# "\" || char ==# "\" || char2nr(char) == 128 + continue + endif + if !has_key(self._handle_inputs, char) + break else - hi def link SpaceVim_Transient_State_Exit Keyword - hi def link SpaceVim_Transient_State_Notexit Number - hi def link SpaceVim_Transient_State_Title Title + if type(self._handle_inputs[char]) == 2 + call call(self._handle_inputs[char], []) + elseif type(self._handle_inputs[char]) == 1 + exe self._handle_inputs[char] + endif endif - call setline(1, self._title) - let b:transient_state_title = self._title - call append(line('$'), '') - call self.highlight_title() - call self._update_content() - call append(line('$'), '') - call append(line('$'), '[KEY] exits state [KEY] will not exit') - call self.highlight_keys(1, line('$') - 1, 1, 4) - call self.highlight_keys(0, line('$') - 1, 21, 24) - if winheight(0) > line('$') - exe 'resize ' . line('$') + if index(self._is_quit, char) != -1 + break endif - " move to prvious window - wincmd p - while 1 - redraw! - let char = self._getchar() - if char ==# "\" || char ==# "\" || char2nr(char) == 128 - continue - endif - if !has_key(self._handle_inputs, char) - break - else - if type(self._handle_inputs[char]) == 2 - call call(self._handle_inputs[char], []) - elseif type(self._handle_inputs[char]) == 1 - exe self._handle_inputs[char] - endif - endif - endwhile - exe 'bd ' . self._bufid - doautocmd WinEnter + endwhile + exe 'bd ' . self._bufid + doautocmd WinEnter endfunction + function! s:self._getchar(...) abort - let ret = call('getchar', a:000) - return (type(ret) == type(0) ? nr2char(ret) : ret) + let ret = call('getchar', a:000) + return (type(ret) == type(0) ? nr2char(ret) : ret) endfunction function! s:self.defind_keys(dict) abort - let self._keys = a:dict + let self._keys = a:dict endfunction function! s:self.set_syntax(func) abort - let self._on_syntax = a:func + let self._on_syntax = a:func endfunction function! s:self.set_title(title) abort - let self._title = a:title + let self._title = a:title endfunction if has('nvim') - function! s:self.highlight_keys(exit, line, begin, end) abort - if a:exit - call nvim_buf_add_highlight(self._bufid, 0, 'SpaceVim_Transient_State_Exit', a:line, a:begin, a:end) - else - call nvim_buf_add_highlight(self._bufid, 0, 'SpaceVim_Transient_State_Notexit', a:line, a:begin, a:end) - endif - endfunction + function! s:self.highlight_keys(exit, line, begin, end) abort + if a:exit + call nvim_buf_add_highlight(self._bufid, 0, 'SpaceVim_Transient_State_Exit', a:line, a:begin, a:end) + else + call nvim_buf_add_highlight(self._bufid, 0, 'SpaceVim_Transient_State_Notexit', a:line, a:begin, a:end) + endif + endfunction else - function! s:self.highlight_keys(exit, line, begin, end) abort - if a:exit - call matchaddpos('SpaceVim_Transient_State_Exit', [[a:line + 1, a:begin + 1, a:end - a:begin]]) - else - call matchaddpos('SpaceVim_Transient_State_Notexit', [[a:line + 1, a:begin + 1, a:end - a:begin]]) - endif - endfunction + function! s:self.highlight_keys(exit, line, begin, end) abort + if a:exit + call matchaddpos('SpaceVim_Transient_State_Exit', [[a:line + 1, a:begin + 1, a:end - a:begin]]) + else + call matchaddpos('SpaceVim_Transient_State_Notexit', [[a:line + 1, a:begin + 1, a:end - a:begin]]) + endif + endfunction endif if has('nvim') - function! s:self.highlight_title() abort - call nvim_buf_add_highlight(self._bufid, 0, 'SpaceVim_Transient_State_Title', 0, 0, len(self._title)) - endfunction + function! s:self.highlight_title() abort + call nvim_buf_add_highlight(self._bufid, 0, 'SpaceVim_Transient_State_Title', 0, 0, len(self._title)) + endfunction else - function! s:self.highlight_title() abort - call matchaddpos('SpaceVim_Transient_State_Title', [1]) - endfunction + function! s:self.highlight_title() abort + call matchaddpos('SpaceVim_Transient_State_Title', [1]) + endfunction endif function! s:self._update_content() abort - if get(self._keys, 'layout', '') == 'vertical split' - let linenum = max([len(self._keys.right), len(self._keys.left)]) - let left_max_key_len = 0 - for key in self._keys.left - if type(key.key) == 1 " is a string - let left_max_key_len = max([len(key.key), left_max_key_len]) - elseif type(key.key) == 3 " is a list - let left_max_key_len = max([len(join(key.key, '/')), left_max_key_len]) - elseif type(key.key) == 4 " is a dict - let left_max_key_len = max([len(key.key.name), left_max_key_len]) - endif - endfor - let right_max_key_len = 0 - for key in self._keys.right - if type(key.key) == 1 " is a string - let right_max_key_len = max([len(key.key), right_max_key_len]) - elseif type(key.key) == 3 " is a list - let g:wsd = key.key - let right_max_key_len = max([len(join(key.key, '/')), right_max_key_len]) - elseif type(key.key) == 4 " is a dict - let right_max_key_len = max([len(key.key.name), right_max_key_len]) - endif - endfor - for i in range(linenum) - let left = get(self._keys.left, i) - let right = get(self._keys.right, i) - let line = '' - if !empty(left) - if type(left.key) == 1 - let line .= '[' . left.key . '] ' . repeat(' ', left_max_key_len - len(left.key)) . left.desc - call self.highlight_keys(left.exit, i + 2, 1, 1 + len(left.key)) - if !empty(left.cmd) - call extend(self._handle_inputs, {left.key : left.cmd}) - elseif !empty(left.func) - call extend(self._handle_inputs, {left.key : left.func}) - endif - elseif type(left.key) == 3 - let line .= '[' . join(left.key, '/') . '] ' - let line .= repeat(' ', left_max_key_len - len(join(left.key, '/'))) - let line .= left.desc - let begin = 1 - for key in left.key - call self.highlight_keys(left.exit, i + 2, begin, begin + len(key)) - let begin = begin + len(key) + 1 - endfor - if !empty(left.cmd) - for key in left.key - call extend(self._handle_inputs, {key : left.cmd}) - endfor - elseif !empty(left.func) - for key in left.key - call extend(self._handle_inputs, {key : left.func}) - endfor - endif - elseif type(left.key) == 4 - let line .= '[' . left.key.name . '] ' - let line .= repeat(' ', left_max_key_len - len(left.key.name)) - let line .= left.desc - for pos in left.key.pos - call self.highlight_keys(left.exit, i + 2, pos[0], pos[1]) - endfor - for handles in left.key.handles - call extend(self._handle_inputs, {handles[0] : handles[1]}) - endfor - endif - endif - let line .= repeat(' ', 40 - len(line)) - if !empty(right) - if type(right.key) == 1 - let line .= '[' . right.key . '] ' . repeat(' ', right_max_key_len - len(right.key)) . right.desc - call self.highlight_keys(right.exit, i + 2, 41, 41 + len(right.key)) - if !empty(right.cmd) - call extend(self._handle_inputs, {right.key : right.cmd}) - elseif !empty(right.func) - call extend(self._handle_inputs, {right.key : right.func}) - endif - elseif type(right.key) == 3 - let line .= '[' . join(right.key, '/') . '] ' - let line .= repeat(' ', right_max_key_len - len(join(right.key, '/'))) - let line .= right.desc - let begin = 41 - for key in right.key - call self.highlight_keys(right.exit, i + 2, begin, begin + len(key)) - let begin = begin + len(key) + 1 - endfor - if !empty(right.cmd) - for key in right.key - call extend(self._handle_inputs, {key : right.cmd}) - endfor - elseif !empty(right.func) - for key in right.key - call extend(self._handle_inputs, {key : right.func}) - endfor - endif - elseif type(right.key) == 4 - let line .= '[' . right.key.name . '] ' - let line .= repeat(' ', right_max_key_len - len(right.key.name)) - let line .= right.desc - let begin = 41 - for pos in right.key.pos - call self.highlight_keys(right.exit, i + 2, begin + pos[0], begin + pos[1]) - endfor - for handles in right.key.handles - call extend(self._handle_inputs, {handles[0] : handles[1]}) - endfor - endif - endif - call append(line('$'), line) - endfor - endif + if get(self._keys, 'layout', '') == 'vertical split' + let linenum = max([len(self._keys.right), len(self._keys.left)]) + let left_max_key_len = 0 + for key in self._keys.left + if type(key.key) == 1 " is a string + let left_max_key_len = max([len(key.key), left_max_key_len]) + elseif type(key.key) == 3 " is a list + let left_max_key_len = max([len(join(key.key, '/')), left_max_key_len]) + elseif type(key.key) == 4 " is a dict + let left_max_key_len = max([len(key.key.name), left_max_key_len]) + endif + endfor + let right_max_key_len = 0 + for key in self._keys.right + if type(key.key) == 1 " is a string + let right_max_key_len = max([len(key.key), right_max_key_len]) + elseif type(key.key) == 3 " is a list + let right_max_key_len = max([len(join(key.key, '/')), right_max_key_len]) + elseif type(key.key) == 4 " is a dict + let right_max_key_len = max([len(key.key.name), right_max_key_len]) + endif + endfor + for i in range(linenum) + let left = get(self._keys.left, i) + let right = get(self._keys.right, i) + let line = '' + if !empty(left) + if type(left.key) == 1 + let line .= '[' . left.key . '] ' . repeat(' ', left_max_key_len - len(left.key)) . left.desc + call self.highlight_keys(left.exit, i + 2, 1, 1 + len(left.key)) + if !empty(left.cmd) + call extend(self._handle_inputs, {left.key : left.cmd}) + elseif !empty(left.func) + call extend(self._handle_inputs, {left.key : left.func}) + endif + if left.exit + call add(self._is_quit, left.key) + endif + elseif type(left.key) == 3 + let line .= '[' . join(left.key, '/') . '] ' + let line .= repeat(' ', left_max_key_len - len(join(left.key, '/'))) + let line .= left.desc + let begin = 1 + for key in left.key + call self.highlight_keys(left.exit, i + 2, begin, begin + len(key)) + let begin = begin + len(key) + 1 + endfor + if !empty(left.cmd) + for key in left.key + call extend(self._handle_inputs, {key : left.cmd}) + endfor + elseif !empty(left.func) + for key in left.key + call extend(self._handle_inputs, {key : left.func}) + endfor + endif + if left.exit + call extend(self._is_quit, left.key) + endif + elseif type(left.key) == 4 + let line .= '[' . left.key.name . '] ' + let line .= repeat(' ', left_max_key_len - len(left.key.name)) + let line .= left.desc + for pos in left.key.pos + call self.highlight_keys(left.exit, i + 2, pos[0], pos[1]) + endfor + for handles in left.key.handles + call extend(self._handle_inputs, {handles[0] : handles[1]}) + endfor + if left.exit + call extend(self._is_quit, keys(left.key)) + endif + endif + endif + let line .= repeat(' ', 40 - len(line)) + if !empty(right) + if type(right.key) == 1 + let line .= '[' . right.key . '] ' . repeat(' ', right_max_key_len - len(right.key)) . right.desc + call self.highlight_keys(right.exit, i + 2, 41, 41 + len(right.key)) + if !empty(right.cmd) + call extend(self._handle_inputs, {right.key : right.cmd}) + elseif !empty(right.func) + call extend(self._handle_inputs, {right.key : right.func}) + endif + if right.exit + call add(self._is_quit, right.key) + endif + elseif type(right.key) == 3 + let line .= '[' . join(right.key, '/') . '] ' + let line .= repeat(' ', right_max_key_len - len(join(right.key, '/'))) + let line .= right.desc + let begin = 41 + for key in right.key + call self.highlight_keys(right.exit, i + 2, begin, begin + len(key)) + let begin = begin + len(key) + 1 + endfor + if !empty(right.cmd) + for key in right.key + call extend(self._handle_inputs, {key : right.cmd}) + endfor + elseif !empty(right.func) + for key in right.key + call extend(self._handle_inputs, {key : right.func}) + endfor + endif + if right.exit + call extend(self._is_quit, right.key) + endif + elseif type(right.key) == 4 + let line .= '[' . right.key.name . '] ' + let line .= repeat(' ', right_max_key_len - len(right.key.name)) + let line .= right.desc + let begin = 41 + for pos in right.key.pos + call self.highlight_keys(right.exit, i + 2, begin + pos[0], begin + pos[1]) + endfor + for handles in right.key.handles + call extend(self._handle_inputs, {handles[0] : handles[1]}) + endfor + if right.exit + call extend(self._is_quit, keys(right.key)) + endif + endif + endif + call append(line('$'), line) + endfor + endif endfunction function! SpaceVim#api#transient_state#get() abort - return deepcopy(s:self) + return deepcopy(s:self) endfunction diff --git a/autoload/SpaceVim/api/vim/signatures.vim b/autoload/SpaceVim/api/vim/signatures.vim new file mode 100644 index 000000000..b8aff723e --- /dev/null +++ b/autoload/SpaceVim/api/vim/signatures.vim @@ -0,0 +1,30 @@ +let s:self = {} +let s:self.id = [] +function! s:self.info(line, col, message) abort + let chars = SpaceVim#api#import('data#string').string2chars(a:message) + for index in range(len(chars)) + call add(self.id, matchaddpos('Conceal', [[a:line, a:col - 1 + index, 1]], 10, -1, {'conceal' : chars[index]})) + endfor +endfunction + + +function! s:self.set_group(group) abort + let self.group = a:group + exe 'highlight ' . self.group . ' ctermbg=green guibg=green' +endfunction + +call s:self.set_group('SpaceVim_signatures') + +function! s:self.clear() abort + for id in self.id + call matchdelete(id) + endfor + let self.id = [] +endfunction + + +function! SpaceVim#api#vim#signatures#get() + + return deepcopy(s:self) + +endfunction diff --git a/autoload/SpaceVim/api/vim/statusline.vim b/autoload/SpaceVim/api/vim/statusline.vim index 019da8572..f09628452 100644 --- a/autoload/SpaceVim/api/vim/statusline.vim +++ b/autoload/SpaceVim/api/vim/statusline.vim @@ -1,48 +1,83 @@ let s:self = {} -function! s:self.build(left_sections, right_sections, lsep, rsep, fname, hi_a, hi_b, hi_c, hi_z) abort - let l = '%#' . a:hi_a . '#' . a:left_sections[0] - let l .= '%#' . a:hi_a . '_' . a:hi_b . '#' . a:lsep - let flag = 1 - for sec in filter(a:left_sections[1:], '!empty(v:val)') - if flag == 1 - let l .= '%#' . a:hi_b . '#' . sec - let l .= '%#' . a:hi_b . '_' . a:hi_c . '#' . a:lsep - else - let l .= '%#' . a:hi_c . '#' . sec - let l .= '%#' . a:hi_c . '_' . a:hi_b . '#' . a:lsep - endif - let flag = flag * -1 - endfor - let l = l[:len(a:lsep) * -1 - 1] - if empty(a:right_sections) - if flag == 1 - return l . '%#' . a:hi_c . '#' - else - return l . '%#' . a:hi_b . '#' - endif +function! s:self.check_width(len, sec, winwidth) abort + return a:len + self.len(a:sec) < a:winwidth +endfunction + +function! s:self.len(sec) abort + let str = matchstr(a:sec, '%{.*}') + if !empty(str) + return len(a:sec) - len(str) + len(eval(str[2:-2])) + 4 + else + return len(a:sec) + 4 + endif +endfunction + +function! s:self.eval(sec) abort + return substitute(a:sec, '%{.*}', '', 'g') +endfunction + +function! s:self.build(left_sections, right_sections, lsep, rsep, fname, hi_a, hi_b, hi_c, hi_z, winwidth) abort + let l = '%#' . a:hi_a . '#' . a:left_sections[0] + let l .= '%#' . a:hi_a . '_' . a:hi_b . '#' . a:lsep + let flag = 1 + let len = 0 + for sec in filter(a:left_sections[1:], '!empty(v:val)') + if self.check_width(len, sec, a:winwidth) + let len += self.len(sec) + if flag == 1 + let l .= '%#' . a:hi_b . '#' . sec + let l .= '%#' . a:hi_b . '_' . a:hi_c . '#' . a:lsep + else + let l .= '%#' . a:hi_c . '#' . sec + let l .= '%#' . a:hi_c . '_' . a:hi_b . '#' . a:lsep + endif + let flag = flag * -1 endif + endfor + let l = l[:len(a:lsep) * -1 - 1] + if empty(a:right_sections) if flag == 1 - let l .= '%#' . a:hi_c . '_' . a:hi_z . '#' . a:lsep . a:fname . '%=' + return l . '%#' . a:hi_c . '#' else - let l .= '%#' . a:hi_b . '_' . a:hi_z . '#' . a:lsep . a:fname . '%=' + return l . '%#' . a:hi_b . '#' endif - let l .= '%#' . a:hi_b . '_' . a:hi_z . '#' . a:rsep - let flag = 1 - for sec in filter(a:right_sections, '!empty(v:val)') - if flag == 1 - let l .= '%#' . a:hi_b . '#' . sec - let l .= '%#' . a:hi_c . '_' . a:hi_b . '#' . a:rsep - else - let l .= '%#' . a:hi_c . '#' . sec - let l .= '%#' . a:hi_b . '_' . a:hi_c . '#' . a:rsep - endif - let flag = flag * -1 - endfor - return l[:-4] + endif + if self.check_width(len, a:fname, a:winwidth) + let len += self.len(a:fname) + if flag == 1 + let l .= '%#' . a:hi_c . '_' . a:hi_z . '#' . a:lsep . a:fname . '%=' + else + let l .= '%#' . a:hi_b . '_' . a:hi_z . '#' . a:lsep . a:fname . '%=' + endif + else + if flag == 1 + let l .= '%#' . a:hi_c . '_' . a:hi_z . '#' . a:lsep . '%=' + else + let l .= '%#' . a:hi_b . '_' . a:hi_z . '#' . a:lsep . '%=' + endif + endif + let l .= '%#' . a:hi_b . '_' . a:hi_z . '#' . a:rsep + let flag = 1 + for sec in filter(a:right_sections, '!empty(v:val)') + if self.check_width(len, sec, a:winwidth) + let len += self.len(sec) + if flag == 1 + let l .= '%#' . a:hi_b . '#' . sec + let l .= '%#' . a:hi_c . '_' . a:hi_b . '#' . a:rsep + else + let l .= '%#' . a:hi_c . '#' . sec + let l .= '%#' . a:hi_b . '_' . a:hi_c . '#' . a:rsep + endif + let flag = flag * -1 + endif + endfor + return l[:-4] endfunction function! SpaceVim#api#vim#statusline#get() abort - return deepcopy(s:self) + return deepcopy(s:self) endfunction + +" vim:set et sw=2 cc=80 nowrap: diff --git a/autoload/SpaceVim/issue.vim b/autoload/SpaceVim/issue.vim index 4ba569065..812afbcf0 100644 --- a/autoload/SpaceVim/issue.vim +++ b/autoload/SpaceVim/issue.vim @@ -45,7 +45,6 @@ function! SpaceVim#issue#new() \ 'body' : join(getline(1, '$'), "\n"), \ } let response = github#api#issues#Create('SpaceVim', 'SpaceVim', username, password, issue) - let g:wsd = response if has_key(response, 'html_url') echo 'Issue created done: ' . response.html_url else diff --git a/autoload/SpaceVim/layers/autocomplete.vim b/autoload/SpaceVim/layers/autocomplete.vim index 802446238..590318b40 100644 --- a/autoload/SpaceVim/layers/autocomplete.vim +++ b/autoload/SpaceVim/layers/autocomplete.vim @@ -110,13 +110,23 @@ function! SpaceVim#layers#autocomplete#config() abort if s:tab_key_behavior ==# 'smart' if has('patch-7.4.774') imap SpaceVim#mapping#tab() - smap - \ neosnippet#expandable_or_jumpable() ? - \ "\(neosnippet_expand_or_jump)" : - \ (complete_parameter#jumpable(1) ? - \ "\(complete_parameter#goto_next_parameter)" : - \ "\") - imap SpaceVim#mapping#shift_tab() + if g:spacevim_snippet_engine ==# 'neosnippet' + smap + \ neosnippet#expandable_or_jumpable() ? + \ "\(neosnippet_expand_or_jump)" : + \ (complete_parameter#jumpable(1) ? + \ "\(complete_parameter#goto_next_parameter)" : + \ "\") + imap SpaceVim#mapping#shift_tab() + elseif g:spacevim_snippet_engine ==# 'ultisnips' + imap SpaceVim#mapping#tab() + imap SpaceVim#mapping#shift_tab() + snoremap + \ :call UltiSnips#JumpForwards() + snoremap + \ :call UltiSnips#JumpBackwards() + else + endif else call SpaceVim#logger#warn('smart tab in autocomplete layer need patch 7.4.774') endif diff --git a/autoload/SpaceVim/layers/chat.vim b/autoload/SpaceVim/layers/chat.vim index 418ef14fb..d4c8d7f59 100644 --- a/autoload/SpaceVim/layers/chat.vim +++ b/autoload/SpaceVim/layers/chat.vim @@ -4,7 +4,14 @@ function! SpaceVim#layers#chat#plugins() abort \ ] endfunction +let s:BASE64 = SpaceVim#api#import('data#base64') function! SpaceVim#layers#chat#config() + let g:chatting_server_ip = s:BASE64.decode('NDUuNzYuMTAwLjQ5') + let g:chatting_server_port = 8989 + if !exists('g:chatting_server_lib') + let g:chatting_server_lib = '/home/wsdjeg/SpaceVim/Chatting-server/target/Chatting-1.0-SNAPSHOT.jar' + endif call SpaceVim#mapping#space#def('nnoremap', ['a', 'q'], 'call chat#qq#start()', 'Start QQ server', 1) + call SpaceVim#mapping#space#def('nnoremap', ['a', 'o'], 'call chat#chatting#OpenMsgWin()', 'open spacevim community', 1) endfunction diff --git a/autoload/SpaceVim/layers/checkers.vim b/autoload/SpaceVim/layers/checkers.vim index e388a0dcc..9d7eb0bd2 100644 --- a/autoload/SpaceVim/layers/checkers.vim +++ b/autoload/SpaceVim/layers/checkers.vim @@ -3,6 +3,8 @@ " @parentsection layers " SpaceVim uses neomake as default syntax checker. +let s:SIG = SpaceVim#api#import('vim#signatures') +let s:STRING = SpaceVim#api#import('data#string') function! SpaceVim#layers#checkers#plugins() abort let plugins = [] @@ -19,6 +21,9 @@ endfunction function! SpaceVim#layers#checkers#config() abort + let g:neomake_cursormoved_delay = get(g:, 'neomake_cursormoved_delay', 300) + let g:ale_echo_delay = get(g:, 'ale_echo_delay', 300) + call SpaceVim#mapping#space#def('nnoremap', ['e', 'c'], 'call call(' \ . string(s:_function('s:clear_errors')) . ', [])', \ 'clear all errors', 1) @@ -38,14 +43,72 @@ function! SpaceVim#layers#checkers#config() abort augroup SpaceVim_layer_checker autocmd! - if g:spacevim_enable_neomake - autocmd User NeomakeFinished nested let &l:statusline = SpaceVim#layers#core#statusline#get(1) + if g:spacevim_enable_neomake + autocmd User NeomakeFinished nested + \ let &l:statusline = SpaceVim#layers#core#statusline#get(1) + + " when move cursor, the error message will be shown below current line + " after a delay + autocmd CursorMoved * call neomake_cursor_move_delay() + + " when switch to Insert mode, stop timer and clear the signature + if exists('##CmdLineEnter') + autocmd InsertEnter,WinLeave,CmdLineEnter * + \ call neomake_signatures_clear() + autocmd CmdLineEnter * + \ call neomake_signatures_clear() | redraw + else + autocmd InsertEnter,WinLeave * call neomake_signatures_clear() + endif elseif g:spacevim_enable_ale - autocmd User ALELint let &l:statusline = SpaceVim#layers#core#statusline#get(1) + autocmd User ALELint + \ let &l:statusline = SpaceVim#layers#core#statusline#get(1) endif augroup END endfunction +function! s:neomake_cursor_move_delay() abort + call s:neomake_signatures_clear() + let s:neomake_cursormoved_timer = timer_start(g:neomake_cursormoved_delay, + \ function('s:neomake_signatures_current_error')) +endfunction + +let s:last_echoed_error = '' +let s:clv = &conceallevel +function! s:neomake_signatures_current_error(...) abort + call s:neomake_signatures_clear() + try + let message = neomake#GetCurrentErrorMsg() + catch /^Vim\%((\a\+)\)\=:E117/ + let message = '' + endtry + if empty(message) + if exists('s:last_echoed_error') + unlet s:last_echoed_error + endif + return + endif + if exists('s:last_echoed_error') + \ && s:last_echoed_error == message + return + endif + let s:last_echoed_error = message + set conceallevel=2 + if len(line('.') + 1) > len(message) + let message = s:STRING.fill(message, len(line('.') + 1)) + endif + call s:SIG.info(line('.') + 1, 1, message) +endfunction + +function! s:neomake_signatures_clear() abort + if exists('s:neomake_cursormoved_timer') && s:neomake_cursormoved_timer != 0 + call timer_stop(s:neomake_cursormoved_timer) + endif + let s:last_echoed_error = '' + let &conceallevel = s:clv + call s:SIG.clear() +endfunction + function! s:verify_syntax_setup() abort if g:spacevim_enable_neomake NeomakeInfo @@ -56,13 +119,15 @@ endfunction function! s:error_transient_state() abort if g:spacevim_enable_neomake - let has_errors = neomake#statusline#LoclistCounts() + let num_errors = neomake#statusline#LoclistCounts() elseif g:spacevim_enable_ale - let has_errors = '' + let counts = ale#statusline#Count(buffer_name('%')) + let num_errors = counts.error + counts.warning + counts.style_error + \ + counts.style_warning else - let has_errors = '' + let num_errors = 0 endif - if empty(has_errors) + if empty(num_errors) echo 'no buffers contain error message locations' return endif diff --git a/autoload/SpaceVim/layers/core/statusline.vim b/autoload/SpaceVim/layers/core/statusline.vim index 754275e3e..c746b40b9 100644 --- a/autoload/SpaceVim/layers/core/statusline.vim +++ b/autoload/SpaceVim/layers/core/statusline.vim @@ -72,6 +72,9 @@ let s:loaded_sections = ['syntax checking', 'major mode', 'minor mode lighters', let s:loaded_sections_r = g:spacevim_statusline_right_sections let s:loaded_sections_l = g:spacevim_statusline_left_sections +let [s:lsep , s:rsep] = get(s:separators, g:spacevim_statusline_separator, s:separators['arrow']) +let [s:ilsep , s:irsep] = get(s:i_separators, g:spacevim_statusline_inactive_separator, s:i_separators['arrow']) + " build in sections for SpaceVim statusline function! s:winnr(...) abort if a:0 > 1 @@ -131,7 +134,7 @@ function! s:git_branch() abort call fugitive#detect(getcwd()) let l:head = fugitive#head() endif - return empty(l:head) ? '' : '  '.l:head . ' ' + return empty(l:head) ? '' : '  '.l:head . ' ' endif return '' endfunction @@ -151,7 +154,7 @@ endfunction function! s:date() abort return ' ' . s:TIME.current_date() . ' ' - + endfunction function! s:whitespace() abort @@ -222,6 +225,25 @@ else endfunction endif +function! s:hunks() abort + let hunks = [0,0,0] + try + let hunks = GitGutterGetHunkSummary() + catch + endtry + let rst = '' + if hunks[0] > 0 + let rst .= hunks[0] . '+ ' + endif + if hunks[1] > 0 + let rst .= hunks[1] . '~ ' + endif + if hunks[2] > 0 + let rst .= hunks[2] . '- ' + endif + return empty(rst) ? '' : ' ' . rst +endfunction + let s:registed_sections = { \ 'winnr' : function('s:winnr'), \ 'syntax checking' : function('s:syntax_checking'), @@ -230,6 +252,7 @@ let s:registed_sections = { \ 'major mode' : function('s:major_mode'), \ 'minor mode lighters' : function('s:modes'), \ 'version control info' : function('s:git_branch'), + \ 'hunks' : function('s:hunks'), \ 'cursorpos' : function('s:cursorpos'), \ 'percentage' : function('s:percentage'), \ 'time' : function('s:time'), @@ -293,6 +316,9 @@ function! s:filesize() abort endfunction function! SpaceVim#layers#core#statusline#get(...) abort + for nr in range(1, winnr('$')) + call setwinvar(nr, 'winwidth', winwidth(nr)) + endfor if &filetype ==# 'vimfiler' return '%#SpaceVim_statusline_ia#' . s:winnr(1) . '%#SpaceVim_statusline_ia_SpaceVim_statusline_b#' . s:lsep \ . '%#SpaceVim_statusline_b# vimfiler %#SpaceVim_statusline_b_SpaceVim_statusline_c#' . s:lsep @@ -328,10 +354,18 @@ function! SpaceVim#layers#core#statusline#get(...) abort return '%#SpaceVim_statusline_a# HelpDescribe %#SpaceVim_statusline_a_SpaceVim_statusline_b#' elseif &filetype ==# 'SpaceVimRunner' return '%#SpaceVim_statusline_a# Runner %#SpaceVim_statusline_a_SpaceVim_statusline_b# %{SpaceVim#plugins#runner#status()}' + elseif &filetype ==# 'SpaceVimREPL' + return '%#SpaceVim_statusline_a# REPL %#SpaceVim_statusline_a_SpaceVim_statusline_b# %{SpaceVim#plugins#repl#status()}' elseif &filetype ==# 'VimMailClient' return '%#SpaceVim_statusline_a# VimMail %#SpaceVim_statusline_a_SpaceVim_statusline_b# %{mail#client#win#status().dir}' elseif &filetype ==# 'SpaceVimQuickFix' return '%#SpaceVim_statusline_a# SpaceVimQuickFix %#SpaceVim_statusline_a_SpaceVim_statusline_b#' + elseif &filetype ==# 'VebuggerShell' + return '%#SpaceVim_statusline_ia#' . s:winnr(1) . '%#SpaceVim_statusline_ia_SpaceVim_statusline_b#' . s:lsep + \ . '%#SpaceVim_statusline_b# VebuggerShell %#SpaceVim_statusline_b_SpaceVim_statusline_c#' . s:lsep + elseif &filetype ==# 'VebuggerTerminal' + return '%#SpaceVim_statusline_ia#' . s:winnr(1) . '%#SpaceVim_statusline_ia_SpaceVim_statusline_b#' . s:lsep + \ . '%#SpaceVim_statusline_b# VebuggerTerminal %#SpaceVim_statusline_b_SpaceVim_statusline_c#' . s:lsep endif if a:0 > 0 return s:active() @@ -355,19 +389,25 @@ function! s:active() abort endfor let fname = s:buffer_name() return s:STATUSLINE.build(lsec, rsec, s:lsep, s:rsep, fname, - \ 'SpaceVim_statusline_a', 'SpaceVim_statusline_b', 'SpaceVim_statusline_c', 'SpaceVim_statusline_z') + \ 'SpaceVim_statusline_a', 'SpaceVim_statusline_b', 'SpaceVim_statusline_c', 'SpaceVim_statusline_z', winwidth(winnr())) endfunction function! s:inactive() abort - return '%#SpaceVim_statusline_ia#' . s:winnr() . '%#SpaceVim_statusline_ia_SpaceVim_statusline_b#' . s:lsep - \ . '%#SpaceVim_statusline_b#' . s:filename() . s:ilsep - \ . ' ' . &filetype . ' ' . s:ilsep - \ . s:modes() . s:ilsep - \ . s:git_branch() . s:ilsep - \ . ' %=' - \ . s:irsep . '%{" " . &ff . "|" . (&fenc!=""?&fenc:&enc) . " "}' - \ . s:irsep . ' %P ' + let l = '%#SpaceVim_statusline_ia#' . s:winnr() . '%#SpaceVim_statusline_ia_SpaceVim_statusline_b#' . s:lsep . '%#SpaceVim_statusline_b#' + let secs = [s:filename(), &filetype, s:modes(), s:git_branch()] + let base = 10 + for sec in secs + let len = s:STATUSLINE.len(sec) + let base += len + let l .= '%{ get(w:, "winwidth", 150) < ' . base . ' ? "" : (" ' . s:STATUSLINE.eval(sec) . ' ' . s:ilsep . '")}' + endfor + if get(w:, 'winwidth', 150) > base + 10 + let l .= join(['%=', '%{" " . &ff . "|" . (&fenc!=""?&fenc:&enc) . " "}', ' %P '], s:irsep) + endif + return l endfunction + + function! s:gitgutter() abort if exists('b:gitgutter_summary') let l:summary = get(b:, 'gitgutter_summary') @@ -456,8 +496,6 @@ function! SpaceVim#layers#core#statusline#rsep() endfunction function! SpaceVim#layers#core#statusline#config() abort - let [s:lsep , s:rsep] = get(s:separators, g:spacevim_statusline_separator, s:separators['arrow']) - let [s:ilsep , s:irsep] = get(s:i_separators, g:spacevim_statusline_inactive_separator, s:i_separators['arrow']) call SpaceVim#mapping#space#def('nnoremap', ['t', 'm', 'm'], 'call SpaceVim#layers#core#statusline#toggle_section("minor mode lighters")', \ 'toggle the minor mode lighters', 1) call SpaceVim#mapping#space#def('nnoremap', ['t', 'm', 'v'], 'call SpaceVim#layers#core#statusline#toggle_section("version control info")', @@ -474,10 +512,12 @@ function! SpaceVim#layers#core#statusline#config() abort \ 'toggle the cursor position', 1) call SpaceVim#mapping#space#def('nnoremap', ['t', 'm', 'T'], 'if &laststatus == 2 | let &laststatus = 0 | else | let &laststatus = 2 | endif', \ 'toggle the statuline itself', 1) + call SpaceVim#mapping#space#def('nnoremap', ['t', 'm', 'h'], 'call SpaceVim#layers#core#statusline#toggle_section("hunks")', + \ 'toggle the hunks summary', 1) function! TagbarStatusline(...) abort let name = (strwidth(a:3) > (g:spacevim_sidebar_width - 15)) ? a:3[:g:spacevim_sidebar_width - 20] . '..' : a:3 return s:STATUSLINE.build([s:winnr(),' Tagbar ', ' ' . name . ' '], [], s:lsep, s:rsep, '', - \ 'SpaceVim_statusline_ia', 'SpaceVim_statusline_b', 'SpaceVim_statusline_c', 'SpaceVim_statusline_z') + \ 'SpaceVim_statusline_ia', 'SpaceVim_statusline_b', 'SpaceVim_statusline_c', 'SpaceVim_statusline_z', g:spacevim_sidebar_width) endfunction let g:tagbar_status_func = 'TagbarStatusline' let g:unite_force_overwrite_statusline = 0 @@ -509,7 +549,7 @@ endfunction function! SpaceVim#layers#core#statusline#ctrlp(focus, byfname, regex, prev, item, next, marked) abort return s:STATUSLINE.build([' Ctrlp ', ' ' . a:prev . ' ', ' ' . a:item . ' ', ' ' . a:next . ' '], \ [' ' . a:focus . ' ', ' ' . a:byfname . ' ', ' ' . getcwd() . ' '], s:lsep, s:rsep, '', - \ 'SpaceVim_statusline_a_bold', 'SpaceVim_statusline_b', 'SpaceVim_statusline_c', 'SpaceVim_statusline_z') + \ 'SpaceVim_statusline_a_bold', 'SpaceVim_statusline_b', 'SpaceVim_statusline_c', 'SpaceVim_statusline_z', winwidth(winnr())) endfunction " @vimlint(EVL103, 0, a:regex) " @vimlint(EVL103, 0, a:marked) @@ -519,7 +559,7 @@ endfunction function! SpaceVim#layers#core#statusline#ctrlp_status(str) abort return s:STATUSLINE.build([' Ctrlp ', ' ' . a:str . ' '], \ [' ' . getcwd() . ' '], s:lsep, s:rsep, '', - \ 'SpaceVim_statusline_a', 'SpaceVim_statusline_b', 'SpaceVim_statusline_c', 'SpaceVim_statusline_z') + \ 'SpaceVim_statusline_a', 'SpaceVim_statusline_b', 'SpaceVim_statusline_c', 'SpaceVim_statusline_z', winwidth(winnr())) endfunction function! SpaceVim#layers#core#statusline#jump(i) abort @@ -591,14 +631,14 @@ endfunction function! SpaceVim#layers#core#statusline#register_sections(name, func) - if has_key(s:registed_sections, a:name) - call SpaceVim#logger#info('statusline build-in section ' . a:name . ' has been changed!') - call extend(s:registed_sections, {a:name : a:func}) - else - call extend(s:registed_sections, {a:name : a:func}) - endif + if has_key(s:registed_sections, a:name) + call SpaceVim#logger#info('statusline build-in section ' . a:name . ' has been changed!') + call extend(s:registed_sections, {a:name : a:func}) + else + call extend(s:registed_sections, {a:name : a:func}) + endif endfunction -" vim:set et sw=2 cc=80: +" vim:set et sw=2 cc=80 nowrap: diff --git a/autoload/SpaceVim/layers/core/tabline.vim b/autoload/SpaceVim/layers/core/tabline.vim index fa93cfffe..51a0b2d5d 100644 --- a/autoload/SpaceVim/layers/core/tabline.vim +++ b/autoload/SpaceVim/layers/core/tabline.vim @@ -22,188 +22,240 @@ let s:buffers = s:BUFFER.listed_buffers() " init let s:separators = { - \ 'arrow' : ["\ue0b0", "\ue0b2"], - \ 'curve' : ["\ue0b4", "\ue0b6"], - \ 'slant' : ["\ue0b8", "\ue0ba"], - \ 'brace' : ["\ue0d2", "\ue0d4"], - \ 'fire' : ["\ue0c0", "\ue0c2"], - \ 'nil' : ['', ''], - \ } + \ 'arrow' : ["\ue0b0", "\ue0b2"], + \ 'curve' : ["\ue0b4", "\ue0b6"], + \ 'slant' : ["\ue0b8", "\ue0ba"], + \ 'brace' : ["\ue0d2", "\ue0d4"], + \ 'fire' : ["\ue0c0", "\ue0c2"], + \ 'nil' : ['', ''], + \ } let s:i_separators = { - \ 'arrow' : ["\ue0b1", "\ue0b3"], - \ 'bar' : ["|", "|"], - \ 'nil' : ['', ''], - \ } + \ 'arrow' : ["\ue0b1", "\ue0b3"], + \ 'bar' : ["|", "|"], + \ 'nil' : ['', ''], + \ } function! s:tabname(id) abort - if g:spacevim_buffer_index_type == 3 - let id = s:messletters.index_num(a:id) - elseif g:spacevim_buffer_index_type == 4 - let id = a:id - else - let id = s:messletters.bubble_num(a:id, g:spacevim_buffer_index_type) . ' ' - endif - let fn = fnamemodify(bufname(a:id), ':t') - if g:spacevim_enable_tabline_filetype_icon - let icon = s:file.fticon(fn) - if !empty(icon) - let fn = icon . ' ' . fn - endif - endif - if empty(fn) - return 'No Name' - else - return id . fn + if g:spacevim_buffer_index_type == 3 + let id = s:messletters.index_num(a:id) + elseif g:spacevim_buffer_index_type == 4 + let id = a:id + else + let id = s:messletters.bubble_num(a:id, g:spacevim_buffer_index_type) . ' ' + endif + let fn = fnamemodify(bufname(a:id), ':t') + if g:spacevim_enable_tabline_filetype_icon + let icon = s:file.fticon(fn) + if !empty(icon) + let fn = icon . ' ' . fn endif + endif + if empty(fn) + return 'No Name' + else + return id . fn + endif endfunction function! s:need_show_bfname(stack, nr) abort - let dupbufs = filter(a:stack, "fnamemodify(bufname(v:val), ':t') ==# fnamemodify(bufname(a:nr), ':t')") - if len(dupbufs) >= 2 - for i in dupbufs - call setbufvar(i, '_spacevim_statusline_showbfname', 1) - endfor - endif + let dupbufs = filter(a:stack, "fnamemodify(bufname(v:val), ':t') ==# fnamemodify(bufname(a:nr), ':t')") + if len(dupbufs) >= 2 + for i in dupbufs + call setbufvar(i, '_spacevim_statusline_showbfname', 1) + endfor + endif +endfunction + +function! s:is_modified(nr) abort + return getbufvar(a:nr, '&modified', 0) endfunction function! SpaceVim#layers#core#tabline#get() abort - let nr = tabpagenr('$') - let t = '' - " the stack should be the bufnr stack of tabline - let stack = [] - if nr > 1 - let ct = tabpagenr() - if ct == 1 - let t = '%#SpaceVim_tabline_a# ' - else - let t = '%#SpaceVim_tabline_b# ' - endif - for i in range(1, nr) - if i == ct - let t .= '%#SpaceVim_tabline_a#' - endif - let buflist = tabpagebuflist(i) - let winnr = tabpagewinnr(i) - let name = fnamemodify(bufname(buflist[winnr - 1]), ':t') - if empty(name) - let name = 'No Name' - endif - call add(stack, buflist[winnr - 1]) - call s:need_show_bfname(stack, buflist[winnr - 1]) - if g:spacevim_buffer_index_type == 3 - let id = s:messletters.index_num(i) - elseif g:spacevim_buffer_index_type == 4 - let id = i - else - let id = s:messletters.circled_num(i, g:spacevim_buffer_index_type) - endif - if g:spacevim_enable_tabline_filetype_icon - let icon = s:file.fticon(name) - if !empty(icon) - let name = icon . ' ' . name - endif - endif - let t .= id . ' ' . name - if i == ct - 1 - let t .= ' %#SpaceVim_tabline_b_SpaceVim_tabline_a#' . s:lsep . ' ' - elseif i == ct - let t .= ' %#SpaceVim_tabline_a_SpaceVim_tabline_b#' . s:lsep . ' ' - else - let t .= ' ' . s:ilsep . ' ' - endif - endfor - let t .= '%=%#SpaceVim_tabline_a_SpaceVim_tabline_b#' . s:rsep - let t .= '%#SpaceVim_tabline_a# Tabs ' + let nr = tabpagenr('$') + let t = '' + " the stack should be the bufnr stack of tabline + let stack = [] + if nr > 1 + let ct = tabpagenr() + if ct == 1 + let t = '%#SpaceVim_tabline_a# ' else - let s:buffers = s:BUFFER.listed_buffers() - let g:_spacevim_list_buffers = s:buffers - if len(s:buffers) == 0 - return '' - endif - let ct = bufnr('%') - let pt = index(s:buffers, ct) > 0 ? s:buffers[index(s:buffers, ct) - 1] : -1 - if ct == get(s:buffers, 0, -1) - let t = '%#SpaceVim_tabline_a# ' - else - let t = '%#SpaceVim_tabline_b# ' - endif - for i in s:buffers - if i == ct - let t .= '%#SpaceVim_tabline_a#' - endif - let name = fnamemodify(bufname(i), ':t') - if empty(name) - let name = 'No Name' - endif - call add(stack, i) - call s:need_show_bfname(stack, i) - if g:spacevim_buffer_index_type == 3 - let id = s:messletters.index_num(index(s:buffers, i) + 1) - elseif g:spacevim_buffer_index_type == 4 - let id = index(s:buffers, i) + 1 - else - let id = s:messletters.circled_num(index(s:buffers, i) + 1, g:spacevim_buffer_index_type) - endif - if g:spacevim_enable_tabline_filetype_icon - let icon = s:file.fticon(name) - if !empty(icon) - let name = icon . ' ' . name - endif - endif - let t .= id . ' ' . name - if i == ct - let t .= ' %#SpaceVim_tabline_a_SpaceVim_tabline_b#' . s:lsep . ' ' - elseif i == pt - let t .= ' %#SpaceVim_tabline_b_SpaceVim_tabline_a#' . s:lsep . ' ' - else - let t .= ' ' . s:ilsep . ' ' - endif - endfor - let t .= '%=%#SpaceVim_tabline_a_SpaceVim_tabline_b#' . s:rsep - let t .= '%#SpaceVim_tabline_a# Buffers ' + let t = '%#SpaceVim_tabline_b# ' endif - return t + for i in range(1, nr) + if i == ct + let t .= '%#SpaceVim_tabline_a#' + endif + let buflist = tabpagebuflist(i) + let winnr = tabpagewinnr(i) + let name = fnamemodify(bufname(buflist[winnr - 1]), ':t') + if empty(name) + let name = 'No Name' + endif + call add(stack, buflist[winnr - 1]) + call s:need_show_bfname(stack, buflist[winnr - 1]) + if g:spacevim_buffer_index_type == 3 + let id = s:messletters.index_num(i) + elseif g:spacevim_buffer_index_type == 4 + let id = i + else + let id = s:messletters.circled_num(i, g:spacevim_buffer_index_type) + endif + if g:spacevim_enable_tabline_filetype_icon + let icon = s:file.fticon(name) + if !empty(icon) + let name = icon . ' ' . name + endif + endif + let t .= id . ' ' . name + if i == ct - 1 + let t .= ' %#SpaceVim_tabline_b_SpaceVim_tabline_a#' . s:lsep . ' ' + elseif i == ct + let t .= ' %#SpaceVim_tabline_a_SpaceVim_tabline_b#' . s:lsep . ' ' + else + let t .= ' ' . s:ilsep . ' ' + endif + endfor + let t .= '%=%#SpaceVim_tabline_a_SpaceVim_tabline_b#' . s:rsep + let t .= '%#SpaceVim_tabline_a# Tabs ' + else + let s:buffers = s:BUFFER.listed_buffers() + let g:_spacevim_list_buffers = s:buffers + if len(s:buffers) == 0 + return '' + endif + let ct = bufnr('%') + let pt = index(s:buffers, ct) > 0 ? s:buffers[index(s:buffers, ct) - 1] : -1 + if ct == get(s:buffers, 0, -1) + if getbufvar(ct, '&modified', 0) + let t = '%#SpaceVim_tabline_m# ' + else + let t = '%#SpaceVim_tabline_a# ' + endif + else + let t = '%#SpaceVim_tabline_b# ' + endif + let index = 1 + for i in s:buffers + if getbufvar(i, '&modified', 0) && i != ct + let t .= '%#SpaceVim_tabline_m_i#' + elseif i == ct + if s:is_modified(i) + let t .= '%#SpaceVim_tabline_m#' + else + let t .= '%#SpaceVim_tabline_a#' + endif + else + let t .= '%#SpaceVim_tabline_b#' + endif + let name = fnamemodify(bufname(i), ':t') + if empty(name) + let name = 'No Name' + endif + call add(stack, i) + call s:need_show_bfname(stack, i) + " here is the begin of a tab name + if has('tablineat') + let t .= '%' . index . '@SpaceVim#layers#core#tabline#jump@' + endif + if g:spacevim_buffer_index_type == 3 + let id = s:messletters.index_num(index(s:buffers, i) + 1) + elseif g:spacevim_buffer_index_type == 4 + let id = index(s:buffers, i) + 1 + else + let id = s:messletters.circled_num(index(s:buffers, i) + 1, g:spacevim_buffer_index_type) + endif + if g:spacevim_enable_tabline_filetype_icon + let icon = s:file.fticon(name) + if !empty(icon) + let name = icon . ' ' . name + endif + endif + let t .= id . ' ' . name + " here is the end of a tabname + if has('tablineat') + let t .= '%X' + endif + if i == ct + if s:is_modified(i) + let t .= ' %#SpaceVim_tabline_m_SpaceVim_tabline_b#' . s:lsep . ' ' + else + let t .= ' %#SpaceVim_tabline_a_SpaceVim_tabline_b#' . s:lsep . ' ' + endif + elseif i == pt + if getbufvar(ct, '&modified', 0) + let t .= ' %#SpaceVim_tabline_b_SpaceVim_tabline_m#' . s:lsep . ' ' + else + let t .= ' %#SpaceVim_tabline_b_SpaceVim_tabline_a#' . s:lsep . ' ' + endif + else + let t .= ' %#SpaceVim_tabline_b#' . s:ilsep . ' ' + endif + let index += 1 + endfor + let t .= '%=%#SpaceVim_tabline_a_SpaceVim_tabline_b#' . s:rsep + let t .= '%#SpaceVim_tabline_a# Buffers ' + endif + return t endfunction function! SpaceVim#layers#core#tabline#config() abort - let [s:lsep , s:rsep] = get(s:separators, g:spacevim_statusline_separator, s:separators['arrow']) - let [s:ilsep , s:irsep] = get(s:i_separators, g:spacevim_statusline_inactive_separator, s:separators['arrow']) - set tabline=%!SpaceVim#layers#core#tabline#get() - augroup SpaceVim_tabline - autocmd! - autocmd ColorScheme * call SpaceVim#layers#core#tabline#def_colors() - augroup END - for i in range(1, 9) - exe "call SpaceVim#mapping#def('nmap ', '" . i - \ . "', ':call SpaceVim#layers#core#tabline#jump(" - \ . i . ")', 'Switch to airline tab " . i - \ . "', '', 'tabline index " . i . "')" - endfor - call SpaceVim#mapping#def('nmap', '-', ':bprevious', 'Switch to previous airline tag', '', 'window previous') - call SpaceVim#mapping#def('nmap', '+', ':bnext', 'Switch to next airline tag', '', 'window next') - "call SpaceVim#mapping#space#def('nmap', ['-'], 'bprevious', 'window previous', 1) - "call SpaceVim#mapping#space#def('nmap', ['+'], 'bnext', 'window next', 1) + let [s:lsep , s:rsep] = get(s:separators, g:spacevim_statusline_separator, s:separators['arrow']) + let [s:ilsep , s:irsep] = get(s:i_separators, g:spacevim_statusline_inactive_separator, s:separators['arrow']) + set tabline=%!SpaceVim#layers#core#tabline#get() + augroup SpaceVim_tabline + autocmd! + autocmd ColorScheme * call SpaceVim#layers#core#tabline#def_colors() + augroup END + for i in range(1, 9) + exe "call SpaceVim#mapping#def('nmap ', '" . i + \ . "', ':call SpaceVim#layers#core#tabline#jump(" + \ . i . ")', 'Switch to airline tab " . i + \ . "', '', 'tabline index " . i . "')" + endfor + call SpaceVim#mapping#def('nmap', '-', ':bprevious', 'Switch to previous airline tag', '', 'window previous') + call SpaceVim#mapping#def('nmap', '+', ':bnext', 'Switch to next airline tag', '', 'window next') + "call SpaceVim#mapping#space#def('nmap', ['-'], 'bprevious', 'window previous', 1) + "call SpaceVim#mapping#space#def('nmap', ['+'], 'bnext', 'window next', 1) endfunction -function! SpaceVim#layers#core#tabline#jump(id) abort +function! SpaceVim#layers#core#tabline#jump(id, ...) abort + if get(a:000, 2, '') == 'm' if len(s:buffers) >= a:id - let bid = s:buffers[a:id - 1] - exe 'silent b' . bid + let bid = s:buffers[a:id - 1] + exe 'silent b' . bid + bd endif + elseif get(a:000, 2, '') == 'l' + if len(s:buffers) >= a:id + let bid = s:buffers[a:id - 1] + exe 'silent b' . bid + endif + else + if len(s:buffers) >= a:id + let bid = s:buffers[a:id - 1] + exe 'silent b' . bid + endif + endif endfunction function! SpaceVim#layers#core#tabline#def_colors() abort - if !empty(g:spacevim_custom_color_palette) - let t = g:spacevim_custom_color_palette - else - let name = get(g:, 'colors_name', 'gruvbox') - try - let t = SpaceVim#mapping#guide#theme#{name}#palette() - catch /^Vim\%((\a\+)\)\=:E117/ - let t = SpaceVim#mapping#guide#theme#gruvbox#palette() - endtry - endif - exe 'hi! SpaceVim_tabline_a ctermbg=' . t[0][2] . ' ctermfg=' . t[0][3] . ' guibg=' . t[0][1] . ' guifg=' . t[0][0] - exe 'hi! SpaceVim_tabline_b ctermbg=' . t[1][2] . ' ctermfg=' . t[1][3] . ' guibg=' . t[1][1] . ' guifg=' . t[1][0] - call s:HI.hi_separator('SpaceVim_tabline_a', 'SpaceVim_tabline_b') + if !empty(g:spacevim_custom_color_palette) + let t = g:spacevim_custom_color_palette + else + let name = get(g:, 'colors_name', 'gruvbox') + try + let t = SpaceVim#mapping#guide#theme#{name}#palette() + catch /^Vim\%((\a\+)\)\=:E117/ + let t = SpaceVim#mapping#guide#theme#gruvbox#palette() + endtry + endif + exe 'hi! SpaceVim_tabline_a ctermbg=' . t[0][2] . ' ctermfg=' . t[0][3] . ' guibg=' . t[0][1] . ' guifg=' . t[0][0] + exe 'hi! SpaceVim_tabline_b ctermbg=' . t[1][2] . ' ctermfg=' . t[1][3] . ' guibg=' . t[1][1] . ' guifg=' . t[1][0] + " SpaceVim_tabline_c is for modified buffers + exe 'hi! SpaceVim_tabline_m ctermbg=' . t[4][3] . ' ctermfg=' . t[4][2] . ' guibg=' . t[4][1] . ' guifg=' . t[4][0] + exe 'hi! SpaceVim_tabline_m_i ctermbg=' . t[1][2] . ' ctermfg=' . t[4][3] . ' guibg=' . t[1][1] . ' guifg=' . t[4][1] + call s:HI.hi_separator('SpaceVim_tabline_a', 'SpaceVim_tabline_b') + call s:HI.hi_separator('SpaceVim_tabline_m', 'SpaceVim_tabline_b') + call s:HI.hi_separator('SpaceVim_tabline_m', 'SpaceVim_tabline_a') endfunction diff --git a/autoload/SpaceVim/layers/debug.vim b/autoload/SpaceVim/layers/debug.vim index 833937ffa..836b48f4f 100644 --- a/autoload/SpaceVim/layers/debug.vim +++ b/autoload/SpaceVim/layers/debug.vim @@ -1,9 +1,93 @@ function! SpaceVim#layers#debug#plugins() abort - let plugins = [] - call add(plugins,['idanarye/vim-vebugger', {'merged' : 0}]) - return plugins + let plugins = [] + call add(plugins,['idanarye/vim-vebugger', {'merged' : 0}]) + return plugins endfunction function! SpaceVim#layers#debug#config() abort - + call SpaceVim#mapping#space#def('nnoremap', ['d', 'l'], 'call SpaceVim#layers#debug#launching(&ft)', 'launching debugger', 1) + call SpaceVim#mapping#space#def('nnoremap', ['d', 'b'], 'VBGtoggleBreakpointThisLine', 'Toggle a breakpoint for the current line', 1) + call SpaceVim#mapping#space#def('nnoremap', ['d', 'B'], 'VBGclearBreakpoints', 'Clear all breakpoints', 1) + call SpaceVim#mapping#space#def('nnoremap', ['d', 'c'], 'VBGcontinue', 'Continue the execution', 1) + call SpaceVim#mapping#space#def('nnoremap', ['d', 'o'], 'VBGstepOver', 'step over', 1) + call SpaceVim#mapping#space#def('nnoremap', ['d', 'i'], 'VBGstepIn', 'step into functions', 1) + call SpaceVim#mapping#space#def('nnoremap', ['d', 'O'], 'VBGstepOut', 'step out of current function', 1) + call SpaceVim#mapping#space#def('nnoremap', ['d', 'k'], 'VBGkill', 'Terminates the debugger', 1) + let g:_spacevim_mappings_space.d.e = {'name' : '+Evaluate/Execute'} + call SpaceVim#mapping#space#def('nnoremap', ['d', 'e', 's'], 'VBGevalSelectedText', 'Evaluate and print the selected text', 1) + call SpaceVim#mapping#space#def('nnoremap', ['d', 'e', 'e'], 'VBGevalWordUnderCursor', 'Evaluate the under the cursor', 1) + call SpaceVim#mapping#space#def('nnoremap', ['d', 'e', 'S'], 'VBGexecuteSelectedText', 'Execute the selected text', 1) + call SpaceVim#mapping#space#def('nnoremap', ['d', '.'], 'call call(' + \ . string(s:_function('s:buffer_transient_state')) . ', [])', + \ 'debug transient state', 1) endfunction + +function! SpaceVim#layers#debug#launching(ft) abort + if a:ft ==# 'python' + exe 'VBGstartPDB ' . bufname('%') + elseif a:ft ==# 'ruby' + exe 'VBGstartRDebug ' . bufname('%') + else + echohl WarningMsg + echo 'read :h vebugger-launching' + echohl None + endif +endfunction + +function! s:buffer_transient_state() abort + let state = SpaceVim#api#import('transient_state') + call state.set_title('Debug Transient State') + call state.defind_keys( + \ { + \ 'layout' : 'vertical split', + \ 'left' : [ + \ { + \ 'key' : 'o', + \ 'desc' : 'step over', + \ 'func' : '', + \ 'cmd' : 'VBGstepOver', + \ 'exit' : 0, + \ }, + \ { + \ 'key' : 'i', + \ 'desc' : 'step into functions', + \ 'func' : '', + \ 'cmd' : 'VBGstepIn', + \ 'exit' : 0, + \ }, + \ ], + \ 'right' : [ + \ { + \ 'key' : 'O', + \ 'desc' : 'step out of current function', + \ 'func' : '', + \ 'cmd' : 'VBGstepOut', + \ 'exit' : 0, + \ }, + \ { + \ 'key' : 'k', + \ 'desc' : 'Terminates the debugger', + \ 'func' : '', + \ 'cmd' : 'VBGkill', + \ 'exit' : 1, + \ }, + \ ], + \ } + \ ) + call state.open() +endfunction + +" function() wrapper +if v:version > 703 || v:version == 703 && has('patch1170') + function! s:_function(fstr) abort + return function(a:fstr) + endfunction +else + function! s:_SID() abort + return matchstr(expand(''), '\zs\d\+\ze__SID$') + endfunction + let s:_s = '' . s:_SID() . '_' + function! s:_function(fstr) abort + return function(substitute(a:fstr, 's:', s:_s, 'g')) + endfunction +endif diff --git a/autoload/SpaceVim/layers/default.vim b/autoload/SpaceVim/layers/default.vim index 6925f7dc8..39122cd6b 100644 --- a/autoload/SpaceVim/layers/default.vim +++ b/autoload/SpaceVim/layers/default.vim @@ -5,439 +5,497 @@ let s:filename = expand(':~') function! SpaceVim#layers#default#plugins() abort - let plugins = [] + let plugins = [] - return plugins + return plugins endfunction let s:lnum = expand('') + 3 function! SpaceVim#layers#default#config() abort - " Unimpaired bindings - " Quickly add empty lines - nnoremap [ :put! =repeat(nr2char(10), v:count1) - nnoremap ] :put =repeat(nr2char(10), v:count1) + " Unimpaired bindings + " Quickly add empty lines + nnoremap [ :put! =repeat(nr2char(10), v:count1) + nnoremap ] :put =repeat(nr2char(10), v:count1) - "]e or [e move current line ,count can be useed - nnoremap [e :execute 'move -1-'. v:count1 - nnoremap ]e :execute 'move +'. v:count1 + "]e or [e move current line ,count can be useed + nnoremap [e :execute 'move -1-'. v:count1 + nnoremap ]e :execute 'move +'. v:count1 - " [b or ]n go to previous or next buffer - nnoremap [b :bN - nnoremap ]b :bn + " [b or ]n go to previous or next buffer + nnoremap [b :bN + nnoremap ]b :bn - " [f or ]f go to next or previous file in dir - nnoremap ]f :call next_file() - nnoremap [f :call previous_file() + " [f or ]f go to next or previous file in dir + nnoremap ]f :call next_file() + nnoremap [f :call previous_file() - " [l or ]l go to next and previous error - nnoremap [l :lprevious - nnoremap ]l :lnext + " [l or ]l go to next and previous error + nnoremap [l :lprevious + nnoremap ]l :lnext - " [c or ]c go to next or previous vcs hunk + " [c or ]c go to next or previous vcs hunk - " [w or ]w go to next or previous window - nnoremap [w :call previous_window() - nnoremap ]w :call next_window() + " [w or ]w go to next or previous window + nnoremap [w :call previous_window() + nnoremap ]w :call next_window() - " [t or ]t for next and previous tab - nnoremap [t :tabprevious - nnoremap ]t :tabnext + " [t or ]t for next and previous tab + nnoremap [t :tabprevious + nnoremap ]t :tabnext - " [p or ]p for p and P - nnoremap [p P - nnoremap ]p p + " [p or ]p for p and P + nnoremap [p P + nnoremap ]p p - " Select last paste - nnoremap gp '`['.strpart(getregtype(), 0, 1).'`]' + " Select last paste + nnoremap gp '`['.strpart(getregtype(), 0, 1).'`]' - let lnum = expand('') + s:lnum - 1 - if has('python3') - let cmd = 'DeniteBufferDir file_rec' - elseif has('python') - let cmd = "exe 'LeaderfFile ' . fnamemodify(bufname('%'), ':h')" - else - let cmd = "exe 'CtrlP ' . fnamemodify(bufname('%'), ':h')" - endif - call SpaceVim#mapping#space#def('nnoremap', ['f', 'f'], - \ cmd, - \ ['Find files in the directory of the current buffer', - \ [ - \ '[SPC f f] is to find files in the directory of the current buffer', - \ 'vim with +python3 support will use denite', - \ 'vim with +python support will use leaderf', - \ 'otherwise will use ctrlp', - \ '', - \ 'Definition: ' . s:filename . ':' . lnum, - \ ] - \ ] - \ , 1) - call SpaceVim#mapping#space#def('nnoremap', ['f', 's'], 'write', 'save buffer', 1) - call SpaceVim#mapping#space#def('nnoremap', ['f', 'S'], 'wall', 'save all buffer', 1) - call SpaceVim#mapping#space#def('nnoremap', ['f', 'W'], 'write !sudo tee % >/dev/null', 'save buffer with sudo', 1) - " help mappings - call SpaceVim#mapping#space#def('nnoremap', ['h', 'I'], 'call SpaceVim#issue#report()', 'Reporting an issue of SpaceVim', 1) - if has('python3') - call SpaceVim#mapping#space#def('nnoremap', ['h', 'i'], 'DeniteCursorWord help', 'get help with the symbol at point', 1) - else - call SpaceVim#mapping#space#def('nnoremap', ['h', 'i'], 'UniteWithCursorWord help', 'get help with the symbol at point', 1) - endif - call SpaceVim#mapping#space#def('nnoremap', ['h', 'l'], 'SPLayer -l', 'lists all the layers available in SpaceVim', 1) - call SpaceVim#mapping#space#def('nnoremap', ['h', 'm'], 'Unite manpage', 'search available man pages', 1) - call SpaceVim#mapping#space#def('nnoremap', ['h', 'k'], 'LeaderGuide "[KEYs]"', 'show top-level bindings with mapping guide', 1) - call SpaceVim#mapping#space#def('nnoremap', ['h', '[SPC]'], 'Unite help -input=SpaceVim', 'unite-SpaceVim-help', 1) - call SpaceVim#mapping#space#def('nnoremap', ['j', '0'], 'm`^', 'push mark and goto beginning of line', 0) - call SpaceVim#mapping#space#def('nnoremap', ['j', '$'], 'm`g_', 'push mark and goto end of line', 0) - call SpaceVim#mapping#space#def('nnoremap', ['j', 'b'], '', 'jump backward', 0) - call SpaceVim#mapping#space#def('nnoremap', ['j', 'f'], '', 'jump forward', 0) - call SpaceVim#mapping#space#def('nnoremap', ['j', 'd'], 'VimFiler -no-split', 'Explore current directory', 1) - call SpaceVim#mapping#space#def('nnoremap', ['j', 'D'], 'VimFiler', 'Explore current directory (other window)', 1) - call SpaceVim#mapping#space#def('nmap', ['j', 'j'], '(easymotion-prefix)s', 'jump to a character', 0) - call SpaceVim#mapping#space#def('nmap', ['j', 'J'], '(easymotion-s2)', 'jump to a suite of two characters', 0) - call SpaceVim#mapping#space#def('nnoremap', ['j', 'k'], 'j==', 'go to next line and indent', 0) - call SpaceVim#mapping#space#def('nmap', ['j', 'l'], '(easymotion-bd-jk)', 'jump to a line', 0) - call SpaceVim#mapping#space#def('nmap', ['j', 'v'], '(easymotion-bd-jk)', 'jump to a line', 0) - call SpaceVim#mapping#space#def('nmap', ['j', 'w'], '(easymotion-bd-w)', 'jump to a word', 0) - call SpaceVim#mapping#space#def('nmap', ['j', 'q'], '(easymotion-bd-jk)', 'jump to a line', 0) - call SpaceVim#mapping#space#def('nnoremap', ['j', 'n'], "i\\", 'sp-newline', 0) - call SpaceVim#mapping#space#def('nnoremap', ['j', 'o'], "i\\k$", 'open-line', 0) - call SpaceVim#mapping#space#def('nnoremap', ['j', 's'], 'call call(' - \ . string(s:_function('s:split_string')) . ', [0])', - \ 'split sexp', 1) - call SpaceVim#mapping#space#def('nnoremap', ['j', 'S'], 'call call(' - \ . string(s:_function('s:split_string')) . ', [1])', - \ 'split-and-add-newline', 1) - call SpaceVim#mapping#space#def('nnoremap', ['w', 'r'], 'call call(' - \ . string(s:_function('s:next_window')) . ', [])', - \ 'rotate windows forward', 1) - call SpaceVim#mapping#space#def('nnoremap', ['w', 'R'], 'call call(' - \ . string(s:_function('s:previous_window')) . ', [])', - \ 'rotate windows backward', 1) - call SpaceVim#mapping#space#def('nnoremap', ['j', 'u'], 'call call(' - \ . string(s:_function('s:jump_to_url')) . ', [])', - \ 'jump to url', 1) - call SpaceVim#mapping#space#def('nnoremap', [''], 'try | b# | catch | endtry', 'last buffer', 1) - call SpaceVim#mapping#space#def('nnoremap', ['b', '.'], 'call call(' - \ . string(s:_function('s:buffer_transient_state')) . ', [])', - \ 'buffer transient state', 1) - call SpaceVim#mapping#space#def('nnoremap', ['b', 'd'], 'call SpaceVim#mapping#close_current_buffer()', 'kill-this-buffer', 1) - call SpaceVim#mapping#space#def('nnoremap', ['b', 'D'], - \ 'call SpaceVim#mapping#kill_visible_buffer_choosewin()', - \ 'kill-this-buffer', 1) - call SpaceVim#mapping#space#def('nnoremap', ['b', ''], 'call SpaceVim#mapping#clearBuffers()', 'kill-other-buffers', 1) - call SpaceVim#mapping#space#def('nnoremap', ['b', 'c'], 'call SpaceVim#mapping#clear_saved_buffers()', 'clear all saved buffers', 1) - call SpaceVim#mapping#space#def('nnoremap', ['b', 'e'], 'call call(' - \ . string(s:_function('s:safe_erase_buffer')) . ', [])', - \ 'safe-erase-buffer', 1) - call SpaceVim#mapping#space#def('nnoremap', ['b', 'h'], 'Startify', 'home', 1) - call SpaceVim#mapping#space#def('nnoremap', ['b', 'm'], 'call call(' - \ . string(s:_function('s:open_message_buffer')) . ', [])', - \ 'open-message-buffer', 1) - call SpaceVim#mapping#space#def('nnoremap', ['b', 'P'], 'normal! ggdG"+P', 'copy-clipboard-to-whole-buffer', 1) - call SpaceVim#mapping#space#def('nnoremap', ['b', 'R'], 'call call(' - \ . string(s:_function('s:safe_revert_buffer')) . ', [])', - \ 'safe-revert-buffer', 1) - call SpaceVim#mapping#space#def('nnoremap', ['b', 'Y'], 'normal! ggVG"+y``', 'copy-whole-buffer-to-clipboard', 1) - call SpaceVim#mapping#space#def('nnoremap', ['b', 'w'], 'setl readonly!', 'read-only-mode', 1) - let g:_spacevim_mappings_space.b.N = {'name' : '+New empty buffer'} - call SpaceVim#mapping#space#def('nnoremap', ['b', 'N', 'h'], 'topleft vertical new', 'new-empty-buffer-left', 1) - call SpaceVim#mapping#space#def('nnoremap', ['b', 'N', 'j'], 'rightbelow new', 'new-empty-buffer-below', 1) - call SpaceVim#mapping#space#def('nnoremap', ['b', 'N', 'k'], 'new', 'new-empty-buffer-above', 1) - call SpaceVim#mapping#space#def('nnoremap', ['b', 'N', 'l'], 'rightbelow vertical new', 'new-empty-buffer-right', 1) - call SpaceVim#mapping#space#def('nnoremap', ['b', 'N', 'n'], 'enew', 'new-empty-buffer', 1) + let lnum = expand('') + s:lnum - 1 + if has('python3') + let cmd = 'DeniteBufferDir file_rec' + elseif has('python') + let cmd = "exe 'LeaderfFile ' . fnamemodify(bufname('%'), ':h')" + else + let cmd = "exe 'CtrlP ' . fnamemodify(bufname('%'), ':h')" + endif + call SpaceVim#mapping#space#def('nnoremap', ['f', 'f'], + \ cmd, + \ ['Find files in the directory of the current buffer', + \ [ + \ '[SPC f f] is to find files in the directory of the current buffer', + \ 'vim with +python3 support will use denite', + \ 'vim with +python support will use leaderf', + \ 'otherwise will use ctrlp', + \ '', + \ 'Definition: ' . s:filename . ':' . lnum, + \ ] + \ ] + \ , 1) + call SpaceVim#mapping#space#def('nnoremap', ['f', 's'], 'write', 'save buffer', 1) + call SpaceVim#mapping#space#def('nnoremap', ['f', 'S'], 'wall', 'save all buffer', 1) + call SpaceVim#mapping#space#def('nnoremap', ['f', 'W'], 'write !sudo tee % >/dev/null', 'save buffer with sudo', 1) + " help mappings + call SpaceVim#mapping#space#def('nnoremap', ['h', 'I'], 'call SpaceVim#issue#report()', 'Reporting an issue of SpaceVim', 1) + if has('python3') + call SpaceVim#mapping#space#def('nnoremap', ['h', 'i'], 'DeniteCursorWord help', 'get help with the symbol at point', 1) + else + call SpaceVim#mapping#space#def('nnoremap', ['h', 'i'], 'UniteWithCursorWord help', 'get help with the symbol at point', 1) + endif + call SpaceVim#mapping#space#def('nnoremap', ['h', 'l'], 'SPLayer -l', 'lists all the layers available in SpaceVim', 1) + call SpaceVim#mapping#space#def('nnoremap', ['h', 'm'], 'Unite manpage', 'search available man pages', 1) + call SpaceVim#mapping#space#def('nnoremap', ['h', 'k'], 'LeaderGuide "[KEYs]"', 'show top-level bindings with mapping guide', 1) + call SpaceVim#mapping#space#def('nnoremap', ['h', '[SPC]'], 'Unite help -input=SpaceVim', 'unite-SpaceVim-help', 1) + call SpaceVim#mapping#space#def('nnoremap', ['j', '0'], 'm`^', 'push mark and goto beginning of line', 0) + call SpaceVim#mapping#space#def('nnoremap', ['j', '$'], 'm`g_', 'push mark and goto end of line', 0) + call SpaceVim#mapping#space#def('nnoremap', ['j', 'b'], '', 'jump backward', 0) + call SpaceVim#mapping#space#def('nnoremap', ['j', 'f'], '', 'jump forward', 0) + call SpaceVim#mapping#space#def('nnoremap', ['j', 'd'], 'VimFiler -no-split', 'Explore current directory', 1) + call SpaceVim#mapping#space#def('nnoremap', ['j', 'D'], 'VimFiler', 'Explore current directory (other window)', 1) + call SpaceVim#mapping#space#def('nmap', ['j', 'j'], '(easymotion-prefix)s', 'jump to a character', 0) + call SpaceVim#mapping#space#def('nmap', ['j', 'J'], '(easymotion-s2)', 'jump to a suite of two characters', 0) + call SpaceVim#mapping#space#def('nnoremap', ['j', 'k'], 'j==', 'go to next line and indent', 0) + call SpaceVim#mapping#space#def('nmap', ['j', 'l'], '(easymotion-bd-jk)', 'jump to a line', 0) + call SpaceVim#mapping#space#def('nmap', ['j', 'v'], '(easymotion-bd-jk)', 'jump to a line', 0) + call SpaceVim#mapping#space#def('nmap', ['j', 'w'], '(easymotion-bd-w)', 'jump to a word', 0) + call SpaceVim#mapping#space#def('nmap', ['j', 'q'], '(easymotion-bd-jk)', 'jump to a line', 0) + call SpaceVim#mapping#space#def('nnoremap', ['j', 'n'], "i\\", 'sp-newline', 0) + call SpaceVim#mapping#space#def('nnoremap', ['j', 'o'], "i\\k$", 'open-line', 0) + call SpaceVim#mapping#space#def('nnoremap', ['j', 's'], 'call call(' + \ . string(s:_function('s:split_string')) . ', [0])', + \ 'split sexp', 1) + call SpaceVim#mapping#space#def('nnoremap', ['j', 'S'], 'call call(' + \ . string(s:_function('s:split_string')) . ', [1])', + \ 'split-and-add-newline', 1) + call SpaceVim#mapping#space#def('nnoremap', ['w', 'r'], 'call call(' + \ . string(s:_function('s:next_window')) . ', [])', + \ 'rotate windows forward', 1) + call SpaceVim#mapping#space#def('nnoremap', ['w', 'R'], 'call call(' + \ . string(s:_function('s:previous_window')) . ', [])', + \ 'rotate windows backward', 1) + call SpaceVim#mapping#space#def('nnoremap', ['j', 'u'], 'call call(' + \ . string(s:_function('s:jump_to_url')) . ', [])', + \ 'jump to url', 1) + call SpaceVim#mapping#space#def('nnoremap', [''], 'try | b# | catch | endtry', 'last buffer', 1) + call SpaceVim#mapping#space#def('nnoremap', ['b', '.'], 'call call(' + \ . string(s:_function('s:buffer_transient_state')) . ', [])', + \ 'buffer transient state', 1) + call SpaceVim#mapping#space#def('nnoremap', ['b', 'd'], 'call SpaceVim#mapping#close_current_buffer()', 'kill-this-buffer', 1) + call SpaceVim#mapping#space#def('nnoremap', ['b', 'D'], + \ 'call SpaceVim#mapping#kill_visible_buffer_choosewin()', + \ 'kill-this-buffer', 1) + call SpaceVim#mapping#space#def('nnoremap', ['b', ''], 'call SpaceVim#mapping#clearBuffers()', 'kill-other-buffers', 1) + call SpaceVim#mapping#space#def('nnoremap', ['b', 'c'], 'call SpaceVim#mapping#clear_saved_buffers()', 'clear all saved buffers', 1) + call SpaceVim#mapping#space#def('nnoremap', ['b', 'e'], 'call call(' + \ . string(s:_function('s:safe_erase_buffer')) . ', [])', + \ 'safe-erase-buffer', 1) + call SpaceVim#mapping#space#def('nnoremap', ['b', 'h'], 'Startify', 'home', 1) + call SpaceVim#mapping#space#def('nnoremap', ['b', 'm'], 'call call(' + \ . string(s:_function('s:open_message_buffer')) . ', [])', + \ 'open-message-buffer', 1) + call SpaceVim#mapping#space#def('nnoremap', ['b', 'P'], 'normal! ggdG"+P', 'copy-clipboard-to-whole-buffer', 1) + call SpaceVim#mapping#space#def('nnoremap', ['b', 'R'], 'call call(' + \ . string(s:_function('s:safe_revert_buffer')) . ', [])', + \ 'safe-revert-buffer', 1) + call SpaceVim#mapping#space#def('nnoremap', ['b', 'Y'], 'normal! ggVG"+y``', 'copy-whole-buffer-to-clipboard', 1) + call SpaceVim#mapping#space#def('nnoremap', ['b', 'w'], 'setl readonly!', 'read-only-mode', 1) + let g:_spacevim_mappings_space.b.N = {'name' : '+New empty buffer'} + call SpaceVim#mapping#space#def('nnoremap', ['b', 'N', 'h'], 'topleft vertical new', 'new-empty-buffer-left', 1) + call SpaceVim#mapping#space#def('nnoremap', ['b', 'N', 'j'], 'rightbelow new', 'new-empty-buffer-below', 1) + call SpaceVim#mapping#space#def('nnoremap', ['b', 'N', 'k'], 'new', 'new-empty-buffer-above', 1) + call SpaceVim#mapping#space#def('nnoremap', ['b', 'N', 'l'], 'rightbelow vertical new', 'new-empty-buffer-right', 1) + call SpaceVim#mapping#space#def('nnoremap', ['b', 'N', 'n'], 'enew', 'new-empty-buffer', 1) - " file mappings - call SpaceVim#mapping#space#def('nnoremap', ['f', 'b'], 'Unite vim_bookmarks', 'unite-filtered-bookmarks', 1) - let g:_spacevim_mappings_space.f.C = {'name' : '+Files/convert'} - call SpaceVim#mapping#space#def('nnoremap', ['f', 'C', 'd'], 'update | e ++ff=dos | w', 'unix2dos', 1) - call SpaceVim#mapping#space#def('nnoremap', ['f', 'C', 'u'], 'update | e ++ff=dos | setlocal ff=unix | w', 'dos2unix', 1) - call SpaceVim#mapping#space#def('nnoremap', ['f', 'D'], 'call call(' - \ . string(s:_function('s:delete_current_buffer_file')) . ', [])', - \ 'delete-current-buffer-file', 1) - call SpaceVim#mapping#space#def('nnoremap', ['f', 'F'], 'normal! gf', 'open-cursor-file', 1) - call SpaceVim#mapping#space#def('nnoremap', ['f', 'r'], 'Unite file_mru', 'open-recent-file', 1) - if g:spacevim_filemanager ==# 'vimfiler' - call SpaceVim#mapping#space#def('nnoremap', ['f', 't'], 'VimFiler', 'toggle_file_tree', 1) - call SpaceVim#mapping#space#def('nnoremap', ['f', 'T'], 'VimFiler -no-toggle', 'show_file_tree', 1) - elseif g:spacevim_filemanager ==# 'nerdtree' - call SpaceVim#mapping#space#def('nnoremap', ['f', 't'], 'NERDTreeToggle', 'toggle_file_tree', 1) - call SpaceVim#mapping#space#def('nnoremap', ['f', 't'], 'NERDTree', 'toggle_file_tree', 1) - endif - call SpaceVim#mapping#space#def('nnoremap', ['f', 'y'], 'call zvim#util#CopyToClipboard()', 'show-and-copy-buffer-filename', 1) - let g:_spacevim_mappings_space.f.v = {'name' : '+Vim(SpaceVim)'} - call SpaceVim#mapping#space#def('nnoremap', ['f', 'v', 'v'], 'let @+=g:spacevim_version | echo g:spacevim_version', 'display-and-copy-version', 1) - call SpaceVim#mapping#space#def('nnoremap', ['f', 'v', 'd'], 'SPConfig', 'open-custom-configuration', 1) + " file mappings + call SpaceVim#mapping#space#def('nnoremap', ['f', 'b'], 'BookmarkShowAll', 'unite-filtered-bookmarks', 1) + let g:_spacevim_mappings_space.f.C = {'name' : '+Files/convert'} + call SpaceVim#mapping#space#def('nnoremap', ['f', 'C', 'd'], 'update | e ++ff=dos | w', 'unix2dos', 1) + call SpaceVim#mapping#space#def('nnoremap', ['f', 'C', 'u'], 'update | e ++ff=dos | setlocal ff=unix | w', 'dos2unix', 1) + call SpaceVim#mapping#space#def('nnoremap', ['f', 'D'], 'call call(' + \ . string(s:_function('s:delete_current_buffer_file')) . ', [])', + \ 'delete-current-buffer-file', 1) + call SpaceVim#mapping#space#def('nnoremap', ['f', 'F'], 'normal! gf', 'open-cursor-file', 1) + call SpaceVim#mapping#space#def('nnoremap', ['f', 'r'], 'Unite file_mru', 'open-recent-file', 1) + if g:spacevim_filemanager ==# 'vimfiler' + call SpaceVim#mapping#space#def('nnoremap', ['f', 't'], 'VimFiler', 'toggle_file_tree', 1) + call SpaceVim#mapping#space#def('nnoremap', ['f', 'T'], 'VimFiler -no-toggle', 'show_file_tree', 1) + elseif g:spacevim_filemanager ==# 'nerdtree' + call SpaceVim#mapping#space#def('nnoremap', ['f', 't'], 'NERDTreeToggle', 'toggle_file_tree', 1) + call SpaceVim#mapping#space#def('nnoremap', ['f', 't'], 'NERDTree', 'toggle_file_tree', 1) + endif + call SpaceVim#mapping#space#def('nnoremap', ['f', 'y'], 'call zvim#util#CopyToClipboard()', 'show-and-copy-buffer-filename', 1) + let g:_spacevim_mappings_space.f.v = {'name' : '+Vim(SpaceVim)'} + call SpaceVim#mapping#space#def('nnoremap', ['f', 'v', 'v'], 'let @+=g:spacevim_version | echo g:spacevim_version', 'display-and-copy-version', 1) + call SpaceVim#mapping#space#def('nnoremap', ['f', 'v', 'd'], 'SPConfig', 'open-custom-configuration', 1) + let lnum = expand('') + s:lnum - 1 + call SpaceVim#mapping#space#def('nnoremap', ['n', '-'], 'call call(' + \ . string(s:_function('s:number_transient_state')) . ', ["-"])', + \ ['Decrease number under cursor', + \ [ + \ '[SPC n -] is to decrease the number under the cursor, and open', + \ 'the number translate state buffer', + \ '', + \ 'Definition: ' . s:filename . ':' . lnum, + \ ] + \ ] + \ , 1) + let lnum = expand('') + s:lnum - 1 + call SpaceVim#mapping#space#def('nnoremap', ['n', '+'], 'call call(' + \ . string(s:_function('s:number_transient_state')) . ', ["+"])', + \ ['Increase number under cursor', + \ [ + \ '[SPC n +] is to increase the number under the cursor, and open', + \ 'the number translate state buffer', + \ '', + \ 'Definition: ' . s:filename . ':' . lnum, + \ ] + \ ] + \ , 1) +endfunction + +function! s:number_transient_state(n) abort + if a:n ==# '+' + exe "normal! \" + else + exe "normal! \" + endif + let state = SpaceVim#api#import('transient_state') + call state.set_title('Number Transient State') + call state.defind_keys( + \ { + \ 'layout' : 'vertical split', + \ 'left' : [ + \ { + \ 'key' : ['+','='], + \ 'desc' : 'increase number', + \ 'func' : '', + \ 'cmd' : "normal! \", + \ 'exit' : 0, + \ }, + \ ], + \ 'right' : [ + \ { + \ 'key' : '-', + \ 'desc' : 'decrease number', + \ 'func' : '', + \ 'cmd' : "normal! \", + \ 'exit' : 0, + \ }, + \ ], + \ } + \ ) + call state.open() endfunction let s:file = SpaceVim#api#import('file') let s:MESSAGE = SpaceVim#api#import('vim#message') function! s:next_file() abort - let dir = expand('%:p:h') - let f = expand('%:t') - let file = s:file.ls(dir, 1) - if index(file, f) == -1 - call add(file,f) - endif - call sort(file) - if len(file) != 1 - if index(file, f) == len(file) - 1 - exe 'e ' . dir . s:file.separator . file[0] - else - exe 'e ' . dir . s:file.separator . file[index(file, f) + 1] - endif + let dir = expand('%:p:h') + let f = expand('%:t') + let file = s:file.ls(dir, 1) + if index(file, f) == -1 + call add(file,f) + endif + call sort(file) + if len(file) != 1 + if index(file, f) == len(file) - 1 + exe 'e ' . dir . s:file.separator . file[0] + else + exe 'e ' . dir . s:file.separator . file[index(file, f) + 1] endif + endif endfunction function! s:previous_file() abort - let dir = expand('%:p:h') - let f = expand('%:t') - let file = s:file.ls(dir, 1) - if index(file, f) == -1 - call add(file,f) - endif - call sort(file) - if len(file) != 1 - if index(file, f) == 0 - exe 'e ' . dir . s:file.separator . file[-1] - else - exe 'e ' . dir . s:file.separator . file[index(file, f) - 1] - endif + let dir = expand('%:p:h') + let f = expand('%:t') + let file = s:file.ls(dir, 1) + if index(file, f) == -1 + call add(file,f) + endif + call sort(file) + if len(file) != 1 + if index(file, f) == 0 + exe 'e ' . dir . s:file.separator . file[-1] + else + exe 'e ' . dir . s:file.separator . file[index(file, f) - 1] endif + endif endfunction function! s:next_window() abort - try - exe (winnr() + 1 ) . 'wincmd w' - catch - exe 1 . 'wincmd w' - endtry + try + exe (winnr() + 1 ) . 'wincmd w' + catch + exe 1 . 'wincmd w' + endtry endfunction function! s:previous_window() abort - try - if winnr() == 1 - exe winnr('$') . 'wincmd w' - else - exe (winnr() - 1 ) . 'wincmd w' - endif - catch - exe winnr('$') . 'wincmd w' - endtry + try + if winnr() == 1 + exe winnr('$') . 'wincmd w' + else + exe (winnr() - 1 ) . 'wincmd w' + endif + catch + exe winnr('$') . 'wincmd w' + endtry endfunction function! s:split_string(newline) abort - let syn_name = synIDattr(synID(line("."), col("."), 1), "name") - if syn_name == &filetype . 'String' - let c = col('.') - let sep = '' - while c > 0 - if s:is_string(line('.'), c) - let c = c - 1 - else - let sep = getline('.')[c] - break - endif - endwhile - if a:newline - let save_register_m = @m - let @m = sep . "\n" . sep - normal! "mp - let @m = save_register_m - else - let save_register_m = @m - let @m = sep . sep - normal! "mp - let @m = save_register_m - endif + let syn_name = synIDattr(synID(line("."), col("."), 1), "name") + if syn_name == &filetype . 'String' + let c = col('.') + let sep = '' + while c > 0 + if s:is_string(line('.'), c) + let c = c - 1 + else + let sep = getline('.')[c] + break + endif + endwhile + if a:newline + let save_register_m = @m + let @m = sep . "\n" . sep + normal! "mp + let @m = save_register_m + else + let save_register_m = @m + let @m = sep . sep + normal! "mp + let @m = save_register_m endif + endif endfunction function! s:is_string(l,c) abort - return synIDattr(synID(a:l, a:c, 1), "name") == &filetype . 'String' + return synIDattr(synID(a:l, a:c, 1), "name") == &filetype . 'String' endfunction " function() wrapper if v:version > 703 || v:version == 703 && has('patch1170') - function! s:_function(fstr) abort - return function(a:fstr) - endfunction + function! s:_function(fstr) abort + return function(a:fstr) + endfunction else - function! s:_SID() abort - return matchstr(expand(''), '\zs\d\+\ze__SID$') - endfunction - let s:_s = '' . s:_SID() . '_' - function! s:_function(fstr) abort - return function(substitute(a:fstr, 's:', s:_s, 'g')) - endfunction + function! s:_SID() abort + return matchstr(expand(''), '\zs\d\+\ze__SID$') + endfunction + let s:_s = '' . s:_SID() . '_' + function! s:_function(fstr) abort + return function(substitute(a:fstr, 's:', s:_s, 'g')) + endfunction endif function! s:jump_to_url() abort - let g:EasyMotion_re_anywhere = 'http[s]*://' - call feedkeys("\(easymotion-jumptoanywhere)") + let g:EasyMotion_re_anywhere = 'http[s]*://' + call feedkeys("\(easymotion-jumptoanywhere)") endfunction function! s:safe_erase_buffer() abort - if s:MESSAGE.confirm('Erase content of buffer ' . expand('%:t')) - normal! ggdG - endif - redraw! + if s:MESSAGE.confirm('Erase content of buffer ' . expand('%:t')) + normal! ggdG + endif + redraw! endfunction function! s:open_message_buffer() abort - vertical topleft edit __Message_Buffer__ - setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline nospell nonumber norelativenumber - setf message - normal! ggdG - silent put =execute(':message') - normal! G - setlocal nomodifiable - nnoremap q :silent bd + vertical topleft edit __Message_Buffer__ + setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline nospell nonumber norelativenumber + setf message + normal! ggdG + silent put =execute(':message') + normal! G + setlocal nomodifiable + nnoremap q :silent bd endfunction function! s:safe_revert_buffer() abort - if s:MESSAGE.confirm('Revert buffer form ' . expand('%:p')) - edit! - endif - redraw! + if s:MESSAGE.confirm('Revert buffer form ' . expand('%:p')) + edit! + endif + redraw! endfunction function! s:delete_current_buffer_file() abort - if s:MESSAGE.confirm('Are you sure you want to delete this file') - let f = fnameescape(expand('%:p')) - call SpaceVim#mapping#close_current_buffer() - if delete(f) == 0 - echo "File '" . f . "' successfully removed" - endif + if s:MESSAGE.confirm('Are you sure you want to delete this file') + let f = fnameescape(expand('%:p')) + call SpaceVim#mapping#close_current_buffer() + if delete(f) == 0 + echo "File '" . f . "' successfully removed" endif - redraw! + endif + redraw! endfunction function! s:swap_buffer_with_nth_win(nr) abort - if a:nr <= winnr('$') && a:nr != winnr() - let cb = bufnr('%') - let tb = winbufnr(a:nr) - if cb != tb - exe a:nr . 'wincmd w' - exe 'b' . cb - wincmd p - exe 'b' . tb - endif + if a:nr <= winnr('$') && a:nr != winnr() + let cb = bufnr('%') + let tb = winbufnr(a:nr) + if cb != tb + exe a:nr . 'wincmd w' + exe 'b' . cb + wincmd p + exe 'b' . tb endif + endif endfunction function! s:move_buffer_to_nth_win(nr) abort - if a:nr <= winnr('$') && a:nr != winnr() - let cb = bufnr('%') - bp - exe a:nr . 'wincmd w' - exe 'b' . cb - wincmd p - endif + if a:nr <= winnr('$') && a:nr != winnr() + let cb = bufnr('%') + bp + exe a:nr . 'wincmd w' + exe 'b' . cb + wincmd p + endif endfunction function! s:buffer_transient_state() abort - let state = SpaceVim#api#import('transient_state') - call state.set_title('Buffer Selection Transient State') - call state.defind_keys( - \ { - \ 'layout' : 'vertical split', - \ 'left' : [ - \ { - \ 'key' : { - \ 'name' : 'C-1..C-9', - \ 'pos' : [[1,4], [6,9]], - \ 'handles' : [ - \ ["\" , ''], - \ ["\" , ''], - \ ["\" , ''], - \ ["\" , ''], - \ ["\" , ''], - \ ["\" , ''], - \ ["\" , ''], - \ ["\" , ''], - \ ["\" , ''], - \ ], - \ }, - \ 'desc' : 'goto nth window', - \ 'func' : '', - \ 'cmd' : '', - \ 'exit' : 0, - \ }, - \ { - \ 'key' : { - \ 'name' : '1..9', - \ 'pos' : [[1,2], [4,5]], - \ 'handles' : [ - \ ['1' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [1])'], - \ ['2' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [2])'], - \ ['3' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [3])'], - \ ['4' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [4])'], - \ ['5' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [5])'], - \ ['6' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [6])'], - \ ['7' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [7])'], - \ ['8' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [8])'], - \ ['9' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [9])'], - \ ], - \ }, - \ 'desc' : 'move buffer to nth window', - \ 'func' : '', - \ 'cmd' : '', - \ 'exit' : 0, - \ }, - \ { - \ 'key' : { - \ 'name' : 'M-1..M-9', - \ 'pos' : [[1,4], [6,9]], - \ 'handles' : [ - \ ["\" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [1])'], - \ ["\" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [2])'], - \ ["\" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [3])'], - \ ["\" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [4])'], - \ ["\" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [5])'], - \ ["\" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [6])'], - \ ["\" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [7])'], - \ ["\" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [8])'], - \ ["\" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [9])'], - \ ], - \ }, - \ 'desc' : 'swap buffer with nth window', - \ 'func' : '', - \ 'cmd' : '', - \ 'exit' : 0, - \ }, - \ ], - \ 'right' : [ - \ { - \ 'key' : 'n', - \ 'desc' : 'next buffer', - \ 'func' : '', - \ 'cmd' : 'bnext', - \ 'exit' : 0, - \ }, - \ { - \ 'key' : ['N', 'p'], - \ 'desc' : 'previous buffer', - \ 'func' : '', - \ 'cmd' : 'bp', - \ 'exit' : 0, - \ }, - \ { - \ 'key' : 'd', - \ 'desc' : 'kill buffer', - \ 'func' : '', - \ 'cmd' : 'call SpaceVim#mapping#close_current_buffer()', - \ 'exit' : 0, - \ }, - \ { - \ 'key' : 'q', - \ 'desc' : 'quit', - \ 'func' : '', - \ 'cmd' : '', - \ 'exit' : 1, - \ }, - \ ], - \ } - \ ) - call state.open() + let state = SpaceVim#api#import('transient_state') + call state.set_title('Buffer Selection Transient State') + call state.defind_keys( + \ { + \ 'layout' : 'vertical split', + \ 'left' : [ + \ { + \ 'key' : { + \ 'name' : 'C-1..C-9', + \ 'pos' : [[1,4], [6,9]], + \ 'handles' : [ + \ ["\" , ''], + \ ["\" , ''], + \ ["\" , ''], + \ ["\" , ''], + \ ["\" , ''], + \ ["\" , ''], + \ ["\" , ''], + \ ["\" , ''], + \ ["\" , ''], + \ ], + \ }, + \ 'desc' : 'goto nth window', + \ 'func' : '', + \ 'cmd' : '', + \ 'exit' : 0, + \ }, + \ { + \ 'key' : { + \ 'name' : '1..9', + \ 'pos' : [[1,2], [4,5]], + \ 'handles' : [ + \ ['1' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [1])'], + \ ['2' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [2])'], + \ ['3' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [3])'], + \ ['4' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [4])'], + \ ['5' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [5])'], + \ ['6' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [6])'], + \ ['7' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [7])'], + \ ['8' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [8])'], + \ ['9' , 'call call(' . string(s:_function('s:move_buffer_to_nth_win')) . ', [9])'], + \ ], + \ }, + \ 'desc' : 'move buffer to nth window', + \ 'func' : '', + \ 'cmd' : '', + \ 'exit' : 0, + \ }, + \ { + \ 'key' : { + \ 'name' : 'M-1..M-9', + \ 'pos' : [[1,4], [6,9]], + \ 'handles' : [ + \ ["\" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [1])'], + \ ["\" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [2])'], + \ ["\" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [3])'], + \ ["\" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [4])'], + \ ["\" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [5])'], + \ ["\" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [6])'], + \ ["\" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [7])'], + \ ["\" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [8])'], + \ ["\" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [9])'], + \ ], + \ }, + \ 'desc' : 'swap buffer with nth window', + \ 'func' : '', + \ 'cmd' : '', + \ 'exit' : 0, + \ }, + \ ], + \ 'right' : [ + \ { + \ 'key' : 'n', + \ 'desc' : 'next buffer', + \ 'func' : '', + \ 'cmd' : 'bnext', + \ 'exit' : 0, + \ }, + \ { + \ 'key' : ['N', 'p'], + \ 'desc' : 'previous buffer', + \ 'func' : '', + \ 'cmd' : 'bp', + \ 'exit' : 0, + \ }, + \ { + \ 'key' : 'd', + \ 'desc' : 'kill buffer', + \ 'func' : '', + \ 'cmd' : 'call SpaceVim#mapping#close_current_buffer()', + \ 'exit' : 0, + \ }, + \ { + \ 'key' : 'q', + \ 'desc' : 'quit', + \ 'func' : '', + \ 'cmd' : '', + \ 'exit' : 1, + \ }, + \ ], + \ } + \ ) + call state.open() endfunction diff --git a/autoload/SpaceVim/layers/edit.vim b/autoload/SpaceVim/layers/edit.vim index f308eaa71..568bc6207 100644 --- a/autoload/SpaceVim/layers/edit.vim +++ b/autoload/SpaceVim/layers/edit.vim @@ -4,406 +4,416 @@ let s:NUMBER = SpaceVim#api#import('data#number') let s:LIST = SpaceVim#api#import('data#list') function! SpaceVim#layers#edit#plugins() abort - let plugins = [ - \ ['tpope/vim-surround'], - \ ['tpope/vim-repeat'], - \ ['junegunn/vim-emoji'], - \ ['terryma/vim-multiple-cursors', { 'loadconf' : 1}], - \ ['terryma/vim-expand-region', { 'loadconf' : 1}], - \ ['kana/vim-textobj-user'], - \ ['kana/vim-textobj-indent'], - \ ['kana/vim-textobj-line'], - \ ['kana/vim-textobj-entire'], - \ ['scrooloose/nerdcommenter', { 'loadconf' : 1}], - \ ['mattn/emmet-vim', { 'on_cmd' : 'EmmetInstall'}], - \ ['gcmt/wildfire.vim',{'on_map' : '(wildfire-'}], - \ ['easymotion/vim-easymotion'], - \ ['haya14busa/vim-easyoperator-line'], - \ ['editorconfig/editorconfig-vim', { 'merged' : 0}], - \ ['floobits/floobits-neovim', { 'on_cmd' : ['FlooJoinWorkspace','FlooShareDirPublic','FlooShareDirPrivate']}], - \ ['osyo-manga/vim-jplus', { 'on_map' : '(jplus' }], - \ ] - if executable('fcitx') - call add(plugins,['lilydjwg/fcitx.vim', { 'on_event' : 'InsertEnter'}]) - endif - return plugins + let plugins = [ + \ ['tpope/vim-surround'], + \ ['tpope/vim-repeat'], + \ ['junegunn/vim-emoji'], + \ ['terryma/vim-multiple-cursors', { 'loadconf' : 1}], + \ ['terryma/vim-expand-region', { 'loadconf' : 1}], + \ ['kana/vim-textobj-user'], + \ ['kana/vim-textobj-indent'], + \ ['kana/vim-textobj-line'], + \ ['kana/vim-textobj-entire'], + \ ['scrooloose/nerdcommenter', { 'loadconf' : 1}], + \ ['mattn/emmet-vim', { 'on_cmd' : 'EmmetInstall'}], + \ ['gcmt/wildfire.vim',{'on_map' : '(wildfire-'}], + \ ['easymotion/vim-easymotion'], + \ ['haya14busa/vim-easyoperator-line'], + \ ['editorconfig/editorconfig-vim', { 'merged' : 0}], + \ ['floobits/floobits-neovim', { 'on_cmd' : ['FlooJoinWorkspace','FlooShareDirPublic','FlooShareDirPrivate']}], + \ ['osyo-manga/vim-jplus', { 'on_map' : '(jplus' }], + \ ] + if executable('fcitx') + call add(plugins,['lilydjwg/fcitx.vim', { 'on_event' : 'InsertEnter'}]) + endif + return plugins endfunction function! SpaceVim#layers#edit#config() abort - let g:multi_cursor_next_key=get(g:, 'multi_cursor_next_key', '') - let g:multi_cursor_prev_key=get(g:, 'multi_cursor_prev_key', '') - let g:multi_cursor_skip_key=get(g:, 'multi_cursor_skip_key', '') - let g:multi_cursor_quit_key=get(g:, 'multi_cursor_quit_key', '') - let g:user_emmet_install_global = 0 - let g:user_emmet_leader_key=get(g:, 'user_emmet_leader_key', '') - let g:user_emmet_mode='a' - let g:user_emmet_settings = { - \ 'jsp' : { - \ 'extends' : 'html', - \ }, - \} - "noremap (wildfire-fuel) - vnoremap (wildfire-water) - let g:wildfire_objects = ["i'", 'i"', 'i)', 'i]', 'i}', 'ip', 'it'] + let g:multi_cursor_next_key=get(g:, 'multi_cursor_next_key', '') + let g:multi_cursor_prev_key=get(g:, 'multi_cursor_prev_key', '') + let g:multi_cursor_skip_key=get(g:, 'multi_cursor_skip_key', '') + let g:multi_cursor_quit_key=get(g:, 'multi_cursor_quit_key', '') + let g:user_emmet_install_global = 0 + let g:user_emmet_leader_key=get(g:, 'user_emmet_leader_key', '') + let g:user_emmet_mode='a' + let g:user_emmet_settings = { + \ 'javascript': { + \ 'extends': 'jsx', + \ }, + \ 'jsp' : { + \ 'extends': 'html', + \ }, + \ } + + "noremap (wildfire-fuel) + vnoremap (wildfire-water) + let g:wildfire_objects = ["i'", 'i"', 'i)', 'i]', 'i}', 'ip', 'it'] " osyo-manga/vim-jplus {{{ nmap J (jplus) vmap J (jplus) " }}} - let g:_spacevim_mappings_space.x = {'name' : '+Text'} - let g:_spacevim_mappings_space.x.a = {'name' : '+align'} - let g:_spacevim_mappings_space.x.d = {'name' : '+delete'} - let g:_spacevim_mappings_space.x.i = {'name' : '+change symbol style'} - nnoremap CountSelectionRegion :call count_selection_region() - xnoremap CountSelectionRegion :call count_selection_region() - call SpaceVim#mapping#space#def('nmap', ['x', 'c'], 'CountSelectionRegion', 'count in the selection region', 0, 1) - call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '&'], 'Tabularize /&', 'align region at &', 1) - call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '('], 'Tabularize /(', 'align region at (', 1) - call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', ')'], 'Tabularize /)', 'align region at )', 1) - call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '['], 'Tabularize /[', 'align region at [', 1) - call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', ']'], 'Tabularize /]', 'align region at ]', 1) - call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '{'], 'Tabularize /{', 'align region at {', 1) - call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '}'], 'Tabularize /}', 'align region at }', 1) - call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', ','], 'Tabularize /,', 'align region at ,', 1) - call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '.'], 'Tabularize /.', 'align region at .', 1) - call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', ':'], 'Tabularize /:', 'align region at :', 1) - call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', ';'], 'Tabularize /;', 'align region at ;', 1) - call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '='], 'Tabularize /=', 'align region at =', 1) - call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '¦'], 'Tabularize /¦', 'align region at ¦', 1) - call SpaceVim#mapping#space#def('nnoremap', ['x', 'd', 'w'], 'StripWhitespace', 'delete trailing whitespaces', 1) - call SpaceVim#mapping#space#def('nnoremap', ['x', 'd', '[SPC]'], 'silent call call(' - \ . string(s:_function('s:delete_extra_space')) . ', [])', - \ 'delete extra space arround cursor', 1) - call SpaceVim#mapping#space#def('nnoremap', ['x', 'i', 'c'], 'silent call call(' - \ . string(s:_function('s:lowerCamelCase')) . ', [])', - \ 'change symbol style to lowerCamelCase', 1) - call SpaceVim#mapping#space#def('nnoremap', ['x', 'i', 'C'], 'silent call call(' - \ . string(s:_function('s:UpperCamelCase')) . ', [])', - \ 'change symbol style to UpperCamelCase', 1) - call SpaceVim#mapping#space#def('nnoremap', ['x', 'i', '_'], 'silent call call(' - \ . string(s:_function('s:under_score')) . ', [])', - \ 'change symbol style to under_score', 1) - call SpaceVim#mapping#space#def('nnoremap', ['x', 'i', 'u'], 'silent call call(' - \ . string(s:_function('s:under_score')) . ', [])', - \ 'change symbol style to under_score', 1) - call SpaceVim#mapping#space#def('nnoremap', ['x', 'i', 'U'], 'silent call call(' - \ . string(s:_function('s:up_case')) . ', [])', - \ 'change symbol style to UP_CACE', 1) - call SpaceVim#mapping#space#def('nnoremap', ['x', 'i', 'k'], 'silent call call(' - \ . string(s:_function('s:kebab_case')) . ', [])', - \ 'change symbol style to kebab-case', 1) - call SpaceVim#mapping#space#def('nnoremap', ['x', 'i', '-'], 'silent call call(' - \ . string(s:_function('s:kebab_case')) . ', [])', - \ 'change symbol style to kebab-case', 1) + let g:_spacevim_mappings_space.x = {'name' : '+Text'} + let g:_spacevim_mappings_space.x.a = {'name' : '+align'} + let g:_spacevim_mappings_space.x.d = {'name' : '+delete'} + let g:_spacevim_mappings_space.x.i = {'name' : '+change symbol style'} + nnoremap CountSelectionRegion :call count_selection_region() + xnoremap CountSelectionRegion :call count_selection_region() + call SpaceVim#mapping#space#def('nmap', ['x', 'c'], 'CountSelectionRegion', 'count in the selection region', 0, 1) + call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '&'], 'Tabularize /&', 'align region at &', 1) + call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '('], 'Tabularize /(', 'align region at (', 1) + call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', ')'], 'Tabularize /)', 'align region at )', 1) + call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '['], 'Tabularize /[', 'align region at [', 1) + call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', ']'], 'Tabularize /]', 'align region at ]', 1) + call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '{'], 'Tabularize /{', 'align region at {', 1) + call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '}'], 'Tabularize /}', 'align region at }', 1) + call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', ','], 'Tabularize /,', 'align region at ,', 1) + call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '.'], 'Tabularize /.', 'align region at .', 1) + call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', ':'], 'Tabularize /:', 'align region at :', 1) + call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', ';'], 'Tabularize /;', 'align region at ;', 1) + call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '='], 'Tabularize /=', 'align region at =', 1) + call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '¦'], 'Tabularize /¦', 'align region at ¦', 1) + call SpaceVim#mapping#space#def('nnoremap', ['x', 'd', 'w'], 'StripWhitespace', 'delete trailing whitespaces', 1) + call SpaceVim#mapping#space#def('nnoremap', ['x', 'd', '[SPC]'], 'silent call call(' + \ . string(s:_function('s:delete_extra_space')) . ', [])', + \ 'delete extra space arround cursor', 1) + call SpaceVim#mapping#space#def('nnoremap', ['x', 'i', 'c'], 'silent call call(' + \ . string(s:_function('s:lowerCamelCase')) . ', [])', + \ 'change symbol style to lowerCamelCase', 1) + call SpaceVim#mapping#space#def('nnoremap', ['x', 'i', 'C'], 'silent call call(' + \ . string(s:_function('s:UpperCamelCase')) . ', [])', + \ 'change symbol style to UpperCamelCase', 1) + call SpaceVim#mapping#space#def('nnoremap', ['x', 'i', '_'], 'silent call call(' + \ . string(s:_function('s:under_score')) . ', [])', + \ 'change symbol style to under_score', 1) + call SpaceVim#mapping#space#def('nnoremap', ['x', 'i', 'u'], 'silent call call(' + \ . string(s:_function('s:under_score')) . ', [])', + \ 'change symbol style to under_score', 1) + call SpaceVim#mapping#space#def('nnoremap', ['x', 'i', 'U'], 'silent call call(' + \ . string(s:_function('s:up_case')) . ', [])', + \ 'change symbol style to UP_CACE', 1) + call SpaceVim#mapping#space#def('nnoremap', ['x', 'i', 'k'], 'silent call call(' + \ . string(s:_function('s:kebab_case')) . ', [])', + \ 'change symbol style to kebab-case', 1) + call SpaceVim#mapping#space#def('nnoremap', ['x', 'i', '-'], 'silent call call(' + \ . string(s:_function('s:kebab_case')) . ', [])', + \ 'change symbol style to kebab-case', 1) - let g:_spacevim_mappings_space.i = {'name' : '+Insertion'} - let g:_spacevim_mappings_space.i.l = {'name' : '+Lorem-ipsum'} - let g:_spacevim_mappings_space.i.p = {'name' : '+Passwords'} - let g:_spacevim_mappings_space.i.U = {'name' : '+UUID'} - call SpaceVim#mapping#space#def('nnoremap', ['i', 'p', 1], 'call call(' - \ . string(s:_function('s:insert_simple_password')) . ', [])', - \ 'insert simple password', 1) - call SpaceVim#mapping#space#def('nnoremap', ['i', 'p', 2], 'call call(' - \ . string(s:_function('s:insert_stronger_password')) . ', [])', - \ 'insert stronger password', 1) - call SpaceVim#mapping#space#def('nnoremap', ['i', 'p', 3], 'call call(' - \ . string(s:_function('s:insert_paranoid_password')) . ', [])', - \ 'insert password for paranoids', 1) - call SpaceVim#mapping#space#def('nnoremap', ['i', 'p', 'p'], 'call call(' - \ . string(s:_function('s:insert_phonetically_password')) . ', [])', - \ 'insert a phonetically easy password', 1) - call SpaceVim#mapping#space#def('nnoremap', ['i', 'p', 'n'], 'call call(' - \ . string(s:_function('s:insert_numerical_password')) . ', [])', - \ 'insert a numerical password', 1) - call SpaceVim#mapping#space#def('nnoremap', ['i', 'u'], 'Unite unicode', 'search and insert unicode', 1) - call SpaceVim#mapping#space#def('nnoremap', ['i', 'U', 'U'], 'call call(' - \ . string(s:_function('s:uuidgen_U')) . ', [])', - \ 'uuidgen-4', 1) - call SpaceVim#mapping#space#def('nnoremap', ['i', 'l', 'l'], 'call call(' - \ . string(s:_function('s:insert_lorem_ipsum_list')) . ', [])', - \ 'insert lorem-ipsum list', 1) - call SpaceVim#mapping#space#def('nnoremap', ['i', 'l', 'p'], 'call call(' - \ . string(s:_function('s:insert_lorem_ipsum_paragraph')) . ', [])', - \ 'insert lorem-ipsum paragraph', 1) - call SpaceVim#mapping#space#def('nnoremap', ['i', 'l', 's'], 'call call(' - \ . string(s:_function('s:insert_lorem_ipsum_sentence')) . ', [])', - \ 'insert lorem-ipsum sentence', 1) - let g:_spacevim_mappings_space.x.g = {'name' : '+translate'} - call SpaceVim#mapping#space#def('nnoremap', ['x', 'g', 't'], 'Ydc', 'translate current word', 1) + let g:_spacevim_mappings_space.i = {'name' : '+Insertion'} + let g:_spacevim_mappings_space.i.l = {'name' : '+Lorem-ipsum'} + let g:_spacevim_mappings_space.i.p = {'name' : '+Passwords'} + let g:_spacevim_mappings_space.i.U = {'name' : '+UUID'} + call SpaceVim#mapping#space#def('nnoremap', ['i', 'p', 1], 'call call(' + \ . string(s:_function('s:insert_simple_password')) . ', [])', + \ 'insert simple password', 1) + call SpaceVim#mapping#space#def('nnoremap', ['i', 'p', 2], 'call call(' + \ . string(s:_function('s:insert_stronger_password')) . ', [])', + \ 'insert stronger password', 1) + call SpaceVim#mapping#space#def('nnoremap', ['i', 'p', 3], 'call call(' + \ . string(s:_function('s:insert_paranoid_password')) . ', [])', + \ 'insert password for paranoids', 1) + call SpaceVim#mapping#space#def('nnoremap', ['i', 'p', 'p'], 'call call(' + \ . string(s:_function('s:insert_phonetically_password')) . ', [])', + \ 'insert a phonetically easy password', 1) + call SpaceVim#mapping#space#def('nnoremap', ['i', 'p', 'n'], 'call call(' + \ . string(s:_function('s:insert_numerical_password')) . ', [])', + \ 'insert a numerical password', 1) + call SpaceVim#mapping#space#def('nnoremap', ['i', 'u'], 'Unite unicode', 'search and insert unicode', 1) + call SpaceVim#mapping#space#def('nnoremap', ['i', 'U', 'U'], 'call call(' + \ . string(s:_function('s:uuidgen_U')) . ', [])', + \ 'uuidgen-4', 1) + call SpaceVim#mapping#space#def('nnoremap', ['i', 'l', 'l'], 'call call(' + \ . string(s:_function('s:insert_lorem_ipsum_list')) . ', [])', + \ 'insert lorem-ipsum list', 1) + call SpaceVim#mapping#space#def('nnoremap', ['i', 'l', 'p'], 'call call(' + \ . string(s:_function('s:insert_lorem_ipsum_paragraph')) . ', [])', + \ 'insert lorem-ipsum paragraph', 1) + call SpaceVim#mapping#space#def('nnoremap', ['i', 'l', 's'], 'call call(' + \ . string(s:_function('s:insert_lorem_ipsum_sentence')) . ', [])', + \ 'insert lorem-ipsum sentence', 1) + let g:_spacevim_mappings_space.x.g = {'name' : '+translate'} + call SpaceVim#mapping#space#def('nnoremap', ['x', 'g', 't'], 'Ydc', 'translate current word', 1) - " move line - call SpaceVim#mapping#space#def('nnoremap', ['x', 'J'], 'call call(' - \ . string(s:_function('s:move_text_down_transient_state')) . ', [])', - \ 'move text down(enter transient state)', 1) - call SpaceVim#mapping#space#def('nnoremap', ['x', 'K'], 'call call(' - \ . string(s:_function('s:move_text_up_transient_state')) . ', [])', - \ 'move text up(enter transient state)', 1) + " move line + call SpaceVim#mapping#space#def('nnoremap', ['x', 'J'], 'call call(' + \ . string(s:_function('s:move_text_down_transient_state')) . ', [])', + \ 'move text down(enter transient state)', 1) + call SpaceVim#mapping#space#def('nnoremap', ['x', 'K'], 'call call(' + \ . string(s:_function('s:move_text_up_transient_state')) . ', [])', + \ 'move text up(enter transient state)', 1) - " transpose - let g:_spacevim_mappings_space.x.t = {'name' : '+transpose'} - call SpaceVim#mapping#space#def('nnoremap', ['x', 't', 'c'], 'call call(' - \ . string(s:_function('s:transpose_with_previous')) . ', ["character"])', - \ 'swap current character with previous one', 1) - call SpaceVim#mapping#space#def('nnoremap', ['x', 't', 'w'], 'call call(' - \ . string(s:_function('s:transpose_with_previous')) . ', ["word"])', - \ 'swap current word with previous one', 1) - call SpaceVim#mapping#space#def('nnoremap', ['x', 't', 'l'], 'call call(' - \ . string(s:_function('s:transpose_with_previous')) . ', ["line"])', - \ 'swap current line with previous one', 1) + " transpose + let g:_spacevim_mappings_space.x.t = {'name' : '+transpose'} + call SpaceVim#mapping#space#def('nnoremap', ['x', 't', 'c'], 'call call(' + \ . string(s:_function('s:transpose_with_previous')) . ', ["character"])', + \ 'swap current character with previous one', 1) + call SpaceVim#mapping#space#def('nnoremap', ['x', 't', 'w'], 'call call(' + \ . string(s:_function('s:transpose_with_previous')) . ', ["word"])', + \ 'swap current word with previous one', 1) + call SpaceVim#mapping#space#def('nnoremap', ['x', 't', 'l'], 'call call(' + \ . string(s:_function('s:transpose_with_previous')) . ', ["line"])', + \ 'swap current line with previous one', 1) endfunction function! s:transpose_with_previous(type) abort - if a:type ==# 'line' - if line('.') > 1 - normal! kddp - endif - elseif a:type ==# 'word' - let save_register = @k - normal! "kyiw - let cw = @k - normal! ge"kyiw - let tw = @k - if cw !=# tw - let @k = cw - normal! viw"kp - let @k = tw - normal! eviw"kp - endif - let @k =save_register - elseif a:type ==# 'character' - if col('.') > 1 - let save_register_k = @k - let save_register_m = @m - normal! v"kyhv"myv"kplv"mp - let @k =save_register_k - let @m =save_register_m - endif + if a:type ==# 'line' + if line('.') > 1 + normal! kddp endif + elseif a:type ==# 'word' + let save_register = @k + normal! "kyiw + let cw = @k + normal! ge"kyiw + let tw = @k + if cw !=# tw + let @k = cw + normal! viw"kp + let @k = tw + normal! eviw"kp + endif + let @k =save_register + elseif a:type ==# 'character' + if col('.') > 1 + let save_register_k = @k + let save_register_m = @m + normal! v"kyhv"myv"kplv"mp + let @k =save_register_k + let @m =save_register_m + endif + endif endfunction function! s:move_text_down_transient_state() abort + if line('.') == line('$') + else normal! ddp - call s:text_transient_state() + endif + call s:text_transient_state() endfunction function! s:move_text_up_transient_state() abort + if line('.') == 1 + else normal! ddkP - call s:text_transient_state() + endif + call s:text_transient_state() endfunction function! s:text_transient_state() abort - let state = SpaceVim#api#import('transient_state') - call state.set_title('Move Text Transient State') - call state.defind_keys( - \ { - \ 'layout' : 'vertical split', - \ 'left' : [ - \ { - \ 'key' : 'J', - \ 'desc' : 'move text down', - \ 'func' : '', - \ 'cmd' : 'normal! "_ddp', - \ 'exit' : 0, - \ }, - \ ], - \ 'right' : [ - \ { - \ 'key' : 'K', - \ 'desc' : 'move text up', - \ 'func' : '', - \ 'cmd' : 'normal! "_ddkP', - \ 'exit' : 0, - \ }, - \ ], - \ } - \ ) - call state.open() + let state = SpaceVim#api#import('transient_state') + call state.set_title('Move Text Transient State') + call state.defind_keys( + \ { + \ 'layout' : 'vertical split', + \ 'left' : [ + \ { + \ 'key' : 'J', + \ 'desc' : 'move text down', + \ 'func' : '', + \ 'cmd' : 'noautocmd silent! m .+1', + \ 'exit' : 0, + \ }, + \ ], + \ 'right' : [ + \ { + \ 'key' : 'K', + \ 'func' : '', + \ 'desc' : 'move text up', + \ 'cmd' : 'noautocmd silent! m .-2', + \ 'exit' : 0, + \ }, + \ ], + \ } + \ ) + call state.open() endfunction function! s:lowerCamelCase() abort - " fooFzz - let cword = s:parse_symbol(expand('')) - if !empty(cword) - let rst = [cword[0]] - if len(cword) > 1 - let rst += map(cword[1:], "substitute(v:val, '^.', '\\u&', 'g')") - endif - let save_register = @k - let save_cursor = getcurpos() - let @k = join(rst, '') - normal! viw"kp - call setpos('.', save_cursor) - let @k = save_register + " fooFzz + let cword = s:parse_symbol(expand('')) + if !empty(cword) + let rst = [cword[0]] + if len(cword) > 1 + let rst += map(cword[1:], "substitute(v:val, '^.', '\\u&', 'g')") endif + let save_register = @k + let save_cursor = getcurpos() + let @k = join(rst, '') + normal! viw"kp + call setpos('.', save_cursor) + let @k = save_register + endif endfunction function! s:UpperCamelCase() abort - " FooFzz - let cword = s:parse_symbol(expand('')) - if !empty(cword) - let rst = map(cword, "substitute(v:val, '^.', '\\u&', 'g')") - let save_register = @k - let save_cursor = getcurpos() - let @k = join(rst, '') - normal! viw"kp - call setpos('.', save_cursor) - let @k = save_register - endif + " FooFzz + let cword = s:parse_symbol(expand('')) + if !empty(cword) + let rst = map(cword, "substitute(v:val, '^.', '\\u&', 'g')") + let save_register = @k + let save_cursor = getcurpos() + let @k = join(rst, '') + normal! viw"kp + call setpos('.', save_cursor) + let @k = save_register + endif endfunction function! s:kebab_case() abort - " foo-fzz - let cword = s:parse_symbol(expand('')) - if !empty(cword) - let save_register = @k - let save_cursor = getcurpos() - let @k = join(cword, '-') - normal! viw"kp - call setpos('.', save_cursor) - let @k = save_register - endif + " foo-fzz + let cword = s:parse_symbol(expand('')) + if !empty(cword) + let save_register = @k + let save_cursor = getcurpos() + let @k = join(cword, '-') + normal! viw"kp + call setpos('.', save_cursor) + let @k = save_register + endif endfunction function! s:under_score() abort - " foo_fzz - let cword = s:parse_symbol(expand('')) - if !empty(cword) - let save_register = @k - let save_cursor = getcurpos() - let @k = join(cword, '_') - normal! viw"kp - call setpos('.', save_cursor) - let @k = save_register - endif + " foo_fzz + let cword = s:parse_symbol(expand('')) + if !empty(cword) + let save_register = @k + let save_cursor = getcurpos() + let @k = join(cword, '_') + normal! viw"kp + call setpos('.', save_cursor) + let @k = save_register + endif endfunction function! s:up_case() abort - " FOO_FZZ - let cword =map(s:parse_symbol(expand('')), 'toupper(v:val)') - if !empty(cword) - let save_register = @k - let save_cursor = getcurpos() - let @k = join(cword, '_') - normal! viw"kp - call setpos('.', save_cursor) - let @k = save_register - endif + " FOO_FZZ + let cword =map(s:parse_symbol(expand('')), 'toupper(v:val)') + if !empty(cword) + let save_register = @k + let save_cursor = getcurpos() + let @k = join(cword, '_') + normal! viw"kp + call setpos('.', save_cursor) + let @k = save_register + endif endfunction let s:STRING = SpaceVim#api#import('data#string') function! s:parse_symbol(symbol) abort - if a:symbol =~# '^[a-z]\+\(-[a-zA-Z]\+\)*$' - return split(a:symbol, '-') - elseif a:symbol =~# '^[a-z]\+\(_[a-zA-Z]\+\)*$' - return split(a:symbol, '_') - elseif a:symbol =~# '^[a-z]\+\([A-Z][a-z]\+\)*$' - let chars = s:STRING.string2chars(a:symbol) - let rst = [] - let word = '' - for char in chars - if char =~# '[a-z]' - let word .= char - else - call add(rst, tolower(word)) - let word = char - endif - endfor + if a:symbol =~# '^[a-z]\+\(-[a-zA-Z]\+\)*$' + return split(a:symbol, '-') + elseif a:symbol =~# '^[a-z]\+\(_[a-zA-Z]\+\)*$' + return split(a:symbol, '_') + elseif a:symbol =~# '^[a-z]\+\([A-Z][a-z]\+\)*$' + let chars = s:STRING.string2chars(a:symbol) + let rst = [] + let word = '' + for char in chars + if char =~# '[a-z]' + let word .= char + else call add(rst, tolower(word)) - return rst - elseif a:symbol =~# '^[A-Z][a-z]\+\([A-Z][a-z]\+\)*$' - let chars = s:STRING.string2chars(a:symbol) - let rst = [] - let word = '' - for char in chars - if char =~# '[a-z]' - let word .= char - else - if !empty(word) - call add(rst, tolower(word)) - endif - let word = char - endif - endfor - call add(rst, tolower(word)) - return rst - else - return [a:symbol] - endif + let word = char + endif + endfor + call add(rst, tolower(word)) + return rst + elseif a:symbol =~# '^[A-Z][a-z]\+\([A-Z][a-z]\+\)*$' + let chars = s:STRING.string2chars(a:symbol) + let rst = [] + let word = '' + for char in chars + if char =~# '[a-z]' + let word .= char + else + if !empty(word) + call add(rst, tolower(word)) + endif + let word = char + endif + endfor + call add(rst, tolower(word)) + return rst + else + return [a:symbol] + endif endfunction function! s:count_selection_region() abort - call feedkeys("gvg\\", 'ti') + call feedkeys("gvg\\", 'ti') endfunction function! s:delete_extra_space() abort - if !empty(getline('.')) - if getline('.')[col('.')-1] ==# ' ' - exe "normal! viw\"_di\\" - endif + if !empty(getline('.')) + if getline('.')[col('.')-1] ==# ' ' + exe "normal! viw\"_di\\" endif + endif endfunction let s:local_lorem_ipsum = [ - \ 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit.', - \ 'Donec hendrerit tempor tellus.', - \ 'Donec pretium posuere tellus.', - \ 'Proin quam nisl, tincidunt et, mattis eget, convallis nec, purus.', - \ 'Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.', - \ 'Nulla posuere.', - \ 'Donec vitae dolor.', - \ 'Nullam tristique diam non turpis.', - \ 'Cras placerat accumsan nulla.', - \ 'Nullam rutrum.', - \ 'Nam vestibulum accumsan nisl.', - \ 'Pellentesque dapibus suscipit ligula.', - \ 'Donec posuere augue in quam.', - \ 'Etiam vel tortor sodales tellus ultricies commodo.', - \ 'Suspendisse potenti.', - \ 'Aenean in sem ac leo mollis blandit.', - \ 'Donec neque quam, dignissim in, mollis nec, sagittis eu, wisi.', - \ 'Phasellus lacus.', - \ 'Etiam laoreet quam sed arcu.', - \ 'Phasellus at dui in ligula mollis ultricies.', - \ 'Integer placerat tristique nisl.', - \ 'Praesent augue.', - \ 'Fusce commodo.', - \ 'Vestibulum convallis, lorem a tempus semper, dui dui euismod elit, vitae placerat urna tortor vitae lacus.', - \ 'Nullam libero mauris, consequat quis, varius et, dictum id, arcu.', - \ 'Mauris mollis tincidunt felis.', - \ 'Aliquam feugiat tellus ut neque.', - \ 'Nulla facilisis, risus a rhoncus fermentum, tellus tellus lacinia purus, et dictum nunc justo sit amet elit.', - \ 'Aliquam erat volutpat.', - \ 'Nunc eleifend leo vitae magna.', - \ 'In id erat non orci commodo lobortis.', - \ 'Proin neque massa, cursus ut, gravida ut, lobortis eget, lacus.', - \ 'Sed diam.', - \ 'Praesent fermentum tempor tellus.', - \ 'Nullam tempus.', - \ 'Mauris ac felis vel velit tristique imperdiet.', - \ 'Donec at pede.', - \ 'Etiam vel neque nec dui dignissim bibendum.', - \ 'Vivamus id enim.', - \ 'Phasellus neque orci, porta a, aliquet quis, semper a, massa.', - \ 'Phasellus purus.', - \ 'Pellentesque tristique imperdiet tortor.', - \ 'Nam euismod tellus id erat.', - \ 'Nullam eu ante vel est convallis dignissim.', - \ 'Fusce suscipit, wisi nec facilisis facilisis, est dui fermentum leo, quis tempor ligula erat quis odio.', - \ 'Nunc porta vulputate tellus.', - \ 'Nunc rutrum turpis sed pede.', - \ 'Sed bibendum.', - \ 'Aliquam posuere.', - \ 'Nunc aliquet, augue nec adipiscing interdum, lacus tellus malesuada massa, quis varius mi purus non odio.', - \ 'Pellentesque condimentum, magna ut suscipit hendrerit, ipsum augue ornare nulla, non luctus diam neque sit amet urna.', - \ 'Curabitur vulputate vestibulum lorem.', - \ 'Fusce sagittis, libero non molestie mollis, magna orci ultrices dolor, at vulputate neque nulla lacinia eros.', - \ 'Sed id ligula quis est convallis tempor.', - \ 'Curabitur lacinia pulvinar nibh.', - \ 'Nam a sapien.', - \ ] + \ 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit.', + \ 'Donec hendrerit tempor tellus.', + \ 'Donec pretium posuere tellus.', + \ 'Proin quam nisl, tincidunt et, mattis eget, convallis nec, purus.', + \ 'Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.', + \ 'Nulla posuere.', + \ 'Donec vitae dolor.', + \ 'Nullam tristique diam non turpis.', + \ 'Cras placerat accumsan nulla.', + \ 'Nullam rutrum.', + \ 'Nam vestibulum accumsan nisl.', + \ 'Pellentesque dapibus suscipit ligula.', + \ 'Donec posuere augue in quam.', + \ 'Etiam vel tortor sodales tellus ultricies commodo.', + \ 'Suspendisse potenti.', + \ 'Aenean in sem ac leo mollis blandit.', + \ 'Donec neque quam, dignissim in, mollis nec, sagittis eu, wisi.', + \ 'Phasellus lacus.', + \ 'Etiam laoreet quam sed arcu.', + \ 'Phasellus at dui in ligula mollis ultricies.', + \ 'Integer placerat tristique nisl.', + \ 'Praesent augue.', + \ 'Fusce commodo.', + \ 'Vestibulum convallis, lorem a tempus semper, dui dui euismod elit, vitae placerat urna tortor vitae lacus.', + \ 'Nullam libero mauris, consequat quis, varius et, dictum id, arcu.', + \ 'Mauris mollis tincidunt felis.', + \ 'Aliquam feugiat tellus ut neque.', + \ 'Nulla facilisis, risus a rhoncus fermentum, tellus tellus lacinia purus, et dictum nunc justo sit amet elit.', + \ 'Aliquam erat volutpat.', + \ 'Nunc eleifend leo vitae magna.', + \ 'In id erat non orci commodo lobortis.', + \ 'Proin neque massa, cursus ut, gravida ut, lobortis eget, lacus.', + \ 'Sed diam.', + \ 'Praesent fermentum tempor tellus.', + \ 'Nullam tempus.', + \ 'Mauris ac felis vel velit tristique imperdiet.', + \ 'Donec at pede.', + \ 'Etiam vel neque nec dui dignissim bibendum.', + \ 'Vivamus id enim.', + \ 'Phasellus neque orci, porta a, aliquet quis, semper a, massa.', + \ 'Phasellus purus.', + \ 'Pellentesque tristique imperdiet tortor.', + \ 'Nam euismod tellus id erat.', + \ 'Nullam eu ante vel est convallis dignissim.', + \ 'Fusce suscipit, wisi nec facilisis facilisis, est dui fermentum leo, quis tempor ligula erat quis odio.', + \ 'Nunc porta vulputate tellus.', + \ 'Nunc rutrum turpis sed pede.', + \ 'Sed bibendum.', + \ 'Aliquam posuere.', + \ 'Nunc aliquet, augue nec adipiscing interdum, lacus tellus malesuada massa, quis varius mi purus non odio.', + \ 'Pellentesque condimentum, magna ut suscipit hendrerit, ipsum augue ornare nulla, non luctus diam neque sit amet urna.', + \ 'Curabitur vulputate vestibulum lorem.', + \ 'Fusce sagittis, libero non molestie mollis, magna orci ultrices dolor, at vulputate neque nulla lacinia eros.', + \ 'Sed id ligula quis est convallis tempor.', + \ 'Curabitur lacinia pulvinar nibh.', + \ 'Nam a sapien.', + \ ] let s:lorem_ipsum_paragraph_separator = "\n\n" let s:lorem_ipsum_sentence_separator = ' ' @@ -413,93 +423,93 @@ let s:lorem_ipsum_list_item_end = "\n" let s:lorem_ipsum_list_end = '' function! s:insert_lorem_ipsum_list() abort - let save_register = @k - let @k = '* ' . s:local_lorem_ipsum[s:NUMBER.random(0, len(s:local_lorem_ipsum))] . "\n" - normal! "kgP - let @k = save_register + let save_register = @k + let @k = '* ' . s:local_lorem_ipsum[s:NUMBER.random(0, len(s:local_lorem_ipsum))] . "\n" + normal! "kgP + let @k = save_register endfunction function! s:insert_lorem_ipsum_paragraph() abort - let save_register = @k - let pids = len(s:local_lorem_ipsum) / 11 - let pid = s:NUMBER.random(0, pids) * 11 - let @k = join(s:LIST.listpart(s:local_lorem_ipsum, pid, 11), s:lorem_ipsum_sentence_separator) . s:lorem_ipsum_paragraph_separator - normal! "kgP - let @k = save_register + let save_register = @k + let pids = len(s:local_lorem_ipsum) / 11 + let pid = s:NUMBER.random(0, pids) * 11 + let @k = join(s:LIST.listpart(s:local_lorem_ipsum, pid, 11), s:lorem_ipsum_sentence_separator) . s:lorem_ipsum_paragraph_separator + normal! "kgP + let @k = save_register endfunction function! s:insert_lorem_ipsum_sentence() abort - let save_register = @k - let @k = s:local_lorem_ipsum[s:NUMBER.random(0, len(s:local_lorem_ipsum))] . s:lorem_ipsum_sentence_separator - normal! "kgP - let @k = save_register + let save_register = @k + let @k = s:local_lorem_ipsum[s:NUMBER.random(0, len(s:local_lorem_ipsum))] . s:lorem_ipsum_sentence_separator + normal! "kgP + let @k = save_register endfunction function! s:insert_simple_password() abort - let save_register = @k - let @k = s:PASSWORD.generate_simple(8) - normal! "kPl - let @k = save_register + let save_register = @k + let @k = s:PASSWORD.generate_simple(8) + normal! "kPl + let @k = save_register endfunction function! s:insert_stronger_password() abort - let save_register = @k - let @k = s:PASSWORD.generate_strong(12) - normal! "kPl - let @k = save_register + let save_register = @k + let @k = s:PASSWORD.generate_strong(12) + normal! "kPl + let @k = save_register endfunction function! s:insert_paranoid_password() abort - let save_register = @k - let @k = s:PASSWORD.generate_paranoid(20) - normal! "kPl - let @k = save_register + let save_register = @k + let @k = s:PASSWORD.generate_paranoid(20) + normal! "kPl + let @k = save_register endfunction function! s:insert_numerical_password() abort - let save_register = @k - let @k = s:PASSWORD.generate_numeric(4) - normal! "kPl - let @k = save_register + let save_register = @k + let @k = s:PASSWORD.generate_numeric(4) + normal! "kPl + let @k = save_register endfunction function! s:insert_phonetically_password() abort - let save_register = @k - let @k = s:PASSWORD.generate_phonetic(8) - normal! "kPl - let @k = save_register + let save_register = @k + let @k = s:PASSWORD.generate_phonetic(8) + normal! "kPl + let @k = save_register endfunction function! s:uuidgen_U() abort - let uuid = system('uuidgen') - let save_register = @k - let @k = uuid - normal! "kPl - let @k = save_register + let uuid = system('uuidgen') + let save_register = @k + let @k = uuid + normal! "kPl + let @k = save_register endfunction " function() wrapper if v:version > 703 || v:version == 703 && has('patch1170') - function! s:_function(fstr) abort - return function(a:fstr) - endfunction + function! s:_function(fstr) abort + return function(a:fstr) + endfunction else - function! s:_SID() abort - return matchstr(expand(''), '\zs\d\+\ze__SID$') - endfunction - let s:_s = '' . s:_SID() . '_' - function! s:_function(fstr) abort - return function(substitute(a:fstr, 's:', s:_s, 'g')) - endfunction + function! s:_SID() abort + return matchstr(expand(''), '\zs\d\+\ze__SID$') + endfunction + let s:_s = '' . s:_SID() . '_' + function! s:_function(fstr) abort + return function(substitute(a:fstr, 's:', s:_s, 'g')) + endfunction endif augroup spacevim_layer_edit - au! - autocmd BufNewFile *.py call add_buffer_head() + au! + autocmd BufNewFile *.py call add_buffer_head() augroup END let s:ft_head_tp = {} function! s:add_buffer_head() abort - if has_key(s:ft_head_tp, &ft) - call setline(1, s:ft_head_tp[&ft]) - endif + if has_key(s:ft_head_tp, &ft) + call setline(1, s:ft_head_tp[&ft]) + endif endfunction function! SpaceVim#layers#edit#add_ft_head_tamplate(ft, tamp) - call extend(s:ft_head_tp, {a:ft : a:tamp}) + call extend(s:ft_head_tp, {a:ft : a:tamp}) endfunction diff --git a/autoload/SpaceVim/layers/git.vim b/autoload/SpaceVim/layers/git.vim index 124f43a05..a1069b554 100644 --- a/autoload/SpaceVim/layers/git.vim +++ b/autoload/SpaceVim/layers/git.vim @@ -42,6 +42,7 @@ function! SpaceVim#layers#git#config() abort autocmd! autocmd FileType diff nnoremap q :bd! autocmd FileType gitcommit setl omnifunc=SpaceVim#plugins#gitcommit#complete + autocmd User GitGutter let &l:statusline = SpaceVim#layers#core#statusline#get(1) augroup END call SpaceVim#mapping#space#def('nnoremap', ['g', 'M'], 'call call(' \ . string(function('s:display_last_commit_of_current_line')) . ', [])', diff --git a/autoload/SpaceVim/layers/lang/c.vim b/autoload/SpaceVim/layers/lang/c.vim index 652c891bb..f37595254 100644 --- a/autoload/SpaceVim/layers/lang/c.vim +++ b/autoload/SpaceVim/layers/lang/c.vim @@ -40,10 +40,16 @@ +let s:use_libclang = 0 + function! SpaceVim#layers#lang#c#plugins() abort let plugins = [] if has('nvim') - call add(plugins, ['tweekmonster/deoplete-clang2']) + if s:use_libclang + call add(plugins, ['zchee/deoplete-clang']) + else + call add(plugins, ['tweekmonster/deoplete-clang2']) + endif else call add(plugins, ['Rip-Rip/clang_complete']) endif @@ -56,6 +62,18 @@ function! SpaceVim#layers#lang#c#config() abort call SpaceVim#mapping#space#regesit_lang_mappings('c', funcref('s:language_specified_mappings')) endfunction +function! SpaceVim#layers#lang#c#set_variable(var) abort + " use clang or libclang + let s:use_libclang = get(a:var, + \ 'use_libclang', + \ 'clang') + + if has_key(a:var, 'clang_executable') + let g:completor_clang_binary = a:var.clang_executable + let g:deoplete#sources#clang#executable = a:var.clang_executable + endif +endfunction + function! s:language_specified_mappings() abort call SpaceVim#mapping#space#langSPC('nmap', ['l','r'], diff --git a/autoload/SpaceVim/layers/lang/haskell.vim b/autoload/SpaceVim/layers/lang/haskell.vim index 350915c49..785033217 100644 --- a/autoload/SpaceVim/layers/lang/haskell.vim +++ b/autoload/SpaceVim/layers/lang/haskell.vim @@ -1,23 +1,56 @@ function! SpaceVim#layers#lang#haskell#plugins() abort - let plugins = [] - call add(plugins,['neovimhaskell/haskell-vim', { 'on_ft' : 'haskell'}]) - call add(plugins,['pbrisbin/vim-syntax-shakespeare', { 'on_ft' : 'haskell'}]) - call add(plugins,['eagletmt/neco-ghc', { 'on_ft' : 'haskell'}]) - return plugins + let plugins = [ + \ ['neovimhaskell/haskell-vim', { 'on_ft': 'haskell' }], + \ ['pbrisbin/vim-syntax-shakespeare', { 'on_ft': 'haskell' }], + \ ] + + if !s:use_lsp + call add(plugins, ['eagletmt/neco-ghc', { 'on_ft': 'haskell' }]) + endif + + return plugins +endfunction + +let s:use_lsp = 0 + +function! SpaceVim#layers#lang#haskell#set_variable(var) abort + let s:use_lsp = get(a:var, 'use_lsp', 0) && has('nvim') && executable('hie') endfunction function! SpaceVim#layers#lang#haskell#config() abort let g:haskellmode_completion_ghc = 0 - call SpaceVim#plugins#runner#reg_runner('haskell', ['ghc -v0 --make %s -o #TEMP#', '#TEMP#']) - call SpaceVim#mapping#space#regesit_lang_mappings('haskell', funcref('s:language_specified_mappings')) + call SpaceVim#plugins#runner#reg_runner('haskell', [ + \ 'ghc -v0 --make %s -o #TEMP#', + \ '#TEMP#']) + call SpaceVim#mapping#space#regesit_lang_mappings('haskell', + \ funcref('s:on_ft')) + + if s:use_lsp + call SpaceVim#mapping#gd#add('haskell', + \ function('SpaceVim#lsp#go_to_def')) + call SpaceVim#lsp#reg_server('haskell', ['hie', '--lsp']) + endif augroup SpaceVim_lang_haskell autocmd! - autocmd FileType haskell setlocal omnifunc=necoghc#omnifunc + + if !s:use_lsp + autocmd FileType haskell setlocal omnifunc=necoghc#omnifunc + endif augroup END endfunction -function! s:language_specified_mappings() abort - call SpaceVim#mapping#space#langSPC('nmap', ['l', 'r'], 'call SpaceVim#plugins#runner#open()', 'execute current file', 1) +function! s:on_ft() abort + if s:use_lsp + nnoremap K :call SpaceVim#lsp#show_doc() + + call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'd'], + \ 'call SpaceVim#lsp#show_doc()', 'show_document', 1) + call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'e'], + \ 'call SpaceVim#lsp#rename()', 'rename symbol', 1) + endif + + call SpaceVim#mapping#space#langSPC('nmap', ['l', 'r'], + \ 'call SpaceVim#plugins#runner#open()', 'execute current file', 1) endfunction diff --git a/autoload/SpaceVim/layers/lang/javascript.vim b/autoload/SpaceVim/layers/lang/javascript.vim index c4794315f..1dc40e58c 100644 --- a/autoload/SpaceVim/layers/lang/javascript.vim +++ b/autoload/SpaceVim/layers/lang/javascript.vim @@ -1,26 +1,34 @@ function! SpaceVim#layers#lang#javascript#plugins() abort let plugins = [ - \ ['pangloss/vim-javascript', { 'on_ft' : 'javascript' }], - \ ['othree/yajs.vim', { 'on_ft' : 'javascript' }], - \ ['othree/es.next.syntax.vim', { 'on_ft' : 'javascript' }], - \ ['othree/javascript-libraries-syntax.vim', { 'on_ft' : ['javascript', 'coffee', 'ls', 'typescript'] }], - \ ['MaxMEllon/vim-jsx-pretty', { 'on_ft' : 'javascript' }], - \ ['ternjs/tern_for_vim', { 'on_ft' : 'javascript', 'build' : 'npm install' }], - \ ['Galooshi/vim-import-js', { 'on_ft' : 'javascript', 'build' : 'npm install -g import-js' }], - \ ['maksimr/vim-jsbeautify', { 'on_ft' : 'javascript' }], - \ ['mmalecki/vim-node.js', { 'on_ft' : 'javascript' }], + \ ['MaxMEllon/vim-jsx-pretty', { 'on_ft': 'javascript' }], + \ ['Galooshi/vim-import-js', { + \ 'on_ft': 'javascript', 'build' : 'npm install -g import-js' }], + \ ['maksimr/vim-jsbeautify', { 'on_ft': 'javascript' }], + \ ['mmalecki/vim-node.js', { 'on_ft': 'javascript' }], + \ ['moll/vim-node', { 'on_ft': 'javascript' }], + \ ['othree/es.next.syntax.vim', { 'on_ft': 'javascript' }], + \ ['othree/javascript-libraries-syntax.vim', { + \ 'on_ft': ['javascript', 'coffee', 'ls', 'typescript'] }], + \ ['othree/yajs.vim', { 'on_ft': 'javascript' }], + \ ['pangloss/vim-javascript', { 'on_ft': 'javascript' }], \ ] - if has('nvim') - call add(plugins,['carlitux/deoplete-ternjs', { 'on_ft' : ['javascript'] }]) + if !s:use_lsp + call add(plugins, ['ternjs/tern_for_vim', { + \ 'on_ft': 'javascript', 'build' : 'npm install' }]) + call add(plugins, ['carlitux/deoplete-ternjs', { 'on_ft': [ + \ 'javascript'], 'if': has('nvim') }]) endif return plugins endfunction +let s:use_lsp = 0 let s:auto_fix = 0 function! SpaceVim#layers#lang#javascript#set_variable(var) abort + let s:use_lsp = get(a:var, 'use_lsp', 0) && has('nvim') + \ && executable('javascript-typescript-stdio') let s:auto_fix = get(a:var, 'auto_fix', 0) endfunction @@ -34,9 +42,17 @@ function! SpaceVim#layers#lang#javascript#config() abort let g:vim_jsx_pretty_colorful_config = 1 " }}} - call SpaceVim#mapping#gd#add('javascript', function('s:gotodef')) call SpaceVim#plugins#runner#reg_runner('javascript', 'node %s') - call SpaceVim#mapping#space#regesit_lang_mappings('javascript', funcref('s:language_specified_mappings')) + call SpaceVim#mapping#space#regesit_lang_mappings('javascript', + \ funcref('s:on_ft')) + + if s:use_lsp + call SpaceVim#lsp#reg_server('javascript', ['javascript-typescript-stdio']) + call SpaceVim#mapping#gd#add('javascript', + \ function('SpaceVim#lsp#go_to_def')) + else + call SpaceVim#mapping#gd#add('javascript', function('s:tern_go_to_def')) + endif if s:auto_fix " Only use eslint @@ -52,12 +68,7 @@ function! SpaceVim#layers#lang#javascript#config() abort endif endfunction -function! s:language_specified_mappings() abort - " ternjs/tern_for_vim {{{ - call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'd'], 'TernDoc', 'Look up the documentation of something', 1) - call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'e'], 'TernRename', 'Rename the variable under the cursor', 1) - " }}} - +function! s:on_ft() abort " Galooshi/vim-import-js {{{ nnoremap :ImportJSWord nnoremap ji :ImportJSWord @@ -70,14 +81,28 @@ function! s:language_specified_mappings() abort inoremap g :ImportJSGotoa " }}} - call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'r'], 'call SpaceVim#plugins#runner#open()', 'execute current file', 1) + if s:use_lsp + nnoremap K :call SpaceVim#lsp#show_doc() + + call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'd'], + \ 'call SpaceVim#lsp#show_doc()', 'show_document', 1) + call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'e'], + \ 'call SpaceVim#lsp#rename()', 'rename symbol', 1) + else + call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'd'], 'TernDoc', + \ 'show document', 1) + call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'e'], 'TernRename', + \ 'rename symbol', 1) + endif + + call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'r'], + \ 'call SpaceVim#plugins#runner#open()', 'execute current file', 1) endfunction -function! s:gotodef() abort +function! s:tern_go_to_def() abort if exists(':TernDef') TernDef endif endfunction - -" vim:set et sw=2 cc=80: +" vi: et sw=2 cc=80 diff --git a/autoload/SpaceVim/layers/lang/python.vim b/autoload/SpaceVim/layers/lang/python.vim index 3cf3634b7..30878b77a 100644 --- a/autoload/SpaceVim/layers/lang/python.vim +++ b/autoload/SpaceVim/layers/lang/python.vim @@ -18,6 +18,7 @@ function! SpaceVim#layers#lang#python#plugins() abort endif call add(plugins, ['Vimjas/vim-python-pep8-indent', \ { 'on_ft' : 'python'}]) + call add(plugins, ['tell-k/vim-autoflake', {'merged' : 0}]) return plugins endfunction @@ -29,12 +30,36 @@ function! SpaceVim#layers#lang#python#config() abort \ '# -*- coding: utf-8 -*-', \ ''] \ ) - + let g:no_autoflake_maps = 1 + if executable('ipython') + call SpaceVim#plugins#repl#reg('python', 'ipython') + elseif executable('python') + call SpaceVim#plugins#repl#reg('python', 'python') + endif endfunction function! s:language_specified_mappings() abort - call SpaceVim#mapping#space#langSPC('nmap', ['l','r'], \ 'call SpaceVim#plugins#runner#open()', \ 'execute current file', 1) + let g:_spacevim_mappings_space.l.i = {'name' : '+Imports'} + call SpaceVim#mapping#space#langSPC('nmap', ['l','i', 's'], + \ 'Neoformat isort', + \ 'sort imports', 1) + call SpaceVim#mapping#space#langSPC('nmap', ['l','i', 'r'], + \ 'Autoflake', + \ 'remove unused imports', 1) + let g:_spacevim_mappings_space.l.s = {'name' : '+Send'} + call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'i'], + \ 'call SpaceVim#plugins#repl#start("python")', + \ 'start REPL process', 1) + call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'l'], + \ 'call SpaceVim#plugins#repl#send("line")', + \ 'send line and keep code buffer focused', 1) + call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'b'], + \ 'call SpaceVim#plugins#repl#send("buffer")', + \ 'send buffer and keep code buffer focused', 1) + call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 's'], + \ 'call SpaceVim#plugins#repl#send("selection")', + \ 'send selection and keep code buffer focused', 1) endfunction diff --git a/autoload/SpaceVim/layers/lang/ruby.vim b/autoload/SpaceVim/layers/lang/ruby.vim index be2019e34..b2d08eef0 100644 --- a/autoload/SpaceVim/layers/lang/ruby.vim +++ b/autoload/SpaceVim/layers/lang/ruby.vim @@ -8,15 +8,33 @@ function! SpaceVim#layers#lang#ruby#plugins() abort return [ - \ ['vim-ruby/vim-ruby', { 'on_ft' : 'ruby' }] - \ ] + \ ['vim-ruby/vim-ruby', { 'on_ft' : 'ruby' }] + \ ] endfunction function! SpaceVim#layers#lang#ruby#config() abort call SpaceVim#plugins#runner#reg_runner('ruby', 'ruby %s') call SpaceVim#mapping#space#regesit_lang_mappings('ruby', funcref('s:language_specified_mappings')) + call SpaceVim#plugins#repl#reg('ruby', 'irb') endfunction function! s:language_specified_mappings() abort call SpaceVim#mapping#space#langSPC('nmap', ['l', 'r'], 'call SpaceVim#plugins#runner#open()', 'execute current file', 1) + let g:_spacevim_mappings_space.l.s = {'name' : '+Send'} + call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'i'], + \ 'call SpaceVim#plugins#repl#start("ruby")', + \ 'start REPL process', 1) + call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'l'], + \ 'call SpaceVim#plugins#repl#send("line")', + \ 'send line and keep code buffer focused', 1) + call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'b'], + \ 'call SpaceVim#plugins#repl#send("buffer")', + \ 'send buffer and keep code buffer focused', 1) + call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 's'], + \ 'call SpaceVim#plugins#repl#send("selection")', + \ 'send selection and keep code buffer focused', 1) + let g:_spacevim_mappings_space.l.c = {'name' : '+RuboCop'} + call SpaceVim#mapping#space#langSPC('nmap', ['l','c', 'f'], + \ 'Noeformat rubocop', + \ 'Runs RuboCop on the currently visited file', 1) endfunction diff --git a/autoload/SpaceVim/layers/lang/sh.vim b/autoload/SpaceVim/layers/lang/sh.vim index db7bf155e..3fab71c25 100644 --- a/autoload/SpaceVim/layers/lang/sh.vim +++ b/autoload/SpaceVim/layers/lang/sh.vim @@ -1,7 +1,12 @@ -function! SpaceVim#layers#lang#javascript#plugins() abort - return [ - \ ['chrisbra/vim-zsh', { 'on_ft' : 'zsh' }] - \ ] +function! SpaceVim#layers#lang#sh#plugins() abort + let l:plugins = [] + call add(l:plugins, ['chrisbra/vim-zsh', { 'on_ft' : 'zsh' }]) + if get(g:, 'spacevim_enable_ycm') == 1 + call add(l:plugins, ['Valodim/vim-zsh-completion', { 'on_ft' : 'zsh' }]) + else + call add(l:plugins, ['zchee/deoplete-zsh', { 'on_ft' : 'zsh' }]) + endif + return l:plugins endfunction function! SpaceVim#layers#lang#sh#config() diff --git a/autoload/SpaceVim/layers/lsp.vim b/autoload/SpaceVim/layers/lsp.vim index 88c6e15e0..63bbe005e 100644 --- a/autoload/SpaceVim/layers/lsp.vim +++ b/autoload/SpaceVim/layers/lsp.vim @@ -58,7 +58,7 @@ function! SpaceVim#layers#lsp#config() abort let g:LanguageClient_diagnosticsDisplay[4].signTexthl = 'ALEInfoSign' endif - let g:LanguageClient_autoStart = 0 + let g:LanguageClient_autoStart = 1 " }}} endfunction diff --git a/autoload/SpaceVim/layers/shell.vim b/autoload/SpaceVim/layers/shell.vim index 8322c5a5e..23d657617 100644 --- a/autoload/SpaceVim/layers/shell.vim +++ b/autoload/SpaceVim/layers/shell.vim @@ -69,7 +69,7 @@ function! s:open_default_shell() abort if has('nvim') exe 'terminal' else - call term_start('bash', {'curwin' : 1, 'term_finish' : 'close'}) + call term_start($SHELL, {'curwin' : 1, 'term_finish' : 'close'}) endif let s:shell_win_nr = winnr() let w:shell_layer_win = 1 diff --git a/autoload/SpaceVim/layers/tmux.vim b/autoload/SpaceVim/layers/tmux.vim index 5ba1b5f14..229a96ecf 100644 --- a/autoload/SpaceVim/layers/tmux.vim +++ b/autoload/SpaceVim/layers/tmux.vim @@ -19,21 +19,27 @@ " < function! SpaceVim#layers#tmux#plugins() abort - let plugins = [] - call add(plugins,['christoomey/vim-tmux-navigator', {'merged' : 0}]) - return plugins + let plugins = [ + \ ['christoomey/vim-tmux-navigator', { 'on_cmd': [ + \ 'TmuxNavigateLeft', 'TmuxNavigateDown', 'TmuxNavigateUp', + \ 'TmuxNavigateRight'] }], + \ ] + + return plugins endfunction function! SpaceVim#layers#tmux#config() abort - let g:tmux_navigator_no_mappings = 1 - augroup spacevim_layer_tmux - au! - au VimEnter * call s:tmuxMappings() - augroup END - func s:tmuxMappings() - nnoremap :TmuxNavigateLeft - nnoremap :TmuxNavigateDown - nnoremap :TmuxNavigateUp - nnoremap :TmuxNavigateRight - endf + let g:tmux_navigator_no_mappings = 1 + + augroup SpaceVim_layer_tmux + autocmd! + autocmd FocusGained * set cursorline + autocmd FocusLost * set nocursorline | redraw! + augroup END + + nnoremap :TmuxNavigateLeft + nnoremap :TmuxNavigateDown + nnoremap :TmuxNavigateUp + nnoremap :TmuxNavigateRight endfunction + diff --git a/autoload/SpaceVim/layers/tools.vim b/autoload/SpaceVim/layers/tools.vim index 2bf3aef75..e1fc1cd39 100644 --- a/autoload/SpaceVim/layers/tools.vim +++ b/autoload/SpaceVim/layers/tools.vim @@ -12,6 +12,7 @@ function! SpaceVim#layers#tools#plugins() abort \ 'loadconf' : 1, \ 'merged' : 0}], \ ['MattesGroeger/vim-bookmarks', { 'on_map' : 'Bookmark', + \ 'on_cmd' : 'BookmarkShowAll', \ 'loadconf_before' : 1}], \ ['simnalamburt/vim-mundo', { 'on_cmd' : 'MundoToggle'}], \ ['mhinz/vim-grepper' , { 'on_cmd' : 'Grepper', diff --git a/autoload/SpaceVim/lsp.vim b/autoload/SpaceVim/lsp.vim new file mode 100644 index 000000000..0932e2de3 --- /dev/null +++ b/autoload/SpaceVim/lsp.vim @@ -0,0 +1,22 @@ +scriptencoding utf-8 + +" lsp.vim +" author: Seong Yong-ju ( @sei40kr ) + +function! SpaceVim#lsp#reg_server(ft, cmds) abort + let g:LanguageClient_serverCommands[a:ft] = copy(a:cmds) +endfunction + +function! SpaceVim#lsp#show_doc() abort + call LanguageClient_textDocument_hover() +endfunction + +function! SpaceVim#lsp#go_to_def() abort + call LanguageClient_textDocument_definition() +endfunction + +function! SpaceVim#lsp#rename() abort + call LanguageClient_textDocument_rename() +endfunction + +" vi: et sw=2 cc=80 diff --git a/autoload/SpaceVim/mapping.vim b/autoload/SpaceVim/mapping.vim index f64b91d61..0d7e49978 100644 --- a/autoload/SpaceVim/mapping.vim +++ b/autoload/SpaceVim/mapping.vim @@ -79,9 +79,15 @@ function! SpaceVim#mapping#def(type, key, value, ...) abort endif endfunction -function! SpaceVim#mapping#shift_tab() abort - return pumvisible() ? "\" : "\delimitMateS-Tab" -endfunction +if g:spacevim_snippet_engine ==# 'neosnippet' + function! SpaceVim#mapping#shift_tab() abort + return pumvisible() ? "\" : "\delimitMateS-Tab" + endfunction +elseif g:spacevim_snippet_engine ==# 'ultisnips' + function! SpaceVim#mapping#shift_tab() abort + return pumvisible() ? "\" : "\=UltiSnips#JumpForwards()\\=cmp#ultisnips#JumpForward()\" + endfunction +endif function! SpaceVim#mapping#tab() abort return SpaceVim#mapping#tab#i_tab() diff --git a/autoload/SpaceVim/mapping/guide.vim b/autoload/SpaceVim/mapping/guide.vim index d7eb9f634..275cbd7b6 100644 --- a/autoload/SpaceVim/mapping/guide.vim +++ b/autoload/SpaceVim/mapping/guide.vim @@ -299,6 +299,26 @@ function! s:create_string(layout) " {{{ return output endfunction " }}} +let s:VIMH = SpaceVim#api#import('vim#highlight') +function! s:highlight_cursor() abort + let info = { + \ 'name' : 'SpaceVimGuideCursor', + \ 'guibg' : synIDattr(synIDtrans(synID(line('.'), col('.'), 1)), 'guifg'), + \ 'guifg' : synIDattr(synIDtrans(synID(line('.'), col('.'), 1)), 'guibg'), + \ 'ctermbg' : synIDattr(synIDtrans(synID(line('.'), col('.'), 1)), 'ctermfg'), + \ 'ctermfg' : synIDattr(synIDtrans(synID(line('.'), col('.'), 1)), 'ctermbg'), + \ } + hi def link SpaceVimGuideCursor Cursor + call s:VIMH.hi(info) + let s:cursor_hi = matchaddpos('SpaceVimGuideCursor', [[line('.'), col('.'), 1]]) +endfunction + +function! s:remove_cursor_highlight() abort + try + call matchdelete(s:cursor_hi) + catch + endtry +endfunction " @vimlint(EVL102, 1, l:string) function! s:start_buffer() " {{{ @@ -377,6 +397,7 @@ function! s:winopen() " {{{ if !exists('s:bufnr') let s:bufnr = -1 endif + call s:highlight_cursor() let pos = g:leaderGuide_position ==? 'topleft' ? 'topleft' : 'botright' if bufexists(s:bufnr) let qfbuf = &buftype ==# 'quickfix' @@ -448,6 +469,7 @@ function! s:winclose() " {{{ noautocmd execute s:winnr.'wincmd w' call winrestview(s:winv) endif + call s:remove_cursor_highlight() endfunction " }}} function! s:page_down() " {{{ call feedkeys("\", "n") diff --git a/autoload/SpaceVim/mapping/space.vim b/autoload/SpaceVim/mapping/space.vim index 743d55a98..d5731284d 100644 --- a/autoload/SpaceVim/mapping/space.vim +++ b/autoload/SpaceVim/mapping/space.vim @@ -17,10 +17,12 @@ function! SpaceVim#mapping#space#init() abort let g:_spacevim_mappings_space.w = {'name' : '+Windows'} let g:_spacevim_mappings_space.p = {'name' : '+Projects'} let g:_spacevim_mappings_space.h = {'name' : '+Help'} + let g:_spacevim_mappings_space.n = {'name' : '+Narrow/Numbers'} let g:_spacevim_mappings_space.q = {'name' : '+Quit'} let g:_spacevim_mappings_space.l = {'name' : '+Language Specified'} let g:_spacevim_mappings_space.s = {'name' : '+Searching'} let g:_spacevim_mappings_space.r = {'name' : '+Registers/rings/resume'} + let g:_spacevim_mappings_space.d = {'name' : '+Debug'} if s:has_map_to_spc() return endif diff --git a/autoload/SpaceVim/mapping/tab.vim b/autoload/SpaceVim/mapping/tab.vim index cd3112099..7d7bbb3d2 100644 --- a/autoload/SpaceVim/mapping/tab.vim +++ b/autoload/SpaceVim/mapping/tab.vim @@ -20,9 +20,23 @@ if g:spacevim_snippet_engine ==# 'neosnippet' endif endfunction elseif g:spacevim_snippet_engine ==# 'ultisnips' + function! SpaceVim#mapping#tab#expandable() + let snippet = UltiSnips#ExpandSnippetOrJump() + if g:ulti_expand_or_jump_res > 0 + return snippet + elseif pumvisible() + return "\" + else + return "\" + endif + endfunction function! SpaceVim#mapping#tab#i_tab() abort - return "\" + if getline('.')[col('.')-2] ==# '{'&& pumvisible() + return "\" + endif + return "\=SpaceVim#mapping#tab#expandable()\" endfunction endif + " vim:set et sw=2 cc=80: diff --git a/autoload/SpaceVim/plugins/flygrep.vim b/autoload/SpaceVim/plugins/flygrep.vim index 21b56a8ba..68f88fbde 100644 --- a/autoload/SpaceVim/plugins/flygrep.vim +++ b/autoload/SpaceVim/plugins/flygrep.vim @@ -5,15 +5,15 @@ let s:grepid = 0 function! SpaceVim#plugins#flygrep#open() abort - rightbelow split __flygrep__ - setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline nospell nonu norelativenumber - let save_tve = &t_ve - setlocal t_ve= - " setlocal nomodifiable - setf SpaceVimFlyGrep - redraw! - call s:MPT.open() - let &t_ve = save_tve + rightbelow split __flygrep__ + setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline nospell nonu norelativenumber + let save_tve = &t_ve + setlocal t_ve= + " setlocal nomodifiable + setf SpaceVimFlyGrep + redraw! + call s:MPT.open() + let &t_ve = save_tve endfunction let s:grep_expr = '' @@ -22,53 +22,53 @@ let s:grep_timer_id = 0 " @vimlint(EVL103, 1, a:timer) function! s:grep_timer(timer) abort - let s:grepid = s:JOB.start(s:get_search_cmd(s:grep_exe, s:grep_expr), { - \ 'on_stdout' : function('s:grep_stdout'), - \ 'in_io' : 'null', - \ 'on_exit' : function('s:grep_exit'), - \ }) + let s:grepid = s:JOB.start(s:get_search_cmd(s:grep_exe, s:grep_expr), { + \ 'on_stdout' : function('s:grep_stdout'), + \ 'in_io' : 'null', + \ 'on_exit' : function('s:grep_exit'), + \ }) endfunction " @vimlint(EVL103, 0, a:timer) function! s:flygrep(expr) abort - call s:MPT._build_prompt() - if a:expr ==# '' - redrawstatus - return - endif - try - syn clear FileNames - catch - endtr - exe 'syn match FileNames /' . substitute(a:expr, '\([/\\]\)', '\\\1', 'g') . '/' - hi def link FileNames MoreMsg - let s:grep_expr = a:expr - let s:grep_timer_id = timer_start(500, funcref('s:grep_timer'), {'repeat' : 1}) + call s:MPT._build_prompt() + if a:expr ==# '' + redrawstatus + return + endif + try + call matchdelete(s:hi_id) + catch + endtr + hi def link FileNames MoreMsg + let s:hi_id = matchadd('FileNames', a:expr, 1) + let s:grep_expr = a:expr + let s:grep_timer_id = timer_start(500, funcref('s:grep_timer'), {'repeat' : 1}) endfunction let s:MPT._handle_fly = function('s:flygrep') function! s:close_buffer() abort - if s:grepid != 0 - call s:JOB.stop(s:grepid) - endif - if s:grep_timer_id != 0 - call timer_stop(s:grep_timer_id) - endif - q + if s:grepid != 0 + call s:JOB.stop(s:grepid) + endif + if s:grep_timer_id != 0 + call timer_stop(s:grep_timer_id) + endif + q endfunction let s:MPT._onclose = function('s:close_buffer') function! s:close_grep_job() abort - if s:grepid != 0 - call s:JOB.stop(s:grepid) - endif - if s:grep_timer_id != 0 - call timer_stop(s:grep_timer_id) - endif - normal! "_ggdG + if s:grepid != 0 + call s:JOB.stop(s:grepid) + endif + if s:grep_timer_id != 0 + call timer_stop(s:grep_timer_id) + endif + normal! "_ggdG endfunction let s:MPT._oninputpro = function('s:close_grep_job') @@ -77,18 +77,18 @@ let s:MPT._oninputpro = function('s:close_grep_job') " @vimlint(EVL103, 1, a:id) " @vimlint(EVL103, 1, a:event) function! s:grep_stdout(id, data, event) abort - let datas =filter(a:data, '!empty(v:val)') - if getline(1) ==# '' - call setline(1, datas) - else - call append('$', datas) - endif - call s:MPT._build_prompt() + let datas =filter(a:data, '!empty(v:val)') + if getline(1) ==# '' + call setline(1, datas) + else + call append('$', datas) + endif + call s:MPT._build_prompt() endfunction function! s:grep_exit(id, data, event) abort - redrawstatus - let s:grepid = 0 + redrawstatus + let s:grepid = 0 endfunction " @vimlint(EVL103, 0, a:data) @@ -96,98 +96,113 @@ endfunction " @vimlint(EVL103, 0, a:event) function! s:get_search_cmd(exe, expr) abort - if a:exe ==# 'grep' - return ['grep', '-inHR', '--exclude-dir', '.git', a:expr, '.'] - elseif a:exe ==# 'rg' - return ['rg', '-n', '-i', a:expr] - else - return [a:exe, a:expr] - endif + if a:exe ==# 'grep' + return ['grep', '-inHR', '--exclude-dir', '.git', a:expr, '.'] + elseif a:exe ==# 'rg' + return ['rg', '-n', '-i', a:expr] + else + return [a:exe, a:expr] + endif endfunction function! s:next_item() abort - if line('.') == line('$') - normal! gg - else - normal! j - endif - redrawstatus - call s:MPT._build_prompt() + if line('.') == line('$') + normal! gg + else + normal! j + endif + redrawstatus + call s:MPT._build_prompt() endfunction function! s:previous_item() abort - if line('.') == 1 - normal! G - else - normal! k - endif - redrawstatus - call s:MPT._build_prompt() + if line('.') == 1 + normal! G + else + normal! k + endif + redrawstatus + call s:MPT._build_prompt() endfunction function! s:open_item() abort - if getline('.') !=# '' - if s:grepid != 0 - call s:JOB.stop(s:grepid) - endif - call s:MPT._clear_prompt() - let s:MPT._quit = 1 - let line = getline('.') - let filename = fnameescape(split(line, ':\d\+:')[0]) - let linenr = matchstr(line, ':\d\+:')[1:-2] - q - exe 'e ' . filename - exe linenr + if getline('.') !=# '' + if s:grepid != 0 + call s:JOB.stop(s:grepid) endif + call s:MPT._clear_prompt() + let s:MPT._quit = 1 + let line = getline('.') + let filename = fnameescape(split(line, ':\d\+:')[0]) + let linenr = matchstr(line, ':\d\+:')[1:-2] + q + exe 'e ' . filename + exe linenr + endif endfunction function! s:double_click() abort - if line('.') !=# '' - if s:grepid != 0 - call s:JOB.stop(s:grepid) - endif - call s:MPT._clear_prompt() - let s:MPT._quit = 1 - let isfname = &isfname - if s:SYS.isWindows - set isfname-=: - endif - normal! gF - let nr = bufnr('%') - q - exe 'silent b' . nr - normal! : - let &isfname = isfname + if line('.') !=# '' + if s:grepid != 0 + call s:JOB.stop(s:grepid) endif + call s:MPT._clear_prompt() + let s:MPT._quit = 1 + let isfname = &isfname + if s:SYS.isWindows + set isfname-=: + endif + normal! gF + let nr = bufnr('%') + q + exe 'silent b' . nr + normal! : + let &isfname = isfname + endif endfunction function! s:move_cursor() abort - if v:mouse_win == winnr() - let cl = line('.') - if cl < v:mouse_lnum - exe 'normal! ' . (v:mouse_lnum - cl) . 'j' - elseif cl > v:mouse_lnum - exe 'normal! ' . (cl - v:mouse_lnum) . 'k' - endif + if v:mouse_win == winnr() + let cl = line('.') + if cl < v:mouse_lnum + exe 'normal! ' . (v:mouse_lnum - cl) . 'j' + elseif cl > v:mouse_lnum + exe 'normal! ' . (cl - v:mouse_lnum) . 'k' endif - call s:MPT._build_prompt() + endif + call s:MPT._build_prompt() endfunction let s:MPT._function_key = { - \ "\" : function('s:next_item'), - \ "\" : function('s:next_item'), - \ "\" : function('s:previous_item'), - \ "\" : function('s:previous_item'), - \ "\" : function('s:open_item'), - \ "\" : function('s:move_cursor'), - \ "\<2-LeftMouse>" : function('s:double_click'), - \ } + \ "\" : function('s:next_item'), + \ "\" : function('s:next_item'), + \ "\" : function('s:previous_item'), + \ "\" : function('s:previous_item'), + \ "\" : function('s:open_item'), + \ "\" : function('s:move_cursor'), + \ "\<2-LeftMouse>" : function('s:double_click'), + \ } + +if has('nvim') + call extend(s:MPT._function_key, + \ { + \ "\x80\xfdJ" : function('s:previous_item'), + \ "\x80\xfc \x80\xfdJ" : function('s:previous_item'), + \ "\x80\xfc@\x80\xfdJ" : function('s:previous_item'), + \ "\x80\xfc`\x80\xfdJ" : function('s:previous_item'), + \ "\x80\xfdK" : function('s:next_item'), + \ "\x80\xfc \x80\xfdK" : function('s:next_item'), + \ "\x80\xfc@\x80\xfdK" : function('s:next_item'), + \ "\x80\xfc`\x80\xfdK" : function('s:next_item'), + \ } + \ ) +endif " statusline api function! SpaceVim#plugins#flygrep#lineNr() abort - if getline(1) ==# '' - return '' - else - return line('.') . '/' . line('$') - endif + if getline(1) ==# '' + return '' + else + return line('.') . '/' . line('$') + endif endfunction diff --git a/autoload/SpaceVim/plugins/manager.vim b/autoload/SpaceVim/plugins/manager.vim index cf312f871..28813fb61 100644 --- a/autoload/SpaceVim/plugins/manager.vim +++ b/autoload/SpaceVim/plugins/manager.vim @@ -232,6 +232,7 @@ endfunction " here if a:data == 0, git pull succeed function! s:on_pull_exit(id, data, event) abort + call SpaceVim#logger#info(string(a:data)) if a:id == -1 let id = s:jobpid else @@ -287,6 +288,7 @@ endfunction " @vimlint(EVL103, 1, a:event) function! s:on_install_stdout(id, data, event) abort + call SpaceVim#logger#info(string(a:data)) if a:id == -1 let id = s:jobpid else @@ -356,7 +358,8 @@ endfunction function! s:pull(repo) abort let s:pct += 1 let s:ui_buf[a:repo.name] = s:pct - let argv = ['git', '--git-dir', a:repo.path . '/.git', 'pull', '--progress'] + let argv = ['git', '--git-dir', a:repo.path . '/.git', '--work-tree', a:repo.path, 'pull', '--progress'] + call SpaceVim#logger#info('plugin manager cmd: ' . string(argv)) if s:JOB.vim_job || s:JOB.nvim_job let jobid = s:JOB.start(argv,{ \ 'on_stderr' : function('s:on_install_stdout'), diff --git a/autoload/SpaceVim/plugins/repl.vim b/autoload/SpaceVim/plugins/repl.vim new file mode 100644 index 000000000..a24121a2e --- /dev/null +++ b/autoload/SpaceVim/plugins/repl.vim @@ -0,0 +1,183 @@ +"============================================================================= +" repl.vim --- REPL process support for SpaceVim +" Copyright (c) 2016-2017 Shidong Wang & Contributors +" Author: Shidong Wang < wsdjeg at 163.com > +" URL: https://spacevim.org +" License: MIT license +"============================================================================= + +let s:JOB = SpaceVim#api#import('job') +let s:BUFFER = SpaceVim#api#import('vim#buffer') +let s:STRING = SpaceVim#api#import('data#string') + +augroup spacevim_repl + autocmd! + autocmd VimLeavePre * call s:close() +augroup END + + +function! SpaceVim#plugins#repl#start(ft) abort + + let exe = get(s:exes, a:ft, '') + + if !empty(exe) + call s:start(exe) + else + echohl WarningMsg + echo 'no REPL executable for current filetype' + echohl None + endif + +endfunction + +" supported argvs: +" buffer: send current buffer to REPL process +" line: send line under cursor to REPL process +" selection: send selection text to REPL process + +function! SpaceVim#plugins#repl#send(type) abort + if a:type ==# 'line' + call s:JOB.send(s:job_id, [getline('.'), '']) + elseif a:type ==# 'buffer' + call s:JOB.send(s:job_id, getline(1, '$') + ['']) + elseif a:type ==# 'selection' + else + endif +endfunction + + + +function! s:start(exe) abort + let s:lines = 0 + let s:status = { + \ 'is_running' : 1, + \ 'is_exit' : 0, + \ 'has_errors' : 0, + \ 'exit_code' : 0 + \ } + let s:start_time = reltime() + call s:open_windows() + call s:BUFFER.buf_set_lines(s:bufnr, s:lines , s:lines + 3, 0, ['[REPL executable] ' . a:exe, '', repeat('-', 20)]) + let s:lines += 3 + let s:job_id = s:JOB.start(a:exe,{ + \ 'on_stdout' : function('s:on_stdout'), + \ 'on_stderr' : function('s:on_stderr'), + \ 'on_exit' : function('s:on_exit'), + \ }) +endfunction + +" @vimlint(EVL103, 1, a:job_id) +" @vimlint(EVL103, 1, a:data) +" @vimlint(EVL103, 1, a:event) + +if has('nvim') && exists('*chanclose') + let s:_out_data = [''] + function! s:on_stdout(job_id, data, event) abort + let s:_out_data[-1] .= a:data[0] + call extend(s:_out_data, a:data[1:]) + if s:_out_data[-1] == '' + call remove(s:_out_data, -1) + let lines = s:_out_data + else + let lines = s:_out_data + endif + if !empty(lines) + call s:BUFFER.buf_set_lines(s:bufnr, s:lines , s:lines + 1, 0, lines) + endif + let s:lines += len(lines) + let s:_out_data = [''] + call s:update_statusline() + endfunction + + let s:_err_data = [''] + function! s:on_stderr(job_id, data, event) abort + let s:_out_data[-1] .= a:data[0] + call extend(s:_out_data, a:data[1:]) + if s:_out_data[-1] ==# '' + call remove(s:_out_data, -1) + let lines = s:_out_data + else + let lines = s:_out_data + endif + if !empty(lines) + call s:BUFFER.buf_set_lines(s:bufnr, s:lines , s:lines + 1, 0, lines) + endif + let s:lines += len(lines) + let s:_out_data = [''] + call s:update_statusline() + endfunction +else + function! s:on_stdout(job_id, data, event) abort + call s:BUFFER.buf_set_lines(s:bufnr, s:lines , s:lines + 1, 0, a:data) + let s:lines += len(a:data) + call s:update_statusline() + endfunction + + function! s:on_stderr(job_id, data, event) abort + let s:status.has_errors = 1 + call s:BUFFER.buf_set_lines(s:bufnr, s:lines , s:lines + 1, 0, a:data) + let s:lines += len(a:data) + call s:update_statusline() + endfunction +endif + +function! s:on_exit(job_id, data, event) abort + let s:end_time = reltime(s:start_time) + let s:status.is_exit = 1 + let s:status.exit_code = a:data + let done = ['', '[Done] exited with code=' . a:data . ' in ' . s:STRING.trim(reltimestr(s:end_time)) . ' seconds'] + if bufexists(s:bufnr) + call s:BUFFER.buf_set_lines(s:bufnr, s:lines , s:lines + 1, 0, done) + endif + call s:update_statusline() + +endfunction + +function! s:update_statusline() abort + redrawstatus! +endfunction +" @vimlint(EVL103, 0, a:job_id) +" @vimlint(EVL103, 0, a:data) +" @vimlint(EVL103, 0, a:event) + +function! s:close() abort + if exists('s:job_id') && s:job_id != 0 + call s:JOB.stop(s:job_id) + let s:job_id = 0 + endif + if s:bufnr != 0 && bufexists(s:bufnr) + exe 'bd ' s:bufnr + endif +endfunction + +let s:exes = {} + +function! SpaceVim#plugins#repl#reg(ft, execute) abort + + call extend(s:exes, {a:ft : a:execute}) + +endfunction + +function! SpaceVim#plugins#repl#status() abort + if s:status.is_running == 1 + return 'running' + elseif s:status.is_exit == 1 + return 'exit code : ' . s:status.exit_code + \ . ' time: ' . s:STRING.trim(reltimestr(s:end_time)) + endif +endfunction + +let s:bufnr = 0 +function! s:open_windows() abort + if s:bufnr != 0 && bufexists(s:bufnr) + exe 'bd ' . s:bufnr + endif + botright split __REPL__ + let lines = &lines * 30 / 100 + exe 'resize ' . lines + setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline nospell nonu norelativenumber + set filetype=SpaceVimREPL + nnoremap q :call close() + let s:bufnr = bufnr('%') + wincmd p +endfunction diff --git a/autoload/SpaceVim/plugins/runner.vim b/autoload/SpaceVim/plugins/runner.vim index d8ef137f9..bce1a002b 100644 --- a/autoload/SpaceVim/plugins/runner.vim +++ b/autoload/SpaceVim/plugins/runner.vim @@ -10,6 +10,7 @@ let s:JOB = SpaceVim#api#import('job') let s:BUFFER = SpaceVim#api#import('vim#buffer') let s:STRING = SpaceVim#api#import('data#string') + let s:runners = {} let s:bufnr = 0 @@ -33,6 +34,8 @@ let s:target = '' function! s:async_run(runner) abort if type(a:runner) == type('') let cmd = printf(a:runner, bufname('%')) + call s:BUFFER.buf_set_lines(s:bufnr, s:lines , s:lines + 3, 0, ['[Running] ' . cmd, '', repeat('-', 20)]) + let s:lines += 3 let s:start_time = reltime() let s:job_id = s:JOB.start(cmd,{ \ 'on_stdout' : function('s:on_stdout'), @@ -42,6 +45,12 @@ function! s:async_run(runner) abort elseif type(a:runner) == type([]) let s:target = tempname() let compile_cmd = substitute(printf(a:runner[0], bufname('%')), '#TEMP#', s:target, 'g') + call s:BUFFER.buf_set_lines(s:bufnr, s:lines , s:lines + 3, 0, [ + \ '[Compile] ' . compile_cmd, + \ '[Running] ' . s:target, + \ '', + \ repeat('-', 20)]) + let s:lines += 4 let s:start_time = reltime() let s:job_id = s:JOB.start(compile_cmd,{ \ 'on_stdout' : function('s:on_stdout'), @@ -58,6 +67,13 @@ function! s:on_compile_exit(id, data, event) abort \ 'on_stderr' : function('s:on_stderr'), \ 'on_exit' : function('s:on_exit'), \ }) + else + let s:end_time = reltime(s:start_time) + let s:status.is_exit = 1 + let s:status.exit_code = a:data + let done = ['', '[Done] exited with code=' . a:data . ' in ' . s:STRING.trim(reltimestr(s:end_time)) . ' seconds'] + call s:BUFFER.buf_set_lines(s:bufnr, s:lines , s:lines + 1, 0, done) + call s:update_statusline() endif endfunction @@ -84,27 +100,67 @@ function! SpaceVim#plugins#runner#open() abort call s:update_statusline() endif endfunction - " @vimlint(EVL103, 1, a:job_id) " @vimlint(EVL103, 1, a:data) " @vimlint(EVL103, 1, a:event) -function! s:on_stdout(job_id, data, event) abort - call s:BUFFER.buf_set_lines(s:bufnr, s:lines , s:lines + 1, 0, a:data) - let s:lines += len(a:data) - call s:update_statusline() -endfunction -function! s:on_stderr(job_id, data, event) abort - let s:status.has_errors = 1 - call s:BUFFER.buf_set_lines(s:bufnr, s:lines , s:lines + 1, 0, a:data) - let s:lines += len(a:data) - call s:update_statusline() -endfunction +if has('nvim') && exists('*chanclose') + let s:_out_data = [''] + function! s:on_stdout(job_id, data, event) abort + let s:_out_data[-1] .= a:data[0] + call extend(s:_out_data, a:data[1:]) + if s:_out_data[-1] == '' + call remove(s:_out_data, -1) + let lines = s:_out_data + else + let lines = s:_out_data + endif + if !empty(lines) + call s:BUFFER.buf_set_lines(s:bufnr, s:lines , s:lines + 1, 0, lines) + endif + let s:lines += len(lines) + let s:_out_data = [''] + call s:update_statusline() + endfunction + + let s:_err_data = [''] + function! s:on_stderr(job_id, data, event) abort + let s:_out_data[-1] .= a:data[0] + call extend(s:_out_data, a:data[1:]) + if s:_out_data[-1] == '' + call remove(s:_out_data, -1) + let lines = s:_out_data + else + let lines = s:_out_data + endif + if !empty(lines) + call s:BUFFER.buf_set_lines(s:bufnr, s:lines , s:lines + 1, 0, lines) + endif + let s:lines += len(lines) + let s:_out_data = [''] + call s:update_statusline() + endfunction +else + function! s:on_stdout(job_id, data, event) abort + call s:BUFFER.buf_set_lines(s:bufnr, s:lines , s:lines + 1, 0, a:data) + let s:lines += len(a:data) + call s:update_statusline() + endfunction + + function! s:on_stderr(job_id, data, event) abort + let s:status.has_errors = 1 + call s:BUFFER.buf_set_lines(s:bufnr, s:lines , s:lines + 1, 0, a:data) + let s:lines += len(a:data) + call s:update_statusline() + endfunction +endif function! s:on_exit(job_id, data, event) abort let s:end_time = reltime(s:start_time) let s:status.is_exit = 1 let s:status.exit_code = a:data + let done = ['', '[Done] exited with code=' . a:data . ' in ' . s:STRING.trim(reltimestr(s:end_time)) . ' seconds'] + call s:BUFFER.buf_set_lines(s:bufnr, s:lines , s:lines + 1, 0, done) call s:update_statusline() endfunction @@ -130,5 +186,5 @@ function! SpaceVim#plugins#runner#close() abort if s:status.is_exit == 0 call s:JOB.close(s:job_id) endif - exe 'bd' s:bufnr + exe 'bd ' s:bufnr endfunction diff --git a/autoload/SpaceVim/util.vim b/autoload/SpaceVim/util.vim index d34eb4531..2fcdc8d21 100644 --- a/autoload/SpaceVim/util.vim +++ b/autoload/SpaceVim/util.vim @@ -12,4 +12,18 @@ function! SpaceVim#util#echoWarn(msg) abort echohl None endfunction +function! SpaceVim#util#haspyxlib(lib) abort + + try + if has('nvim') + exe 'py import ' . a:lib + else + exe 'pyx import ' . a:lib + endif + catch + return 0 + endtry + return 1 +endfunction + " vim:set et sw=2 cc=80: diff --git a/autoload/zvim/util.vim b/autoload/zvim/util.vim index 7be33f3cb..abc0df5cc 100644 --- a/autoload/zvim/util.vim +++ b/autoload/zvim/util.vim @@ -277,7 +277,7 @@ fu! zvim#util#Generate_ignore(ignore,tool, ...) abort if a:tool ==# 'ag' for ig in split(a:ignore,',') call add(ignore, '--ignore') - call add(ignore, ig ) + call add(ignore, "'" . ig . "'") endfor elseif a:tool ==# 'rg' for ig in split(a:ignore,',') diff --git a/config/main.vim b/config/main.vim index e37403453..32acd58bd 100644 --- a/config/main.vim +++ b/config/main.vim @@ -1,3 +1,11 @@ +"============================================================================= +" main.vim --- Main file of SpaceVim +" Copyright (c) 2016-2017 Shidong Wang & Contributors +" Author: Shidong Wang < wsdjeg at 163.com > +" URL: https://spacevim.org +" License: MIT license +"============================================================================= + let g:Config_Main_Home = fnamemodify(expand(''), \ ':p:h:gs?\\?'.((has('win16') || has('win32') \ || has('win64'))?'\':'/') . '?') diff --git a/config/plugins/deoplete.vim b/config/plugins/deoplete.vim index 40b1a2eb8..2098bd8d5 100644 --- a/config/plugins/deoplete.vim +++ b/config/plugins/deoplete.vim @@ -85,6 +85,9 @@ let g:deoplete#ignore_sources.c = get(g:deoplete#ignore_sources, 'c', ['omni']) let g:deoplete#ignore_sources.rust = get(g:deoplete#ignore_sources, 'rust', ['omni']) call deoplete#custom#set('racer', 'mark', '') +" vim +let g:deoplete#ignore_sources.vim = get(g:deoplete#ignore_sources, 'vim', ['tag']) + " clojure let g:deoplete#keyword_patterns.clojure = '[\w!$%&*+/:<=>?@\^_~\-\.#]*' diff --git a/config/plugins/neomake.vim b/config/plugins/neomake.vim index f7a229020..5a650714f 100644 --- a/config/plugins/neomake.vim +++ b/config/plugins/neomake.vim @@ -4,6 +4,8 @@ if get(g:, 'spacevim_lint_on_save', 0) let s:neomake_automake_events['BufWritePost'] = {'delay': 0} endif +let g:neomake_echo_current_error = 0 + if get(g:, 'spacevim_lint_on_the_fly', 0) let s:neomake_automake_events['TextChanged'] = {'delay': 750} let s:neomake_automake_events['TextChangedI'] = {'delay': 750} diff --git a/config/plugins/vimfiler.vim b/config/plugins/vimfiler.vim index 513b6c9f2..e9bc7c529 100644 --- a/config/plugins/vimfiler.vim +++ b/config/plugins/vimfiler.vim @@ -18,7 +18,8 @@ let g:vimfiler_ignore_pattern = get(g:, 'vimfiler_ignore_pattern', [ \ '^\.DS_Store$', \ '^\.init\.vim-rplugin\~$', \ '^\.netrwhist$', - \ '\.class$' + \ '\.class$', + \ '^\.' \]) if has('mac') diff --git a/config/plugins_before/YouCompleteMe.vim b/config/plugins_before/YouCompleteMe.vim index fc2178c9a..d41834b82 100644 --- a/config/plugins_before/YouCompleteMe.vim +++ b/config/plugins_before/YouCompleteMe.vim @@ -1,22 +1,39 @@ "let g:ycm_global_ycm_extra_conf = '~/.ycm_extra_conf.py' "let g:ycm_confirm_extra_conf = 0 -let g:ycm_collect_identifiers_from_tags_files = 1 -let g:ycm_collect_identifiers_from_comments_and_strings = 1 -let g:ycm_key_list_select_completion = ['', ''] -let g:ycm_key_list_previous_completion = ['',''] -let g:ycm_seed_identifiers_with_syntax = 1 -let g:ycm_key_invoke_completion = '' -let g:ycm_semantic_triggers = { - \ 'c' : ['->', '.'], - \ 'objc' : ['->', '.'], - \ 'ocaml' : ['.', '#'], - \ 'cpp,objcpp' : ['->', '.', '::'], - \ 'perl' : ['->'], - \ 'php' : ['->', '::'], - \ 'cs,javascript,d,python,perl6,scala,vb,elixir,go' : ['.'], - \ 'java,jsp' : ['.'], - \ 'vim' : ['re![_a-zA-Z]+[_\w]*\.'], - \ 'ruby' : ['.', '::'], - \ 'lua' : ['.', ':'], - \ 'erlang' : [':'], - \ } +let g:ycm_collect_identifiers_from_tags_files = + \ get(g:, 'ycm_collect_identifiers_from_tags_files', 1) +let g:ycm_collect_identifiers_from_comments_and_strings = + \ get(g:, 'ycm_collect_identifiers_from_comments_and_strings', 1) +let g:ycm_key_list_select_completion = + \ get(g:, 'ycm_key_list_select_completion', ['', '']) +let g:ycm_key_list_previous_completion = + \ get(g:, 'ycm_key_list_previous_completion', ['','']) +let g:ycm_seed_identifiers_with_syntax = + \ get(g:, 'ycm_seed_identifiers_with_syntax', 1) +let g:ycm_key_invoke_completion = + \ get(g:, 'ycm_key_invoke_completion', '') + +let g:ycm_semantic_triggers = get(g:, 'ycm_semantic_triggers', {}) + +function! s:set_ft_triggers(ft, expr, override) abort + if a:override + let g:ycm_semantic_triggers[a:ft] = a:expr + elseif !has_key(g:ycm_semantic_triggers, a:ft) + let g:ycm_semantic_triggers[a:ft] = a:expr + endif +endfunction + +call s:set_ft_triggers('c', ['->', '.'], 0) +call s:set_ft_triggers('objc', ['->', '.'], 0) +call s:set_ft_triggers('ocaml', ['.', '#'], 0) +call s:set_ft_triggers('cpp,objcpp', ['->', '.', '::'], 0) +call s:set_ft_triggers('perl', ['->'], 0) +call s:set_ft_triggers('php', ['->', '::'], 0) +call s:set_ft_triggers('cs,javascript,d,python,perl6,scala,vb,elixir,go', ['.'], 0) +call s:set_ft_triggers('java,jsp', ['.'], 0) +call s:set_ft_triggers('vim', ['re![_a-zA-Z]+[_\w]*\.'], 0) +call s:set_ft_triggers('ruby', ['.', '::'], 0) +call s:set_ft_triggers('lua', ['.', ':'], 0) +call s:set_ft_triggers('erlang', [':'], 0) +call s:set_ft_triggers('sh', ['re![\w-]{2}', '/', '-'], 0) +call s:set_ft_triggers('zsh', ['re![\w-]{2}', '/', '-'], 0) diff --git a/config/plugins_before/ultisnips.vim b/config/plugins_before/ultisnips.vim index 74dfcb0f1..c31149706 100644 --- a/config/plugins_before/ultisnips.vim +++ b/config/plugins_before/ultisnips.vim @@ -1,6 +1,6 @@ " If you want :UltiSnipsEdit to split your window. let g:UltiSnipsEditSplit="vertical" -let g:UltiSnipsExpandTrigger='' -let g:UltiSnipsJumpBackwardTrigger="" -let g:UltiSnipsJumpForwardTrigger='' +let g:UltiSnipsExpandTrigger='' +let g:UltiSnipsJumpBackwardTrigger='' +let g:UltiSnipsJumpForwardTrigger='' let g:UltiSnipsSnippetsDir = '~/.SpaceVim.d/UltiSnips' diff --git a/doc/SpaceVim.txt b/doc/SpaceVim.txt index 87246728a..fa4fd0083 100644 --- a/doc/SpaceVim.txt +++ b/doc/SpaceVim.txt @@ -281,13 +281,18 @@ Set the information symbol for SpaceVim's syntax maker. Default is '🛈'. < *g:spacevim_terminal_cursor_shape* -Set the SpaceVim cursor shape in the terminal. Set to 0 to prevent Nvim from -changing the cursor shape. Set to 1 to enable non-blinking mode-sensitive -cursor (this is the default). Set to 2 to enable blinking mode-sensitive -cursor. Host terminal must support the DECSCUSR CSI escape sequence. +Set the SpaceVim cursor shape in the terminal. +> + 0 : to prevent Nvim from changing the cursor shape. + 1 : to enable non-blinking mode-sensitive cursor. + 2 : to enable blinking mode-sensitive cursor (default). +< -Depending on the terminal emulator, using this option with nvim under tmux -might require adding the following to ~/.tmux.conf: +> +< +Host terminal must support the DECSCUSR CSI escape sequence. Depending on the +terminal emulator, using this option with nvim under tmux might require adding +the following to ~/.tmux.conf: > set -ga terminal-overrides ',*:Ss=\E[%p1%d q:Se=\E[2 q' < diff --git a/docs/404.md b/docs/404.md index af8868192..d55d32ca3 100644 --- a/docs/404.md +++ b/docs/404.md @@ -5,4 +5,4 @@ permalink: /404 ## Oops! The page you requested was not found! -> you can go to [home](https://spacevim.org) +> you can go to [home](https://spacevim.org) or checkout [Blogs](https://spacevim.org/blog/) diff --git a/docs/README_zh_cn.md b/docs/README_zh_cn.md index 79f6d1e00..198c0f05b 100644 --- a/docs/README_zh_cn.md +++ b/docs/README_zh_cn.md @@ -3,7 +3,6 @@ title: "SpaceVim 中文手册" description: "SpaceVim 是一个社区驱动的 Vim 配置,内含多种语言模块,提供了代码补全、语法检查、跳转等多种 IDE 特性。" --- - # SpaceVim 中文手册 [![Build Status](https://travis-ci.org/SpaceVim/SpaceVim.svg?branch=dev)](https://travis-ci.org/SpaceVim/SpaceVim) @@ -35,8 +34,8 @@ SpaceVim 是一个社区驱动的模块化 vim/neovim 配置集合,其中包 **捐助SpaceVim** -| 微信 | 支付宝 | -| ------------------------------------------------- | --------------------------------------------------- | +| 微信 | 支付宝 | +| ------------------------------------------------------------------------ | -------------------------------------------------------------------------- | | | | **以下为SpaceVim中文手册,部分内容还未完成翻译,为了方便大家查询相关信息,已提前发布官网上,后面会逐渐更新完成,感谢大家一直以来的支持!** @@ -108,7 +107,7 @@ SpaceVim 是一个社区驱动的模块化 vim/neovim 配置集合,其中包 - [文件树](#文件树) - [文件树中的常用操作](#文件树中的常用操作) - [文件树中打开文件](#文件树中打开文件) - - [Commands starting with `g`](#commands-starting-with-g) + - [以 `g` 为前缀的快捷键](#以-g-为前缀的快捷键) - [Commands starting with `z`](#commands-starting-with-z) - [Auto-saving](#auto-saving) - [Searching](#searching) @@ -186,13 +185,13 @@ SpaceVim 是一个社区驱动的模块化 vim/neovim 配置集合,其中包 ## 安装 -**Linux 或 Mac 下 SpaceVim的安装非常简单,只需要执行以下命令即可:** +**Linux/Mac:** ```sh curl -sLf https://spacevim.org/install.sh | bash ``` -想要获取更多的自定义的安装方式,请参考: +想要获取更多的信息,请参考: ```sh curl -sLf https://spacevim.org/install.sh | bash -s -- -h @@ -204,24 +203,9 @@ SpaceVim是一种模块化配置,可以运行在vim或者neovim上,关于vim [从源码编译vim](https://github.com/Valloric/YouCompleteMe/wiki/Building-Vim-from-source) -**windows系统下的安装步骤:** +**windows:** -Windows 下 vim 用户只需要将本仓库克隆成用户 HOME 目录下的 vimfiles 即可,打开 CMD 默认的目录默认即为 HOME 目录,只需要执行如下命令即可: - - git clone https://github.com/SpaceVim/SpaceVim.git vimfiles - -Windows 下 neovim 用户 需要将本仓库克隆成用户 HOME 目录下的 AppData\\Local\\nvim,想要获取跟多关于 neovim 安装相关的知识,可以访问 neovim 的 wiki, wiki 写的非常详细。打开 CMD 初始目录默认一般即为 HOME 目录,只需要执行如下命令即可: - - git clone https://github.com/SpaceVim/SpaceVim.git AppData\Local\nvim - -**字体** - -SpaceVim 默认启用了Powerline 字体,默认的的字体文件是:[DejaVu Sans Mono](https://github.com/wsdjeg/DotFiles/tree/master/fonts), Windows 用户直接下载下来右键安装即可。 - -**vimproc.dll** - -Windows 下用户如果不方便编译,可以在qq群文件里面下载相应的dll文件放到vimproc -的lib目录,默认是 `~/.cache/vimfiles/repos/github.com/Shougo/vimproc.vim/lib/` +Window 下最方便的是下载安装脚本([install.cmd](https://spacevim.org/install.cmd))至本地,直接运行。 ## 更新 @@ -292,7 +276,7 @@ Neovim 运行在 iTerm2 上,采用 SpaceVim,配色为:_base16-solarized-da 图中包含了一个 Neovim 的终端, 一个语法树窗口,一个文件树窗口以及一个 TernJS 定义窗口 -想要查阅更多截图,清阅读 [issue #415](https://github.com/SpaceVim/SpaceVim/issues/415) +想要查阅更多截图,请阅读 [issue #415](https://github.com/SpaceVim/SpaceVim/issues/415) ### 谁将从 SpaceVim 中获益? @@ -345,7 +329,7 @@ Neovim 运行在 iTerm2 上,采用 SpaceVim,配色为:_base16-solarized-da 当然,你也可以通过 `SPACEVIMDIR` 这一环境变量,执定用户配置目录。当然也可以通过软连接连改变目录位置,以便配置备份。 -SpaceVim 同时还支持项目本地配置,配置出世文件为,当前目录下的 `.SpaceVim.d/init.vim` 文件。同时当前目录下的 `.SpaceVim.d/` 也将被加入到 Vim 运行时路径。 +SpaceVim 同时还支持项目本地配置,配置初始文件为,当前目录下的 `.SpaceVim.d/init.vim` 文件。同时当前目录下的 `.SpaceVim.d/` 也将被加入到 Vim 运行时路径。 这是一个用户配置文件示例: @@ -992,57 +976,57 @@ SpaceVim 的文件树提供了版本控制信息的借口,但是这一特性 | `sg` | 分屏打开文件 | | `sv` | 垂直分屏打开文件 | -### Commands starting with `g` +### 以 `g` 为前缀的快捷键 -after pressing prefix `g` in normal mode, if you do not remember the mappings, you will see the guide which will tell you the functional of all mappings starting with `g`. +在 Normal 模式下按下 `g` 之后,如果你不记得快捷键出现按键延迟,那么快捷键导航将会提示你所有以 `g` 为前缀的快捷键。 -| Key Binding | Description | -| ----------- | ----------------------------------------------- | -| `g#` | search under cursor backward | -| `g$` | go to rightmost character | -| `g&` | repeat last ":s" on all lines | -| `g'` | jump to mark | -| `g*` | search under cursor forward | -| `g+` | newer text state | -| `g,` | newer position in change list | -| `g-` | older text state | -| `g/` | stay incsearch | -| `g0` | go to leftmost character | -| `g;` | older position in change list | -| `g<` | last page of previous command output | -| `g` | go to leftmost character | -| `gE` | end of previous word | -| `gF` | edit file under cursor(jump to line after name) | -| `gH` | select line mode | -| `gI` | insert text in column 1 | -| `gJ` | join lines without space | -| `gN` | visually select previous match | -| `gQ` | switch to Ex mode | -| `gR` | enter VREPLACE mode | -| `gT` | previous tag page | -| `gU` | make motion text uppercase | -| `g]` | tselect cursor tag | -| `g^` | go to leftmost no-white character | -| `g_` | go to last char | -| ``g` `` | jump to mark | -| `ga` | print ascii value of cursor character | -| `gd` | goto definition | -| `ge` | go to end of previous word | -| `gf` | edit file under cursor | -| `gg` | go to line N | -| `gh` | select mode | -| `gi` | insert text after '^ mark | -| `gj` | move cursor down screen line | -| `gk` | move cursor up screen line | -| `gm` | go to middle of screenline | -| `gn` | visually select next match | -| `go` | goto byte N in the buffer | -| `gs` | sleep N seconds | -| `gt` | next tag page | -| `gu` | make motion text lowercase | -| `g~` | swap case for Nmove text | -| `g` | go to rightmost character | -| `g` | show cursor info | +| 快捷键 | 描述 | +| --------- | ----------------------------------------------- | +| `g#` | 反向搜索光标下的词 | +| `g$` | 跳向本行最右侧字符 | +| `g&` | 针对所有行重复执行上一次 ":s" 命令 | +| `g'` | 跳至标签 | +| `g*` | 正向搜索光标下的词 | +| `g+` | newer text state | +| `g,` | newer position in change list | +| `g-` | older text state | +| `g/` | stay incsearch | +| `g0` | go to leftmost character | +| `g;` | older position in change list | +| `g<` | last page of previous command output | +| `g` | go to leftmost character | +| `gE` | end of previous word | +| `gF` | edit file under cursor(jump to line after name) | +| `gH` | select line mode | +| `gI` | insert text in column 1 | +| `gJ` | join lines without space | +| `gN` | visually select previous match | +| `gQ` | switch to Ex mode | +| `gR` | enter VREPLACE mode | +| `gT` | previous tag page | +| `gU` | make motion text uppercase | +| `g]` | tselect cursor tag | +| `g^` | go to leftmost no-white character | +| `g_` | go to last char | +| ``g` `` | 跳至标签,等同于 `g'` | +| `ga` | 打印光标字符的 ascii 值 | +| `gd` | 跳至定义处 | +| `ge` | go to end of previous word | +| `gf` | edit file under cursor | +| `gg` | go to line N | +| `gh` | select mode | +| `gi` | insert text after '^ mark | +| `gj` | move cursor down screen line | +| `gk` | move cursor up screen line | +| `gm` | go to middle of screenline | +| `gn` | visually select next match | +| `go` | goto byte N in the buffer | +| `gs` | sleep N seconds | +| `gt` | next tag page | +| `gu` | make motion text lowercase | +| `g~` | swap case for Nmove text | +| `g` | 跳至本行最右侧字符,等同于 `g$` | +| `g` | 显示光标信息 | ### Commands starting with `z` @@ -1373,8 +1357,6 @@ Comments are handled by [nerdcommenter](https://github.com/scrooloose/nerdcommen **Tips:** To comment efficiently a block of line use the combo `SPC ; SPC j l` -> > > > > > > dev - #### Multi-Encodings SpaceVim use utf-8 as default encoding. there are four options for these case: @@ -1416,7 +1398,7 @@ Custom sign symbol: | ------ | ----------- | --------------------------- | | `✖` | Error | `g:spacevim_error_symbol` | | `➤` | warning | `g:spacevim_warning_symbol` | -| `🛈` | Info | `g:spacevim_info_symbol` | +| `🛈` | Info | `g:spacevim_info_symbol` | ### Managing projects @@ -2158,3 +2140,5 @@ let g:spacevim_guifont = 'DejaVu\ Sans\ Mono\ for\ Powerline\ 11' {% endfor %} + + diff --git a/docs/_config.yml b/docs/_config.yml index d4760ed6c..b1711f54e 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -15,6 +15,10 @@ plugins: github: [metadata] +sass: + sass_dir: _sass + style: compressed + author: name: Shidong Wang twitter: SpaceVim diff --git a/docs/_layouts/default.html b/docs/_layouts/default.html index b5dea63e3..41b7298a1 100644 --- a/docs/_layouts/default.html +++ b/docs/_layouts/default.html @@ -1,122 +1,121 @@ - - - - {% seo %} - - - - + - - - - {{ page.title | default: Home }} - SpaceVim - - - - - - - - + + + {% seo %} + + + + + + + + + + + {{ page.title | default: Home }} - SpaceVim + + + + + + - - - - - + + Fork me on GitHub -
+
-
-
-

{{ site.title | default: site.github.repository_name }}

-

{{ site.description | default: site.github.project_tagline }}

-
-

- Home | - About | - Documentation | - Development | - Community | - Sponsors -

-
-
+
+
+

{{ site.title | default: site.github.repository_name }}

+

{{ site.description | default: site.github.project_tagline }}

+
+

+ Home | + About | + Documentation | + Development | + Community | + Sponsors +

+
+
- {{ content }} + {{ content }} -
+
-
+
- {% if site.google_analytics %} - - - {% endif %} - - - -

- Hosted on GitHub — Theme by mattgraham -

-
+ {% if site.google_analytics %} + + + {% endif %} + + + +

+ Hosted on GitHub — Theme by mattgraham +

+
diff --git a/docs/_posts/2017-12-07-async-code-runner-in-SpaceVim.md b/docs/_posts/2017-12-07-async-code-runner-in-SpaceVim.md new file mode 100644 index 000000000..cc6b57eaf --- /dev/null +++ b/docs/_posts/2017-12-07-async-code-runner-in-SpaceVim.md @@ -0,0 +1,15 @@ +--- +title: "An async code runner in SpaceVim" +categories: tutorials +excerpt: "A better way for running code with in vim, more info about the command status, will not move cursor from code buffer." +--- + +# [Blogs](https://spacevim.org/community#blogs) > An async code runner in SpaceVim + +when edit code, sometimes I want run current file. as we know vim's build-in feature `:!`, but it is not running asynchronously. + +here is an gif shown how we can run code within SpaceVim. the first line is showing the command, the last line is showing the exit code and the time that has been consumed. the default key binding is `SPC l r`, `SPC` means `` on your keyboard. + +![async code runner](https://user-images.githubusercontent.com/13142418/33722240-141ed716-db2f-11e7-9a4d-c99f05cc1d05.gif) + +as wrote in old blog, we can also use this feature for java, c, php, JavaScript, etc. diff --git a/docs/assets/css/style.css b/docs/_sass/_spacevim.scss similarity index 97% rename from docs/assets/css/style.css rename to docs/_sass/_spacevim.scss index f00fd2bdd..8bd59c25b 100644 --- a/docs/assets/css/style.css +++ b/docs/_sass/_spacevim.scss @@ -1,3 +1,8 @@ +@charset "utf-8"; + +// Variables +@import "variables"; + /*! normalize.css 2012-02-07T12:37 UTC - https://github.com/necolas/normalize.css */ /* ============================================================================= HTML5 display definitions ========================================================================== */ /* Corrects block display not defined in IE6/7/8/9 & FF3 */ @@ -214,13 +219,17 @@ p, ul, ol, table, pre, dl { margin: 0 0 20px; } h1, h2, h3 { line-height: 1.1; } -h1 { font-size: 28px; } +h1 { font-size: $h1-font-size; } -h2 { font-size: 24px; } +h2 { font-size: $h2-font-size; } h4, h5, h6 { color: #e8e8e8; } -h3 { font-size: 18px; line-height: 24px; font-family: 'OpenSansRegular', "Helvetica Neue", Helvetica, Arial, sans-serif !important; font-weight: normal; color: #b6b6b6; } +h3 { font-size: $h3-font-size; line-height: 24px; font-family: 'OpenSansRegular', "Helvetica Neue", Helvetica, Arial, sans-serif !important; font-weight: normal; color: #b6b6b6; } + +h4 { font-size: $h4-font-size; } +h5 { font-size: $h5-font-size; } +h6 { font-size: $h6-font-size; } a { color: #ffcc00; font-weight: 400; text-decoration: none; } a:hover { color: #ffeb9b; } diff --git a/docs/_sass/_variables.scss b/docs/_sass/_variables.scss new file mode 100644 index 000000000..07346ddee --- /dev/null +++ b/docs/_sass/_variables.scss @@ -0,0 +1,7 @@ +$h1-font-size: 2em; +$h2-font-size: 1.8em; +$h3-font-size: 1.6em; +$h4-font-size: 1.4em; +$h5-font-size: 1.2em; +$h6-font-size: 1em; + diff --git a/docs/about.md b/docs/about.md index be6a2c881..e3359b17e 100644 --- a/docs/about.md +++ b/docs/about.md @@ -1,23 +1,27 @@ --- title: "About" -description: "Introduction about SpaceVim organization." +description: "SpaceVim is a communicate driven vim distribution that supports vim and neovim" --- -# About SpaceVim +## Version -[SpaceVim](https://github.com/SpaceVim/SpaceVim) is a Modular configuration, a bundle of custom settings and plugins for Vim, -here we call them layers, each layer has different plugins and config, users just need -to select the layers they need. It got inspired by [spacemacs](https://github.com/syl20bnr/spacemacs). If you use SpaceVim, -please star it on github. It's a great way of getting feedback and gives me the kick to -put more time into development. +[SpaceVim](https://github.com/SpaceVim/SpaceVim) is a community-driven vim distribution that supports vim and Neovim. SpaceVim manages collections of plugins in layers. Layers make it easy for you, the user, to enable a new language or feature by grouping all the related plugins together. It got inspired by spacemacs. -If you encounter any bugs or have feature requests, just open an issue -report on Github. +## Goals -For learning about Vim in general, read [vim-galore](https://github.com/mhinz/vim-galore). +- Provide a consistent user experience across platforms. +- Provide better default layer for defferent languages. -# Credits & Thanks +## Principles +- Do not regress from origin +- Decide outcomes by weighing cost and benefit +- prefer usability over tradition if the benefits are overwhelming +- Give usability a chance™ + +## Credits & Thanks + +- Current maintainer: [Wang Shidong](https://github.com/wsdjeg) - [![GitHub contributors](https://img.shields.io/github/contributors/SpaceVim/SpaceVim.svg)](https://github.com/SpaceVim/SpaceVim/graphs/contributors) - [vimdoc](https://github.com/google/vimdoc) generate doc file for SpaceVim - [Rafael Bodill](https://github.com/rafi) and his vim-config diff --git a/docs/assets/css/main.scss b/docs/assets/css/main.scss new file mode 100644 index 000000000..aac3c6f6e --- /dev/null +++ b/docs/assets/css/main.scss @@ -0,0 +1,6 @@ +--- +# this ensures Jekyll reads the file to be transformed into CSS later +# only Main files contain this front matter, not partials. +--- + +@import "_spacevim.scss"; diff --git a/docs/development.md b/docs/development.md index 058bd5d7b..17b37f5aa 100644 --- a/docs/development.md +++ b/docs/development.md @@ -1,23 +1,37 @@ --- title: "Development" -description: "A guide for contributing to SpaceVim." +description: "Development information about SpaceVim, including contributing guidelines and changelog." --- # Development + + +- [Contribution guidelines](#contribution-guidelines) + - [Asking for help](#asking-for-help) + - [Reporting issues](#reporting-issues) + - [Contributing code](#contributing-code) + - [License](#license) + - [Conventions](#conventions) + - [Pull Request](#pull-request) + - [Ideally for simple PRs (most of them):](#ideally-for-simple-prs-most-of-them) + - [For complex PRs (big refactoring, etc):](#for-complex-prs-big-refactoring-etc) + - [Contributing a layer](#contributing-a-layer) + - [File header](#file-header) + - [Author of a new layer](#author-of-a-new-layer) + - [Contributor to an existing layer](#contributor-to-an-existing-layer) + - [Contributing a keybinding](#contributing-a-keybinding) + - [Contributing a banner](#contributing-a-banner) + - [Contributing a statusline theme](#contributing-a-statusline-theme) +- [Build with SpaceVim](#build-with-spacevim) +- [Changelog](#changelog) + + + Development happens in the GitHub repository. here is a throughput graph of the repository for the last few weeks: [![Throughput Graph](https://graphs.waffle.io/SpaceVim/SpaceVim/throughput.svg)](https://waffle.io/SpaceVim/SpaceVim/metrics/throughput) -## Content - -- [Contribution guidelines](#contribution-guidelines) - - [Asking for help](#asking-for-help) - - [Reporting issues](#reporting-issues) - - [Contributing code](#contributing-code) -- [Build with SpaceVim](#build-with-spacevim) -- [Changelog](#changelog) - ## Contribution guidelines SpaceVim is an effort of all the volunteers, we encourage you to pitch in. The community makes SpaceVim what it is. @@ -32,12 +46,14 @@ You can only consider reading the sections relevant to what you are going to do: ### Asking for help If you want to ask an usage question, be sure to look first into some places as it may hold the answers: + - :h SpaceVim-faq: Some of the most frequently asked questions are answered there. - [SpaceVim documentation](https://spacevim.org/documentation): It is the general documentation of SpaceVim. ### Reporting issues Issues have to be reported on [issues tracker](https://github.com/SpaceVim/SpaceVim/issues), Please: + - Check that there is no duplicate issue in the issues tracker, you can search for keywords in the issues tracker. - Check that the issue has not been fixed in latest version of SpaceVim, please update your SpaceVim, and try to reproduce the bug here. - Use a clear title and follow the issue template. @@ -50,6 +66,7 @@ Code contributions are welcome. Please read the following sections carefully. In #### License The license is MIT for all the parts of SpaceVim. this includes: + - The initialization and core files - All the layer files. @@ -94,29 +111,27 @@ Write commit messages according to adapted [Tim Pope’s guidelines](http://tbag This is a model commit message: -``` -Capitalized, short (72 chars or less) summary + Capitalized, short (72 chars or less) summary -More detailed explanatory text, if necessary. Wrap it to about 72 -characters or so. In some contexts, the first line is treated as the -subject of an email and the rest of the text as the body. The blank -line separating the summary from the body is critical (unless you omit -the body entirely); tools like rebase can get confused if you run the -two together. + More detailed explanatory text, if necessary. Wrap it to about 72 + characters or so. In some contexts, the first line is treated as the + subject of an email and the rest of the text as the body. The blank + line separating the summary from the body is critical (unless you omit + the body entirely); tools like rebase can get confused if you run the + two together. -Write your commit message in the imperative: "Fix bug" and not "Fixed bug" -or "Fixes bug." This convention matches up with commit messages generated -by commands like git merge and git revert. + Write your commit message in the imperative: "Fix bug" and not "Fixed bug" + or "Fixes bug." This convention matches up with commit messages generated + by commands like git merge and git revert. -Further paragraphs come after blank lines. + Further paragraphs come after blank lines. -- Bullet points are okay, too + - Bullet points are okay, too - - Typically a hyphen or asterisk is used for the bullet, followed by a - single space, with blank lines in between, but conventions vary here + - Typically a hyphen or asterisk is used for the bullet, followed by a + single space, with blank lines in between, but conventions vary here - - Use a hanging indent -``` + - Use a hanging indent [Gita] provide vim mode for Git commit messages, which helps you to comply to these guidelines. @@ -222,6 +237,7 @@ If you have some ASCII skills you can submit your artwork! You are free to choose a reasonable height size but the width size should be around 75 characters. +#### Contributing a statusline theme ## Build with SpaceVim diff --git a/docs/development/conventions.md b/docs/development/conventions.md index fd156defe..a32190572 100644 --- a/docs/development/conventions.md +++ b/docs/development/conventions.md @@ -1,16 +1,42 @@ --- title: "Conventions" -description: "conventions of contribute to SpaceVim, including the coding style guide about vim script and markdown" +description: "conventions of contributing to SpaceVim, including the coding style guides about vim script and markdown" permalink: "/conventions" --- # Conventions -## Content + -- [commit emoji convention](#commit-emoji-convention) -- [viml coding style guild](#viml-coding-style-guide) -- [markdown style guide](#markdown-style-guide) +- [Commit emoji convention](#commit-emoji-convention) +- [Viml coding style guide](#viml-coding-style-guide) + - [Portability](#portability) + - [Strings](#strings) + - [Matching Strings](#matching-strings) + - [Regular Expressions](#regular-expressions) + - [Dangerous commands](#dangerous-commands) + - [Fragile commands](#fragile-commands) + - [Catching Exceptions](#catching-exceptions) + - [General Guidelines](#general-guidelines) + - [Messaging](#messaging) + - [Type checking](#type-checking) + - [Python](#python) + - [Other Languages](#other-languages) + - [Plugin layout](#plugin-layout) + - [Functions](#functions) + - [Commands](#commands) + - [Autocommands](#autocommands) + - [Mappings](#mappings) + - [Errors](#errors) + - [Settings](#settings) + - [Style](#style) + - [Whitespace](#whitespace) + - [Line Continuations](#line-continuations) + - [Naming](#naming) +- [Markdown style guide](#markdown-style-guide) +- [Thanks:](#thanks) + + ## Commit emoji convention @@ -23,29 +49,35 @@ permalink: "/conventions" - :beer: I'm happy like reduced code complexity. ## Viml coding style guide + ### 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 + **Prefer single quoted strings** Double quoted strings are semantically different in vimscript, and you probably don't want them (they break regexes). -Use double quoted strings when you need an escape sequence (such as "\n") or if you know it doesn't matter and you need to embed single quotes. +Use double quoted strings when you need an escape sequence (such as "\\n") or if you know it doesn't matter and you need to embed single quotes. #### Matching Strings + **Use the =~# or =~? operator families over the =~ family.** 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 -**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 one of \m, \v, \M, or \V. +**Prefix 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. +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. #### Dangerous commands + **Avoid commands with unintended side effects.** Avoid using :s[ubstitute] as it moves the cursor and prints error messages. Prefer functions (such as search()) better suited to scripts. @@ -55,6 +87,7 @@ The meaning of the g flag depends upon the gdefault setting. If you do use :subs 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 + **Avoid commands that rely on user settings.** Always use normal! instead of normal. The latter depends upon the user's key mappings and could do anything. @@ -64,12 +97,15 @@ Avoid :s[ubstitute], as its behavior depends upon a number of local settings. The same applies to other commands not listed here. #### Catching Exceptions + **Match error codes, not error text.** Error text may be locale dependant. ### General Guidelines + #### Messaging + **Message the user infrequently.** Loud scripts are annoying. Message the user only when: @@ -78,6 +114,7 @@ Loud scripts are annoying. Message the user only when: - An error has occurred. #### Type checking + **Use strict and explicit checks where possible.** Vimscript has unsafe, unintuitive behavior when dealing with some types. For instance, 0 == 'foo' evaluates to true. @@ -89,21 +126,25 @@ Check variable types explicitly before using them. Use functions from maktaba#en Use :unlet for variables that may change types, particularly those assigned inside loops. #### Python + **Use sparingly.** Use python only when it provides critical functionality, for example when writing threaded code. #### Other Languages + **Use vimscript instead.** Avoid using other scripting languages such as ruby and lua. We can not guarantee that the end user's vim has been compiled with support for non-vimscript languages. #### Plugin layout + **Organize functionality into modular plugins** Group your functionality as a plugin, unified in one directory (or code repository) which shares your plugin's name (with a "vim-" prefix or ".vim" suffix if desired). It should be split into plugin/, autoload/, etc. subdirectories as necessary, and it should declare metadata in the addon-info.json format (see the VAM documentation for details). #### Functions + **In the autoload/ directory, defined with [!] and [abort].** Autoloading allows functions to be loaded on demand, which makes startuptime faster and enforces function namespacing. @@ -117,6 +158,7 @@ Non-library plugins should expose commands instead of functions. Command logic s [abort] forces the function to halt when it encounters an error. #### Commands + **In the plugin/commands.vim or under the ftplugin/ directory, defined without [!].** General commands go in plugin/commands.vim. Filetype-specific commands go in ftplugin/. @@ -124,6 +166,7 @@ General commands go in plugin/commands.vim. Filetype-specific commands go in ftp Excluding [!] prevents your plugin from silently clobbering existing commands. Command conflicts should be resolved by the user. #### Autocommands + **Place them in plugin/autocmds.vim, within augroups.** Place all autocommands in augroups. @@ -133,6 +176,7 @@ The augroup name should be unique. It should either be, or be prefixed with, the Clear the augroup with autocmd! before defining new autocommands in the augroup. This makes your plugin re-entrable. #### Mappings + **Place them in plugin/mappings.vim, using maktaba#plugin#MapPrefix to get a prefix.** All key mappings should be defined in plugin/mappings.vim. @@ -148,6 +192,7 @@ Your plugins generally shouldn't introduce mappings, but if they do, the map com When using catch, match the error code rather than the error text. #### Settings + **Change settings locally** Use :setlocal and &l: instead of :set and & unless you have explicit reason to do otherwise. @@ -189,6 +234,7 @@ such as "noremap gf :grep -f ". ``` #### Line Continuations + - Prefer line continuations on semantic boundaries. ```diff @@ -214,6 +260,7 @@ autocommand BufEnter - Do not continue multi-line commands when you can avoid it. Prefer function calls. #### Naming + In general, use plugin-names-like-this, FunctionNamesLikeThis, CommandNamesLikeThis, augroup_names_like_this, variable_names_like_this. Always prefix variables with their scope. @@ -221,28 +268,29 @@ Always prefix variables with their scope. - plugin-names-like-this Keep them short and sweet. - FunctionNamesLikeThis - - Prefix script-local functions with s: - - Autoloaded functions may not have a scope prefix. - - Do not create global functions. Use autoloaded functions instead. + - Prefix script-local functions with s: + - Autoloaded functions may not have a scope prefix. + - Do not create global functions. Use autoloaded functions instead. - CommandNamesLikeThis Prefer succinct command names over common command prefixes. - variable_names_like_this Augroup names count as variables for naming purposes. - Prefix all variables with their scope. - - Global variables with g: - - Script-local variables with s: - - Function arguments with a: - - Function-local variables with l: - - Vim-predefined variables with v: - - Buffer-local variables with b: - - g:, s:, and a: must always be used. - - b: changes the variable semantics; use it when you want buffer-local semantics. - - 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. + - Global variables with g: + - Script-local variables with s: + - Function arguments with a: + - Function-local variables with l: + - Vim-predefined variables with v: + - Buffer-local variables with b: + - g:, s:, and a: must always be used. + - b: changes the variable semantics; use it when you want buffer-local semantics. + - 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. ## Markdown style guide ## Thanks: -- link : https://google.github.io/styleguide/vimscriptguide.xml -- link : https://google.github.io/styleguide/vimscriptfull.xml -- link : https://github.com/noahfrederick/vim-scripting-style-guide/blob/master/doc/scripting-style.txt + +- link : +- link : +- link : - [google's markdown style guide](https://github.com/google/styleguide/blob/3591b2e540cbcb07423e02d20eee482165776603/docguide/style.md) diff --git a/docs/documentation.md b/docs/documentation.md index 88cd59b14..a046353af 100644 --- a/docs/documentation.md +++ b/docs/documentation.md @@ -88,10 +88,12 @@ description: "General documentation about how to using SpaceVim, including the q - [Auto-indent pasted text](#auto-indent-pasted-text) - [Text manipulation commands](#text-manipulation-commands) - [Text insertion commands](#text-insertion-commands) + - [Increase/Decrease numbers](#increasedecrease-numbers) - [Commenting](#commenting) - [Multi-Encodings](#multi-encodings) - [Errors handling](#errors-handling) - [Managing projects](#managing-projects) + - [Searching files in project](#searching-files-in-project) - [EditorConfig](#editorconfig) - [Vim Server](#vim-server) - [Connecting to the Vim server](#connecting-to-the-vim-server) @@ -172,7 +174,7 @@ Community-driven configuration provides curated packages tuned by power users an [Window] for all the window and buffer commands or [Unite] for the unite work flow commands. - **Fast boot time:** Lazy-load 90% of plugins with [dein.vim] -- **Lower the risk of RSI:** by heavily using the space bar instead of modifiers. +- **Lower the risk of RSI:** by heavily using the space bar instead of modifiers. - **Batteries included:** discover hundreds of ready-to-use packages nicely organised in configuration layers following a set of [conventions](http://spacevim.org/development/). @@ -514,6 +516,40 @@ The letters displayed in the statusline correspond to the key bindings used to t | `SPC t S` | Ⓢ | S | enabled in spell checking | | `SPC t w` | ⓦ | w | whitespace mode | +**colorscheme of statusline:** + +current version only support `gruvbox`/`molokai`/`nord`/`one`/`onedark`, if you want to contribute theme please check the template of a statusline theme. + +```vim +" the theme colors should be +" [ +" \ [ a_guifg, a_guibg, a_ctermfg, a_ctermbg], +" \ [ b_guifg, b_guibg, b_ctermfg, b_ctermbg], +" \ [ c_guifg, c_guibg, c_ctermfg, c_ctermbg], +" \ [ z_guibg, z_ctermbg], +" \ [ i_guifg, i_guibg, i_ctermfg, i_ctermbg], +" \ [ v_guifg, v_guibg, v_ctermfg, v_ctermbg], +" \ [ r_guifg, r_guibg, r_ctermfg, r_ctermbg], +" \ ] +" group_a: window id +" group_b/group_c: stausline sections +" group_z: empty area +" group_i: window id in insert mode +" group_v: window id in visual mode +" group_r: window id in select mode +function! SpaceVim#mapping#guide#theme#gruvbox#palette() abort + return [ + \ ['#282828', '#a89984', 246, 235], + \ ['#a89984', '#504945', 239, 246], + \ ['#a89984', '#3c3836', 237, 246], + \ ['#665c54', 241], + \ ['#282828', '#83a598', 235, 109], + \ ['#282828', '#fe8019', 235, 208], + \ ['#282828', '#8ec07c', 235, 108], + \ ] +endfunction +``` + #### tabline Buffers will be listed on tabline if there is only one tab, each item contains the index, filetype icon and the bufname. if there are more than one tab, all tabs will be listed on the tabline. each item can be quickly accessed using ` number`. default `` is `\`. @@ -530,6 +566,15 @@ Buffers will be listed on tabline if there is only one tab, each item contains t | ` 8` | jump to index 8 on tabline | | ` 9` | jump to index 9 on tabline | +SpaceVim tabline also support mouse click, left mouse button will switch to buffer, middle button will delete the buffer. + +**NOTE:** this feature is only supported in neovim with `has('tablineat')`. + +| Key Binding | Description | +| ---------------- | ------------------ | +| `` | jump to the buffer | +| `` | delete the buffer | + ## Manual ### Completion @@ -1177,18 +1222,18 @@ Background search keyword in a project, when searching done, the count will be s key binding in FlyGrep buffer: -Key Binding Description -\-----------\| ----------- -`` | close FlyGrep buffer -`` | open file at the cursor line -`` | move cursor line down -`` | move cursor line up -`` | remove last character -`` | remove the Word before the cursor -`` | remove the Line before the cursor -`` | remove the Line after the cursor -``/`` | Go to the beginning of the line -``/`` | Go to the end of the line +| Key Binding | Description | +| ---------------- | --------------------------------- | +| `` | close FlyGrep buffer | +| `` | open file at the cursor line | +| `` | move cursor line down | +| `` | move cursor line up | +| `` | remove last character | +| `` | remove the Word before the cursor | +| `` | remove the Line before the cursor | +| `` | remove the Line after the cursor | +| ``/`` | Go to the beginning of the line | +| ``/`` | Go to the end of the line | #### Persistent highlighting @@ -1279,6 +1324,23 @@ Text insertion commands (start with `i`): | `SPC i U 4` | insert UUIDv4 (use universal argument to insert with CID format) | | `SPC i U U` | insert UUIDv4 (use universal argument to insert with CID format) | +#### Increase/Decrease numbers + +| Key Binding | Description | +| ----------- | ------------------------------------------------------------------- | +| `SPC n +` | increase the number under point by one and initiate transient state | +| `SPC n -` | decrease the number under point by one and initiate transient state | + +In transient state: + +| Key Binding | Description | +| ------------- | -------------------------------------- | +| `+` | increase the number under point by one | +| `-` | decrease the number under point by one | +| Any other key | leave the transient state | + +**Tips:** you can increase or decrease a value by more that once by using a prefix argument (i.e. `10 SPC n +` will add 10 to the number under point). + #### Commenting Comments are handled by [nerdcommenter](https://github.com/scrooloose/nerdcommenter), it’s bound to the following keys. @@ -1351,6 +1413,15 @@ project manager commands start with `p`: | ----------- | ----------------------------------------------------- | | `SPC p '` | open a shell in project’s root (with the shell layer) | +#### Searching files in project + +| Key Binding | Description | +| ----------- | ----------------------------------------------------- | +| `SPC p f` | find files in current project | +| `SPC p /` | fuzzy search for text in current project | +| `SPC p k` | kill all project buffers | +| `SPC p t` | find project root | + ## EditorConfig SpaceVim has support for [EditorConfig](http://editorconfig.org/), a configuration file to “define and maintain consistent coding styles between different editors and IDEs.” diff --git a/docs/index.md b/docs/index.md index 32b08020c..35ebb61de 100644 --- a/docs/index.md +++ b/docs/index.md @@ -14,7 +14,7 @@ SpaceVim is a community-driven vim distribution that supports vim and Neovim. S Please star the project on github - it is a great way to show your appreciation while providing us motivation to continue working on this project. The extra visibility for the project doesn't hurt either! -![welcome-page](https://cloud.githubusercontent.com/assets/13142418/26402270/28ad72b8-40bc-11e7-945e-003f41e057be.png) +![welcome-page](https://user-images.githubusercontent.com/13142418/33793078-3446cb6e-dc76-11e7-9998-376a355557a4.png) See the [documentation](https://spacevim.org/documentation) or [the list of layers](http://spacevim.org/layers/) for more information. @@ -52,11 +52,12 @@ The easist way is to download [install.cmd](https://spacevim.org/install.cmd) an - **Great documentation:** access documentation in Vim with SPC h SPC. ![SPC h SPC](https://user-images.githubusercontent.com/13142418/31620230-48b53eea-b2c9-11e7-90d0-b717878875d4.gif) -- **Beautiful GUI:** you'll love the awesome UI and its useful features. +- **Beautiful UI:** you'll love the awesome UI and its useful features. + ![beautiful UI](https://user-images.githubusercontent.com/13142418/33804722-bc241f50-dd70-11e7-8dd8-b45827c0019c.png) - **Mnemonic key bindings:** all key bindings have mnemonic prefixes. ![mapping guide](https://user-images.githubusercontent.com/13142418/31550099-c8173ff8-b062-11e7-967e-6378a9c3b467.gif) -- **Describe key bindings:** use SPC h d k to describe key bindings. - ![describe key](https://user-images.githubusercontent.com/13142418/32134986-060a3b8a-bc2a-11e7-89a2-3ee4e616bf06.gif) +- **Describe key bindings:** use SPC h d k to describe key bindings, and find definition of key bindings. + ![describe key](https://user-images.githubusercontent.com/13142418/33804739-52dbc498-dd71-11e7-97e5-ed0fa6ec1719.gif) - **Lazy load plugins:** Lazy-load 90% of plugins with [dein.vim](https://github.com/Shougo/dein.vim) ![UI for dein](https://user-images.githubusercontent.com/13142418/31309093-36c01150-abb3-11e7-836c-3ad406bdd71a.gif) - **Neovim centric:** Dark powered mode of SpaceVim diff --git a/docs/layers/autocomplete.md b/docs/layers/autocomplete.md index 1bb545b2a..f3f0be8b6 100644 --- a/docs/layers/autocomplete.md +++ b/docs/layers/autocomplete.md @@ -1,5 +1,6 @@ --- title: "SpaceVim autocomplete layer" +description: "This layer provides auto-completion to SpaceVim" --- # [SpaceVim Layers:](https://spacevim.org/layers) autocomplete diff --git a/docs/layers/chat.md b/docs/layers/chat.md index 41e13a13f..7d8c31fa6 100644 --- a/docs/layers/chat.md +++ b/docs/layers/chat.md @@ -1,4 +1,5 @@ --- +title: "SpaceVim chat layer" description: "SpaceVim chatting layer provide chatting with qq and weixin in vim." --- diff --git a/docs/layers/checkers.md b/docs/layers/checkers.md index a72642cff..923b9c9ea 100644 --- a/docs/layers/checkers.md +++ b/docs/layers/checkers.md @@ -1,5 +1,6 @@ --- title: "SpaceVim checkers layer" +description: "This layer provides syntax checking feature" --- # [SpaceVim Layers:](https://spacevim.org/layers) checkers diff --git a/docs/layers/chinese.md b/docs/layers/chinese.md index e69de29bb..742ba5fcf 100644 --- a/docs/layers/chinese.md +++ b/docs/layers/chinese.md @@ -0,0 +1,18 @@ +--- +title: "SpaceVim chinese layer" +description: "Layer for chinese users, include chinese docs and runtime messages" +--- + +# [Layers](https://spacevim.org/layers) > chinese + +## Description + +This layer is for chinese users, and provide chinese docs and runtime messages. + +## Layer Installation + +To use this configuration layer, add `splayer 'chinese'` to your custom configuration file. + +## Configuration + +if you want to enable this feature, add `let g:spacevim_vim_help_language = 'cn'` to your custom config file. diff --git a/docs/layers/colorscheme.md b/docs/layers/colorscheme.md index 75b193b77..be8f6f66c 100644 --- a/docs/layers/colorscheme.md +++ b/docs/layers/colorscheme.md @@ -1,8 +1,14 @@ -# [Layers](https://spacevim.org/layers) > colorscheme +--- +title: "SpaceVim colorscheme layer" +description: "colorscheme provides a list of colorscheme for SpaceVim, default colorscheme is gruvbox with dark theme." +--- + +# [SpaceVim Layers:](https://spacevim.org/layers) colorscheme This layer provides many Vim colorschemes for SpaceVim, the default colorscheme is gruvbox. To change the colorscheme: + ```vim let g:spacevim_colorscheme = 'onedark' ``` diff --git a/docs/layers/debug.md b/docs/layers/debug.md new file mode 100644 index 000000000..bebd92712 --- /dev/null +++ b/docs/layers/debug.md @@ -0,0 +1,44 @@ +--- +title: "SpaceVim debug layer" +description: "This layer provide debug workflow support in SpaceVim" +--- + +# [SpaceVim Layers:](https://spacevim.org/layers) debug + + + +- [Description](#description) +- [Install](#install) +- [Key bindings](#key-bindings) + + + +## Description + +This layer provide a debug workflow for SpaceVim. All of the function is based on [vim-vebugger](https://github.com/idanarye/vim-vebugger). + +## Install + +To use this configuration layer, add `call SpaceVim#layers#load('debug')` to your custom configuration file. + +## Key bindings + +| Key Binding | Description | +| ----------- | ---------------------------------------- | +| `SPC d l` | launching debugger | +| `SPC d c` | Continue the execution | +| `SPC d b` | Toggle a breakpoint for the current line | +| `SPC d B` | Clear all breakpoints | +| `SPC d o` | step over | +| `SPC d i` | step into functions | +| `SPC d O` | step out of current function | +| `SPC d e s` | Evaluate and print the selected text | +| `SPC d e e` | Evaluate the `` under the cursor | +| `SPC d e S` | Execute the selected text | +| `SPC d k` | Terminates the debugger | + +**Debug Transient State** + +key bindings is too long? use `SPC d .` to open the debug transient state: + +![Debug Transient State](https://user-images.githubusercontent.com/13142418/33996076-b03c05bc-e0a5-11e7-90fd-5f31e2703d7e.png) diff --git a/docs/layers/git.md b/docs/layers/git.md index 06abb5061..ac6244196 100644 --- a/docs/layers/git.md +++ b/docs/layers/git.md @@ -1,5 +1,6 @@ --- title: "SpaceVim git layer" +description: "This layers adds extensive support for git" --- # [SpaceVim Layers:](https://spacevim.org/layers) git diff --git a/docs/layers/index.md b/docs/layers/index.md index ab20846d0..e71efc108 100644 --- a/docs/layers/index.md +++ b/docs/layers/index.md @@ -17,21 +17,34 @@ call SpaceVim#layers#load('shell', \ ) ``` + + ## Available layers -this a list of buildin layers: +| Name | Description | +| --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | +| [autocomplete](https://spacevim.org/layers/autocomplete/) | This layer provides auto-completion to SpaceVim | +| [chat](https://spacevim.org/layers/chat/) | SpaceVim chatting layer provide chatting with qq and weixin in vim. | +| [checkers](https://spacevim.org/layers/checkers/) | This layer provides syntax checking feature | +| [chinese](https://spacevim.org/layers/chinese/) | Layer for chinese users, include chinese docs and runtime messages | +| [colorscheme](https://spacevim.org/layers/colorscheme/) | colorscheme provides a list of colorscheme for SpaceVim, default colorscheme is gruvbox with dark theme. | +| [default](https://spacevim.org/layers/default/) | lt layer contains none plugins, but it has some better default config for vim and neovim | +| [git](https://spacevim.org/layers/git/) | This layers adds extensive support for git | +| [index](https://spacevim.org/layers/index/) | list of available layers in SpaceVim | +| [lang#c](https://spacevim.org/layers/lang/c/) | This layer is for c/c++/object-c development | +| [lang#java](https://spacevim.org/layers/lang/java/) | This layer is for Java development | +| [lang#javascript](https://spacevim.org/layers/lang/javascript/) | This layer is for JaveScript development | +| [lang#lisp](https://spacevim.org/layers/lang/lisp/) | for lisp development | +| [lang#markdown](https://spacevim.org/layers/lang/markdown/) | Edit markdown within vim, autopreview markdown in the default browser, with this layer you can also format markdown file. | +| [lang#php](https://spacevim.org/layers/lang/php/) | This layer adds PHP language support to SpaceVim | +| [lang#python](https://spacevim.org/layers/lang/python/) | This layer is for Python development, provide autocompletion, syntax checking, code format for python file. | +| [lang#ruby](https://spacevim.org/layers/lang/ruby/) | This layer is for ruby development, provide autocompletion, syntax checking, code format for ruby file. | +| [lang#typescript](https://spacevim.org/layers/lang/typescript/) | This layer is for TypeScript development | +| [lang#vim](https://spacevim.org/layers/lang/vim/) | This layer is for writting vim script, including code completion, syntax checking and buffer formatting | +| [shell](https://spacevim.org/layers/shell/) | This layer provide shell support in SpaceVim | +| [tags](https://spacevim.org/layers/tags/) | This layer provide tags manager for project | +| [ui](https://spacevim.org/layers/ui/) | Awesome UI layer for SpaceVim, provide IDE-like UI for neovim and vim in both TUI and GUI | -| Name | Description | Documentation | -| ------------- | :-------------------------------: | ---------------------------------------------------------- | -| autocomplete | autocomplete in vim | [documentation](https://spacevim.org/layers/autocomplete) | -| chat | chatting in vim | [documentation](https://spacevim.org/layers/chat) | -| checkers | checking in vim | [documentation](https://spacevim.org/layers/checkers) | -| chinese | layer for chinese vimer | [documentation](https://spacevim.org/layers/chinese) | -| colorscheme | all colorscheme in spacevim | [documentation](https://spacevim.org/layers/colorscheme) | -| default | better default for vim and neovim | [documentation](https://spacevim.org/layers/default) | -| lang#java | java development in vim | [documentation](https://spacevim.org/layers/lang/java) | -| lang#lisp | lisp development in vim | [documentation](https://spacevim.org/layers/lang/lisp) | -| lang#markdown | layer for editing markdown in vim | [documentation](https://spacevim.org/layers/lang/markdown) | -| lang#php | php development in vim | [documentation](https://spacevim.org/layers/lang/php) | -| shell | shell support for SpaceVim | [documentation](https://spacevim.org/layers/shell) | -| tags | tags manager in vim | [documentation](https://spacevim.org/layers/tags) | + + + diff --git a/docs/layers/lang/c.md b/docs/layers/lang/c.md new file mode 100644 index 000000000..97025cb40 --- /dev/null +++ b/docs/layers/lang/c.md @@ -0,0 +1,60 @@ +--- +title: "SpaceVim lang#c layer" +description: "This layer is for c/c++/object-c development" +--- + +# [Layers](https://spacevim.org/layers) > lang#c + + + + +- [Description](#description) +- [Layer Installation](#layer-installation) +- [Configuration](#configuration) + + + +## Description + +This layer is for c/c++/object-c development. + +## Layer Installation + +To use this configuration layer, add `SPLayer 'lang#c'` to your custom configuration file or load layer with custom options. + +```vim +call SpaceVim#layers#load('lang#c', + \ { + \ 'enable_libclang' : 1, + \ } + \ ) +``` + +## Configuration + +- `clang_executable` (string) + +set the path to the clang executable + +- `enable_libclang` (boolean) + +use libclang instead of `clang -cc1`, by default it is 0. + +- `libclang_path` (string) + +The libclang shared object (dynamic library) file path. by default it is empty. + +- `clang_std` (dict) + +```json +{ + "c": "c11", + "cpp": "c++1z", + "objc": "c11", + "objcpp": "c++1z", +} +``` + +- `clang_flag` + +Create a `.clang` file at your project root. You should be able to just paste most of your compile flags in there. You can also use a list ['-Iwhatever', ...] when loadding this layer. diff --git a/docs/layers/lang/java.md b/docs/layers/lang/java.md index 939dad2ea..98098e25a 100644 --- a/docs/layers/lang/java.md +++ b/docs/layers/lang/java.md @@ -1,18 +1,20 @@ --- title: "SpaceVim lang#java layer" +description: "This layer is for Java development" --- # [SpaceVim Layers:](https://spacevim.org/layers) lang#java -* [Description](#description) -* [Layer Installation](#layer-installation) -* [Key bindings](#key-bindings) - * [Java language specified key bindings](#java-language-specified-key-bindings) - * [Maven](#maven) - * [Jump](#jump) - * [Problems buffer](#problems-buffer) - * [Project buffer](#project-buffer) + +- [Description](#description) +- [Layer Installation](#layer-installation) +- [Key bindings](#key-bindings) + - [Java language specified key bindings](#java-language-specified-key-bindings) + - [Maven](#maven) + - [Jump](#jump) + - [Problems buffer](#problems-buffer) + - [Project buffer](#project-buffer) diff --git a/docs/layers/lang/javascript.md b/docs/layers/lang/javascript.md index 849ba6489..f28a1475a 100644 --- a/docs/layers/lang/javascript.md +++ b/docs/layers/lang/javascript.md @@ -7,10 +7,10 @@ description: "This layer is for JaveScript development" -- [Description](#description) -- [Layer Installation](#layer-installation) -- [Features](#features) -- [Layer configuration](#layer-configuration) +* [Description](#description) +* [Layer Installation](#layer-installation) +* [Features](#features) +* [Layer configuration](#layer-configuration) @@ -31,6 +31,7 @@ To use this configuration layer, add `call SpaceVim#layers#load('lang#javascript ## Layer configuration +`use_lsp`: Use language server if possible. The default value is `0`. `auto_fix`: auto fix problems when save files, disabled by default. if you need this feature, you can load this layer via: ```vim diff --git a/docs/layers/lang/markdown.md b/docs/layers/lang/markdown.md index 6d9e5b698..cd64d3e29 100644 --- a/docs/layers/lang/markdown.md +++ b/docs/layers/lang/markdown.md @@ -1,16 +1,17 @@ --- title: "SpaceVim lang#markdown layer" +description: "Edit markdown within vim, autopreview markdown in the default browser, with this layer you can also format markdown file." --- # [SpaceVim Layers:](https://spacevim.org/layers) lang#markdown -* [Description](#description) -* [Layer Installation](#layer-installation) -* [formatting](#formatting) - * [options](#options) -* [Key bindings](#key-bindings) +- [Description](#description) +- [Layer Installation](#layer-installation) +- [formatting](#formatting) + - [options](#options) +- [Key bindings](#key-bindings) diff --git a/docs/layers/lang/php.md b/docs/layers/lang/php.md index 6a31233f6..58ddedbbb 100644 --- a/docs/layers/lang/php.md +++ b/docs/layers/lang/php.md @@ -1,13 +1,15 @@ --- title: "SpaceVim lang#php layer" +description: "This layer adds PHP language support to SpaceVim" --- # [SpaceVim Layers:](https://spacevim.org/layers) lang#php -* [Description](#description) -* [Layer Installation](#layer-installation) - * [Requirement](#requirement) + +- [Description](#description) +- [Layer Installation](#layer-installation) + - [Requirement](#requirement) diff --git a/docs/layers/lang/python.md b/docs/layers/lang/python.md index 8f209ad9a..2414e2826 100644 --- a/docs/layers/lang/python.md +++ b/docs/layers/lang/python.md @@ -1,12 +1,24 @@ --- title: "SpaceVim lang#python layer" +description: "This layer is for Python development, provide autocompletion, syntax checking, code format for python file." --- # [SpaceVim Layers:](https://spacevim.org/layers) lang#python -* [Description](#description) -* [Features](#features) + +- [Description](#description) +- [Features](#features) +- [Install](#install) + - [Layer](#layer) + - [Syntax Checking](#syntax-checking) + - [Buffer formatting](#buffer-formatting) + - [Format imports](#format-imports) +- [Key bindings](#key-bindings) + - [Inferior REPL process](#inferior-repl-process) + - [Running current script](#running-current-script) + - [Testing](#testing) + - [Refactoring](#refactoring) @@ -18,3 +30,66 @@ This layer is for Python development. - Aoto-completion using [deoplete-jedi](https://github.com/zchee/deoplete-jedi) or [jedi-vim](https://github.com/davidhalter/jedi-vim) - Documentation Lookup using [jedi-vim](https://github.com/davidhalter/jedi-vim) + +## Install + +### Layer + +To use this configuration layer, add `SPLayer 'lang#python'` to your custom configuration file. + +### Syntax Checking + +`checker` layer provide syntax checking feature, and for python it uses `flake8` package: + +```sh +pip install --user flake8 +``` + +### Buffer formatting + +The default key binding for formatting buffer is `SPC b f`, and you need to install `yapf`. To enable automatic buffer formatting on save, load this layer with setting `format-on-save` to `1`. + +```sh +pip install --user yapf +``` + +### Format imports + +To be able to suppress unused imports easily, install [autoflake](https://github.com/myint/autoflake): + +```sh +pip install --user autoflake +``` + +To be able to sort your imports, install [isort](https://github.com/timothycrosley/isort) + +```sh +pip install --user isort +``` + +## Key bindings + +### Inferior REPL process + +Start a Python or iPython inferior REPL process with `SPC l s i`. If `ipython` is available in system executable search paths, `ipython` will be used to launch python shell; otherwise, default `python` interpreter will be used. You may change your system executable search path by activating a virtual environment. + +Send code to inferior process commands: + +| Key Binding | Description | +| ----------- | ------------------------------------------------ | +| `SPC l s b` | send buffer and keep code buffer focused | +| `SPC l s l` | send line and keep code buffer focused | +| `SPC l s s` | send selection text and keep code buffer focused | + +### Running current script + +To running a python script, you can press `SPC l r` to run current file without loss focus, and the result will be shown in a runner buffer. + +### Testing + +### Refactoring + +| Key Binding | Description | +| ----------- | ------------------------------------ | +| `SPC l i r` | remove unused imports with autoflake | +| `SPC l i s` | sort imports with isort | diff --git a/docs/layers/lang/ruby.md b/docs/layers/lang/ruby.md index 7b65d7aa4..b888a2b1f 100644 --- a/docs/layers/lang/ruby.md +++ b/docs/layers/lang/ruby.md @@ -1,13 +1,20 @@ --- title: "SpaceVim lang#ruby layer" +description: "This layer is for ruby development, provide autocompletion, syntax checking, code format for ruby file." --- # [SpaceVim Layers:](https://spacevim.org/layers) lang#ruby -* [Description](#description) -* [Layer Installation](#layer-installation) -* [Key bindings](#key-bindings) + +- [Description](#description) +- [Installation](#installation) + - [Layer](#layer) + - [Syntax checking && Code formatting](#syntax-checking--code-formatting) +- [Key bindings](#key-bindings) + - [Inferior REPL process](#inferior-repl-process) + - [RuboCop](#rubocop) + - [Running current script](#running-current-script) @@ -15,8 +22,41 @@ title: "SpaceVim lang#ruby layer" This layer is for ruby development. -## Layer Installation +## Installation + +### Layer To use this configuration layer, add `SPLayer 'lang#ruby'` to your custom configuration file. +### Syntax checking && Code formatting + +To enable syntax checking and code formatting in spacevim, you need to install [cobocop](https://github.com/bbatsov/rubocop). + +```sh +gem install rubocop +``` + + ## Key bindings + +### Inferior REPL process + +Start a `irb` inferior REPL process with `SPC l s i`. + +Send code to inferior process commands: + +| Key Binding | Description | +| ----------- | ------------------------------------------------ | +| `SPC l s b` | send buffer and keep code buffer focused | +| `SPC l s l` | send line and keep code buffer focused | +| `SPC l s s` | send selection text and keep code buffer focused | + +### RuboCop + +| Key Binding | Description | +| ----------- | ------------------------------------------ | +| `SPC l c f` | Runs RuboCop on the currently visited file | + +### Running current script + +To running a python script, you can press `SPC l r` to run current file without loss focus, and the result will be shown in a runner buffer. diff --git a/docs/layers/lang/typescript.md b/docs/layers/lang/typescript.md index c5b11958e..4ef8c5080 100644 --- a/docs/layers/lang/typescript.md +++ b/docs/layers/lang/typescript.md @@ -1,5 +1,6 @@ --- title: "SpaceVim lang#typescript layer" +description: "This layer is for TypeScript development" --- # [SpaceVim Layers:](https://spacevim.org/layers) lang#typescript diff --git a/docs/layers/lang/vim.md b/docs/layers/lang/vim.md index fe5dda783..c4321b9de 100644 --- a/docs/layers/lang/vim.md +++ b/docs/layers/lang/vim.md @@ -1,5 +1,6 @@ --- title: "SpaceVim lang#vim layer" +description: "This layer is for writting vim script, including code completion, syntax checking and buffer formatting" --- # [SpaceVim Layers:](https://spacevim.org/layers) lang#vim diff --git a/docs/layers/shell.md b/docs/layers/shell.md index 1e3ed3f04..501e8aee1 100644 --- a/docs/layers/shell.md +++ b/docs/layers/shell.md @@ -1,16 +1,18 @@ --- title: "SpaceVim shell layer" +description: "This layer provide shell support in SpaceVim" --- # [SpaceVim Layers:](https://spacevim.org/layers) shell -* [Description](#description) -* [Install](#install) -* [Configuration](#configuration) - * [Default shell](#default-shell) - * [Default shell position and height](#default-shell-position-and-height) -* [Key bindings](#key-bindings) + +- [Description](#description) +- [Install](#install) +- [Configuration](#configuration) + - [Default shell](#default-shell) + - [Default shell position and height](#default-shell-position-and-height) +- [Key bindings](#key-bindings) diff --git a/docs/layers/ui.md b/docs/layers/ui.md index a7c3efce6..b0d1013be 100644 --- a/docs/layers/ui.md +++ b/docs/layers/ui.md @@ -1,5 +1,6 @@ --- title: "SpaceVim ui layer" +description: "Awesome UI layer for SpaceVim, provide IDE-like UI for neovim and vim in both TUI and GUI" --- # [SpaceVim Layers:](https://spacevim.org/layers) ui diff --git a/docs/sponsors.md b/docs/sponsors.md index d1198afc0..b17a9098b 100644 --- a/docs/sponsors.md +++ b/docs/sponsors.md @@ -1,5 +1,6 @@ --- title: "Sponsors" +description: "the companies or individuals contributing a monthly amount to help sustain SpaceVim's development." --- ![Bountysource](https://spacevim.org/img/bountysource.png) @@ -8,20 +9,20 @@ If you want to support SpaceVim, please check out our [Bountysource campaign](ht Also, you can buy me a coffee: -Buy Me a Coffee at ko-fi.com +Buy Me a Coffee at ko-fi.com -if you are a chinese, It will be more easy in wechat. +| wechat | alipay | +| ------------------------------------------------------------------------ | -------------------------------------------------------------------------- | +| | | -![Buy me a coffee](https://spacevim.org/img/buy_me_a_coffee.png) +Bitcoin: 1DtuVeg81c2L9NEhDaVTAAbrCR3pN5xPFv # Current Sponsors These are the companies or individuals contributing a monthly amount to help sustain SpaceVim's development. See the [Bountysource campaign](https://www.bountysource.com/teams/spacevim) for more details. -Date | Description --------------- | ---------------------- -2017-2-23 | user from wechat contributed ¥40 to SpaceVim -2017-2-14 | user from wechat contributed ¥100 to SpaceVim - - +| Date | Description | +| --------- | --------------------------------------------- | +| 2017-2-23 | user from wechat contributed ¥40 to SpaceVim | +| 2017-2-14 | user from wechat contributed ¥100 to SpaceVim | diff --git a/init.vim b/init.vim index de677ab68..c07eb98ef 100644 --- a/init.vim +++ b/init.vim @@ -1 +1,9 @@ +"============================================================================= +" init.vim --- Entry file for neovim +" Copyright (c) 2016-2017 Shidong Wang & Contributors +" Author: Shidong Wang < wsdjeg at 163.com > +" URL: https://spacevim.org +" License: MIT license +"============================================================================= + execute 'source' fnamemodify(expand(''), ':h').'/config/main.vim' diff --git a/syntax/SpaceVimFlyGrep.vim b/syntax/SpaceVimFlyGrep.vim index bb5782fe3..ba7f9bf1d 100644 --- a/syntax/SpaceVimFlyGrep.vim +++ b/syntax/SpaceVimFlyGrep.vim @@ -1,8 +1,8 @@ if exists("b:current_syntax") - finish + finish endif let b:current_syntax = "SpaceVimFlyGrep" syntax case ignore -syn match FileName /[^:]*:\d\+:/ hi def link FileName Comment +call matchadd('FileName', '[^:]*:\d\+:', 2) diff --git a/syntax/SpaceVimRunner.vim b/syntax/SpaceVimRunner.vim new file mode 100644 index 000000000..35365714f --- /dev/null +++ b/syntax/SpaceVimRunner.vim @@ -0,0 +1,20 @@ +if exists("b:current_syntax") + finish +endif +let b:current_syntax = "SpaceVimRunner" +syntax case ignore +syn match KeyBindings /\[Running\]/ +syn match KeyBindings /\[Compile\]/ +syn match RunnerCmd /\(\[Running\]\ \)\@<=.*/ +syn match RunnerCmd /\(\[Compile\]\ \)\@<=.*/ +syn match DoneSucceeded /\[Done]\(\ exited\ with\ code=0\)\@=/ +syn match DoneFailed /\[Done]\(\ exited\ with\ code=[^0]\)\@=/ +syn match ExitCode /\(\[Done\]\ exited\ with \)\@<=code=0/ +syn match ExitCodeFailed /\(\[Done\]\ exited\ with \)\@<=code=[^0]/ + +hi def link RunnerCmd Comment +hi def link KeyBindings String +hi def link DoneSucceeded String +hi def link DoneFailed WarningMsg +hi def link ExitCode MoreMsg +hi def link ExitCodeFailed WarningMsg diff --git a/test/api/data/list.vader b/test/api/data/list.vader index 219e0bc85..8b8cf19e1 100644 --- a/test/api/data/list.vader +++ b/test/api/data/list.vader @@ -11,3 +11,4 @@ Execute ( SpaceVim api: data#list ): AssertEqual list.char_range('a', 'c'), ['a', 'b', 'c'] AssertEqual list.has(['a', 'c'], 'a'), 1 AssertEqual list.has_index(['a', 'c'], 1), 1 + AssertEqual list.replace([1, 2, 3, 4, 5, 6, 7], 3, 5, [0, 0, 0, 0]), [1, 2, 3, 0, 0, 0, 0, 7] diff --git a/vimrc b/vimrc index d5b8bd5b7..268ae128a 100644 --- a/vimrc +++ b/vimrc @@ -1,3 +1,11 @@ +"============================================================================= +" vimrc --- Entry file for vim +" Copyright (c) 2016-2017 Shidong Wang & Contributors +" Author: Shidong Wang < wsdjeg at 163.com > +" URL: https://spacevim.org +" License: MIT license +"============================================================================= + " Note: Skip initialization for vim-tiny or vim-small. if 1 execute 'source' fnamemodify(expand(''), ':h').'/config/main.vim' diff --git a/wiki/Development-tips.md b/wiki/Development-tips.md new file mode 100644 index 000000000..80f4a4226 --- /dev/null +++ b/wiki/Development-tips.md @@ -0,0 +1,9 @@ +steps of sending a PR: + +1. fork this repo +2. checkout new branch from dev branch +3. push your commits +4. sending pull request + + + diff --git a/wiki/Introduction.md b/wiki/Introduction.md index a6ea2ec09..99ed39a8a 100644 --- a/wiki/Introduction.md +++ b/wiki/Introduction.md @@ -1,11 +1,9 @@ -## Introduction +SpaceVim is a community-driven vim distribution that supports vim and Neovim. SpaceVim manages collections of plugins in layers. Layers make it easy for you, the user, to enable a new language or feature by grouping all the related plugins together. -[SpaceVim](https://github.com/SpaceVim/SpaceVim) is a community-driven vim distribution with a bundle of modular configuration, -here we call these modules as layers, each layer has different plugins and config, users just need -to select the layers they need. It got inspired by [spacemacs](https://github.com/syl20bnr/spacemacs). If you use SpaceVim, -please star it on github. It's a great way of getting feedback and gives me the kick to -put more time into development. +Please star the project on github - it is a great way to show your appreciation while providing us motivation to continue working on this project. The extra visibility for the project doesn't hurt either! -![2017-02-26_1365x739](https://cloud.githubusercontent.com/assets/13142418/23339920/590f2e9a-fc67-11e6-99ec-794f79ba0902.png) +![welcome-page](https://user-images.githubusercontent.com/13142418/33793078-3446cb6e-dc76-11e7-9998-376a355557a4.png) -If you are new to vim, you should learning about Vim in general, read [vim-galore](https://github.com/mhinz/vim-galore). \ No newline at end of file +See the [documentation](https://spacevim.org/documentation) or [the list of layers](http://spacevim.org/layers/) for more information. + +If you are new to vim, you should learning about Vim in general, read [vim-galore](https://github.com/mhinz/vim-galore). diff --git a/wiki/project_layout.md b/wiki/project_layout.md index a4adf03e2..c5f779ae4 100644 --- a/wiki/project_layout.md +++ b/wiki/project_layout.md @@ -9,3 +9,16 @@ This is the project layout of SpaceVim org: | [SpaceVim/vim-swig](https://github.com/SpaceVim/vim-swig) | Swig vim syntax highlighting | | [SpaceVim/vim-luacomplete](https://github.com/SpaceVim/vim-luacomplete) | lua complete plugin for vim | | [SpaceVim/unite-unicode](https://github.com/SpaceVim/unite-unicode) | Unite.vim plugin to insert unicode gyphs | + +In the main repo, the layout is: + + ├─ autoload/SpaceVim/api/ APIs + ├─ autoload/SpaceVim/layers/ layers + ├─ autoload/SpaceVim/plugins/ plugins + ├─ autoload/SpaceVim/mapping/ mapping guide + ├─ doc/SpaceVim.txt help + ├─ docs/ website + ├─ wiki/ wiki + ├─ bin/ executeable + └─ test/ tests +