Skip to content

Commit

Permalink
Add support setting diagnostics list dynamically.
Browse files Browse the repository at this point in the history
Close #583.
  • Loading branch information
Junfeng Li committed Sep 4, 2018
1 parent f903cbd commit f736b52
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 3 deletions.
7 changes: 7 additions & 0 deletions autoload/LanguageClient.vim
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,13 @@ function! LanguageClient#setLoggingLevel(level) abort
return LanguageClient#Call('languageClient/setLoggingLevel', l:params, v:null)
endfunction

function! LanguageClient#setDiagnosticsList(diagnosticsList) abort
let l:params = {
\ 'diagnosticsList': a:diagnosticsList,
\ }
return LanguageClient#Call('languageClient/setDiagnosticsList', l:params, v:null)
endfunction

function! LanguageClient#registerHandlers(handlers, ...) abort
let l:handle = a:0 > 0 ? a:1 : v:null
return LanguageClient#Call('languageClient/registerHandlers', a:handlers, l:handle)
Expand Down
12 changes: 9 additions & 3 deletions doc/LanguageClient.txt
Original file line number Diff line number Diff line change
Expand Up @@ -492,10 +492,16 @@ Execute a workspace command.
*LanguageClient_setLoggingLevel()*
Signature: LanguageClient#setLoggingLevel(level: String)

Set the plugin logging level. By default, only errors are logged into
/tmp/LanguageClient.log (%TMP%/LanguageClient.log for Windows).
Set the plugin logging level.

Valid logging levels are 'ERROR'(default), 'INFO', 'DEBUG'.
Valid logging levels are 'ERROR', 'WARN'(default), 'INFO', 'DEBUG'.

*LanguageClient#setDiagnosticsList()*
Signature: LanguageClient#setDiagnosticsList(diagnosticsList: String)

Set the destination of diagnostics.

Valid options are 'Quickfix', 'Location', 'Disabled'.

*LanguageClient#registerServerCommands()*
*LanguageClient_registerServerCommands()*
Expand Down
9 changes: 9 additions & 0 deletions src/languageclient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2065,6 +2065,15 @@ impl State {
Ok(Value::Null)
}

pub fn languageClient_setDiagnosticsList(&mut self, params: &Value) -> Result<Value> {
info!("Begin {}", REQUEST__SetDiagnosticsList);
let (diagnosticsList,): (DiagnosticsList,) =
self.gather_args(&["diagnosticsList"], params)?;
self.diagnosticsList = diagnosticsList;
info!("End {}", REQUEST__SetDiagnosticsList);
Ok(Value::Null)
}

pub fn languageClient_registerHandlers(&mut self, params: &Value) -> Result<Value> {
info!("Begin {}", REQUEST__RegisterHandlers);
let handlers: HashMap<String, String> = params.clone().to_lsp()?;
Expand Down
1 change: 1 addition & 0 deletions src/rpchandler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ impl State {
REQUEST__StartServer => self.languageClient_startServer(&params),
REQUEST__RegisterServerCommands => self.languageClient_registerServerCommands(&params),
REQUEST__SetLoggingLevel => self.languageClient_setLoggingLevel(&params),
REQUEST__SetDiagnosticsList => self.languageClient_setDiagnosticsList(&params),
REQUEST__RegisterHandlers => self.languageClient_registerHandlers(&params),
REQUEST__NCMRefresh => self.NCM_refresh(&params),
REQUEST__NCM2OnComplete => self.NCM2_on_complete(&params),
Expand Down
1 change: 1 addition & 0 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub const REQUEST__StartServer: &str = "languageClient/startServer";
pub const REQUEST__RegisterServerCommands: &str = "languageClient/registerServerCommands";
pub const REQUEST__OmniComplete: &str = "languageClient/omniComplete";
pub const REQUEST__SetLoggingLevel: &str = "languageClient/setLoggingLevel";
pub const REQUEST__SetDiagnosticsList: &str = "languageClient/setDiagnosticsList";
pub const REQUEST__RegisterHandlers: &str = "languageClient/registerHandlers";
pub const REQUEST__NCMRefresh: &str = "LanguageClient_NCMRefresh";
pub const REQUEST__NCM2OnComplete: &str = "LanguageClient_NCM2OnComplete";
Expand Down

0 comments on commit f736b52

Please sign in to comment.