From a14ef641496a69532bf39a92ce1a2248b608eb71 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Mon, 15 May 2017 23:22:54 +0800 Subject: [PATCH] Improve checker layer doc --- autoload/SpaceVim/layers/checkers.vim | 3 +++ autoload/SpaceVim/layers/ui.vim | 9 ++++++++- config/plugins_before/neomake.vim | 15 ++++++++++----- docs/documentation.md | 23 +++++++++++++++++++++++ 4 files changed, 44 insertions(+), 6 deletions(-) diff --git a/autoload/SpaceVim/layers/checkers.vim b/autoload/SpaceVim/layers/checkers.vim index fac722a6c..319d49571 100644 --- a/autoload/SpaceVim/layers/checkers.vim +++ b/autoload/SpaceVim/layers/checkers.vim @@ -18,6 +18,9 @@ endfunction function! SpaceVim#layers#checkers#config() abort call SpaceVim#mapping#space#def('nnoremap', ['e', '.'], 'lopen', 'error-transient-state', 1) + call SpaceVim#mapping#space#def('nnoremap', ['e', 'c'], '', 'clear all errors', 1) + call SpaceVim#mapping#space#def('nnoremap', ['e', 'h'], '', 'describe a syntax checker', 1) + call SpaceVim#mapping#space#def('nnoremap', ['e', 'v'], '', 'verify syntax checker setup', 1) call SpaceVim#mapping#space#def('nnoremap', ['e', 'n'], 'lnext', 'next-error', 1) call SpaceVim#mapping#space#def('nnoremap', ['e', 'l'], 'lopen', 'toggle showing the error list', 1) call SpaceVim#mapping#space#def('nnoremap', ['e', 'p'], 'lprevious', 'previous-error', 1) diff --git a/autoload/SpaceVim/layers/ui.vim b/autoload/SpaceVim/layers/ui.vim index 66b434d26..3f8955c61 100644 --- a/autoload/SpaceVim/layers/ui.vim +++ b/autoload/SpaceVim/layers/ui.vim @@ -59,6 +59,9 @@ function! SpaceVim#layers#ui#config() abort call SpaceVim#mapping#space#def('nnoremap', ['T', '~'], 'call call(' \ . string(s:_function('s:toggle_end_of_buffer')) . ', [])', \ 'display ~ in the fringe on empty lines', 1) + call SpaceVim#mapping#space#def('nnoremap', ['t', 's'], 'call call(' + \ . string(s:_function('s:toggle_syntax_checker')) . ', [])', + \ 'toggle syntax checker', 1) endfunction " function() wrapper if v:version > 703 || v:version == 703 && has('patch1170') @@ -110,7 +113,7 @@ endfunction let s:fcflag = 0 function! s:toggle_fill_column() abort if !s:fcflag - let &colorcolumn=join(range(80,999),",") + let &colorcolumn=join(range(80,999),',') let s:fcflag = 1 else set cc= @@ -173,3 +176,7 @@ function! s:toggle_win_fringe() abort let s:tfflag = 0 endif endfunction + +function! s:toggle_syntax_checker() abort + let g:_spacevim_toggle_syntax_flag = g:_spacevim_toggle_syntax_flag * -1 +endfunction diff --git a/config/plugins_before/neomake.vim b/config/plugins_before/neomake.vim index bf3510dac..b22a526b8 100644 --- a/config/plugins_before/neomake.vim +++ b/config/plugins_before/neomake.vim @@ -1,18 +1,23 @@ if get(g:, 'spacevim_lint_on_save', 0) augroup Neomake_on_save au! - autocmd! BufWritePost * Neomake + autocmd! BufWritePost * call s:neomake() augroup END endif -if empty(maparg('ck', '',0,1)) - nnoremap ck :Neomake -endif + +let g:_spacevim_toggle_syntax_flag = 1 + +function! s:neomake() abort + if g:_spacevim_toggle_syntax_flag == 1 + Neomake + endif +endfunction if get(g:, 'spacevim_lint_on_the_fly', 0) let g:neomake_tempfile_enabled = 1 let g:neomake_open_list = 0 augroup Neomake_on_the_fly au! - autocmd! TextChangedI * Neomake + autocmd! TextChangedI * call s:neomake() augroup END endif diff --git a/docs/documentation.md b/docs/documentation.md index dc4e958b8..5b8528d64 100644 --- a/docs/documentation.md +++ b/docs/documentation.md @@ -48,6 +48,7 @@ title: "Documentation" * [Searching](#searching) * [Editing](#editing) * [Multi-Encodings](#multi-encodings) + * [Errors handling](#errors-handling) * [Features](#features) * [Awesome ui](#awesome-ui-1) * [Mnemonic key bindings](#mnemonic-key-bindings) @@ -461,9 +462,31 @@ set enc=utf-8 write ``` +### Errors handling +SpaceVim uses [neomake](https://github.com/neomake/neomake) to gives error feedback on the fly. The checks are only performed at save time by default. +Errors management mappings (start with e): +Mappings | Description +-------- | ----------- +`SPC t s` | toggle syntax checker +`SPC e c` | clear all errors +`SPC e h` | describe a syntax checker +`SPC e l` | toggle the display of the list of errors/warnings +`SPC e n` | go to the next error +`SPC e p` | go to the previous error +`SPC e v` | verify syntax checker setup (useful to debug 3rd party tools configuration) +`SPC e .` | error transient state + +The next/previous error mappings and the error transient state can be used to browse errors from syntax checkers as well as errors from location list buffers, and indeed anything that supports vim's location list. This includes for example search results that have been saved to a location list buffer. + +Custom sign symbol: + +Symbol | Description | Custom option +------ | ----------- | ------------- +`✖` | Error | `g:spacevim_error_symbol` +`➤` | warning | `g:spacevim_warning_symbol` ## Features