Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treat window/progress messages as log messages #316

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
17 changes: 10 additions & 7 deletions autoload/lsc/server.vim
Original file line number Diff line number Diff line change
Expand Up @@ -325,13 +325,16 @@ 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 has_key(a:params, 'message')
let l:full = a:params['title'] . a:params['message']
call lsc#message#show('Progress ' . l:full)
elseif has_key(a:params, 'done')
call lsc#message#show('Finished ' . a:params['title'])
else
call lsc#message#show('Starting ' . a:params['title'])
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)
elseif has_key(a:params, 'done')
call lsc#message#show('Finished ' . a:params['title'])
else
call lsc#message#show('Starting ' . a:params['title'])
endif
endif
elseif a:method ==? 'workspace/applyEdit'
let l:applied = lsc#edit#apply(a:params.edit)
Expand Down