CodeLens configuration options.

This commit is contained in:
vsrs
2020-05-17 19:51:44 +03:00
parent 71e94b1d0b
commit dc217bdf90
4 changed files with 168 additions and 92 deletions

View File

@@ -33,6 +33,34 @@ pub struct Config {
pub inlay_hints: InlayHintsConfig,
pub completion: CompletionConfig,
pub call_info_full: bool,
pub lens: LensConfig,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct LensConfig {
pub run: bool,
pub debug: bool,
pub impementations: bool,
}
impl Default for LensConfig {
fn default() -> Self {
Self { run: true, debug: true, impementations: true }
}
}
impl LensConfig {
pub fn any(&self) -> bool {
self.impementations || self.runnable()
}
pub fn none(&self) -> bool {
!self.any()
}
pub fn runnable(&self) -> bool {
self.run || self.debug
}
}
#[derive(Debug, Clone)]
@@ -107,6 +135,7 @@ impl Default for Config {
..CompletionConfig::default()
},
call_info_full: true,
lens: LensConfig::default(),
}
}
}
@@ -195,6 +224,9 @@ impl Config {
set(value, "/completion/addCallParenthesis", &mut self.completion.add_call_parenthesis);
set(value, "/completion/addCallArgumentSnippets", &mut self.completion.add_call_argument_snippets);
set(value, "/callInfo/full", &mut self.call_info_full);
set(value, "/lens/run", &mut self.lens.run);
set(value, "/lens/debug", &mut self.lens.debug);
set(value, "/lens/implementations", &mut self.lens.impementations);
log::info!("Config::update() = {:#?}", self);
@@ -212,35 +244,35 @@ impl Config {
pub fn update_caps(&mut self, caps: &ClientCapabilities) {
if let Some(doc_caps) = caps.text_document.as_ref() {
if let Some(value) = doc_caps.definition.as_ref().and_then(|it| it.link_support) {
self.client_caps.location_link = value;
}
self.client_caps.location_link = value;
}
if let Some(value) = doc_caps.folding_range.as_ref().and_then(|it| it.line_folding_only)
{
self.client_caps.line_folding_only = value
}
self.client_caps.line_folding_only = value
}
if let Some(value) = doc_caps
.document_symbol
.as_ref()
.and_then(|it| it.hierarchical_document_symbol_support)
{
self.client_caps.hierarchical_symbols = value
}
{
self.client_caps.hierarchical_symbols = value
}
if let Some(value) = doc_caps
.code_action
.as_ref()
.and_then(|it| Some(it.code_action_literal_support.is_some()))
{
self.client_caps.code_action_literals = value;
}
self.completion.allow_snippets(false);
{
self.client_caps.code_action_literals = value;
}
self.completion.allow_snippets(false);
if let Some(completion) = &doc_caps.completion {
if let Some(completion_item) = &completion.completion_item {
if let Some(value) = completion_item.snippet_support {
self.completion.allow_snippets(value);
}
if let Some(completion_item) = &completion.completion_item {
if let Some(value) = completion_item.snippet_support {
self.completion.allow_snippets(value);
}
}
}
}
if let Some(window_caps) = caps.window.as_ref() {
if let Some(value) = window_caps.work_done_progress {