summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-11-12 23:19:26 +0000
committerw0rp <devw0rp@gmail.com>2017-11-12 23:19:26 +0000
commit70623ca8a7ffadac0d282b4737dbb7322659c592 (patch)
treedb71facbb77c0bbb67ae2b73033b62f67d0acec5
parent7d056b0839a6d716533bce73cd72555aec6f5837 (diff)
downloadale-70623ca8a7ffadac0d282b4737dbb7322659c592.zip
Add support for showing Info severities in echoed messages
-rw-r--r--autoload/ale/cursor.vim12
-rw-r--r--doc/ale.txt8
-rw-r--r--plugin/ale.vim1
-rw-r--r--test/test_cursor_warnings.vader46
4 files changed, 62 insertions, 5 deletions
diff --git a/autoload/ale/cursor.vim b/autoload/ale/cursor.vim
index 6238b4a9..c7c74c9b 100644
--- a/autoload/ale/cursor.vim
+++ b/autoload/ale/cursor.vim
@@ -7,12 +7,16 @@ let s:last_pos = [0, 0, 0]
" Return a formatted message according to g:ale_echo_msg_format variable
function! s:GetMessage(linter, type, text) abort
let l:msg = g:ale_echo_msg_format
- let l:type = a:type is# 'E'
- \ ? g:ale_echo_msg_error_str
- \ : g:ale_echo_msg_warning_str
+ let l:severity = g:ale_echo_msg_warning_str
+
+ if a:type is# 'E'
+ let l:severity = g:ale_echo_msg_error_str
+ elseif a:type is# 'I'
+ let l:severity = g:ale_echo_msg_info_str
+ endif
" Replace handlers if they exist
- for [l:k, l:v] in items({'linter': a:linter, 'severity': l:type})
+ for [l:k, l:v] in items({'linter': a:linter, 'severity': l:severity})
let l:msg = substitute(l:msg, '\V%' . l:k . '%', l:v, '')
endfor
diff --git a/doc/ale.txt b/doc/ale.txt
index f384b1e6..5638a2c8 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -660,6 +660,14 @@ g:ale_echo_msg_format *g:ale_echo_msg_format*
|g:ale_echo_cursor| needs to be set to 1 for messages to be displayed.
+g:ale_echo_msg_info_str *g:ale_echo_msg_info_str*
+
+ Type: |String|
+ Default: `'Info'`
+
+ The string used for `%severity%` for info. See |g:ale_echo_msg_format|
+
+
g:ale_echo_msg_warning_str *g:ale_echo_msg_warning_str*
Type: |String|
diff --git a/plugin/ale.vim b/plugin/ale.vim
index 0b5ac78e..c67e1de7 100644
--- a/plugin/ale.vim
+++ b/plugin/ale.vim
@@ -155,6 +155,7 @@ let g:ale_echo_msg_format = get(g:, 'ale_echo_msg_format', '%s')
" Strings used for severity in the echoed message
let g:ale_echo_msg_error_str = get(g:, 'ale_echo_msg_error_str', 'Error')
+let g:ale_echo_msg_info_str = get(g:, 'ale_echo_msg_info_str', 'Info')
let g:ale_echo_msg_warning_str = get(g:, 'ale_echo_msg_warning_str', 'Warning')
" This flag can be set to 0 to disable echoing when the cursor moves.
diff --git a/test/test_cursor_warnings.vader b/test/test_cursor_warnings.vader
index 586cc13c..20ccb157 100644
--- a/test/test_cursor_warnings.vader
+++ b/test/test_cursor_warnings.vader
@@ -1,4 +1,6 @@
Before:
+ Save g:ale_echo_msg_format
+
let g:ale_buffer_info = {
\ bufnr('%'): {
\ 'loclist': [
@@ -14,6 +16,16 @@ Before:
\ 'detail': "Every statement should end with a semicolon\nsecond line"
\ },
\ {
+ \ 'lnum': 1,
+ \ 'col': 14,
+ \ 'bufnr': bufnr('%'),
+ \ 'vcol': 0,
+ \ 'linter_name': 'eslint',
+ \ 'nr': -1,
+ \ 'type': 'I',
+ \ 'text': 'Some information',
+ \ },
+ \ {
\ 'lnum': 2,
\ 'col': 10,
\ 'bufnr': bufnr('%'),
@@ -63,6 +75,8 @@ Before:
endfunction
After:
+ Restore
+
call cursor(1, 1)
let g:ale_set_loclist = 1
@@ -81,7 +95,7 @@ After:
echomsg ''
Given javascript(A Javscript file with warnings/errors):
- var x = 3
+ var x = 3 + 12345678
var x = 5*2 + parseInt("10");
// comment
@@ -141,3 +155,33 @@ Execute(ALEDetail should not capitlise cursor messages):
call ale#cursor#EchoCursorWarning()
AssertEqual 'lowercase error', GetLastMessage()
+
+Execute(The linter name should be formatted into the message correctly):
+ let g:ale_echo_msg_format = '%linter%: %s'
+
+ call cursor(2, 9)
+ call ale#cursor#EchoCursorWarning()
+
+ AssertEqual
+ \ 'eslint: Infix operators must be spaced. (space-infix-ops)',
+ \ GetLastMessage()
+
+Execute(The severity should be formatted into the message correctly):
+ let g:ale_echo_msg_format = '%severity%: %s'
+
+ call cursor(2, 9)
+ call ale#cursor#EchoCursorWarning()
+
+ AssertEqual
+ \ 'Warning: Infix operators must be spaced. (space-infix-ops)',
+ \ GetLastMessage()
+
+ call cursor(1, 10)
+ call ale#cursor#EchoCursorWarning()
+
+ AssertEqual 'Error: Missing semicolon. (semi)', GetLastMessage()
+
+ call cursor(1, 14)
+ call ale#cursor#EchoCursorWarning()
+
+ AssertEqual 'Info: Some information', GetLastMessage()