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/.ci/install.sh b/.ci/install.sh index 20d348345..6dbed876d 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" + (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 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/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/layers/core.vim b/autoload/SpaceVim/layers/core.vim index 895da6868..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' @@ -44,6 +45,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/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 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..a4b07952c 100644 --- a/autoload/SpaceVim/plugins/projectmanager.vim +++ b/autoload/SpaceVim/plugins/projectmanager.vim @@ -18,36 +18,70 @@ 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#current_() - return get(b:, '_spacevim_project_name', '') +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', '') +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 + catch + endtry + return getcwd() 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)', - \ 'index(tabpagebuflist(), v:val) == -1', - \ '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 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 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 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 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. diff --git a/docs/documentation.md b/docs/documentation.md index f10205d42..f1dd22926 100644 --- a/docs/documentation.md +++ b/docs/documentation.md @@ -1422,12 +1422,13 @@ 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 | +| `SPC p p` | list all projects | ## EditorConfig 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 | 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.