From 8f82a025501d3c63720557ee2cce73319af14239 Mon Sep 17 00:00:00 2001 From: Greg Anders <8965202+gpanders@users.noreply.github.com> Date: Tue, 7 Jul 2020 14:35:44 -0600 Subject: [PATCH 1/2] Treat window/progress messages as log messages These messages should only be displayed if `log_level` is set to `'Log'`. --- autoload/lsc/server.vim | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/autoload/lsc/server.vim b/autoload/lsc/server.vim index 93a1fd9d..3d72c61b 100644 --- a/autoload/lsc/server.vim +++ b/autoload/lsc/server.vim @@ -325,13 +325,15 @@ 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']) + if lsc#config#shouldEcho(a:server, 4) + 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) From a4950d2cce9fc8b8a71e08ab54b63b5ab71a2d10 Mon Sep 17 00:00:00 2001 From: Greg Anders <8965202+gpanders@users.noreply.github.com> Date: Tue, 7 Jul 2020 14:50:02 -0600 Subject: [PATCH 2/2] Add lsc#config#messageType function This converts a message type by name into a log level value --- autoload/lsc/config.vim | 28 +++++++++++++++++++--------- autoload/lsc/server.vim | 3 ++- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/autoload/lsc/config.vim b/autoload/lsc/config.vim index 316ecd21..7ad86a55 100644 --- a/autoload/lsc/config.vim +++ b/autoload/lsc/config.vim @@ -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 diff --git a/autoload/lsc/server.vim b/autoload/lsc/server.vim index 3d72c61b..a98e4458 100644 --- a/autoload/lsc/server.vim +++ b/autoload/lsc/server.vim @@ -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)