-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make a series of sweeping changes to make :ALEInfo more useful. 1. Deprecate :ALEInfoToClipboard and support :ALEInfo -clipboard 2. Permit :ALEInfo -clip as a shorthand for :ALEInfo -clipboard 3. Support :ALEInfo -preview to render in the preview window 4. Support :ALEInfo -echo for the classic :ALEInfo mode 5. Change the default mode to 'preview', and make it configurable 6. Add syntax highlighting for ALEInfo in preview mode 7. Add a convenience to look up documentatation that explains itself 8. Don't show an empty 'Linter Variables' section
- Loading branch information
Showing
9 changed files
with
225 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
" Author: w0rp <[email protected]> | ||
" Description: This file implements debugging information for ALE | ||
|
||
let g:ale_info_default_mode = get(g:, 'ale_info_default_mode', 'preview') | ||
|
||
let s:global_variable_list = [ | ||
\ 'ale_cache_executable_check_failures', | ||
\ 'ale_change_sign_column_color', | ||
|
@@ -18,6 +20,7 @@ let s:global_variable_list = [ | |
\ 'ale_fix_on_save', | ||
\ 'ale_fixers', | ||
\ 'ale_history_enabled', | ||
\ 'ale_info_default_mode', | ||
\ 'ale_history_log_output', | ||
\ 'ale_keep_list_window_open', | ||
\ 'ale_lint_delay', | ||
|
@@ -199,7 +202,10 @@ function! s:EchoLSPErrorMessages(all_linter_names) abort | |
endfor | ||
endfunction | ||
|
||
function! ale#debugging#Info() abort | ||
function! ale#debugging#Info(...) abort | ||
let l:options = (a:0 > 0) ? a:1 : {} | ||
let l:show_preview_info = get(l:options, 'preview') | ||
|
||
let l:buffer = bufnr('') | ||
let l:filetype = &filetype | ||
|
||
|
@@ -241,13 +247,31 @@ function! ale#debugging#Info() abort | |
call s:EchoLinterAliases(l:all_linters) | ||
call s:Echo(' Enabled Linters: ' . string(l:enabled_names)) | ||
call s:Echo(' Ignored Linters: ' . string(l:ignored_names)) | ||
call s:Echo(' Suggested Fixers: ' . l:fixers_string) | ||
call s:Echo(' Linter Variables:') | ||
call s:Echo('') | ||
call s:EchoLinterVariables(l:variable_list) | ||
call s:Echo(' Suggested Fixers:' . l:fixers_string) | ||
" We use this line with only a space to know where to end highlights. | ||
call s:Echo(' ') | ||
|
||
" Only show Linter Variables directive if there are any. | ||
if !empty(l:variable_list) | ||
call s:Echo(' Linter Variables:') | ||
|
||
if l:show_preview_info | ||
call s:Echo('" Press Space to read :help for a setting') | ||
endif | ||
|
||
call s:EchoLinterVariables(l:variable_list) | ||
" We use this line with only a space to know where to end highlights. | ||
call s:Echo(' ') | ||
endif | ||
|
||
call s:Echo(' Global Variables:') | ||
call s:Echo('') | ||
|
||
if l:show_preview_info | ||
call s:Echo('" Press Space to read :help for a setting') | ||
endif | ||
|
||
call s:EchoGlobalVariables() | ||
call s:Echo(' ') | ||
call s:EchoLSPErrorMessages(l:all_names) | ||
call s:Echo(' Command History:') | ||
call s:Echo('') | ||
|
@@ -275,3 +299,41 @@ function! ale#debugging#InfoToFile(filename) abort | |
call writefile(split(l:output, "\n"), l:expanded_filename) | ||
call s:Echo('ALEInfo written to ' . l:expanded_filename) | ||
endfunction | ||
|
||
function! ale#debugging#InfoToPreview() abort | ||
let l:output = execute('call ale#debugging#Info({''preview'': 1})') | ||
|
||
call ale#preview#Show(split(l:output, "\n"), { | ||
\ 'filetype': 'ale-info', | ||
\}) | ||
endfunction | ||
|
||
function! ale#debugging#InfoCommand(...) abort | ||
if len(a:000) > 1 | ||
" no-custom-checks | ||
echom 'Invalid ALEInfo arguments!' | ||
|
||
return | ||
endif | ||
|
||
" Get 'echo' from '-echo', if there's an argument. | ||
let l:mode = get(a:000, '')[1:] | ||
|
||
if empty(l:mode) | ||
let l:mode = ale#Var(bufnr(''), 'info_default_mode') | ||
endif | ||
|
||
if l:mode is# 'echo' | ||
call ale#debugging#Info() | ||
elseif l:mode is# 'clip' || l:mode is# 'clipboard' | ||
call ale#debugging#InfoToClipboard() | ||
else | ||
call ale#debugging#InfoToPreview() | ||
endif | ||
endfunction | ||
|
||
function! ale#debugging#InfoToClipboardDeprecatedCommand() abort | ||
" no-custom-checks | ||
echom 'ALEInfoToClipboard is deprecated. Use ALEInfo -clipboard instead.' | ||
call ale#debugging#InfoToClipboard() | ||
endfunction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
" Close the ALEInfo preview window with the q key. | ||
noremap <buffer> q :q!<CR> | ||
" Explicitly use the default synmaxcol for ale-info. | ||
setlocal synmaxcol=3000 | ||
|
||
function! ALEInfoOpenHelp() abort | ||
let l:variable = matchstr(getline('.'), '\v[gb]:ale_[a-z0-9_]+') | ||
|
||
if !empty(l:variable) | ||
execute('help ' . l:variable) | ||
endif | ||
endfunction | ||
|
||
" Press space to open :help for an ALE Variable | ||
nnoremap <buffer> <silent> <space> :call ALEInfoOpenHelp()<CR> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
if exists('b:current_syntax') | ||
finish | ||
endif | ||
|
||
" Exhaustively list different ALE Info directives to match here. | ||
" This should hopefully avoid matching too eagerly. | ||
syn match aleInfoDirective /^ *Current Filetype:/ | ||
syn match aleInfoDirective /^ *Available Linters:/ | ||
syn match aleInfoDirective /^ *Enabled Linters:/ | ||
syn match aleInfoDirective /^ *Ignored Linters:/ | ||
syn match aleInfoDirective /^ *Suggested Fixers:/ | ||
syn match aleInfoDirective /^ *Command History:/ | ||
|
||
syn match aleCommandNoOutput /^<<<NO OUTPUT RETURNED>>>$/ | ||
|
||
hi def link aleInfoDirective Title | ||
hi def link aleInfoDirective Title | ||
hi def link aleCommandNoOutput Comment | ||
|
||
" Use Vim syntax highlighting for Vim options. | ||
unlet! b:current_syntax | ||
syntax include @srcVim syntax/vim.vim | ||
syntax region aleInfoVimRegionLinter matchgroup=aleInfoDirective start="^ *Linter Variables:$" end="^ $" contains=@srcVim | ||
syntax region aleInfoVimRegionGlobal matchgroup=aleInfoDirective start="^ *Global Variables:$" end="^ $" contains=@srcVim | ||
|
||
unlet! b:current_syntax | ||
syntax include @srcAleFixSuggest syntax/ale-fix-suggest.vim | ||
syntax region aleInfoFixSuggestRegion matchgroup=aleInfoDirective start="^ *Suggested Fixers:$" end="^ $" contains=@srcAleFixSuggest | ||
|
||
let b:current_syntax = 'ale-info' |
Oops, something went wrong.