mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-02 21:00:03 +08:00
Merge branch 'master' into cursor
This commit is contained in:
commit
1fefff25fe
@ -32,19 +32,19 @@ endfunction
|
||||
|
||||
function! s:generate_content_cn() abort
|
||||
let content = ['', '## 可用 APIs', '']
|
||||
let content += s:layer_list_cn()
|
||||
let content += s:api_list_cn()
|
||||
let content += ['']
|
||||
return content
|
||||
endfunction
|
||||
|
||||
function! s:generate_content() abort
|
||||
let content = ['', '## Available APIs', '', 'here is the list of all available APIs, and welcome to contribute to SpaceVim.', '']
|
||||
let content += s:layer_list()
|
||||
let content = ['', '## Available APIs', '', 'Here is the list of all available APIs, and welcome to contribute to SpaceVim.', '']
|
||||
let content += s:api_list()
|
||||
let content += ['']
|
||||
return content
|
||||
endfunction
|
||||
|
||||
function! s:layer_list() abort
|
||||
function! s:api_list() abort
|
||||
let layers = SpaceVim#util#globpath('~/.SpaceVim/', 'docs/api/**/*.md')
|
||||
let list = [
|
||||
\ '| Name | Description |',
|
||||
@ -69,7 +69,7 @@ function! s:layer_list() abort
|
||||
return list
|
||||
endfunction
|
||||
|
||||
function! s:layer_list_cn() abort
|
||||
function! s:api_list_cn() abort
|
||||
let layers = SpaceVim#util#globpath('~/.SpaceVim/', 'docs/cn/api/**/*.md')
|
||||
let list = [
|
||||
\ '| 名称 | 描述 |',
|
||||
|
@ -58,5 +58,5 @@ function! s:follow_head_content() abort
|
||||
let s:prs =s:get_list_of_PRs()
|
||||
endif
|
||||
let md = md + SpaceVim#dev#releases#parser_prs(s:prs, s:lang)
|
||||
return join(md, "\n")
|
||||
return md
|
||||
endfunction
|
||||
|
@ -1,8 +1,8 @@
|
||||
function! SpaceVim#dev#g#updatedoc()
|
||||
function! SpaceVim#dev#g#updatedoc() abort
|
||||
let keys = keys(g:_spacevim_mappings_g)
|
||||
let lines = []
|
||||
for key in keys
|
||||
if key == '`'
|
||||
if key ==# '`'
|
||||
let line = '`` g' . key . ' `` | ' . g:_spacevim_mappings_g[key][1]
|
||||
else
|
||||
let line = '`g' . key . '` | ' . g:_spacevim_mappings_g[key][1]
|
||||
|
41
.SpaceVim.d/autoload/SpaceVim/dev/issuemanager.vim
Normal file
41
.SpaceVim.d/autoload/SpaceVim/dev/issuemanager.vim
Normal file
@ -0,0 +1,41 @@
|
||||
"=============================================================================
|
||||
" issuemanager.vim --- issue manager for SpaceVim development
|
||||
" Copyright (c) 2016-2017 Wang Shidong & Contributors
|
||||
" Author: Wang Shidong < wsdjeg at 163.com >
|
||||
" URL: https://spacevim.org
|
||||
" License: GPLv3
|
||||
"=============================================================================
|
||||
|
||||
function! SpaceVim#dev#issuemanager#edit(id) abort
|
||||
let issue = github#api#issues#Get_issue('SpaceVim', 'SpaceVim', a:id)
|
||||
exe 'silent tabnew ++ff=unix ' . tempname() . '/issue_' . a:id . '.md'
|
||||
let content = split(issue.body, "\n")
|
||||
let b:current_issue = issue
|
||||
call setline(1, map(content, "substitute(v:val, '
$', '', 'g')"))
|
||||
augroup spacevim_dev_issuemanager
|
||||
autocmd!
|
||||
autocmd BufWritePost <buffer> call <SID>update_issue()
|
||||
augroup END
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:update_issue() abort
|
||||
let issue = get(b:, 'current_issue', {})
|
||||
if !empty(issue)
|
||||
let new = {'title' : issue.title,
|
||||
\ 'body' : join(getline(1, '$'), "\n")}
|
||||
redraw
|
||||
call inputsave()
|
||||
let username = input('github username:')
|
||||
let password = input('github password:')
|
||||
call inputrestore()
|
||||
let respons = github#api#issues#Edit('SpaceVim', 'SpaceVim', issue.number, username, password, new)
|
||||
normal! :
|
||||
if !empty(respons) && get(respons, 'number', 0) == issue.number
|
||||
echon 'Issue ' . issue.number . ' has been updated!'
|
||||
elseif !empty(respons)
|
||||
let msg = get(respons, 'message', '')
|
||||
echon 'Failed to update issue ' . issue.number . ':' . msg
|
||||
endif
|
||||
endif
|
||||
endfunction
|
@ -8,17 +8,26 @@
|
||||
|
||||
scriptencoding utf-8
|
||||
|
||||
let s:FILE = SpaceVim#api#import('file')
|
||||
let s:SYS = SpaceVim#api#import('system')
|
||||
|
||||
|
||||
|
||||
let s:AUTODOC = SpaceVim#api#import('dev#autodoc')
|
||||
let s:AUTODOC.autoformat = 1
|
||||
|
||||
function! SpaceVim#dev#layers#update() abort
|
||||
let s:AUTODOC.begin = '^<!-- SpaceVim layer list start -->$'
|
||||
let s:AUTODOC.end = '^<!-- SpaceVim layer list end -->$'
|
||||
let s:AUTODOC.content_func = function('s:generate_content')
|
||||
call s:AUTODOC.update()
|
||||
endfunction
|
||||
|
||||
let [start, end] = s:find_position()
|
||||
if start != 0 && end != 0
|
||||
if end - start > 1
|
||||
exe (start + 1) . ',' . (end - 1) . 'delete'
|
||||
endif
|
||||
call append(start, s:generate_content())
|
||||
silent! Neoformat
|
||||
endif
|
||||
|
||||
function! SpaceVim#dev#layers#updateCn() abort
|
||||
let s:AUTODOC.begin = '^<!-- SpaceVim layer cn list start -->$'
|
||||
let s:AUTODOC.end = '^<!-- SpaceVim layer cn list end -->$'
|
||||
let s:AUTODOC.content_func = function('s:generate_content_cn')
|
||||
call s:AUTODOC.update()
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#dev#layers#updatedocker() abort
|
||||
@ -31,19 +40,6 @@ function! SpaceVim#dev#layers#updatedocker() abort
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#dev#layers#updateCn() abort
|
||||
|
||||
let [start, end] = s:find_position_cn()
|
||||
if start != 0 && end != 0
|
||||
if end - start > 1
|
||||
exe (start + 1) . ',' . (end - 1) . 'delete'
|
||||
endif
|
||||
call append(start, s:generate_content_cn())
|
||||
silent! Neoformat
|
||||
endif
|
||||
|
||||
endfunction
|
||||
|
||||
function! s:find_position() abort
|
||||
let start = search('^<!-- SpaceVim layer list start -->$','bwnc')
|
||||
let end = search('^<!-- SpaceVim layer list end -->$','bnwc')
|
||||
@ -99,18 +95,19 @@ function! s:layer_list() abort
|
||||
\ '| Name | Description |',
|
||||
\ '| ---------- | ------------ |'
|
||||
\ ]
|
||||
call remove(layers, index(layers, '/home/wsdjeg/.SpaceVim/docs/layers/index.md'))
|
||||
if s:SYS.isWindows
|
||||
let pattern = join(['', 'docs', 'layers', ''], s:FILE.separator . s:FILE.separator)
|
||||
else
|
||||
let pattern = join(['', 'docs', 'layers', ''], s:FILE.separator)
|
||||
endif
|
||||
for layer in layers
|
||||
let name = split(layer, '/docs/layers/')[1][:-4] . '/'
|
||||
let url = name
|
||||
if name ==# 'language-server-protocol/'
|
||||
let name = 'lsp'
|
||||
endif
|
||||
let name = split(layer, pattern)[1][:-4] . s:FILE.separator
|
||||
let url = join(split(name, s:FILE.separator), '/') . '/'
|
||||
let content = readfile(layer)
|
||||
if len(content) > 3
|
||||
let line = '| [' . join(split(name, '/'), '#') . '](' . url . ') | ' . content[2][14:-2] . ' | '
|
||||
let line = '| [' . join(split(name, s:FILE.separator), '#') . '](' . url . ') | ' . content[2][14:-2] . ' | '
|
||||
else
|
||||
let line = '| [' . join(split(name, '/'), '#') . '](' . url . ') | can not find Description |'
|
||||
let line = '| [' . join(split(name, s:FILE.separator), '#') . '](' . url . ') | can not find Description |'
|
||||
endif
|
||||
call add(list, line)
|
||||
endfor
|
||||
@ -123,18 +120,19 @@ function! s:layer_list_cn() abort
|
||||
\ '| 名称 | 描述 |',
|
||||
\ '| ---------- | ------------ |'
|
||||
\ ]
|
||||
call remove(layers, index(layers, '/home/wsdjeg/.SpaceVim/docs/cn/layers/index.md'))
|
||||
if s:SYS.isWindows
|
||||
let pattern = join(['', 'docs', 'cn', 'layers', ''], s:FILE.separator . s:FILE.separator)
|
||||
else
|
||||
let pattern = join(['', 'docs', 'cn', 'layers', ''], s:FILE.separator)
|
||||
endif
|
||||
for layer in layers
|
||||
let name = split(layer, '/docs/cn/layers/')[1][:-4] . '/'
|
||||
let url = name
|
||||
if name ==# 'language-server-protocol/'
|
||||
let name = 'lsp'
|
||||
endif
|
||||
let name = split(layer, pattern)[1][:-4] . s:FILE.separator
|
||||
let url = join(split(name, s:FILE.separator), '/') . '/'
|
||||
let content = readfile(layer)
|
||||
if len(content) > 3
|
||||
let line = '| [' . join(split(name, '/'), '#') . '](' . url . ') | ' . content[2][14:-2] . ' | '
|
||||
let line = '| [' . join(split(name, s:FILE.separator), '#') . '](' . url . ') | ' . content[2][14:-2] . ' | '
|
||||
else
|
||||
let line = '| [' . join(split(name, '/'), '#') . '](' . url . ') | can not find Description |'
|
||||
let line = '| [' . join(split(name, s:FILE.separator), '#') . '](' . url . ') | can not find Description |'
|
||||
endif
|
||||
call add(list, line)
|
||||
endfor
|
||||
|
@ -6,6 +6,7 @@
|
||||
" License: GPLv3
|
||||
"=============================================================================
|
||||
|
||||
scriptencoding utf-8
|
||||
|
||||
" 2017-08-05 v0.4.0 is released at https://github.com/SpaceVim/SpaceVim/pull/768
|
||||
" 2017-11-16 v0.5.0 is released at https://github.com/SpaceVim/SpaceVim/pull/966
|
||||
@ -83,6 +84,7 @@ function! s:get_list_of_PRs() abort
|
||||
\ . s:last_release_number
|
||||
\ . " && v:val['number'] < "
|
||||
\ . s:current_release_number
|
||||
\ . ' && !empty(get(v:val, "merged_at", ""))'
|
||||
\ . " && index(s:unmerged_prs_since_current_release, v:val['number']) == -1 "
|
||||
\ ))
|
||||
endfor
|
||||
@ -112,7 +114,7 @@ endfunction
|
||||
|
||||
" this function is to generate markdown form pull request list
|
||||
function! SpaceVim#dev#releases#parser_prs(prs, ...) abort
|
||||
let is_cn = get(a:000, 0, '') == 'cn'
|
||||
let is_cn = get(a:000, 0, '') ==# 'cn'
|
||||
let g:is_cn = is_cn
|
||||
let md = []
|
||||
let adds = []
|
||||
|
@ -5,10 +5,10 @@ let s:port = '9995'
|
||||
let s:JSON = SpaceVim#api#import('data#json')
|
||||
let s:JOB = SpaceVim#api#import('job')
|
||||
|
||||
func! SpaceVim#dev#send_to_channel#setport(port)
|
||||
func! SpaceVim#dev#send_to_channel#setport(port) abort
|
||||
let s:port = a:port
|
||||
endf
|
||||
func! SpaceVim#dev#send_to_channel#send(t)
|
||||
func! SpaceVim#dev#send_to_channel#send(t) abort
|
||||
|
||||
if a:t ==# 'line'
|
||||
call s:sendline()
|
||||
@ -16,7 +16,7 @@ func! SpaceVim#dev#send_to_channel#send(t)
|
||||
|
||||
endf
|
||||
|
||||
func! s:send(msg)
|
||||
func! s:send(msg) abort
|
||||
let msg = {
|
||||
\ 'text' : a:msg,
|
||||
\ 'username' : s:username,
|
||||
|
@ -14,7 +14,7 @@ call SpaceVim#custom#SPC('nnoremap', ['a', 'o'], 'call SpaceVim#dev#todo#list()'
|
||||
|
||||
" after run make test, the vader will be downloaded to ./build/vader/
|
||||
|
||||
let &runtimepath .= ',' . fnamemodify(g:_spacevim_root_dir, ':p:h:h') . '/build/vader'
|
||||
let &runtimepath .= ',' . fnamemodify(g:_spacevim_root_dir, ':p:h') . '/build/vader'
|
||||
|
||||
" vader language specific key bindings
|
||||
|
||||
@ -25,4 +25,5 @@ function! s:language_specified_mappings() abort
|
||||
endfunction
|
||||
call SpaceVim#mapping#space#regesit_lang_mappings('vader', function('s:language_specified_mappings'))
|
||||
call SpaceVim#plugins#a#set_config_name('.projections.json')
|
||||
command! -nargs=1 IssueEdit call SpaceVim#dev#issuemanager#edit(<f-args>)
|
||||
|
||||
|
@ -9,7 +9,8 @@ if [ "$TRAVIS_PULL_REQUEST" != "false" ] ; then
|
||||
VIMLINT_LOG=`cat build_log`
|
||||
echo "$VIMLINT_LOG"
|
||||
git clone https://github.com/wsdjeg/GitHub.vim.git build/GitHub.vim
|
||||
docker run -it --rm \
|
||||
docker run \
|
||||
-it --rm \
|
||||
-v $PWD/.ci:/.ci \
|
||||
-v $PWD/autoload/SpaceVim/api:/API/autoload/SpaceVim/api \
|
||||
-v $PWD/autoload/SpaceVim/api.vim:/API/autoload/SpaceVim/api.vim \
|
||||
|
@ -25,7 +25,7 @@ function! s:update_log(log, summary, new_log) abort
|
||||
|
||||
endfunction
|
||||
if !empty(s:log)
|
||||
if $LINT == 'vader'
|
||||
if $LINT ==# 'vader'
|
||||
let s:summary = $VIM . ' ' . $LINT . ' build log'
|
||||
else
|
||||
let s:summary = $LINT . ' build log'
|
||||
@ -50,7 +50,7 @@ if !empty(s:log)
|
||||
endif
|
||||
endif
|
||||
else
|
||||
if $LINT == 'vader'
|
||||
if $LINT ==# 'vader'
|
||||
let s:summary = $VIM . ' ' . $LINT . ' build log'
|
||||
else
|
||||
let s:summary = $LINT . ' build log'
|
||||
|
@ -55,6 +55,7 @@ main () {
|
||||
_detect autoload/SpaceVim/api.vim
|
||||
_detect autoload/SpaceVim/commands.vim
|
||||
_detect autoload/SpaceVim/api/job.vim
|
||||
_detect autoload/SpaceVim/api/system.vim
|
||||
_detect autoload/SpaceVim/api/data/list.vim
|
||||
_detect autoload/SpaceVim/api/vim/compatible.vim
|
||||
_detect syntax/SpaceVimPlugManager.vim
|
||||
|
@ -7,7 +7,6 @@ set -ue -o pipefail
|
||||
export LC_ALL=C
|
||||
|
||||
docker pull spacevim/vims
|
||||
|
||||
git fetch origin master:master
|
||||
|
||||
if [ "${LINT#vimlint}" != "$LINT" ]; then
|
||||
|
@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -ex
|
||||
export TRAVIS_PULL_REQUEST=${TRAVIS_PULL_REQUEST}
|
||||
if [ "$LINT" = "vimlint" ]; then
|
||||
for file in $(git diff --name-only HEAD dev | grep .vim$);
|
||||
do
|
||||
|
3
.github/CODEOWNERS
vendored
3
.github/CODEOWNERS
vendored
@ -2,7 +2,8 @@
|
||||
# the repo. Unless a later match takes precedence,
|
||||
# @wsdjeg will be requested for review when someone opens a
|
||||
# pull request.
|
||||
* @wsdjeg
|
||||
# Just watching this repo, disable duplicate message
|
||||
# * @wsdjeg
|
||||
|
||||
# lang#julia layer
|
||||
autoload/SpaceVim/layers/lang/julia.vim @jingpengw
|
||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -30,3 +30,6 @@ cscope.po.out
|
||||
build/
|
||||
.coverage.covimerage
|
||||
*.swp
|
||||
.gtm/
|
||||
.metadata/
|
||||
jdt.ls-java-project/
|
||||
|
@ -13,8 +13,14 @@
|
||||
"wiki/cn/Following-HEAD.md": {"alternate": "wiki/en/Following-HEAD.md"},
|
||||
"docs/_posts/2017-02-11-use-vim-as-a-java-ide.md": {"alternate": "docs/_posts/2018-09-19-use-vim-as-a-java-ide.md"},
|
||||
"docs/_posts/2018-09-19-use-vim-as-a-java-ide.md": {"alternate": "docs/_posts/2017-02-11-use-vim-as-a-java-ide.md"},
|
||||
"docs/_posts/2019-01-28-use-vim-as-a-coffeescript-ide.md": {"alternate": "docs/_posts/2019-01-29-use-vim-as-a-coffeescript-ide.md"},
|
||||
"docs/_posts/2019-01-29-use-vim-as-a-coffeescript-ide.md": {"alternate": "docs/_posts/2019-01-28-use-vim-as-a-coffeescript-ide.md"},
|
||||
"docs/_posts/2018-09-27-use-vim-as-a-python-ide.md": {"alternate": "docs/_posts/2018-09-28-use-vim-as-a-python-ide.md"},
|
||||
"docs/_posts/2018-09-28-use-vim-as-a-python-ide.md": {"alternate": "docs/_posts/2018-09-27-use-vim-as-a-python-ide.md"},
|
||||
"docs/_posts/2019-02-11-use-vim-as-a-perl-ide.md": {"alternate": "docs/_posts/2019-02-12-use-vim-as-a-perl-ide.md"},
|
||||
"docs/_posts/2019-02-12-use-vim-as-a-perl-ide.md": {"alternate": "docs/_posts/2019-02-11-use-vim-as-a-perl-ide.md"},
|
||||
"docs/_posts/2019-02-17-use-vim-as-a-ruby-ide.md": {"alternate": "docs/_posts/2019-02-18-use-vim-as-a-ruby-ide.md"},
|
||||
"docs/_posts/2019-02-18-use-vim-as-a-ruby-ide.md": {"alternate": "docs/_posts/2019-02-17-use-vim-as-a-ruby-ide.md"},
|
||||
"docs/_posts/2018-09-27-use-vim-as-ide.md": {"alternate": "docs/_posts/2018-09-28-use-vim-as-ide.md"},
|
||||
"docs/_posts/2018-01-23-grep-on-the-fly-in-spacevim.md": {"alternate": "docs/_posts/2018-01-31-grep-on-the-fly-in-spacevim.md"},
|
||||
"docs/_posts/2018-01-31-grep-on-the-fly-in-spacevim.md": {"alternate": "docs/_posts/2018-01-23-grep-on-the-fly-in-spacevim.md"},
|
||||
|
@ -32,7 +32,7 @@ Github: <https://github.com/SpaceVim/SpaceVim>
|
||||
|
||||
<!-- vim-markdown-toc GFM -->
|
||||
|
||||
- [最新特新](#最新特新)
|
||||
- [最新特性](#最新特性)
|
||||
- [多光标 Iedit 模式](#多光标-iedit-模式)
|
||||
- [高亮光标下的函数](#高亮光标下的函数)
|
||||
- [实时代码检索](#实时代码检索)
|
||||
@ -46,7 +46,7 @@ Github: <https://github.com/SpaceVim/SpaceVim>
|
||||
|
||||
<!-- vim-markdown-toc -->
|
||||
|
||||
## 最新特新
|
||||
## 最新特性
|
||||
|
||||
以下为 SpaceVim 中最新实现的一些特性:
|
||||
|
||||
@ -62,7 +62,7 @@ SpaceVim 内置了一种特殊的模式,Iedit 模式,这种模式提供了
|
||||
|
||||
SpaceVim 支持高亮当前光标函数,并且启动一个特殊模式,在该模式下可以快捷地切换高亮区域
|
||||
(方法内、屏幕内、整个文件内),并且可以快速在高亮函数间跳转、切换高亮状态(高亮、取消高亮),
|
||||
并且可以根据已选择的位置计入 Iedit 模式。
|
||||
并且可以根据已选择的位置进入 Iedit 模式。
|
||||
|
||||
![highlight cursor symbol](https://user-images.githubusercontent.com/13142418/36210381-e6dffde6-1163-11e8-9b35-0bf262e6f22b.gif)
|
||||
|
||||
@ -94,7 +94,7 @@ SpaceVim 利用了 Vim 8 和 Neovim 最新的异步机制,实现了异步插
|
||||
|
||||
![UI for dein](https://user-images.githubusercontent.com/13142418/34907332-903ae968-f842-11e7-8ac9-07fcc9940a53.gif)
|
||||
|
||||
想要获取更多关于 SpaceVim 的最新特新,请关注 [SpaceVim 官方博客](https://spacevim.org/blog/)
|
||||
想要获取更多关于 SpaceVim 的最新特性,请关注 [SpaceVim 官方博客](https://spacevim.org/blog/)
|
||||
|
||||
## 安装
|
||||
|
||||
|
23
README.md
23
README.md
@ -59,13 +59,13 @@ This is a list of latest features implemented in SpaceVim:
|
||||
Here is an example for using toml as SpaceVim config:
|
||||
|
||||
```toml
|
||||
# This is basic configuration example for SpaceVim
|
||||
# This is basic configuration example for SpaceVim.
|
||||
|
||||
# All SpaceVim options below [option] section
|
||||
# All SpaceVim options below [options] snippet.
|
||||
[options]
|
||||
# set spacevim theme. by default colorscheme layer is not loaded,
|
||||
# if you want to use more colorschemes, please load the colorscheme
|
||||
# layer
|
||||
# Set SpaceVim theme. By default colorscheme layer is not loaded.
|
||||
# If you want to use more colorschemes, please load the colorscheme
|
||||
# layer.
|
||||
colorscheme = "gruvbox"
|
||||
colorscheme_bg = "dark"
|
||||
# Disable guicolors in basic mode, many terminal do not support 24bit
|
||||
@ -85,14 +85,14 @@ Here is an example for using toml as SpaceVim config:
|
||||
|
||||
# Enable autocomplete layer
|
||||
[[layers]]
|
||||
name = 'autocomplete'
|
||||
auto-completion-return-key-behavior = "complete"
|
||||
auto-completion-tab-key-behavior = "cycle"
|
||||
name = 'autocomplete'
|
||||
auto-completion-return-key-behavior = "complete"
|
||||
auto-completion-tab-key-behavior = "cycle"
|
||||
|
||||
[[layers]]
|
||||
name = 'shell'
|
||||
default_position = 'top'
|
||||
default_height = 30
|
||||
name = 'shell'
|
||||
default_position = 'top'
|
||||
default_height = 30
|
||||
```
|
||||
|
||||
**Iedit mode**
|
||||
@ -177,6 +177,7 @@ Bitcoin: 1DtuVeg81c2L9NEhDaVTAAbrCR3pN5xPFv
|
||||
### Credits & Thanks
|
||||
|
||||
This project exists to thank all the people who have [contributed](CONTRIBUTING.md):
|
||||
|
||||
<a href="https://github.com/SpaceVim/SpaceVim/graphs/contributors"><img src="https://opencollective.com/spacevim/contributors.svg?width=890&button=false" /></a>
|
||||
|
||||
- [@Gabirel](https://github.com/Gabirel) and his [Hack-SpaceVim](https://github.com/Gabirel/Hack-SpaceVim)
|
||||
|
@ -498,8 +498,16 @@ let g:spacevim_colorscheme_default = 'desert'
|
||||
let g:spacevim_simple_mode = 0
|
||||
""
|
||||
" The default file manager of SpaceVim. Default is 'vimfiler'.
|
||||
" you can also use nerdtree or defx
|
||||
let g:spacevim_filemanager = 'vimfiler'
|
||||
|
||||
""
|
||||
" Config the direction of file tree. Default is 'right'. you can also set to
|
||||
" 'left'.
|
||||
"
|
||||
" NOTE: if it is 'left', the tagbar will be move to right.
|
||||
let g:spacevim_filetree_direction = 'right'
|
||||
|
||||
let g:spacevim_sidebar_direction = ''
|
||||
""
|
||||
" The default plugin manager of SpaceVim.
|
||||
@ -685,6 +693,7 @@ let g:spacevim_smartcloseignorewin = ['__Tagbar__' , 'vimfiler:default']
|
||||
let g:spacevim_smartcloseignoreft = [
|
||||
\ 'tagbar',
|
||||
\ 'vimfiler',
|
||||
\ 'defx',
|
||||
\ 'SpaceVimRunner',
|
||||
\ 'SpaceVimREPL',
|
||||
\ 'SpaceVimQuickFix',
|
||||
@ -832,7 +841,7 @@ function! SpaceVim#end() abort
|
||||
endif
|
||||
""
|
||||
" generate tags for SpaceVim
|
||||
let help = fnamemodify(g:_spacevim_root_dir, ':p:h:h') . '/doc'
|
||||
let help = fnamemodify(g:_spacevim_root_dir, ':p:h') . '/doc'
|
||||
try
|
||||
exe 'helptags ' . help
|
||||
catch
|
||||
@ -963,6 +972,9 @@ function! SpaceVim#welcome() abort
|
||||
if exists(':VimFiler') == 2
|
||||
VimFiler
|
||||
wincmd p
|
||||
elseif exists(':Defx') == 2
|
||||
Defx
|
||||
wincmd p
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
@ -8,14 +8,17 @@
|
||||
|
||||
let s:self = {}
|
||||
|
||||
let s:completer = fnamemodify(g:_spacevim_root_dir, ':p:h:h') . '/autoload/SpaceVim/bin/get_complete'
|
||||
let s:completer = g:_spacevim_root_dir . '/autoload/SpaceVim/bin/get_complete'
|
||||
|
||||
let s:COP = SpaceVim#api#import('vim#compatible')
|
||||
|
||||
" this is for vim command completion
|
||||
|
||||
" @vimlint(EVL103, 1, a:ArgLead)
|
||||
" @vimlint(EVL103, 1, a:CmdLine)
|
||||
" @vimlint(EVL103, 1, a:CursorPos)
|
||||
function! s:self.complete(ArgLead, CmdLine, CursorPos) abort
|
||||
if a:CmdLine =~ '^\s\{0,\}\w\+$'
|
||||
if a:CmdLine =~? '^\s\{0,\}\w\+$'
|
||||
return s:COP.systemlist('compgen -c ' . a:CmdLine)
|
||||
endif
|
||||
let result = s:COP.systemlist([s:completer, a:CmdLine])
|
||||
@ -26,11 +29,11 @@ endfunction
|
||||
" this is for vim input()
|
||||
|
||||
function! s:self.complete_input(ArgLead, CmdLine, CursorPos) abort
|
||||
if a:CmdLine =~ '^\s\{0,\}\w\+$'
|
||||
if a:CmdLine =~? '^\s\{0,\}\w\+$'
|
||||
return s:COP.systemlist('compgen -c ' . a:CmdLine)
|
||||
endif
|
||||
let result = s:COP.systemlist([s:completer, a:CmdLine])
|
||||
if a:ArgLead == ''
|
||||
if a:ArgLead ==# ''
|
||||
let result = map(result, 'a:CmdLine . v:val')
|
||||
else
|
||||
let leader = substitute(a:CmdLine, '[^ ]*$', '', 'g')
|
||||
@ -39,9 +42,12 @@ function! s:self.complete_input(ArgLead, CmdLine, CursorPos) abort
|
||||
return result
|
||||
|
||||
endfunction
|
||||
" @vimlint(EVL103, 0, a:ArgLead)
|
||||
" @vimlint(EVL103, 0, a:CmdLine)
|
||||
" @vimlint(EVL103, 0, a:CursorPos)
|
||||
|
||||
|
||||
function! SpaceVim#api#bash#complete#get()
|
||||
function! SpaceVim#api#bash#complete#get() abort
|
||||
|
||||
return deepcopy(s:self)
|
||||
|
||||
|
@ -69,7 +69,7 @@ endfunction
|
||||
|
||||
function! s:self.str2nr(str) abort
|
||||
let nr = get(self._deps.swap(self._color_map), a:str, -1)
|
||||
if nr =~ 'fg\|bg\|NONE'
|
||||
if nr =~# 'fg\|bg\|NONE'
|
||||
return nr
|
||||
else
|
||||
return str2nr(nr)
|
||||
|
@ -60,7 +60,7 @@ function! s:pop(list) abort
|
||||
return remove(a:list, -1)
|
||||
endfunction
|
||||
|
||||
function! s:listpart(list, start, ...)
|
||||
function! s:listpart(list, start, ...) abort
|
||||
let idx = range(a:start, a:start + get(a:000, 0, 0))
|
||||
let rst = []
|
||||
for i in idx
|
||||
@ -140,7 +140,7 @@ function! s:has_index(list, index) abort
|
||||
return 0 <= a:index && a:index < len(a:list)
|
||||
endfunction
|
||||
|
||||
function! s:replace(list, begin, end, re_list)
|
||||
function! s:replace(list, begin, end, re_list) abort
|
||||
if a:begin <= a:end && a:begin >= 0 && a:end < len(a:list)
|
||||
return a:list[:a:begin - 1] + a:re_list + a:list[a:end + 1:]
|
||||
else
|
||||
|
@ -16,6 +16,14 @@
|
||||
" split(str [, sep [, keepempty[, max]]])
|
||||
"
|
||||
" run vim command, and return the output of such command.
|
||||
"
|
||||
" trim(str)
|
||||
"
|
||||
" remove space at the begin and end of a string, same as |trim()|
|
||||
"
|
||||
" fill(str, length[, char])
|
||||
"
|
||||
" fill string to length with {char}, if {char} is omnit, a space is used.
|
||||
|
||||
let s:self = {}
|
||||
|
||||
@ -24,44 +32,55 @@ function! s:self.trim(str) abort
|
||||
return substitute(str, '^\s*', '', 'g')
|
||||
endfunction
|
||||
|
||||
function! s:self.fill(str, length) abort
|
||||
function! s:self.fill(str, length, ...) abort
|
||||
if strwidth(a:str) <= a:length
|
||||
return a:str . repeat(' ', a:length - strwidth(a:str))
|
||||
let l:string = a:str
|
||||
else
|
||||
let l = 0
|
||||
for i in range(strchars(a:str) - 1)
|
||||
if strwidth(strcharpart(a:str, 0, i)) > a:length
|
||||
break
|
||||
else
|
||||
let l = i
|
||||
endif
|
||||
endfor
|
||||
let str = strcharpart(a:str, 0, l)
|
||||
return str . repeat(' ', a:length - strwidth(str))
|
||||
let l:rightmost = 0
|
||||
while strwidth(strcharpart(a:str, 0, l:rightmost)) < a:length
|
||||
let l:rightmost += 1
|
||||
endwhile
|
||||
let l:string = strcharpart(a:str, 0, l:rightmost)
|
||||
endif
|
||||
let char = get(a:000, 0, ' ')
|
||||
if type(char) !=# 1 || len(char) > 1
|
||||
let char = ' '
|
||||
endif
|
||||
let l:spaces = repeat(char, a:length - strwidth(l:string))
|
||||
return l:string . l:spaces
|
||||
endfunction
|
||||
|
||||
function! s:self.fill_middle(str, length) abort
|
||||
function! s:self.fill_left(str, length, ...) abort
|
||||
if strwidth(a:str) <= a:length
|
||||
"return a:str . repeat(' ', a:length - strwidth(a:str))
|
||||
let n = a:length - strwidth(a:str)
|
||||
if n % 2 == 0
|
||||
return repeat(' ', (a:length - strwidth(a:str))/2) . a:str . repeat(' ', (a:length - strwidth(a:str))/2)
|
||||
else
|
||||
return repeat(' ', (a:length - strwidth(a:str))/2) . a:str . repeat(' ', (a:length + 1 - strwidth(a:str))/2)
|
||||
endif
|
||||
let l:string = a:str
|
||||
else
|
||||
let l = 0
|
||||
for i in range(strchars(a:str) - 1)
|
||||
if strwidth(strcharpart(a:str, 0, i)) > a:length
|
||||
break
|
||||
else
|
||||
let l = i
|
||||
endif
|
||||
endfor
|
||||
let str = strcharpart(a:str, 0, l)
|
||||
return str . repeat(' ', a:length - strwidth(str))
|
||||
let l:string = strcharpart(a:str, strwidth(a:str) - a:length, a:length)
|
||||
endif
|
||||
let char = get(a:000, 0, ' ')
|
||||
if type(char) !=# 1 || len(char) > 1
|
||||
let char = ' '
|
||||
endif
|
||||
let l:spaces = repeat(char, a:length - strwidth(l:string))
|
||||
return l:spaces . l:string
|
||||
endfunction
|
||||
|
||||
function! s:self.fill_middle(str, length, ...) abort
|
||||
if strwidth(a:str) <= a:length
|
||||
let l:string = a:str
|
||||
else
|
||||
let l:string = strcharpart(a:str, (a:length/2 < 1 ? 1 : a:length/2), a:length)
|
||||
endif
|
||||
let l:numofspaces = a:length - strwidth(l:string)
|
||||
let char = get(a:000, 0, ' ')
|
||||
if type(char) !=# 1 || len(char) > 1
|
||||
let char = ' '
|
||||
endif
|
||||
let l:halfspaces = repeat(char, l:numofspaces/2)
|
||||
let l:rst = l:halfspaces . l:string . l:halfspaces
|
||||
if l:numofspaces % 2
|
||||
let l:rst .= char
|
||||
endif
|
||||
return l:rst
|
||||
endfunction
|
||||
|
||||
function! s:self.trim_start(str) abort
|
||||
@ -72,11 +91,17 @@ function! s:self.trim_end(str) abort
|
||||
return substitute(a:str, '\s*$', '', 'g')
|
||||
endfunction
|
||||
|
||||
|
||||
" note: this function only works when encoding is utf-8
|
||||
" ref: https://github.com/SpaceVim/SpaceVim/pull/2515
|
||||
function! s:self.string2chars(str) abort
|
||||
let save_enc = &encoding
|
||||
let &encoding = 'utf-8'
|
||||
let chars = []
|
||||
for i in range(len(a:str))
|
||||
call add(chars, a:str[i : i])
|
||||
for i in range(strchars(a:str))
|
||||
call add(chars, strcharpart(a:str, i , 1))
|
||||
endfor
|
||||
let &encoding = save_enc
|
||||
return chars
|
||||
endfunction
|
||||
|
||||
@ -101,13 +126,15 @@ function! s:self.strAllIndex(str, need, use_expr) abort
|
||||
endfunction
|
||||
|
||||
function! s:self.strQ2B(str) abort
|
||||
let save_enc = &encoding
|
||||
let &encoding = 'utf-8'
|
||||
let chars = self.string2chars(a:str)
|
||||
let bchars = []
|
||||
for char in chars
|
||||
let nr = char2nr(char)
|
||||
if nr == 12288
|
||||
call add(bchars, nr2char(32))
|
||||
elseif nr == 8216 && nr == 8217
|
||||
elseif nr == 8216 || nr == 8217
|
||||
call add(bchars, nr2char(39))
|
||||
elseif nr >= 65281 && nr <= 65374
|
||||
call add(bchars, nr2char(nr - 65248))
|
||||
@ -115,10 +142,13 @@ function! s:self.strQ2B(str) abort
|
||||
call add(bchars, char)
|
||||
endif
|
||||
endfor
|
||||
let &encoding = save_enc
|
||||
return join(bchars, '')
|
||||
endfunction
|
||||
|
||||
function! s:self.strB2Q(str) abort
|
||||
let save_enc = &encoding
|
||||
let &encoding = 'utf-8'
|
||||
let chars = self.string2chars(a:str)
|
||||
let bchars = []
|
||||
for char in chars
|
||||
@ -131,6 +161,7 @@ function! s:self.strB2Q(str) abort
|
||||
call add(bchars, char)
|
||||
endif
|
||||
endfor
|
||||
let &encoding = save_enc
|
||||
return join(bchars, '')
|
||||
|
||||
endfunction
|
||||
|
@ -222,13 +222,29 @@ endfunction
|
||||
|
||||
let s:file['updateFiles'] = function('s:updatefiles')
|
||||
|
||||
" this function should return a unify path
|
||||
" 1. the sep is /
|
||||
" 2. if it is a dir, end with /
|
||||
" 3. if a:path end with /, then return path also end with /
|
||||
function! s:unify_path(path, ...) abort
|
||||
let mod = a:0 > 0 ? a:1 : ':p'
|
||||
return resolve(fnamemodify(a:path, mod . ':gs?[\\/]?/?'))
|
||||
let path = resolve(fnamemodify(a:path, mod . ':gs?[\\/]?/?'))
|
||||
if isdirectory(path) && path[-1:] !=# '/'
|
||||
return path . '/'
|
||||
elseif a:path[-1:] ==# '/' && path[-1:] !=# '/'
|
||||
return path . '/'
|
||||
else
|
||||
return path
|
||||
endif
|
||||
endfunction
|
||||
|
||||
let s:file['unify_path'] = function('s:unify_path')
|
||||
|
||||
function! s:path_to_fname(path) abort
|
||||
return substitute(s:unify_path(a:path), '[\\/:;.]', '_', 'g')
|
||||
endfunction
|
||||
|
||||
let s:file['path_to_fname'] = function('s:path_to_fname')
|
||||
|
||||
function! SpaceVim#api#file#get() abort
|
||||
return deepcopy(s:file)
|
||||
|
@ -272,6 +272,17 @@ function! s:self.info(id) abort
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:self.chanclose(id, type) abort
|
||||
if self.nvim_job
|
||||
call chanclose(a:id, a:type)
|
||||
elseif self.vim_job
|
||||
if has_key(self.jobs, a:id) && a:type ==# 'stdin'
|
||||
call ch_close_in(get(self.jobs, a:id))
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:self.debug() abort
|
||||
echo join(self._message, "\n")
|
||||
endfunction
|
||||
|
@ -14,7 +14,7 @@ let s:self._title = 'Transient State'
|
||||
let s:self._handle_inputs = {}
|
||||
let s:self._is_quit = []
|
||||
let s:self._handle_quit = {}
|
||||
let s:self.noredraw = 0
|
||||
let s:self._clear_cmdline = 1
|
||||
let s:self._cmp = SpaceVim#api#import('vim#compatible')
|
||||
|
||||
function! s:self.open() abort
|
||||
@ -54,17 +54,15 @@ function! s:self.open() abort
|
||||
while 1
|
||||
if has_key(self._keys, 'logo')
|
||||
noautocmd wincmd p
|
||||
if self.noredraw
|
||||
redraw!
|
||||
endif
|
||||
call call(self._keys.logo, [])
|
||||
noautocmd wincmd p
|
||||
endif
|
||||
if !self.noredraw
|
||||
redraw!
|
||||
if self._clear_cmdline
|
||||
normal! :
|
||||
else
|
||||
let self.noredraw = 0
|
||||
let self._clear_cmdline = 1
|
||||
endif
|
||||
redraw
|
||||
let char = self._getchar()
|
||||
if char ==# "\<FocusLost>" || char ==# "\<FocusGained>" || char2nr(char) == 128
|
||||
continue
|
||||
@ -91,7 +89,12 @@ function! s:self.open() abort
|
||||
exe self._handle_quit[char]
|
||||
endif
|
||||
endif
|
||||
redraw!
|
||||
if self._clear_cmdline
|
||||
normal! :
|
||||
else
|
||||
let self._clear_cmdline = 1
|
||||
endif
|
||||
redraw
|
||||
endfunction
|
||||
|
||||
|
||||
|
@ -23,7 +23,7 @@ function! s:self.battery_status(v) abort
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#api#unicode#icon#get()
|
||||
function! SpaceVim#api#unicode#icon#get() abort
|
||||
|
||||
return deepcopy(s:self)
|
||||
|
||||
|
@ -61,9 +61,9 @@ function! s:self.complete(ArgLead, CmdLine, CursorPos) abort
|
||||
let msg = 'ArgLead: ' . a:ArgLead . ' CmdLine: ' . a:CmdLine . ' CursorPos: '
|
||||
\ . a:CursorPos . ' LastArgv: ' . last_argv
|
||||
call add(self._message, msg)
|
||||
if a:ArgLead == '' && index(keys(self.options), last_argv) == -1
|
||||
if a:ArgLead ==# '' && index(keys(self.options), last_argv) == -1
|
||||
return join(keys(self.options), "\n")
|
||||
elseif a:ArgLead == '' && index(keys(self.options), last_argv) != -1
|
||||
elseif a:ArgLead ==# '' && index(keys(self.options), last_argv) != -1
|
||||
return self._complete_opt(a:ArgLead, last_argv)
|
||||
elseif !empty(a:ArgLead) && len(argvs) >= 3
|
||||
\ && index(keys(self.options), argvs[-2]) != -1
|
||||
@ -85,9 +85,9 @@ function! s:self.completelist(ArgLead, CmdLine, CursorPos) abort
|
||||
let msg = 'ArgLead: ' . a:ArgLead . ' CmdLine: ' . a:CmdLine . ' CursorPos: '
|
||||
\ . a:CursorPos . ' LastArgv: ' . last_argv
|
||||
call add(self._message, msg)
|
||||
if a:ArgLead == '' && index(keys(self.options), last_argv) == -1
|
||||
if a:ArgLead ==# '' && index(keys(self.options), last_argv) == -1
|
||||
return keys(self.options)
|
||||
elseif a:ArgLead == '' && index(keys(self.options), last_argv) != -1
|
||||
elseif a:ArgLead ==# '' && index(keys(self.options), last_argv) != -1
|
||||
return self._complete_opt_list(a:ArgLead, last_argv)
|
||||
elseif !empty(a:ArgLead) && len(argvs) >= 3
|
||||
\ && index(keys(self.options), argvs[-2]) != -1
|
||||
@ -108,7 +108,7 @@ endfunction
|
||||
|
||||
|
||||
|
||||
function! SpaceVim#api#vim#command#get()
|
||||
function! SpaceVim#api#vim#command#get() abort
|
||||
return deepcopy(s:self)
|
||||
endfunction
|
||||
|
||||
|
@ -6,10 +6,11 @@
|
||||
" License: GPLv3
|
||||
"=============================================================================
|
||||
|
||||
scriptencoding utf-8
|
||||
|
||||
let s:has_cache = {}
|
||||
|
||||
|
||||
let s:SYS = SpaceVim#api#import('system')
|
||||
|
||||
""
|
||||
" @section vim#compatible, api-vim-compatible
|
||||
@ -112,9 +113,11 @@ elseif s:self.has('python3')
|
||||
\ py3eval('vim.windows[' . a:nr . '].col')]
|
||||
endfunction
|
||||
else
|
||||
" @vimlint(EVL103, 1, a:nr)
|
||||
function! s:self.win_screenpos(nr) abort
|
||||
return [0, 0]
|
||||
endfunction
|
||||
" @vimlint(EVL103, 0, a:nr)
|
||||
endif
|
||||
|
||||
if exists('*execute')
|
||||
@ -290,7 +293,7 @@ else
|
||||
let result = []
|
||||
" 20 281 23 -invalid-
|
||||
for info in jumpinfo
|
||||
let [jump, line, col, file_text] = s:STRING.split(info, '', 0, 4)
|
||||
let [jump, line, col] = s:STRING.split(info, '', 0, 4)[0:2]
|
||||
call add(result, {
|
||||
\ 'bufnr' : jump,
|
||||
\ 'lnum' : line,
|
||||
@ -301,6 +304,25 @@ else
|
||||
endfunction
|
||||
endif
|
||||
|
||||
if s:SYS.isWindows
|
||||
function! s:self.resolve(path) abort
|
||||
let cmd = 'dir /a "' . a:path . '" | findstr SYMLINK'
|
||||
" 2018/12/07 周五 下午 10:23 <SYMLINK> vimfiles [C:\Users\Administrator\.SpaceVim]
|
||||
" ref: https://superuser.com/questions/524669/checking-where-a-symbolic-link-points-at-in-windows-7
|
||||
silent let rst = system(cmd)
|
||||
if !v:shell_error
|
||||
let dir = split(rst)[-1][1:-2]
|
||||
return dir
|
||||
endif
|
||||
return a:path
|
||||
endfunction
|
||||
else
|
||||
function! s:self.resolve(path) abort
|
||||
return resolve(a:path)
|
||||
endfunction
|
||||
endif
|
||||
|
||||
|
||||
|
||||
function! SpaceVim#api#vim#compatible#get() abort
|
||||
return deepcopy(s:self)
|
||||
|
@ -33,6 +33,6 @@ function! s:self.nr2name(nr) abort
|
||||
endfunction
|
||||
|
||||
|
||||
function! SpaceVim#api#vim#key#get()
|
||||
function! SpaceVim#api#vim#key#get() abort
|
||||
return deepcopy(s:self)
|
||||
endfunction
|
||||
|
@ -46,6 +46,8 @@ function! s:self.confirm(msg) abort
|
||||
echon a:msg . '? (y or n) '
|
||||
echohl NONE
|
||||
let rst = nr2char(getchar())
|
||||
" clear the cmdline
|
||||
redraw!
|
||||
if rst =~? 'y' || rst == nr2char(13)
|
||||
return 1
|
||||
else
|
||||
|
@ -30,7 +30,7 @@ function! s:self.get_tree() abort
|
||||
endfunction
|
||||
|
||||
function! s:self.realTabBuffers(id) abort
|
||||
return filter(copy(tabpagebuflist(a:id)), 'buflisted(v:val) && getbufvar(v:val, "&buftype") == ""')
|
||||
return filter(copy(tabpagebuflist(a:id)), 'buflisted(v:val) && getbufvar(v:val, "&buftype") ==# ""')
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#api#vim#tab#get() abort
|
||||
|
@ -20,7 +20,6 @@ function! SpaceVim#autocmds#init() abort
|
||||
autocmd BufEnter * if (winnr('$') == 1 && &buftype ==# 'quickfix' ) |
|
||||
\ bd|
|
||||
\ q | endif
|
||||
autocmd FileType jsp call JspFileTypeInit()
|
||||
autocmd QuitPre * call SpaceVim#plugins#windowsmanager#UpdateRestoreWinInfo()
|
||||
autocmd WinEnter * call SpaceVim#plugins#windowsmanager#MarkBaseWin()
|
||||
autocmd BufRead,BufNewFile *.pp setfiletype puppet
|
||||
@ -37,17 +36,13 @@ function! SpaceVim#autocmds#init() abort
|
||||
\ exe "normal! g`\"" |
|
||||
\ endif
|
||||
autocmd BufNewFile,BufEnter * set cpoptions+=d " NOTE: ctags find the tags file from the current path instead of the path of currect file
|
||||
autocmd BufLeave * let b:winview = winsaveview()
|
||||
autocmd BufEnter * if(exists('b:winview')) | call winrestview(b:winview) | endif
|
||||
autocmd BufWinLeave * let b:_winview = winsaveview()
|
||||
autocmd BufWinEnter * if(exists('b:_winview')) | call winrestview(b:_winview) | endif
|
||||
autocmd BufEnter * :syntax sync fromstart " ensure every file does syntax highlighting (full)
|
||||
autocmd BufNewFile,BufRead *.avs set syntax=avs " for avs syntax file.
|
||||
autocmd FileType c,cpp,java,javascript set comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,://
|
||||
autocmd FileType cs set comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,:///,://
|
||||
autocmd FileType vim set comments=sO:\"\ -,mO:\"\ \ ,eO:\"\",:\"
|
||||
autocmd FileType lua set comments=f:--
|
||||
autocmd FileType xml call XmlFileTypeInit()
|
||||
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
|
||||
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
|
||||
autocmd Filetype qf setlocal nobuflisted
|
||||
autocmd FileType python,coffee call zvim#util#check_if_expand_tab()
|
||||
au StdinReadPost * call s:disable_welcome()
|
||||
|
@ -9,6 +9,7 @@
|
||||
let s:TOML = SpaceVim#api#import('data#toml')
|
||||
let s:JSON = SpaceVim#api#import('data#json')
|
||||
let s:FILE = SpaceVim#api#import('file')
|
||||
let s:CMP = SpaceVim#api#import('vim#compatible')
|
||||
|
||||
function! SpaceVim#custom#profile(dict) abort
|
||||
for key in keys(a:dict)
|
||||
@ -46,14 +47,14 @@ endfunction
|
||||
|
||||
function! s:awesome_mode() abort
|
||||
let sep = s:FILE.separator
|
||||
let f = fnamemodify(g:_spacevim_root_dir, ':h') . join(['', 'mode', 'dark_powered.toml'], sep)
|
||||
let f = g:_spacevim_root_dir . join(['', 'mode', 'dark_powered.toml'], sep)
|
||||
let config = readfile(f, '')
|
||||
call s:write_to_config(config)
|
||||
endfunction
|
||||
|
||||
function! s:basic_mode() abort
|
||||
let sep = s:FILE.separator
|
||||
let f = fnamemodify(g:_spacevim_root_dir, ':h') . join(['', 'mode', 'basic.toml'], sep)
|
||||
let f = g:_spacevim_root_dir . join(['', 'mode', 'basic.toml'], sep)
|
||||
let config = readfile(f, '')
|
||||
call s:write_to_config(config)
|
||||
endfunction
|
||||
@ -133,8 +134,8 @@ endfunction
|
||||
function! SpaceVim#custom#load() abort
|
||||
" if file .SpaceVim.d/init.toml exist
|
||||
if filereadable('.SpaceVim.d/init.toml')
|
||||
let g:_spacevim_config_path = fnamemodify('.SpaceVim.d/init.toml', ':p')
|
||||
let &rtp = fnamemodify('.SpaceVim.d', ':p:h') . ',' . &rtp
|
||||
let g:_spacevim_config_path = s:CMP.resolve(fnamemodify('.SpaceVim.d/init.toml', ':p'))
|
||||
let &rtp = s:FILE.unify_path(s:CMP.resolve(fnamemodify('.SpaceVim.d', ':p:h'))) . ',' . &rtp
|
||||
let local_conf = g:_spacevim_config_path
|
||||
call SpaceVim#logger#info('find local conf: ' . local_conf)
|
||||
let local_conf_cache = s:path_to_fname(local_conf)
|
||||
@ -154,7 +155,7 @@ function! SpaceVim#custom#load() abort
|
||||
endif
|
||||
elseif filereadable('.SpaceVim.d/init.vim')
|
||||
let g:_spacevim_config_path = fnamemodify('.SpaceVim.d/init.vim', ':p')
|
||||
let &rtp = fnamemodify('.SpaceVim.d', ':p:h') . ',' . &rtp
|
||||
let &rtp = s:FILE.unify_path(s:CMP.resolve(fnamemodify('.SpaceVim.d', ':p:h'))) . ',' . &rtp
|
||||
let local_conf = g:_spacevim_config_path
|
||||
call SpaceVim#logger#info('find local conf: ' . local_conf)
|
||||
exe 'source .SpaceVim.d/init.vim'
|
||||
@ -176,11 +177,11 @@ endfunction
|
||||
|
||||
|
||||
function! s:load_glob_conf() abort
|
||||
let global_dir = empty($SPACEVIMDIR) ? expand('~/.SpaceVim.d') : $SPACEVIMDIR
|
||||
if filereadable(global_dir . '/init.toml')
|
||||
let g:_spacevim_global_config_path = global_dir . '/init.toml'
|
||||
let local_conf = global_dir . '/init.toml'
|
||||
let local_conf_cache = expand('~/.cache/SpaceVim/conf/init.json')
|
||||
let global_dir = empty($SPACEVIMDIR) ? s:FILE.unify_path(s:CMP.resolve(expand('~/.SpaceVim.d/'))) : $SPACEVIMDIR
|
||||
if filereadable(global_dir . 'init.toml')
|
||||
let g:_spacevim_global_config_path = global_dir . 'init.toml'
|
||||
let local_conf = global_dir . 'init.toml'
|
||||
let local_conf_cache = s:FILE.unify_path(expand('~/.cache/SpaceVim/conf/init.json'))
|
||||
let &rtp = global_dir . ',' . &rtp
|
||||
if getftime(local_conf) < getftime(local_conf_cache)
|
||||
let conf = s:JSON.json_decode(join(readfile(local_conf_cache, ''), ''))
|
||||
@ -190,9 +191,9 @@ function! s:load_glob_conf() abort
|
||||
call writefile([s:JSON.json_encode(conf)], local_conf_cache)
|
||||
call SpaceVim#custom#apply(conf, 'glob')
|
||||
endif
|
||||
elseif filereadable(global_dir . '/init.vim')
|
||||
let g:_spacevim_global_config_path = global_dir . '/init.vim'
|
||||
let custom_glob_conf = global_dir . '/init.vim'
|
||||
elseif filereadable(global_dir . 'init.vim')
|
||||
let g:_spacevim_global_config_path = global_dir . 'init.vim'
|
||||
let custom_glob_conf = global_dir . 'init.vim'
|
||||
let &rtp = global_dir . ',' . &rtp
|
||||
exe 'source ' . custom_glob_conf
|
||||
else
|
||||
|
@ -24,7 +24,7 @@ endfunction
|
||||
function! s:spacevim_status() abort
|
||||
let pwd = getcwd()
|
||||
try
|
||||
exe 'cd ' . fnamemodify(g:_spacevim_root_dir, ':p:h:h')
|
||||
exe 'cd ' . fnamemodify(g:_spacevim_root_dir, ':p:h')
|
||||
let status = s:CMP.systemlist('git status')
|
||||
catch
|
||||
exe 'cd ~/.SpaceVim'
|
||||
@ -90,7 +90,7 @@ function! SpaceVim#issue#new() abort
|
||||
endfunction
|
||||
|
||||
|
||||
function! SpaceVim#issue#reopen(id)
|
||||
function! SpaceVim#issue#reopen(id) abort
|
||||
let issue = {
|
||||
\ 'state' : 'open'
|
||||
\ }
|
||||
|
@ -90,7 +90,7 @@ function! s:find_layers() abort
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#get() abort
|
||||
return s:enabled_layers
|
||||
return deepcopy(s:enabled_layers)
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#isLoaded(layer) abort
|
||||
|
@ -10,9 +10,11 @@ scriptencoding utf-8
|
||||
|
||||
let s:CMP = SpaceVim#api#import('vim#compatible')
|
||||
|
||||
let s:enable_gtm_status = 0
|
||||
|
||||
function! SpaceVim#layers#VersionControl#plugins() abort
|
||||
let plugins = []
|
||||
call add(plugins, ['mhinz/vim-signify', {'merged' : 0}])
|
||||
call add(plugins, ['mhinz/vim-signify', {'merged' : 0, 'loadconf' : 1}])
|
||||
call add(plugins, ['tpope/vim-fugitive', { 'merged' : 0}])
|
||||
return plugins
|
||||
endfunction
|
||||
@ -31,28 +33,76 @@ function! SpaceVim#layers#VersionControl#config() abort
|
||||
\ 'version control info', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['t', 'm', 'h'], 'call SpaceVim#layers#core#statusline#toggle_section("hunks")',
|
||||
\ 'toggle the hunks summary', 1)
|
||||
let g:gtm_plugin_status_enabled = s:enable_gtm_status
|
||||
if s:enable_gtm_status
|
||||
augroup gtm_plugin
|
||||
autocmd!
|
||||
autocmd BufReadPost,BufWritePost,CursorMoved,CursorMovedI * silent call s:record()
|
||||
augroup END
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#VersionControl#set_variable(var) abort
|
||||
let s:enable_gtm_status = get(a:var,
|
||||
\ 'enable_gtm_status',
|
||||
\ s:enable_gtm_status)
|
||||
endfunction
|
||||
|
||||
" master
|
||||
function! s:git_branch() abort
|
||||
if exists('g:loaded_fugitive')
|
||||
try
|
||||
let l:head = fugitive#head()
|
||||
if empty(l:head)
|
||||
call fugitive#detect(getcwd())
|
||||
let l:head = fugitive#head()
|
||||
endif
|
||||
if g:spacevim_statusline_unicode_symbols == 1
|
||||
return empty(l:head) ? '' : ' '.l:head . ' '
|
||||
else
|
||||
return empty(l:head) ? '' : ' '.l:head . ' '
|
||||
endif
|
||||
if empty(l:head)
|
||||
call fugitive#detect(getcwd())
|
||||
let l:head = fugitive#head()
|
||||
endif
|
||||
if g:spacevim_statusline_unicode_symbols == 1
|
||||
return empty(l:head) ? '' : ' '.l:head . s:gtm_status()
|
||||
else
|
||||
return empty(l:head) ? '' : ' '.l:head . s:gtm_status()
|
||||
endif
|
||||
catch
|
||||
endtry
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:gtm_status() abort
|
||||
if s:enable_gtm_status
|
||||
let status = s:gtm_statusline()
|
||||
return empty(status) ? '' : ' (' . status . ') '
|
||||
else
|
||||
return ''
|
||||
endif
|
||||
endfunction
|
||||
|
||||
let s:last_update = 0
|
||||
let s:last_file = ''
|
||||
let s:update_interval = 30
|
||||
let s:gtm_plugin_status = ''
|
||||
|
||||
function! s:record() abort
|
||||
let fpath = expand('%:p')
|
||||
" record if file path has changed or last update is greater than update_interval
|
||||
if (s:last_file != fpath || localtime() - s:last_update > s:update_interval) && filereadable(fpath)
|
||||
let s:cmd = (s:enable_gtm_status == 1 ? 'gtm record --status' : 'gtm record')
|
||||
let output=system(s:cmd . ' ' . shellescape(fpath))
|
||||
if v:shell_error
|
||||
echoerr 'failed to run ' . s:cmd . ' ' . shellescape(fpath)
|
||||
else
|
||||
let s:gtm_plugin_status = (s:enable_gtm_status ? substitute(output, '\n\+$', '', '') : '')
|
||||
endif
|
||||
let s:last_update = localtime()
|
||||
let s:last_file = fpath
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:gtm_statusline() abort
|
||||
return s:gtm_plugin_status
|
||||
endfunction
|
||||
|
||||
" +0 ~0 -0
|
||||
function! s:hunks() abort
|
||||
let hunks = [0,0,0]
|
||||
@ -72,7 +122,6 @@ function! s:hunks() abort
|
||||
endif
|
||||
return empty(rst) ? '' : ' ' . rst
|
||||
endfunction
|
||||
|
||||
" vcs transient state functions:
|
||||
|
||||
" first we need to open a buffer contains:
|
||||
|
@ -26,6 +26,7 @@
|
||||
" directory is `~/.SpaceVim/snippets/`. If `g:spacevim_force_global_config = 1`,
|
||||
" SpaceVim will not append `./.SpaceVim/snippets` as default snippets directory.
|
||||
|
||||
let s:SYS = SpaceVim#api#import('system')
|
||||
|
||||
function! SpaceVim#layers#autocomplete#plugins() abort
|
||||
let plugins = [
|
||||
@ -63,7 +64,11 @@ function! SpaceVim#layers#autocomplete#plugins() abort
|
||||
\ 'loadconf' : 1,
|
||||
\ }])
|
||||
elseif g:spacevim_autocomplete_method ==# 'coc'
|
||||
call add(plugins, ['neoclide/coc.nvim', {'merged': 0}])
|
||||
if s:SYS.isWindows
|
||||
call add(plugins, ['neoclide/coc.nvim', {'merged': 0, 'build': './install.cmd'}])
|
||||
else
|
||||
call add(plugins, ['neoclide/coc.nvim', {'merged': 0, 'build': './install.sh'}])
|
||||
endif
|
||||
elseif g:spacevim_autocomplete_method ==# 'deoplete'
|
||||
call add(plugins, ['Shougo/deoplete.nvim', {
|
||||
\ 'on_event' : 'InsertEnter',
|
||||
|
@ -14,7 +14,7 @@ endfunction
|
||||
|
||||
let s:BASE64 = SpaceVim#api#import('data#base64')
|
||||
|
||||
function! SpaceVim#layers#chat#config()
|
||||
function! SpaceVim#layers#chat#config() abort
|
||||
let g:chatting_server_ip = s:BASE64.decode('NDUuNzYuMTAwLjQ5')
|
||||
let g:chatting_server_port = 8989
|
||||
if !exists('g:chatting_server_lib')
|
||||
|
@ -58,6 +58,8 @@ function! SpaceVim#layers#checkers#config() abort
|
||||
let g:neomake_cursormoved_delay = get(g:, 'neomake_cursormoved_delay', 300)
|
||||
"" }}}
|
||||
|
||||
let g:neomake_virtualtext_current_error = get(g:, 'neomake_virtualtext_current_error', !s:show_cursor_error)
|
||||
|
||||
"" w0rp/ale {{{
|
||||
let g:ale_echo_delay = get(g:, 'ale_echo_delay', 300)
|
||||
"" }}}
|
||||
@ -91,6 +93,9 @@ function! SpaceVim#layers#checkers#config() abort
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['t', 's'], 'call call('
|
||||
\ . string(s:_function('s:toggle_syntax_checker')) . ', [])',
|
||||
\ 'toggle syntax checker', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['e', 'e'], 'call call('
|
||||
\ . string(s:_function('s:explain_the_error')) . ', [])',
|
||||
\ 'explain the error', 1)
|
||||
augroup SpaceVim_layer_checker
|
||||
autocmd!
|
||||
if g:spacevim_enable_neomake
|
||||
@ -221,6 +226,28 @@ function! s:toggle_syntax_checker() abort
|
||||
verbose NeomakeToggle
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:explain_the_error() abort
|
||||
if g:spacevim_enable_neomake
|
||||
try
|
||||
let message = neomake#GetCurrentErrorMsg()
|
||||
catch /^Vim\%((\a\+)\)\=:E117/
|
||||
let message = ''
|
||||
endtry
|
||||
elseif g:spacevim_enable_ale
|
||||
try
|
||||
let message = neomake#GetCurrentErrorMsg()
|
||||
catch /^Vim\%((\a\+)\)\=:E117/
|
||||
let message = ''
|
||||
endtry
|
||||
endif
|
||||
if !empty(message)
|
||||
echo message
|
||||
else
|
||||
echo 'no error message at this point!'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:error_transient_state() abort
|
||||
if g:spacevim_enable_neomake
|
||||
let num_errors = neomake#statusline#LoclistCounts()
|
||||
|
@ -9,8 +9,9 @@
|
||||
|
||||
function! SpaceVim#layers#chinese#plugins() abort
|
||||
let plugins = [
|
||||
\ ['yianwillis/vimcdoc', {'merged' : 0}],
|
||||
\ ['ianva/vim-youdao-translater', { 'on_cmd' : ['Ydv','Ydc','Yde']}],
|
||||
\ ['yianwillis/vimcdoc' , {'merged' : 0}],
|
||||
\ ['ianva/vim-youdao-translater' , {'on_cmd' : ['Ydv' , 'Ydc', 'Yde']}],
|
||||
\ ['wsdjeg/ChineseLinter.vim' , {'merged' : 0, 'on_cmd' : ['CheckChinese']}],
|
||||
\ ]
|
||||
if SpaceVim#layers#isLoaded('ctrlp')
|
||||
call add(plugins, ['vimcn/ctrlp.cnx', {'merged' : 0}])
|
||||
@ -20,7 +21,8 @@ endfunction
|
||||
|
||||
function! SpaceVim#layers#chinese#config() abort
|
||||
let g:_spacevim_mappings_space.x.g = {'name' : '+translate'}
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'g', 't'], 'Ydc', 'translate current word', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'g', 't'], 'Ydc' , 'translate current word' , 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['l', 'c'] , 'CheckChinese', 'Check with ChineseLinter', 1)
|
||||
" do not load vimcdoc plugin
|
||||
let g:loaded_vimcdoc = 1
|
||||
endfunction
|
||||
|
@ -68,11 +68,11 @@ let s:time = {
|
||||
\ 'weekly' : 7 * 24 * 60 * 60 * 1000,
|
||||
\ }
|
||||
|
||||
for n in range(1, 23)
|
||||
call extend(s:time, {n . 'h' : n * 60 * 60 * 1000})
|
||||
for s:n in range(1, 23)
|
||||
call extend(s:time, {s:n . 'h' : s:n * 60 * 60 * 1000})
|
||||
endfor
|
||||
|
||||
unlet n
|
||||
unlet s:n
|
||||
|
||||
let s:random_colorscheme = 0
|
||||
let s:random_frequency = ''
|
||||
@ -83,6 +83,8 @@ function! SpaceVim#layers#colorscheme#config() abort
|
||||
" Use local file's save time, the local file is
|
||||
" ~/.cache/SpaceVim/colorscheme_frequence.json
|
||||
" {"fequecnce" : "dalily", "last" : 000000, 'theme' : 'one'}
|
||||
" FIXME: when global config cache is updated, check the cache also should
|
||||
" be updated
|
||||
if filereadable(expand('~/.cache/SpaceVim/colorscheme_frequence.json'))
|
||||
let conf = s:JSON.json_decode(join(readfile(expand('~/.cache/SpaceVim/colorscheme_frequence.json'), ''), ''))
|
||||
if s:random_frequency !=# '' && !empty(conf)
|
||||
|
@ -17,6 +17,8 @@ function! SpaceVim#layers#core#plugins() abort
|
||||
call add(plugins, ['Shougo/vimfiler.vim',{'merged' : 0, 'loadconf' : 1 , 'loadconf_before' : 1, 'on_cmd' : ['VimFiler', 'VimFilerBufferDir']}])
|
||||
call add(plugins, ['Shougo/unite.vim',{ 'merged' : 0 , 'loadconf' : 1}])
|
||||
call add(plugins, ['Shougo/vimproc.vim', {'build' : [(executable('gmake') ? 'gmake' : 'make')]}])
|
||||
elseif g:spacevim_filemanager ==# 'defx'
|
||||
call add(plugins, ['Shougo/defx.nvim',{'merged' : 0, 'loadconf' : 1 , 'loadconf_before' : 1}])
|
||||
endif
|
||||
|
||||
if !g:spacevim_vimcompatible
|
||||
@ -96,8 +98,17 @@ function! SpaceVim#layers#core#config() abort
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['j', '$'], 'm`g_', 'push mark and goto end of line', 0)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['j', 'b'], '<C-o>', 'jump backward', 0)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['j', 'f'], '<C-i>', 'jump forward', 0)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['j', 'd'], 'VimFiler -no-split', 'Explore current directory', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['j', 'D'], 'VimFiler', 'Explore current directory (other window)', 1)
|
||||
|
||||
" file tree key bindings
|
||||
if g:spacevim_filemanager ==# 'vimfiler'
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['j', 'd'], 'VimFiler -no-split', 'Explore current directory', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['j', 'D'], 'VimFiler', 'Explore current directory (other window)', 1)
|
||||
elseif g:spacevim_filemanager ==# 'nerdtree'
|
||||
elseif g:spacevim_filemanager ==# 'defx'
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['j', 'd'], 'let g:_spacevim_autoclose_defx = 0 | Defx -split=no | let g:_spacevim_autoclose_defx = 1', 'Explore current directory', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['j', 'D'], 'Defx', 'Explore current directory (other window)', 1)
|
||||
endif
|
||||
|
||||
call SpaceVim#mapping#space#def('nmap', ['j', 'j'], '<Plug>(easymotion-overwin-f)', 'jump to a character', 0)
|
||||
call SpaceVim#mapping#space#def('nmap', ['j', 'J'], '<Plug>(easymotion-overwin-f2)', 'jump to a suite of two characters', 0)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['j', 'k'], 'j==', 'go to next line and indent', 0)
|
||||
@ -170,9 +181,16 @@ function! SpaceVim#layers#core#config() abort
|
||||
\ 'delete-current-buffer-file', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['f', 'F'], 'normal! gf', 'open-cursor-file', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['f', '/'], 'call SpaceVim#plugins#find#open()', 'find-files', 1)
|
||||
if s:SYS.isWindows
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['f', 'd'], 'call call('
|
||||
\ . string(s:_function('s:ToggleWinDiskManager')) . ', [])',
|
||||
\ 'toggle Windows disk manager', 1)
|
||||
endif
|
||||
|
||||
" file tree key bindings
|
||||
if g:spacevim_filemanager ==# 'vimfiler'
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['f', 't'], 'VimFiler', 'toggle_file_tree', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['f', 'T'], 'VimFiler -no-toggle', 'show_file_tree', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['f', 't'], 'VimFiler | doautocmd WinEnter', 'toggle_file_tree', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['f', 'T'], 'VimFiler -no-toggle | doautocmd WinEnter', 'show_file_tree', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['f', 'o'], 'VimFiler -find', 'open_file_tree', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['b', 't'], 'VimFilerBufferDir -no-toggle', 'show_file_tree_at_buffer_dir', 1)
|
||||
elseif g:spacevim_filemanager ==# 'nerdtree'
|
||||
@ -180,11 +198,26 @@ function! SpaceVim#layers#core#config() abort
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['f', 'T'], 'NERDTree', 'show_file_tree', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['f', 'o'], 'NERDTreeFind', 'open_file_tree', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['b', 't'], 'NERDTree %', 'show_file_tree_at_buffer_dir', 1)
|
||||
elseif g:spacevim_filemanager ==# 'defx'
|
||||
" TODO: fix all these command
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['f', 't'], 'Defx', 'toggle_file_tree', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['f', 'T'], 'Defx -no-toggle', 'show_file_tree', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['f', 'o'], "Defx -no-toggle -search=`expand('%:p')` `getcwd()`", 'open_file_tree', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['b', 't'], 'Defx -no-toggle', 'show_file_tree_at_buffer_dir', 1)
|
||||
endif
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['f', 'y'], 'call zvim#util#CopyToClipboard()', 'show-and-copy-buffer-filename', 1)
|
||||
let g:_spacevim_mappings_space.f.v = {'name' : '+Vim(SpaceVim)'}
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['f', 'v', 'v'], 'let @+=g:spacevim_version | echo g:spacevim_version', 'display-and-copy-version', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['f', 'v', 'd'], 'SPConfig', 'open-custom-configuration', 1)
|
||||
let lnum = expand('<slnum>') + s:lnum - 1
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['f', 'v', 'd'], 'SPConfig',
|
||||
\ ['open-custom-configuration',
|
||||
\ [
|
||||
\ '[SPC f v d] is to open the custom configuration file for SpaceVim',
|
||||
\ '',
|
||||
\ 'Definition: ' . s:filename . ':' . lnum,
|
||||
\ ]
|
||||
\ ]
|
||||
\ , 1)
|
||||
let lnum = expand('<slnum>') + s:lnum - 1
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['n', '-'], 'call call('
|
||||
\ . string(s:_function('s:number_transient_state')) . ', ["-"])',
|
||||
@ -233,19 +266,22 @@ function! SpaceVim#layers#core#config() 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('nmap', ['c', 'l'], '<Plug>NERDCommenterInvert', 'comment or uncomment lines', 0, 1)
|
||||
call SpaceVim#mapping#space#def('nmap', ['c', 'L'], '<Plug>NERDCommenterInvert', 'comment or uncomment lines invert', 0, 1)
|
||||
call SpaceVim#mapping#space#def('nmap', ['c', 'v'], '<Plug>NERDCommenterInvertgv', 'comment or uncomment lines and keep visual', 0, 1)
|
||||
call SpaceVim#mapping#space#def('nmap', ['c', 'l'], '<Plug>NERDCommenterInvert', 'toggle comment lines', 0, 1)
|
||||
call SpaceVim#mapping#space#def('nmap', ['c', 'L'], '<Plug>NERDCommenterComment', 'comment lines', 0, 1)
|
||||
call SpaceVim#mapping#space#def('nmap', ['c', 'u'], '<Plug>NERDCommenterUncomment', 'uncomment lines', 0, 1)
|
||||
call SpaceVim#mapping#space#def('nmap', ['c', 'v'], '<Plug>NERDCommenterInvertgv', 'toggle comment lines and keep visual', 0, 1)
|
||||
call SpaceVim#mapping#space#def('nmap', ['c', 's'], '<Plug>NERDCommenterSexy', 'comment with sexy/pretty layout', 0, 1)
|
||||
call SpaceVim#mapping#space#def('nmap', ['c', 'Y'], '<Plug>NERDCommenterYank', 'yank and comment', 0, 1)
|
||||
call SpaceVim#mapping#space#def('nmap', ['c', '$'], '<Plug>NERDCommenterToEOL', 'comment current line from cursor to the end of the line', 0, 1)
|
||||
|
||||
nnoremap <silent> <Plug>CommentToLine :call <SID>comment_to_line(0)<Cr>
|
||||
nnoremap <silent> <Plug>CommentToLineInvert :call <SID>comment_to_line(1)<Cr>
|
||||
nnoremap <silent> <Plug>CommentParagraphs :call <SID>comment_paragraphs(0)<Cr>
|
||||
nnoremap <silent> <Plug>CommentParagraphsInvert :call <SID>comment_paragraphs(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)
|
||||
call SpaceVim#mapping#space#def('nmap', ['c', 'p'], '<Plug>CommentParagraphs', 'comment paragraphs', 0, 1)
|
||||
call SpaceVim#mapping#space#def('nmap', ['c', 'P'], '<Plug>CommentParagraphsInvert', 'toggle comment paragraphs', 0, 1)
|
||||
call SpaceVim#mapping#space#def('nmap', ['c', 't'], '<Plug>CommentToLineInvert', 'toggle comment until the line', 0, 1)
|
||||
call SpaceVim#mapping#space#def('nmap', ['c', 'T'], '<Plug>CommentToLine', 'comment until the line', 0, 1)
|
||||
call SpaceVim#mapping#space#def('nmap', ['c', 'p'], '<Plug>CommentParagraphsInvert', 'toggle comment paragraphs', 0, 1)
|
||||
call SpaceVim#mapping#space#def('nmap', ['c', 'P'], '<Plug>CommentParagraphs', 'comment paragraphs', 0, 1)
|
||||
|
||||
nnoremap <silent> <Plug>CommentOperator :set opfunc=<SID>commentOperator<Cr>g@
|
||||
let g:_spacevim_mappings_space[';'] = ['call feedkeys("\<Plug>CommentOperator")', 'comment operator']
|
||||
@ -354,33 +390,29 @@ function! s:previous_window() abort
|
||||
endfunction
|
||||
|
||||
function! s:split_string(newline) abort
|
||||
let syn_name = synIDattr(synID(line('.'), col('.'), 1), 'name')
|
||||
if syn_name == &filetype . 'String'
|
||||
if s:is_string(line('.'), col('.'))
|
||||
let c = col('.')
|
||||
let sep = ''
|
||||
while c > 0
|
||||
if s:is_string(line('.'), c)
|
||||
let c = c - 1
|
||||
let c -= 1
|
||||
else
|
||||
let sep = getline('.')[c]
|
||||
break
|
||||
endif
|
||||
endwhile
|
||||
let l:connector = a:newline ? "\n" : ""
|
||||
let l:save_register_m = @m
|
||||
let @m = sep . l:connector . sep
|
||||
normal! "mp
|
||||
let @m = l:save_register_m
|
||||
if a:newline
|
||||
let save_register_m = @m
|
||||
let @m = sep . "\n" . sep
|
||||
normal! "mp
|
||||
let @m = save_register_m
|
||||
else
|
||||
let save_register_m = @m
|
||||
let @m = sep . sep
|
||||
normal! "mp
|
||||
let @m = save_register_m
|
||||
normal! j==k$
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:is_string(l,c) abort
|
||||
function! s:is_string(l, c) abort
|
||||
return synIDattr(synID(a:l, a:c, 1), 'name') == &filetype . 'String'
|
||||
endfunction
|
||||
|
||||
@ -411,6 +443,14 @@ function! s:safe_erase_buffer() abort
|
||||
redraw!
|
||||
endfunction
|
||||
|
||||
function! s:ToggleWinDiskManager() abort
|
||||
if bufexists("__windisk__")
|
||||
execute 'bd "__windisk__"'
|
||||
else
|
||||
call SpaceVim#plugins#windisk#open()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:open_message_buffer() abort
|
||||
vertical topleft edit __Message_Buffer__
|
||||
setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline nospell nonumber norelativenumber
|
||||
@ -431,14 +471,14 @@ endfunction
|
||||
|
||||
function! s:delete_current_buffer_file() abort
|
||||
if s:MESSAGE.confirm('Are you sure you want to delete this file')
|
||||
let f = fnameescape(expand('%:p'))
|
||||
call SpaceVim#mapping#close_current_buffer()
|
||||
let f = expand('%')
|
||||
if delete(f) == 0
|
||||
echo "File '" . f . "' successfully removed"
|
||||
call SpaceVim#mapping#close_current_buffer('n')
|
||||
echo "File '" . f . "' successfully deleted!"
|
||||
else
|
||||
call s:MESSAGE.warn('Failed to delete file:' . f)
|
||||
endif
|
||||
endif
|
||||
redraw!
|
||||
|
||||
endfunction
|
||||
|
||||
function! s:swap_buffer_with_nth_win(nr) abort
|
||||
|
@ -145,7 +145,7 @@ function! SpaceVim#layers#core#banner#config() abort
|
||||
\ [
|
||||
\ '',
|
||||
\ '',
|
||||
\ " ######### ######### ######### ######### ################## ",
|
||||
\ ' ######### ######### ######### ######### ################## ',
|
||||
\ " ###(_)### [`\'`\'] ##\\`.\'/## \':v:` ##/\\:/\\## |:+:| ##\':v:`## \\`.\'/ ##[`\'`\']###\\`~\'/## \\`.\'/ ",
|
||||
\ " ###| |### |::| ##(o:o)## (o:0) #/(o:o)\\# (o:o) ##(o:0)## (o:o) ###|::|####(o o)## (o:o) ",
|
||||
\ " ###|_|### |::| ###\\:/:\\# (:) ###(:)### (:) ###(:)### \\:/:\\ ###|::|#####\\ / \\# \\:/:\\ ",
|
||||
|
@ -113,7 +113,7 @@ function! s:winnr(...) abort
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#core#statusline#winnr(id)
|
||||
function! SpaceVim#layers#core#statusline#winnr(id) abort
|
||||
return s:MESSLETTERS.circled_num(a:id, g:spacevim_windows_index_type)
|
||||
endfunction
|
||||
|
||||
@ -174,7 +174,7 @@ function! s:date() abort
|
||||
endfunction
|
||||
|
||||
function! s:whitespace() abort
|
||||
let ln = search('\s\+$', 'n')
|
||||
let ln = search('\s\+$', 'nw')
|
||||
if ln != 0
|
||||
return ' trailing[' . ln . '] '
|
||||
else
|
||||
@ -203,8 +203,21 @@ function! s:battery_status() abort
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:input_method() abort
|
||||
" use fcitx-remote get current method
|
||||
if executable('fcitx-remote')
|
||||
if system('fcitx-remote') == 1
|
||||
return ' cn '
|
||||
else
|
||||
return ' en '
|
||||
endif
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
|
||||
if g:spacevim_enable_neomake
|
||||
function! s:syntax_checking()
|
||||
function! s:syntax_checking() abort
|
||||
if !exists('g:loaded_neomake')
|
||||
return ''
|
||||
endif
|
||||
@ -216,7 +229,7 @@ if g:spacevim_enable_neomake
|
||||
return l
|
||||
endfunction
|
||||
elseif g:spacevim_enable_ale
|
||||
function! s:syntax_checking()
|
||||
function! s:syntax_checking() abort
|
||||
if !exists('g:ale_enabled')
|
||||
return ''
|
||||
endif
|
||||
@ -228,7 +241,7 @@ elseif g:spacevim_enable_ale
|
||||
return l
|
||||
endfunction
|
||||
else
|
||||
function! s:syntax_checking()
|
||||
function! s:syntax_checking() abort
|
||||
if !exists(':SyntasticCheck')
|
||||
return ''
|
||||
endif
|
||||
@ -269,18 +282,19 @@ let s:registed_sections = {
|
||||
\ 'date' : function('s:date'),
|
||||
\ 'whitespace' : function('s:whitespace'),
|
||||
\ 'battery status' : function('s:battery_status'),
|
||||
\ 'input method' : function('s:input_method'),
|
||||
\ 'search status' : function('s:search_status'),
|
||||
\ }
|
||||
|
||||
|
||||
function! s:check_mode() abort
|
||||
if mode() == 'n'
|
||||
if mode() ==# 'n'
|
||||
return 'n'
|
||||
elseif mode() =='i'
|
||||
elseif mode() ==# 'i'
|
||||
return 'i'
|
||||
elseif mode() =~ 'v'
|
||||
elseif mode() =~# 'v'
|
||||
return 'v'
|
||||
elseif mode() =~ 'R'
|
||||
elseif mode() =~# 'R'
|
||||
return 'R'
|
||||
endif
|
||||
endfunction
|
||||
@ -303,7 +317,7 @@ endfunction
|
||||
function! SpaceVim#layers#core#statusline#_current_tag() abort
|
||||
let tag = ''
|
||||
try
|
||||
let tag =tagbar#currenttag("%s ", "")
|
||||
let tag =tagbar#currenttag('%s ', '')
|
||||
catch
|
||||
endtry
|
||||
return tag
|
||||
@ -337,6 +351,9 @@ function! SpaceVim#layers#core#statusline#get(...) abort
|
||||
\ . '%#SpaceVim_statusline_b#'
|
||||
\ . ' vimfiler %#SpaceVim_statusline_b_SpaceVim_statusline_c#'
|
||||
\ . s:lsep
|
||||
elseif &filetype ==# 'defx'
|
||||
return '%#SpaceVim_statusline_ia#' . s:winnr(1) . '%#SpaceVim_statusline_ia_SpaceVim_statusline_b#' . s:lsep
|
||||
\ . '%#SpaceVim_statusline_b# defx %#SpaceVim_statusline_b_SpaceVim_statusline_c#' . s:lsep . ' '
|
||||
elseif &filetype ==# 'gista-list'
|
||||
return '%#SpaceVim_statusline_ia#'
|
||||
\ . s:winnr(1) . '%#SpaceVim_statusline_ia_SpaceVim_statusline_b#'
|
||||
@ -357,7 +374,7 @@ function! SpaceVim#layers#core#statusline#get(...) abort
|
||||
elseif &filetype ==# 'gina-commit'
|
||||
return '%#SpaceVim_statusline_ia#' . s:winnr(1) . '%#SpaceVim_statusline_ia_SpaceVim_statusline_b#' . s:lsep
|
||||
\ . '%#SpaceVim_statusline_b# Gina commit %#SpaceVim_statusline_b_SpaceVim_statusline_c#' . s:lsep . ' '
|
||||
elseif &filetype ==# 'diff' && bufname('%') =~ '^gina://'
|
||||
elseif &filetype ==# 'diff' && bufname('%') =~# '^gina://'
|
||||
return '%#SpaceVim_statusline_ia#' . s:winnr(1) . '%#SpaceVim_statusline_ia_SpaceVim_statusline_b#' . s:lsep
|
||||
\ . '%#SpaceVim_statusline_b# Gina diff %#SpaceVim_statusline_b_SpaceVim_statusline_c#' . s:lsep . ' '
|
||||
elseif &filetype ==# 'nerdtree'
|
||||
@ -381,12 +398,16 @@ function! SpaceVim#layers#core#statusline#get(...) abort
|
||||
\ . '%#SpaceVim_statusline_c_SpaceVim_statusline_z#' . s:lsep
|
||||
endif
|
||||
return st
|
||||
elseif &buftype ==# 'nofile' && bufname('%') ==# '__LanguageClient__'
|
||||
return '%#SpaceVim_statusline_a# LanguageClient %#SpaceVim_statusline_a_SpaceVim_statusline_b#' . s:lsep
|
||||
\ . '%#SpaceVim_statusline_b# ' . &filetype . ' %#SpaceVim_statusline_b_SpaceVim_statusline_c#' . s:lsep
|
||||
elseif &filetype ==# 'SpaceVimLayerManager'
|
||||
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 ==# 'SpaceVimGitLogPopup'
|
||||
return '%#SpaceVim_statusline_a# Git log popup %#SpaceVim_statusline_a_SpaceVim_statusline_b#' . s:lsep
|
||||
|
||||
elseif &filetype ==# 'SpaceVimWinDiskManager'
|
||||
return '%#SpaceVim_statusline_a# WinDisk %#SpaceVim_statusline_a_SpaceVim_statusline_b#' . s:lsep
|
||||
elseif &filetype ==# 'SpaceVimTodoManager'
|
||||
return '%#SpaceVim_statusline_a# TODO manager %#SpaceVim_statusline_a_SpaceVim_statusline_b#' . s:lsep
|
||||
|
||||
@ -464,7 +485,7 @@ endfunction
|
||||
|
||||
function! s:inactive() abort
|
||||
let l = '%#SpaceVim_statusline_ia#' . s:winnr(1) . '%#SpaceVim_statusline_ia_SpaceVim_statusline_b#' . s:lsep . '%#SpaceVim_statusline_b#'
|
||||
let secs = [s:filename(), " " . &filetype, s:modes()]
|
||||
let secs = [s:filename(), ' ' . &filetype, s:modes()]
|
||||
let base = 10
|
||||
for sec in secs
|
||||
let len = s:STATUSLINE.len(sec)
|
||||
@ -557,7 +578,7 @@ function! SpaceVim#layers#core#statusline#toggle_section(name) abort
|
||||
let s:section_old_pos[a:name] = ['l', index(s:loaded_sections_l, a:name)]
|
||||
call remove(s:loaded_sections_l, index(s:loaded_sections_l, a:name))
|
||||
elseif has_key(s:section_old_pos, a:name)
|
||||
if s:section_old_pos[a:name][0] == 'r'
|
||||
if s:section_old_pos[a:name][0] ==# 'r'
|
||||
call insert(s:loaded_sections_r, a:name, s:section_old_pos[a:name][1])
|
||||
else
|
||||
call insert(s:loaded_sections_l, a:name, s:section_old_pos[a:name][1])
|
||||
@ -566,7 +587,7 @@ function! SpaceVim#layers#core#statusline#toggle_section(name) abort
|
||||
let &l:statusline = SpaceVim#layers#core#statusline#get(1)
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#core#statusline#rsep()
|
||||
function! SpaceVim#layers#core#statusline#rsep() abort
|
||||
return get(s:separators, g:spacevim_statusline_separator, s:separators['arrow'])
|
||||
endfunction
|
||||
|
||||
@ -579,6 +600,8 @@ function! SpaceVim#layers#core#statusline#config() abort
|
||||
\ 'toggle the battery status', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['t', 'm', 'd'], 'call SpaceVim#layers#core#statusline#toggle_section("date")',
|
||||
\ 'toggle the date', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['t', 'm', 'i'], 'call SpaceVim#layers#core#statusline#toggle_section("input method")',
|
||||
\ 'toggle the input method', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['t', 'm', 't'], 'call SpaceVim#layers#core#statusline#toggle_section("time")',
|
||||
\ 'toggle the time', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['t', 'm', 'p'], 'call SpaceVim#layers#core#statusline#toggle_section("cursorpos")',
|
||||
@ -639,12 +662,12 @@ function! SpaceVim#layers#core#statusline#jump(i) abort
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#core#statusline#mode(mode)
|
||||
function! SpaceVim#layers#core#statusline#mode(mode) abort
|
||||
let t = s:colors_template
|
||||
let iedit_mode = get(w:, 'spacevim_iedit_mode', '')
|
||||
let mode = get(w:, 'spacevim_statusline_mode', '')
|
||||
if mode != a:mode
|
||||
if a:mode == 'n'
|
||||
if a:mode ==# 'n'
|
||||
if !empty(iedit_mode)
|
||||
if iedit_mode ==# 'n'
|
||||
exe 'hi! SpaceVim_statusline_a gui=bold cterm=bold ctermbg=' . t[8][3] . ' ctermfg=' . t[8][2] . ' guibg=' . t[8][1] . ' guifg=' . t[8][0]
|
||||
@ -656,11 +679,11 @@ function! SpaceVim#layers#core#statusline#mode(mode)
|
||||
else
|
||||
exe 'hi! SpaceVim_statusline_a gui=bold cterm=bold ctermbg=' . t[0][2] . ' ctermfg=' . t[0][3] . ' guibg=' . t[0][1] . ' guifg=' . t[0][0]
|
||||
endif
|
||||
elseif a:mode == 'i'
|
||||
elseif a:mode ==# 'i'
|
||||
exe 'hi! SpaceVim_statusline_a gui=bold cterm=bold ctermbg=' . t[4][3] . ' ctermfg=' . t[4][2] . ' guibg=' . t[4][1] . ' guifg=' . t[4][0]
|
||||
elseif a:mode == 'R'
|
||||
elseif a:mode ==# 'R'
|
||||
exe 'hi! SpaceVim_statusline_a gui=bold cterm=bold 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 == '' || a:mode == 's' || a:mode == 'S' || a:mode == ''
|
||||
elseif a:mode ==# 'v' || a:mode ==# 'V' || a:mode ==# '' || a:mode ==# 's' || a:mode ==# 'S' || a:mode ==# ''
|
||||
exe 'hi! SpaceVim_statusline_a gui=bold cterm=bold 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')
|
||||
@ -669,9 +692,9 @@ function! SpaceVim#layers#core#statusline#mode(mode)
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#core#statusline#mode_text(mode)
|
||||
function! SpaceVim#layers#core#statusline#mode_text(mode) abort
|
||||
let iedit_mode = get(w:, 'spacevim_iedit_mode', '')
|
||||
if a:mode == 'n'
|
||||
if a:mode ==# 'n'
|
||||
if !empty(iedit_mode)
|
||||
if iedit_mode ==# 'n'
|
||||
return 'IEDIT-NORMAL'
|
||||
@ -680,9 +703,9 @@ function! SpaceVim#layers#core#statusline#mode_text(mode)
|
||||
endif
|
||||
endif
|
||||
return 'NORMAL'
|
||||
elseif a:mode == 'i'
|
||||
elseif a:mode ==# 'i'
|
||||
return 'INSERT'
|
||||
elseif a:mode == 'R'
|
||||
elseif a:mode ==# 'R'
|
||||
return 'REPLACE'
|
||||
elseif a:mode ==# 'v'
|
||||
return 'VISUAL'
|
||||
@ -694,19 +717,19 @@ function! SpaceVim#layers#core#statusline#mode_text(mode)
|
||||
return 'COMMAND'
|
||||
elseif a:mode ==# 't'
|
||||
return 'TERMINAL'
|
||||
elseif a:mode == 'v' || a:mode == 'V' || a:mode == '^V' || a:mode == 's' || a:mode == 'S' || a:mode == '^S'
|
||||
elseif a:mode ==# 'v' || a:mode ==# 'V' || a:mode ==# '^V' || a:mode ==# 's' || a:mode ==# 'S' || a:mode ==# '^S'
|
||||
return 'VISUAL'
|
||||
endif
|
||||
return ' '
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#core#statusline#denite_mode()
|
||||
function! SpaceVim#layers#core#statusline#denite_mode() abort
|
||||
let t = s:colors_template
|
||||
let dmode = split(denite#get_status_mode())[1]
|
||||
if get(w:, 'spacevim_statusline_mode', '') != dmode
|
||||
if dmode == 'NORMAL'
|
||||
if dmode ==# 'NORMAL'
|
||||
exe 'hi! SpaceVim_statusline_a_bold cterm=bold gui=bold ctermbg=' . t[0][2] . ' ctermfg=' . t[0][3] . ' guibg=' . t[0][1] . ' guifg=' . t[0][0]
|
||||
elseif dmode == 'INSERT'
|
||||
elseif dmode ==# 'INSERT'
|
||||
exe 'hi! SpaceVim_statusline_a_bold cterm=bold gui=bold ctermbg=' . t[4][3] . ' ctermfg=' . t[4][2] . ' guibg=' . t[4][1] . ' guifg=' . t[4][0]
|
||||
endif
|
||||
call s:HI.hi_separator('SpaceVim_statusline_a_bold', 'SpaceVim_statusline_b')
|
||||
@ -715,13 +738,13 @@ function! SpaceVim#layers#core#statusline#denite_mode()
|
||||
return dmode
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#core#statusline#unite_mode()
|
||||
function! SpaceVim#layers#core#statusline#unite_mode() abort
|
||||
let t = s:colors_template
|
||||
let dmode = mode()
|
||||
if get(w:, 'spacevim_statusline_mode', '') != dmode
|
||||
if dmode == 'n'
|
||||
if dmode ==# 'n'
|
||||
exe 'hi! SpaceVim_statusline_a_bold cterm=bold gui=bold ctermbg=' . t[0][2] . ' ctermfg=' . t[0][3] . ' guibg=' . t[0][1] . ' guifg=' . t[0][0]
|
||||
elseif dmode == 'i'
|
||||
elseif dmode ==# 'i'
|
||||
exe 'hi! SpaceVim_statusline_a_bold cterm=bold gui=bold ctermbg=' . t[4][3] . ' ctermfg=' . t[4][2] . ' guibg=' . t[4][1] . ' guifg=' . t[4][0]
|
||||
endif
|
||||
call s:HI.hi_separator('SpaceVim_statusline_a_bold', 'SpaceVim_statusline_b')
|
||||
@ -730,7 +753,7 @@ function! SpaceVim#layers#core#statusline#unite_mode()
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#core#statusline#register_sections(name, func)
|
||||
function! SpaceVim#layers#core#statusline#register_sections(name, func) abort
|
||||
|
||||
if has_key(s:registed_sections, a:name)
|
||||
call SpaceVim#logger#info('statusline build-in section ' . a:name . ' has been changed!')
|
||||
|
@ -15,7 +15,8 @@ endfunction
|
||||
|
||||
|
||||
function! SpaceVim#layers#cscope#config() abort
|
||||
let g:_spacevim_mappings_space.m.c = {'name' : '+cscope'}
|
||||
let g:_spacevim_mappings_space.m.c = {'name' : '+cscope'}
|
||||
if SpaceVim#layers#isLoaded('unite')
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['m', 'c', 'c'], 'Unite cscope/functions_called_by', 'find functions called by this function', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['m', 'c', 'C'], 'Unite cscope/functions_calling', 'find functions calling this function', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['m', 'c', 'd'], 'Unite cscope/global_definition', 'find global definition of a symbol', 1)
|
||||
@ -25,5 +26,17 @@ function! SpaceVim#layers#cscope#config() abort
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['m', 'c', 'e'], 'Unite cscope/egrep_pattern', 'Find this egrep pattern', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['m', 'c', 't'], 'Unite cscope/text_string', 'find this text string', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['m', 'c', '='], 'Unite cscope/assignments_to_symbol', 'find assignments to this symbol', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['m', 'c', 'i'], 'call CscopeUpdateDB()', 'create cscope index', 1)
|
||||
else
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['m', 'c', 'c'], 'call cscope#find("d", expand("<cword>"))', 'find functions called by this function', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['m', 'c', 'C'], 'call cscope#find("c", expand("<cword>"))', 'find functions calling this function', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['m', 'c', 'C'], 'call cscope#find("g", expand("<cword>"))', 'find global definition of a symbol', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['m', 'c', 'r'], 'call cscope#find("s", expand("<cword>"))', 'find references of a symbol', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['m', 'c', 'f'], 'call cscope#find("f", expand("<cword>"))', 'find files', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['m', 'c', 'F'], 'call cscope#find("i", expand("<cword>"))', 'find files including this file', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['m', 'c', 'e'], 'call cscope#find("e", expand("<cword>"))', 'Find this egrep pattern', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['m', 'c', 't'], 'call cscope#find("t", expand("<cword>"))', 'find this text string', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['m', 'c', '='], 'call cscope#find("a", expand("<cword>"))', 'find assignments to this symbol', 1)
|
||||
endif
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['m', 'c', 'u'], 'call cscope#updateDB()', 'create cscope index', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['m', 'c', 'i'], 'call cscope#createDB()', 'create cscope DB', 1)
|
||||
endfunction
|
||||
|
@ -111,7 +111,7 @@ function! SpaceVim#layers#denite#config() abort
|
||||
|
||||
let lnum = expand('<slnum>') + s:lnum - 1
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['f', 'f'], 'call call('
|
||||
\ . string(s:_function('s:warp_denite')) . ', ["DeniteBufferDir file_rec"])',
|
||||
\ . string(s:_function('s:warp_denite')) . ', ["DeniteBufferDir file/rec"])',
|
||||
\ ['Find files in the directory of the current buffer',
|
||||
\ [
|
||||
\ '[SPC f f] is to find files in the directory of the current buffer',
|
||||
@ -123,7 +123,7 @@ function! SpaceVim#layers#denite#config() abort
|
||||
|
||||
let lnum = expand('<slnum>') + s:lnum - 1
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['p', 'f'], 'call call('
|
||||
\ . string(s:_function('s:warp_denite')) . ', ["Denite file_rec"])',
|
||||
\ . string(s:_function('s:warp_denite')) . ', ["Denite file/rec"])',
|
||||
\ ['find files in current project',
|
||||
\ [
|
||||
\ '[SPC p f] is to find files in the root of the current project',
|
||||
@ -132,7 +132,7 @@ function! SpaceVim#layers#denite#config() abort
|
||||
\ ]
|
||||
\ ],
|
||||
\ 1)
|
||||
nnoremap <silent> <C-p> :call <SID>warp_denite('Denite file_rec')<cr>
|
||||
nnoremap <silent> <C-p> :call <SID>warp_denite('Denite file/rec')<cr>
|
||||
|
||||
|
||||
let lnum = expand('<slnum>') + s:lnum - 1
|
||||
@ -242,7 +242,7 @@ function! s:defind_fuzzy_finder() abort
|
||||
\ ]
|
||||
\ ]
|
||||
nnoremap <silent> <Leader>f<Space> :Denite menu:CustomKeyMaps<CR>
|
||||
let g:_spacevim_mappings.f['<Space>'] = ['Denite menu:CustomKeyMaps',
|
||||
let g:_spacevim_mappings.f['[SPC]'] = ['Denite menu:CustomKeyMaps',
|
||||
\ 'fuzzy find custom key bindings',
|
||||
\ [
|
||||
\ '[Leader f SPC] is to fuzzy find custom key bindings',
|
||||
@ -250,6 +250,16 @@ function! s:defind_fuzzy_finder() abort
|
||||
\ 'Definition: ' . s:file . ':' . lnum,
|
||||
\ ]
|
||||
\ ]
|
||||
nnoremap <silent> <Leader>fp :<C-u>Denite menu:AddedPlugins<CR>
|
||||
let lnum = expand('<slnum>') + s:unite_lnum - 4
|
||||
let g:_spacevim_mappings.f.p = ['Denite menu:AddedPlugins',
|
||||
\ 'fuzzy find vim packages',
|
||||
\ [
|
||||
\ '[Leader f p] is to fuzzy find vim packages installed in SpaceVim',
|
||||
\ '',
|
||||
\ 'Definition: ' . s:file . ':' . lnum,
|
||||
\ ]
|
||||
\ ]
|
||||
endfunction
|
||||
|
||||
function! s:warp_denite(cmd) abort
|
||||
|
@ -68,20 +68,25 @@ function! SpaceVim#layers#edit#config() abort
|
||||
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', 'count in the selection region', 0, 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '&'], 'Tabularize /&', 'align region at &', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '('], 'Tabularize /(', 'align region at (', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', ')'], 'Tabularize /)', 'align region at )', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '['], 'Tabularize /[', 'align region at [', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', ']'], 'Tabularize /]', 'align region at ]', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '{'], 'Tabularize /{', 'align region at {', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '}'], 'Tabularize /}', 'align region at }', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', ','], 'Tabularize /,', 'align region at ,', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '.'], 'Tabularize /.', 'align region at .', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', ':'], 'Tabularize /:', 'align region at :', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', ';'], 'Tabularize /;', 'align region at ;', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '='], 'Tabularize /===\|<=>\|\(&&\|||\|<<\|>>\|\/\/\)=\|=\~[#?]\?\|=>\|[:+/*!%^=><&|.?-]\?=[#?]\?/l1r1', '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', '<Bar>'], 'Tabularize /|', 'align region at |', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '&'], 'Tabularize /&', 'align-region-at-&', 1, 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '('], 'Tabularize /(', 'align-region-at-(', 1, 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', ')'], 'Tabularize /)', 'align-region-at-)', 1, 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '['], 'Tabularize /[', 'align-region-at-[', 1, 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', ']'], 'Tabularize /]', 'align-region-at-]', 1, 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '{'], 'Tabularize /{', 'align-region-at-{', 1, 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '}'], 'Tabularize /}', 'align-region-at-}', 1, 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', ','], 'Tabularize /,', 'align-region-at-,', 1, 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '.'], 'Tabularize /.', 'align-region-at-.', 1, 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', ':'], 'Tabularize /:', 'align-region-at-:', 1, 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', ';'], 'Tabularize /;', 'align-region-at-;', 1, 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '='], 'Tabularize /===\|<=>\|\(&&\|||\|<<\|>>\|\/\/\)=\|=\~[#?]\?\|=>\|[:+/*!%^=><&|.?-]\?=[#?]\?/l1r1', 'align-region-at-=', 1, 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', 'o'], 'Tabularize /&&\|||\|\.\.\|\*\*\|<<\|>>\|\/\/\|[-+*/.%^><&|?]/l1r1', 'align-region-at-operator, such as +,-,*,/,%,^,etc', 1, 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '¦'], 'Tabularize /¦', 'align-region-at-¦', 1, 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '<Bar>'], 'Tabularize /|', 'align-region-at-|', 1, 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '[SPC]'], 'Tabularize /\s\ze\S/l0', 'align-region-at-space', 1, 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', 'r'], 'call call('
|
||||
\ . string(s:_function('s:align_at_regular_expression')) . ', [])',
|
||||
\ 'align-region-at-user-specified-regexp', 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')) . ', [])',
|
||||
@ -108,6 +113,24 @@ function! SpaceVim#layers#edit#config() abort
|
||||
\ . string(s:_function('s:kebab_case')) . ', [])',
|
||||
\ 'change symbol style to kebab-case', 1)
|
||||
|
||||
" justification
|
||||
let g:_spacevim_mappings_space.x.j = {'name' : '+Justification'}
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'j', 'l'], 'silent call call('
|
||||
\ . string(s:_function('s:set_justification_to')) . ', ["left"])',
|
||||
\ 'set-the-justification-to-left', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'j', 'c'], 'silent call call('
|
||||
\ . string(s:_function('s:set_justification_to')) . ', ["center"])',
|
||||
\ 'set-the-justification-to-center', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 'j', 'r'], 'silent call call('
|
||||
\ . string(s:_function('s:set_justification_to')) . ', ["right"])',
|
||||
\ 'set-the-justification-to-right', 1)
|
||||
|
||||
call SpaceVim#mapping#space#def('vnoremap', ['x', 'u'], 'gu', 'set the selected text to lower case', 0)
|
||||
call SpaceVim#mapping#space#def('vnoremap', ['x', 'U'], 'gU', 'set the selected text to up case', 0)
|
||||
|
||||
" word
|
||||
let g:_spacevim_mappings_space.x.w = {'name' : '+word'}
|
||||
call SpaceVim#mapping#space#def('vnoremap', ['x', 'w', 'c'], "normal! " . ":'<,'>s/\\\w\\+//gn" . "\<cr>", 'count the words in the select region', 1)
|
||||
|
||||
let g:_spacevim_mappings_space.i = {'name' : '+Insertion'}
|
||||
let g:_spacevim_mappings_space.i.l = {'name' : '+Lorem-ipsum'}
|
||||
@ -160,50 +183,83 @@ function! SpaceVim#layers#edit#config() abort
|
||||
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)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 't', 'C'], 'call call('
|
||||
\ . string(s:_function('s:transpose_with_next')) . ', ["character"])',
|
||||
\ 'swap current character with next one', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 't', 'W'], 'call call('
|
||||
\ . string(s:_function('s:transpose_with_next')) . ', ["word"])',
|
||||
\ 'swap current word with next one', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['x', 't', 'L'], 'call call('
|
||||
\ . string(s:_function('s:transpose_with_next')) . ', ["line"])',
|
||||
\ 'swap current line with next one', 1)
|
||||
|
||||
endfunction
|
||||
|
||||
function! s:transpose_with_previous(type) abort
|
||||
let l:save_register = @"
|
||||
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
|
||||
normal! yiw
|
||||
let l:cw = @"
|
||||
normal! geyiw
|
||||
let l:tw = @"
|
||||
if l:cw !=# l:tw
|
||||
let @" = l:cw
|
||||
normal! viwp
|
||||
let @" = l:tw
|
||||
normal! eviwp
|
||||
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
|
||||
normal! hxp
|
||||
endif
|
||||
endif
|
||||
let @" = l:save_register
|
||||
endfunction
|
||||
|
||||
function! s:transpose_with_next(type) abort
|
||||
let l:save_register = @"
|
||||
if a:type ==# 'line'
|
||||
if line('.') < line('$')
|
||||
normal! ddp
|
||||
endif
|
||||
elseif a:type ==# 'word'
|
||||
normal! yiw
|
||||
let l:cw = @"
|
||||
normal! wyiw
|
||||
let l:nw = @"
|
||||
if l:cw !=# l:nw
|
||||
let @" = l:cw
|
||||
normal! viwp
|
||||
let @" = l:nw
|
||||
normal! geviwp
|
||||
endif
|
||||
elseif a:type ==# 'character'
|
||||
if col('.') < col('$')-1
|
||||
normal! xp
|
||||
endif
|
||||
endif
|
||||
let @" = l:save_register
|
||||
endfunction
|
||||
|
||||
function! s:move_text_down_transient_state() abort
|
||||
if line('.') == line('$')
|
||||
else
|
||||
let l:save_register = @"
|
||||
normal! ddp
|
||||
let @" = l:save_register
|
||||
endif
|
||||
call s:text_transient_state()
|
||||
endfunction
|
||||
|
||||
function! s:move_text_up_transient_state() abort
|
||||
if line('.') == 1
|
||||
else
|
||||
if line('.') > 1
|
||||
let l:save_register = @"
|
||||
normal! ddkP
|
||||
let @" = l:save_register
|
||||
endif
|
||||
call s:text_transient_state()
|
||||
endfunction
|
||||
@ -356,10 +412,43 @@ endfunction
|
||||
function! s:delete_extra_space() abort
|
||||
if !empty(getline('.'))
|
||||
if getline('.')[col('.')-1] ==# ' '
|
||||
exe "normal! viw\"_di\<Space>\<Esc>"
|
||||
execute "normal! \"_ciw\<Space>\<Esc>"
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:set_justification_to(align) abort
|
||||
let l:startlinenr = line("'{")
|
||||
let l:endlinenr = line("'}")
|
||||
if getline(l:startlinenr) ==# ''
|
||||
let l:startlinenr += 1
|
||||
endif
|
||||
if getline(l:endlinenr) ==# ''
|
||||
let l:endlinenr -= 1
|
||||
endif
|
||||
let l:lineList = map(getline(l:startlinenr, l:endlinenr), 'trim(v:val)')
|
||||
let l:maxlength = 0
|
||||
for l:line in l:lineList
|
||||
let l:length = strdisplaywidth(l:line)
|
||||
if l:length > l:maxlength
|
||||
let l:maxlength = l:length
|
||||
endif
|
||||
endfor
|
||||
|
||||
if a:align ==# 'left'
|
||||
execute l:startlinenr . ',' . l:endlinenr . ":left\<cr>"
|
||||
elseif a:align ==# 'center'
|
||||
execute l:startlinenr . ',' . l:endlinenr . ':center ' . l:maxlength . "\<cr>"
|
||||
elseif a:align ==# 'right'
|
||||
execute l:startlinenr . ',' . l:endlinenr . ':right ' . l:maxlength . "\<cr>"
|
||||
endif
|
||||
|
||||
unlet l:startlinenr
|
||||
unlet l:endlinenr
|
||||
unlet l:lineList
|
||||
unlet l:maxlength
|
||||
endfunction
|
||||
|
||||
let s:local_lorem_ipsum = [
|
||||
\ 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit.',
|
||||
\ 'Donec hendrerit tempor tellus.',
|
||||
@ -488,6 +577,16 @@ function! s:uuidgen_U() abort
|
||||
let @k = save_register
|
||||
endfunction
|
||||
|
||||
function! s:align_at_regular_expression() abort
|
||||
let re = input(':Tabularize /')
|
||||
if !empty(re)
|
||||
exe 'Tabularize /' . re
|
||||
else
|
||||
normal! :
|
||||
echo 'empty input, canceled!'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" function() wrapper
|
||||
if v:version > 703 || v:version == 703 && has('patch1170')
|
||||
function! s:_function(fstr) abort
|
||||
|
@ -143,15 +143,15 @@ endfunction
|
||||
command! FzfColors call <SID>colors()
|
||||
function! s:colors() abort
|
||||
let s:source = 'colorscheme'
|
||||
call fzf#run({'source': map(split(globpath(&rtp, 'colors/*.vim')),
|
||||
call fzf#run(fzf#wrap({'source': map(split(globpath(&rtp, 'colors/*.vim')),
|
||||
\ "fnamemodify(v:val, ':t:r')"),
|
||||
\ 'sink': 'colo','options': '--reverse', 'down': '40%'})
|
||||
\ 'sink': 'colo','options': '--reverse', 'down': '40%'}))
|
||||
endfunction
|
||||
|
||||
command! FzfFiles call <SID>files()
|
||||
function! s:files() abort
|
||||
let s:source = 'files'
|
||||
call fzf#run({'sink': 'e', 'options': '--reverse', 'down' : '40%'})
|
||||
call fzf#run(fzf#wrap('files', {'sink': 'e', 'options': '--reverse', 'down' : '40%'}))
|
||||
endfunction
|
||||
|
||||
let s:source = ''
|
||||
@ -171,14 +171,11 @@ function! s:bufopen(e) abort
|
||||
let [linenr, col, file_text] = [list[1], list[2]+1, join(list[3:])]
|
||||
let lines = getbufline(file_text, linenr)
|
||||
let path = file_text
|
||||
let bufnr = bufnr(file_text)
|
||||
if empty(lines)
|
||||
if stridx(join(split(getline(linenr))), file_text) == 0
|
||||
let lines = [file_text]
|
||||
let path = bufname('%')
|
||||
let bufnr = bufnr('%')
|
||||
elseif filereadable(path)
|
||||
let bufnr = 0
|
||||
let lines = ['buffer unloaded']
|
||||
else
|
||||
" Skip.
|
||||
@ -194,12 +191,12 @@ function! s:jumps() abort
|
||||
function! s:jumplist() abort
|
||||
return split(s:CMP.execute('jumps'), '\n')[1:]
|
||||
endfunction
|
||||
call fzf#run({
|
||||
call fzf#run(fzf#wrap('jumps', {
|
||||
\ 'source': reverse(<sid>jumplist()),
|
||||
\ 'sink': function('s:bufopen'),
|
||||
\ 'options': '+m',
|
||||
\ 'down': len(<sid>jumplist()) + 2
|
||||
\ })
|
||||
\ }))
|
||||
endfunction
|
||||
command! FzfMessages call <SID>message()
|
||||
function! s:yankmessage(e) abort
|
||||
@ -213,12 +210,12 @@ function! s:message() abort
|
||||
function! s:messagelist() abort
|
||||
return split(s:CMP.execute('message'), '\n')
|
||||
endfunction
|
||||
call fzf#run({
|
||||
call fzf#run(fzf#wrap('messages', {
|
||||
\ 'source': reverse(<sid>messagelist()),
|
||||
\ 'sink': function('s:yankmessage'),
|
||||
\ 'options': '+m',
|
||||
\ 'down': len(<sid>messagelist()) + 2
|
||||
\ })
|
||||
\ }))
|
||||
endfunction
|
||||
|
||||
command! FzfQuickfix call s:quickfix()
|
||||
@ -238,12 +235,12 @@ function! s:quickfix() abort
|
||||
function! s:quickfix_list() abort
|
||||
return map(getqflist(), 's:quickfix_to_grep(v:val)')
|
||||
endfunction
|
||||
call fzf#run({
|
||||
call fzf#run(fzf#wrap('quickfix', {
|
||||
\ 'source': reverse(<sid>quickfix_list()),
|
||||
\ 'sink': function('s:open_quickfix_item'),
|
||||
\ 'options': '--reverse',
|
||||
\ 'down' : '40%',
|
||||
\ })
|
||||
\ }))
|
||||
endfunction
|
||||
command! FzfLocationList call s:location_list()
|
||||
function! s:location_list_to_grep(v) abort
|
||||
@ -262,12 +259,12 @@ function! s:location_list() abort
|
||||
function! s:get_location_list() abort
|
||||
return map(getloclist(0), 's:location_list_to_grep(v:val)')
|
||||
endfunction
|
||||
call fzf#run({
|
||||
call fzf#run(fzf#wrap('location_list', {
|
||||
\ 'source': reverse(<sid>get_location_list()),
|
||||
\ 'sink': function('s:open_location_item'),
|
||||
\ 'options': '--reverse',
|
||||
\ 'down' : '40%',
|
||||
\ })
|
||||
\ }))
|
||||
endfunction
|
||||
|
||||
|
||||
@ -291,6 +288,7 @@ function! s:outline_source(tag_cmds) abort
|
||||
throw 'Save the file first'
|
||||
endif
|
||||
|
||||
let lines = []
|
||||
for cmd in a:tag_cmds
|
||||
let lines = split(system(cmd), "\n")
|
||||
if !v:shell_error
|
||||
@ -314,7 +312,6 @@ endfunction
|
||||
|
||||
function! s:outline(...) abort
|
||||
let s:source = 'outline'
|
||||
let args = copy(a:000)
|
||||
let tag_cmds = [
|
||||
\ printf('ctags -f - --sort=no --excmd=number --language-force=%s %s 2>/dev/null', &filetype, expand('%:S')),
|
||||
\ printf('ctags -f - --sort=no --excmd=number %s 2>/dev/null', expand('%:S'))]
|
||||
@ -337,12 +334,12 @@ function! s:register() abort
|
||||
function! s:registers_list() abort
|
||||
return split(s:CMP.execute('registers'), '\n')[1:]
|
||||
endfunction
|
||||
call fzf#run({
|
||||
call fzf#run(fzf#wrap('registers', {
|
||||
\ 'source': reverse(<sid>registers_list()),
|
||||
\ 'sink': function('s:yankregister'),
|
||||
\ 'options': '+m',
|
||||
\ 'down': '40%'
|
||||
\ })
|
||||
\ }))
|
||||
endfunction
|
||||
|
||||
command! Fzfbuffers call <SID>buffers()
|
||||
@ -354,17 +351,17 @@ function! s:buffers() abort
|
||||
function! s:buffer_list() abort
|
||||
return split(s:CMP.execute('buffers'), '\n')
|
||||
endfunction
|
||||
call fzf#run({
|
||||
call fzf#run(fzf#wrap('buffers', {
|
||||
\ 'source': reverse(<sid>buffer_list()),
|
||||
\ 'sink': function('s:open_buffer'),
|
||||
\ 'options': '+m',
|
||||
\ 'down': '40%'
|
||||
\ })
|
||||
\ }))
|
||||
endfunction
|
||||
|
||||
let s:ansi = {'black': 30, 'red': 31, 'green': 32, 'yellow': 33, 'blue': 34, 'magenta': 35, 'cyan': 36}
|
||||
|
||||
function! s:get_color(attr, ...)
|
||||
function! s:get_color(attr, ...) abort
|
||||
let gui = has('termguicolors') && &termguicolors
|
||||
let fam = gui ? 'gui' : 'cterm'
|
||||
let pat = gui ? '^#[a-f0-9]\+' : '^[0-9]\+$'
|
||||
@ -376,15 +373,15 @@ function! s:get_color(attr, ...)
|
||||
endfor
|
||||
return ''
|
||||
endfunction
|
||||
function! s:csi(color, fg)
|
||||
function! s:csi(color, fg) abort
|
||||
let prefix = a:fg ? '38;' : '48;'
|
||||
if a:color[0] == '#'
|
||||
if a:color[0] ==# '#'
|
||||
return prefix.'2;'.join(map([a:color[1:2], a:color[3:4], a:color[5:6]], 'str2nr(v:val, 16)'), ';')
|
||||
endif
|
||||
return prefix.'5;'.a:color
|
||||
endfunction
|
||||
|
||||
function! s:ansi(str, group, default, ...)
|
||||
function! s:ansi(str, group, default, ...) abort
|
||||
let fg = s:get_color('fg', a:group)
|
||||
let bg = s:get_color('bg', a:group)
|
||||
let color = s:csi(empty(fg) ? s:ansi[a:default] : fg, 1) .
|
||||
@ -392,12 +389,13 @@ function! s:ansi(str, group, default, ...)
|
||||
return printf("\x1b[%s%sm%s\x1b[m", color, a:0 ? ';1' : '', a:str)
|
||||
endfunction
|
||||
for s:color_name in keys(s:ansi)
|
||||
execute "function! s:".s:color_name."(str, ...)\n"
|
||||
execute 'function! s:'.s:color_name."(str, ...)\n"
|
||||
\ " return s:ansi(a:str, get(a:, 1, ''), '".s:color_name."')\n"
|
||||
\ "endfunction"
|
||||
\ 'endfunction'
|
||||
endfor
|
||||
function! s:helptag_sink(line)
|
||||
function! s:helptag_sink(line) abort
|
||||
let [tag, file, path] = split(a:line, "\t")[0:2]
|
||||
unlet file
|
||||
let rtp = fnamemodify(path, ':p:h:h')
|
||||
if stridx(&rtp, rtp) < 0
|
||||
execute 'set rtp+='. fnameescape(rtp)
|
||||
@ -405,7 +403,7 @@ function! s:helptag_sink(line)
|
||||
execute 'help' tag
|
||||
endfunction
|
||||
command! -nargs=? FzfHelpTags call <SID>helptags(<q-args>)
|
||||
function! s:helptags(...)
|
||||
function! s:helptags(...) abort
|
||||
let query = get(a:000, 0, '')
|
||||
if !executable('grep') || !executable('perl')
|
||||
call SpaceVim#logger#warn('FzfHelpTags command requires grep and perl')
|
||||
@ -417,13 +415,13 @@ function! s:helptags(...)
|
||||
silent! call delete(s:helptags_script)
|
||||
endif
|
||||
let s:helptags_script = tempname()
|
||||
call writefile(['/('.(s:SYS.isWindows ? '^[A-Z]:\/.*?[^:]' : '.*?').'):(.*?)\t(.*?)\t/; printf(qq('.s:green('%-40s', 'Label').'\t%s\t%s\n), $2, $3, $1)'], s:helptags_script)
|
||||
call writefile(['/('.(s:SYS.isWindows ? '^[A-Z]:\/.*?[^:]' : '.*?').'):(.*?)\t(.*?)\t/; printf(qq('. call('s:green', ['%-40s', 'Label']) . '\t%s\t%s\n), $2, $3, $1)'], s:helptags_script)
|
||||
let s:source = 'help'
|
||||
call fzf#run({
|
||||
call fzf#run(fzf#wrap('helptags', {
|
||||
\ 'source': 'grep -H ".*" '.join(map(tags, 'shellescape(v:val)')).
|
||||
\ ' | perl -n '. shellescape(s:helptags_script).' | sort',
|
||||
\ 'sink': function('s:helptag_sink'),
|
||||
\ 'options': ['--ansi', '--reverse', '+m', '--tiebreak=begin', '--with-nth', '..-2'] + (empty(query) ? [] : ['--query', query]),
|
||||
\ 'down': '40%'
|
||||
\ })
|
||||
\ }))
|
||||
endfunction
|
||||
|
@ -48,6 +48,7 @@ function! SpaceVim#layers#incsearch#config() abort
|
||||
map ? <Plug>(incsearch-backward)
|
||||
map g/ <Plug>(incsearch-stay)
|
||||
set hlsearch
|
||||
let g:incsearch#no_inc_hlsearch = 1
|
||||
let g:incsearch#auto_nohlsearch = get(g:, 'incsearch#auto_nohlsearch', 1)
|
||||
nnoremap <silent> n :call <SID>update_search_index('d')<cr>
|
||||
nnoremap <silent> N :call <SID>update_search_index('r')<cr>
|
||||
|
@ -92,9 +92,22 @@ function! SpaceVim#layers#lang#c#config() abort
|
||||
\ function('s:go_to_def'))
|
||||
call SpaceVim#mapping#gd#add('cpp',
|
||||
\ function('s:go_to_def'))
|
||||
call SpaceVim#plugins#runner#reg_runner('c', ['gcc -o #TEMP# %s', '#TEMP#'])
|
||||
" TODO: add stdin suport flex -t lexer.l | gcc -o lexer.o -xc -
|
||||
let runner1 = {
|
||||
\ 'exe' : 'gcc',
|
||||
\ 'targetopt' : '-o',
|
||||
\ 'opt' : ['-xc', '-'],
|
||||
\ 'usestdin' : 1,
|
||||
\ }
|
||||
call SpaceVim#plugins#runner#reg_runner('c', [runner1, '#TEMP#'])
|
||||
call SpaceVim#mapping#space#regesit_lang_mappings('c', function('s:language_specified_mappings'))
|
||||
call SpaceVim#plugins#runner#reg_runner('cpp', ['g++ -o #TEMP# %s', '#TEMP#'])
|
||||
let runner2 = {
|
||||
\ 'exe' : 'g++',
|
||||
\ 'targetopt' : '-o',
|
||||
\ 'opt' : ['-xc++', '-'],
|
||||
\ 'usestdin' : 1,
|
||||
\ }
|
||||
call SpaceVim#plugins#runner#reg_runner('cpp', [runner2, '#TEMP#'])
|
||||
call SpaceVim#mapping#space#regesit_lang_mappings('cpp', funcref('s:language_specified_mappings'))
|
||||
call SpaceVim#plugins#projectmanager#reg_callback(funcref('s:update_clang_flag'))
|
||||
if executable('clang')
|
||||
|
73
autoload/SpaceVim/layers/lang/coffeescript.vim
Normal file
73
autoload/SpaceVim/layers/lang/coffeescript.vim
Normal file
@ -0,0 +1,73 @@
|
||||
"=============================================================================
|
||||
" coffeescript.vim --- lang#coffeescript layer
|
||||
" Copyright (c) 2016-2017 Wang Shidong & Contributors
|
||||
" Author: Wang Shidong < wsdjeg at 163.com >
|
||||
" URL: https://spacevim.org
|
||||
" License: GPLv3
|
||||
"=============================================================================
|
||||
|
||||
let s:SYS = SpaceVim#api#import('system')
|
||||
|
||||
function! SpaceVim#layers#lang#coffeescript#plugins() abort
|
||||
let plugins = []
|
||||
call add(plugins, ['wsdjeg/vim-coffeescript', {'on_ft' : 'coffee'}])
|
||||
return plugins
|
||||
endfunction
|
||||
|
||||
|
||||
function! SpaceVim#layers#lang#coffeescript#config() abort
|
||||
call SpaceVim#plugins#runner#reg_runner('coffee', {
|
||||
\ 'exe' : 'coffee' . (s:SYS.isWindows ? '.CMD' : ''),
|
||||
\ 'usestdin' : 1,
|
||||
\ 'opt': ['-s'],
|
||||
\ })
|
||||
" call SpaceVim#plugins#runner#reg_runner('coffee', 'coffee %s')
|
||||
call SpaceVim#plugins#repl#reg('coffee', ['coffee' . (s:SYS.isWindows ? '.CMD' : ''), '-i'])
|
||||
call SpaceVim#mapping#space#regesit_lang_mappings('coffee', function('s:language_specified_mappings'))
|
||||
|
||||
endfunction
|
||||
|
||||
function! s:language_specified_mappings() abort
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','r'], 'call SpaceVim#plugins#runner#open()', 'execute current file', 1)
|
||||
let g:_spacevim_mappings_space.l.s = {'name' : '+Send'}
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'i'],
|
||||
\ 'call SpaceVim#plugins#repl#start("coffee")',
|
||||
\ 'start REPL process', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'l'],
|
||||
\ 'call SpaceVim#plugins#repl#send("line")',
|
||||
\ 'send line and keep code buffer focused', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'b'],
|
||||
\ 'call SpaceVim#plugins#repl#send("buffer")',
|
||||
\ 'send buffer and keep code buffer focused', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 's'],
|
||||
\ 'call SpaceVim#plugins#repl#send("selection")',
|
||||
\ 'send selection and keep code buffer focused', 1)
|
||||
let g:neomake_coffee_enabled_makers = ['coffee', 'coffeelint']
|
||||
let g:neomake_coffee_coffeelint_maker = {
|
||||
\ 'args': ['--reporter=csv'],
|
||||
\ 'errorformat': '%f\,%l\,%\d%#\,%trror\,%m,' .
|
||||
\ '%f\,%l\,%trror\,%m,' .
|
||||
\ '%f\,%l\,%\d%#\,%tarn\,%m,' .
|
||||
\ '%f\,%l\,%tarn\,%m'
|
||||
\ }
|
||||
let g:neomake_coffee_coffeelint_remove_invalid_entries = 1
|
||||
let g:neomake_coffee_coffee_maker = {
|
||||
\ 'args': [],
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'errorformat': '%f:%l:%c: %m',
|
||||
\ }
|
||||
let g:neomake_coffee_coffee_remove_invalid_entries = 1
|
||||
" \ 'filter_output' : function('s:filter_coffee_lint'),
|
||||
|
||||
let g:neoformat_enabled_coffee = ['coffeefmt']
|
||||
let g:neoformat_coffee_coffeefmt = {
|
||||
\ 'exe': 'coffee-fmt',
|
||||
\ 'args': ['--indent_stype', 'space', '-i'],
|
||||
\ 'stdin': 0,
|
||||
\ }
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:filter_coffee_lint(lines, job) abort
|
||||
let a:lines = []
|
||||
endfunction
|
@ -9,7 +9,7 @@
|
||||
|
||||
function! SpaceVim#layers#lang#extra#plugins() abort
|
||||
let plugins = [
|
||||
\ ['digitaltoad/vim-jade', { 'on_ft' : ['jade']}],
|
||||
\ ['digitaltoad/vim-pug', { 'on_ft' : ['pug', 'jade']}],
|
||||
\ ['juvenn/mustache.vim', { 'on_ft' : ['mustache']}],
|
||||
\ ['kchmck/vim-coffee-script', { 'on_ft' : ['coffee']}],
|
||||
\ ['PotatoesMaster/i3-vim-syntax', { 'on_ft' : 'i3'}],
|
||||
|
@ -15,7 +15,7 @@ function! SpaceVim#layers#lang#fsharp#plugins() abort
|
||||
endfunction
|
||||
|
||||
|
||||
function! SpaceVim#layers#lang#fsharp#config()
|
||||
function! SpaceVim#layers#lang#fsharp#config() abort
|
||||
call SpaceVim#plugins#repl#reg('fsharp', ['fsharpi', '--readline-'])
|
||||
call SpaceVim#mapping#space#regesit_lang_mappings('python', function('s:language_specified_mappings'))
|
||||
endfunction
|
||||
|
@ -25,6 +25,7 @@ function! SpaceVim#layers#lang#html#config() abort
|
||||
autocmd!
|
||||
autocmd FileType html,css,scss,sass,less,javascript,jsp,vue,eex call s:install_emmet()
|
||||
autocmd Filetype html setlocal omnifunc=htmlcomplete#CompleteTags
|
||||
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
|
||||
augroup END
|
||||
endfunction
|
||||
|
||||
|
@ -56,6 +56,14 @@
|
||||
" normal SPC l m R run one maven goal
|
||||
" normal SPC l m t run maven test
|
||||
"
|
||||
" Gradle key bindings:
|
||||
"
|
||||
" Mode Key Function
|
||||
" -------------------------------------------------------------
|
||||
" normal SPC l g b run gradle clean build
|
||||
" normal SPC l g B run gradle build
|
||||
" normal SPC l g t run gradle test
|
||||
"
|
||||
" Jump key bindings:
|
||||
"
|
||||
" Mode Key Function
|
||||
@ -96,8 +104,12 @@ function! SpaceVim#layers#lang#java#config() abort
|
||||
call add(g:spacevim_project_rooter_patterns, 'pom.xml')
|
||||
augroup SpaceVim_lang_java
|
||||
au!
|
||||
autocmd FileType java setlocal omnifunc=javacomplete#Complete
|
||||
autocmd FileType java call s:java_mappings()
|
||||
if !SpaceVim#layers#lsp#check_filetype('java')
|
||||
" omnifunc will be used only when no java lsp support
|
||||
autocmd FileType java setlocal omnifunc=javacomplete#Complete
|
||||
call SpaceVim#mapping#gd#add('java', function('s:go_to_def'))
|
||||
endif
|
||||
autocmd FileType jsp call JspFileTypeInit()
|
||||
augroup END
|
||||
let g:neoformat_enabled_java = ['googlefmt']
|
||||
let g:neoformat_java_googlefmt = {
|
||||
@ -113,6 +125,23 @@ endfunction
|
||||
|
||||
function! s:language_specified_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)
|
||||
" Import key bindings
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','I'],
|
||||
\ '<Plug>(JavaComplete-Imports-AddMissing)',
|
||||
@ -162,7 +191,7 @@ function! s:language_specified_mappings() abort
|
||||
|
||||
" execute
|
||||
let g:_spacevim_mappings_space.l.r = {'name' : '+Run'}
|
||||
" run main methon
|
||||
" run main method
|
||||
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)
|
||||
@ -183,6 +212,18 @@ function! s:language_specified_mappings() abort
|
||||
call SpaceVim#mapping#space#langSPC('nnoremap', ['l','m', 't'], 'call call('
|
||||
\ . string(function('s:execCMD')) . ', ["mvn test"])',
|
||||
\ 'Run maven test', 1)
|
||||
|
||||
" Gradle
|
||||
let g:_spacevim_mappings_space.l.g = {'name' : '+Gradle'}
|
||||
call SpaceVim#mapping#space#langSPC('nnoremap', ['l','g', 'b'], 'call call('
|
||||
\ . string(function('s:execCMD')) . ', ["gradle clean build"])',
|
||||
\ 'Run gradle clean build', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nnoremap', ['l','g', 'B'], 'call call('
|
||||
\ . string(function('s:execCMD')) . ', ["gradle build"])',
|
||||
\ 'Run gradle build', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nnoremap', ['l','g', 't'], 'call call('
|
||||
\ . string(function('s:execCMD')) . ', ["gradle test"])',
|
||||
\ 'Run gradle test', 1)
|
||||
let g:_spacevim_mappings_space.l.s = {'name' : '+Send'}
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'i'],
|
||||
\ 'call SpaceVim#plugins#repl#start("java")',
|
||||
@ -196,27 +237,23 @@ function! s:language_specified_mappings() abort
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 's'],
|
||||
\ 'call SpaceVim#plugins#repl#send("selection")',
|
||||
\ 'send selection and keep code buffer focused', 1)
|
||||
|
||||
if SpaceVim#layers#lsp#check_filetype('java')
|
||||
nnoremap <silent><buffer> K :call SpaceVim#lsp#show_doc()<CR>
|
||||
|
||||
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'd'],
|
||||
\ 'call SpaceVim#lsp#show_doc()', 'show_document', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'e'],
|
||||
\ 'call SpaceVim#lsp#rename()', 'rename symbol', 1)
|
||||
endif
|
||||
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)
|
||||
endfunction
|
||||
|
||||
function! s:go_to_def() abort
|
||||
call SpaceVim#lsp#go_to_def()
|
||||
endfunction
|
||||
|
||||
function! s:execCMD(cmd) abort
|
||||
|
@ -51,7 +51,11 @@ function! SpaceVim#layers#lang#javascript#config() abort
|
||||
|
||||
call add(g:spacevim_project_rooter_patterns, 'package.json')
|
||||
|
||||
call SpaceVim#plugins#runner#reg_runner('javascript', 'node %s')
|
||||
call SpaceVim#plugins#runner#reg_runner('javascript', {
|
||||
\ 'exe' : 'node',
|
||||
\ 'usestdin' : 1,
|
||||
\ 'opt': ['-'],
|
||||
\ })
|
||||
call SpaceVim#mapping#space#regesit_lang_mappings('javascript',
|
||||
\ function('s:on_ft'))
|
||||
|
||||
@ -62,12 +66,20 @@ function! SpaceVim#layers#lang#javascript#config() abort
|
||||
call SpaceVim#mapping#gd#add('javascript', function('s:tern_go_to_def'))
|
||||
endif
|
||||
|
||||
let g:neomake_javascript_enabled_makers = ['eslint']
|
||||
let g:neomake_javascript_eslint_maker = {
|
||||
\ 'args': ['--format=compact'],
|
||||
\ 'errorformat': '%E%f: line %l\, col %c\, Error - %m,' .
|
||||
\ '%W%f: line %l\, col %c\, Warning - %m,%-G,%-G%*\d problems%#',
|
||||
\ 'cwd': '%:p:h',
|
||||
\ 'output_stream': 'stdout',
|
||||
\ }
|
||||
|
||||
if s:auto_fix
|
||||
" Only use eslint
|
||||
let g:neomake_javascript_enabled_makers = ['eslint']
|
||||
" Use the fix option of eslint
|
||||
let g:neomake_javascript_eslint_args = ['-f', 'compact', '--fix']
|
||||
endif
|
||||
" Only use eslint
|
||||
|
||||
if s:auto_fix
|
||||
augroup SpaceVim_lang_javascript
|
||||
@ -77,6 +89,10 @@ function! SpaceVim#layers#lang#javascript#config() abort
|
||||
autocmd FocusGained * call <SID>checktime_if_javascript()
|
||||
augroup END
|
||||
endif
|
||||
" just add a note here, when using `node -`, the Buffered stdout will not
|
||||
" be flushed by sender.
|
||||
" Use node -i will show the output of repl command.
|
||||
call SpaceVim#plugins#repl#reg('javascript', ['node', '-i'])
|
||||
endfunction
|
||||
|
||||
function! s:on_ft() abort
|
||||
@ -125,6 +141,20 @@ function! s:on_ft() abort
|
||||
|
||||
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'r'],
|
||||
\ 'call SpaceVim#plugins#runner#open()', 'execute current file', 1)
|
||||
|
||||
let g:_spacevim_mappings_space.l.s = {'name' : '+Send'}
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'i'],
|
||||
\ 'call SpaceVim#plugins#repl#start("javascript")',
|
||||
\ 'start REPL process', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'l'],
|
||||
\ 'call SpaceVim#plugins#repl#send("line")',
|
||||
\ 'send line and keep code buffer focused', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'b'],
|
||||
\ 'call SpaceVim#plugins#repl#send("buffer")',
|
||||
\ 'send buffer and keep code buffer focused', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 's'],
|
||||
\ 'call SpaceVim#plugins#repl#send("selection")',
|
||||
\ 'send selection and keep code buffer focused', 1)
|
||||
endfunction
|
||||
|
||||
function! s:tern_go_to_def() abort
|
||||
|
@ -12,6 +12,13 @@
|
||||
" This layer is for kotlin development.
|
||||
|
||||
|
||||
" Load SpaceVim APIs:
|
||||
let s:SYS = SpaceVim#api#import('system')
|
||||
|
||||
" Default Options:
|
||||
let s:enable_native_support = 0
|
||||
|
||||
|
||||
function! SpaceVim#layers#lang#kotlin#plugins() abort
|
||||
let plugins = []
|
||||
call add(plugins, ['udalov/kotlin-vim', {'merged' : 0}])
|
||||
@ -33,6 +40,23 @@ function! SpaceVim#layers#lang#kotlin#config() abort
|
||||
let g:neomake_kotlin_enabled_makers = ['kotlinc']
|
||||
endif
|
||||
call SpaceVim#mapping#space#regesit_lang_mappings('kotlin', function('s:language_specified_mappings'))
|
||||
if s:enable_native_support
|
||||
let runner = {
|
||||
\ 'exe' : 'kotlinc-native'. (s:SYS.isWindows ? '.BAT' : ''),
|
||||
\ 'targetopt' : '-o',
|
||||
\ 'opt' : [],
|
||||
\ 'usestdin' : 0,
|
||||
\ }
|
||||
call SpaceVim#plugins#runner#reg_runner('kotlin', [runner, '#TEMP#'])
|
||||
else
|
||||
let runner = {
|
||||
\ 'exe' : 'kotlinc-jvm'. (s:SYS.isWindows ? '.BAT' : ''),
|
||||
\ 'opt' : ['-script'],
|
||||
\ 'usestdin' : 0,
|
||||
\ }
|
||||
call SpaceVim#plugins#runner#reg_runner('kotlin', runner)
|
||||
endif
|
||||
call SpaceVim#plugins#repl#reg('kotlin', ['kotlinc-jvm'. (s:SYS.isWindows ? '.BAT' : '')])
|
||||
endfunction
|
||||
|
||||
function! s:language_specified_mappings() abort
|
||||
@ -44,6 +68,20 @@ function! s:language_specified_mappings() abort
|
||||
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'e'],
|
||||
\ 'call SpaceVim#lsp#rename()', 'rename symbol', 1)
|
||||
endif
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','r'], 'call SpaceVim#plugins#runner#open()', 'execute current file', 1)
|
||||
let g:_spacevim_mappings_space.l.s = {'name' : '+Send'}
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'i'],
|
||||
\ 'call SpaceVim#plugins#repl#start("kotlin")',
|
||||
\ 'start REPL process', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'l'],
|
||||
\ 'call SpaceVim#plugins#repl#send("line")',
|
||||
\ 'send line and keep code buffer focused', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'b'],
|
||||
\ 'call SpaceVim#plugins#repl#send("buffer")',
|
||||
\ 'send buffer and keep code buffer focused', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 's'],
|
||||
\ 'call SpaceVim#plugins#repl#send("selection")',
|
||||
\ 'send selection and keep code buffer focused', 1)
|
||||
endfunction
|
||||
func! s:classpath() abort
|
||||
|
||||
@ -53,3 +91,8 @@ func! s:outputdir() abort
|
||||
|
||||
endf
|
||||
|
||||
function! SpaceVim#layers#lang#kotlin#set_variable(var) abort
|
||||
let s:enable_native_support = get(a:var,
|
||||
\ 'enable-native-support',
|
||||
\ 'nil')
|
||||
endfunction
|
||||
|
@ -117,46 +117,46 @@ function! SpaceVim#layers#lang#lisp#config() abort
|
||||
endfunction
|
||||
|
||||
|
||||
fu! s:lisp()
|
||||
fu! s:lisp() abort
|
||||
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)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','c', 'd'], "call VlimeCloseCurConnection()", 'Disconnect', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','c', 'R'], "call VlimeRenameCurConnection()", 'Rename the current connection', 1)
|
||||
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)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','c', 'd'], 'call VlimeCloseCurConnection()', 'Disconnect', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','c', 'R'], 'call VlimeRenameCurConnection()', 'Rename the current connection', 1)
|
||||
|
||||
let g:_spacevim_mappings_space.l.r = {'name' : '+Server Management'}
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','r', 'r'], "call VlimeNewServer()", 'Run a new Vlime server and connect to it', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','r', 'v'], "call VlimeShowSelectedServer()", 'View the console output of a server', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','r', 'R'], "call VlimeRenameSelectedServer()", 'Rename a server', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','r', 'r'], 'call VlimeNewServer()', 'Run a new Vlime server and connect to it', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','r', 'v'], 'call VlimeShowSelectedServer()', 'View the console output of a server', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','r', 'R'], 'call VlimeRenameSelectedServer()', 'Rename a server', 1)
|
||||
|
||||
let g:_spacevim_mappings_space.l.s = {'name' : '+Sending Stuff To The REPL'}
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s','s'], "call VlimeSendToREPL(vlime#ui#CurExprOrAtom())",
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s','s'], 'call VlimeSendToREPL(vlime#ui#CurExprOrAtom())',
|
||||
\ 'Send s-expr or atom under the cursor to REPL', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s','e'], "call VlimeSendToREPL(vlime#ui#CurExpr())",
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s','e'], 'call VlimeSendToREPL(vlime#ui#CurExpr())',
|
||||
\ 'Send s-expr under the cursor to REPL', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s','t'], "VlimeSendToREPL(vlime#ui#CurTopExpr())",
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s','t'], 'VlimeSendToREPL(vlime#ui#CurTopExpr())',
|
||||
\ 'Send to-level s-expr under the cursor to REPL', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s','a'], "call VlimeSendToREPL(vlime#ui#CurAtom())",
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s','a'], 'call VlimeSendToREPL(vlime#ui#CurAtom())',
|
||||
\ 'Send atom under the cursor to REPL', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s','i'], "call VlimeSendToREPL()",
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s','i'], 'call VlimeSendToREPL()',
|
||||
\ 'Open vlime input buffer for REPL', 1)
|
||||
call SpaceVim#mapping#space#langSPC('vmap', ['l','s','v'], "call VlimeSendToREPL(vlime#ui#CurSelection())",
|
||||
call SpaceVim#mapping#space#langSPC('vmap', ['l','s','v'], 'call VlimeSendToREPL(vlime#ui#CurSelection())',
|
||||
\ 'Send the current selection to the REPL', 1)
|
||||
|
||||
let g:_spacevim_mappings_space.l.m = {'name' : '+Expanding Macros'}
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','m','l'], "call VlimeExpandMacro(vlime#ui#CurExpr(), v:false)",
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','m','l'], 'call VlimeExpandMacro(vlime#ui#CurExpr(), v:false)',
|
||||
\ 'Expand the macro under the cursor', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','m','a'], "call VlimeExpandMacro(vlime#ui#CurExpr(), v:true)",
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','m','a'], 'call VlimeExpandMacro(vlime#ui#CurExpr(), v:true)',
|
||||
\ 'Expand the macro under the cursor and all nested macros', 1)
|
||||
|
||||
let g:_spacevim_mappings_space.l.o = {'name' : '+Compiling'}
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','o','e'], "call VlimeCompile(vlime#ui#CurExpr(v:true))",
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','o','e'], 'call VlimeCompile(vlime#ui#CurExpr(v:true))',
|
||||
\ 'Compile the form under the cursor', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','o','t'], "call VlimeCompile(vlime#ui#CurTopExpr(v:true))",
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','o','t'], 'call VlimeCompile(vlime#ui#CurTopExpr(v:true))',
|
||||
\ 'Compile the top-level form under the cursor', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','o','f'], "call VlimeCompileFile(expand('%:p'))",
|
||||
\ 'Compile the current file', 1)
|
||||
call SpaceVim#mapping#space#langSPC('vmap', ['l','o','v'], "call VlimeCompile(vlime#ui#CurSelection(v:true))",
|
||||
call SpaceVim#mapping#space#langSPC('vmap', ['l','o','v'], 'call VlimeCompile(vlime#ui#CurSelection(v:true))',
|
||||
\ 'Compile the current selection', 1)
|
||||
|
||||
let g:_spacevim_mappings_space.l.x = {'name' : '+Cross references'}
|
||||
@ -220,23 +220,23 @@ fu! s:lisp()
|
||||
\ 'Prompt for the expression to inspect', 1)
|
||||
endf
|
||||
|
||||
fu! s:vlime_sldb()
|
||||
fu! s:vlime_sldb() abort
|
||||
endf
|
||||
fu! s:vlime_repl()
|
||||
fu! s:vlime_repl() abort
|
||||
endf
|
||||
fu! s:vlime_inspector()
|
||||
fu! s:vlime_inspector() abort
|
||||
endf
|
||||
fu! s:vlime_xref()
|
||||
fu! s:vlime_xref() abort
|
||||
endf
|
||||
fu! s:vlime_notes()
|
||||
fu! s:vlime_notes() abort
|
||||
endf
|
||||
fu! s:vlime_threads()
|
||||
fu! s:vlime_threads() abort
|
||||
endf
|
||||
fu! s:vlime_server()
|
||||
fu! s:vlime_server() abort
|
||||
endf
|
||||
fu! s:vlime_preview()
|
||||
fu! s:vlime_preview() abort
|
||||
endf
|
||||
fu! s:vlime_arglist()
|
||||
fu! s:vlime_arglist() abort
|
||||
endf
|
||||
fu! s:vlime_input()
|
||||
fu! s:vlime_input() abort
|
||||
endf
|
||||
|
@ -21,35 +21,58 @@
|
||||
function! SpaceVim#layers#lang#lua#plugins() abort
|
||||
let plugins = []
|
||||
" Improved Lua 5.3 syntax and indentation support for Vim
|
||||
call add(plugins, ['tbastos/vim-lua', {'on_ft' : 'lua'}])
|
||||
call add(plugins, ['wsdjeg/vim-lua', {'on_ft' : 'lua'}])
|
||||
call add(plugins, ['WolfgangMehner/lua-support', {'on_ft' : 'lua'}])
|
||||
call add(plugins, ['SpaceVim/vim-luacomplete', {'on_ft' : 'lua', 'if' : has('lua')}])
|
||||
return plugins
|
||||
endfunction
|
||||
|
||||
let s:lua_repl_command = ''
|
||||
|
||||
function! SpaceVim#layers#lang#lua#config() abort
|
||||
if has('lua')
|
||||
augroup spacevim_lua
|
||||
autocmd FileType lua setlocal omnifunc=luacomplete#complete
|
||||
augroup END
|
||||
endif
|
||||
|
||||
augroup spacevim_lang_lua
|
||||
autocmd!
|
||||
autocmd FileType lua set comments=f:--
|
||||
augroup END
|
||||
call SpaceVim#mapping#space#regesit_lang_mappings('lua', function('s:language_specified_mappings'))
|
||||
let luaexe = filter(['lua53', 'lua52', 'lua51'], 'executable(v:val)')
|
||||
if !empty(luaexe)
|
||||
call SpaceVim#plugins#runner#reg_runner('lua', luaexe[0] . ' %s')
|
||||
call SpaceVim#plugins#runner#reg_runner('lua', {
|
||||
\ 'exe' : luaexe[0],
|
||||
\ 'opt' : ['-'],
|
||||
\ 'usestdin' : 1,
|
||||
\ })
|
||||
else
|
||||
call SpaceVim#plugins#runner#reg_runner('lua', 'lua %s')
|
||||
call SpaceVim#plugins#runner#reg_runner('lua', {
|
||||
\ 'exe' : 'lua',
|
||||
\ 'opt' : ['-'],
|
||||
\ 'usestdin' : 1,
|
||||
\ })
|
||||
endif
|
||||
let g:neomake_lua_enabled_makers = ['luac']
|
||||
let luacexe = filter(['luac53', 'luac52', 'luac51'], 'executable(v:val)')
|
||||
if !empty(luacexe)
|
||||
let g:neomake_lua_luac_maker = {
|
||||
\ 'exe': luacexe[0],
|
||||
\ 'args': ['-p'],
|
||||
\ 'errorformat': '%*\f: %#%f:%l: %m',
|
||||
\ }
|
||||
else
|
||||
let g:neomake_lua_luac_maker = {
|
||||
\ 'exe': 'luac',
|
||||
\ 'args': ['-p'],
|
||||
\ 'errorformat': '%*\f: %#%f:%l: %m',
|
||||
\ }
|
||||
endif
|
||||
if !empty(s:lua_repl_command)
|
||||
call SpaceVim#plugins#repl#reg('lua',s:lua_repl_command)
|
||||
call SpaceVim#plugins#repl#reg('lua',s:lua_repl_command)
|
||||
else
|
||||
if executable('luap')
|
||||
call SpaceVim#plugins#repl#reg('lua', 'luap')
|
||||
elseif !empty(luaexe)
|
||||
call SpaceVim#plugins#repl#reg('lua', luaexe + ['-i'])
|
||||
else
|
||||
call SpaceVim#plugins#repl#reg('lua', 'lua')
|
||||
call SpaceVim#plugins#repl#reg('lua', ['lua', '-i'])
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
@ -25,12 +25,21 @@ function! SpaceVim#layers#lang#markdown#plugins() abort
|
||||
call add(plugins, ['joker1007/vim-markdown-quote-syntax',{ 'on_ft' : 'markdown'}])
|
||||
call add(plugins, ['mzlogin/vim-markdown-toc',{ 'on_ft' : 'markdown'}])
|
||||
call add(plugins, ['iamcco/mathjax-support-for-mkdp',{ 'on_ft' : 'markdown'}])
|
||||
call add(plugins, ['iamcco/markdown-preview.vim', { 'depends' : 'open-browser.vim', 'on_ft' : 'markdown' }])
|
||||
call add(plugins, ['iamcco/markdown-preview.nvim',
|
||||
\ { 'on_ft' : 'markdown',
|
||||
\ 'depends': 'open-browser.vim',
|
||||
\ 'build' : 'cd app & yarn install' }])
|
||||
call add(plugins, ['lvht/tagbar-markdown',{'merged' : 0}])
|
||||
return plugins
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#lang#markdown#config() abort
|
||||
" do not highlight markdown error
|
||||
let g:markdown_hi_error = 0
|
||||
" the fenced languages based on loaded language layer
|
||||
let g:markdown_fenced_languages = []
|
||||
let g:markdown_nested_languages = map(filter(SpaceVim#layers#get(),
|
||||
\ 'v:val =~# "^lang#" && v:val !=# "lang#markdown" && v:val !=# "lang#vim"'), 'v:val[5:]')
|
||||
let g:vmt_list_item_char = s:md_listItemChar
|
||||
let g:markdown_minlines = 100
|
||||
let g:markdown_syntax_conceal = 0
|
||||
@ -38,8 +47,8 @@ function! SpaceVim#layers#lang#markdown#config() abort
|
||||
let g:markdown_enable_insert_mode_leader_mappings = 0
|
||||
let g:markdown_enable_spell_checking = 0
|
||||
let g:markdown_quote_syntax_filetypes = {
|
||||
\ "vim" : {
|
||||
\ "start" : "\\%(vim\\|viml\\)",
|
||||
\ 'vim' : {
|
||||
\ 'start' : "\\%(vim\\|viml\\)",
|
||||
\},
|
||||
\}
|
||||
let remarkrc = s:generate_remarkrc()
|
||||
@ -58,8 +67,10 @@ function! SpaceVim#layers#lang#markdown#config() abort
|
||||
let g:mkdp_browserfunc = 'openbrowser#open'
|
||||
" }}}
|
||||
call SpaceVim#mapping#space#regesit_lang_mappings('markdown', function('s:mappings'))
|
||||
nnoremap <silent> <plug>(markdown-insert-link) :call <SID>markdown_insert_url()<Cr>
|
||||
xnoremap <silent> <plug>(markdown-insert-link) :call <SID>markdown_insert_url()<Cr>
|
||||
nnoremap <silent> <plug>(markdown-insert-link) :call <SID>markdown_insert_link(0, 0)<Cr>
|
||||
xnoremap <silent> <plug>(markdown-insert-link) :<C-u> call <SID>markdown_insert_link(1, 0)<Cr>
|
||||
nnoremap <silent> <plug>(markdown-insert-picture) :call <SID>markdown_insert_link(0, 1)<Cr>
|
||||
xnoremap <silent> <plug>(markdown-insert-picture) :<C-u> call <SID>markdown_insert_link(1, 1)<Cr>
|
||||
augroup spacevim_layer_lang_markdown
|
||||
autocmd!
|
||||
autocmd FileType markdown setlocal omnifunc=htmlcomplete#CompleteTags
|
||||
@ -71,9 +82,13 @@ function! s:mappings() abort
|
||||
let g:_spacevim_mappings_space = {}
|
||||
endif
|
||||
let g:_spacevim_mappings_space.l = {'name' : '+Language Specified'}
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','ft'], "Tabularize /|", 'Format table under cursor', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','p'], "MarkdownPreview", 'Real-time markdown preview', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','p'], 'MarkdownPreview', 'Real-time markdown preview', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','k'], '<plug>(markdown-insert-link)', 'add link url', 0, 1)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','K'], '<plug>(markdown-insert-picture)', 'add link picture', 0, 1)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l', 'r'],
|
||||
\ 'call call('
|
||||
\ . string(function('s:run_code_in_block'))
|
||||
\ . ', [])', 'run code in block', 1)
|
||||
endfunction
|
||||
|
||||
function! s:generate_remarkrc() abort
|
||||
@ -97,19 +112,47 @@ function! s:generate_remarkrc() abort
|
||||
return f
|
||||
endfunction
|
||||
|
||||
function! s:markdown_insert_url() abort
|
||||
let pos1 = getpos("'<")
|
||||
let pos2 = getpos("'>")
|
||||
let scope = sort([pos1[2], pos2[2]], 'n')
|
||||
"FIXME: list scope is not same as string scope index.
|
||||
let url = @+
|
||||
if !empty(url)
|
||||
let line = getline(pos1[1])
|
||||
let splits = [line[:scope[0]], line[scope[0] : scope[1]], line[scope[1]:]]
|
||||
let result = splits[0] . '[' . splits[1] . '](' . url . ')' . splits[2]
|
||||
call setline(pos1[1], result)
|
||||
function! s:markdown_insert_link(isVisual, isPicture) abort
|
||||
if !empty(@+)
|
||||
let l:save_register_unnamed = @"
|
||||
let l:save_edge_left = getpos("'<")
|
||||
let l:save_edge_right = getpos("'>")
|
||||
if !a:isVisual
|
||||
execute "normal! viw\<esc>"
|
||||
endif
|
||||
let l:paste = (col("'>") == col("$") - 1 ? 'p' : 'P')
|
||||
normal! gvx
|
||||
let @" = '[' . @" . '](' . @+ . ')'
|
||||
if a:isPicture
|
||||
let @" = '!' . @"
|
||||
endif
|
||||
execute 'normal! ' . l:paste
|
||||
let @" = l:save_register_unnamed
|
||||
if a:isVisual
|
||||
let l:save_edge_left[2] += 1
|
||||
if l:save_edge_left[1] == l:save_edge_right[1]
|
||||
let l:save_edge_right[2] += 1
|
||||
endif
|
||||
endif
|
||||
call setpos("'<", l:save_edge_left)
|
||||
call setpos("'>", l:save_edge_right)
|
||||
endif
|
||||
keepjumps call cursor(pos1[1], scope[0])
|
||||
endfunction
|
||||
|
||||
" this function need context_filetype.vim
|
||||
function! s:run_code_in_block() abort
|
||||
let cf = context_filetype#get()
|
||||
if cf.filetype !=# 'markdown'
|
||||
let runner = SpaceVim#plugins#runner#get(cf.filetype)
|
||||
if type(runner) ==# 4
|
||||
let runner['usestdin'] = 1
|
||||
let runner['range'] = [cf['range'][0][0], cf['range'][1][0]]
|
||||
call SpaceVim#plugins#runner#open(runner)
|
||||
elseif type(runner) ==# 3 && type(runner[0]) == 4
|
||||
let runner[0]['usestdin'] = 1
|
||||
let runner[0]['range'] = [cf['range'][0][0], cf['range'][1][0]]
|
||||
call SpaceVim#plugins#runner#open(runner)
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
" License: GPLv3
|
||||
"=============================================================================
|
||||
|
||||
let s:SYS = SpaceVim#api#import('system')
|
||||
|
||||
function! SpaceVim#layers#lang#perl#plugins() abort
|
||||
let plugins = []
|
||||
@ -17,9 +18,17 @@ endfunction
|
||||
|
||||
function! SpaceVim#layers#lang#perl#config() abort
|
||||
let g:perldoc_no_default_key_mappings = 1
|
||||
call SpaceVim#plugins#runner#reg_runner('perl', 'perl %s')
|
||||
call SpaceVim#plugins#runner#reg_runner('perl', {
|
||||
\ 'exe' : 'perl',
|
||||
\ 'opt' : ['-'],
|
||||
\ 'usestdin' : 1,
|
||||
\ })
|
||||
call SpaceVim#mapping#space#regesit_lang_mappings('perl', function('s:language_specified_mappings'))
|
||||
call SpaceVim#plugins#repl#reg('perl', ['perl', '-de', '42'])
|
||||
if executable('perli')
|
||||
call SpaceVim#plugins#repl#reg('perl', ['perli'. (s:SYS.isWindows ? '.CMD' : '')])
|
||||
else
|
||||
call SpaceVim#plugins#repl#reg('perl', ['perl', '-del'])
|
||||
endif
|
||||
endfunction
|
||||
function! s:language_specified_mappings() abort
|
||||
nnoremap <silent><buffer> K :Perldoc<CR>
|
||||
|
49
autoload/SpaceVim/layers/lang/processing.vim
Normal file
49
autoload/SpaceVim/layers/lang/processing.vim
Normal file
@ -0,0 +1,49 @@
|
||||
"=============================================================================
|
||||
" processing.vim --- SpaceVim lang#processing layer
|
||||
" Copyright (c) 2016-2017 Wang Shidong & Contributors
|
||||
" Author: Russell Bentley < russell.w.bentley at icloud.com >
|
||||
" URL: https://spacevim.org
|
||||
" License: GPLv3
|
||||
"=============================================================================
|
||||
|
||||
""
|
||||
" @section lang#processing, layer-lang-processing
|
||||
" @parentsection layers
|
||||
" This layer is for Processing development:
|
||||
" https://processing.org
|
||||
"
|
||||
" This is based on the work from https://github.com/sophacles/vim-processing
|
||||
"
|
||||
" Requirements:
|
||||
"
|
||||
" 1. You will need a copy of processing-java. The best way to do this is to get a copy of the Processing IDE from https://processing.org/download/
|
||||
"
|
||||
" Once you have it, run it, and then select Tools -> install
|
||||
" "processing-java"
|
||||
"
|
||||
" @subsection Mappings
|
||||
" >
|
||||
" Mode Key Function
|
||||
" -----------------------------------------------
|
||||
" normal SPC l r execute current sketch
|
||||
" <
|
||||
|
||||
function! SpaceVim#layers#lang#processing#plugins() abort
|
||||
let plugins = [
|
||||
\ ['sophacles/vim-processing', { 'on_ft' : 'processing' }],
|
||||
\ ]
|
||||
return plugins
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#lang#processing#config() abort
|
||||
let runner = 'processing-java --force --output=/tmp/vim-processing --sketch=$(pwd)/$(dirname %s) --run'
|
||||
call SpaceVim#plugins#runner#reg_runner('processing', runner)
|
||||
call SpaceVim#mapping#space#regesit_lang_mappings('processing',
|
||||
\ function('s:language_specified_mappings'))
|
||||
endfunction
|
||||
|
||||
function! s:language_specified_mappings() abort
|
||||
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'r'],
|
||||
\ 'call SpaceVim#plugins#runner#open()', 'execute current file', 1)
|
||||
endfunction
|
||||
|
@ -53,7 +53,8 @@ function! SpaceVim#layers#lang#python#config() abort
|
||||
call SpaceVim#plugins#runner#reg_runner('python',
|
||||
\ {
|
||||
\ 'exe' : function('s:getexe'),
|
||||
\ 'opt' : [],
|
||||
\ 'opt' : ['-'],
|
||||
\ 'usestdin' : 1,
|
||||
\ })
|
||||
call SpaceVim#mapping#gd#add('python', function('s:go_to_def'))
|
||||
call SpaceVim#mapping#space#regesit_lang_mappings('python', function('s:language_specified_mappings'))
|
||||
@ -65,7 +66,7 @@ function! SpaceVim#layers#lang#python#config() abort
|
||||
if executable('ipython')
|
||||
call SpaceVim#plugins#repl#reg('python', 'ipython --no-term-title')
|
||||
elseif executable('python')
|
||||
call SpaceVim#plugins#repl#reg('python', 'python')
|
||||
call SpaceVim#plugins#repl#reg('python', ['python', '-i'])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
@ -11,3 +11,36 @@ function! SpaceVim#layers#lang#r#plugins() abort
|
||||
call add(plugins, ['wsdjeg/Nvim-R', {'merged' : 0}])
|
||||
return plugins
|
||||
endfunction
|
||||
|
||||
let s:r_repl_command = ''
|
||||
function! SpaceVim#layers#lang#r#set_variable(var) abort
|
||||
let s:r_repl_command = get(a:var, 'repl_command', '')
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#lang#r#config() abort
|
||||
call SpaceVim#plugins#runner#reg_runner('r', 'r %s')
|
||||
call SpaceVim#mapping#space#regesit_lang_mappings('r', function('s:language_specified_mappings'))
|
||||
if !empty(s:r_repl_command)
|
||||
call SpaceVim#plugins#repl#reg('r',s:r_repl_command)
|
||||
else
|
||||
call SpaceVim#plugins#repl#reg('r', 'r')
|
||||
endif
|
||||
|
||||
endfunction
|
||||
|
||||
function! s:language_specified_mappings() abort
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l', 'r'], 'call SpaceVim#plugins#runner#open()', 'execute current file', 1)
|
||||
let g:_spacevim_mappings_space.l.s = {'name' : '+Send'}
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'i'],
|
||||
\ 'call SpaceVim#plugins#repl#start("r")',
|
||||
\ 'start REPL process', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'l'],
|
||||
\ 'call SpaceVim#plugins#repl#send("line")',
|
||||
\ 'send line and keep code buffer focused', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'b'],
|
||||
\ 'call SpaceVim#plugins#repl#send("buffer")',
|
||||
\ 'send buffer and keep code buffer focused', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 's'],
|
||||
\ 'call SpaceVim#plugins#repl#send("selection")',
|
||||
\ 'send selection and keep code buffer focused', 1)
|
||||
endfunction
|
||||
|
38
autoload/SpaceVim/layers/lang/red.vim
Normal file
38
autoload/SpaceVim/layers/lang/red.vim
Normal file
@ -0,0 +1,38 @@
|
||||
"=============================================================================
|
||||
" red.vim --- red language layer
|
||||
" Copyright (c) 2016-2017 Wang Shidong & Contributors
|
||||
" Author: Wang Shidong < wsdjeg at 163.com >
|
||||
" URL: https://spacevim.org
|
||||
" License: GPLv3
|
||||
"=============================================================================
|
||||
|
||||
|
||||
function! SpaceVim#layers#lang#red#plugins() abort
|
||||
let plugins = []
|
||||
call add(plugins, ['DavidFeng/vim-red', {'merged' : 0}])
|
||||
return plugins
|
||||
endfunction
|
||||
|
||||
|
||||
function! SpaceVim#layers#lang#red#config() abort
|
||||
call SpaceVim#plugins#runner#reg_runner('red', 'red --cli %s')
|
||||
call SpaceVim#mapping#space#regesit_lang_mappings('red', function('s:language_specified_mappings'))
|
||||
call SpaceVim#plugins#repl#reg('red', 'red --cli')
|
||||
endfunction
|
||||
|
||||
function! s:language_specified_mappings() abort
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l', 'r'], 'call SpaceVim#plugins#runner#open()', 'execute current file', 1)
|
||||
let g:_spacevim_mappings_space.l.s = {'name' : '+Send'}
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'i'],
|
||||
\ 'call SpaceVim#plugins#repl#start("red")',
|
||||
\ 'start REPL process', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'l'],
|
||||
\ 'call SpaceVim#plugins#repl#send("line")',
|
||||
\ 'send line and keep code buffer focused', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'b'],
|
||||
\ 'call SpaceVim#plugins#repl#send("buffer")',
|
||||
\ 'send buffer and keep code buffer focused', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 's'],
|
||||
\ 'call SpaceVim#plugins#repl#send("selection")',
|
||||
\ 'send selection and keep code buffer focused', 1)
|
||||
endfunction
|
@ -16,6 +16,7 @@ let s:ruby_repl_command = ''
|
||||
|
||||
function! SpaceVim#layers#lang#ruby#config() abort
|
||||
call SpaceVim#plugins#runner#reg_runner('ruby', 'ruby %s')
|
||||
call SpaceVim#mapping#gd#add('ruby', function('s:go_to_def'))
|
||||
call SpaceVim#mapping#space#regesit_lang_mappings('ruby', function('s:language_specified_mappings'))
|
||||
if !empty(s:ruby_repl_command)
|
||||
call SpaceVim#plugins#repl#reg('ruby',s:ruby_repl_command)
|
||||
@ -30,6 +31,14 @@ endfunction
|
||||
|
||||
function! s:language_specified_mappings() abort
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l', 'r'], 'call SpaceVim#plugins#runner#open()', 'execute current file', 1)
|
||||
if SpaceVim#layers#lsp#check_filetype('ruby')
|
||||
nnoremap <silent><buffer> K :call SpaceVim#lsp#show_doc()<CR>
|
||||
|
||||
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'd'],
|
||||
\ 'call SpaceVim#lsp#show_doc()', 'show_document', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'e'],
|
||||
\ 'call SpaceVim#lsp#rename()', 'rename symbol', 1)
|
||||
endif
|
||||
let g:_spacevim_mappings_space.l.s = {'name' : '+Send'}
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'i'],
|
||||
\ 'call SpaceVim#plugins#repl#start("ruby")',
|
||||
@ -47,4 +56,13 @@ function! s:language_specified_mappings() abort
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','c', 'f'],
|
||||
\ 'Neoformat rubocop',
|
||||
\ 'Runs RuboCop on the currently visited file', 1)
|
||||
let g:neomake_ruby_rubylint_remove_invalid_entries = 1
|
||||
endfunction
|
||||
|
||||
function! s:go_to_def() abort
|
||||
if !SpaceVim#layers#lsp#check_filetype('ruby')
|
||||
normal! gd
|
||||
else
|
||||
call SpaceVim#lsp#go_to_def()
|
||||
endif
|
||||
endfunction
|
||||
|
@ -52,10 +52,12 @@ function! SpaceVim#layers#lang#rust#plugins() abort
|
||||
return plugins
|
||||
endfunction
|
||||
|
||||
let s:recommended_style = 0
|
||||
|
||||
function! SpaceVim#layers#lang#rust#config() abort
|
||||
let g:racer_experimental_completer = 1
|
||||
let g:racer_cmd = get(g:, 'racer_cmd', $HOME . '/.cargo/bin/racer')
|
||||
|
||||
let g:rust_recommended_style = s:recommended_style
|
||||
if SpaceVim#layers#lsp#check_filetype('rust')
|
||||
call SpaceVim#mapping#gd#add('rust',
|
||||
\ function('SpaceVim#lsp#go_to_def'))
|
||||
@ -63,12 +65,25 @@ function! SpaceVim#layers#lang#rust#config() abort
|
||||
call SpaceVim#mapping#gd#add('rust', function('s:gotodef'))
|
||||
endif
|
||||
|
||||
call SpaceVim#plugins#runner#reg_runner('rust',
|
||||
\ ['rustc %s -o #TEMP#', '#TEMP#'])
|
||||
let runner = {
|
||||
\ 'exe' : 'rustc',
|
||||
\ 'targetopt' : '-o',
|
||||
\ 'opt' : ['-'],
|
||||
\ 'usestdin' : 1,
|
||||
\ }
|
||||
call SpaceVim#plugins#runner#reg_runner('rust', [runner, '#TEMP#'])
|
||||
call SpaceVim#mapping#space#regesit_lang_mappings('rust',
|
||||
\ function('s:language_specified_mappings'))
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#lang#rust#set_variable(var) abort
|
||||
|
||||
let s:recommended_style = get(a:var,
|
||||
\ 'recommended-style',
|
||||
\ s:recommended_style)
|
||||
|
||||
endfunction
|
||||
|
||||
function! s:language_specified_mappings() abort
|
||||
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 's'],
|
||||
\ '<Plug>(rust-def-split)', 'rust-def-split', 0)
|
||||
|
@ -17,7 +17,7 @@ function! SpaceVim#layers#lang#sh#plugins() abort
|
||||
return l:plugins
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#lang#sh#config()
|
||||
function! SpaceVim#layers#lang#sh#config() abort
|
||||
" chrisbra/vim-zsh {{{
|
||||
let g:zsh_fold_enable = 1
|
||||
" }}}
|
||||
|
@ -10,6 +10,7 @@
|
||||
function! SpaceVim#layers#lang#typescript#plugins() abort
|
||||
let plugins = []
|
||||
call add(plugins, ['leafgarland/typescript-vim'])
|
||||
call add(plugins, ['heavenshell/vim-jsdoc', { 'on_cmd': 'JsDoc' }])
|
||||
if !SpaceVim#layers#lsp#check_filetype('typescript')
|
||||
if has('nvim')
|
||||
call add(plugins, ['mhartington/nvim-typescript', {'build': './install.sh'}])
|
||||
@ -60,7 +61,7 @@ function! s:on_ft() abort
|
||||
if has('nvim')
|
||||
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'c'], 'TSTypeDef',
|
||||
\ 'type definition', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'd'], 'TsDoc',
|
||||
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'd'], 'TSDoc',
|
||||
\ 'show document', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'e'], 'TSRename',
|
||||
\ 'rename symbol', 1)
|
||||
@ -91,6 +92,11 @@ function! s:on_ft() abort
|
||||
\ 'references', 1)
|
||||
endif
|
||||
endif
|
||||
let g:_spacevim_mappings_space.l.g = {'name' : '+Generate'}
|
||||
|
||||
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'g', 'd'], 'JsDoc',
|
||||
\ 'generate JSDoc', 1)
|
||||
|
||||
endfunction
|
||||
|
||||
function! s:go_to_def() abort
|
||||
|
@ -17,14 +17,14 @@ function! SpaceVim#layers#lang#vim#plugins() abort
|
||||
\ ['todesking/vint-syntastic', { 'on_ft' : 'vim'}],
|
||||
\ ]
|
||||
call add(plugins,['tweekmonster/exception.vim', {'merged' : 0}])
|
||||
call add(plugins,['mhinz/vim-lookup', {'merged' : 0}])
|
||||
call add(plugins,['wsdjeg/vim-lookup', {'merged' : 0}])
|
||||
call add(plugins,['Shougo/neco-vim', { 'on_event' : 'InsertEnter', 'loadconf_before' : 1}])
|
||||
if g:spacevim_autocomplete_method == 'asyncomplete'
|
||||
if g:spacevim_autocomplete_method ==# 'asyncomplete'
|
||||
call add(plugins, ['prabirshrestha/asyncomplete-necovim.vim', {
|
||||
\ 'loadconf' : 1,
|
||||
\ 'merged' : 0,
|
||||
\ }])
|
||||
elseif g:spacevim_autocomplete_method == 'coc'
|
||||
elseif g:spacevim_autocomplete_method ==# 'coc'
|
||||
call add(plugins, ['neoclide/coc-neco', {'merged' : 0}])
|
||||
endif
|
||||
call add(plugins,['tweekmonster/helpful.vim', {'on_cmd': 'HelpfulVersion'}])
|
||||
@ -34,7 +34,7 @@ endfunction
|
||||
function! SpaceVim#layers#lang#vim#config() abort
|
||||
call SpaceVim#mapping#gd#add('vim','lookup#lookup')
|
||||
call SpaceVim#mapping#space#regesit_lang_mappings('vim', function('s:language_specified_mappings'))
|
||||
call SpaceVim#plugins#highlight#reg_expr('vim', '^\s*\(func\|fu\|function\)!\?\s\+', '^\s*\(endfunc\|endf\|endfunction\)')
|
||||
call SpaceVim#plugins#highlight#reg_expr('vim', '\s*\<fu\%[nction]\>!\?\s*', '\s*\<endf\%[unction]\>\s*')
|
||||
endfunction
|
||||
|
||||
function! s:language_specified_mappings() abort
|
||||
|
@ -23,5 +23,9 @@ function! SpaceVim#layers#lang#xml#plugins() abort
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#lang#xml#config() abort
|
||||
|
||||
augroup spacevim_lang_xml
|
||||
autocmd!
|
||||
autocmd FileType xml call XmlFileTypeInit()
|
||||
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
|
||||
augroup END
|
||||
endfunction
|
||||
|
@ -9,7 +9,7 @@
|
||||
function! SpaceVim#layers#lsp#plugins() abort
|
||||
let plugins = []
|
||||
|
||||
if SpaceVim#layers#isLoaded("autocomplete") && get(g:, "spacevim_autocomplete_method") ==# 'coc'
|
||||
if SpaceVim#layers#isLoaded('autocomplete') && get(g:, 'spacevim_autocomplete_method') ==# 'coc'
|
||||
" nop
|
||||
elseif has('nvim')
|
||||
call add(plugins, ['autozimu/LanguageClient-neovim',
|
||||
@ -82,23 +82,25 @@ endfunction
|
||||
let s:enabled_fts = []
|
||||
|
||||
let s:lsp_servers = {
|
||||
\ 'typescript' : ['typescript-language-server', '--stdio'],
|
||||
\ 'sh' : ['bash-language-server', 'start'],
|
||||
\ 'haskell' : ['hie-wrapper', '--lsp'],
|
||||
\ 'c' : ['clangd'],
|
||||
\ 'cpp' : ['clangd'],
|
||||
\ 'css' : ['css-languageserver', '--stdio'],
|
||||
\ 'dart' : ['dart_language_server'],
|
||||
\ 'dockerfile' : ['docker-langserver', '--stdio'],
|
||||
\ 'go' : ['go-langserver', '-mode', 'stdio'],
|
||||
\ 'haskell' : ['hie-wrapper', '--lsp'],
|
||||
\ 'html' : ['html-languageserver', '--stdio'],
|
||||
\ 'javascript' : ['javascript-typescript-stdio'],
|
||||
\ 'julia' : ['julia', '--startup-file=no', '--history-file=no', '-e', 'using LanguageServer; server = LanguageServer.LanguageServerInstance(STDIN, STDOUT, false); server.runlinter = true; run(server);'],
|
||||
\ 'objc' : ['clangd'],
|
||||
\ 'objcpp' : ['clangd'],
|
||||
\ 'dart' : ['dart_language_server'],
|
||||
\ 'go' : ['go-langserver', '-mode', 'stdio'],
|
||||
\ 'dockerfile' : ['docker-langserver', '--stdio'],
|
||||
\ 'rust' : ['rustup', 'run', 'nightly', 'rls'],
|
||||
\ 'python' : ['pyls'],
|
||||
\ 'html' : ['html-languageserver', '--stdio'],
|
||||
\ 'php' : ['php', g:spacevim_plugin_bundle_dir . 'repos/github.com/felixfbecker/php-language-server/bin/php-language-server.php'],
|
||||
\ 'julia' : ['julia', '--startup-file=no', '--history-file=no', '-e', 'using LanguageServer; server = LanguageServer.LanguageServerInstance(STDIN, STDOUT, false); server.runlinter = true; run(server);'],
|
||||
\ 'javascript' : ['javascript-typescript-stdio'],
|
||||
\ 'purescript' : ['purescript-language-server', '--stdio'],
|
||||
\ 'python' : ['pyls'],
|
||||
\ 'rust' : ['rustup', 'run', 'nightly', 'rls'],
|
||||
\ 'sh' : ['bash-language-server', 'start'],
|
||||
\ 'typescript' : ['typescript-language-server', '--stdio'],
|
||||
\ 'ruby' : ['solargraph.BAT', 'stdio'],
|
||||
\ 'vue' : ['vls']
|
||||
\ }
|
||||
|
||||
|
@ -13,6 +13,6 @@ function! SpaceVim#layers#mail#plugins() abort
|
||||
endfunction
|
||||
|
||||
|
||||
function! SpaceVim#layers#mail#config()
|
||||
function! SpaceVim#layers#mail#config() abort
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['a', 'm'], 'call mail#client#open()', 'Start mail client', 1)
|
||||
endfunction
|
||||
|
@ -37,7 +37,7 @@ let s:file = expand('<sfile>:~')
|
||||
let s:lnum = expand('<slnum>') + 2
|
||||
function! SpaceVim#layers#shell#config() abort
|
||||
call SpaceVim#mapping#space#def('nnoremap', ["'"], 'call call('
|
||||
\ . string(function('s:open_default_shell')) . ', [])',
|
||||
\ . string(function('s:open_default_shell')) . ', [0])',
|
||||
\ ['open shell',
|
||||
\ [
|
||||
\ "[SPC '] is to open or jump to default shell window",
|
||||
@ -45,6 +45,15 @@ function! SpaceVim#layers#shell#config() abort
|
||||
\ 'Definition: ' . s:file . ':' . s:lnum,
|
||||
\ ]
|
||||
\ ], 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ["\""], 'call call('
|
||||
\ . string(function('s:open_default_shell')) . ', [1])',
|
||||
\ ["open shell in current file's path",
|
||||
\ [
|
||||
\ "[SPC \"] is to open or jump to default shell window with the current file's pwd",
|
||||
\ '',
|
||||
\ 'Definition: ' . s:file . ':' . s:lnum,
|
||||
\ ]
|
||||
\ ], 1)
|
||||
|
||||
if has('nvim') || exists(':tnoremap') == 2
|
||||
exe 'tnoremap <silent><C-Right> <C-\><C-n>:<C-u>wincmd l<CR>'
|
||||
@ -115,28 +124,43 @@ function! SpaceVim#layers#shell#get_options() abort
|
||||
|
||||
endfunction
|
||||
|
||||
let s:shell_win_nr = -1
|
||||
let s:term_buf_nr = -1
|
||||
let s:open_terminals_buffers = []
|
||||
" shell windows shoud be toggleable, and can be hide.
|
||||
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'
|
||||
" fuck gvim bug, startinsert do not work in gvim
|
||||
if has('nvim')
|
||||
startinsert
|
||||
function! s:open_default_shell(open_with_file_cwd) abort
|
||||
if a:open_with_file_cwd
|
||||
if getwinvar(winnr(), '&buftype') ==# 'terminal'
|
||||
let path = getbufvar(winbufnr(winnr()), '_spacevim_shell_cwd', SpaceVim#plugins#projectmanager#current_root())
|
||||
else
|
||||
normal! a
|
||||
let path = expand('%:p:h')
|
||||
endif
|
||||
return
|
||||
else
|
||||
let path = SpaceVim#plugins#projectmanager#current_root()
|
||||
endif
|
||||
if &buftype ==# 'terminal'
|
||||
if has('nvim')
|
||||
startinsert
|
||||
else
|
||||
normal! a
|
||||
|
||||
" look for already opened terminal windows
|
||||
let windows = []
|
||||
windo call add(windows, winnr())
|
||||
for window in windows
|
||||
if getwinvar(window, '&buftype') ==# 'terminal'
|
||||
exe window . 'wincmd w'
|
||||
if getbufvar(winbufnr(window), '_spacevim_shell_cwd') ==# l:path
|
||||
" fuck gvim bug, startinsert do not work in gvim
|
||||
if has('nvim')
|
||||
startinsert
|
||||
else
|
||||
normal! a
|
||||
endif
|
||||
return
|
||||
else
|
||||
" the opened terminal window is not the one we want.
|
||||
" close it, we're gonna open a new terminal window with the given l:path
|
||||
exe 'wincmd c'
|
||||
break
|
||||
endif
|
||||
endif
|
||||
return
|
||||
endif
|
||||
endfor
|
||||
|
||||
" no terminal window found. Open a new window
|
||||
let cmd = s:default_position ==# 'top' ?
|
||||
\ 'topleft split' :
|
||||
\ s:default_position ==# 'bottom' ?
|
||||
@ -144,20 +168,30 @@ function! s:open_default_shell() abort
|
||||
\ s:default_position ==# 'right' ?
|
||||
\ 'rightbelow vsplit' : 'leftabove vsplit'
|
||||
exe cmd
|
||||
let w:shell_layer_win = 1
|
||||
let lines = &lines * s:default_height / 100
|
||||
if lines < winheight(0) && (s:default_position ==# 'top' || s:default_position ==# 'bottom')
|
||||
exe 'resize ' . lines
|
||||
endif
|
||||
if bufexists(s:term_buf_nr)
|
||||
exe 'silent b' . s:term_buf_nr
|
||||
" clear the message
|
||||
if has('nvim')
|
||||
startinsert
|
||||
for open_terminal in s:open_terminals_buffers
|
||||
if bufexists(open_terminal)
|
||||
if getbufvar(open_terminal, '_spacevim_shell_cwd') ==# l:path
|
||||
exe 'silent b' . open_terminal
|
||||
" clear the message
|
||||
if has('nvim')
|
||||
startinsert
|
||||
else
|
||||
normal! a
|
||||
endif
|
||||
return
|
||||
endif
|
||||
else
|
||||
normal! a
|
||||
" remove closed buffer from list
|
||||
call remove(s:open_terminals_buffers, 0)
|
||||
endif
|
||||
return
|
||||
endif
|
||||
endfor
|
||||
|
||||
" no terminal window with l:path as cwd has been found, let's open one
|
||||
if s:default_shell ==# 'terminal'
|
||||
if exists(':terminal')
|
||||
if has('nvim')
|
||||
@ -166,7 +200,8 @@ function! s:open_default_shell() abort
|
||||
else
|
||||
let shell = empty($SHELL) ? 'bash' : $SHELL
|
||||
endif
|
||||
terminal
|
||||
enew
|
||||
call termopen(shell, {'cwd': l:path})
|
||||
" @bug cursor is not cleared when open terminal windows.
|
||||
" in neovim-qt when using :terminal to open a shell windows, the orgin
|
||||
" cursor position will be highlighted. switch to normal mode and back
|
||||
@ -180,20 +215,23 @@ function! s:open_default_shell() abort
|
||||
endif
|
||||
let s:term_buf_nr = bufnr('%')
|
||||
call extend(s:shell_cached_br, {getcwd() : s:term_buf_nr})
|
||||
else
|
||||
else
|
||||
" handle vim terminal
|
||||
if s:SYSTEM.isWindows
|
||||
let shell = empty($SHELL) ? 'cmd.exe' : $SHELL
|
||||
else
|
||||
let shell = empty($SHELL) ? 'bash' : $SHELL
|
||||
endif
|
||||
let s:term_buf_nr = term_start(shell, {'curwin' : 1, 'term_finish' : 'close'})
|
||||
let s:term_buf_nr = term_start(shell, {'cwd': l:path, 'curwin' : 1, 'term_finish' : 'close'})
|
||||
endif
|
||||
call add(s:open_terminals_buffers, s:term_buf_nr)
|
||||
let b:_spacevim_shell = shell
|
||||
let b:_spacevim_shell_cwd = l:path
|
||||
|
||||
" use WinEnter autocmd to update statusline
|
||||
doautocmd WinEnter
|
||||
let s:shell_win_nr = winnr()
|
||||
let w:shell_layer_win = 1
|
||||
setlocal nobuflisted nonumber norelativenumber
|
||||
|
||||
" use q to hide terminal buffer in vim, if vimcompatible mode is not
|
||||
" enabled, and smart quit is on.
|
||||
if g:spacevim_windows_smartclose == 0 && !g:spacevim_vimcompatible
|
||||
@ -209,8 +247,10 @@ function! s:open_default_shell() abort
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#shell#close_terminal()
|
||||
if bufexists(s:term_buf_nr)
|
||||
exe 'silent bd!' . s:term_buf_nr
|
||||
endif
|
||||
function! SpaceVim#layers#shell#close_terminal() abort
|
||||
for terminal_bufnr in s:open_terminals_buffers
|
||||
if bufexists(terminal_bufnr)
|
||||
exe 'silent bd!' . terminal_bufnr
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
|
@ -8,9 +8,7 @@
|
||||
|
||||
function! SpaceVim#layers#tags#plugins() abort
|
||||
return [
|
||||
\ ['ludovicchabant/vim-gutentags', {'merged' : 0, 'loadconf' : 1}],
|
||||
\ ['SpaceVim/gtags.vim', {'merged' : 0}],
|
||||
\ ['tsukkee/unite-tag', {'merged' : 0}],
|
||||
\ ]
|
||||
endfunction
|
||||
|
||||
@ -18,19 +16,19 @@ function! SpaceVim#layers#tags#config() abort
|
||||
let g:_spacevim_mappings_space.m.g = {'name' : '+gtags'}
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['m', 'g', 'c'], 'GtagsGenerate!', 'create a gtags database', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['m', 'g', 'u'], 'GtagsGenerate', 'update tag database', 1)
|
||||
if SpaceVim#layers#isLoaded('denite')
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['m', 'g', 'f'], 'Denite gtags_path', 'list all file in GTAGS', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['m', 'g', 'd'], 'DeniteCursorWord gtags_def', 'find definitions', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['m', 'g', 'r'], 'DeniteCursorWord gtags_ref', 'find references', 1)
|
||||
elseif SpaceVim#layers#isLoaded('unite')
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['m', 'g', 'f'], 'Unite gtags/path', 'list all file in GTAGS', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['m', 'g', 'd'], 'Unite gtags/def', 'find definitions', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['m', 'g', 'r'], 'Unite gtags/ref', 'find references', 1)
|
||||
else
|
||||
" if SpaceVim#layers#isLoaded('denite')
|
||||
" call SpaceVim#mapping#space#def('nnoremap', ['m', 'g', 'f'], 'Denite gtags_path', 'list all file in GTAGS', 1)
|
||||
" call SpaceVim#mapping#space#def('nnoremap', ['m', 'g', 'd'], 'DeniteCursorWord gtags_def', 'find definitions', 1)
|
||||
" call SpaceVim#mapping#space#def('nnoremap', ['m', 'g', 'r'], 'DeniteCursorWord gtags_ref', 'find references', 1)
|
||||
" elseif SpaceVim#layers#isLoaded('unite')
|
||||
" call SpaceVim#mapping#space#def('nnoremap', ['m', 'g', 'f'], 'Unite gtags/path', 'list all file in GTAGS', 1)
|
||||
" call SpaceVim#mapping#space#def('nnoremap', ['m', 'g', 'd'], 'Unite gtags/def', 'find definitions', 1)
|
||||
" call SpaceVim#mapping#space#def('nnoremap', ['m', 'g', 'r'], 'Unite gtags/ref', 'find references', 1)
|
||||
" else
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['m', 'g', 'f'], 'Gtags -p', 'list all file in GTAGS', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['m', 'g', 'd'], 'exe "Gtags -d " . expand("<cword>")', 'find definitions', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['m', 'g', 'r'], 'exe "Gtags -r " . expand("<cword>")', 'find references', 1)
|
||||
endif
|
||||
" endif
|
||||
augroup spacevim_layer_tags
|
||||
autocmd!
|
||||
autocmd BufEnter *
|
||||
@ -49,7 +47,7 @@ endfunction
|
||||
|
||||
function! MyTagfuncBack() abort
|
||||
if exists('s:MyTagfunc_flag')&&s:MyTagfunc_flag
|
||||
exe "normal! `H"
|
||||
exe 'normal! `H'
|
||||
let s:MyTagfunc_flag =0
|
||||
endif
|
||||
endfunction
|
||||
|
@ -24,17 +24,18 @@
|
||||
|
||||
function! SpaceVim#layers#test#plugins() abort
|
||||
return [
|
||||
\ ['janko-m/vim-test'],
|
||||
\ ['janko/vim-test'],
|
||||
\ ]
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#test#config() abort
|
||||
let g:_spacevim_mappings_space.k = get(g:_spacevim_mappings_space, 'k', {'name' : '+Test'})
|
||||
|
||||
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['k', 'n'], 'TestNearest', 'nearest', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['k', 'f'], 'TestFile', 'file', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['k', 's'], 'TestSuite', 'suite', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['k', 'l'], 'TestLast', 'last', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['k', 'v'], 'TestVisit', 'visit', 1)
|
||||
let g:test#custom_strategies = {'spacevim': function('SpaceVim#plugins#runner#open')}
|
||||
let g:test#strategy = 'spacevim'
|
||||
endfunction
|
||||
|
||||
|
@ -20,7 +20,15 @@ function! SpaceVim#layers#tools#plugins() abort
|
||||
call add(plugins, ['itchyny/calendar.vim', { 'on_cmd' : 'Calendar'}])
|
||||
call add(plugins, ['junegunn/limelight.vim', { 'on_cmd' : 'Limelight'}])
|
||||
call add(plugins, ['junegunn/goyo.vim', { 'on_cmd' : 'Goyo', 'loadconf' : 1}])
|
||||
call add(plugins, ['MattesGroeger/vim-bookmarks', { 'on_map' : '<Plug>Bookmark', 'on_cmd' : 'BookmarkShowAll', 'loadconf_before' : 1}])
|
||||
call add(plugins, ['MattesGroeger/vim-bookmarks', { 'on_cmd' :
|
||||
\ [
|
||||
\ 'BookmarkShowAll',
|
||||
\ 'BookmarkToggle',
|
||||
\ 'BookmarkAnnotate',
|
||||
\ 'BookmarkNext',
|
||||
\ 'BookmarkPrev',
|
||||
\ ],
|
||||
\ 'loadconf_before' : 1}])
|
||||
let s:CMP = SpaceVim#api#import('vim#compatible')
|
||||
if s:CMP.has('python')
|
||||
call add(plugins, ['gregsexton/VimCalc', {'on_cmd' : 'Calc'}])
|
||||
@ -41,11 +49,13 @@ function! SpaceVim#layers#tools#config() abort
|
||||
\ 'Goyo', 'centered-buffer-mode', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', 'C'],
|
||||
\ 'ChooseWin | Goyo', 'centered-buffer-mode(other windows)', 1)
|
||||
nmap mm <Plug>BookmarkToggle
|
||||
nmap mi <Plug>BookmarkAnnotate
|
||||
nmap ma <Plug>BookmarkShowAll
|
||||
nmap mn <Plug>BookmarkNext
|
||||
nmap mp <Plug>BookmarkPrev
|
||||
|
||||
" bootmark key binding
|
||||
nnoremap <silent> mm :<C-u>BookmarkToggle<Cr>
|
||||
nnoremap <silent> mi :<C-u>BookmarkAnnotate<Cr>
|
||||
nnoremap <silent> ma :<C-u>BookmarkShowAll<Cr>
|
||||
nnoremap <silent> mn :<C-u>BookmarkNext<Cr>
|
||||
nnoremap <silent> mp :<C-u>BookmarkPrev<Cr>
|
||||
nnoremap <silent> <F7> :MundoToggle<CR>
|
||||
augroup rainbow_lisp
|
||||
autocmd!
|
||||
@ -63,7 +73,6 @@ function! SpaceVim#layers#tools#config() abort
|
||||
if maparg('<C-_>', 'n') ==# ''
|
||||
nnoremap <silent> <C-_> <Esc>:Ydc<CR>
|
||||
endif
|
||||
noremap <silent> <F8> :TlistToggle<CR>
|
||||
endfunction
|
||||
|
||||
" vim:set et sw=2 cc=80:
|
||||
|
33
autoload/SpaceVim/layers/tools/zeal.vim
Normal file
33
autoload/SpaceVim/layers/tools/zeal.vim
Normal file
@ -0,0 +1,33 @@
|
||||
"=============================================================================
|
||||
" zeal.vim --- tools#zeal layer file for SpaceVim
|
||||
" Copyright (c) 2018 Shidong Wang & Contributors
|
||||
" Author: Chen Lijun < chenlijun1999 at gmail.com >
|
||||
" URL: https://spacevim.org
|
||||
" License: GPLv3
|
||||
"=============================================================================
|
||||
|
||||
""
|
||||
" @section tools#zeal, layer-tools-zeal
|
||||
" @parentsection layers
|
||||
" This layer provides Zeal integration for SpaceVim
|
||||
|
||||
function! SpaceVim#layers#tools#zeal#plugins() abort
|
||||
return [
|
||||
\ ['KabbAmine/zeavim.vim', {
|
||||
\ 'on_map': { 'nv': ['<Plug>Zeavim', '<Plug>ZVVisSelection', '<Plug>ZVKeyDocset'] }
|
||||
\ }],
|
||||
\ ]
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#tools#zeal#config() abort
|
||||
" Disable default mapping
|
||||
let g:zv_disable_mapping = 1
|
||||
|
||||
let g:_spacevim_mappings_space.D = { 'name' : '+Zeal' }
|
||||
call SpaceVim#mapping#space#def('nmap', ['D', 'd'],
|
||||
\ '<Plug>Zeavim', 'search word under cursor', 0)
|
||||
call SpaceVim#mapping#space#def('vmap', ['D', 'D'],
|
||||
\ '<Plug>ZVVisSelection', 'search selected text', 0)
|
||||
call SpaceVim#mapping#space#def('nmap', ['D', 's'],
|
||||
\ '<Plug>ZVKeyDocset', 'specify docset and query', 0)
|
||||
endfunction
|
@ -55,7 +55,8 @@ function! SpaceVim#layers#ui#config() abort
|
||||
\ 'highlight-long-lines', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['t', 'b'], 'call ToggleBG()',
|
||||
\ 'toggle background', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['t', 'c'], 'call ToggleConceal()',
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['t', 'c'], 'call call('
|
||||
\ . string(s:_function('s:toggle_conceal')) . ', [])',
|
||||
\ 'toggle conceal', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['t', 't'], 'call SpaceVim#plugins#tabmanager#open()',
|
||||
\ 'Open tabs manager', 1)
|
||||
@ -272,3 +273,11 @@ function! s:toggle_whitespace() abort
|
||||
call SpaceVim#layers#core#statusline#toggle_section('whitespace')
|
||||
call SpaceVim#layers#core#statusline#toggle_mode('whitespace')
|
||||
endfunction
|
||||
|
||||
func! s:toggle_conceal()
|
||||
if &conceallevel == 0
|
||||
setlocal conceallevel=2
|
||||
else
|
||||
setlocal conceallevel=0
|
||||
endif
|
||||
endf
|
||||
|
@ -198,6 +198,16 @@ function! s:defind_fuzzy_finder() abort
|
||||
\ 'Definition: ' . s:file . ':' . lnum,
|
||||
\ ]
|
||||
\ ]
|
||||
nnoremap <silent> <Leader>fp :<C-u>Unite menu:AddedPlugins<CR>
|
||||
let lnum = expand('<slnum>') + s:unite_lnum - 4
|
||||
let g:_spacevim_mappings.f.p = ['Unite menu:AddedPlugins',
|
||||
\ 'fuzzy find vim packages',
|
||||
\ [
|
||||
\ '[Leader f p] is to fuzzy find vim packages installed in SpaceVim',
|
||||
\ '',
|
||||
\ 'Definition: ' . s:file . ':' . lnum,
|
||||
\ ]
|
||||
\ ]
|
||||
endfunction
|
||||
|
||||
function! s:run_shell_cmd() abort
|
||||
|
@ -9,7 +9,7 @@
|
||||
scriptencoding utf-8
|
||||
|
||||
|
||||
if SpaceVim#layers#isLoaded("autocomplete") && get(g:, "spacevim_autocomplete_method") ==# 'coc'
|
||||
if SpaceVim#layers#isLoaded('autocomplete') && get(g:, 'spacevim_autocomplete_method') ==# 'coc'
|
||||
" use coc.nvim
|
||||
let s:coc_language_servers = {}
|
||||
let s:coc_language_servers_key_id_map = {}
|
||||
@ -30,7 +30,7 @@ if SpaceVim#layers#isLoaded("autocomplete") && get(g:, "spacevim_autocomplete_me
|
||||
" actually the same.
|
||||
" We need to keep an id to distinguish among conflicting keys.
|
||||
|
||||
if stridx(a:cmds[0], ".") >= 0
|
||||
if stridx(a:cmds[0], '.') >= 0
|
||||
let l:key = split(a:cmds[0], "\\.")[-1]
|
||||
else
|
||||
let l:key = a:cmds[0]
|
||||
@ -52,23 +52,26 @@ if SpaceVim#layers#isLoaded("autocomplete") && get(g:, "spacevim_autocomplete_me
|
||||
|
||||
let s:coc_language_servers_key_id_map[l:key] = s:coc_language_servers_key_id_map[l:key] + 1
|
||||
|
||||
autocmd! User CocNvimInit :call coc#config("languageserver", s:coc_language_servers)
|
||||
augroup spacevim_lsp_layer
|
||||
autocmd!
|
||||
autocmd! User CocNvimInit :call coc#config("languageserver", s:coc_language_servers)
|
||||
augroup END
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#lsp#show_doc() abort
|
||||
call CocActionAsync("doHover")
|
||||
call CocActionAsync('doHover')
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#lsp#go_to_def() abort
|
||||
call CocActionAsync("jumpDefinition")
|
||||
call CocActionAsync('jumpDefinition')
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#lsp#rename() abort
|
||||
call CocActionAsync("rename")
|
||||
call CocActionAsync('rename')
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#lsp#references() abort
|
||||
call CocActionAsync("jumpReferences")
|
||||
call CocActionAsync('jumpReferences')
|
||||
endfunction
|
||||
elseif has('nvim')
|
||||
" use LanguageClient-neovim
|
||||
@ -94,11 +97,11 @@ elseif has('nvim')
|
||||
else
|
||||
" use vim-lsp
|
||||
function! SpaceVim#lsp#reg_server(ft, cmds) abort
|
||||
exe "au User lsp_setup call lsp#register_server({"
|
||||
exe 'au User lsp_setup call lsp#register_server({'
|
||||
\ . "'name': 'LSP',"
|
||||
\ . "'cmd': {server_info -> " . string(a:cmds) . "},"
|
||||
\ . "'cmd': {server_info -> " . string(a:cmds) . '},'
|
||||
\ . "'whitelist': ['" . a:ft . "' ],"
|
||||
\ . "})"
|
||||
\ . '})'
|
||||
exe 'autocmd FileType ' . a:ft . ' setlocal omnifunc=lsp#complete'
|
||||
endfunction
|
||||
|
||||
|
@ -135,10 +135,9 @@ function! SpaceVim#mapping#split_previous_buffer() abort
|
||||
wincmd w
|
||||
e#
|
||||
endif
|
||||
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#mapping#vertical_split_previous_buffer() abort
|
||||
function! SpaceVim#mapping#vertical_split_previous_buffer(...) abort
|
||||
if bufnr('#') == -1
|
||||
call SpaceVim#util#echoWarn('There is no previous buffer')
|
||||
else
|
||||
@ -148,16 +147,20 @@ function! SpaceVim#mapping#vertical_split_previous_buffer() abort
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#mapping#close_current_buffer() abort
|
||||
function! SpaceVim#mapping#close_current_buffer(...) abort
|
||||
let buffers = get(g:, '_spacevim_list_buffers', [])
|
||||
let bn = bufnr('%')
|
||||
let f = ''
|
||||
if getbufvar(bn, '&modified', 0)
|
||||
redraw
|
||||
echohl WarningMsg
|
||||
echon 'save changes to "' . bufname(bn) . '"? Yes/No/Cancel'
|
||||
if len(a:000) > 0
|
||||
let rs = get(a:000, 0)
|
||||
else
|
||||
echon 'save changes to "' . bufname(bn) . '"? Yes/No/Cancel'
|
||||
let rs = nr2char(getchar())
|
||||
endif
|
||||
echohl None
|
||||
let rs = nr2char(getchar())
|
||||
if rs ==? 'y'
|
||||
write
|
||||
elseif rs ==? 'n'
|
||||
@ -175,7 +178,7 @@ function! SpaceVim#mapping#close_current_buffer() abort
|
||||
endif
|
||||
endif
|
||||
|
||||
if &buftype == 'terminal'
|
||||
if &buftype ==# 'terminal'
|
||||
exe 'bd!'
|
||||
return
|
||||
endif
|
||||
@ -208,6 +211,10 @@ function! SpaceVim#mapping#close_term_buffer(...) abort
|
||||
let index = index(buffers, abuf)
|
||||
if get(w:, 'shell_layer_win', 0) == 1
|
||||
exe 'bd!' . abuf
|
||||
" fuck the terminal windows
|
||||
if get(w:, 'shell_layer_win', 0) == 1
|
||||
close
|
||||
endif
|
||||
return
|
||||
endif
|
||||
if index != -1
|
||||
@ -252,7 +259,7 @@ function! SpaceVim#mapping#menu(desc, key, cmd) abort
|
||||
\ a:cmd])
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#mapping#clear_saved_buffers()
|
||||
function! SpaceVim#mapping#clear_saved_buffers() abort
|
||||
call s:BUFFER.filter_do(
|
||||
\ {
|
||||
\ 'expr' : [
|
||||
|
@ -17,7 +17,7 @@ function! SpaceVim#mapping#g#init() abort
|
||||
|
||||
let g:_spacevim_mappings_g["'"] = ['call feedkeys("g' . "'" . '", "n")', 'jump to mark']
|
||||
nnoremap g' g'
|
||||
let g:_spacevim_mappings_g["`"] = ['call feedkeys("g' . "`" . '", "n")', 'jump to mark']
|
||||
let g:_spacevim_mappings_g['`'] = ['call feedkeys("g' . '`' . '", "n")', 'jump to mark']
|
||||
nnoremap g` g`
|
||||
|
||||
let g:_spacevim_mappings_g['+'] = ['call feedkeys("g+", "n")', 'newer text state']
|
||||
|
@ -13,12 +13,13 @@ scriptencoding utf-8
|
||||
" Load SpaceVim API
|
||||
|
||||
let s:CMP = SpaceVim#api#import('vim#compatible')
|
||||
let s:STR = SpaceVim#api#import('data#string')
|
||||
|
||||
function! SpaceVim#mapping#guide#has_configuration() "{{{
|
||||
function! SpaceVim#mapping#guide#has_configuration() abort "{{{
|
||||
return exists('s:desc_lookup')
|
||||
endfunction "}}}
|
||||
|
||||
function! SpaceVim#mapping#guide#register_prefix_descriptions(key, dictname) " {{{
|
||||
function! SpaceVim#mapping#guide#register_prefix_descriptions(key, dictname) abort " {{{
|
||||
let key = a:key ==? '<Space>' ? ' ' : a:key
|
||||
if !exists('s:desc_lookup')
|
||||
call s:create_cache()
|
||||
@ -31,11 +32,11 @@ function! SpaceVim#mapping#guide#register_prefix_descriptions(key, dictname) " {
|
||||
let s:desc_lookup[key] = a:dictname
|
||||
endif
|
||||
endfunction "}}}
|
||||
function! s:create_cache() " {{{
|
||||
function! s:create_cache() abort " {{{
|
||||
let s:desc_lookup = {}
|
||||
let s:cached_dicts = {}
|
||||
endfunction " }}}
|
||||
function! s:create_target_dict(key) " {{{
|
||||
function! s:create_target_dict(key) abort " {{{
|
||||
if has_key(s:desc_lookup, 'top')
|
||||
let toplevel = deepcopy({s:desc_lookup['top']})
|
||||
let tardict = s:toplevel ? toplevel : get(toplevel, a:key, {})
|
||||
@ -50,7 +51,7 @@ function! s:create_target_dict(key) " {{{
|
||||
endif
|
||||
return tardict
|
||||
endfunction " }}}
|
||||
function! s:merge(dict_t, dict_o) " {{{
|
||||
function! s:merge(dict_t, dict_o) abort " {{{
|
||||
let target = a:dict_t
|
||||
let other = a:dict_o
|
||||
for k in keys(target)
|
||||
@ -65,50 +66,49 @@ function! s:merge(dict_t, dict_o) " {{{
|
||||
let target[k.'m'] = target[k]
|
||||
endif
|
||||
let target[k] = other[k]
|
||||
if has_key(other, k."m") && type(other[k."m"]) == type({})
|
||||
call s:merge(target[k."m"], other[k."m"])
|
||||
if has_key(other, k.'m') && type(other[k.'m']) == type({})
|
||||
call s:merge(target[k.'m'], other[k.'m'])
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
call extend(target, other, "keep")
|
||||
call extend(target, other, 'keep')
|
||||
endfunction " }}}
|
||||
|
||||
" @vimlint(EVL103, 1, a:dictname)
|
||||
function! SpaceVim#mapping#guide#populate_dictionary(key, dictname) " {{{
|
||||
function! SpaceVim#mapping#guide#populate_dictionary(key, dictname) abort " {{{
|
||||
call s:start_parser(a:key, s:cached_dicts[a:key])
|
||||
endfunction " }}}
|
||||
" @vimlint(EVL103, 0, a:dictname)
|
||||
|
||||
function! SpaceVim#mapping#guide#parse_mappings() " {{{
|
||||
function! SpaceVim#mapping#guide#parse_mappings() abort " {{{
|
||||
for [k, v] in items(s:cached_dicts)
|
||||
call s:start_parser(k, v)
|
||||
endfor
|
||||
endfunction " }}}
|
||||
|
||||
|
||||
function! s:start_parser(key, dict) " {{{
|
||||
function! s:start_parser(key, dict) abort " {{{
|
||||
if a:key ==# '[KEYs]'
|
||||
return
|
||||
endif
|
||||
let key = a:key ==? ' ' ? "<Space>" : a:key
|
||||
let key = a:key ==? ' ' ? '<Space>' : a:key
|
||||
|
||||
0verbose let readmap = s:CMP.execute('map ' . key, 'silent')
|
||||
|
||||
let lines = split(readmap, "\n")
|
||||
let visual = s:vis == "gv" ? 1 : 0
|
||||
let visual = s:vis ==# 'gv' ? 1 : 0
|
||||
|
||||
for line in lines
|
||||
let mapd = maparg(split(line[3:])[0], line[0], 0, 1)
|
||||
if mapd.lhs == '\\'
|
||||
echom string(mapd)
|
||||
let mapd.feedkeyargs = ""
|
||||
if mapd.lhs ==# '\\'
|
||||
let mapd.feedkeyargs = ''
|
||||
elseif mapd.noremap == 1
|
||||
let mapd.feedkeyargs = "nt"
|
||||
let mapd.feedkeyargs = 'nt'
|
||||
else
|
||||
let mapd.feedkeyargs = "mt"
|
||||
let mapd.feedkeyargs = 'mt'
|
||||
endif
|
||||
if mapd.lhs =~ '<Plug>.*' || mapd.lhs =~ '<SNR>.*'
|
||||
if mapd.lhs =~# '<Plug>.*' || mapd.lhs =~# '<SNR>.*'
|
||||
continue
|
||||
endif
|
||||
let mapd.display = s:format_displaystring(mapd.rhs)
|
||||
@ -116,17 +116,17 @@ function! s:start_parser(key, dict) " {{{
|
||||
let mapd.lhs = substitute(mapd.lhs, '<Space>', ' ', 'g')
|
||||
let mapd.lhs = substitute(mapd.lhs, '<Tab>', '<C-I>', 'g')
|
||||
let mapd.rhs = substitute(mapd.rhs, '<SID>', '<SNR>'.mapd['sid'].'_', 'g')
|
||||
if mapd.lhs != '' && mapd.display !~# 'LeaderGuide.*'
|
||||
if mapd.lhs !=# '' && mapd.display !~# 'LeaderGuide.*'
|
||||
let mapd.lhs = s:string_to_keys(mapd.lhs)
|
||||
if (visual && match(mapd.mode, "[vx ]") >= 0) ||
|
||||
\ (!visual && match(mapd.mode, "[vx]") == -1)
|
||||
if (visual && match(mapd.mode, '[vx ]') >= 0) ||
|
||||
\ (!visual && match(mapd.mode, '[vx]') == -1)
|
||||
call s:add_map_to_dict(mapd, 0, a:dict)
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
endfunction " }}}
|
||||
|
||||
function! s:add_map_to_dict(map, level, dict) " {{{
|
||||
function! s:add_map_to_dict(map, level, dict) abort " {{{
|
||||
if len(a:map.lhs) > a:level+1
|
||||
let curkey = a:map.lhs[a:level]
|
||||
let nlevel = a:level+1
|
||||
@ -142,7 +142,7 @@ function! s:add_map_to_dict(map, level, dict) " {{{
|
||||
endif
|
||||
elseif type(a:dict[curkey]) == type([]) && g:leaderGuide_flatten == 0
|
||||
let cmd = s:escape_mappings(a:map)
|
||||
let curkey = curkey."m"
|
||||
let curkey = curkey.'m'
|
||||
if !has_key(a:dict, curkey)
|
||||
let a:dict[curkey] = { 'name' : g:leaderGuide_default_group_name }
|
||||
endif
|
||||
@ -166,7 +166,7 @@ function! s:add_map_to_dict(map, level, dict) " {{{
|
||||
endif
|
||||
endfunction " }}}
|
||||
" @vimlint(EVL111, 1, Fun)
|
||||
function! s:format_displaystring(map) " {{{
|
||||
function! s:format_displaystring(map) abort " {{{
|
||||
let g:leaderGuide#displayname = a:map
|
||||
for Fun in g:leaderGuide_displayfunc
|
||||
call Fun()
|
||||
@ -176,7 +176,7 @@ function! s:format_displaystring(map) " {{{
|
||||
return display
|
||||
endfunction " }}}
|
||||
" @vimlint(EVL111, 0, Fun)
|
||||
function! s:flattenmap(dict, str) " {{{
|
||||
function! s:flattenmap(dict, str) abort " {{{
|
||||
let ret = {}
|
||||
for kv in keys(a:dict)
|
||||
if type(a:dict[kv]) == type([])
|
||||
@ -191,14 +191,14 @@ function! s:flattenmap(dict, str) " {{{
|
||||
endfunction " }}}
|
||||
|
||||
|
||||
function! s:escape_mappings(mapping) " {{{
|
||||
function! s:escape_mappings(mapping) abort " {{{
|
||||
let rstring = substitute(a:mapping.rhs, '\', '\\\\', 'g')
|
||||
let rstring = substitute(rstring, '<\([^<>]*\)>', '\\<\1>', 'g')
|
||||
let rstring = substitute(rstring, '"', '\\"', 'g')
|
||||
let rstring = 'call feedkeys("'.rstring.'", "'.a:mapping.feedkeyargs.'")'
|
||||
return rstring
|
||||
endfunction " }}}
|
||||
function! s:string_to_keys(input) " {{{
|
||||
function! s:string_to_keys(input) abort " {{{
|
||||
" Avoid special case: <>
|
||||
let retlist = []
|
||||
if match(a:input, '<.\+>') != -1
|
||||
@ -232,13 +232,13 @@ function! s:string_to_keys(input) " {{{
|
||||
endif
|
||||
return retlist
|
||||
endfunction " }}}
|
||||
function! s:escape_keys(inp) " {{{
|
||||
let ret = substitute(a:inp, "<", "<lt>", "")
|
||||
return substitute(ret, "|", "<Bar>", "")
|
||||
function! s:escape_keys(inp) abort " {{{
|
||||
let ret = substitute(a:inp, '<', '<lt>', '')
|
||||
return substitute(ret, '|', '<Bar>', '')
|
||||
endfunction " }}}
|
||||
|
||||
|
||||
function! s:calc_layout() " {{{
|
||||
function! s:calc_layout() abort " {{{
|
||||
let ret = {}
|
||||
let smap = filter(copy(s:lmap), 'v:key !=# "name"')
|
||||
let ret.n_items = len(smap)
|
||||
@ -252,15 +252,36 @@ function! s:calc_layout() " {{{
|
||||
let ret.col_width = maxlength
|
||||
let ret.win_dim = ret.n_cols * ret.col_width
|
||||
else
|
||||
let ret.n_cols = winwidth(0) / maxlength
|
||||
let ret.n_cols = winwidth(0) >= maxlength ? winwidth(0) / maxlength : 1
|
||||
let ret.col_width = winwidth(0) / ret.n_cols
|
||||
let ret.n_rows = ret.n_items / ret.n_cols + (fmod(ret.n_items,ret.n_cols) > 0 ? 1 : 0)
|
||||
let ret.win_dim = ret.n_rows
|
||||
"echom string(ret)
|
||||
endif
|
||||
return ret
|
||||
endfunction " }}}
|
||||
function! s:create_string(layout) " {{{
|
||||
|
||||
" icon -> number -> A-Za-z
|
||||
" 65-90 97-122
|
||||
function! s:compare_key(i1, i2) abort
|
||||
let a = char2nr(a:i1 ==# '[SPC]' ? ' ' : a:i1 ==? '<Tab>' ? "\t" : a:i1)
|
||||
let b = char2nr(a:i2 ==# '[SPC]' ? ' ' : a:i2 ==? '<Tab>' ? "\t" : a:i2)
|
||||
if a - b == 32 && a >= 97 && a <= 122
|
||||
return -1
|
||||
elseif b - a == 32 && b >= 97 && b <= 122
|
||||
return 1
|
||||
elseif a >= 97 && a <= 122 && b >= 97 && b <= 122
|
||||
return a == b ? 0 : a > b ? 1 : -1
|
||||
elseif a >= 65 && a <= 90 && b >= 65 && b <= 90
|
||||
return a == b ? 0 : a > b ? 1 : -1
|
||||
elseif a >= 97 && a <= 122 && b >= 65 && b <= 90
|
||||
return s:compare_key(nr2char(a), nr2char(b + 32))
|
||||
elseif a >= 65 && a <= 90 && b >= 97 && b <= 122
|
||||
return s:compare_key(nr2char(a), nr2char(b - 32))
|
||||
endif
|
||||
return a == b ? 0 : a > b ? 1 : -1
|
||||
endfunction
|
||||
|
||||
function! s:create_string(layout) abort " {{{
|
||||
let l = a:layout
|
||||
let l.capacity = l.n_rows * l.n_cols
|
||||
let overcap = l.capacity - l.n_items
|
||||
@ -270,10 +291,10 @@ function! s:create_string(layout) " {{{
|
||||
let rows = []
|
||||
let row = 0
|
||||
let col = 0
|
||||
let smap = sort(filter(keys(s:lmap), 'v:val !=# "name"'),'1')
|
||||
let smap = sort(filter(keys(s:lmap), 'v:val !=# "name"'), function('s:compare_key'))
|
||||
for k in smap
|
||||
let desc = type(s:lmap[k]) == type({}) ? s:lmap[k].name : s:lmap[k][1]
|
||||
let displaystring = "[". k ."] ".desc
|
||||
let displaystring = '['. k .'] '.desc
|
||||
let crow = get(rows, row, [])
|
||||
if empty(crow)
|
||||
call add(rows, crow)
|
||||
@ -301,7 +322,6 @@ function! s:create_string(layout) " {{{
|
||||
let col += 1
|
||||
endif
|
||||
endif
|
||||
silent execute "cnoremap <nowait> <buffer> ".substitute(k, "|", "<Bar>", ""). " " . s:escape_keys(k) ."<CR>"
|
||||
endfor
|
||||
let r = []
|
||||
let mlen = 0
|
||||
@ -330,7 +350,7 @@ function! s:highlight_cursor() abort
|
||||
\ }
|
||||
hi! def link SpaceVimGuideCursor Cursor
|
||||
call s:VIMH.hi(info)
|
||||
if s:vis == 'gv'
|
||||
if s:vis ==# 'gv'
|
||||
" [bufnum, lnum, col, off]
|
||||
let begin = getpos("'<")
|
||||
let end = getpos("'>")
|
||||
@ -358,7 +378,7 @@ function! s:remove_cursor_highlight() abort
|
||||
endfunction
|
||||
|
||||
" @vimlint(EVL102, 1, l:string)
|
||||
function! s:start_buffer() " {{{
|
||||
function! s:start_buffer() abort " {{{
|
||||
let s:winv = winsaveview()
|
||||
let s:winnr = winnr()
|
||||
let s:winres = winrestcmd()
|
||||
@ -371,22 +391,36 @@ function! s:start_buffer() " {{{
|
||||
endif
|
||||
|
||||
setlocal modifiable
|
||||
if g:leaderGuide_vertical
|
||||
noautocmd execute 'vert res '.layout.win_dim
|
||||
if exists('*nvim_open_win')
|
||||
call nvim_win_config(win_getid(s:gwin), &columns, layout.win_dim + 2,
|
||||
\ {
|
||||
\ 'relative': 'editor',
|
||||
\ 'row': &lines - layout.win_dim - 4,
|
||||
\ 'col': 0
|
||||
\ })
|
||||
|
||||
else
|
||||
noautocmd execute 'res '.layout.win_dim
|
||||
if g:leaderGuide_vertical
|
||||
noautocmd execute 'vert res '.layout.win_dim
|
||||
else
|
||||
noautocmd execute 'res '.layout.win_dim
|
||||
endif
|
||||
endif
|
||||
silent 1put!=string
|
||||
normal! gg"_dd
|
||||
setlocal nomodifiable
|
||||
if empty(maparg("<c-c>", "c", 0, 1))
|
||||
execute 'cnoremap <nowait> <silent> <buffer> <c-c> <esc>'
|
||||
if exists('*nvim_open_win')
|
||||
" when using floating windows, and the flaating windows do not support
|
||||
" statusline, add extra black line at top and button of the content.
|
||||
call setline(1, [''] + split(string, "\n") + [''])
|
||||
else
|
||||
call setline(1, split(string, "\n"))
|
||||
endif
|
||||
setlocal nomodifiable
|
||||
redraw!
|
||||
call s:wait_for_input()
|
||||
endfunction " }}}
|
||||
" @vimlint(EVL102, 0, l:string)
|
||||
|
||||
function! s:handle_input(input) " {{{
|
||||
function! s:handle_input(input) abort " {{{
|
||||
call s:winclose()
|
||||
if type(a:input) ==? type({})
|
||||
let s:lmap = a:input
|
||||
@ -403,20 +437,34 @@ function! s:handle_input(input) " {{{
|
||||
endtry
|
||||
endif
|
||||
endfunction " }}}
|
||||
function! s:wait_for_input() " {{{
|
||||
|
||||
function! s:getchar(...) abort
|
||||
let ret = call('getchar', a:000)
|
||||
return (type(ret) == type(0) ? nr2char(ret) : ret)
|
||||
endfunction
|
||||
|
||||
|
||||
" wait for in input sub function should be not block vim
|
||||
function! s:wait_for_input() abort " {{{
|
||||
redraw!
|
||||
let inp = input("")
|
||||
if inp ==? ''
|
||||
let inp = s:getchar()
|
||||
if inp ==# "\<Esc>"
|
||||
let s:prefix_key_inp = ''
|
||||
let s:guide_help_mode = 0
|
||||
call s:winclose()
|
||||
doautocmd WinEnter
|
||||
elseif match(inp, "^<LGCMD>paging_help") == 0
|
||||
elseif s:guide_help_mode ==# 1
|
||||
call s:submode_mappings(inp)
|
||||
let s:guide_help_mode = 0
|
||||
call s:updateStatusline()
|
||||
redraw!
|
||||
elseif inp ==# "\<C-h>"
|
||||
let s:guide_help_mode = 1
|
||||
call s:updateStatusline()
|
||||
redraw!
|
||||
call s:submode_mappings()
|
||||
call s:wait_for_input()
|
||||
else
|
||||
if inp == ' '
|
||||
if inp ==# ' '
|
||||
let inp = '[SPC]'
|
||||
endif
|
||||
let fsel = get(s:lmap, inp)
|
||||
@ -424,40 +472,76 @@ function! s:wait_for_input() " {{{
|
||||
let s:prefix_key_inp = inp
|
||||
call s:handle_input(fsel)
|
||||
else
|
||||
let s:prefix_key_inp = ''
|
||||
call s:winclose()
|
||||
doautocmd WinEnter
|
||||
let keys = get(s:, 'prefix_key_inp', '')
|
||||
let name = SpaceVim#mapping#leader#getName(s:prefix_key)
|
||||
call s:build_mpt(['key bidings is not defined: ', name . '-' . join(s:STR.string2chars(keys), '-') . '-' . inp])
|
||||
let s:prefix_key_inp = ''
|
||||
let s:guide_help_mode = 0
|
||||
endif
|
||||
endif
|
||||
endfunction " }}}
|
||||
function! s:winopen() " {{{
|
||||
|
||||
function! s:build_mpt(mpt) abort
|
||||
normal! :
|
||||
echohl Comment
|
||||
if type(a:mpt) == 1
|
||||
echon a:mpt
|
||||
elseif type(a:mpt) == 3
|
||||
echon join(a:mpt)
|
||||
endif
|
||||
echohl NONE
|
||||
endfunction
|
||||
|
||||
function! s:winopen() abort " {{{
|
||||
if !exists('s:bufnr')
|
||||
let s:bufnr = -1
|
||||
endif
|
||||
call s:highlight_cursor()
|
||||
let pos = g:leaderGuide_position ==? 'topleft' ? 'topleft' : 'botright'
|
||||
if bufexists(s:bufnr)
|
||||
let qfbuf = &buftype ==# 'quickfix'
|
||||
let splitcmd = g:leaderGuide_vertical ? ' 1vs' : ' 1sp'
|
||||
noautocmd execute pos . splitcmd
|
||||
let bnum = bufnr('%')
|
||||
noautocmd execute 'buffer '.s:bufnr
|
||||
cmapclear <buffer>
|
||||
if qfbuf
|
||||
noautocmd execute bnum.'bwipeout!'
|
||||
if exists('*nvim_open_win')
|
||||
if !bufexists(s:bufnr)
|
||||
let s:bufnr = nvim_create_buf(v:false,v:false)
|
||||
endif
|
||||
call nvim_open_win(s:bufnr, v:true, &columns, 12,
|
||||
\ {
|
||||
\ 'relative': 'editor',
|
||||
\ 'row': &lines - 14,
|
||||
\ 'col': 0
|
||||
\ })
|
||||
else
|
||||
let splitcmd = g:leaderGuide_vertical ? ' 1vnew' : ' 1new'
|
||||
noautocmd execute pos.splitcmd
|
||||
let s:bufnr = bufnr('%')
|
||||
autocmd WinLeave <buffer> call s:winclose()
|
||||
if bufexists(s:bufnr)
|
||||
let qfbuf = &buftype ==# 'quickfix'
|
||||
let splitcmd = g:leaderGuide_vertical ? ' 1vs' : ' 1sp'
|
||||
noautocmd execute pos . splitcmd
|
||||
let bnum = bufnr('%')
|
||||
noautocmd execute 'buffer '.s:bufnr
|
||||
cmapclear <buffer>
|
||||
if qfbuf
|
||||
noautocmd execute bnum.'bwipeout!'
|
||||
endif
|
||||
else
|
||||
let splitcmd = g:leaderGuide_vertical ? ' 1vnew' : ' 1new'
|
||||
noautocmd execute pos.splitcmd
|
||||
let s:bufnr = bufnr('%')
|
||||
augroup guide_autocmd
|
||||
autocmd!
|
||||
autocmd WinLeave <buffer> call s:winclose()
|
||||
augroup END
|
||||
endif
|
||||
endif
|
||||
let s:gwin = winnr()
|
||||
let s:guide_help_mode = 0
|
||||
setlocal filetype=leaderGuide
|
||||
if exists('&winhighlight')
|
||||
set winhighlight=Normal:Pmenu
|
||||
endif
|
||||
setlocal nonumber norelativenumber nolist nomodeline nowrap
|
||||
setlocal nobuflisted buftype=nofile bufhidden=unload noswapfile
|
||||
setlocal nocursorline nocursorcolumn colorcolumn=
|
||||
setlocal winfixwidth winfixheight
|
||||
setlocal listchars=
|
||||
call s:updateStatusline()
|
||||
call s:toggle_hide_cursor()
|
||||
endfunction " }}}
|
||||
@ -497,7 +581,7 @@ function! s:toggle_hide_cursor() abort
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:winclose() " {{{
|
||||
function! s:winclose() abort " {{{
|
||||
call s:toggle_hide_cursor()
|
||||
noautocmd execute s:gwin.'wincmd w'
|
||||
if s:gwin == winnr()
|
||||
@ -510,59 +594,43 @@ function! s:winclose() " {{{
|
||||
endif
|
||||
call s:remove_cursor_highlight()
|
||||
endfunction " }}}
|
||||
function! s:page_down() " {{{
|
||||
call feedkeys("\<c-c>", "n")
|
||||
call feedkeys("\<c-f>", "x")
|
||||
function! s:page_down() abort " {{{
|
||||
call feedkeys("\<c-c>", 'n')
|
||||
call feedkeys("\<c-f>", 'x')
|
||||
redraw!
|
||||
call s:wait_for_input()
|
||||
endfunction " }}}
|
||||
function! s:page_undo() " {{{
|
||||
function! s:page_undo() abort " {{{
|
||||
call s:winclose()
|
||||
let s:guide_group = {}
|
||||
let s:prefix_key_inp = ''
|
||||
let s:lmap = s:lmap_undo
|
||||
call s:start_buffer()
|
||||
endfunction " }}}
|
||||
function! s:page_up() " {{{
|
||||
call feedkeys("\<c-c>", "n")
|
||||
call feedkeys("\<c-b>", "x")
|
||||
function! s:page_up() abort " {{{
|
||||
call feedkeys("\<c-c>", 'n')
|
||||
call feedkeys("\<c-b>", 'x')
|
||||
redraw!
|
||||
call s:wait_for_input()
|
||||
endfunction " }}}
|
||||
|
||||
function! s:handle_submode_mapping(cmd) " {{{
|
||||
function! s:handle_submode_mapping(cmd) abort " {{{
|
||||
let s:guide_help_mode = 0
|
||||
call s:updateStatusline()
|
||||
if a:cmd ==? '<LGCMD>page_down'
|
||||
if a:cmd ==# 'n'
|
||||
call s:page_down()
|
||||
elseif a:cmd ==? '<LGCMD>page_up'
|
||||
elseif a:cmd ==# 'p'
|
||||
call s:page_up()
|
||||
elseif a:cmd ==? '<LGCMD>undo'
|
||||
elseif a:cmd ==# 'u'
|
||||
call s:page_undo()
|
||||
elseif a:cmd ==? '<LGCMD>win_close'
|
||||
call s:winclose()
|
||||
else
|
||||
call feedkeys("\<c-c>", "n")
|
||||
redraw!
|
||||
call s:wait_for_input()
|
||||
call s:winclose()
|
||||
endif
|
||||
endfunction " }}}
|
||||
function! s:submode_mappings() " {{{
|
||||
let maplist = []
|
||||
for key in items(g:leaderGuide_submode_mappings)
|
||||
let map = maparg(key[0], "c", 0, 1)
|
||||
if !empty(map)
|
||||
call add(maplist, map)
|
||||
endif
|
||||
execute 'cnoremap <nowait> <silent> <buffer> '.key[0].' <LGCMD>'.key[1].'<CR>'
|
||||
endfor
|
||||
let inp = input('')
|
||||
for map in maplist
|
||||
call s:mapmaparg(map)
|
||||
endfor
|
||||
silent call s:handle_submode_mapping(inp)
|
||||
function! s:submode_mappings(key) abort " {{{
|
||||
silent call s:handle_submode_mapping(a:key)
|
||||
endfunction " }}}
|
||||
function! s:mapmaparg(maparg) " {{{
|
||||
function! s:mapmaparg(maparg) abort " {{{
|
||||
let noremap = a:maparg.noremap ? 'noremap' : 'map'
|
||||
let buffer = a:maparg.buffer ? '<buffer> ' : ''
|
||||
let silent = a:maparg.silent ? '<silent> ' : ''
|
||||
@ -572,7 +640,7 @@ function! s:mapmaparg(maparg) " {{{
|
||||
execute st
|
||||
endfunction " }}}
|
||||
|
||||
function! s:get_register() "{{{
|
||||
function! s:get_register() abort "{{{
|
||||
if match(&clipboard, 'unnamedplus') >= 0
|
||||
let clip = '+'
|
||||
elseif match(&clipboard, 'unnamed') >= 0
|
||||
@ -582,8 +650,8 @@ function! s:get_register() "{{{
|
||||
endif
|
||||
return clip
|
||||
endfunction "}}}
|
||||
function! SpaceVim#mapping#guide#start_by_prefix(vis, key) " {{{
|
||||
if a:key == ' ' && exists('b:spacevim_lang_specified_mappings')
|
||||
function! SpaceVim#mapping#guide#start_by_prefix(vis, key) abort " {{{
|
||||
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
|
||||
@ -612,23 +680,22 @@ function! SpaceVim#mapping#guide#start_by_prefix(vis, key) " {{{
|
||||
endif
|
||||
let s:lmap = rundict
|
||||
let s:lmap_undo = rundict
|
||||
|
||||
call s:start_buffer()
|
||||
endfunction " }}}
|
||||
function! SpaceVim#mapping#guide#start(vis, dict) " {{{
|
||||
function! SpaceVim#mapping#guide#start(vis, dict) abort " {{{
|
||||
let s:vis = a:vis ? 'gv' : 0
|
||||
let s:lmap = a:dict
|
||||
call s:start_buffer()
|
||||
endfunction " }}}
|
||||
|
||||
if !exists("g:leaderGuide_displayfunc")
|
||||
function! s:leaderGuide_display()
|
||||
if !exists('g:leaderGuide_displayfunc')
|
||||
function! s:leaderGuide_display() abort
|
||||
let g:leaderGuide#displayname = substitute(g:leaderGuide#displayname, '\c<cr>$', '', '')
|
||||
endfunction
|
||||
let g:leaderGuide_displayfunc = [function("s:leaderGuide_display")]
|
||||
let g:leaderGuide_displayfunc = [function('s:leaderGuide_display')]
|
||||
endif
|
||||
|
||||
if get(g:, 'mapleader', '\') == ' '
|
||||
if get(g:, 'mapleader', '\') ==# ' '
|
||||
call SpaceVim#mapping#guide#register_prefix_descriptions(' ',
|
||||
\ 'g:_spacevim_mappings')
|
||||
else
|
||||
|
0
autoload/SpaceVim/mapping/guide/paser.vim
Normal file
0
autoload/SpaceVim/mapping/guide/paser.vim
Normal file
@ -6,44 +6,44 @@
|
||||
" License: GPLv3
|
||||
"=============================================================================
|
||||
" Color palette
|
||||
let s:gui00 = "#151515"
|
||||
let s:gui01 = "#262626"
|
||||
let s:gui02 = "#4f5b66"
|
||||
let s:gui03 = "#65737e"
|
||||
let s:gui04 = "#a7adba"
|
||||
let s:gui05 = "#c0c5ce"
|
||||
let s:gui06 = "#cdd3de"
|
||||
let s:gui07 = "#d8dee9"
|
||||
let s:gui08 = "#870000"
|
||||
let s:gui09 = "#f99157"
|
||||
let s:gui0A = "#fac863"
|
||||
let s:gui0B = "#437019"
|
||||
let s:gui0C = "#5fb3b3"
|
||||
let s:gui0D = "#0d61ac"
|
||||
let s:gui0E = "#c594c5"
|
||||
let s:gui0F = "#ab7967"
|
||||
let s:gui00 = '#151515'
|
||||
let s:gui01 = '#262626'
|
||||
let s:gui02 = '#4f5b66'
|
||||
let s:gui03 = '#65737e'
|
||||
let s:gui04 = '#a7adba'
|
||||
let s:gui05 = '#c0c5ce'
|
||||
let s:gui06 = '#cdd3de'
|
||||
let s:gui07 = '#d8dee9'
|
||||
let s:gui08 = '#870000'
|
||||
let s:gui09 = '#f99157'
|
||||
let s:gui0A = '#fac863'
|
||||
let s:gui0B = '#437019'
|
||||
let s:gui0C = '#5fb3b3'
|
||||
let s:gui0D = '#0d61ac'
|
||||
let s:gui0E = '#c594c5'
|
||||
let s:gui0F = '#ab7967'
|
||||
|
||||
let s:cterm00 = "233"
|
||||
let s:cterm01 = "235"
|
||||
let s:cterm02 = "59"
|
||||
let s:cterm03 = "66"
|
||||
let s:cterm04 = "145"
|
||||
let s:cterm05 = "152"
|
||||
let s:cterm06 = "188"
|
||||
let s:cterm07 = "189"
|
||||
let s:cterm08 = "88"
|
||||
let s:cterm09 = "209"
|
||||
let s:cterm0A = "221"
|
||||
let s:cterm0B = "22"
|
||||
let s:cterm0C = "73"
|
||||
let s:cterm0D = "25"
|
||||
let s:cterm0E = "176"
|
||||
let s:cterm0F = "137"
|
||||
let s:cterm00 = '233'
|
||||
let s:cterm01 = '235'
|
||||
let s:cterm02 = '59'
|
||||
let s:cterm03 = '66'
|
||||
let s:cterm04 = '145'
|
||||
let s:cterm05 = '152'
|
||||
let s:cterm06 = '188'
|
||||
let s:cterm07 = '189'
|
||||
let s:cterm08 = '88'
|
||||
let s:cterm09 = '209'
|
||||
let s:cterm0A = '221'
|
||||
let s:cterm0B = '22'
|
||||
let s:cterm0C = '73'
|
||||
let s:cterm0D = '25'
|
||||
let s:cterm0E = '176'
|
||||
let s:cterm0F = '137'
|
||||
|
||||
let s:guiWhite = "#ffffff"
|
||||
let s:guiGray = "#666666"
|
||||
let s:ctermWhite = "231"
|
||||
let s:ctermGray = "243"
|
||||
let s:guiWhite = '#ffffff'
|
||||
let s:guiGray = '#666666'
|
||||
let s:ctermWhite = '231'
|
||||
let s:ctermGray = '243'
|
||||
|
||||
|
||||
function! SpaceVim#mapping#guide#theme#jellybeans#palette() abort
|
||||
|
@ -24,23 +24,23 @@
|
||||
" group_v: window id in visual mode
|
||||
" group_r: window id in select mode
|
||||
|
||||
let s:gui_base03 = "#002b36"
|
||||
let s:gui_base02 = "#073642"
|
||||
let s:gui_base01 = "#586e75"
|
||||
let s:gui_base00 = "#657b83"
|
||||
let s:gui_base0 = "#839496"
|
||||
let s:gui_base1 = "#93a1a1"
|
||||
let s:gui_base2 = "#eee8d5"
|
||||
let s:gui_base3 = "#fdf6e3"
|
||||
let s:gui_yellow = "#b58900"
|
||||
let s:gui_orange = "#cb4b16"
|
||||
let s:gui_red = "#dc322f"
|
||||
let s:gui_magenta = "#d33682"
|
||||
let s:gui_violet = "#6c71c4"
|
||||
let s:gui_blue = "#268bd2"
|
||||
let s:gui_cyan = "#2aa198"
|
||||
let s:gui_base03 = '#002b36'
|
||||
let s:gui_base02 = '#073642'
|
||||
let s:gui_base01 = '#586e75'
|
||||
let s:gui_base00 = '#657b83'
|
||||
let s:gui_base0 = '#839496'
|
||||
let s:gui_base1 = '#93a1a1'
|
||||
let s:gui_base2 = '#eee8d5'
|
||||
let s:gui_base3 = '#fdf6e3'
|
||||
let s:gui_yellow = '#b58900'
|
||||
let s:gui_orange = '#cb4b16'
|
||||
let s:gui_red = '#dc322f'
|
||||
let s:gui_magenta = '#d33682'
|
||||
let s:gui_violet = '#6c71c4'
|
||||
let s:gui_blue = '#268bd2'
|
||||
let s:gui_cyan = '#2aa198'
|
||||
"let s:gui_green = "#859900" "original
|
||||
let s:gui_green = "#719e07" "experimental
|
||||
let s:gui_green = '#719e07' "experimental
|
||||
|
||||
let s:cterm_base03 = 8
|
||||
let s:cterm_base02 = 0
|
||||
|
@ -14,17 +14,6 @@ function! SpaceVim#mapping#leader#defindWindowsLeader(key) abort
|
||||
\ a:key . '"<CR>'
|
||||
exe 'nmap ' .a:key . ' [Window]'
|
||||
let g:_spacevim_mappings_windows = {}
|
||||
nnoremap <silent> [Window]p
|
||||
\ :<C-u>vsplit<CR>:wincmd w<CR>
|
||||
let lnum = expand('<slnum>') + s:lnum - 4
|
||||
let g:_spacevim_mappings_windows.p = ['vsplit | wincmd w',
|
||||
\ 'vsplit vertically,switch to next window',
|
||||
\ [
|
||||
\ '[WIN p ] is to split windows vertically, switch to the new window',
|
||||
\ '',
|
||||
\ 'Definition: ' . s:file . ':' . lnum,
|
||||
\ ]
|
||||
\ ]
|
||||
nnoremap <silent> [Window]v
|
||||
\ :<C-u>split<CR>
|
||||
let lnum = expand('<slnum>') + s:lnum - 4
|
||||
@ -36,13 +25,35 @@ function! SpaceVim#mapping#leader#defindWindowsLeader(key) abort
|
||||
\ 'Definition: ' . s:file . ':' . lnum,
|
||||
\ ]
|
||||
\ ]
|
||||
nnoremap <silent> [Window]V
|
||||
\ :<C-u>split +bp<CR>
|
||||
let lnum = expand('<slnum>') + s:lnum - 4
|
||||
let g:_spacevim_mappings_windows.V = ['split +bp',
|
||||
\ 'split previous buffer',
|
||||
\ [
|
||||
\ '[WIN V] is to split previous buffer, switch to the new window',
|
||||
\ '',
|
||||
\ 'Definition: ' . s:file . ':' . lnum,
|
||||
\ ]
|
||||
\ ]
|
||||
nnoremap <silent> [Window]g
|
||||
\ :<C-u>vsplit<CR>
|
||||
let lnum = expand('<slnum>') + s:lnum - 4
|
||||
let g:_spacevim_mappings_windows.g = ['vsplit',
|
||||
\ 'vsplit window',
|
||||
\ [
|
||||
\ '[WIN g] is to split windows vertically, switch to the new window',
|
||||
\ '[WIN g] is to split previous buffer vertically, switch to the new window',
|
||||
\ '',
|
||||
\ 'Definition: ' . s:file . ':' . lnum,
|
||||
\ ]
|
||||
\ ]
|
||||
nnoremap <silent> [Window]G
|
||||
\ :<C-u>vsplit +bp<CR>
|
||||
let lnum = expand('<slnum>') + s:lnum - 4
|
||||
let g:_spacevim_mappings_windows.G = ['vsplit +bp',
|
||||
\ 'vsplit previous buffer',
|
||||
\ [
|
||||
\ '[WIN G] is to split windows vertically, switch to the new window',
|
||||
\ '',
|
||||
\ 'Definition: ' . s:file . ':' . lnum,
|
||||
\ ]
|
||||
@ -172,13 +183,13 @@ endfunction
|
||||
|
||||
|
||||
function! SpaceVim#mapping#leader#getName(key) abort
|
||||
if a:key == ' '
|
||||
if a:key ==# ' '
|
||||
return '[SPC]'
|
||||
elseif a:key == 'g'
|
||||
elseif a:key ==# 'g'
|
||||
return '[g]'
|
||||
elseif a:key == 'z'
|
||||
elseif a:key ==# 'z'
|
||||
return '[z]'
|
||||
elseif a:key == g:spacevim_windows_leader
|
||||
elseif a:key ==# g:spacevim_windows_leader
|
||||
return '[WIN]'
|
||||
elseif a:key ==# '\'
|
||||
return '<leader>'
|
||||
|
@ -7,6 +7,7 @@
|
||||
"=============================================================================
|
||||
|
||||
let s:file = expand('<sfile>:~')
|
||||
let s:funcbeginline = expand('<slnum>') + 1
|
||||
function! SpaceVim#mapping#space#init() abort
|
||||
let g:_spacevim_mappings_space = {}
|
||||
let g:_spacevim_mappings_prefixs['[SPC]'] = {'name' : '+SPC prefix'}
|
||||
@ -20,7 +21,7 @@ function! SpaceVim#mapping#space#init() abort
|
||||
let g:_spacevim_mappings_space.j = {'name' : '+Jump/Join/Split'}
|
||||
let g:_spacevim_mappings_space.m = {'name' : '+Major-mode'}
|
||||
let g:_spacevim_mappings_space.w = {'name' : '+Windows'}
|
||||
let g:_spacevim_mappings_space.p = {'name' : '+Projects'}
|
||||
let g:_spacevim_mappings_space.p = {'name' : '+Projects/Packages'}
|
||||
let g:_spacevim_mappings_space.h = {'name' : '+Help'}
|
||||
let g:_spacevim_mappings_space.n = {'name' : '+Narrow/Numbers'}
|
||||
let g:_spacevim_mappings_space.q = {'name' : '+Quit'}
|
||||
@ -52,63 +53,239 @@ function! SpaceVim#mapping#space#init() abort
|
||||
\ 'call call('
|
||||
\ . string(function('s:windows_layout_toggle'))
|
||||
\ . ', [])', 'windows-layout-toggle', 1)
|
||||
let s:lnum = expand('<slnum>') + 3
|
||||
let s:lnum = expand('<slnum>') + s:funcbeginline
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', '.'], 'call call('
|
||||
\ . string(s:_function('s:windows_transient_state')) . ', [])',
|
||||
\ ['buffer transient state',
|
||||
\ [
|
||||
\ '[SPC b .] is to open the buffer transient state',
|
||||
\ '[SPC w .] is to open the buffer transient state',
|
||||
\ '',
|
||||
\ 'Definition: ' . s:file . ':' . s:lnum,
|
||||
\ ]
|
||||
\ ]
|
||||
\ , 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', 'd'],
|
||||
\ 'close', 'delete window', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', 'D'],
|
||||
\ 'ChooseWin | close | wincmd w', 'delete window (other windows)', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', 'f'],
|
||||
\ 'tabnew', 'create new tab', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', 'F'],
|
||||
\ 'call call('
|
||||
let s:lnum = expand('<slnum>') + s:funcbeginline
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', 'd'], 'close',
|
||||
\ ['close-current-windows',
|
||||
\ [
|
||||
\ '[SPC w d] is to close current windows',
|
||||
\ '',
|
||||
\ 'Definition: ' . s:file . ':' . s:lnum,
|
||||
\ ]
|
||||
\ ]
|
||||
\ , 1)
|
||||
let s:lnum = expand('<slnum>') + s:funcbeginline
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', 'D'], 'ChooseWin | close | wincmd w',
|
||||
\ ['delete window (other windows)',
|
||||
\ [
|
||||
\ '[SPC w D] is to select a windows to close',
|
||||
\ '',
|
||||
\ 'Definition: ' . s:file . ':' . s:lnum,
|
||||
\ ]
|
||||
\ ]
|
||||
\ , 1)
|
||||
let s:lnum = expand('<slnum>') + s:funcbeginline
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', 'f'], 'tabnew',
|
||||
\ ['create new tab',
|
||||
\ [
|
||||
\ '[SPC w f] is to create new tab',
|
||||
\ '',
|
||||
\ 'Definition: ' . s:file . ':' . s:lnum,
|
||||
\ ]
|
||||
\ ]
|
||||
\ , 1)
|
||||
let s:lnum = expand('<slnum>') + s:funcbeginline
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', 'F'], 'call call('
|
||||
\ . string(function('s:create_new_named_tab'))
|
||||
\ . ', [])', 'create new named tab', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', 'h'],
|
||||
\ 'wincmd h', 'window-left', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', 'j'],
|
||||
\ 'wincmd j', 'window-down', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', 'k'],
|
||||
\ 'wincmd k', 'window-up', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', 'l'],
|
||||
\ 'wincmd l', 'window-right', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', 'H'],
|
||||
\ 'wincmd H', 'window-far-left', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', 'J'],
|
||||
\ 'wincmd J', 'window-far-down', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', 'K'],
|
||||
\ 'wincmd K', 'window-far-up', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', 'L'],
|
||||
\ 'wincmd L', 'window-far-right', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', 'm'],
|
||||
\ 'only', 'maximize/minimize window', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', 'M'],
|
||||
\ 'ChooseWinSwap', 'swap window', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', 'o'],
|
||||
\ 'tabnext', 'other tabs', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', '/'],
|
||||
\ 'bel vs | wincmd w', 'split-window-right', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', 'v'],
|
||||
\ 'bel vs | wincmd w', 'split-window-right', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', '-'],
|
||||
\ 'bel split | wincmd w', 'split-window-below', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', 's'],
|
||||
\ 'bel split | wincmd w', 'split-window-below', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', 'S'],
|
||||
\ 'bel split', 'split-focus-window-below', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', '2'],
|
||||
\ 'silent only | vs | wincmd w', 'layout-double-columns', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', '3'],
|
||||
\ 'silent only | vs | vs | wincmd H', 'split-window-below', 1)
|
||||
\ . ', [])',
|
||||
\ ['create new named tab',
|
||||
\ [
|
||||
\ '[SPC w F] is to create new named tab',
|
||||
\ '',
|
||||
\ 'Definition: ' . s:file . ':' . s:lnum,
|
||||
\ ]
|
||||
\ ]
|
||||
\ , 1)
|
||||
let s:lnum = expand('<slnum>') + s:funcbeginline
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', 'h'], 'wincmd h',
|
||||
\ ['window-left',
|
||||
\ [
|
||||
\ '[SPC w h] is to jump to the left window',
|
||||
\ '',
|
||||
\ 'Definition: ' . s:file . ':' . s:lnum,
|
||||
\ ]
|
||||
\ ]
|
||||
\ , 1)
|
||||
let s:lnum = expand('<slnum>') + s:funcbeginline
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', 'j'], 'wincmd j',
|
||||
\ ['window-down',
|
||||
\ [
|
||||
\ '[SPC w j] is to jump to the window below current windows',
|
||||
\ '',
|
||||
\ 'Definition: ' . s:file . ':' . s:lnum,
|
||||
\ ]
|
||||
\ ]
|
||||
\ , 1)
|
||||
let s:lnum = expand('<slnum>') + s:funcbeginline
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', 'k'], 'wincmd k',
|
||||
\ ['window-up',
|
||||
\ [
|
||||
\ '[SPC w k] is to jump to the window above current windows',
|
||||
\ '',
|
||||
\ 'Definition: ' . s:file . ':' . s:lnum,
|
||||
\ ]
|
||||
\ ]
|
||||
\ , 1)
|
||||
let s:lnum = expand('<slnum>') + s:funcbeginline
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', 'l'], 'wincmd l',
|
||||
\ ['window-right',
|
||||
\ [
|
||||
\ '[SPC w l] is to jump to the right window',
|
||||
\ '',
|
||||
\ 'Definition: ' . s:file . ':' . s:lnum,
|
||||
\ ]
|
||||
\ ]
|
||||
\ , 1)
|
||||
let s:lnum = expand('<slnum>') + s:funcbeginline
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', 'H'], 'wincmd H',
|
||||
\ ['window-far-left',
|
||||
\ [
|
||||
\ '[SPC w H] is to jump to the far left window',
|
||||
\ '',
|
||||
\ 'Definition: ' . s:file . ':' . s:lnum,
|
||||
\ ]
|
||||
\ ]
|
||||
\ , 1)
|
||||
let s:lnum = expand('<slnum>') + s:funcbeginline
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', 'J'], 'wincmd J',
|
||||
\ ['window-far-down',
|
||||
\ [
|
||||
\ '[SPC w J] is to jump to the far down window',
|
||||
\ '',
|
||||
\ 'Definition: ' . s:file . ':' . s:lnum,
|
||||
\ ]
|
||||
\ ]
|
||||
\ , 1)
|
||||
let s:lnum = expand('<slnum>') + s:funcbeginline
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', 'K'], 'wincmd K',
|
||||
\ ['window-far-up',
|
||||
\ [
|
||||
\ '[SPC w K] is to jump to the far up window',
|
||||
\ '',
|
||||
\ 'Definition: ' . s:file . ':' . s:lnum,
|
||||
\ ]
|
||||
\ ]
|
||||
\ , 1)
|
||||
let s:lnum = expand('<slnum>') + s:funcbeginline
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', 'L'], 'wincmd L',
|
||||
\ ['window-far-right',
|
||||
\ [
|
||||
\ '[SPC w L] is to jump to the far right window',
|
||||
\ '',
|
||||
\ 'Definition: ' . s:file . ':' . s:lnum,
|
||||
\ ]
|
||||
\ ]
|
||||
\ , 1)
|
||||
let s:lnum = expand('<slnum>') + s:funcbeginline
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', 'm'], 'only',
|
||||
\ ['maximize/minimize window',
|
||||
\ [
|
||||
\ '[SPC w m] is to maximize/minimize window',
|
||||
\ '',
|
||||
\ 'Definition: ' . s:file . ':' . s:lnum,
|
||||
\ ]
|
||||
\ ]
|
||||
\ , 1)
|
||||
let s:lnum = expand('<slnum>') + s:funcbeginline
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', 'M'], 'ChooseWinSwap',
|
||||
\ ['swap window',
|
||||
\ [
|
||||
\ '[SPC w M] is to swap window',
|
||||
\ '',
|
||||
\ 'Definition: ' . s:file . ':' . s:lnum,
|
||||
\ ]
|
||||
\ ]
|
||||
\ , 1)
|
||||
let s:lnum = expand('<slnum>') + s:funcbeginline
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', 'o'], 'tabnext',
|
||||
\ ['other tabs',
|
||||
\ [
|
||||
\ '[SPC w o] is to switch to next tabs',
|
||||
\ '',
|
||||
\ 'Definition: ' . s:file . ':' . s:lnum,
|
||||
\ ]
|
||||
\ ]
|
||||
\ , 1)
|
||||
let s:lnum = expand('<slnum>') + s:funcbeginline
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', '/'], 'belowright vsplit | wincmd w',
|
||||
\ ['split-windows-right',
|
||||
\ [
|
||||
\ '[SPC w /] is to split windows on the right',
|
||||
\ '',
|
||||
\ 'Definition: ' . s:file . ':' . s:lnum,
|
||||
\ ]
|
||||
\ ]
|
||||
\ , 1)
|
||||
let s:lnum = expand('<slnum>') + s:funcbeginline
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', 'v'], 'belowright vsplit | wincmd w',
|
||||
\ ['split-windows-right',
|
||||
\ [
|
||||
\ '[SPC w v] is to split windows on the right',
|
||||
\ '',
|
||||
\ 'Definition: ' . s:file . ':' . s:lnum,
|
||||
\ ]
|
||||
\ ]
|
||||
\ , 1)
|
||||
let s:lnum = expand('<slnum>') + s:funcbeginline
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', '-'], 'bel split | wincmd w',
|
||||
\ ['split-windows-below',
|
||||
\ [
|
||||
\ '[SPC w -] is to split windows below',
|
||||
\ '',
|
||||
\ 'Definition: ' . s:file . ':' . s:lnum,
|
||||
\ ]
|
||||
\ ]
|
||||
\ , 1)
|
||||
let s:lnum = expand('<slnum>') + s:funcbeginline
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', 's'], 'bel split | wincmd w',
|
||||
\ ['split-windows-below',
|
||||
\ [
|
||||
\ '[SPC w s] is to split windows below',
|
||||
\ '',
|
||||
\ 'Definition: ' . s:file . ':' . s:lnum,
|
||||
\ ]
|
||||
\ ]
|
||||
\ , 1)
|
||||
let s:lnum = expand('<slnum>') + s:funcbeginline
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', 'S'], 'bel split',
|
||||
\ ['split-focus-windows-below',
|
||||
\ [
|
||||
\ '[SPC w S] is to split windows below and focus on new windows',
|
||||
\ '',
|
||||
\ 'Definition: ' . s:file . ':' . s:lnum,
|
||||
\ ]
|
||||
\ ]
|
||||
\ , 1)
|
||||
let s:lnum = expand('<slnum>') + s:funcbeginline
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', '2'], 'silent only | vs | wincmd w',
|
||||
\ ['layout-double-columns',
|
||||
\ [
|
||||
\ '[SPC w 2] is to change current windows layout to double columns',
|
||||
\ '',
|
||||
\ 'Definition: ' . s:file . ':' . s:lnum,
|
||||
\ ]
|
||||
\ ]
|
||||
\ , 1)
|
||||
let s:lnum = expand('<slnum>') + s:funcbeginline
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', '3'], 'silent only | vs | vs | wincmd H',
|
||||
\ ['layout-three-columns',
|
||||
\ [
|
||||
\ '[SPC w 3] is to change current windows layout to three columns',
|
||||
\ '',
|
||||
\ 'Definition: ' . s:file . ':' . s:lnum,
|
||||
\ ]
|
||||
\ ]
|
||||
\ , 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', 'V'],
|
||||
\ 'bel vs', 'split-window-right-focus', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', '='],
|
||||
@ -119,7 +296,7 @@ function! SpaceVim#mapping#space#init() abort
|
||||
\ 'ChooseWin', 'select window', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', 'u'], 'call SpaceVim#plugins#windowsmanager#UndoQuitWin()', 'undo quieted window', 1)
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['w', 'U'], 'call SpaceVim#plugins#windowsmanager#RedoQuitWin()', 'redo quieted window', 1)
|
||||
let s:lnum = expand('<slnum>') + 3
|
||||
let s:lnum = expand('<slnum>') + s:funcbeginline
|
||||
call SpaceVim#mapping#space#def('nnoremap', ['b', 'n'], 'bnext', ['next buffer',
|
||||
\ [
|
||||
\ '[SPC b n] is running :bnext, jump to next buffer',
|
||||
@ -348,9 +525,11 @@ function! SpaceVim#mapping#space#def(m, keys, cmd, desc, is_cmd, ...) abort
|
||||
let is_visual = a:0 > 0 ? a:1 : 0
|
||||
if a:is_cmd
|
||||
let cmd = ':<C-u>' . a:cmd . '<CR>'
|
||||
let xcmd = ':' . a:cmd . '<CR>'
|
||||
let lcmd = a:cmd
|
||||
else
|
||||
let cmd = a:cmd
|
||||
let xcmd = a:cmd
|
||||
let feedkey_m = a:m =~# 'nore' ? 'n' : 'm'
|
||||
if a:cmd =~? '^<plug>'
|
||||
let lcmd = 'call feedkeys("\' . a:cmd . '", "' . feedkey_m . '")'
|
||||
@ -361,9 +540,9 @@ function! SpaceVim#mapping#space#def(m, keys, cmd, desc, is_cmd, ...) abort
|
||||
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')
|
||||
exe 'xnoremap <silent> [SPC]' . join(a:keys, '') . ' ' . substitute(xcmd, '|', '\\|', 'g')
|
||||
elseif a:m ==# 'nmap'
|
||||
exe 'xmap <silent> [SPC]' . join(a:keys, '') . ' ' . substitute(cmd, '|', '\\|', 'g')
|
||||
exe 'xmap <silent> [SPC]' . join(a:keys, '') . ' ' . substitute(xcmd, '|', '\\|', 'g')
|
||||
endif
|
||||
endif
|
||||
if len(a:keys) == 2
|
||||
|
@ -28,7 +28,7 @@ if g:spacevim_snippet_engine ==# 'neosnippet'
|
||||
endif
|
||||
endfunction
|
||||
elseif g:spacevim_snippet_engine ==# 'ultisnips'
|
||||
function! SpaceVim#mapping#tab#expandable()
|
||||
function! SpaceVim#mapping#tab#expandable() abort
|
||||
let snippet = UltiSnips#ExpandSnippetOrJump()
|
||||
if g:ulti_expand_or_jump_res > 0
|
||||
return snippet
|
||||
|
@ -70,10 +70,14 @@ function! SpaceVim#mapping#z#init() abort "{{{
|
||||
nnoremap z<Left> zh
|
||||
let g:_spacevim_mappings_z['i'] = ['call feedkeys("zi", "n")', 'toggle foldenable']
|
||||
nnoremap zi zi
|
||||
let g:_spacevim_mappings_z['j'] = ['call feedkeys("zj", "n")', 'mode to start of next fold']
|
||||
let g:_spacevim_mappings_z['j'] = ['call feedkeys("zj", "n")', 'move to start of next fold']
|
||||
nnoremap zj zj
|
||||
let g:_spacevim_mappings_z['k'] = ['call feedkeys("zk", "n")', 'mode to end of previous fold']
|
||||
let g:_spacevim_mappings_z['J'] = ['call feedkeys("zjzx", "n")', 'move to and open next fold']
|
||||
nnoremap zJ zjzx
|
||||
let g:_spacevim_mappings_z['k'] = ['call feedkeys("zk", "n")', 'move to end of previous fold']
|
||||
nnoremap zk zk
|
||||
let g:_spacevim_mappings_z['K'] = ['call feedkeys("zkzx", "n")', 'move to and open previous fold']
|
||||
nnoremap zK zkzx
|
||||
let g:_spacevim_mappings_z['l'] = ['call feedkeys("zl", "n")', 'scroll screen N characters to left']
|
||||
nnoremap zl zl
|
||||
let g:_spacevim_mappings_z['<Right>'] = ['call feedkeys("zl", "n")', 'scroll screen N characters to left']
|
||||
|
@ -20,13 +20,13 @@ let s:conf = '.project_alt.json'
|
||||
|
||||
let s:project_config = {}
|
||||
|
||||
function! SpaceVim#plugins#a#set_config_name(name)
|
||||
function! SpaceVim#plugins#a#set_config_name(name) abort
|
||||
|
||||
let s:conf = a:name
|
||||
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#plugins#a#alt()
|
||||
function! SpaceVim#plugins#a#alt() abort
|
||||
let conf_file = s:FILE.unify_path(s:conf, ':p')
|
||||
let file = s:FILE.unify_path(bufname('%'), ':.')
|
||||
let alt = SpaceVim#plugins#a#get_alt(file, conf_file)
|
||||
@ -70,7 +70,7 @@ function! Log() abort
|
||||
return s:project_config
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#plugins#a#get_alt(file, root)
|
||||
function! SpaceVim#plugins#a#get_alt(file, root) abort
|
||||
if !has_key(s:project_config, a:root)
|
||||
let altconfa = s:JSON.json_decode(join(readfile(a:root), "\n"))
|
||||
let s:project_config[a:root] = {}
|
||||
@ -84,7 +84,7 @@ function! SpaceVim#plugins#a#get_alt(file, root)
|
||||
endfunction
|
||||
|
||||
|
||||
function! SpaceVim#plugins#a#get_root()
|
||||
function! SpaceVim#plugins#a#get_root() abort
|
||||
return s:FILE.unify_path(s:conf, ':p')
|
||||
endfunction
|
||||
|
||||
|
@ -15,7 +15,7 @@ endif
|
||||
|
||||
" complete input
|
||||
|
||||
function! SpaceVim#plugins#bashcomplete#complete(ArgLead, CmdLine, CursorPos)
|
||||
function! SpaceVim#plugins#bashcomplete#complete(ArgLead, CmdLine, CursorPos) abort
|
||||
return s:BASH_COMPLETE.complete_input(a:ArgLead, a:CmdLine, a:CursorPos)
|
||||
endfunction
|
||||
|
||||
|
@ -14,7 +14,9 @@ let s:SYS = SpaceVim#api#import('system')
|
||||
let s:BUFFER = SpaceVim#api#import('vim#buffer')
|
||||
let s:LIST = SpaceVim#api#import('data#list')
|
||||
let s:HI = SpaceVim#api#import('vim#highlight')
|
||||
"}}}
|
||||
" }}}
|
||||
|
||||
let s:grepid = 0
|
||||
|
||||
" Init local options: {{{
|
||||
let s:grep_expr = ''
|
||||
@ -77,7 +79,7 @@ function! s:get_search_cmd(expr) abort
|
||||
let cmd += [a:expr] + [s:grep_files]
|
||||
elseif !empty(s:grep_dir)
|
||||
" grep dir is not a empty string
|
||||
if s:grep_exe == 'findstr'
|
||||
if s:grep_exe ==# 'findstr'
|
||||
let cmd += [s:grep_dir] + [a:expr] + ['%CD%\*']
|
||||
else
|
||||
let cmd += [a:expr] + [s:grep_dir]
|
||||
@ -87,7 +89,7 @@ function! s:get_search_cmd(expr) abort
|
||||
" current directory.
|
||||
let cmd += [a:expr]
|
||||
" in window, when using rg, ag, need to add '.' at the end.
|
||||
if s:SYS.isWindows && (s:grep_exe == 'rg' || s:grep_exe == 'ag' || s:grep_exe == 'pt' )
|
||||
if s:SYS.isWindows && (s:grep_exe ==# 'rg' || s:grep_exe ==# 'ag' || s:grep_exe ==# 'pt' )
|
||||
let cmd += ['.']
|
||||
endif
|
||||
let cmd += s:grep_ropt
|
||||
@ -258,6 +260,7 @@ function! s:close_grep_job() abort
|
||||
" NOTE: the jobid maybe -1, that is means the cmd is not executable.
|
||||
if s:grepid > 0
|
||||
call s:JOB.stop(s:grepid)
|
||||
let s:std_line = 0
|
||||
endif
|
||||
call timer_stop(s:grep_timer_id)
|
||||
call timer_stop(s:preview_timer_id)
|
||||
@ -275,6 +278,16 @@ endfunction
|
||||
" @vimlint(EVL103, 1, a:data)
|
||||
" @vimlint(EVL103, 1, a:id)
|
||||
" @vimlint(EVL103, 1, a:event)
|
||||
|
||||
" if exists('*nvim_open_win')
|
||||
" let s:std_line = 0
|
||||
" function! s:grep_stdout(id, data, event) abort
|
||||
" let datas =filter(a:data, '!empty(v:val)')
|
||||
" call nvim_buf_set_lines(s:buffer_id,s:std_line,-1,v:true,datas)
|
||||
" let s:std_line += len(datas)
|
||||
" call s:MPT._build_prompt()
|
||||
" endfunction
|
||||
" else
|
||||
function! s:grep_stdout(id, data, event) abort
|
||||
let datas =filter(a:data, '!empty(v:val)')
|
||||
" let datas = s:LIST.uniq_by_func(datas, function('s:file_line'))
|
||||
@ -288,6 +301,7 @@ function! s:grep_stdout(id, data, event) abort
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
" endif
|
||||
|
||||
function! s:grep_stderr(id, data, event) abort
|
||||
call SpaceVim#logger#error(' flygerp stderr: ' . string(a:data))
|
||||
@ -297,6 +311,7 @@ function! s:grep_exit(id, data, event) abort
|
||||
redraw
|
||||
call s:MPT._build_prompt()
|
||||
redrawstatus
|
||||
let s:std_line = 1
|
||||
let s:grepid = 0
|
||||
endfunction
|
||||
" @vimlint(EVL103, 0, a:data)
|
||||
@ -445,27 +460,33 @@ endfunction
|
||||
|
||||
let s:previewd_bufnrs = []
|
||||
|
||||
function! Test() abort
|
||||
return s:previewd_bufnrs
|
||||
endfunction
|
||||
" @vimlint(EVL103, 1, a:timer)
|
||||
" use floating windows to preview
|
||||
let s:preview_win_id = -1
|
||||
if exists('*nvim_open_win')
|
||||
function! s:preview_timer(timer) abort
|
||||
|
||||
function! s:preview_timer(timer) abort
|
||||
for id in filter(s:previewd_bufnrs, 'bufexists(v:val) && buflisted(v:val)')
|
||||
endfunction
|
||||
else
|
||||
function! s:preview_timer(timer) abort
|
||||
for id in filter(s:previewd_bufnrs, 'bufexists(v:val) && buflisted(v:val)')
|
||||
exe 'silent bd ' . id
|
||||
endfor
|
||||
let br = bufnr('$')
|
||||
let line = getline('.')
|
||||
let filename = fnameescape(split(line, ':\d\+:')[0])
|
||||
let linenr = matchstr(line, ':\d\+:')[1:-2]
|
||||
exe 'silent pedit! +' . linenr . ' ' . filename
|
||||
wincmd p
|
||||
if bufnr('%') > br
|
||||
call add(s:previewd_bufnrs, bufnr('%'))
|
||||
endif
|
||||
wincmd p
|
||||
resize 18
|
||||
call s:MPT._build_prompt()
|
||||
endfunction
|
||||
endfor
|
||||
let br = bufnr('$')
|
||||
let line = getline('.')
|
||||
let filename = fnameescape(split(line, ':\d\+:')[0])
|
||||
let linenr = matchstr(line, ':\d\+:')[1:-2]
|
||||
exe 'silent pedit! +' . linenr . ' ' . filename
|
||||
wincmd p
|
||||
if bufnr('%') > br
|
||||
call add(s:previewd_bufnrs, bufnr('%'))
|
||||
endif
|
||||
wincmd p
|
||||
resize 18
|
||||
call s:MPT._build_prompt()
|
||||
endfunction
|
||||
endif
|
||||
" @vimlint(EVL103, 0, a:timer)
|
||||
|
||||
|
||||
function! s:preview() abort
|
||||
@ -575,11 +596,27 @@ function! SpaceVim#plugins#flygrep#open(agrv) abort
|
||||
let s:mode = ''
|
||||
" set default handle func: s:flygrep
|
||||
let s:MPT._handle_fly = function('s:flygrep')
|
||||
noautocmd rightbelow split __flygrep__
|
||||
if exists('*nvim_open_win')
|
||||
let s:buffer_id = nvim_create_buf(v:false, v:false)
|
||||
let flygrep_win_height = 16
|
||||
let s:flygrep_win_id = nvim_open_win(s:buffer_id, v:true, &columns, flygrep_win_height,
|
||||
\ {
|
||||
\ 'relative': 'editor',
|
||||
\ 'row': &lines - flygrep_win_height - 2,
|
||||
\ 'col': 0
|
||||
\ })
|
||||
else
|
||||
noautocmd rightbelow split __flygrep__
|
||||
let s:flygrep_win_id = win_getid()
|
||||
endif
|
||||
if exists('&winhighlight')
|
||||
set winhighlight=Normal:Pmenu,EndOfBuffer:Pmenu,CursorLine:PmenuSel
|
||||
endif
|
||||
let s:flygrep_buffer_id = bufnr('%')
|
||||
setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline nospell nonu norelativenumber
|
||||
let save_tve = &t_ve
|
||||
setlocal t_ve=
|
||||
let cursor_hi = {}
|
||||
if has('gui_running')
|
||||
let cursor_hi = s:HI.group2dict('Cursor')
|
||||
call s:HI.hide_in_normal('Cursor')
|
||||
@ -603,9 +640,9 @@ function! SpaceVim#plugins#flygrep#open(agrv) abort
|
||||
let s:grep_dir = ''
|
||||
endif
|
||||
let s:grep_exe = get(a:agrv, 'cmd', s:grep_default_exe)
|
||||
if empty(s:grep_dir) && empty(s:grep_files) && s:grep_exe == 'findstr'
|
||||
if empty(s:grep_dir) && empty(s:grep_files) && s:grep_exe ==# 'findstr'
|
||||
let s:grep_files = '*.*'
|
||||
elseif s:grep_exe == 'findstr' && !empty(s:grep_dir)
|
||||
elseif s:grep_exe ==# 'findstr' && !empty(s:grep_dir)
|
||||
let s:grep_dir = '/D:' . s:grep_dir
|
||||
endif
|
||||
let s:grep_opt = get(a:agrv, 'opt', s:grep_default_opt)
|
||||
@ -633,6 +670,42 @@ function! SpaceVim#plugins#flygrep#open(agrv) abort
|
||||
endfunction
|
||||
" }}}
|
||||
|
||||
let s:statusline_win_id = -1
|
||||
let s:statusline_buf_id = -1
|
||||
function! s:create_statusline() abort
|
||||
let s:statusline_buf_id = nvim_create_buf(0,0)
|
||||
let s:statusline_win_id = nvim_open_win(s:statusline_buf_id,
|
||||
\ v:true,
|
||||
\ &columns ,
|
||||
\ 1,
|
||||
\ {
|
||||
\ 'relative': 'editor',
|
||||
\ 'row': &lines ,
|
||||
\ 'col': 10
|
||||
\ })
|
||||
call setbufvar(s:statusline_buf_id, '&relativenumber', 0)
|
||||
call setbufvar(s:statusline_buf_id, '&number', 0)
|
||||
call nvim_buf_set_virtual_text(
|
||||
\ s:statusline_buf_id,
|
||||
\ -1,
|
||||
\ 0,
|
||||
\ [
|
||||
\ ['FlyGrep ', 'SpaceVim_statusline_a_bold'],
|
||||
\ ['', 'SpaceVim_statusline_a_SpaceVim_statusline_b'],
|
||||
\ [SpaceVim#plugins#flygrep#mode(), 'SpaceVim_statusline_b'],
|
||||
\ ['', 'SpaceVim_statusline_b_SpaceVim_statusline_c'],
|
||||
\ [getcwd(), 'SpaceVim_statusline_c'],
|
||||
\ ['', 'SpaceVim_statusline_c_SpaceVim_statusline_b'],
|
||||
\ [SpaceVim#plugins#flygrep#lineNr(), 'SpaceVim_statusline_b'],
|
||||
\ ['', 'SpaceVim_statusline_b_SpaceVim_statusline_z'],
|
||||
\ ],
|
||||
\ {})
|
||||
endfunction
|
||||
|
||||
function! Test_st() abort
|
||||
call s:create_statusline()
|
||||
endfunction
|
||||
|
||||
" Plugin API: SpaceVim#plugins#flygrep#lineNr() {{{
|
||||
function! SpaceVim#plugins#flygrep#lineNr() abort
|
||||
if getline(1) ==# ''
|
||||
|
@ -7,12 +7,13 @@
|
||||
"=============================================================================
|
||||
|
||||
let s:KEY = SpaceVim#api#import('vim#key')
|
||||
let s:TABs = SpaceVim#api#import('vim#tab')
|
||||
let s:key_describ = {}
|
||||
|
||||
function! SpaceVim#plugins#help#describe_bindings()
|
||||
function! SpaceVim#plugins#help#describe_bindings() abort
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#plugins#help#regist_root(dict)
|
||||
function! SpaceVim#plugins#help#regist_root(dict) abort
|
||||
let keys = keys(a:dict)
|
||||
if type(a:dict) == 4 && len(keys) == 1
|
||||
call extend(s:key_describ, a:dict)
|
||||
@ -20,7 +21,7 @@ function! SpaceVim#plugins#help#regist_root(dict)
|
||||
endfunction
|
||||
|
||||
|
||||
function! SpaceVim#plugins#help#describe_key()
|
||||
function! SpaceVim#plugins#help#describe_key() abort
|
||||
let defined = 1
|
||||
let root = s:key_describ
|
||||
let prompt = 'Describe key:'
|
||||
@ -38,7 +39,7 @@ function! SpaceVim#plugins#help#describe_key()
|
||||
let root = root[name]
|
||||
if type(root) == 3
|
||||
if len(root) == 3
|
||||
redraw!
|
||||
normal! :
|
||||
call s:open_describe_buffer(root[-1])
|
||||
else
|
||||
call s:build_mpt(['can not find describe for ', join(keys, ' - ')])
|
||||
@ -48,9 +49,9 @@ function! SpaceVim#plugins#help#describe_key()
|
||||
call s:build_mpt([prompt, join(keys + [''], ' - ')])
|
||||
endif
|
||||
else
|
||||
redraw!
|
||||
normal! :
|
||||
echohl Comment
|
||||
echo join(keys, ' - ') . ' is undefined'
|
||||
echon join(keys, ' - ') . ' is undefined'
|
||||
echohl NONE
|
||||
let defined = 0
|
||||
endif
|
||||
@ -62,7 +63,7 @@ function! SpaceVim#plugins#help#describe_key()
|
||||
let root = root[name]
|
||||
if type(root) == 3
|
||||
if len(root) == 3
|
||||
redraw!
|
||||
normal! :
|
||||
call s:open_describe_buffer(root[-1])
|
||||
else
|
||||
call s:build_mpt(['can not find describe for ', join(keys, ' - ')])
|
||||
@ -72,9 +73,9 @@ function! SpaceVim#plugins#help#describe_key()
|
||||
call s:build_mpt([prompt, join(keys + [''], ' - ')])
|
||||
endif
|
||||
else
|
||||
redraw!
|
||||
normal! :
|
||||
echohl Comment
|
||||
echo join(keys, ' - ') . ' is undefined'
|
||||
echon join(keys, ' - ') . ' is undefined'
|
||||
echohl NONE
|
||||
let defined = 0
|
||||
endif
|
||||
@ -82,27 +83,50 @@ function! SpaceVim#plugins#help#describe_key()
|
||||
endfunction
|
||||
|
||||
function! s:build_mpt(mpt) abort
|
||||
redraw!
|
||||
normal! :
|
||||
echohl Comment
|
||||
if type(a:mpt) == 1
|
||||
echo a:mpt
|
||||
echon a:mpt
|
||||
elseif type(a:mpt) == 3
|
||||
echo join(a:mpt)
|
||||
echon join(a:mpt)
|
||||
endif
|
||||
echohl NONE
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:open_describe_buffer(desc) abort
|
||||
noautocmd botright split __help_describe__
|
||||
setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline nospell nonu norelativenumber nocursorline
|
||||
set filetype=HelpDescribe
|
||||
call setline(1, a:desc)
|
||||
let b:defind_file_name = split(a:desc[-1][12:], ':')
|
||||
let lines = &lines * 30 / 100
|
||||
if lines < winheight(0)
|
||||
exe 'resize ' . lines
|
||||
" FIXME: check if the help windows exist in current tab
|
||||
" if the windows exit switch to that windows, clear content, update desc and
|
||||
" key binding
|
||||
let tabtree = s:TABs.get_tree()
|
||||
if index(map(tabtree[tabpagenr()], 'bufname(v:val)'), '__help_describe__') == -1
|
||||
noautocmd botright split __help_describe__
|
||||
let s:helpbufnr = bufnr('%')
|
||||
setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline nospell nonu norelativenumber nocursorline
|
||||
set filetype=HelpDescribe
|
||||
setlocal modifiable
|
||||
silent normal! "_ggdG
|
||||
silent call setline(1, a:desc)
|
||||
setlocal nomodifiable
|
||||
let b:defind_file_name = split(a:desc[-1][12:], ':')
|
||||
let lines = &lines * 30 / 100
|
||||
if lines < winheight(0)
|
||||
exe 'resize ' . lines
|
||||
endif
|
||||
setlocal nofoldenable nomodifiable
|
||||
nnoremap <buffer><silent> q :bd<cr>
|
||||
else
|
||||
let winnr = bufwinnr(s:helpbufnr)
|
||||
exe winnr . 'wincmd w'
|
||||
setlocal modifiable
|
||||
silent normal! "_ggdG
|
||||
silent call setline(1, a:desc)
|
||||
setlocal nomodifiable
|
||||
let b:defind_file_name = split(a:desc[-1][12:], ':')
|
||||
let lines = &lines * 30 / 100
|
||||
if lines < winheight(0)
|
||||
exe 'resize ' . lines
|
||||
endif
|
||||
setlocal nofoldenable nomodifiable
|
||||
nnoremap <buffer><silent> q :bd<cr>
|
||||
endif
|
||||
setlocal nofoldenable
|
||||
nnoremap <buffer><silent> q :bd<cr>
|
||||
endfunction
|
||||
|
@ -17,6 +17,7 @@
|
||||
let s:VIMH = SpaceVim#api#import('vim#highlight')
|
||||
let s:STRING = SpaceVim#api#import('data#string')
|
||||
let s:CMP = SpaceVim#api#import('vim#compatible')
|
||||
let s:HI = SpaceVim#api#import('vim#highlight')
|
||||
"}}}
|
||||
|
||||
" init local variable {{{
|
||||
@ -40,11 +41,6 @@ function! s:range_logo() abort
|
||||
endtry
|
||||
let s:hi_range_id = s:CMP.matchaddpos('HiRrange' . s:current_range, [[3, begin, len(s:current_range) + 2]])
|
||||
let s:hi_range_index = s:CMP.matchaddpos('HiRrangeIndex', [[3, begin + len(s:current_range) + 2, len(index) + 2]])
|
||||
redraw!
|
||||
echon ' Change current range to:'
|
||||
exe 'echohl HiRrange' . s:current_range
|
||||
echon s:current_range
|
||||
echohl None
|
||||
endfunction
|
||||
" }}}
|
||||
|
||||
@ -198,7 +194,17 @@ function! SpaceVim#plugins#highlight#start(current) abort
|
||||
\ ],
|
||||
\ }
|
||||
\ )
|
||||
let save_tve = &t_ve
|
||||
setlocal t_ve=
|
||||
if has('gui_running')
|
||||
let cursor_hi = s:HI.group2dict('Cursor')
|
||||
call s:HI.hide_in_normal('Cursor')
|
||||
endif
|
||||
call s:state.open()
|
||||
let &t_ve = save_tve
|
||||
if has('gui_running')
|
||||
call s:HI.hi(cursor_hi)
|
||||
endif
|
||||
try
|
||||
call s:clear_highlight()
|
||||
catch
|
||||
@ -252,7 +258,11 @@ function! s:change_range() abort
|
||||
call s:clear_highlight()
|
||||
call s:highlight()
|
||||
endif
|
||||
let s:state.noredraw = 1
|
||||
let s:state._clear_cmdline = 0
|
||||
echon ' Change current range to:'
|
||||
exe 'echohl HiRrange' . s:current_range
|
||||
echon s:current_range
|
||||
echohl None
|
||||
endfunction
|
||||
" }}}
|
||||
|
||||
|
@ -70,7 +70,7 @@ endfunction
|
||||
" stack cursor pos stack
|
||||
" <
|
||||
" if only argv 1 is given, use selected word as pattern
|
||||
function! SpaceVim#plugins#iedit#start(...)
|
||||
function! SpaceVim#plugins#iedit#start(...) abort
|
||||
let save_tve = &t_ve
|
||||
let save_cl = &l:cursorline
|
||||
setlocal nocursorline
|
||||
@ -112,7 +112,7 @@ function! SpaceVim#plugins#iedit#start(...)
|
||||
endif
|
||||
call s:highlight_cursor()
|
||||
redrawstatus!
|
||||
while s:mode != ''
|
||||
while s:mode !=# ''
|
||||
redraw!
|
||||
let char = getchar()
|
||||
if s:mode ==# 'n' && char == 27
|
||||
@ -176,7 +176,7 @@ function! s:handle_normal(char) abort
|
||||
let s:cursor_stack[i].end = substitute(s:cursor_stack[i].end, '^.', '', 'g')
|
||||
endfor
|
||||
redrawstatus!
|
||||
elseif a:char == "\<Left>" || a:char == 104
|
||||
elseif a:char ==# "\<Left>" || a:char == 104
|
||||
for i in range(len(s:cursor_stack))
|
||||
if !empty(s:cursor_stack[i].begin)
|
||||
let s:cursor_stack[i].end = s:cursor_stack[i].cursor . s:cursor_stack[i].end
|
||||
@ -184,19 +184,19 @@ function! s:handle_normal(char) abort
|
||||
let s:cursor_stack[i].begin = substitute(s:cursor_stack[i].begin, '.$', '', 'g')
|
||||
endif
|
||||
endfor
|
||||
elseif a:char == "\<Right>" || a:char == 108
|
||||
elseif a:char ==# "\<Right>" || a:char == 108
|
||||
for i in range(len(s:cursor_stack))
|
||||
let s:cursor_stack[i].begin = s:cursor_stack[i].begin . s:cursor_stack[i].cursor
|
||||
let s:cursor_stack[i].cursor = matchstr(s:cursor_stack[i].end, '^.')
|
||||
let s:cursor_stack[i].end = substitute(s:cursor_stack[i].end, '^.', '', 'g')
|
||||
endfor
|
||||
elseif a:char == 48 || a:char == "\<Home>" " 0 or <Home>
|
||||
elseif a:char == 48 || a:char ==# "\<Home>" " 0 or <Home>
|
||||
for i in range(len(s:cursor_stack))
|
||||
let s:cursor_stack[i].cursor = matchstr(s:cursor_stack[i].begin . s:cursor_stack[i].cursor . s:cursor_stack[i].end, '^.')
|
||||
let s:cursor_stack[i].end = substitute(s:cursor_stack[i].begin . s:cursor_stack[i].cursor . s:cursor_stack[i].end , '^.', '', 'g')
|
||||
let s:cursor_stack[i].begin = ''
|
||||
endfor
|
||||
elseif a:char == 36 || a:char == "\<End>" " $ or <End>
|
||||
elseif a:char == 36 || a:char ==# "\<End>" " $ or <End>
|
||||
for i in range(len(s:cursor_stack))
|
||||
let s:cursor_stack[i].cursor = matchstr(s:cursor_stack[i].begin . s:cursor_stack[i].cursor . s:cursor_stack[i].end, '.$')
|
||||
let s:cursor_stack[i].begin = substitute(s:cursor_stack[i].begin . s:cursor_stack[i].cursor . s:cursor_stack[i].end , '.$', '', 'g')
|
||||
@ -290,11 +290,11 @@ function! s:handle_insert(char) abort
|
||||
let s:cursor_stack[i].cursor = ''
|
||||
let s:cursor_stack[i].end = ''
|
||||
endfor
|
||||
elseif a:char == "\<bs>"
|
||||
elseif a:char ==# "\<bs>"
|
||||
for i in range(len(s:cursor_stack))
|
||||
let s:cursor_stack[i].begin = substitute(s:cursor_stack[i].begin, '.$', '', 'g')
|
||||
endfor
|
||||
elseif a:char == "\<Left>"
|
||||
elseif a:char ==# "\<Left>"
|
||||
for i in range(len(s:cursor_stack))
|
||||
if !empty(s:cursor_stack[i].begin)
|
||||
let s:cursor_stack[i].end = s:cursor_stack[i].cursor . s:cursor_stack[i].end
|
||||
@ -302,7 +302,7 @@ function! s:handle_insert(char) abort
|
||||
let s:cursor_stack[i].begin = substitute(s:cursor_stack[i].begin, '.$', '', 'g')
|
||||
endif
|
||||
endfor
|
||||
elseif a:char == "\<Right>"
|
||||
elseif a:char ==# "\<Right>"
|
||||
for i in range(len(s:cursor_stack))
|
||||
let s:cursor_stack[i].begin = s:cursor_stack[i].begin . s:cursor_stack[i].cursor
|
||||
let s:cursor_stack[i].cursor = matchstr(s:cursor_stack[i].end, '^.')
|
||||
|
@ -3,7 +3,7 @@
|
||||
" Copyright (c) 2016-2017 Shidong Wang & Contributors
|
||||
" Author: Shidong Wang < wsdjeg at 163.com >
|
||||
" URL: https://spacevim.org
|
||||
" License: MIT license
|
||||
" License: GPLv3 license
|
||||
"=============================================================================
|
||||
|
||||
" Load SpaceVim api
|
||||
@ -163,6 +163,7 @@ function! SpaceVim#plugins#manager#install(...) abort
|
||||
let s:start_time = reltime()
|
||||
for i in range(g:spacevim_plugin_manager_processes)
|
||||
if !empty(s:plugins)
|
||||
let repo = {}
|
||||
if g:spacevim_plugin_manager ==# 'dein'
|
||||
let repo = dein#get(s:LIST.shift(s:plugins))
|
||||
elseif g:spacevim_plugin_manager ==# 'neobundle'
|
||||
@ -224,6 +225,8 @@ function! SpaceVim#plugins#manager#update(...) abort
|
||||
let s:start_time = reltime()
|
||||
for i in range(g:spacevim_plugin_manager_processes)
|
||||
if !empty(s:plugins)
|
||||
let repo = {}
|
||||
let reponame = ''
|
||||
if g:spacevim_plugin_manager ==# 'dein'
|
||||
let reponame = s:LIST.shift(s:plugins)
|
||||
let repo = dein#get(reponame)
|
||||
@ -236,7 +239,7 @@ function! SpaceVim#plugins#manager#update(...) abort
|
||||
elseif reponame ==# 'SpaceVim'
|
||||
let repo = {
|
||||
\ 'name' : 'SpaceVim',
|
||||
\ 'path' : fnamemodify(g:_spacevim_root_dir, ':h')
|
||||
\ 'path' : g:_spacevim_root_dir
|
||||
\ }
|
||||
call s:pull(repo)
|
||||
|
||||
@ -290,6 +293,7 @@ function! s:on_pull_exit(id, data, event) abort
|
||||
call remove(s:pulling_repos, string(id))
|
||||
if !empty(s:plugins)
|
||||
let name = s:LIST.shift(s:plugins)
|
||||
let repo = {}
|
||||
if name ==# 'SpaceVim'
|
||||
let repo = {
|
||||
\ 'name' : 'SpaceVim',
|
||||
@ -590,6 +594,7 @@ function! s:open_plugin_dir() abort
|
||||
enew
|
||||
exe 'resize ' . &lines * 30 / 100
|
||||
let shell = empty($SHELL) ? SpaceVim#api#import('system').isWindows ? 'cmd.exe' : 'bash' : $SHELL
|
||||
let path = ''
|
||||
if g:spacevim_plugin_manager ==# 'dein'
|
||||
let path = dein#get(keys(plugin)[0]).path
|
||||
elseif g:spacevim_plugin_manager ==# 'neobundle'
|
||||
|
@ -32,7 +32,7 @@ if !exists('Pmd_Cmd')
|
||||
endif
|
||||
|
||||
if !exists('Pmd_Rulesets')
|
||||
let g:Pmd_Rulesets = ["-R", "java-basic,java-design", "-property", "xsltFilename=my-own.xs"]
|
||||
let g:Pmd_Rulesets = ['-R', 'java-basic,java-design', '-property', 'xsltFilename=my-own.xs']
|
||||
endif
|
||||
|
||||
if !exists('Pmd_silent_stderr')
|
||||
@ -91,7 +91,7 @@ endfunction
|
||||
" @vimlint(EVL103, 0, a:data)
|
||||
" @vimlint(EVL103, 0, a:event)
|
||||
|
||||
function! SpaceVim#plugins#pmd#run(...)
|
||||
function! SpaceVim#plugins#pmd#run(...) abort
|
||||
let argv = g:Pmd_Cmd + a:000
|
||||
if index(a:000, '-R') == -1
|
||||
let argv += g:Pmd_Rulesets
|
||||
@ -112,13 +112,13 @@ function! SpaceVim#plugins#pmd#run(...)
|
||||
\ )
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#plugins#pmd#debug()
|
||||
function! SpaceVim#plugins#pmd#debug() abort
|
||||
call s:CMD.debug()
|
||||
call s:JOB.debug()
|
||||
endfunction
|
||||
|
||||
|
||||
function! SpaceVim#plugins#pmd#complete(ArgLead, CmdLine, CursorPos)
|
||||
function! SpaceVim#plugins#pmd#complete(ArgLead, CmdLine, CursorPos) abort
|
||||
return s:CMD.complete(a:ArgLead, a:CmdLine, a:CursorPos)
|
||||
endfunction
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user