From a97504f04e233ebc978b0ecd26a755a9b2ab15b8 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sat, 16 Dec 2017 20:50:31 +0800 Subject: [PATCH 01/14] Update elixir layer --- autoload/SpaceVim/layers/lang/elixir.vim | 28 +++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/autoload/SpaceVim/layers/lang/elixir.vim b/autoload/SpaceVim/layers/lang/elixir.vim index 91c6aceab..83ec9c1f2 100644 --- a/autoload/SpaceVim/layers/lang/elixir.vim +++ b/autoload/SpaceVim/layers/lang/elixir.vim @@ -8,7 +8,29 @@ " @section(layer-checkers) function! SpaceVim#layers#lang#elixir#plugins() abort - let plugins = [] - call add(plugins, ['slashmili/alchemist.vim', {'on_ft' : 'elixir'}]) - return plugins + let plugins = [] + call add(plugins, ['elixir-editors/vim-elixir', {'on_ft' : 'elixir'}]) + call add(plugins, ['slashmili/alchemist.vim', {'on_ft' : 'elixir'}]) + return plugins +endfunction + + +function! SpaceVim#layers#lang#elixir#config() + call SpaceVim#plugins#repl#reg('elixir', 'iex') + call SpaceVim#mapping#space#regesit_lang_mappings('elixir', funcref('s:language_specified_mappings')) +endfunction +function! s:language_specified_mappings() abort + let g:_spacevim_mappings_space.l.s = {'name' : '+Send'} + call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'i'], + \ 'call SpaceVim#plugins#repl#start("elixir")', + \ '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 From 03cd0e244501d3da587b56393bc020a9028061d2 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sat, 16 Dec 2017 21:35:55 +0800 Subject: [PATCH 02/14] Fix selection REPL --- autoload/SpaceVim/plugins/repl.vim | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/autoload/SpaceVim/plugins/repl.vim b/autoload/SpaceVim/plugins/repl.vim index a24121a2e..748891ee6 100644 --- a/autoload/SpaceVim/plugins/repl.vim +++ b/autoload/SpaceVim/plugins/repl.vim @@ -41,6 +41,15 @@ function! SpaceVim#plugins#repl#send(type) abort elseif a:type ==# 'buffer' call s:JOB.send(s:job_id, getline(1, '$') + ['']) elseif a:type ==# 'selection' + let begin = getpos("'<") + let end = getpos("'>") + if begin[1] != 0 && end[1] != 0 + call s:JOB.send(s:job_id, getline(begin[1], end[1]) + ['']) + else + echohl WarningMsg + echo 'no selection text' + echohl None + endif else endif endfunction From 6a38cb64a762e9124772ec87d96f0408b94b518e Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sun, 17 Dec 2017 00:06:51 +0800 Subject: [PATCH 03/14] Update py support --- .travis.yml | 1 + docs/development.md | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 69425fb04..99b0bdf47 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,6 +32,7 @@ jobs: - env: LINT=vint-errors VIM=nvim VIM_VERSION=v0.2.0 - env: LINT=vint VIM=nvim VIM_VERSION=v0.2.0 - env: LINT=vader + addons: { apt: { packages: [python2.7-dev] } } allow_failures: - env: LINT=vimlint VIM=nvim VIM_VERSION=v0.2.0 - env: LINT=vint VIM=nvim VIM_VERSION=v0.2.0 diff --git a/docs/development.md b/docs/development.md index 17b37f5aa..aa5416665 100644 --- a/docs/development.md +++ b/docs/development.md @@ -22,7 +22,6 @@ description: "Development information about SpaceVim, including contributing gui - [Contributor to an existing layer](#contributor-to-an-existing-layer) - [Contributing a keybinding](#contributing-a-keybinding) - [Contributing a banner](#contributing-a-banner) - - [Contributing a statusline theme](#contributing-a-statusline-theme) - [Build with SpaceVim](#build-with-spacevim) - [Changelog](#changelog) @@ -237,8 +236,6 @@ If you have some ASCII skills you can submit your artwork! You are free to choose a reasonable height size but the width size should be around 75 characters. -#### Contributing a statusline theme - ## Build with SpaceVim SpaceVim provide a lot of public [APIs](https://spacevim.org/apis), you can create plugins base on this APIs. also you can add a badge to the README.md of your plugin. From 65bca3ac6be6e9c04361b16bd0f352de4a340bdb Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sun, 17 Dec 2017 13:46:27 +0800 Subject: [PATCH 04/14] Fix test --- .ci/install.sh | 20 +++++++++----------- .ci/script.sh | 45 +++++++++++++++++++++++---------------------- 2 files changed, 32 insertions(+), 33 deletions(-) diff --git a/.ci/install.sh b/.ci/install.sh index 20d348345..a044a54d0 100755 --- a/.ci/install.sh +++ b/.ci/install.sh @@ -11,17 +11,15 @@ docker pull spacevim/vims git fetch origin dev:dev if [ "${LINT#vimlint}" != "$LINT" ]; then - git clone --depth=1 https://github.com/syngan/vim-vimlint /tmp/vimlint - git clone --depth=1 https://github.com/ynkdir/vim-vimlparser /tmp/vimlparser + git clone --depth=1 https://github.com/syngan/vim-vimlint /tmp/vimlint + git clone --depth=1 https://github.com/ynkdir/vim-vimlparser /tmp/vimlparser elif [ "${LINT#vint}" != "$LINT" ]; then - pip install vim-vint + pip install vim-vint elif [ "${LINT#vader}" != "$LINT" ]; then - git clone --depth=1 https://github.com/Shougo/dein.vim.git ~/.cache/vimfiles/repos/github.com/Shougo/dein.vim - if [ ! -f "$HOME/deps/bin/vim" ]; then - C_OPTS="--prefix=$DEPS --with-features=huge --disable-gui --enable-pythoninterp" - (git clone --depth 1 https://github.com/vim/vim /tmp/vim && - cd /tmp/vim && - ./configure $C_OPTS && - make install) - fi + git clone --depth=1 https://github.com/Shougo/dein.vim.git ~/.cache/vimfiles/repos/github.com/Shougo/dein.vim + C_OPTS="--prefix=$DEPS --with-features=huge --disable-gui --enable-pythoninterp --enable-python3interp --enable-rubyinterp" + (git clone --depth 1 https://github.com/vim/vim /tmp/vim && + cd /tmp/vim && + ./configure $C_OPTS && + make install) fi diff --git a/.ci/script.sh b/.ci/script.sh index bfc4ea4bb..4ae9e6e1d 100755 --- a/.ci/script.sh +++ b/.ci/script.sh @@ -2,31 +2,32 @@ set -ex if [ "$LINT" = "vimlint" ]; then - for file in $(git diff --name-only HEAD dev | grep .vim$); - do - sh /tmp/vimlint/bin/vimlint.sh -l /tmp/vimlint -p /tmp/vimlparser $file; - done + for file in $(git diff --name-only HEAD dev | grep .vim$); + do + sh /tmp/vimlint/bin/vimlint.sh -l /tmp/vimlint -p /tmp/vimlparser $file; + done elif [ "$LINT" = "vimlint-errors" ]; then - if [[ -f build_log ]]; then - rm build_log - fi - for file in $(git diff --name-only HEAD dev | grep .vim$); - do - /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser $file >> build_log 2>&1; - done - if [[ -s build_log ]]; then - cat build_log - exit 2 - fi + if [[ -f build_log ]]; then + rm build_log + fi + for file in $(git diff --name-only HEAD dev | grep .vim$); + do + /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser $file >> build_log 2>&1; + done + if [[ -s build_log ]]; then + cat build_log + exit 2 + fi elif [ "$LINT" = "vint" ]; then - vint . + vint . elif [ "$LINT" = "vint-errors" ]; then - vint --error . + vint --error . elif [ "$LINT" = "vader" ]; then - pip install covimerage - make test_coverage - covimerage -vv xml --omit 'build/*' - pip install codecov - codecov -X search gcov pycov -f coverage.xml + vim --version + pip install covimerage + make test_coverage + covimerage -vv xml --omit 'build/*' + pip install codecov + codecov -X search gcov pycov -f coverage.xml fi set +x From 2dd60c0c2837bb2ab53da08240a01027b5f60d64 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sun, 17 Dec 2017 13:53:10 +0800 Subject: [PATCH 05/14] Fixup --- .ci/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/install.sh b/.ci/install.sh index a044a54d0..6dbed876d 100755 --- a/.ci/install.sh +++ b/.ci/install.sh @@ -17,7 +17,7 @@ elif [ "${LINT#vint}" != "$LINT" ]; then pip install vim-vint elif [ "${LINT#vader}" != "$LINT" ]; then git clone --depth=1 https://github.com/Shougo/dein.vim.git ~/.cache/vimfiles/repos/github.com/Shougo/dein.vim - C_OPTS="--prefix=$DEPS --with-features=huge --disable-gui --enable-pythoninterp --enable-python3interp --enable-rubyinterp" + C_OPTS="--prefix=$DEPS --with-features=huge --disable-gui --enable-pythoninterp" (git clone --depth 1 https://github.com/vim/vim /tmp/vim && cd /tmp/vim && ./configure $C_OPTS && From bf1a1cc80e147072b2d49755f597be599ee7f080 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sun, 17 Dec 2017 14:11:57 +0800 Subject: [PATCH 06/14] Add Update doc --- docs/layers/lang/elixir.md | 56 ++++++++++++++++++++++++++++++++++++++ docs/layers/lang/ruby.md | 2 +- 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 docs/layers/lang/elixir.md diff --git a/docs/layers/lang/elixir.md b/docs/layers/lang/elixir.md new file mode 100644 index 000000000..a1ab65bff --- /dev/null +++ b/docs/layers/lang/elixir.md @@ -0,0 +1,56 @@ +--- +title: "SpaceVim lang#elixir layer" +description: "This layer is for elixir development, provide autocompletion, syntax checking, code format for elixir file." +--- + +# [SpaceVim Layers:](https://spacevim.org/layers) lang#elixir + + + +- [Description](#description) +- [Features](#features) +- [Install](#install) + - [Layer](#layer) +- [Key bindings](#key-bindings) + - [Inferior REPL process](#inferior-repl-process) + - [Running current script](#running-current-script) + + + +## Description + +This layer is for Elixir development. + +## Features + +This layer include the plugin [slashmili/alchemist.vim](https://github.com/slashmili/alchemist.vim), which provides: + +- Completion for Modules and functions. +- Documentation lookup for Modules and functions. +- Jump to the definition. + +SpaceVim also provides REPL/Debug support for elixir. + +## Install + +### Layer + +To use this configuration layer, add `SPLayer 'lang#elixir'` to your custom configuration file. + +## Key bindings + +### Inferior REPL process + +Start a `iex` inferior REPL process with `SPC l s i`. + +Send code to inferior process commands: + +| Key Binding | Description | +| ----------- | ------------------------------------------------ | +| `SPC l s b` | send buffer and keep code buffer focused | +| `SPC l s l` | send line and keep code buffer focused | +| `SPC l s s` | send selection text and keep code buffer focused | + +### Running current script + +To running current script, you can press `SPC l r` to run current file without loss focus, and the result will be shown in a runner buffer. diff --git a/docs/layers/lang/ruby.md b/docs/layers/lang/ruby.md index b888a2b1f..24500a357 100644 --- a/docs/layers/lang/ruby.md +++ b/docs/layers/lang/ruby.md @@ -59,4 +59,4 @@ Send code to inferior process commands: ### Running current script -To running a python script, you can press `SPC l r` to run current file without loss focus, and the result will be shown in a runner buffer. +To running a ruby script, you can press `SPC l r` to run current file without loss focus, and the result will be shown in a runner buffer. From 243fc98c6d91574bbcb066c028db8769074600da Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sun, 17 Dec 2017 16:23:47 +0800 Subject: [PATCH 07/14] Update Layer list --- .SpaceVim.d/autoload/SpaceVim/dev/layers.vim | 1 + docs/layers/index.md | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.SpaceVim.d/autoload/SpaceVim/dev/layers.vim b/.SpaceVim.d/autoload/SpaceVim/dev/layers.vim index 3e4a9ef0e..b2f408b54 100644 --- a/.SpaceVim.d/autoload/SpaceVim/dev/layers.vim +++ b/.SpaceVim.d/autoload/SpaceVim/dev/layers.vim @@ -29,6 +29,7 @@ function! s:layer_list() abort \ '| Name | Description |', \ '| ---------- | ------------ |' \ ] + call remove(layers, index(layers, '/home/wsdjeg/.SpaceVim/docs/layers/index.md')) for layer in layers let name = split(layer, '/docs/layers')[1][:-4] . '/' let url = 'https://spacevim.org/layers' . name diff --git a/docs/layers/index.md b/docs/layers/index.md index e71efc108..375ef63c7 100644 --- a/docs/layers/index.md +++ b/docs/layers/index.md @@ -28,10 +28,11 @@ call SpaceVim#layers#load('shell', | [checkers](https://spacevim.org/layers/checkers/) | This layer provides syntax checking feature | | [chinese](https://spacevim.org/layers/chinese/) | Layer for chinese users, include chinese docs and runtime messages | | [colorscheme](https://spacevim.org/layers/colorscheme/) | colorscheme provides a list of colorscheme for SpaceVim, default colorscheme is gruvbox with dark theme. | +| [debug](https://spacevim.org/layers/debug/) | This layer provide debug workflow support in SpaceVim | | [default](https://spacevim.org/layers/default/) | lt layer contains none plugins, but it has some better default config for vim and neovim | | [git](https://spacevim.org/layers/git/) | This layers adds extensive support for git | -| [index](https://spacevim.org/layers/index/) | list of available layers in SpaceVim | | [lang#c](https://spacevim.org/layers/lang/c/) | This layer is for c/c++/object-c development | +| [lang#elixir](https://spacevim.org/layers/lang/elixir/) | This layer is for elixir development, provide autocompletion, syntax checking, code format for elixir file. | | [lang#java](https://spacevim.org/layers/lang/java/) | This layer is for Java development | | [lang#javascript](https://spacevim.org/layers/lang/javascript/) | This layer is for JaveScript development | | [lang#lisp](https://spacevim.org/layers/lang/lisp/) | for lisp development | From a5f349096f54146ab5cc3d1b13d0396c8471b55c Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sun, 17 Dec 2017 20:36:58 +0800 Subject: [PATCH 08/14] Fix shell config --- autoload/SpaceVim/layers/core.vim | 3 +++ autoload/SpaceVim/layers/unite.vim | 17 ++++++++++++++++- autoload/SpaceVim/plugins/projectmanager.vim | 8 ++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/autoload/SpaceVim/layers/core.vim b/autoload/SpaceVim/layers/core.vim index 895da6868..ea20c0888 100644 --- a/autoload/SpaceVim/layers/core.vim +++ b/autoload/SpaceVim/layers/core.vim @@ -44,6 +44,9 @@ function! SpaceVim#layers#core#config() abort call SpaceVim#mapping#space#def('nnoremap', ['q', 'r'], '', 'restart-vim-resume-layouts(TODO)', 1) call SpaceVim#mapping#space#def('nnoremap', ['q', 't'], 'tabclose!', 'kill current tab', 1) call SpaceVim#mapping#gd#add('HelpDescribe', function('s:gotodef')) + " project manager + call SpaceVim#mapping#space#def('nnoremap', ['p', '!'], 'Grepper', 'fuzzy search for text in current project', 1) + endfunction function! s:gotodef() abort diff --git a/autoload/SpaceVim/layers/unite.vim b/autoload/SpaceVim/layers/unite.vim index a48f1905b..ea4a6bf80 100644 --- a/autoload/SpaceVim/layers/unite.vim +++ b/autoload/SpaceVim/layers/unite.vim @@ -82,7 +82,10 @@ endfunction function! SpaceVim#layers#unite#config() abort call SpaceVim#mapping#space#def('nnoremap', ['!'], 'call call(' \ . string(s:_function('s:run_shell_cmd')) . ', [])', - \ 'shell cmd', 1) + \ 'shell cmd(current dir)', 1) + call SpaceVim#mapping#space#def('nnoremap', ['p', '!'], 'call call(' + \ . string(s:_function('s:run_shell_cmd_project')) . ', [])', + \ 'shell cmd(project root)', 1) endfunction function! s:run_shell_cmd() abort @@ -92,6 +95,18 @@ function! s:run_shell_cmd() abort endif endfunction +function! s:run_shell_cmd_project() abort + let cmd = input('Please input shell command:', '', 'customlist,SpaceVim#plugins#bashcomplete#complete') + if !empty(cmd) + call unite#start([['output/shellcmd', cmd]], { + \ 'log': 1, + \ 'wrap': 1, + \ 'start_insert':0, + \ 'cwd' : SpaceVim#plugins#projectmanager#current_root(), + \ }) + endif +endfunction + " function() wrapper if v:version > 703 || v:version == 703 && has('patch1170') function! s:_function(fstr) abort diff --git a/autoload/SpaceVim/plugins/projectmanager.vim b/autoload/SpaceVim/plugins/projectmanager.vim index c64d6347d..ac57e95e2 100644 --- a/autoload/SpaceVim/plugins/projectmanager.vim +++ b/autoload/SpaceVim/plugins/projectmanager.vim @@ -32,6 +32,14 @@ function! SpaceVim#plugins#projectmanager#current_() return get(b:, '_spacevim_project_name', '') endfunction +function! SpaceVim#plugins#projectmanager#current_root() abort + try + Rooter + catch + endtry + return getcwd() +endfunction + let s:BUFFER = SpaceVim#api#import('vim#buffer') function! SpaceVim#plugins#projectmanager#kill_project() abort From 7468d6ec1263373789c5a469a2b9e7617eb6dfce Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sun, 17 Dec 2017 21:14:50 +0800 Subject: [PATCH 09/14] Auto set project name --- autoload/SpaceVim/autocmds.vim | 2 ++ autoload/SpaceVim/plugins/projectmanager.vim | 13 ++++++++++++- config/main.vim | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/autoload/SpaceVim/autocmds.vim b/autoload/SpaceVim/autocmds.vim index 5280ec28c..ece117d17 100644 --- a/autoload/SpaceVim/autocmds.vim +++ b/autoload/SpaceVim/autocmds.vim @@ -79,6 +79,8 @@ function! SpaceVim#autocmds#init() abort autocmd BufWritePost *.vim call s:generate_doc() autocmd ColorScheme gruvbox call s:fix_gruvbox() autocmd VimEnter * call SpaceVim#autocmds#VimEnter() + autocmd User RooterChDir call SpaceVim#plugins#projectmanager#RootchandgeCallback() + autocmd BufEnter * let b:_spacevim_project_name = get(g:, '_spacevim_project_name', '') augroup END endfunction diff --git a/autoload/SpaceVim/plugins/projectmanager.vim b/autoload/SpaceVim/plugins/projectmanager.vim index ac57e95e2..bf22bdc84 100644 --- a/autoload/SpaceVim/plugins/projectmanager.vim +++ b/autoload/SpaceVim/plugins/projectmanager.vim @@ -28,10 +28,21 @@ function! SpaceVim#plugins#projectmanager#list() abort endfunction -function! SpaceVim#plugins#projectmanager#current_() +function! SpaceVim#plugins#projectmanager#current_name() abort return get(b:, '_spacevim_project_name', '') endfunction +function! SpaceVim#plugins#projectmanager#RootchandgeCallback() abort + + let project = { + \ 'path' : getcwd(), + \ 'name' : fnamemodify(getcwd(), ':t') + \ } + call s:cache_project(project) + let g:_spacevim_project_name = project.name + let b:_spacevim_project_name = g:_spacevim_project_name +endfunction + function! SpaceVim#plugins#projectmanager#current_root() abort try Rooter diff --git a/config/main.vim b/config/main.vim index 32acd58bd..9e4e4b670 100644 --- a/config/main.vim +++ b/config/main.vim @@ -31,6 +31,7 @@ function! s:parser_argv() abort endif endfunction let s:status = s:parser_argv() +call SpaceVim#plugins#projectmanager#RootchandgeCallback() if s:status[0] let g:_spacevim_enter_dir = s:status[1] augroup SPwelcome From 34a8e229360543b49736ae27522d3e9c43c28f6f Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sun, 17 Dec 2017 21:18:24 +0800 Subject: [PATCH 10/14] Fix SPC p k --- autoload/SpaceVim/plugins/projectmanager.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/SpaceVim/plugins/projectmanager.vim b/autoload/SpaceVim/plugins/projectmanager.vim index bf22bdc84..279a15817 100644 --- a/autoload/SpaceVim/plugins/projectmanager.vim +++ b/autoload/SpaceVim/plugins/projectmanager.vim @@ -61,7 +61,7 @@ function! SpaceVim#plugins#projectmanager#kill_project() abort \ 'expr' : [ \ 'buflisted(v:val)', \ 'index(tabpagebuflist(), v:val) == -1', - \ 'getbufvar(v:val, "_spacevim_project_name") == ' . name, + \ 'getbufvar(v:val, "_spacevim_project_name") == "' . name . '"', \ ], \ 'do' : 'bd %d' \ } From ea732fae96d55764c8826e951ab8151e35ccd7fe Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sun, 17 Dec 2017 21:22:53 +0800 Subject: [PATCH 11/14] Kill all buffers --- autoload/SpaceVim/plugins/projectmanager.vim | 1 - docs/documentation.md | 12 ++++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/autoload/SpaceVim/plugins/projectmanager.vim b/autoload/SpaceVim/plugins/projectmanager.vim index 279a15817..e2bf3d464 100644 --- a/autoload/SpaceVim/plugins/projectmanager.vim +++ b/autoload/SpaceVim/plugins/projectmanager.vim @@ -60,7 +60,6 @@ function! SpaceVim#plugins#projectmanager#kill_project() abort \ { \ 'expr' : [ \ 'buflisted(v:val)', - \ 'index(tabpagebuflist(), v:val) == -1', \ 'getbufvar(v:val, "_spacevim_project_name") == "' . name . '"', \ ], \ 'do' : 'bd %d' diff --git a/docs/documentation.md b/docs/documentation.md index f10205d42..4402721d4 100644 --- a/docs/documentation.md +++ b/docs/documentation.md @@ -1422,12 +1422,12 @@ project manager commands start with `p`: #### Searching files in project -| Key Binding | Description | -| ----------- | ----------------------------------------------------- | -| `SPC p f` | find files in current project | -| `SPC p /` | fuzzy search for text in current project | -| `SPC p k` | kill all project buffers | -| `SPC p t` | find project root | +| Key Binding | Description | +| ----------- | ---------------------------------------- | +| `SPC p f` | find files in current project | +| `SPC p /` | fuzzy search for text in current project | +| `SPC p k` | kill all buffers of current project | +| `SPC p t` | find project root | ## EditorConfig From 861914d3396608a0cbd3a467b7e048f4cf8f486c Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sun, 17 Dec 2017 21:57:02 +0800 Subject: [PATCH 12/14] Add key bindings for list projects --- autoload/SpaceVim/layers/core.vim | 1 + autoload/SpaceVim/plugins/projectmanager.vim | 48 +++++++++++++------- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/autoload/SpaceVim/layers/core.vim b/autoload/SpaceVim/layers/core.vim index ea20c0888..f7d0bbb04 100644 --- a/autoload/SpaceVim/layers/core.vim +++ b/autoload/SpaceVim/layers/core.vim @@ -16,6 +16,7 @@ function! SpaceVim#layers#core#config() abort call SpaceVim#layers#load('core#tabline') call SpaceVim#mapping#space#def('nnoremap', ['p', 't'], 'Rooter', 'find-project-root', 1) call SpaceVim#mapping#space#def('nnoremap', ['p', 'k'], 'call SpaceVim#plugins#projectmanager#kill_project()', 'kill all project buffers', 1) + call SpaceVim#mapping#space#def('nnoremap', ['p', 'p'], 'call SpaceVim#plugins#projectmanager#list()', 'List all projects', 1) let lnum = expand('') + s:lnum - 1 if has('python3') let cmd = 'Denite file_rec' diff --git a/autoload/SpaceVim/plugins/projectmanager.vim b/autoload/SpaceVim/plugins/projectmanager.vim index e2bf3d464..a4b07952c 100644 --- a/autoload/SpaceVim/plugins/projectmanager.vim +++ b/autoload/SpaceVim/plugins/projectmanager.vim @@ -18,18 +18,34 @@ let s:project_paths = {} function! s:cache_project(prj) abort - if !has_key(s:project_paths, a:prj.path) - let s:project_paths[a:prj.path] = a:prj - endif + if !has_key(s:project_paths, a:prj.path) + let s:project_paths[a:prj.path] = a:prj + let desc = '[' . a:prj.name . '] ' . a:prj.path + let cmd = 'call SpaceVim#plugins#projectmanager#open("' . a:prj.path . '")' + call add(g:unite_source_menu_menus.Projects.command_candidates, [desc,cmd]) + endif endfunction +let g:unite_source_menu_menus = + \ get(g:,'unite_source_menu_menus',{}) +let g:unite_source_menu_menus.Projects = {'description': + \ 'Custom mapped keyboard shortcuts [SPC] p p'} +let g:unite_source_menu_menus.Projects.command_candidates = + \ get(g:unite_source_menu_menus.Projects,'command_candidates', []) function! SpaceVim#plugins#projectmanager#list() abort + Unite menu:Projects +endfunction +function! SpaceVim#plugins#projectmanager#open(project) abort + let path = s:project_paths[a:project]['path'] + tabnew + exe 'lcd ' . path + Startify | VimFiler endfunction function! SpaceVim#plugins#projectmanager#current_name() abort - return get(b:, '_spacevim_project_name', '') + return get(b:, '_spacevim_project_name', '') endfunction function! SpaceVim#plugins#projectmanager#RootchandgeCallback() abort @@ -54,18 +70,18 @@ endfunction let s:BUFFER = SpaceVim#api#import('vim#buffer') function! SpaceVim#plugins#projectmanager#kill_project() abort - let name = get(b:, '_spacevim_project_name', '') - if name != '' - call s:BUFFER.filter_do( - \ { - \ 'expr' : [ - \ 'buflisted(v:val)', - \ 'getbufvar(v:val, "_spacevim_project_name") == "' . name . '"', - \ ], - \ 'do' : 'bd %d' - \ } - \ ) - endif + let name = get(b:, '_spacevim_project_name', '') + if name != '' + call s:BUFFER.filter_do( + \ { + \ 'expr' : [ + \ 'buflisted(v:val)', + \ 'getbufvar(v:val, "_spacevim_project_name") == "' . name . '"', + \ ], + \ 'do' : 'bd %d' + \ } + \ ) + endif endfunction From ca96a936d5ae4c8ce26ac03a43c2e7392edc49e5 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sun, 17 Dec 2017 21:58:21 +0800 Subject: [PATCH 13/14] Update doc --- docs/documentation.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/documentation.md b/docs/documentation.md index 4402721d4..f1dd22926 100644 --- a/docs/documentation.md +++ b/docs/documentation.md @@ -1428,6 +1428,7 @@ project manager commands start with `p`: | `SPC p /` | fuzzy search for text in current project | | `SPC p k` | kill all buffers of current project | | `SPC p t` | find project root | +| `SPC p p` | list all projects | ## EditorConfig From 87b6cdb0605bbd31481c63b294af9719870c3fcd Mon Sep 17 00:00:00 2001 From: ws198601 Date: Sun, 17 Dec 2017 22:25:46 +0800 Subject: [PATCH 14/14] Update init.vim MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在fencs中支持gbk字符集,放在utf-8之后 --- config/init.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/init.vim b/config/init.vim index 92c25ffdf..b6381985d 100644 --- a/config/init.vim +++ b/config/init.vim @@ -52,7 +52,7 @@ if WINDOWS() " fallback into cp1252 instead of eg. iso-8859-15. " Newer Windows files might contain utf-8 or utf-16 LE so we might " want to try them first. - set fileencodings=ucs-bom,utf-8,utf-16le,cp1252,iso-8859-15 + set fileencodings=ucs-bom,utf-8,gbk,utf-16le,cp1252,iso-8859-15 endif else