mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-04-14 15:19:12 +08:00
feat(checkers): fix checkers layer option
This commit is contained in:
parent
9caa00b009
commit
14d9225346
@ -1112,6 +1112,8 @@ let g:spacevim_enable_powerline_fonts = 1
|
||||
" >
|
||||
" let g:spacevim_lint_on_save = 0
|
||||
" <
|
||||
" NOTE: the `lint_on_save` option has been deprecated. Please use layer option
|
||||
" of @section(layers-checkers) layer.
|
||||
let g:spacevim_lint_on_save = 1
|
||||
""
|
||||
" @section search_tools, options-search_tools
|
||||
@ -1248,6 +1250,8 @@ let g:spacevim_todo_prefix = '@'
|
||||
" >
|
||||
" lint_on_the_fly = false
|
||||
" <
|
||||
" NOTE: the `lint_on_the_fly` option has been deprecated. Please use layer option
|
||||
" of @section(layers-checkers) layer.
|
||||
|
||||
""
|
||||
" Enable/Disable lint on the fly feature of SpaceVim's maker. Default is 0.
|
||||
|
@ -36,6 +36,8 @@ else
|
||||
endif
|
||||
|
||||
let s:lint_exclude_filetype = []
|
||||
let s:lint_on_the_fly = 0
|
||||
let s:lint_on_save = 1
|
||||
|
||||
let s:SIG = SpaceVim#api#import('vim#signatures')
|
||||
let s:STRING = SpaceVim#api#import('data#string')
|
||||
@ -62,7 +64,8 @@ endfunction
|
||||
function! SpaceVim#layers#checkers#set_variable(var) abort
|
||||
|
||||
let s:show_cursor_error = get(a:var, 'show_cursor_error', 1)
|
||||
let s:lint_on_the_fly = get(a:var, 'lint_on_the_fly', 1)
|
||||
let s:lint_on_the_fly = get(a:var, 'lint_on_the_fly', 0)
|
||||
let s:lint_on_save = get(a:var, 'lint_on_save', 1)
|
||||
let s:lint_exclude_filetype = get(a:var, 'lint_exclude_filetype', [])
|
||||
|
||||
if s:show_cursor_error && !has('timers')
|
||||
@ -77,6 +80,15 @@ function! SpaceVim#layers#checkers#get_options() abort
|
||||
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#checkers#get_lint_option() abort
|
||||
|
||||
return {
|
||||
\ 'lint_on_the_fly' : s:lint_on_the_fly,
|
||||
\ 'lint_on_save' : s:lint_on_save,
|
||||
\ }
|
||||
|
||||
endfunction
|
||||
|
||||
|
||||
function! SpaceVim#layers#checkers#config() abort
|
||||
" neomake config
|
||||
@ -90,6 +102,7 @@ function! SpaceVim#layers#checkers#config() abort
|
||||
let g:neomake_{ft}_enabled_makers = []
|
||||
endfor
|
||||
|
||||
|
||||
elseif g:spacevim_lint_engine ==# 'ale'
|
||||
let g:ale_echo_delay = get(g:, 'ale_echo_delay', 300)
|
||||
endif
|
||||
|
@ -1,21 +1,21 @@
|
||||
scriptencoding utf-8
|
||||
" 1 open list and move cursor 2 open list without move cursor
|
||||
|
||||
let s:lint_option = SpaceVim#layers#checkers#get_lint_option()
|
||||
let s:neomake_automake_events = {}
|
||||
if get(g:, 'spacevim_lint_on_save', 0)
|
||||
let s:neomake_automake_events['BufWritePost'] = {'delay': 0}
|
||||
if s:lint_option.lint_on_the_fly
|
||||
let s:neomake_automake_events['TextChanged'] = {'delay': 750}
|
||||
let s:neomake_automake_events['TextChangedI'] = {'delay': 750}
|
||||
endif
|
||||
|
||||
if get(g:, 'spacevim_lint_on_the_fly', 0)
|
||||
let s:neomake_automake_events['TextChanged'] = {'delay': 750}
|
||||
let s:neomake_automake_events['TextChangedI'] = {'delay': 750}
|
||||
if s:lint_option.lint_on_save
|
||||
let s:neomake_automake_events['BufWritePost'] = {'delay': 0}
|
||||
endif
|
||||
|
||||
if !empty(s:neomake_automake_events)
|
||||
try
|
||||
call neomake#configure#automake(s:neomake_automake_events)
|
||||
catch /^Vim\%((\a\+)\)\=:E117/
|
||||
endtry
|
||||
endif
|
||||
" 1 open list and move cursor 2 open list without move cursor
|
||||
let g:neomake_open_list = get(g:, 'neomake_open_list', 2)
|
||||
let g:neomake_verbose = get(g:, 'neomake_verbose', 0)
|
||||
let g:neomake_java_javac_delete_output = get(g:, 'neomake_java_javac_delete_output', 0)
|
||||
|
@ -3,16 +3,17 @@ let g:ale_sign_error = get(g:, 'spacevim_error_symbol', '✖')
|
||||
let g:ale_sign_warning = get(g:,'spacevim_warning_symbol', '➤')
|
||||
let g:ale_sign_info = get(g:,'spacevim_info_symbol', '🛈')
|
||||
let g:ale_echo_msg_format = get(g:, 'ale_echo_msg_format', '%severity%: %linter%: %s')
|
||||
let g:ale_lint_on_save = get(g:, 'spacevim_lint_on_save', 1)
|
||||
|
||||
if get(g:, 'spacevim_colorscheme', '') ==# 'gruvbox'
|
||||
highlight link ALEErrorSign GruvboxRedSign
|
||||
highlight link ALEWarningSign GruvboxYellowSign
|
||||
endif
|
||||
|
||||
if get(g:, 'spacevim_lint_on_the_fly', 0)
|
||||
let s:lint_option = SpaceVim#layers#checkers#get_lint_option()
|
||||
if s:lint_option.lint_on_the_fly
|
||||
let g:ale_lint_on_text_changed = 'always'
|
||||
let g:ale_lint_delay = 750
|
||||
else
|
||||
let g:ale_lint_on_text_changed = 'never'
|
||||
endif
|
||||
let g:ale_lint_on_save = s:lint_option.lint_on_save
|
||||
|
@ -656,6 +656,8 @@ Enable/Disable lint on the fly feature of SpaceVim's maker. Default is true.
|
||||
>
|
||||
lint_on_the_fly = false
|
||||
<
|
||||
NOTE: the `lint_on_the_fly` option has been deprecated. Please use layer
|
||||
option of |SpaceVim-layers-checkers| layer.
|
||||
|
||||
==============================================================================
|
||||
MAX_COLUMN *SpaceVim-options-max_column*
|
||||
@ -1422,6 +1424,8 @@ Enable/Disable lint on save feature of SpaceVim's maker. Default is 1.
|
||||
>
|
||||
let g:spacevim_lint_on_save = 0
|
||||
<
|
||||
NOTE: the `lint_on_save` option has been deprecated. Please use layer option
|
||||
of |SpaceVim-layers-checkers| layer.
|
||||
|
||||
*g:spacevim_search_tools*
|
||||
Default search tools supported by flygrep. The default order is ['rg', 'ag',
|
||||
|
@ -31,8 +31,30 @@ lang: zh
|
||||
|
||||
## 模块配置
|
||||
|
||||
默认会在光标的下一行显示当前行错误的详细信息,如果需要禁用这一特性,可以在载入模块
|
||||
时指定 `show_cursor_error` 的值为 false。
|
||||
`checkers` 模块默认已经加载了,与该模块相关的选项有两种,一个是全局选项,一个是模块选项:
|
||||
|
||||
**全局选项:**
|
||||
|
||||
所有的 SpaceVim 全局选项需要写在`[options]`下方:
|
||||
|
||||
| 选项名称 | 默认值 | 功能描述 |
|
||||
| ------------- | --------- | ---------------------- |
|
||||
| `lint_engine` | `neomake` | 设置默认的语法检查插件 |
|
||||
|
||||
默认的语法检查插件是 `neomake`,你也可以设置成 `ale` 或者 `syntastic`。
|
||||
|
||||
如果需要设置 neomake 选项,需要使用启动函数。在启动函数里面可以使用 vim 脚本。具体如何配置 neomake 可以阅读`:h neomake`。
|
||||
|
||||
**模块选项:**
|
||||
|
||||
默认情况下,语法错误将在当前行下方展示,如果需要禁用这个功能,可以将`show_cursor_error`模块选项设置成`false`。
|
||||
|
||||
| 选项名称 | 默认值 | 功能描述 |
|
||||
| ----------------------- | ------- | ---------------------------------------- |
|
||||
| `lint_on_the_fly` | `false` | 设置语法实时检查,默认已禁用 |
|
||||
| `lint_on_save` | `true` | 设置保存文件时进行语法检查,默认已启用 |
|
||||
| `show_cursor_error` | `true` | 设置在当前行下方展示语法错误,默认已启用 |
|
||||
| `lint_exclude_filetype` | `[]` | 设置禁用语法检查的文件类型列表 |
|
||||
|
||||
```toml
|
||||
[[layers]]
|
||||
@ -40,28 +62,6 @@ lang: zh
|
||||
show_cursor_error = false
|
||||
```
|
||||
|
||||
SpaceVim 选项:
|
||||
|
||||
| 选项名称 | 默认值 | 描述 |
|
||||
| ----------------- | ------ | ----------------------------------- |
|
||||
| `enable_neomake` | true | 使用 [neomake](https://github.com/neomake/neomake) 作为默认的语法检查插件 |
|
||||
| `enable_ale` | false | 使用 Ale 作为默认语法检查插件 |
|
||||
| `lint_on_the_fly` | false | 启用实时语法检查 |
|
||||
|
||||
Neomake 的设置需要使用启动函数,在启动函数里,可以使用 Vim 脚本,
|
||||
关于 neomake 所有的配置相关信息,可以查阅 `:h neomake`。
|
||||
|
||||
|
||||
**NOTE:** 如果你需要使用 Ale 作为默认检查工具,SpaceVim 选项需要加入:
|
||||
|
||||
```toml
|
||||
[options]
|
||||
enable_neomake = false
|
||||
enable_ale = true
|
||||
```
|
||||
|
||||
如果需要使用 syntastic,将两者都设置为 false。
|
||||
|
||||
## 快捷键
|
||||
|
||||
| 快捷键 | 功能描述 |
|
||||
|
Loading…
x
Reference in New Issue
Block a user