summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md3
-rw-r--r--autoload/ale/debugging.vim1
-rw-r--r--autoload/ale/engine.vim26
-rw-r--r--autoload/ale/list.vim9
-rw-r--r--autoload/ale/lsp/response.vim8
-rw-r--r--doc/ale.txt12
-rw-r--r--plugin/ale.vim3
-rw-r--r--test/lsp/test_read_lsp_diagnostics.vader35
-rw-r--r--test/test_ale_info.vader1
-rw-r--r--test/test_list_opening.vader51
10 files changed, 134 insertions, 15 deletions
diff --git a/README.md b/README.md
index e964c651..d5335e2a 100644
--- a/README.md
+++ b/README.md
@@ -577,6 +577,9 @@ let g:ale_open_list = 1
let g:ale_keep_list_window_open = 1
```
+You can also set `let g:ale_list_vertical = 1` to open the windows vertically
+instead of the default horizontally.
+
<a name="faq-jsx-stylelint-eslint"></a>
### 5.xii. How can I check JSX files with both stylelint and eslint?
diff --git a/autoload/ale/debugging.vim b/autoload/ale/debugging.vim
index 9be1fbf6..cb93ec16 100644
--- a/autoload/ale/debugging.vim
+++ b/autoload/ale/debugging.vim
@@ -29,6 +29,7 @@ let s:global_variable_list = [
\ 'ale_linters',
\ 'ale_linters_explicit',
\ 'ale_list_window_size',
+\ 'ale_list_vertical',
\ 'ale_loclist_msg_format',
\ 'ale_max_buffer_history_size',
\ 'ale_max_signs',
diff --git a/autoload/ale/engine.vim b/autoload/ale/engine.vim
index a21eecdd..9ef3ba39 100644
--- a/autoload/ale/engine.vim
+++ b/autoload/ale/engine.vim
@@ -145,35 +145,39 @@ function! s:GatherOutput(job_id, line) abort
endfunction
function! s:HandleLoclist(linter_name, buffer, loclist) abort
- let l:buffer_info = get(g:ale_buffer_info, a:buffer, {})
+ let l:info = get(g:ale_buffer_info, a:buffer, {})
- if empty(l:buffer_info)
+ if empty(l:info)
return
endif
" Remove this linter from the list of active linters.
" This may have already been done when the job exits.
- call filter(l:buffer_info.active_linter_list, 'v:val isnot# a:linter_name')
+ call filter(l:info.active_linter_list, 'v:val isnot# a:linter_name')
" Make some adjustments to the loclists to fix common problems, and also
" to set default values for loclist items.
let l:linter_loclist = ale#engine#FixLocList(a:buffer, a:linter_name, a:loclist)
" Remove previous items for this linter.
- call filter(g:ale_buffer_info[a:buffer].loclist, 'v:val.linter_name isnot# a:linter_name')
- " Add the new items.
- call extend(g:ale_buffer_info[a:buffer].loclist, l:linter_loclist)
+ call filter(l:info.loclist, 'v:val.linter_name isnot# a:linter_name')
- " Sort the loclist again.
- " We need a sorted list so we can run a binary search against it
- " for efficient lookup of the messages in the cursor handler.
- call sort(g:ale_buffer_info[a:buffer].loclist, 'ale#util#LocItemCompare')
+ " We don't need to add items or sort the list when this list is empty.
+ if !empty(l:linter_loclist)
+ " Add the new items.
+ call extend(l:info.loclist, l:linter_loclist)
+
+ " Sort the loclist again.
+ " We need a sorted list so we can run a binary search against it
+ " for efficient lookup of the messages in the cursor handler.
+ call sort(l:info.loclist, 'ale#util#LocItemCompare')
+ endif
if ale#ShouldDoNothing(a:buffer)
return
endif
- call ale#engine#SetResults(a:buffer, g:ale_buffer_info[a:buffer].loclist)
+ call ale#engine#SetResults(a:buffer, l:info.loclist)
endfunction
function! s:HandleExit(job_id, exit_code) abort
diff --git a/autoload/ale/list.vim b/autoload/ale/list.vim
index b1a8d4a7..30b8f5cf 100644
--- a/autoload/ale/list.vim
+++ b/autoload/ale/list.vim
@@ -97,12 +97,17 @@ function! s:SetListsImpl(timer_id, buffer, loclist) abort
let l:reset_visual_selection = l:mode is? 'v' || l:mode is# "\<c-v>"
let l:reset_character_selection = l:mode is? 's' || l:mode is# "\<c-s>"
+ " open windows vertically instead of default horizontally
+ let l:open_type = ''
+ if ale#Var(a:buffer, 'list_vertical') == 1
+ let l:open_type = 'vert '
+ endif
if g:ale_set_quickfix
if !ale#list#IsQuickfixOpen()
- silent! execute 'copen ' . str2nr(ale#Var(a:buffer, 'list_window_size'))
+ silent! execute l:open_type . 'copen ' . str2nr(ale#Var(a:buffer, 'list_window_size'))
endif
elseif g:ale_set_loclist
- silent! execute 'lopen ' . str2nr(ale#Var(a:buffer, 'list_window_size'))
+ silent! execute l:open_type . 'lopen ' . str2nr(ale#Var(a:buffer, 'list_window_size'))
endif
" If focus changed, restore it (jump to the last window).
diff --git a/autoload/ale/lsp/response.vim b/autoload/ale/lsp/response.vim
index 13219ef6..5a431287 100644
--- a/autoload/ale/lsp/response.vim
+++ b/autoload/ale/lsp/response.vim
@@ -59,6 +59,14 @@ function! ale#lsp#response#ReadTSServerDiagnostics(response) abort
let l:loclist_item.nr = l:diagnostic.code
endif
+ if get(l:diagnostic, 'category') is# 'warning'
+ let l:loclist_item.type = 'W'
+ endif
+
+ if get(l:diagnostic, 'category') is# 'suggestion'
+ let l:loclist_item.type = 'I'
+ endif
+
call add(l:loclist, l:loclist_item)
endfor
diff --git a/doc/ale.txt b/doc/ale.txt
index 76ad0587..aeeb9fad 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -1152,6 +1152,16 @@ g:ale_linters_explicit *g:ale_linters_explicit*
as possible, unless otherwise specified.
+g:ale_list_vertical *g:ale_list_vertical*
+ *b:ale_list_vertical*
+ Type: |Number|
+ Default: `0`
+
+ When set to `1`, this will cause ALE to open any windows (loclist or
+ quickfix) vertically instead of horizontally (|vert| |lopen|) or (|vert|
+ |copen|)
+
+
g:ale_loclist_msg_format *g:ale_loclist_msg_format*
b:ale_loclist_msg_format *b:ale_loclist_msg_format*
@@ -1223,6 +1233,8 @@ g:ale_open_list *g:ale_open_list*
The window size can be configured with |g:ale_list_window_size|.
+ Windows can be opened vertically with |g:ale_list_vertical|.
+
If you want to close the loclist window automatically when the buffer is
closed, you can set up the following |autocmd| command: >
diff --git a/plugin/ale.vim b/plugin/ale.vim
index d75d33b0..1a473df1 100644
--- a/plugin/ale.vim
+++ b/plugin/ale.vim
@@ -118,6 +118,9 @@ let g:ale_open_list = get(g:, 'ale_open_list', 0)
" This flag dictates if ale keeps open loclist even if there is no error in loclist
let g:ale_keep_list_window_open = get(g:, 'ale_keep_list_window_open', 0)
+" This flag dictates that quickfix windows should be opened vertically
+let g:ale_list_vertical = get(g:, 'ale_list_vertical', 0)
+
" The window size to set for the quickfix and loclist windows
call ale#Set('list_window_size', 10)
diff --git a/test/lsp/test_read_lsp_diagnostics.vader b/test/lsp/test_read_lsp_diagnostics.vader
index 3e637418..444272aa 100644
--- a/test/lsp/test_read_lsp_diagnostics.vader
+++ b/test/lsp/test_read_lsp_diagnostics.vader
@@ -121,7 +121,8 @@ Execute(ale#lsp#response#ReadDiagnostics() should handle multiple messages):
\ ]}})
Execute(ale#lsp#response#ReadTSServerDiagnostics() should handle tsserver responses):
- AssertEqual [
+ AssertEqual
+ \ [
\ {
\ 'type': 'E',
\ 'nr': 2365,
@@ -131,5 +132,35 @@ Execute(ale#lsp#response#ReadTSServerDiagnostics() should handle tsserver respon
\ 'end_lnum': 1,
\ 'end_col': 17,
\ },
- \],
+ \ ],
\ ale#lsp#response#ReadTSServerDiagnostics({"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/bar/foo.ts","diagnostics":[{"start":{"line":1,"offset":11},"end":{"line":1,"offset":17},"text":"Operator ''+'' cannot be applied to types ''3'' and ''{}''.","code":2365}]}})
+
+Execute(ale#lsp#response#ReadTSServerDiagnostics() should handle warnings from tsserver):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 27,
+ \ 'col': 3,
+ \ 'nr': 2515,
+ \ 'end_lnum': 27,
+ \ 'type': 'W',
+ \ 'end_col': 14,
+ \ 'text': 'Calls to ''console.log'' are not allowed. (no-console)',
+ \ }
+ \ ],
+ \ ale#lsp#response#ReadTSServerDiagnostics({"seq":0,"type":"event","event":"semanticDiag","body":{"file":"<removed>","diagnostics":[{"start":{"line":27,"offset":3},"end":{"line":27,"offset":14},"text":"Calls to 'console.log' are not allowed. (no-console)","code":2515,"category":"warning","source":"tslint"}]}})
+
+Execute(ale#lsp#response#ReadTSServerDiagnostics() should handle suggestions from tsserver):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 27,
+ \ 'col': 3,
+ \ 'nr': 2515,
+ \ 'end_lnum': 27,
+ \ 'type': 'I',
+ \ 'end_col': 14,
+ \ 'text': 'Some info',
+ \ }
+ \ ],
+ \ ale#lsp#response#ReadTSServerDiagnostics({"seq":0,"type":"event","event":"semanticDiag","body":{"file":"<removed>","diagnostics":[{"start":{"line":27,"offset":3},"end":{"line":27,"offset":14},"text":"Some info","code":2515,"category":"suggestion","source":"tslint"}]}})
diff --git a/test/test_ale_info.vader b/test/test_ale_info.vader
index e20125a3..05c045bb 100644
--- a/test/test_ale_info.vader
+++ b/test/test_ale_info.vader
@@ -66,6 +66,7 @@ Before:
\ 'let g:ale_linters = {}',
\ 'let g:ale_linters_explicit = 0',
\ 'let g:ale_list_window_size = 10',
+ \ 'let g:ale_list_vertical = 0',
\ 'let g:ale_loclist_msg_format = ''%code: %%s''',
\ 'let g:ale_max_buffer_history_size = 20',
\ 'let g:ale_max_signs = -1',
diff --git a/test/test_list_opening.vader b/test/test_list_opening.vader
index 63b30ef1..a24e8de9 100644
--- a/test/test_list_opening.vader
+++ b/test/test_list_opening.vader
@@ -5,6 +5,7 @@ Before:
Save g:ale_open_list
Save g:ale_keep_list_window_open
Save g:ale_list_window_size
+ Save g:ale_list_vertical
Save g:ale_buffer_info
Save g:ale_set_lists_synchronously
@@ -13,6 +14,7 @@ Before:
let g:ale_open_list = 0
let g:ale_keep_list_window_open = 0
let g:ale_list_window_size = 10
+ let g:ale_list_vertical = 0
let g:ale_set_lists_synchronously = 1
let g:loclist = [
@@ -33,16 +35,29 @@ Before:
return 0
endfunction
+ " If the window is vertical, window size should match column size/width
+ function GetQuickfixIsVertical(cols) abort
+ for l:win in range(1, winnr('$'))
+ if getwinvar(l:win, '&buftype') is# 'quickfix'
+ return winwidth(l:win) == a:cols
+ endif
+ endfor
+
+ return 0
+ endfunction
+
After:
Restore
unlet! g:loclist
+ unlet! b:ale_list_vertical
unlet! b:ale_list_window_size
unlet! b:ale_open_list
unlet! b:ale_keep_list_window_open
unlet! b:ale_save_event_fired
delfunction GetQuickfixHeight
+ delfunction GetQuickfixIsVertical
" Close quickfix window after every execute block
lcl
@@ -98,6 +113,24 @@ Execute(The quickfix window height should be correct for the loclist with buffer
AssertEqual 8, GetQuickfixHeight()
+Execute(The quickfix window should be vertical for the loclist with appropriate variables):
+ let g:ale_open_list = 1
+ let b:ale_list_window_size = 8
+ let b:ale_list_vertical = 1
+
+ call ale#list#SetLists(bufnr('%'), g:loclist)
+
+ AssertEqual 1, GetQuickfixIsVertical(b:ale_list_window_size)
+
+Execute(The quickfix window should be horizontal for the loclist with appropriate variables):
+ let g:ale_open_list = 1
+ let b:ale_list_window_size = 8
+ let b:ale_list_vertical = 0
+
+ call ale#list#SetLists(bufnr('%'), g:loclist)
+
+ AssertEqual 0, GetQuickfixIsVertical(b:ale_list_window_size)
+
Execute(The quickfix window should stay open for just the loclist):
let g:ale_open_list = 1
let g:ale_keep_list_window_open = 1
@@ -167,6 +200,24 @@ Execute(The quickfix window height should be correct for the quickfix list with
AssertEqual 8, GetQuickfixHeight()
+Execute(The quickfix window should be vertical for the quickfix with appropriate variables):
+ let g:ale_open_list = 1
+ let b:ale_list_window_size = 8
+ let b:ale_list_vertical = 1
+
+ call ale#list#SetLists(bufnr('%'), g:loclist)
+
+ AssertEqual 1, GetQuickfixIsVertical(b:ale_list_window_size)
+
+Execute(The quickfix window should be horizontal for the quickfix with appropriate variables):
+ let g:ale_open_list = 1
+ let b:ale_list_window_size = 8
+ let b:ale_list_vertical = 0
+
+ call ale#list#SetLists(bufnr('%'), g:loclist)
+
+ AssertEqual 0, GetQuickfixIsVertical(b:ale_list_window_size)
+
Execute(The buffer ale_open_list option should be respected):
let b:ale_open_list = 1