mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-11-23 12:46:43 +00:00
feat: respect clients that doesn't have a client-side codelens handler
This commit is contained in:
parent
62456fda01
commit
3bf3a65734
6 changed files with 34 additions and 2 deletions
|
|
@ -72,7 +72,7 @@ pub fn query_main(mut cmds: QueryCommands) -> Result<()> {
|
||||||
allow_overlapping_token: const_config.tokens_overlapping_token_support,
|
allow_overlapping_token: const_config.tokens_overlapping_token_support,
|
||||||
allow_multiline_token: const_config.tokens_multiline_token_support,
|
allow_multiline_token: const_config.tokens_multiline_token_support,
|
||||||
remove_html: !config.support_html_in_markdown,
|
remove_html: !config.support_html_in_markdown,
|
||||||
support_client_codelens: true,
|
support_client_codelens: config.support_client_codelens,
|
||||||
extended_code_action: config.extended_code_action,
|
extended_code_action: config.extended_code_action,
|
||||||
completion_feat: config.completion.clone(),
|
completion_feat: config.completion.clone(),
|
||||||
color_theme: match config.color_theme.as_deref() {
|
color_theme: match config.color_theme.as_deref() {
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,32 @@ impl SemanticRequest for CodeLensRequest {
|
||||||
vec!["more".into()],
|
vec!["more".into()],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if !ctx.analysis.support_client_codelens
|
||||||
|
&& let Some(uri) = path_to_url(&self.path)
|
||||||
|
.ok()
|
||||||
|
.and_then(|u| serde_json::to_value(u).ok())
|
||||||
|
{
|
||||||
|
res.push(CodeLens {
|
||||||
|
range: doc_start,
|
||||||
|
command: Some(Command {
|
||||||
|
title: if is_html {
|
||||||
|
tinymist_l10n::t!("tinymist-query.code-action.exportPdf", "Export PDF")
|
||||||
|
} else {
|
||||||
|
tinymist_l10n::t!("tinymist-query.code-action.exportHtml", "Export HTML")
|
||||||
|
}
|
||||||
|
.to_string(),
|
||||||
|
command: if is_html {
|
||||||
|
"tinymist.exportPdf"
|
||||||
|
} else {
|
||||||
|
"tinymist.exportHtml"
|
||||||
|
}
|
||||||
|
.to_string(),
|
||||||
|
arguments: Some(vec![uri]),
|
||||||
|
}),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
Some(res)
|
Some(res)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,8 @@ pub struct Config {
|
||||||
pub notify_status: bool,
|
pub notify_status: bool,
|
||||||
/// Whether to remove HTML from markup content in responses.
|
/// Whether to remove HTML from markup content in responses.
|
||||||
pub support_html_in_markdown: bool,
|
pub support_html_in_markdown: bool,
|
||||||
|
/// Whether to support client code lenses.
|
||||||
|
pub support_client_codelens: bool,
|
||||||
/// Whether to utilize the extended `tinymist.resolveCodeAction` at client
|
/// Whether to utilize the extended `tinymist.resolveCodeAction` at client
|
||||||
/// side.
|
/// side.
|
||||||
pub extended_code_action: bool,
|
pub extended_code_action: bool,
|
||||||
|
|
@ -355,6 +357,7 @@ impl Config {
|
||||||
assign_config!(semantic_tokens := "semanticTokens"?: SemanticTokensMode);
|
assign_config!(semantic_tokens := "semanticTokens"?: SemanticTokensMode);
|
||||||
assign_config!(delegate_fs_requests := "delegateFsRequests"?: bool);
|
assign_config!(delegate_fs_requests := "delegateFsRequests"?: bool);
|
||||||
assign_config!(support_html_in_markdown := "supportHtmlInMarkdown"?: bool);
|
assign_config!(support_html_in_markdown := "supportHtmlInMarkdown"?: bool);
|
||||||
|
assign_config!(support_client_codelens := "supportClientCodelens"?: bool);
|
||||||
assign_config!(extended_code_action := "supportExtendedCodeAction"?: bool);
|
assign_config!(extended_code_action := "supportExtendedCodeAction"?: bool);
|
||||||
assign_config!(development := "development"?: bool);
|
assign_config!(development := "development"?: bool);
|
||||||
assign_config!(system_fonts := "systemFonts"?: Option<bool>);
|
assign_config!(system_fonts := "systemFonts"?: Option<bool>);
|
||||||
|
|
@ -1203,6 +1206,7 @@ mod tests {
|
||||||
test_good_config("semanticTokens");
|
test_good_config("semanticTokens");
|
||||||
test_good_config("delegateFsRequests");
|
test_good_config("delegateFsRequests");
|
||||||
test_good_config("supportHtmlInMarkdown");
|
test_good_config("supportHtmlInMarkdown");
|
||||||
|
test_good_config("supportClientCodelens");
|
||||||
test_good_config("supportExtendedCodeAction");
|
test_good_config("supportExtendedCodeAction");
|
||||||
test_good_config("development");
|
test_good_config("development");
|
||||||
test_good_config("systemFonts");
|
test_good_config("systemFonts");
|
||||||
|
|
|
||||||
|
|
@ -174,7 +174,7 @@ impl ServerState {
|
||||||
allow_overlapping_token: const_config.tokens_overlapping_token_support,
|
allow_overlapping_token: const_config.tokens_overlapping_token_support,
|
||||||
allow_multiline_token: const_config.tokens_multiline_token_support,
|
allow_multiline_token: const_config.tokens_multiline_token_support,
|
||||||
remove_html: !config.support_html_in_markdown,
|
remove_html: !config.support_html_in_markdown,
|
||||||
support_client_codelens: true,
|
support_client_codelens: config.support_client_codelens,
|
||||||
extended_code_action: config.extended_code_action,
|
extended_code_action: config.extended_code_action,
|
||||||
completion_feat: config.completion.clone(),
|
completion_feat: config.completion.clone(),
|
||||||
color_theme: match config.color_theme.as_deref() {
|
color_theme: match config.color_theme.as_deref() {
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ function configureEditorAndLanguage(context: ExtensionContext, trait: TinymistTr
|
||||||
config.triggerSuggestAndParameterHints = true;
|
config.triggerSuggestAndParameterHints = true;
|
||||||
config.triggerParameterHints = true;
|
config.triggerParameterHints = true;
|
||||||
config.supportHtmlInMarkdown = true;
|
config.supportHtmlInMarkdown = true;
|
||||||
|
config.supportClientCodelens = true;
|
||||||
config.supportExtendedCodeAction = true;
|
config.supportExtendedCodeAction = true;
|
||||||
config.customizedShowDocument = true;
|
config.customizedShowDocument = true;
|
||||||
config.delegateFsRequests = false; // todo: detect live sharing.
|
config.delegateFsRequests = false; // todo: detect live sharing.
|
||||||
|
|
|
||||||
|
|
@ -276,6 +276,7 @@
|
||||||
"triggerParameterHints": true,
|
"triggerParameterHints": true,
|
||||||
"triggerSuggestAndParameterHints": true,
|
"triggerSuggestAndParameterHints": true,
|
||||||
"supportHtmlInMarkdown": true,
|
"supportHtmlInMarkdown": true,
|
||||||
|
"supportClientCodelens": true,
|
||||||
"supportExtendedCodeAction": true,
|
"supportExtendedCodeAction": true,
|
||||||
"customizedShowDocument": true,
|
"customizedShowDocument": true,
|
||||||
"experimentalFormatterMode": "disable"
|
"experimentalFormatterMode": "disable"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue