1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-24 05:40:05 +08:00
This commit is contained in:
tenfy 2017-07-28 13:20:23 +08:00
commit 49b49a5aec
47 changed files with 3680 additions and 1151 deletions

View File

@ -40,9 +40,17 @@ install:
script:
- |
if [ "$LINT" = "vimlint" ]; then
sh /tmp/vimlint/bin/vimlint.sh -l /tmp/vimlint -p /tmp/vimlparser .
sh /tmp/vimlint/bin/vimlint.sh -l /tmp/vimlint -p /tmp/vimlparser ./config
sh /tmp/vimlint/bin/vimlint.sh -l /tmp/vimlint -p /tmp/vimlparser ./autoload
sh /tmp/vimlint/bin/vimlint.sh -l /tmp/vimlint -p /tmp/vimlparser ./ftplugin
sh /tmp/vimlint/bin/vimlint.sh -l /tmp/vimlint -p /tmp/vimlparser ./syntax
sh /tmp/vimlint/bin/vimlint.sh -l /tmp/vimlint -p /tmp/vimlparser ./mode
elif [ "$LINT" = "vimlint-errors" ]; then
sh /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser .
sh /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser ./config
sh /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser ./autoload
sh /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser ./ftplugin
sh /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser ./syntax
sh /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser ./mode
elif [ "$LINT" = "vint" ]; then
vint .
elif [ "$LINT" = "vint-errors" ]; then

154
README.md
View File

@ -30,14 +30,14 @@ Here is a throughput graph of the repository for the last few weeks:
* [Mnemonic key bindings](#mnemonic-key-bindings)
* [Unite work flow](#unite-work-flow)
* [module statusline](#module-statusline)
* [Install](#install)
* [1. Requirements](#1-requirements)
* [2. Install SpaceVim in Linux/Mac](#2-install-spacevim-in-linuxmac)
* [3. Install SpaceVim in windows](#3-install-spacevim-in-windows)
* [Update](#update)
* [Documentation](#documentation)
* [Quick start guide](#quick-start-guide)
* [Getting Help](#getting-help)
* [Community](#community)
* [Install](#install)
* [Linux/Mac](#linuxmac)
* [windows support](#windows-support)
* [Update](#update)
* [Support SpaceVim](#support-spacevim)
* [contribute to SpaceVim](#contribute-to-spacevim)
* [Write post about SpaceVim](#write-post-about-spacevim)
@ -102,6 +102,66 @@ The `core#statusline` layer provide a heavily customized powerline with the foll
![search status](https://cloud.githubusercontent.com/assets/13142418/26313080/578cc68c-3f3c-11e7-9259-a27419d49572.png)
## Install
### 1. Requirements
**nerd fonts and true colors:**
SpaceVim provides basic and awesome mode, if you want to use awesome mode, you need to install the [nerd-fonts](https://github.com/ryanoasis/nerd-fonts) and make sure your terminal support [true colors](https://gist.github.com/XVilka/8346728).
**Vim 7.4 above or neovim:**
- [neovim installation](https://github.com/neovim/neovim/wiki/Installing-Neovim)
- [install vim with python, python3 and lua support](https://github.com/Valloric/YouCompleteMe/wiki/Building-Vim-from-source)
**git:**
SpaceVim will download all plugins via git.
### 2. Install SpaceVim in Linux/Mac
Install SpaceVim with the command below:
```bash
curl -sLf https://spacevim.org/install.sh | bash
```
After SpaceVim is installed, launch `vim` and SpaceVim will **automatically** install plugins.
for more info about the install script, please check:
```bash
curl -sLf https://spacevim.org/install.sh | bash -s -- -h
```
### 3. Install SpaceVim in windows
- For vim in windows, please just clone this repo as vimfiles in you Home directory.
by default, when open a cmd, the current dir is your Home directory, run this command in cmd.
make sure you have a backup of your own vimfiles. also you need remove `~/_vimrc` in your home directory.
```sh
git clone https://github.com/SpaceVim/SpaceVim.git vimfiles
```
- For neovim in windows, please clone this repo as `AppData\Local\nvim` in your home directory.
for more info, please check out [neovim's wiki](https://github.com/neovim/neovim/wiki/Installing-Neovim).
by default, when open a cmd, the current dir is your Home directory, run this command in cmd.
```bash
git clone https://github.com/SpaceVim/SpaceVim.git AppData\Local\nvim
```
## Update
you can update SpaceVim with the command below:
```viml
:SPUpdate SpaceVim
```
## Documentation
### Quick start guide
@ -123,20 +183,20 @@ let g:spacevim_max_column = 80
let g:spacevim_plugin_bundle_dir = '~/.cache/vimfiles/'
" set SpaceVim colorscheme
let g:spacevim_colorscheme = 'jellybeans'
let g:spacevim_colorscheme = 'gruvbox'
" Set plugin manager, you want to use, default is dein.vim
let g:spacevim_plugin_manager = 'dein' " neobundle or dein or vim-plug
" use space as `<Leader>`
let mapleader = "\<space>"
" Set windows shortcut leader [Window], default is `s`
let g:spacevim_windows_leader = 's'
" Set unite work flow shortcut leader [Unite], default is `f`
let g:spacevim_unite_leader = 'f'
" Set Denite work flow shortcut leader [Denite], default is `F`
let g:spacevim_denite_leader = 'F'
" By default, language specific plugins are not loaded. This can be changed
" with the following, then the plugins for go development will be loaded.
call SpaceVim#layers#load('lang#go')
@ -164,78 +224,20 @@ Comprehensive documentation is available for each layer by <kbd>:h SpaceVim</kbd
You can also check the [general documentation](http://spacevim.org/documentation/).
## Getting Help
If you need help, ask your question in the [Gitter Chat](https://gitter.im/SpaceVim/SpaceVim), a member of the community will help you out.
## Community
Try these Neovim hangouts for any questions, problems or comments.
- Ask
- [issue tracker](https://github.com/SpaceVim/SpaceVim/issues) for issue and feature requests
- vi StackExchange for "how to" & configuration questions
- [![Twitter Follow](https://img.shields.io/twitter/follow/SpaceVim.svg?style=social&label=Follow&maxAge=2592000)](https://twitter.com/SpaceVim) for hugs & pithy comments
Try these SpaceVim hangouts for any questions, problems or comments.
- Chat
- [![Gitter](https://badges.gitter.im/SpaceVim/SpaceVim.svg)](https://gitter.im/SpaceVim/SpaceVim?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
- [![QQ](https://img.shields.io/badge/QQ群-121056965-blue.svg)](https://jq.qq.com/?_wv=1027&k=43DB6SG)
- [![Facebook](https://img.shields.io/badge/FaceBook-SpaceVim-blue.svg)](https://www.facebook.com/SpaceVim)
- Ask
- [issue tracker](https://github.com/SpaceVim/SpaceVim/issues) for issue and feature requests
- vi StackExchange for "how to" & configuration questions
- [![Twitter Follow](https://img.shields.io/twitter/follow/SpaceVim.svg?style=social&label=Follow&maxAge=2592000)](https://twitter.com/SpaceVim) for hugs & pithy comments
- Discuss
- [google mailing list](https://groups.google.com/forum/#!forum/spacevim)
## Install
### Linux/Mac
**Install SpaceVim with the command below**
```bash
curl -sLf https://spacevim.org/install.sh | bash
```
**After SpaceVim is installed, launch `vim` and SpaceVim will automatically install plugins**
Once plugins start installing, at the bottom of the vim window, you will see
`[dein] Install started: (YYYY/MM/DD HH:MM:SS)`
Please wait for all the plugins to complete installing before using vim. Once the plugin installation completes, you will see
`[dein] Done: (YYYY/MM/DD HH:MM:SS) `. At this point you can start using vim.
SpaceVim required Vim7.4 above or neovim, here is the installation of neovim/vim with python support:
- [neovim installation](https://github.com/neovim/neovim/wiki/Installing-Neovim)
- [Building Vim from source](https://github.com/Valloric/YouCompleteMe/wiki/Building-Vim-from-source)
for more info about the install script, please check:
```bash
curl -sLf https://spacevim.org/install.sh | bash -s -- -h
```
### windows support
- For vim in windows, please just clone this repo as vimfiles in you Home directory.
by default, when open a cmd, the current dir is your Home directory, run this command in cmd.
make sure you have a backup of your own vimfiles. also you need remove `~/_vimrc` in your home directory.
```sh
git clone https://github.com/SpaceVim/SpaceVim.git vimfiles
```
- For neovim in windows, please clone this repo as `AppData\Local\nvim` in your home directory.
for more info, please check out [neovim's wiki](https://github.com/neovim/neovim/wiki/Installing-Neovim).
by default, when open a cmd, the current dir is your Home directory, run this command in cmd.
```bash
git clone https://github.com/SpaceVim/SpaceVim.git AppData\Local\nvim
```
## Update
you can update SpaceVim with the command below:
```viml
:SPUpdate SpaceVim
```
## Support SpaceVim
@ -251,7 +253,7 @@ If you used SpaceVim in a project and you want to show that fact, you can use th
markdown
```md
```markdown
[![](https://spacevim.org/img/build-with-SpaceVim.svg)](https://spacevim.org)
```
@ -261,11 +263,13 @@ Before contributing be sure to consult the [contribution guidelines](http://spac
### Write post about SpaceVim
if you want to write something about SpaceVim, and want your post be linked in [SpaceVim's blog page](https://spacevim.org/blog), please show us the link.
if you want to write something about SpaceVim, and want your post to be posted in [SpaceVim's blog page](https://spacevim.org/blog), please show us the link.
## Credits & Thanks
- [![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
- [Bailey Ling](https://github.com/bling) and his dotvim
- authors of all the plugins used in SpaceVim.

View File

@ -150,6 +150,7 @@ let g:spacevim_enable_cursorline = 1
" See more details in: http://spacevim.org/documentation/#statusline
"
let g:spacevim_statusline_separator = 'arrow'
let g:spacevim_statusline_inactive_separator = 'arrow'
""
" Enable/Disable cursorcolumn. Default is 0, cursorcolumn will be
" highlighted in normal mode. To enable this feature:
@ -416,6 +417,7 @@ let g:spacevim_leader_guide_submode_mappings = {'<C-C>': "win_close"}
command -nargs=1 LeaderGuide call SpaceVim#mapping#guide#start_by_prefix('0', <args>)
command -range -nargs=1 LeaderGuideVisual call SpaceVim#mapping#guide#start_by_prefix('1', <args>)
function! SpaceVim#loadCustomConfig() abort
let custom_confs_old = SpaceVim#util#globpath(getcwd(), '.local.vim')

View File

@ -0,0 +1,147 @@
""
" @section prompt, api-prompt
" @parentsection api
" open()
"
" Create a cmdline prompt, use while loop to get the input from user. The
" default mapping for prompt is:
" >
" <Bs> remove last character
" <C-w> remove the Word before the cursor
" <C-u> remove the Line before the cursor
" <C-k> remove the Line after the cursor
" <C-a> / <Home> Go to the beginning of the line
" <C-e> / <End> Go to the end of the line
" <
let s:self = {}
let s:self._keys = {
\ 'close' : "\<Esc>",
\ 'cursor_back' : '<Left>',
\ 'cursor_forword' : '<Right>',
\ }
let s:self._prompt = {
\ 'mpt' : '==>',
\ 'begin' : '',
\ 'cursor' : '',
\ 'end' : '',
\ }
let s:self._function_key = {}
let s:self._quit = 1
let s:self._handle_fly = ''
let s:self._onclose = ''
let s:self._oninputpro = ''
func! s:self.open() abort
let self._quit = 0
let save_redraw = &lazyredraw
set nolazyredraw
call self._build_prompt()
call self._handle_input()
let &lazyredraw = save_redraw
endf
function! s:self._getchar(...) abort
let ret = call('getchar', a:000)
return (type(ret) == type(0) ? nr2char(ret) : ret)
endfunction
func! s:self._handle_input() abort
while self._quit == 0
let char = self._getchar()
if has_key(self._function_key, char)
call call(self._function_key[char], [])
continue
endif
if char ==# "\<Right>" || char == 6
let self._prompt.begin = self._prompt.begin . self._prompt.cursor
let self._prompt.cursor = matchstr(self._prompt.end, '^.')
let self._prompt.end = substitute(self._prompt.end, '^.', '', 'g')
call self._build_prompt()
continue
elseif char ==# "\<Left>" || char == 2
if self._prompt.begin !=# ''
let self._prompt.end = self._prompt.cursor . self._prompt.end
let self._prompt.cursor = matchstr(self._prompt.begin, '.$')
let self._prompt.begin = substitute(self._prompt.begin, '.$', '', 'g')
call self._build_prompt()
endif
continue
elseif char ==# "\<C-w>"
let self._prompt.begin = substitute(self._prompt.begin,'[^\ .*]\+\s*$','','g')
call self._build_prompt()
elseif char ==# "\<C-a>" || char ==# "\<Home>"
let self._prompt.end = substitute(self._prompt.begin . self._prompt.cursor . self._prompt.end, '^.', '', 'g')
let self._prompt.cursor = matchstr(self._prompt.begin, '^.')
let self._prompt.begin = ''
call self._build_prompt()
continue
elseif char ==# "\<C-e>" || char ==# "\<End>"
let self._prompt.begin = self._prompt.begin . self._prompt.cursor . self._prompt.end
let self._prompt.cursor = ''
let self._prompt.end = ''
call self._build_prompt()
continue
elseif char ==# "\<C-u>"
let self._prompt.begin = ''
call self._build_prompt()
elseif char ==# "\<C-k>"
let self._prompt.cursor = ''
let self._prompt.end = ''
call self._build_prompt()
elseif char ==# "\<bs>"
let self._prompt.begin = substitute(self._prompt.begin,'.$','','g')
call self._build_prompt()
elseif char == self._keys.close
call self.close()
break
elseif char ==# "\<FocusLost>" || char ==# "\<FocusGained>" || char2nr(char) == 128
continue
else
let self._prompt.begin .= char
call self._build_prompt()
endif
if self._oninputpro !=# ''
call call(self._oninputpro, [])
endif
if self._handle_fly !=# ''
call call(self._handle_fly, [self._prompt.begin . self._prompt.cursor . self._prompt.end])
endif
endwhile
endf
func! s:self._build_prompt() abort
redraw
echohl Comment | echon self._prompt.mpt
echohl None | echon self._prompt.begin
echohl Wildmenu | echon self._prompt.cursor
echohl None | echon self._prompt.end
endf
function! s:self._clear_prompt() abort
let self._prompt = {
\ 'mpt' : self._prompt.mpt,
\ 'begin' : '',
\ 'cursor' : '',
\ 'end' : '',
\ }
endfunction
function! s:self.close() abort
if self._onclose !=# ''
call call(self._onclose, [])
endif
call self._clear_prompt()
normal! :
let self._quit = 1
endfunction
function! SpaceVim#api#prompt#get() abort
return deepcopy(s:self)
endfunction

View File

@ -0,0 +1,192 @@
let s:self = {}
let s:self._keys = {}
let s:self._on_syntax = ''
let s:self._title = 'Transient State'
let s:self._handle_inputs = {}
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, [])
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 ==# "\<FocusLost>" || char ==# "\<FocusGained>" || 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
endfunction
function! s:self._getchar(...) abort
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
endfunction
function! s:self.set_syntax(func) abort
let self._on_syntax = a:func
endfunction
function! s:self.set_title(title) abort
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
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
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
else
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 list
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 list
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
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
endif
endif
call append(line('$'), line)
endfor
endif
endfunction
function! SpaceVim#api#transient_state#get() abort
return deepcopy(s:self)
endfunction

View File

@ -3,7 +3,16 @@ let s:self = {}
function! s:self.group2dict(name) abort
let id = index(map(range(1999), "synIDattr(v:val, 'name')"), a:name)
if id == -1
return {}
return {
\ 'name' : '',
\ 'ctermbg' : '',
\ 'ctermfg' : '',
\ 'bold' : '',
\ 'italic' : '',
\ 'underline' : '',
\ 'guibg' : '',
\ 'guifg' : '',
\ }
endif
let rst = {
\ 'name' : synIDattr(id, 'name'),
@ -32,35 +41,35 @@ function! s:self.unite(base, target, part) abort
endfunction
function! s:self.hi(info) abort
if empty(a:info)
if empty(a:info) || get(a:info, 'name', '') ==# ''
return
endif
let cmd = 'hi! ' . a:info.name
if !empty(a:info.ctermbg)
let cmd .= ' ctermbg=' . a:info.ctermbg
endif
if !empty(a:info.ctermfg)
let cmd .= ' ctermfg=' . a:info.ctermfg
endif
if !empty(a:info.guibg)
let cmd .= ' guibg=' . a:info.guibg
endif
if !empty(a:info.guifg)
let cmd .= ' guifg=' . a:info.guifg
endif
let style = []
for sty in ['hold', 'italic', 'underline']
if get(a:info, sty, '') ==# '1'
call add(style, sty)
endif
endfor
if !empty(style)
let cmd .= ' gui=' . join(style, ',') . ' cterm=' . join(style, ',')
endif
try
exe cmd
catch
endtry
let cmd = 'hi! ' . a:info.name
if !empty(a:info.ctermbg)
let cmd .= ' ctermbg=' . a:info.ctermbg
endif
if !empty(a:info.ctermfg)
let cmd .= ' ctermfg=' . a:info.ctermfg
endif
if !empty(a:info.guibg)
let cmd .= ' guibg=' . a:info.guibg
endif
if !empty(a:info.guifg)
let cmd .= ' guifg=' . a:info.guifg
endif
let style = []
for sty in ['hold', 'italic', 'underline']
if get(a:info, sty, '') ==# '1'
call add(style, sty)
endif
endfor
if !empty(style)
let cmd .= ' gui=' . join(style, ',') . ' cterm=' . join(style, ',')
endif
try
exe cmd
catch
endtry
endfunction
function! s:self.hide_in_normal(name) abort
@ -68,7 +77,7 @@ function! s:self.hide_in_normal(name) abort
if empty(group)
return
endif
if &termguicolors || has('gui_running')
if (exists('+termguicolors') && &termguicolors ) || has('gui_running')
let bg = self.group2dict('Normal').guibg
if empty(bg)
return

View File

@ -15,7 +15,7 @@ function! s:self.build(left_sections, right_sections, lsep, rsep, hi_a, hi_b, hi
endif
let flag = flag * -1
endfor
let l = l[:-4]
let l = l[:len(a:lsep) * -1 - 1]
if empty(a:right_sections)
if flag == 1
return l . '%#' . a:hi_c . '#'

View File

@ -0,0 +1,53 @@
let s:save_cpo = &cpo
set cpo&vim
let s:self = {}
let s:XML = SpaceVim#api#import('web#xml')
let s:HTTP = SpaceVim#api#import('web#http')
function! s:self.decodeEntityReference(str) abort
let str = a:str
let str = substitute(str, '&gt;', '>', 'g')
let str = substitute(str, '&lt;', '<', 'g')
let str = substitute(str, '&quot;', '"', 'g')
let str = substitute(str, '&apos;', "'", 'g')
let str = substitute(str, '&nbsp;', ' ', 'g')
let str = substitute(str, '&yen;', '\&#65509;', 'g')
let str = substitute(str, '&#\(\d\+\);', '\=s:nr2enc_char(submatch(1))', 'g')
let str = substitute(str, '&amp;', '\&', 'g')
let str = substitute(str, '&raquo;', '>', 'g')
let str = substitute(str, '&laquo;', '<', 'g')
return str
endfunction
function! s:self.encodeEntityReference(str) abort
let str = a:str
let str = substitute(str, '&', '\&amp;', 'g')
let str = substitute(str, '>', '\&gt;', 'g')
let str = substitute(str, '<', '\&lt;', 'g')
let str = substitute(str, "\n", '\&#x0d;', 'g')
let str = substitute(str, '"', '\&quot;', 'g')
let str = substitute(str, "'", '\&apos;', 'g')
let str = substitute(str, ' ', '\&nbsp;', 'g')
return str
endfunction
function! s:self.parse(html) abort
let html = substitute(a:html, '<\(area\|base\|basefont\|br\|nobr\|col\|frame\|hr\|img\|input\|isindex\|link\|meta\|param\|embed\|keygen\|command\)\([^>]*[^/]\|\)>', '<\1\2/>', 'g')
return s:XML.parse(html)
endfunction
function! s:self.parseFile(file) abort
return self.parse(join(readfile(a:file), "\n"))
endfunction
function! s:self.parseURL(url) abort
return self.parse(s:HTTP.get(a:url).content)
endfunction
function! SpaceVim#api#web#html#get() abort
return deepcopy(s:self)
endfunction
let &cpo = s:save_cpo
unlet s:save_cpo

View File

@ -0,0 +1,478 @@
let s:save_cpo = &cpo
set cpo&vim
let s:self = {}
let s:system = function(get(g:, 'webapi#system_function', 'system'))
function! s:nr2byte(nr) abort
if a:nr < 0x80
return nr2char(a:nr)
elseif a:nr < 0x800
return nr2char(a:nr/64+192).nr2char(a:nr%64+128)
elseif a:nr < 0x10000
return nr2char(a:nr/4096%16+224).nr2char(a:nr/64%64+128).nr2char(a:nr%64+128)
elseif a:nr < 0x200000
return nr2char(a:nr/262144%16+240).nr2char(a:nr/4096/16+128).nr2char(a:nr/64%64+128).nr2char(a:nr%64+128)
elseif a:nr < 0x4000000
return nr2char(a:nr/16777216%16+248).nr2char(a:nr/262144%16+128).nr2char(a:nr/4096/16+128).nr2char(a:nr/64%64+128).nr2char(a:nr%64+128)
else
return nr2char(a:nr/1073741824%16+252).nr2char(a:nr/16777216%16+128).nr2char(a:nr/262144%16+128).nr2char(a:nr/4096/16+128).nr2char(a:nr/64%64+128).nr2char(a:nr%64+128)
endif
endfunction
function! s:nr2enc_char(charcode) abort
if &encoding ==# 'utf-8'
return nr2char(a:charcode)
endif
let char = s:nr2byte(a:charcode)
if strlen(char) > 1
let char = strtrans(iconv(char, 'utf-8', &encoding))
endif
return char
endfunction
function! s:nr2hex(nr) abort
let n = a:nr
let r = ''
while n
let r = '0123456789ABCDEF'[n % 16] . r
let n = n / 16
endwhile
return r
endfunction
function! s:urlencode_char(c, ...) abort
let is_binary = get(a:000, 1)
let c = a:c
if !is_binary
let c = iconv(a:c, &encoding, 'utf-8')
if c ==# ''
let c = a:c
endif
endif
let s = ''
for i in range(strlen(c))
let s .= printf('%%%02X', char2nr(c[i]))
endfor
return s
endfunction
function! s:self.decodeURI(str) abort
let ret = a:str
let ret = substitute(ret, '+', ' ', 'g')
let ret = substitute(ret, '%\(\x\x\)', '\=printf("%c", str2nr(submatch(1), 16))', 'g')
return ret
endfunction
function! s:self.escape(str) abort
return substitute(a:str, '[^a-zA-Z0-9_.~/-]', '\=s:urlencode_char(submatch(0))', 'g')
endfunction
function! s:self.encodeURI(items, ...) abort
let is_binary = get(a:000, 1)
let ret = ''
if type(a:items) == 4
for key in sort(keys(a:items))
if strlen(ret) | let ret .= '&' | endif
let ret .= key . '=' . s:self.encodeURI(a:items[key])
endfor
elseif type(a:items) == 3
for item in sort(a:items)
if strlen(ret) | let ret .= '&' | endif
let ret .= item
endfor
else
let ret = substitute(a:items, '[^a-zA-Z0-9_.~-]', '\=s:urlencode_char(submatch(0), is_binary)', 'g')
endif
return ret
endfunction
function! s:self.encodeURIComponent(items) abort
let ret = ''
if type(a:items) == 4
for key in sort(keys(a:items))
if strlen(ret) | let ret .= '&' | endif
let ret .= key . '=' . s:self.encodeURIComponent(a:items[key])
endfor
elseif type(a:items) == 3
for item in sort(a:items)
if strlen(ret) | let ret .= '&' | endif
let ret .= item
endfor
else
let items = iconv(a:items, &enc, 'utf-8')
let len = strlen(items)
let i = 0
while i < len
let ch = items[i]
if ch =~# '[0-9A-Za-z-._~!''()*]'
let ret .= ch
elseif ch ==# ' '
let ret .= '+'
else
let ret .= '%' . substitute('0' . s:nr2hex(char2nr(ch)), '^.*\(..\)$', '\1', '')
endif
let i = i + 1
endwhile
endif
return ret
endfunction
function! s:self.get(url, ...) abort
let getdata = a:0 > 0 ? a:000[0] : {}
let headdata = a:0 > 1 ? a:000[1] : {}
let follow = a:0 > 2 ? a:000[2] : 1
let url = a:url
let getdatastr = self.encodeURI(getdata)
if strlen(getdatastr)
let url .= '?' . getdatastr
endif
if executable('curl')
let command = printf('curl -q %s -s -k -i', follow ? '-L' : '')
let quote = &shellxquote ==# '"' ? "'" : '"'
for key in keys(headdata)
if has('win32')
let command .= ' -H ' . quote . key . ': ' . substitute(headdata[key], '"', '"""', 'g') . quote
else
let command .= ' -H ' . quote . key . ': ' . headdata[key] . quote
endif
endfor
let command .= ' ' . quote . url . quote
let res = s:system(command)
elseif executable('wget')
let command = printf('wget -O- --save-headers --server-response -q %s', follow ? '-L' : '')
let quote = &shellxquote ==# '"' ? "'" : '"'
for key in keys(headdata)
if has('win32')
let command .= ' --header=' . quote . key . ': ' . substitute(headdata[key], '"', '"""', 'g') . quote
else
let command .= ' --header=' . quote . key . ': ' . headdata[key] . quote
endif
endfor
let command .= ' ' . quote . url . quote
let res = s:system(command)
else
throw 'require `curl` or `wget` command'
endif
if follow != 0
let mx = 'HTTP/\%(1\.[01]\|2\%(\.0\)\?\)'
while res =~# '^' . mx . ' 3' || res =~# '^' . mx . ' [0-9]\{3} .\+\n\r\?\n' . mx . ' .\+'
let pos = stridx(res, "\r\n\r\n")
if pos != -1
let res = strpart(res, pos+4)
else
let pos = stridx(res, "\n\n")
let res = strpart(res, pos+2)
endif
endwhile
endif
let pos = stridx(res, "\r\n\r\n")
if pos != -1
let content = strpart(res, pos+4)
else
let pos = stridx(res, "\n\n")
let content = strpart(res, pos+2)
endif
let header = split(res[:pos-1], '\r\?\n')
let matched = matchlist(get(header, 0), '^HTTP/\%(1\.[01]\|2\%(\.0\)\?\)\s\+\(\d\+\)\s*\(.*\)')
if !empty(matched)
let [status, message] = matched[1 : 2]
call remove(header, 0)
else
if v:shell_error || len(matched)
let [status, message] = ['500', "Couldn't connect to host"]
else
let [status, message] = ['200', 'OK']
endif
endif
return {
\ 'status' : status,
\ 'message' : message,
\ 'header' : header,
\ 'content' : content
\}
endfunction
function! s:self.post(url, ...) abort
let postdata = a:0 > 0 ? a:000[0] : {}
let headdata = a:0 > 1 ? a:000[1] : {}
let method = a:0 > 2 ? a:000[2] : 'POST'
let follow = a:0 > 3 ? a:000[3] : 1
let url = a:url
if type(postdata) == 4
let postdatastr = self.encodeURI(postdata)
else
let postdatastr = postdata
endif
let file = tempname()
if executable('curl')
let command = printf('curl -q %s -s -k -i -X %s', (follow ? '-L' : ''), len(method) ? method : 'POST')
let quote = &shellxquote ==# '"' ? "'" : '"'
for key in keys(headdata)
if has('win32')
let command .= ' -H ' . quote . key . ': ' . substitute(headdata[key], '"', '"""', 'g') . quote
else
let command .= ' -H ' . quote . key . ': ' . headdata[key] . quote
endif
endfor
let command .= ' ' . quote . url . quote
call writefile(split(postdatastr, "\n"), file, 'b')
let res = s:system(command . ' --data-binary @' . quote.file.quote)
elseif executable('wget')
let command = printf('wget -O- --save-headers --server-response -q %s', follow ? '-L' : '')
let headdata['X-HTTP-Method-Override'] = method
let quote = &shellxquote ==# '"' ? "'" : '"'
for key in keys(headdata)
if has('win32')
let command .= ' --header=' . quote . key . ': ' . substitute(headdata[key], '"', '"""', 'g') . quote
else
let command .= ' --header=' . quote . key . ': ' . headdata[key] . quote
endif
endfor
let command .= ' '.quote.url.quote
call writefile(split(postdatastr, "\n"), file, 'b')
let res = s:system(command . ' --post-data @' . quote.file.quote)
else
throw 'require `curl` or `wget` command'
endif
call delete(file)
if follow != 0
let mx = 'HTTP/\%(1\.[01]\|2\%(\.0\)\?\)'
while res =~# '^' . mx . ' 3' || res =~# '^' . mx . ' [0-9]\{3} .\+\n\r\?\n' . mx . ' .\+'
let pos = stridx(res, "\r\n\r\n")
if pos != -1
let res = strpart(res, pos+4)
else
let pos = stridx(res, "\n\n")
let res = strpart(res, pos+2)
endif
endwhile
endif
let pos = stridx(res, "\r\n\r\n")
if pos != -1
let content = strpart(res, pos+4)
else
let pos = stridx(res, "\n\n")
let content = strpart(res, pos+2)
endif
let header = split(res[:pos-1], '\r\?\n')
let matched = matchlist(get(header, 0), '^HTTP/\%(1\.[01]\|2\%(\.0\)\?\)\s\+\(\d\+\)\s*\(.*\)')
if !empty(matched)
let [status, message] = matched[1 : 2]
call remove(header, 0)
else
if v:shell_error || len(matched)
let [status, message] = ['500', "Couldn't connect to host"]
else
let [status, message] = ['200', 'OK']
endif
endif
return {
\ 'status' : status,
\ 'message' : message,
\ 'header' : header,
\ 'content' : content
\}
endfunction
function! s:self.send(req) abort
let postdata = get(a:req, 'data', '')
let method = get(a:req, 'method', postdata ==# '' ? 'GET': 'POST')
let headdata = get(a:req, 'header', {})
let follow = get(a:req, 'follow', 1)
let url = get(a:req, 'url', '')
if type(postdata) == 4
let postdatastr = self.encodeURI(postdata)
else
let postdatastr = postdata
endif
if empty(postdatastr)
let file = ''
else
let file = tempname()
endif
if executable('curl')
let command = printf('curl -q %s -s -k -i -X %s', (follow ? '-L' : ''), len(method) ? method : 'POST')
let quote = &shellxquote ==# '"' ? "'" : '"'
for key in keys(headdata)
if has('win32')
let command .= ' -H ' . quote . key . ': ' . substitute(headdata[key], '"', '"""', 'g') . quote
else
let command .= ' -H ' . quote . key . ': ' . headdata[key] . quote
endif
endfor
let command .= ' ' . quote . url . quote
if file ==# ''
let res = s:system(command)
else
call writefile(split(postdatastr, "\n"), file, 'b')
let res = s:system(command . ' --data-binary @' . quote.file.quote)
call delete(file)
endif
elseif executable('wget')
let command = printf('wget -O- --save-headers --server-response -q %s', follow ? '-L' : '')
let headdata['X-HTTP-Method-Override'] = method
let quote = &shellxquote ==# '"' ? "'" : '"'
for key in keys(headdata)
if has('win32')
let command .= ' --header=' . quote . key . ': ' . substitute(headdata[key], '"', '"""', 'g') . quote
else
let command .= ' --header=' . quote . key . ': ' . headdata[key] . quote
endif
endfor
let command .= ' '.quote.url.quote
if file ==# ''
let res = s:system(command)
else
call writefile(split(postdatastr, "\n"), file, 'b')
let res = s:system(command . ' --post-data @' . quote.file.quote)
call delete(file)
endif
else
throw 'require `curl` or `wget` command'
endif
if follow != 0
let mx = 'HTTP/\%(1\.[01]\|2\%(\.0\)\?\)'
while res =~# '^' . mx . ' 3' || res =~# '^' . mx . ' [0-9]\{3} .\+\n\r\?\n' . mx . ' .\+'
let pos = stridx(res, "\r\n\r\n")
if pos != -1
let res = strpart(res, pos+4)
else
let pos = stridx(res, "\n\n")
let res = strpart(res, pos+2)
endif
endwhile
endif
let pos = stridx(res, "\r\n\r\n")
if pos != -1
let content = strpart(res, pos+4)
else
let pos = stridx(res, "\n\n")
let content = strpart(res, pos+2)
endif
let header = split(res[:pos-1], '\r\?\n')
let matched = matchlist(get(header, 0), '^HTTP/\%(1\.[01]\|2\%(\.0\)\?\)\s\+\(\d\+\)\s*\(.*\)')
if !empty(matched)
let [status, message] = matched[1 : 2]
call remove(header, 0)
else
if v:shell_error || len(matched)
let [status, message] = ['500', "Couldn't connect to host"]
else
let [status, message] = ['200', 'OK']
endif
endif
return {
\ 'status' : status,
\ 'message' : message,
\ 'header' : header,
\ 'content' : content
\}
endfunction
function! s:self.stream(req) abort
let postdata = get(a:req, 'data', '')
let method = get(a:req, 'method', postdata ==# '' ? 'GET': 'POST')
let headdata = get(a:req, 'header', {})
let follow = get(a:req, 'follow', 1)
let url = get(a:req, 'url', '')
let mode = get(a:req, 'mode', 'nl')
if type(postdata) == 4
let postdatastr = self.encodeURI(postdata)
else
let postdatastr = postdata
endif
if empty(postdatastr)
let file = ''
else
let file = tempname()
endif
if executable('curl')
let command = printf('curl -q %s -s -k -X %s', (follow ? '-L' : ''), len(method) ? method : 'POST')
let quote = &shellxquote ==# '"' ? "'" : '"'
for key in keys(headdata)
if has('win32')
let command .= ' -H ' . quote . key . ': ' . substitute(headdata[key], '"', '"""', 'g') . quote
else
let command .= ' -H ' . quote . key . ': ' . headdata[key] . quote
endif
endfor
let command .= ' '.quote . url . quote
if file ==# ''
let job = job_start(command)
else
call writefile(split(postdatastr, "\n"), file, 'b')
let job = job_start(command . ' --data-binary @' . quote.file.quote)
call delete(file)
endif
elseif executable('wget')
let command = printf('wget -O- -q %s', follow ? '-L' : '')
let headdata['X-HTTP-Method-Override'] = method
let quote = &shellxquote ==# '"' ? "'" : '"'
for key in keys(headdata)
if has('win32')
let command .= ' --header=' . quote . key . ': ' . substitute(headdata[key], '"', '"""', 'g') . quote
else
let command .= ' --header=' . quote . key . ': ' . headdata[key] . quote
endif
endfor
let command .= ' '.quote.url.quote
if file ==# ''
let job = job_start(command)
else
call writefile(split(postdatastr, "\n"), file, 'b')
let job = job_start(command . ' --post-data @' . quote.file.quote)
call delete(file)
endif
else
throw 'require `curl` or `wget` command'
endif
call job_setoptions(job,
\{
\ 'exit_cb': function('webapi#http#exit_cb', [a:req]),
\ 'stoponexit': 'kill',
\})
let a:req['job'] = job
let channel = job_getchannel(job)
call ch_setoptions(channel,
\{
\ 'out_cb': function('webapi#http#out_cb', [a:req]),
\ 'mode': mode,
\})
let a:req['channel'] = channel
let a:req['file'] = file
endfunction
" @vimlint(EVL103, 1, a:job)
function! s:self.exit_cb(req, job, code) abort
let file = get(a:req, 'file')
if file !=# ''
call delete(file)
endif
let fexit_cb = get(a:req, 'exit_cb', v:none)
if fexit_cb != v:none
call call(fexit_cb, [a:code])
endif
endfunction
" @vimlint(EVL103, 0, a:job)
" @vimlint(EVL103, 1, a:ch)
function! s:self.out_cb(req, ch, data) abort
let fout_cb = get(a:req, 'out_cb', v:none)
if fout_cb != v:none
call Fout_cb(a:data)
call call(fout_cb, [a:data])
endif
endfunction
" @vimlint(EVL103, 0, a:ch)
function! SpaceVim#api#web#http#get() abort
return deepcopy(s:self)
endfunction
let &cpo = s:save_cpo
unlet s:save_cpo
" vim:set et:

View File

@ -0,0 +1,328 @@
let s:save_cpo = &cpo
set cpo&vim
let s:self = {}
let s:HTTP = SpaceVim#api#import('web#http')
let s:template = { 'name': '', 'attr': {}, 'child': [] }
function! s:nr2byte(nr) abort
if a:nr < 0x80
return nr2char(a:nr)
elseif a:nr < 0x800
return nr2char(a:nr/64+192).nr2char(a:nr%64+128)
else
return nr2char(a:nr/4096%16+224).nr2char(a:nr/64%64+128).nr2char(a:nr%64+128)
endif
endfunction
function! s:nr2enc_char(charcode) abort
if &encoding ==# 'utf-8'
return nr2char(a:charcode)
endif
let char = s:nr2byte(a:charcode)
if strlen(char) > 1
let char = strtrans(iconv(char, 'utf-8', &encoding))
endif
return char
endfunction
function! s:nr2hex(nr) abort
let n = a:nr
let r = ''
while n
let r = '0123456789ABCDEF'[n % 16] . r
let n = n / 16
endwhile
return r
endfunction
function! s:decodeEntityReference(str, ...) abort
let str = a:str
let str = substitute(str, '&gt;', '>', 'g')
let str = substitute(str, '&lt;', '<', 'g')
if get(g:, 'webapi#xml#decodeAsHTML', 0)
let str = substitute(str, '&quot;', '"', 'g')
let str = substitute(str, '&apos;', "'", 'g')
let str = substitute(str, '&nbsp;', ' ', 'g')
let str = substitute(str, '&yen;', '\&#65509;', 'g')
endif
let str = substitute(str, '&#x\([0-9a-fA-F]\+\);', '\=s:nr2enc_char("0x".submatch(1))', 'g')
let str = substitute(str, '&#\(\d\+\);', '\=s:nr2enc_char(submatch(1))', 'g')
let str = substitute(str, '&amp;', '\&', 'g')
return str
endfunction
function! s:encodeEntityReference(str) abort
let str = a:str
let str = substitute(str, '&', '\&amp;', 'g')
let str = substitute(str, '>', '\&gt;', 'g')
let str = substitute(str, '<', '\&lt;', 'g')
let str = substitute(str, '"', '\&#34;', 'g')
"let str = substitute(str, "\n", '\&#x0d;', 'g')
"let str = substitute(str, '"', '&quot;', 'g')
"let str = substitute(str, "'", '&apos;', 'g')
"let str = substitute(str, ' ', '&nbsp;', 'g')
return str
endfunction
function! s:matchNode(node, cond) abort
if type(a:cond) == 1 && a:node.name == a:cond
return 1
endif
if type(a:cond) == 2
return a:cond(a:node)
endif
if type(a:cond) == 3
let ret = 1
for l:R in a:cond
if !s:matchNode(a:node, l:R) | let ret = 0 | endif
unlet l:R
endfor
return ret
endif
if type(a:cond) == 4
for k in keys(a:cond)
if has_key(a:node.attr, k) && a:node.attr[k] == a:cond[k] | return 1 | endif
endfor
endif
return 0
endfunction
function! s:template.childNode(...) dict abort
for c in self.child
if type(c) == 4 && s:matchNode(c, a:000)
return c
endif
unlet c
endfor
return {}
endfunction
function! s:template.childNodes(...) dict abort
let ret = []
for c in self.child
if type(c) == 4 && s:matchNode(c, a:000)
let ret += [c]
endif
unlet c
endfor
return ret
endfunction
function! s:template.value(...) dict abort
if a:0
let self.child = a:000
return
endif
let ret = ''
for c in self.child
if type(c) <= 1 || type(c) == 5
let ret .= c
elseif type(c) == 4
let ret .= c.value()
endif
unlet c
endfor
return ret
endfunction
function! s:template.find(...) dict abort
for c in self.child
if type(c) == 4
if s:matchNode(c, a:000)
return c
endif
unlet! ret
let ret = c.find(a:000)
if !empty(ret)
return ret
endif
endif
unlet c
endfor
return {}
endfunction
function! s:template.findAll(...) dict abort
let ret = []
for c in self.child
if type(c) == 4
if s:matchNode(c, a:000)
call add(ret, c)
endif
let ret += c.findAll(a:000)
endif
unlet c
endfor
return ret
endfunction
function! s:template.toString() dict abort
let xml = '<' . self.name
for attr in keys(self.attr)
let xml .= ' ' . attr . '="' . s:encodeEntityReference(self.attr[attr]) . '"'
endfor
if len(self.child)
let xml .= '>'
for c in self.child
if type(c) == 4
let xml .= c.toString()
elseif type(c) > 1
let xml .= s:encodeEntityReference(string(c))
else
let xml .= s:encodeEntityReference(c)
endif
unlet c
endfor
let xml .= '</' . self.name . '>'
else
let xml .= ' />'
endif
return xml
endfunction
function! s:self.createElement(name) abort
let node = deepcopy(s:template)
let node.name = a:name
return node
endfunction
" @vimlint(EVL102, 1, l:content)
function! s:parse_tree(ctx, top) abort
let node = a:top
let stack = [a:top]
" content accumulates the text only tags
let content = ''
let append_content_to_parent = 'if len(stack) && content != "" | call add(stack[-1].child, content) | let content ="" | endif'
let mx = '^\s*\(<?xml[^>]\+>\)'
if a:ctx['xml'] =~ mx
let match = matchstr(a:ctx['xml'], mx)
let a:ctx['xml'] = a:ctx['xml'][stridx(a:ctx['xml'], match) + len(match):]
let mx = 'encoding\s*=\s*["'']\{0,1}\([^"'' \t]\+\|[^"'']\+\)["'']\{0,1}'
let matches = matchlist(match, mx)
if len(matches)
let encoding = matches[1]
if len(encoding) && len(a:ctx['encoding']) == 0
let a:ctx['encoding'] = encoding
let a:ctx['xml'] = iconv(a:ctx['xml'], encoding, &encoding)
endif
endif
endif
" this regex matches
" 1) the remaining until the next tag begins
" 2) maybe closing "/" of tag name
" 3) tagname
" 4) the attributes of the text (optional)
" 5) maybe closing "/" (end of tag name)
" or
" 6) CDATA or ''
" 7) text content of CDATA
" 8) the remaining text after the tag (rest)
" (These numbers correspond to the indexes in matched list m)
let tag_mx = '^\(\_.\{-}\)\%(\%(<\(/\?\)\([^!/>[:space:]]\+\)\(\%([[:space:]]*[^/>=[:space:]]\+[[:space:]]*=[[:space:]]*\%([^"'' >\t]\+\|"[^"]*"\|''[^'']*''\)\|[[:space:]]\+[^/>=[:space:]]\+[[:space:]]*\)*\)[[:space:]]*\(/\?\)>\)\|\%(<!\[\(CDATA\)\[\(.\{-}\)\]\]>\)\|\(<!--.\{-}-->\)\)'
while len(a:ctx['xml']) > 0
let m = matchlist(a:ctx.xml, tag_mx)
if empty(m) | break | endif
let a:ctx.xml = a:ctx.xml[len(m[0]) :]
let is_end_tag = m[2] ==# '/' && m[5] ==# ''
let is_start_and_end_tag = m[2] ==# '' && m[5] ==# '/'
let tag_name = m[3]
let attrs = m[4]
if len(m[1])
let content .= s:decodeEntityReference(m[1])
endif
if is_end_tag
" closing tag: pop from stack and continue at upper level
exec append_content_to_parent
if len(stack) " TODO: checking whether opened tag is exist.
call remove(stack, -1)
endif
continue
endif
" comment tag
if m[8] !=# ''
continue
endif
" if element is a CDATA
if m[6] !=# ''
let content .= m[7]
continue
endif
let node = deepcopy(s:template)
let node.name = tag_name
let attr_mx = '\([^=[:space:]]\+\)\s*\%(=\s*''\([^'']*\)''\|=\s*"\([^"]*\)"\|=\s*\(\w\+\)\|\)'
while len(attrs) > 0
let attr_match = matchlist(attrs, attr_mx)
if len(attr_match) == 0
break
endif
let name = attr_match[1]
let value = len(attr_match[2]) ? attr_match[2] : len(attr_match[3]) ? attr_match[3] : len(attr_match[4]) ? attr_match[4] : ''
if value ==# ''
let value = name
endif
let node.attr[name] = s:decodeEntityReference(value)
let attrs = attrs[stridx(attrs, attr_match[0]) + len(attr_match[0]):]
endwhile
exec append_content_to_parent
if len(stack)
call add(stack[-1].child, node)
endif
if !is_start_and_end_tag
" opening tag, continue parsing its contents
call add(stack, node)
endif
endwhile
endfunction
" @vimlint(EVL102, 0, l:content)
function! s:self.parse(xml) abort
let top = deepcopy(s:template)
let oldmaxmempattern=&maxmempattern
let oldmaxfuncdepth=&maxfuncdepth
let &maxmempattern=2000000
let &maxfuncdepth=2000
"try
call s:parse_tree({'xml': a:xml, 'encoding': ''}, top)
for node in top.child
if type(node) == 4
return node
endif
unlet node
endfor
"catch /.*/
"endtry
let &maxmempattern=oldmaxmempattern
let &maxfuncdepth=oldmaxfuncdepth
throw 'Parse Error'
endfunction
function! s:self.parseFile(file) abort
return self.parse(join(readfile(a:file), "\n"))
endfunction
function! s:self.parseURL(url) abort
return self.parse(s:HTTP.get(a:url).content)
endfunction
function! SpaceVim#api#web#xml#get() abort
return deepcopy(s:self)
endfunction
let &cpo = s:save_cpo
unlet s:save_cpo
" vim:set et sw=2 cc=80:

View File

@ -65,7 +65,9 @@ function! SpaceVim#autocmds#init() abort
" Instead of reverting the cursor to the last position in the buffer, we
" set it to the first line when editing a git commit message
au FileType gitcommit au! BufEnter COMMIT_EDITMSG call setpos('.', [0, 1, 1, 0])
au StdinReadPost * call s:disable_welcome()
autocmd InsertEnter * call s:fixindentline()
autocmd BufEnter,FileType * call SpaceVim#mapping#space#refrashLSPC()
if executable('synclient') && g:spacevim_auto_disable_touchpad
let s:touchpadoff = 0
autocmd InsertEnter * call s:disable_touchpad()
@ -138,5 +140,11 @@ function! SpaceVim#autocmds#VimEnter() abort
endif
endfunction
function! s:disable_welcome() abort
augroup SPwelcome
au!
augroup END
endfunction
" vim:set et sw=2:

View File

@ -107,6 +107,10 @@ function! SpaceVim#default#SetOptions() abort
set ttimeout
set ttimeoutlen=50
set lazyredraw
if has('patch-7.4.314')
" don't give ins-completion-menu messages.
set shortmess+=c
endif
endfunction
function! SpaceVim#default#SetPlugins() abort

View File

@ -5,14 +5,18 @@
""
" Load the {layer} you want. For all the layers SpaceVim supports, see @section(layers).
" the second argv is the layer variable.
function! SpaceVim#layers#load(layer, ...) abort
if a:layer == '-l'
call s:list_layers()
endif
if index(g:spacevim_plugin_groups, a:layer) == -1
call add(g:spacevim_plugin_groups, a:layer)
if a:0 == 1 && type(a:1) == 4
call SpaceVim#layers#{a:layer}#set_variable(a:1)
endif
endif
if a:0 > 1
if a:0 > 0 && type(a:1) == 1
for l in a:000
call SpaceVim#layers#load(l)
endfor

View File

@ -17,7 +17,6 @@ endfunction
function! SpaceVim#layers#checkers#config() abort
call SpaceVim#mapping#space#def('nnoremap', ['e', '.'], 'lopen', 'error-transient-state', 1)
call SpaceVim#mapping#space#def('nnoremap', ['e', 'c'], 'sign unplace *', 'clear all errors', 1)
call SpaceVim#mapping#space#def('nnoremap', ['e', 'h'], '', 'describe a syntax checker', 1)
call SpaceVim#mapping#space#def('nnoremap', ['e', 'v'], '', 'verify syntax checker setup', 1)
@ -25,4 +24,62 @@ function! SpaceVim#layers#checkers#config() abort
call SpaceVim#mapping#space#def('nnoremap', ['e', 'l'], 'lopen', 'toggle showing the error list', 1)
call SpaceVim#mapping#space#def('nnoremap', ['e', 'p'], 'lprevious', 'previous-error', 1)
call SpaceVim#mapping#space#def('nnoremap', ['e', 'N'], 'lNext', 'previous-error', 1)
call SpaceVim#mapping#space#def('nnoremap', ['e', '.'], 'call call('
\ . string(s:_function('s:error_transient_state')) . ', [])',
\ 'error-transient-state', 1)
endfunction
function! s:error_transient_state() abort
if empty(neomake#statusline#LoclistCounts())
echo 'no buffers contain error message locations'
return
endif
let state = SpaceVim#api#import('transient_state')
call state.set_title('Error Transient State')
call state.defind_keys(
\ {
\ 'layout' : 'vertical split',
\ 'left' : [
\ {
\ 'key' : 'n',
\ 'desc' : 'next error',
\ 'func' : '',
\ 'cmd' : 'try | lnext | catch | endtry',
\ 'exit' : 0,
\ },
\ ],
\ 'right' : [
\ {
\ 'key' : ['p', 'N'],
\ 'desc' : 'previous error',
\ 'func' : '',
\ 'cmd' : 'try | lprevious | catch | endtry',
\ 'exit' : 0,
\ },
\ {
\ 'key' : 'q',
\ 'desc' : 'quit',
\ 'func' : '',
\ 'cmd' : '',
\ '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('<sfile>'), '<SNR>\zs\d\+\ze__SID$')
endfunction
let s:_s = '<SNR>' . s:_SID() . '_'
function! s:_function(fstr) abort
return function(substitute(a:fstr, 's:', s:_s, 'g'))
endfunction
endif

View File

@ -25,6 +25,11 @@ let s:separators = {
\ 'fire' : ["\ue0c0", "\ue0c2"],
\ 'nil' : ['', ''],
\ }
let s:i_separators = {
\ 'arrow' : ["\ue0b1", "\ue0b3"],
\ 'bar' : ["|", "|"],
\ 'nil' : ['', ''],
\ }
let s:loaded_modes = ['syntax-checking']
let s:modes = {
\ 'center-cursor': {
@ -187,33 +192,36 @@ endfunction
function! SpaceVim#layers#core#statusline#get(...) abort
if &filetype ==# 'vimfiler'
return '%#SpaceVim_statusline_ia#' . s:winnr(1) . '%#SpaceVim_statusline_ia_SpaceVim_statusline_b#'
\ . '%#SpaceVim_statusline_b# vimfiler %#SpaceVim_statusline_b_SpaceVim_statusline_c#'
elseif &filetype ==# 'tagbar'
return '%#SpaceVim_statusline_ia# ' . s:winnr(1) . ' %#SpaceVim_statusline_a_b#'
\ . '%#SpaceVim_statusline_b# tagbar %#SpaceVim_statusline_b_c#'
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
elseif &filetype ==# 'startify'
call fugitive#detect(getcwd())
elseif &filetype ==# 'SpaceVimLayerManager'
return '%#SpaceVim_statusline_a#' . s:winnr(1) . '%#SpaceVim_statusline_a_SpaceVim_statusline_b#'
\ . '%#SpaceVim_statusline_b# LayerManager %#SpaceVim_statusline_b_SpaceVim_statusline_c#'
return '%#SpaceVim_statusline_a#' . s:winnr(1) . '%#SpaceVim_statusline_a_SpaceVim_statusline_b#' . s:lsep
\ . '%#SpaceVim_statusline_b# LayerManager %#SpaceVim_statusline_b_SpaceVim_statusline_c#' . s:lsep
elseif &filetype ==# 'SpaceVimPlugManager'
return '%#SpaceVim_statusline_a#' . s:winnr(1) . '%#SpaceVim_statusline_a_SpaceVim_statusline_b#'
\ . '%#SpaceVim_statusline_b# PlugManager %#SpaceVim_statusline_b_SpaceVim_statusline_c#'
return '%#SpaceVim_statusline_a#' . s:winnr(1) . '%#SpaceVim_statusline_a_SpaceVim_statusline_b#' . s:lsep
\ . '%#SpaceVim_statusline_b# PlugManager %#SpaceVim_statusline_b_SpaceVim_statusline_c#' . s:lsep
elseif &filetype ==# 'SpaceVimTabsManager'
return '%#SpaceVim_statusline_a#' . s:winnr(1) . '%#SpaceVim_statusline_a_SpaceVim_statusline_b#'
\ . '%#SpaceVim_statusline_b# TabsManager %#SpaceVim_statusline_b_SpaceVim_statusline_c#'
return '%#SpaceVim_statusline_a#' . s:winnr(1) . '%#SpaceVim_statusline_a_SpaceVim_statusline_b#' . s:lsep
\ . '%#SpaceVim_statusline_b# TabsManager %#SpaceVim_statusline_b_SpaceVim_statusline_c#' . s:lsep
elseif &filetype ==# 'denite'
return '%#SpaceVim_statusline_a_bold# %{SpaceVim#layers#core#statusline#denite_mode()} '
\ . '%#SpaceVim_statusline_a_bold_SpaceVim_statusline_b# '
\ . '%#SpaceVim_statusline_b#%{denite#get_status_sources()} %#SpaceVim_statusline_b_SpaceVim_statusline_z# '
\ . '%#SpaceVim_statusline_z#%=%#SpaceVim_statusline_c_SpaceVim_statusline_z#'
\ . '%#SpaceVim_statusline_a_bold_SpaceVim_statusline_b#' . s:lsep . ' '
\ . '%#SpaceVim_statusline_b#%{denite#get_status_sources()} %#SpaceVim_statusline_b_SpaceVim_statusline_z#' . s:lsep . ' '
\ . '%#SpaceVim_statusline_z#%=%#SpaceVim_statusline_c_SpaceVim_statusline_z#' . s:rsep
\ . '%#SpaceVim_statusline_c# %{denite#get_status_path() . denite#get_status_linenr()}'
elseif &filetype ==# 'unite'
return '%#SpaceVim_statusline_a_bold#%{SpaceVim#layers#core#statusline#unite_mode()} Unite '
\ . '%#SpaceVim_statusline_a_bold_SpaceVim_statusline_b# %{get(unite#get_context(), "buffer_name", "")} '
\ . '%#SpaceVim_statusline_b_SpaceVim_statusline_c# '
\ . '%#SpaceVim_statusline_a_bold_SpaceVim_statusline_b#' . s:lsep . ' %{get(unite#get_context(), "buffer_name", "")} '
\ . '%#SpaceVim_statusline_b_SpaceVim_statusline_c#' . s:lsep . ' '
\ . '%#SpaceVim_statusline_c# %{unite#get_status_string()} '
elseif &filetype ==# 'SpaceVimFlyGrep'
return '%#SpaceVim_statusline_a# FlyGrep %#SpaceVim_statusline_a_SpaceVim_statusline_b#' . s:lsep
\ . '%#SpaceVim_statusline_b# %{getcwd()}%#SpaceVim_statusline_b_SpaceVim_statusline_c#' . s:lsep
\ . '%#SpaceVim_statusline_c# %{SpaceVim#plugins#flygrep#lineNr()}'
elseif &filetype ==# 'TransientState'
return '%#SpaceVim_statusline_a# Transient State %#SpaceVim_statusline_a_SpaceVim_statusline_b#'
endif
if a:0 > 0
return s:active()
@ -262,14 +270,14 @@ function! s:active() abort
endfunction
function! s:inactive() abort
return '%#SpaceVim_statusline_ia#' . s:winnr() . '%#SpaceVim_statusline_ia_SpaceVim_statusline_b#'
\ . '%#SpaceVim_statusline_b#' . s:filename() . ''
\ . ' ' . &filetype . ' '
\ . s:modes() . ''
\ . s:git_branch() . ''
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
\ . ' %='
\ . '%{" " . &ff . "|" . (&fenc!=""?&fenc:&enc) . " "}'
\ . ' %P '
\ . s:irsep . '%{" " . &ff . "|" . (&fenc!=""?&fenc:&enc) . " "}'
\ . s:irsep . ' %P '
endfunction
function! s:gitgutter() abort
if exists('b:gitgutter_summary')
@ -335,12 +343,13 @@ function! SpaceVim#layers#core#statusline#toggle_section(name) abort
let &l:statusline = SpaceVim#layers#core#statusline#get(1)
endfunction
function! Test() abort
echo s:loaded_modes
function! SpaceVim#layers#core#statusline#rsep()
return get(s:separators, g:spacevim_statusline_separator, s:separators['arrow'])
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")',
@ -379,7 +388,7 @@ function! SpaceVim#layers#core#statusline#mode(mode)
exe 'hi! SpaceVim_statusline_a ctermbg=' . t[4][3] . ' ctermfg=' . t[4][2] . ' guibg=' . t[4][1] . ' guifg=' . t[4][0]
elseif a:mode == 'R'
exe 'hi! SpaceVim_statusline_a ctermbg=' . t[6][3] . ' ctermfg=' . t[6][2] . ' guibg=' . t[6][1] . ' guifg=' . t[6][0]
elseif a:mode == 'v' || a:mode == 'V' || a:mode == '^V'
elseif a:mode == 'v' || a:mode == 'V' || a:mode == '^V' || a:mode == 's' || a:mode == 'S' || a:mode == '^S'
exe 'hi! SpaceVim_statusline_a ctermbg=' . t[5][3] . ' ctermfg=' . t[5][2] . ' guibg=' . t[5][1] . ' guifg=' . t[5][0]
endif
call s:HI.hi_separator('SpaceVim_statusline_a', 'SpaceVim_statusline_b')

View File

@ -20,6 +20,22 @@ let s:HI = SpaceVim#api#import('vim#highlight')
let g:_spacevim_tabline_loaded = 1
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' : ['', ''],
\ }
let s:i_separators = {
\ '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)
@ -77,14 +93,14 @@ function! SpaceVim#layers#core#tabline#get() abort
endif
let t .= id . ' ' . name
if i == ct - 1
let t .= ' %#SpaceVim_tabline_b_SpaceVim_tabline_a# '
let t .= ' %#SpaceVim_tabline_b_SpaceVim_tabline_a#' . s:lsep . ' '
elseif i == ct
let t .= ' %#SpaceVim_tabline_a_SpaceVim_tabline_b# '
let t .= ' %#SpaceVim_tabline_a_SpaceVim_tabline_b#' . s:lsep . ' '
else
let t .= ' '
let t .= ' ' . s:ilsep . ' '
endif
endfor
let t .= '%=%#SpaceVim_tabline_a_SpaceVim_tabline_b#'
let t .= '%=%#SpaceVim_tabline_a_SpaceVim_tabline_b#' . s:rsep
let t .= '%#SpaceVim_tabline_a# Tabs'
else
let s:buffers = s:BUFFER.listed_buffers()
@ -122,19 +138,21 @@ function! SpaceVim#layers#core#tabline#get() abort
endif
let t .= id . ' ' . name
if i == ct
let t .= ' %#SpaceVim_tabline_a_SpaceVim_tabline_b# '
let t .= ' %#SpaceVim_tabline_a_SpaceVim_tabline_b#' . s:lsep . ' '
elseif i == pt
let t .= ' %#SpaceVim_tabline_b_SpaceVim_tabline_a# '
let t .= ' %#SpaceVim_tabline_b_SpaceVim_tabline_a#' . s:lsep . ' '
else
let t .= ' '
let t .= ' ' . s:ilsep . ' '
endif
endfor
let t .= '%=%#SpaceVim_tabline_a_SpaceVim_tabline_b#'
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!

View File

@ -93,6 +93,9 @@ function! SpaceVim#layers#default#config() abort
\ . string(s:_function('s:jump_to_url')) . ', [])',
\ 'jump to url', 1)
call SpaceVim#mapping#space#def('nnoremap', ['<Tab>'], '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()',
@ -285,3 +288,132 @@ function! s:delete_current_buffer_file() abort
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
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
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' : [
\ ["\<C-1>" , ''],
\ ["\<C-2>" , ''],
\ ["\<C-3>" , ''],
\ ["\<C-4>" , ''],
\ ["\<C-5>" , ''],
\ ["\<C-6>" , ''],
\ ["\<C-7>" , ''],
\ ["\<C-8>" , ''],
\ ["\<C-9>" , ''],
\ ],
\ },
\ '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' : [
\ ["\<M-1>" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [1])'],
\ ["\<M-2>" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [2])'],
\ ["\<M-3>" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [3])'],
\ ["\<M-4>" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [4])'],
\ ["\<M-5>" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [5])'],
\ ["\<M-6>" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [6])'],
\ ["\<M-7>" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [7])'],
\ ["\<M-8>" , 'call call(' . string(s:_function('s:swap_buffer_with_nth_win')) . ', [8])'],
\ ["\<M-9>" , '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

View File

@ -1,8 +1,8 @@
scriptencoding utf-8
let s:PASSWORD = SpaceVim#api#import('password')
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'],
@ -28,12 +28,12 @@ function! SpaceVim#layers#edit#plugins() abort
endfunction
function! SpaceVim#layers#edit#config() abort
let g:multi_cursor_next_key='<C-j>'
let g:multi_cursor_prev_key='<C-k>'
let g:multi_cursor_skip_key='<C-x>'
let g:multi_cursor_quit_key='<Esc>'
let g:multi_cursor_next_key=get(g:, 'multi_cursor_next_key', '<C-j>')
let g:multi_cursor_prev_key=get(g:, 'multi_cursor_prev_key', '<C-k>')
let g:multi_cursor_skip_key=get(g:, 'multi_cursor_skip_key', '<C-x>')
let g:multi_cursor_quit_key=get(g:, 'multi_cursor_quit_key', '<Esc>')
let g:user_emmet_install_global = 0
let g:user_emmet_leader_key='<C-e>'
let g:user_emmet_leader_key=get(g:, 'user_emmet_leader_key', '<C-e>')
let g:user_emmet_mode='a'
let g:user_emmet_settings = {
\ 'jsp' : {
@ -43,6 +43,53 @@ function! SpaceVim#layers#edit#config() abort
"noremap <SPACE> <Plug>(wildfire-fuel)
vnoremap <C-SPACE> <Plug>(wildfire-water)
let g:wildfire_objects = ["i'", 'i"', 'i)', 'i]', 'i}', 'ip', 'it']
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 <silent> <Plug>CountSelectionRegion :call <SID>count_selection_region()<Cr>
xnoremap <silent> <Plug>CountSelectionRegion :<C-u>call <SID>count_selection_region()<Cr>
call SpaceVim#mapping#space#def('nmap', ['x', 'c'], '<Plug>CountSelectionRegion', 'cunt 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'}
@ -75,6 +122,221 @@ function! SpaceVim#layers#edit#config() abort
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)
" 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
endif
endfunction
function! s:move_text_down_transient_state() abort
normal! ddp
call s:text_transient_state()
endfunction
function! s:move_text_up_transient_state() abort
normal! ddkP
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()
endfunction
function! s:lowerCamelCase() abort
" fooFzz
let cword = s:parse_symbol(expand('<cword>'))
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('<cword>'))
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('<cword>'))
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('<cword>'))
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('<cword>')), '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
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\<c-g>\<Esc>", 'ti')
endfunction
function! s:delete_extra_space() abort
if !empty(getline('.'))
if getline('.')[col('.')-1] ==# ' '
exe "normal! viw\"_di\<Space>\<Esc>"
endif
endif
endfunction
let s:local_lorem_ipsum = [
\ 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit.',
@ -218,3 +480,18 @@ else
return function(substitute(a:fstr, 's:', s:_s, 'g'))
endfunction
endif
augroup spacevim_layer_edit
au!
autocmd BufNewFile *.py call <SID>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
endfunction
function! SpaceVim#layers#edit#add_ft_head_tamplate(ft, tamp)
call extend(s:ft_head_tp, {a:ft : a:tamp})
endfunction

View File

@ -67,10 +67,18 @@ endfunction
let s:si_flag = 0
function! s:update_search_index(key) abort
if a:key == 'n'
normal! n
if mapcheck("<Plug>(incsearch-nohl-n)") !=# ''
call feedkeys("\<Plug>(incsearch-nohl-n)")
else
normal! n
endif
normal! ml
elseif a:key == 'N'
normal! N
if mapcheck("<Plug>(incsearch-nohl-n)") !=# ''
call feedkeys("\<Plug>(incsearch-nohl-N)")
else
normal! N
endif
normal! ml
endif
if s:si_flag == 0

View File

@ -59,67 +59,94 @@ function! SpaceVim#layers#lang#java#plugins() abort
endfunction
function! SpaceVim#layers#lang#java#config() abort
function! s:java_mappings() abort
let g:_spacevim_mappings_space.l = {'name' : '+Language Specified'}
if g:spacevim_enable_insert_leader
inoremap <silent> <buffer> <leader>UU <esc>bgUwea
inoremap <silent> <buffer> <leader>uu <esc>bguwea
inoremap <silent> <buffer> <leader>ua <esc>bgulea
inoremap <silent> <buffer> <leader>Ua <esc>bgUlea
endif
nmap <silent><buffer> <F4> <Plug>(JavaComplete-Imports-Add)
imap <silent><buffer> <F4> <Plug>(JavaComplete-Imports-Add)
nmap <silent><buffer> <leader>jI <Plug>(JavaComplete-Imports-AddMissing)
nmap <silent><buffer> <leader>jR <Plug>(JavaComplete-Imports-RemoveUnused)
nmap <silent><buffer> <leader>ji <Plug>(JavaComplete-Imports-AddSmart)
nmap <silent><buffer> <leader>jii <Plug>(JavaComplete-Imports-Add)
imap <silent><buffer> <C-j>I <Plug>(JavaComplete-Imports-AddMissing)
imap <silent><buffer> <C-j>R <Plug>(JavaComplete-Imports-RemoveUnused)
imap <silent><buffer> <C-j>i <Plug>(JavaComplete-Imports-AddSmart)
imap <silent><buffer> <C-j>ii <Plug>(JavaComplete-Imports-Add)
nmap <silent><buffer> <leader>jM <Plug>(JavaComplete-Generate-AbstractMethods)
imap <silent><buffer> <C-j>jM <Plug>(JavaComplete-Generate-AbstractMethods)
call SpaceVim#mapping#space#langSPC('nmap', ['l','M'], '<Plug>(JavaComplete-Generate-AbstractMethods)', 'Generate abstract methods', 0)
nmap <silent><buffer> <leader>jA <Plug>(JavaComplete-Generate-Accessors)
nmap <silent><buffer> <leader>js <Plug>(JavaComplete-Generate-AccessorSetter)
nmap <silent><buffer> <leader>jg <Plug>(JavaComplete-Generate-AccessorGetter)
nmap <silent><buffer> <leader>ja <Plug>(JavaComplete-Generate-AccessorSetterGetter)
nmap <silent><buffer> <leader>jts <Plug>(JavaComplete-Generate-ToString)
nmap <silent><buffer> <leader>jeq <Plug>(JavaComplete-Generate-EqualsAndHashCode)
nmap <silent><buffer> <leader>jc <Plug>(JavaComplete-Generate-Constructor)
nmap <silent><buffer> <leader>jcc <Plug>(JavaComplete-Generate-DefaultConstructor)
imap <silent><buffer> <C-j>s <Plug>(JavaComplete-Generate-AccessorSetter)
imap <silent><buffer> <C-j>g <Plug>(JavaComplete-Generate-AccessorGetter)
imap <silent><buffer> <C-j>a <Plug>(JavaComplete-Generate-AccessorSetterGetter)
vmap <silent><buffer> <leader>js <Plug>(JavaComplete-Generate-AccessorSetter)
vmap <silent><buffer> <leader>jg <Plug>(JavaComplete-Generate-AccessorGetter)
vmap <silent><buffer> <leader>ja <Plug>(JavaComplete-Generate-AccessorSetterGetter)
let g:neoformat_enabled_java = ['googlefmt']
let g:neoformat_java_googlefmt = {
\ 'exe': 'java',
\ 'args': ['-jar', get(g:,'spacevim_layer_lang_java_formatter', '')],
\ 'replace': 0,
\ 'stdin': 0,
\ 'no_append': 0,
\ }
try
let g:neoformat_enabled_java += neoformat#formatters#java#enabled()
catch
endtry
endfunction
call SpaceVim#mapping#space#regesit_lang_mappings('java', funcref('s:language_specified_mappings'))
augroup SpaceVim_lang_java
au!
autocmd FileType java setlocal omnifunc=javacomplete#Complete
autocmd FileType java call s:java_mappings()
set tags +=~/others/openjdksrc/java/tags
set tags +=~/others/openjdksrc/javax/tags
augroup END
set tags +=~/others/openjdksrc/java/tags
set tags +=~/others/openjdksrc/javax/tags
let g:neoformat_enabled_java = ['googlefmt']
let g:neoformat_java_googlefmt = {
\ 'exe': 'java',
\ 'args': ['-jar', get(g:,'spacevim_layer_lang_java_formatter', '')],
\ 'replace': 0,
\ 'stdin': 0,
\ 'no_append': 0,
\ }
try
let g:neoformat_enabled_java += neoformat#formatters#java#enabled()
catch
endtry
endfunction
function! s:language_specified_mappings() abort
call SpaceVim#mapping#space#langSPC('nmap', ['l','M'], '<Plug>(JavaComplete-Generate-AbstractMethods)', 'Generate abstract methods', 0)
call SpaceVim#mapping#space#langSPC('nmap', ['l','I'], '<Plug>(JavaComplete-Imports-AddMissing)', 'Import missing classes', 0)
call SpaceVim#mapping#space#langSPC('nmap', ['l','R'], '<Plug>(JavaComplete-Imports-RemoveUnused)', 'Remove unused classes', 0)
call SpaceVim#mapping#space#langSPC('nmap', ['l','i'], '<Plug>(JavaComplete-Imports-AddSmart)', 'Smart import class under cursor', 0)
call SpaceVim#mapping#space#langSPC('nmap', ['l','s'], '<Plug>(JavaComplete-Generate-AccessorSetter)', 'generate setter accessor', 0)
call SpaceVim#mapping#space#langSPC('nmap', ['l','a'], '<Plug>(JavaComplete-Generate-AccessorSetterGetter)', 'generate setter and getter accessor', 0)
call SpaceVim#mapping#space#langSPC('nnoremap', ['l','a'], 'A', 'jump to alternate file', 1)
" execute
let g:_spacevim_mappings_space.l.r = {'name' : '+Run'}
" run main methon
call SpaceVim#mapping#space#langSPC('nmap', ['l','r', 'm'], 'JavaUnitTestMain', 'Run main method', 1)
call SpaceVim#mapping#space#langSPC('nmap', ['l','r', 'c'], 'JavaUnitExec', 'Run current method', 1)
call SpaceVim#mapping#space#langSPC('nmap', ['l','r', 'a'], 'JavaUnitTestAll', 'Run all test methods', 1)
" debug
let g:_spacevim_mappings_space.l.d = {'name' : '+Debug'}
" maven
let g:_spacevim_mappings_space.l.m = {'name' : '+Maven'}
call SpaceVim#mapping#space#langSPC('nnoremap', ['l','m', 'i'], 'call call('
\ . string(function('s:execCMD')) . ', ["mvn clean install"])',
\ 'Run maven clean install', 1)
call SpaceVim#mapping#space#langSPC('nnoremap', ['l','m', 'I'], 'call call('
\ . string(function('s:execCMD')) . ', ["mvn install"])',
\ 'Run maven install', 1)
call SpaceVim#mapping#space#langSPC('nnoremap', ['l','m', 't'], 'call call('
\ . string(function('s:execCMD')) . ', ["mvn test"])',
\ 'Run maven test', 1)
endfunction
function! s:java_mappings() abort
let g:_spacevim_mappings_space.l = {'name' : '+Language Specified'}
if g:spacevim_enable_insert_leader
inoremap <silent> <buffer> <leader>UU <esc>bgUwea
inoremap <silent> <buffer> <leader>uu <esc>bguwea
inoremap <silent> <buffer> <leader>ua <esc>bgulea
inoremap <silent> <buffer> <leader>Ua <esc>bgUlea
endif
nmap <silent><buffer> <F4> <Plug>(JavaComplete-Imports-Add)
imap <silent><buffer> <F4> <Plug>(JavaComplete-Imports-Add)
imap <silent><buffer> <C-j>I <Plug>(JavaComplete-Imports-AddMissing)
imap <silent><buffer> <C-j>R <Plug>(JavaComplete-Imports-RemoveUnused)
imap <silent><buffer> <C-j>i <Plug>(JavaComplete-Imports-AddSmart)
imap <silent><buffer> <C-j>s <Plug>(JavaComplete-Generate-AccessorSetter)
imap <silent><buffer> <C-j>g <Plug>(JavaComplete-Generate-AccessorGetter)
imap <silent><buffer> <C-j>a <Plug>(JavaComplete-Generate-AccessorSetterGetter)
imap <silent><buffer> <C-j>jM <Plug>(JavaComplete-Generate-AbstractMethods)
nmap <silent><buffer> <leader>jA <Plug>(JavaComplete-Generate-Accessors)
nmap <silent><buffer> <leader>jg <Plug>(JavaComplete-Generate-AccessorGetter)
nmap <silent><buffer> <leader>ja <Plug>(JavaComplete-Generate-AccessorSetterGetter)
nmap <silent><buffer> <leader>jts <Plug>(JavaComplete-Generate-ToString)
nmap <silent><buffer> <leader>jeq <Plug>(JavaComplete-Generate-EqualsAndHashCode)
nmap <silent><buffer> <leader>jc <Plug>(JavaComplete-Generate-Constructor)
nmap <silent><buffer> <leader>jcc <Plug>(JavaComplete-Generate-DefaultConstructor)
vmap <silent><buffer> <leader>js <Plug>(JavaComplete-Generate-AccessorSetter)
vmap <silent><buffer> <leader>jg <Plug>(JavaComplete-Generate-AccessorGetter)
vmap <silent><buffer> <leader>ja <Plug>(JavaComplete-Generate-AccessorSetterGetter)
endfunction
function! s:execCMD(cmd) abort
call unite#start([['output/shellcmd', a:cmd]], {'log': 1, 'wrap': 1,'start_insert':0})
endfunction
" vim:set et sw=2 cc=80:

View File

@ -91,9 +91,9 @@ function! SpaceVim#layers#lang#lisp#config() abort
\ ['n', '<c-n>', ':call vlime#ui#input#NextHistoryItem("forward")<cr>'],
\ ],
\ }
call SpaceVim#mapping#space#regesit_lang_mappings('lisp', funcref('s:lisp'))
augroup LocalVlimeKeys
autocmd!
autocmd FileType lisp call s:lisp()
autocmd FileType vlime_sldb call s:vlime_sldb()
autocmd FileType vlime_repl call s:vlime_repl()
autocmd FileType vlime_inspector call s:vlime_inspector()
@ -109,7 +109,6 @@ endfunction
fu! s:lisp()
let g:_spacevim_mappings_space.l = {'name' : '+Language Specified'}
let g:_spacevim_mappings_space.l.c = {'name' : '+Connection Management'}
call SpaceVim#mapping#space#langSPC('nmap', ['l','c', 'c'], "call VlimeConnectREPL()", 'Connect to Vlime server', 1)
call SpaceVim#mapping#space#langSPC('nmap', ['l','c', 's'], "call VlimeSelectCurConnection()", 'Switch Vlime connections', 1)

View File

@ -26,6 +26,12 @@ function! SpaceVim#layers#lang#markdown#config() abort
if executable('firefox')
let g:mkdp_path_to_chrome= get(g:, 'mkdp_path_to_chrome', 'firefox')
endif
let g:neoformat_enabled_markdown = ['remark']
let g:neoformat_markdown_remark = {
\ 'exe': 'remark',
\ 'args': ['--no-color', '--silent', '--use', 'remark-frontmatter'],
\ 'stdin': 1,
\ }
endfunction
function! s:mappings() abort

View File

@ -13,8 +13,18 @@ function! SpaceVim#layers#lang#python#plugins() abort
if has('nvim')
call add(plugins, ['zchee/deoplete-jedi', { 'on_ft' : 'python'}])
else
call add(plugins, ['davidhalter/jedi-vim', { 'on_ft' : 'python'}])
call add(plugins, ['davidhalter/jedi-vim', { 'on_ft' : 'python', 'if' : has('python') || has('python3')}])
endif
call add(plugins, ['Vimjas/vim-python-pep8-indent', { 'on_ft' : 'python'}])
return plugins
endfunction
function! SpaceVim#layers#lang#python#config()
call SpaceVim#layers#edit#add_ft_head_tamplate('python',
\ ['#!/usr/bin/env python',
\ '# -*- coding: utf-8 -*-',
\ '']
\ )
endfunction

View File

@ -3,6 +3,9 @@
" @parentsection layers
" SpaceVim uses deol.nvim for shell support in neovim and uses vimshell for
" vim. For more info, read |deol| and |vimshell|.
" @subsection variable
" default_shell
"
function! SpaceVim#layers#shell#plugins() abort
let plugins = []
@ -13,3 +16,50 @@ function! SpaceVim#layers#shell#plugins() abort
endif
return plugins
endfunction
function! SpaceVim#layers#shell#config() abort
call SpaceVim#mapping#space#def('nnoremap', ["'"], 'call call('
\ . string(function('s:open_default_shell')) . ', [])',
\ 'open shell', 1)
endfunction
function! SpaceVim#layers#shell#set_variable(var) abort
let s:default_shell = get(a:var, 'defaut_shell', 'terminal')
let s:default_position = get(a:var, 'default_position', 'top')
let s:default_height = get(a:var, 'default_height', 30)
endfunction
let s:shell_win_nr = 0
function! s:open_default_shell() abort
if s:shell_win_nr != 0 && getwinvar(s:shell_win_nr, '&buftype') ==# 'terminal' && &buftype !=# 'terminal'
exe s:shell_win_nr . 'wincmd w'
return
endif
if &buftype ==# 'terminal'
bwipeout! %
return
endif
let cmd = s:default_position ==# 'top' ?
\ 'topleft split' :
\ s:default_position ==# 'bottom' ?
\ 'botright split' :
\ s:default_position ==# 'right' ?
\ 'rightbelow vsplit' : 'leftabove vsplit'
exe cmd
let lines = &lines * s:default_height / 100
if lines < winheight(0) && (s:default_position ==# 'top' || s:default_position ==# 'bottom')
exe 'resize ' . lines
endif
if s:default_shell ==# 'terminal'
if exists(':te')
exe 'te'
let s:shell_win_nr = winnr()
else
echo ':terminal is not supported in this version'
endif
elseif s:default_shell ==# 'VimShell'
VimShell
endif
endfunction

View File

@ -21,7 +21,7 @@
function! SpaceVim#layers#tmux#plugins() abort
let plugins = []
call add(plugins,['christoomey/vim-tmux-navigator'])
call add(plugins,['christoomey/vim-tmux-navigator', {'merged' : 0}])
return plugins
endfunction

View File

@ -47,6 +47,7 @@ function! SpaceVim#layers#tools#plugins() abort
endfunction
function! SpaceVim#layers#tools#config() abort
let g:better_whitespace_filetypes_blacklist = ['diff', 'gitcommit', 'unite', 'qf', 'help', 'markdown', 'leaderGuide']
call SpaceVim#mapping#space#def('nnoremap', ['a', 'c'], 'Calendar', 'vim calendar', 1)
call SpaceVim#mapping#space#def('nnoremap', ['e', 'a'], 'FencAutoDetect',
\ 'Auto detect the file encoding', 1)

View File

@ -169,7 +169,7 @@ function! s:toggle_end_of_buffer() abort
endif
let s:ebflag = 1
else
if &termguicolors || has('gui_running')
if (exists('+termguicolors') && &termguicolors) || has('gui_running')
let normalbg = s:HI.group2dict('Normal').guibg
else
let normalbg = s:HI.group2dict('Normal').ctermbg
@ -196,6 +196,11 @@ function! s:toggle_syntax_checker() abort
call SpaceVim#layers#core#statusline#toggle_section('syntax checking')
call SpaceVim#layers#core#statusline#toggle_mode('syntax-checking')
let g:_spacevim_toggle_syntax_flag = g:_spacevim_toggle_syntax_flag * -1
if g:_spacevim_toggle_syntax_flag == 1
echo "syntax-checking enabled."
else
echo "syntax-checking disabled."
endif
endfunction
function! s:toggle_spell_check() abort

View File

@ -20,6 +20,8 @@ function! SpaceVim#mapping#g#init() abort
nnoremap g, g,
let g:_spacevim_mappings_g[';'] = ['call feedkeys("g;", "n")', 'older position in change list']
nnoremap g; g;
let g:_spacevim_mappings_g['@'] = ['call feedkeys("g@", "n")', 'call operatorfunc']
nnoremap g@ g@
let g:_spacevim_mappings_g['#'] = ['call feedkeys("\<Plug>(incsearch-nohl-g#)")', 'search under cursor backward']
let g:_spacevim_mappings_g['*'] = ['call feedkeys("\<Plug>(incsearch-nohl-g*)")', 'search under cursor forward']

View File

@ -411,11 +411,11 @@ function! s:updateStatusline() abort
let gname = substitute(gname,' ', '\\ ', 'g')
endif
exe 'setlocal statusline=%#LeaderGuiderPrompt#\ Guide:\ ' .
\ '%#LeaderGuiderSep1#' .
\ '%#LeaderGuiderSep1#' . s:lsep .
\ '%#LeaderGuiderName#\ ' .
\ SpaceVim#mapping#leader#getName(s:prefix_key)
\ . get(s:, 'prefix_key_inp', '') . gname
\ . '\ %#LeaderGuiderSep2#%#LeaderGuiderFill#'
\ . '\ %#LeaderGuiderSep2#' . s:lsep . '%#LeaderGuiderFill#'
\ . s:guide_help_msg()
endfunction
@ -512,6 +512,9 @@ function! s:get_register() "{{{
return clip
endfunction "}}}
function! SpaceVim#mapping#guide#start_by_prefix(vis, key) " {{{
if a:key == ' ' && exists('b:spacevim_lang_specified_mappings')
let g:_spacevim_mappings_space.l = b:spacevim_lang_specified_mappings
endif
let s:guide_help_mode = 0
let s:vis = a:vis ? 'gv' : ''
let s:count = v:count != 0 ? v:count : ''
@ -578,6 +581,7 @@ call SpaceVim#mapping#guide#register_prefix_descriptions(
call SpaceVim#mapping#guide#register_prefix_descriptions(
\ 'z',
\ 'g:_spacevim_mappings_z')
let [s:lsep, s:rsep] = SpaceVim#layers#core#statusline#rsep()
let &cpo = s:save_cpo
unlet s:save_cpo

View File

@ -3,7 +3,9 @@ function! SpaceVim#mapping#space#init() abort
return
endif
nnoremap <silent><nowait> [SPC] :<c-u>LeaderGuide " "<CR>
vnoremap <silent><nowait> [SPC] :<c-u>LeaderGuideVisual " "<CR>
nmap <Space> [SPC]
vmap <Space> [SPC]
let g:_spacevim_mappings_space = {}
let g:_spacevim_mappings_prefixs['[SPC]'] = {'name' : '+SPC prefix'}
let g:_spacevim_mappings_space['?'] = ['Unite menu:CustomKeyMaps -input=[SPC]', 'show mappings']
@ -72,7 +74,26 @@ function! SpaceVim#mapping#space#init() abort
"
" Toggles the comment state of the selected line(s). If the topmost selected
" line is commented, all selected lines are uncommented and vice versa.
call SpaceVim#mapping#space#def('nnoremap', ['c', 'l'], 'call NERDComment("n", "Toggle")', 'Toggle comment line(s)', 1)
call SpaceVim#mapping#space#def('nmap', ['c', 'l'], '<Plug>NERDCommenterComment', 'comment lines', 0, 1)
call SpaceVim#mapping#space#def('nmap', ['c', 'L'], '<Plug>NERDCommenterInvert', 'toggle comment lines', 0, 1)
call SpaceVim#mapping#space#def('nmap', ['c', 'p'], 'vip<Plug>NERDCommenterComment', 'comment paragraphs', 0, 1)
call SpaceVim#mapping#space#def('nmap', ['c', 'P'], 'vip<Plug>NERDCommenterInvert', 'toggle comment paragraphs', 0, 1)
nnoremap <silent> <Plug>CommentToLine :call <SID>comment_to_line(0)<Cr>
nnoremap <silent> <Plug>CommentToLineInvert :call <SID>comment_to_line(1)<Cr>
call SpaceVim#mapping#space#def('nmap', ['c', 't'], '<Plug>CommentToLine', 'comment until the line', 0, 1)
call SpaceVim#mapping#space#def('nmap', ['c', 'T'], '<Plug>CommentToLineInvert', 'toggle comment until the line', 0, 1)
nnoremap <silent> <Plug>CommentOperator :set opfunc=<SID>commentOperator<Cr>g@
let g:_spacevim_mappings_space[';'] = ['call feedkeys("\<Plug>CommentOperator")', 'comment operator']
nmap <silent> [SPC]; <Plug>CommentOperator
" in nerdcomment if has map to <plug>... the default mapping will be
" disable, so we add it for compatibility
nmap <Leader>cc <Plug>NERDCommenterComment
xmap <Leader>cc <Plug>NERDCommenterComment
nmap <Leader>ci <Plug>NERDCommenterInvert
xmap <Leader>ci <Plug>NERDCommenterInvert
let g:_spacevim_mappings_space.e = {'name' : '+Errors/Encoding'}
let g:_spacevim_mappings_space.B = {'name' : '+Global-buffers'}
@ -196,14 +217,18 @@ function! SpaceVim#mapping#space#init() abort
call SpaceVim#mapping#space#def('nnoremap', ['s', 't', 'J'], 'call SpaceVim#plugins#searcher#find(expand("<cword>"), "pt")',
\ 'Background search cursor words in project with pt', 1)
call SpaceVim#mapping#space#def('nnoremap', ['s', 'g', 'G'], 'call SpaceVim#plugins#flygrep#open()',
\ 'grep on the fly', 1)
call SpaceVim#mapping#space#def('nnoremap', ['s', 'c'], 'noh',
\ 'clear search highlight', 1)
endfunction
function! SpaceVim#mapping#space#def(m, keys, cmd, desc, is_cmd) abort
function! SpaceVim#mapping#space#def(m, keys, cmd, desc, is_cmd, ...) abort
if s:has_map_to_spc()
return
endif
let is_visual = a:0 > 0 ? a:1 : 0
if a:is_cmd
let cmd = ':<C-u>' . a:cmd . '<CR>'
let lcmd = a:cmd
@ -217,6 +242,13 @@ function! SpaceVim#mapping#space#def(m, keys, cmd, desc, is_cmd) abort
endif
endif
exe a:m . ' <silent> [SPC]' . join(a:keys, '') . ' ' . substitute(cmd, '|', '\\|', 'g')
if is_visual
if a:m ==# 'nnoremap'
exe 'xnoremap <silent> [SPC]' . join(a:keys, '') . ' ' . substitute(cmd, '|', '\\|', 'g')
elseif a:m ==# 'nmap'
exe 'xmap <silent> [SPC]' . join(a:keys, '') . ' ' . substitute(cmd, '|', '\\|', 'g')
endif
endif
if len(a:keys) == 2
let g:_spacevim_mappings_space[a:keys[0]][a:keys[1]] = [lcmd, a:desc]
elseif len(a:keys) == 3
@ -254,6 +286,22 @@ function! s:windows_layout_toggle() abort
wincmd w
endif
endfunction
let s:language_specified_mappings = {}
function! SpaceVim#mapping#space#refrashLSPC()
let g:_spacevim_mappings_space.l = {'name' : '+Language Specified'}
if !empty(&filetype) && has_key(s:language_specified_mappings, &filetype)
call call(s:language_specified_mappings[&filetype], [])
let b:spacevim_lang_specified_mappings = g:_spacevim_mappings_space.l
endif
endfunction
function! SpaceVim#mapping#space#regesit_lang_mappings(ft, func)
call extend(s:language_specified_mappings, {a:ft : a:func})
endfunction
function! SpaceVim#mapping#space#langSPC(m, keys, cmd, desc, is_cmd) abort
if s:has_map_to_spc()
return
@ -282,4 +330,45 @@ function! SpaceVim#mapping#space#langSPC(m, keys, cmd, desc, is_cmd) abort
call extend(g:_spacevim_mappings_prefixs['[SPC]'], get(g:, '_spacevim_mappings_space', {}))
endfunction
function! s:commentOperator(type, ...)
let sel_save = &selection
let &selection = "inclusive"
let reg_save = @@
if a:0 " Invoked from Visual mode, use gv command.
silent exe "normal! gv"
call feedkeys("\<Plug>NERDCommenterComment")
elseif a:type == 'line'
call feedkeys('`[V`]')
call feedkeys("\<Plug>NERDCommenterComment")
else
call feedkeys('`[v`]')
call feedkeys("\<Plug>NERDCommenterComment")
endif
let &selection = sel_save
let @@ = reg_save
set opfunc=
endfunction
function! s:comment_to_line(invert) abort
let input = input('line number: ')
if empty(input)
return
endif
let line = str2nr(input)
let ex = line - line('.')
if ex > 0
exe 'normal! V'. ex .'j'
elseif ex == 0
else
exe 'normal! V'. abs(ex) .'k'
endif
if a:invert
call feedkeys("\<Plug>NERDCommenterInvert")
else
call feedkeys("\<Plug>NERDCommenterComment")
endif
endfunction
" vim:set et sw=2 cc=80:

View File

@ -0,0 +1,193 @@
let s:MPT = SpaceVim#api#import('prompt')
let s:JOB = SpaceVim#api#import('job')
let s:SYS = SpaceVim#api#import('system')
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
endfunction
let s:grep_expr = ''
let s:grep_exe = SpaceVim#mapping#search#default_tool()
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'),
\ })
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})
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
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
endfunction
let s:MPT._oninputpro = function('s:close_grep_job')
" @vimlint(EVL103, 1, a:data)
" @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()
endfunction
function! s:grep_exit(id, data, event) abort
redrawstatus
let s:grepid = 0
endfunction
" @vimlint(EVL103, 0, a:data)
" @vimlint(EVL103, 0, a:id)
" @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
endfunction
function! s:next_item() abort
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()
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
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
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
endif
call s:MPT._build_prompt()
endfunction
let s:MPT._function_key = {
\ "\<Tab>" : function('s:next_item'),
\ "\<ScrollWheelDown>" : function('s:next_item'),
\ "\<S-tab>" : function('s:previous_item'),
\ "\<ScrollWheelUp>" : function('s:previous_item'),
\ "\<Return>" : function('s:open_item'),
\ "\<LeftMouse>" : function('s:move_cursor'),
\ "\<2-LeftMouse>" : function('s:double_click'),
\ }
" statusline api
function! SpaceVim#plugins#flygrep#lineNr() abort
if getline(1) ==# ''
return ''
else
return line('.') . '/' . line('$')
endif
endfunction

View File

@ -2,7 +2,7 @@ let s:JOB = SpaceVim#api#import('job')
let s:rst = []
function! SpaceVim#plugins#searcher#find(expr, exe)
function! SpaceVim#plugins#searcher#find(expr, exe) abort
if empty(a:expr)
let expr = input('search expr: ')
else
@ -14,6 +14,8 @@ function! SpaceVim#plugins#searcher#find(expr, exe)
\ 'on_exit' : function('s:search_exit'),
\ })
endfunction
" @vimlint(EVL103, 1, a:id)
" @vimlint(EVL103, 1, a:event)
function! s:search_stdout(id, data, event) abort
for data in a:data
let info = split(data, '\:\d\+\:')
@ -30,27 +32,31 @@ function! s:search_stdout(id, data, event) abort
endfunction
function! s:get_search_cmd(exe, expr) abort
if a:exe == 'grep'
if a:exe ==# 'grep'
return ['grep', '-inHR', '--exclude-dir', '.git', a:expr, '.']
elseif a:exe == 'rg'
elseif a:exe ==# 'rg'
return ['rg', '-n', a:expr]
else
return [a:exe, a:expr]
endif
endfunction
" @vimlint(EVL103, 1, a:data)
function! s:search_exit(id, data, event) abort
let &l:statusline = SpaceVim#layers#core#statusline#get(1)
endfunction
" @vimlint(EVL103, 0, a:data)
" @vimlint(EVL103, 0, a:id)
" @vimlint(EVL103, 0, a:event)
function! SpaceVim#plugins#searcher#list()
function! SpaceVim#plugins#searcher#list() abort
call setqflist(s:rst)
let s:rst = []
copen
endfunction
function! SpaceVim#plugins#searcher#count()
function! SpaceVim#plugins#searcher#count() abort
if empty(s:rst)
return ''
else

View File

@ -26,7 +26,7 @@ else
exec 'colorscheme '. g:spacevim_colorscheme_default
endif
if g:spacevim_hiddenfileinfo == 1 && has('patch-7.4.1570')
set shortmess=filnxtToOFs
set shortmess+=F
endif
if !empty(g:spacevim_guifont)
exe 'set guifont=' . g:spacevim_guifont

View File

@ -71,7 +71,7 @@ let g:terminal_color_15 = '#ebdbb2'
augroup Terminal
au!
au TermOpen * let g:last_terminal_job_id = b:terminal_job_id | IndentLinesDisable
au BufWinEnter term://* startinsert | IndentLinesDisable
au WinEnter,BufWinEnter term://* startinsert | IndentLinesDisable
if has('timers')
au TermClose * let g:_spacevim_termclose_abuf = expand('<abuf>') | call timer_start(5, 'SpaceVim#mapping#close_term_buffer')
else

View File

@ -50,8 +50,9 @@ CONTENTS *SpaceVim-contents*
6. API........................................................|SpaceVim-api|
1. cmdlinemenu................................|SpaceVim-api-cmdlinemenu|
2. data#list....................................|SpaceVim-api-data-list|
3. sid............................................|SpaceVim-api-vim-sid|
4. vim#message................................|SpaceVim-api-vim-message|
3. prompt..........................................|SpaceVim-api-prompt|
4. sid............................................|SpaceVim-api-vim-sid|
5. vim#message................................|SpaceVim-api-vim-message|
7. FAQ........................................................|SpaceVim-faq|
==============================================================================
@ -413,7 +414,7 @@ FUNCTIONS *SpaceVim-functions*
SpaceVim#layers#load({layer}) *SpaceVim#layers#load()*
Load the {layer} you want. For all the layers SpaceVim supports, see
|SpaceVim-layers|.
|SpaceVim-layers|. the second argv is the layer variable.
SpaceVim#logger#setLevel({level}) *SpaceVim#logger#setLevel()*
Set debug level of SpaceVim. Default is 1.
@ -921,6 +922,9 @@ SHELL *SpaceVim-layer-shell*
SpaceVim uses deol.nvim for shell support in neovim and uses vimshell for vim.
For more info, read |deol| and |vimshell|.
VARIABLE
default_shell
==============================================================================
TMUX *SpaceVim-layer-tmux*
@ -982,6 +986,22 @@ listpart({list}, {start}[, {len}])
The result is a List, which is part of {list}, starting from index {start},
with the length {len}
==============================================================================
PROMPT *SpaceVim-api-prompt*
open()
Create a cmdline prompt, use while loop to get the input from user. The
default mapping for prompt is:
>
<Bs> remove last character
<C-w> remove the Word before the cursor
<C-u> remove the Line before the cursor
<C-k> remove the Line after the cursor
<C-a> / <Home> Go to the beginning of the line
<C-e> / <End> Go to the end of the line
<
==============================================================================
SID *SpaceVim-api-vim-sid*

File diff suppressed because it is too large Load Diff

View File

@ -23,13 +23,13 @@ If you are new to vim, you should learning about Vim in general, read [vim-galor
### Linux/Mac
If you are using linux or mac os, it is recommenced to use this command to install SpaceVim:
If you are using linux or mac os, it is recommended to use this command to install SpaceVim:
```sh
curl -sLf https://spacevim.org/install.sh | bash
```
with this command, SpaceVim will be installed. all the plugins will be install **automatically** when first time run vim/nvim.
for more info about the install script, please check:
with this command, SpaceVim will be installed. All the plugins will be installed **automatically** when vim/nvim is run for the first time.
For more info about the install script, please check:
```sh
curl -sLf https://spacevim.org/install.sh | bash -s -- -h

View File

@ -42,6 +42,10 @@ error() {
exit 1
}
warn () {
msg "${Red}[✘]${Color_off} ${1}${2}"
}
fetch_repo () {
if [[ -d "$HOME/.SpaceVim" ]]; then
info "Trying to update SpaceVim"
@ -75,6 +79,14 @@ install_vim () {
fi
}
install_package_manager () {
if [[ ! -d "$HOME/.cache/vimfiles/repos/github.com/Shougo/dein.vim" ]]; then
info "Install dein.vim"
git clone https://github.com/Shougo/dein.vim.git $HOME/.cache/vimfiles/repos/github.com/Shougo/dein.vim
success "dein.vim installation done"
fi
}
install_neovim () {
if [[ -d "$HOME/.config/nvim" ]]; then
if [[ "$(readlink $HOME/.config/nvim)" =~ \.SpaceVim$ ]]; then
@ -121,6 +133,42 @@ uninstall_neovim () {
fi
}
check_requirements () {
info "Checking Requirements for SpaceVim"
if hash "git" &>/dev/null; then
git_version=$(git --version)
success "Check Requirements: ${git_version}"
else
warn "Check Requirements : git"
fi
if hash "vim" &>/dev/null; then
is_vim8=$(vim --version | grep "Vi IMproved 8.0")
is_vim74=$(vim --version | grep "Vi IMproved 7.4")
if [ -n "$is_vim8" ]; then
success "Check Requirements: vim 8.0"
elif [ -n "$is_vim74" ]; then
success "Check Requirements: vim 7.4"
else
if hash "nvim" &>/dev/null; then
success "Check Requirements: nvim"
else
warn "SpaceVim need vim 7.4 or above"
fi
fi
if hash "nvim" &>/dev/null; then
success "Check Requirements: nvim"
fi
else
if hash "nvim" &>/dev/null; then
success "Check Requirements: nvim"
else
warn "Check Requirements : vim or nvim"
fi
fi
info "Checking true colors support in terminal:"
sh -c "$(curl -fsSL https://raw.githubusercontent.com/JohnMorales/dotfiles/master/colors/24-bit-color.sh)"
}
usage () {
echo "SpaceVim install script : V ${Version}"
echo ""
@ -133,6 +181,7 @@ usage () {
echo " -i, --install install spacevim for vim or neovim"
echo " -v, --version Show version information and exit"
echo " -u, --uninstall Uninstall SpaceVim"
echo " -c, --checkRequirements checkRequirements for SpaceVim"
echo ""
echo "EXAMPLE"
echo ""
@ -160,6 +209,10 @@ then
uninstall_neovim
exit 0
;;
--checkRequirements|-c)
check_requirements
exit 0
;;
--install|-i)
need_cmd 'git'
fetch_repo
@ -193,3 +246,4 @@ need_cmd 'git'
fetch_repo
install_vim
install_neovim
install_package_manager

View File

@ -1,14 +1,15 @@
# SpaceVim Layers
Name | Description | Documentation
----- |:----:| ------------------
default | better default for vim and neovim | [documentation](https://spacevim.org/layers/default)
checkers | checking in vim | [documentation](https://spacevim.org/layers/checkers)
autocomplete | autocomplete in vim | [documentation](https://spacevim.org/layers/autocomplete)
chinese | layer for chinese vimer | [documentation](https://spacevim.org/layers/chinese)
colorscheme | all colorscheme in spacevim | [documentation](https://spacevim.org/layers/colorscheme)
chat | chatting in vim | [documentation](https://spacevim.org/layers/chat)
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)
| Name | Description | Documentation |
| ------------- | :-------------------------------: | ---------------------------------------------------------- |
| default | better default for vim and neovim | [documentation](https://spacevim.org/layers/default) |
| shell | shell support for SpaceVim | [documentation](https://spacevim.org/layers/shell) |
| checkers | checking in vim | [documentation](https://spacevim.org/layers/checkers) |
| autocomplete | autocomplete in vim | [documentation](https://spacevim.org/layers/autocomplete) |
| chinese | layer for chinese vimer | [documentation](https://spacevim.org/layers/chinese) |
| colorscheme | all colorscheme in spacevim | [documentation](https://spacevim.org/layers/colorscheme) |
| chat | chatting in vim | [documentation](https://spacevim.org/layers/chat) |
| 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) |

View File

@ -1,53 +1,80 @@
# [Layers](https://spacevim.org/layers) > lang#java
---
title: "SpaceVim lang#java layer"
---
# [SpaceVim Layers:](https://spacevim.org/layers) lang#java
<!-- vim-markdown-toc GFM -->
* [Description](#description)
* [Layer Installation](#layer-installation)
* [Key bindings](#key-bindings)
* [Java language specified key bindings](#java-language-specified-key-bindings)
* [Maven](#maven)
* [Problems buffer](#problems-buffer)
* [Project buffer](#project-buffer)
<!-- vim-markdown-toc -->
## Description
This layer is for Java development.
## Install
## Layer Installation
To use this configuration layer, add `SPLayer 'lang#java'` to your custom configuration file.
## Key bindings
## Mappings
### Java language specified key bindings
Import mappings:
**Import key bindings:**
Mode Key Function
-------------------------------------------------------------
normal <F4> import class under cursor
insert <F4> import class under cursor
normal <leader>jI import missing classes
normal <leader>jR remove unused imports
normal <leader>ji smart import class under cursor
normal <leader>jii same as <F4>
insert <c-j>I import missing imports
insert <c-j>R remove unused imports
insert <c-j>i smart import class under cursor
insert <c-j>ii add import for class under cursor
| Key Binding | Description |
| -------------------- | ------------------------------- |
| `F4` (Insert/Normal) | Import class under cursor |
| `SPC l I` | Import missing classes |
| `SPC l R` | Remove unused classes |
| `SPC l i` | smart import class under cursor |
| `<C-j>I` (Insert) | Import missing classes |
| `<C-j>R` (Insert) | Remove unused classes |
| `<C-j>i` (Insert) | smart import class under cursor |
Generate mappings:
**Generate key bindings:**
Mode Key Function
-------------------------------------------------------------
normal <leader>jA generate accessors
normal <leader>js generate setter accessor
normal <leader>jg generate getter accessor
normal <leader>ja generate setter and getter accessor
normal <leader>jts generate toString function
normal <leader>jeq generate equals and hashcode function
normal <leader>jc generate constructor
normal <leader>jcc generate default constructor
insert <c-j>s generate setter accessor
insert <c-j>g generate getter accessor
insert <c-j>a generate getter and setter accessor
visual <leader>js generate setter accessor
visual <leader>jg generate getter accessor
visual <leader>ja generate setter and getter accessor
| Mode | Key Binding | Description |
| ------------- | ----------- | ------------------------------------- |
| normal | `SPC l A` | generate accessors |
| normal/visual | `SPC l s` | generate setter accessor |
| normal/visual | `SPC l g` | generate getter accessor |
| normal/visual | `SPC l a` | generate setter and getter accessor |
| insert | `<c-j>s` | generate setter accessor |
| insert | `<c-j>g` | generate getter accessor |
| insert | `<c-j>a` | generate getter and setter accessor |
| normal | `SPC l t s` | generate toString function |
| normal | `SPC l e q` | generate equals and hashcode function |
| normal | `SPC l c` | generate constructor |
| normal | `SPC l C` | generate default constructor |
## Code formatting
**Code formatting:**
the default key bindings for format current buffer is `SPC b f`. and this key bindings is defined in [format layer](<>). you can also use `g=` to indent current buffer.
To make neoformat support java file, you should install uncrustify. or
download google's formater jar from:
download [google's formater jar](https://github.com/google/google-java-format)
and add `let g:spacevim_layer_lang_java_formatter = 'path/to/google-java-format.jar'`
to SpaceVim custom configuration file.
https://github.com/google/google-java-format
#### Maven
and set 'g:spacevim_layer_lang_java_formatter' to the path of the jar.
| Key Binding | Description |
| ----------- | ------------------------------ |
| `SPC l m i` | Run maven clean install |
| `SPC l m I` | Run maven install |
| `SPC l m p` | Run one already goal from list |
| `SPC l m r` | Run maven goals |
| `SPC l m R` | Run one maven goal |
| `SPC l m t` | Run maven test |
### Problems buffer
### Project buffer

55
docs/layers/shell.md Normal file
View File

@ -0,0 +1,55 @@
---
title: "SpaceVim shell layer"
---
# [SpaceVim Layers:](https://spacevim.org/layers) shell
<!-- vim-markdown-toc GFM -->
* [Description](#description)
* [Install](#install)
* [Configuration](#configuration)
* [Default shell](#default-shell)
* [Default shell position and height](#default-shell-position-and-height)
* [Key bindings](#key-bindings)
<!-- vim-markdown-toc -->
## Description
This layer provide shell support in SpaceVim.
## Install
To use this configuration layer, add `SPLayer 'shell'` to your custom configuration file.
## Configuration
### Default shell
Vim support these kinds of shell:
To define the default shell you can set the layer variable `default_shell` to the following variables:
- terminal
- VimShell
The default shell is quickly accessible via a the default shortcut key `SPC '`.
### Default shell position and height
It is possible to choose where the shell should pop up by setting the variable `default_position` to either `top`, `bottom`, `left`, `right`, or `full`. Default value is `top`. It is also possible to set the default height in percents with the variable `default_height`. Default value is 30.
```vim
call SpaceVim#layers#load('shell',
\ {
\ 'default_position' : 'top',
\ 'default_height' : 30,
\ }
\ )
```
## Key bindings
| Key Binding | Description |
| ----------- | -------------------------------------- |
| `SPC '` | Open, close or go to the default shell |

View File

@ -1,3 +1,8 @@
" Basic mode of SpaceVim, generated by SpaceVim automatically.
let g:spacevim_enable_guicolors = 0
let g:spacevim_statusline_separator = 'nil'
let g:spacevim_statusline_inactive_separator = 'bar'
let g:spacevim_buffer_index_type = 4
let g:spacevim_enable_tabline_filetype_icon = 0

View File

@ -25,7 +25,13 @@ let g:deoplete#auto_complete_delay = 150
let g:spacevim_enable_tabline_filetype_icon = 1
let g:spacevim_enable_os_fileformat_icon = 1
let g:spacevim_buffer_index_type = 1
let g:neomake_vim_enabled_makers = ['vimlint', 'vint']
let g:neomake_vim_enabled_makers = []
if executable('vimlint')
call add(g:neomake_vim_enabled_makers, 'vimlint')
endif
if executable('vint')
call add(g:neomake_vim_enabled_makers, 'vint')
endif
if has('python3')
let g:ctrlp_map = ''
nnoremap <silent> <C-p> :Denite file_rec<CR>

View File

@ -0,0 +1,8 @@
if exists("b:current_syntax")
finish
endif
let b:current_syntax = "SpaceVimFlyGrep"
syntax case ignore
syn match FileName /[^:]*:\d\+:/
hi def link FileName Comment

4
test/api/web/html.vader Normal file
View File

@ -0,0 +1,4 @@
Execute (Test web#http api):
let g:test_api_web_html = SpaceVim#api#import('web#html')
let g:test_api_web_html_paser = g:test_api_web_html.parseURL('spacevim.org')
AssertEqual g:test_api_web_html_paser.child[1].find('title').child[0], 'Home - SpaceVim'

4
test/api/web/http.vader Normal file
View File

@ -0,0 +1,4 @@
Execute (Test web#http api):
let g:test_api_web_http = SpaceVim#api#import('web#http')
let g:test_api_web_http_getresult = g:test_api_web_http.get('spacevim.org')
AssertEqual g:test_api_web_http_getresult.status, '200'

4
test/test.sh Executable file
View File

@ -0,0 +1,4 @@
if [ ! -e /tmp/vader ]; then
git clone https://github.com/junegunn/vader.vim.git /tmp/vader
fi
vim -Nu test/test.vim -c 'Vader! test/**'