Skip to content

Commit

Permalink
Add lsc#config#messageType function
Browse files Browse the repository at this point in the history
This converts a message type by name into a log level value
  • Loading branch information
gpanders committed Jul 7, 2020
1 parent 5458f54 commit 2ed0efa
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
28 changes: 19 additions & 9 deletions autoload/lsc/config.vim
Original file line number Diff line number Diff line change
Expand Up @@ -169,20 +169,30 @@ function! lsc#config#shouldEcho(server, type) abort
let l:threshold = a:server.config.log_level
else
let l:config = a:server.config.log_level
if l:config ==# 'Error'
let l:threshold = 1
elseif l:config ==# 'Warning'
let l:threshold = 2
elseif l:config ==# 'Info'
let l:threshold = 3
elseif l:config ==# 'Log'
let l:threshold = 4
endif
let l:threshold = lsc#config#messageType(l:config)
endif
endif
return a:type <= l:threshold
endfunction

" Convert message type name to number
function! lsc#config#messageType(type) abort
if a:type ==# 'Error'
return 1
elseif a:type ==# 'Warning'
return 2
elseif a:type ==# 'Info'
return 3
elseif a:type ==# 'Log'
return 4
else
call lsc#message#error('Unkown message type: '.a:type)

" Default to "Info"
return 3
endif
endfunction

" A maker from returns from "message_hook" functions indicating that a call
" should not be made.
function! lsc#config#skip() abort
Expand Down
3 changes: 2 additions & 1 deletion autoload/lsc/server.vim
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,8 @@ function! s:Dispatch(server, method, params, id) abort
call lsc#util#shift(a:server.logs, 100,
\ {'message': a:params.message, 'type': a:params.type})
elseif a:method ==? 'window/progress'
if lsc#config#shouldEcho(a:server, 4)
let a:params.type = lsc#config#messageType('Log')
if lsc#config#shouldEcho(a:server, a:params.type)
if has_key(a:params, 'message')
let l:full = a:params['title'] . a:params['message']
call lsc#message#show('Progress ' . l:full)
Expand Down

0 comments on commit 2ed0efa

Please sign in to comment.