diff --git a/Cargo.lock b/Cargo.lock index c64995b01b..6c346e331e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9018,6 +9018,7 @@ dependencies = [ "task", "text", "theme", + "toml 0.8.20", "tree-sitter", "tree-sitter-elixir", "tree-sitter-embedded-template", diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index a31f789fb0..d5448f30f3 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -109,10 +109,10 @@ use inline_completion::{EditPredictionProvider, InlineCompletionProviderHandle}; pub use items::MAX_TAB_TITLE_LEN; use itertools::Itertools; use language::{ - AutoindentMode, BracketMatch, BracketPair, Buffer, Capability, CharKind, CodeLabel, - CursorShape, DiagnosticEntry, DiffOptions, DocumentationConfig, EditPredictionsMode, - EditPreview, HighlightedText, IndentKind, IndentSize, Language, OffsetRangeExt, Point, - Selection, SelectionGoal, TextObject, TransactionId, TreeSitterOptions, WordsQuery, + AutoindentMode, BlockCommentConfig, BracketMatch, BracketPair, Buffer, Capability, CharKind, + CodeLabel, CursorShape, DiagnosticEntry, DiffOptions, EditPredictionsMode, EditPreview, + HighlightedText, IndentKind, IndentSize, Language, OffsetRangeExt, Point, Selection, + SelectionGoal, TextObject, TransactionId, TreeSitterOptions, WordsQuery, language_settings::{ self, InlayHintSettings, LspInsertMode, RewrapBehavior, WordsCompletionMode, all_language_settings, language_settings, @@ -4408,7 +4408,9 @@ impl Editor { }) .max_by_key(|(_, len)| *len)?; - if let Some((block_start, _)) = language.block_comment_delimiters() + if let Some(BlockCommentConfig { + start: block_start, .. + }) = language.block_comment() { let block_start_trimmed = block_start.trim_end(); if block_start_trimmed.starts_with(delimiter.trim_end()) { @@ -4445,13 +4447,12 @@ impl Editor { return None; } - let DocumentationConfig { + let BlockCommentConfig { start: start_tag, end: end_tag, prefix: delimiter, tab_size: len, - } = language.documentation()?; - + } = language.documentation_comment()?; let is_within_block_comment = buffer .language_scope_at(start_point) .is_some_and(|scope| scope.override_name() == Some("comment")); @@ -4521,7 +4522,7 @@ impl Editor { let cursor_is_at_start_of_end_tag = column == end_tag_offset; if cursor_is_at_start_of_end_tag { - indent_on_extra_newline.len = (*len).into(); + indent_on_extra_newline.len = *len; } } cursor_is_before_end_tag @@ -4534,7 +4535,7 @@ impl Editor { && cursor_is_before_end_tag_if_exists { if cursor_is_after_start_tag { - indent_on_newline.len = (*len).into(); + indent_on_newline.len = *len; } Some(delimiter.clone()) } else { @@ -14349,8 +14350,11 @@ impl Editor { (position..position, first_prefix.clone()) })); } - } else if let Some((full_comment_prefix, comment_suffix)) = - language.block_comment_delimiters() + } else if let Some(BlockCommentConfig { + start: full_comment_prefix, + end: comment_suffix, + .. + }) = language.block_comment() { let comment_prefix = full_comment_prefix.trim_end_matches(' '); let comment_prefix_whitespace = &full_comment_prefix[comment_prefix.len()..]; diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index fbb877796c..b9ca8c3755 100644 --- a/crates/editor/src/editor_tests.rs +++ b/crates/editor/src/editor_tests.rs @@ -2875,11 +2875,11 @@ async fn test_newline_documentation_comments(cx: &mut TestAppContext) { let language = Arc::new( Language::new( LanguageConfig { - documentation: Some(language::DocumentationConfig { + documentation_comment: Some(language::BlockCommentConfig { start: "/**".into(), end: "*/".into(), prefix: "* ".into(), - tab_size: NonZeroU32::new(1).unwrap(), + tab_size: 1, }), ..LanguageConfig::default() @@ -3089,7 +3089,12 @@ async fn test_newline_comments_with_block_comment(cx: &mut TestAppContext) { let lua_language = Arc::new(Language::new( LanguageConfig { line_comments: vec!["--".into()], - block_comment: Some(("--[[".into(), "]]".into())), + block_comment: Some(language::BlockCommentConfig { + start: "--[[".into(), + prefix: "".into(), + end: "]]".into(), + tab_size: 0, + }), ..LanguageConfig::default() }, None, @@ -13806,7 +13811,12 @@ async fn test_toggle_block_comment(cx: &mut TestAppContext) { Language::new( LanguageConfig { name: "HTML".into(), - block_comment: Some(("".into())), + block_comment: Some(BlockCommentConfig { + start: "".into(), + tab_size: 0, + }), ..Default::default() }, Some(tree_sitter_html::LANGUAGE.into()), diff --git a/crates/editor/src/test/editor_lsp_test_context.rs b/crates/editor/src/test/editor_lsp_test_context.rs index f7f34135f3..c59786b1eb 100644 --- a/crates/editor/src/test/editor_lsp_test_context.rs +++ b/crates/editor/src/test/editor_lsp_test_context.rs @@ -14,7 +14,8 @@ use futures::Future; use gpui::{Context, Entity, Focusable as _, VisualTestContext, Window}; use indoc::indoc; use language::{ - FakeLspAdapter, Language, LanguageConfig, LanguageMatcher, LanguageQueries, point_to_lsp, + BlockCommentConfig, FakeLspAdapter, Language, LanguageConfig, LanguageMatcher, LanguageQueries, + point_to_lsp, }; use lsp::{notification, request}; use multi_buffer::ToPointUtf16; @@ -269,7 +270,12 @@ impl EditorLspTestContext { path_suffixes: vec!["html".into()], ..Default::default() }, - block_comment: Some(("".into())), + block_comment: Some(BlockCommentConfig { + start: "".into(), + tab_size: 0, + }), completion_query_characters: ['-'].into_iter().collect(), ..Default::default() }, diff --git a/crates/language/Cargo.toml b/crates/language/Cargo.toml index 477b978517..4ab56d6647 100644 --- a/crates/language/Cargo.toml +++ b/crates/language/Cargo.toml @@ -92,6 +92,7 @@ tree-sitter-python.workspace = true tree-sitter-ruby.workspace = true tree-sitter-rust.workspace = true tree-sitter-typescript.workspace = true +toml.workspace = true unindent.workspace = true util = { workspace = true, features = ["test-support"] } zlog.workspace = true diff --git a/crates/language/src/buffer_tests.rs b/crates/language/src/buffer_tests.rs index 6955cd0549..2e2df7e658 100644 --- a/crates/language/src/buffer_tests.rs +++ b/crates/language/src/buffer_tests.rs @@ -2273,7 +2273,12 @@ fn test_language_scope_at_with_javascript(cx: &mut App) { LanguageConfig { name: "JavaScript".into(), line_comments: vec!["// ".into()], - block_comment: Some(("/*".into(), "*/".into())), + block_comment: Some(BlockCommentConfig { + start: "/*".into(), + end: "*/".into(), + prefix: "* ".into(), + tab_size: 1, + }), brackets: BracketPairConfig { pairs: vec![ BracketPair { @@ -2300,7 +2305,12 @@ fn test_language_scope_at_with_javascript(cx: &mut App) { "element".into(), LanguageConfigOverride { line_comments: Override::Remove { remove: true }, - block_comment: Override::Set(("{/*".into(), "*/}".into())), + block_comment: Override::Set(BlockCommentConfig { + start: "{/*".into(), + prefix: "".into(), + end: "*/}".into(), + tab_size: 0, + }), ..Default::default() }, )] @@ -2338,9 +2348,15 @@ fn test_language_scope_at_with_javascript(cx: &mut App) { let config = snapshot.language_scope_at(0).unwrap(); assert_eq!(config.line_comment_prefixes(), &[Arc::from("// ")]); assert_eq!( - config.block_comment_delimiters(), - Some((&"/*".into(), &"*/".into())) + config.block_comment(), + Some(&BlockCommentConfig { + start: "/*".into(), + prefix: "* ".into(), + end: "*/".into(), + tab_size: 1, + }) ); + // Both bracket pairs are enabled assert_eq!( config.brackets().map(|e| e.1).collect::>(), @@ -2360,8 +2376,13 @@ fn test_language_scope_at_with_javascript(cx: &mut App) { .unwrap(); assert_eq!(string_config.line_comment_prefixes(), &[Arc::from("// ")]); assert_eq!( - string_config.block_comment_delimiters(), - Some((&"/*".into(), &"*/".into())) + string_config.block_comment(), + Some(&BlockCommentConfig { + start: "/*".into(), + prefix: "* ".into(), + end: "*/".into(), + tab_size: 1, + }) ); // Second bracket pair is disabled assert_eq!( @@ -2391,8 +2412,13 @@ fn test_language_scope_at_with_javascript(cx: &mut App) { .unwrap(); assert_eq!(tag_config.line_comment_prefixes(), &[Arc::from("// ")]); assert_eq!( - tag_config.block_comment_delimiters(), - Some((&"/*".into(), &"*/".into())) + tag_config.block_comment(), + Some(&BlockCommentConfig { + start: "/*".into(), + prefix: "* ".into(), + end: "*/".into(), + tab_size: 1, + }) ); assert_eq!( tag_config.brackets().map(|e| e.1).collect::>(), @@ -2408,8 +2434,13 @@ fn test_language_scope_at_with_javascript(cx: &mut App) { &[Arc::from("// ")] ); assert_eq!( - expression_in_element_config.block_comment_delimiters(), - Some((&"/*".into(), &"*/".into())) + expression_in_element_config.block_comment(), + Some(&BlockCommentConfig { + start: "/*".into(), + prefix: "* ".into(), + end: "*/".into(), + tab_size: 1, + }) ); assert_eq!( expression_in_element_config @@ -2528,13 +2559,18 @@ fn test_language_scope_at_with_combined_injections(cx: &mut App) { let html_config = snapshot.language_scope_at(Point::new(2, 4)).unwrap(); assert_eq!(html_config.line_comment_prefixes(), &[]); assert_eq!( - html_config.block_comment_delimiters(), - Some((&"".into())) + html_config.block_comment(), + Some(&BlockCommentConfig { + start: "".into(), + prefix: "".into(), + tab_size: 0, + }) ); let ruby_config = snapshot.language_scope_at(Point::new(3, 12)).unwrap(); assert_eq!(ruby_config.line_comment_prefixes(), &[Arc::from("# ")]); - assert_eq!(ruby_config.block_comment_delimiters(), None); + assert_eq!(ruby_config.block_comment(), None); buffer }); @@ -3490,7 +3526,12 @@ fn html_lang() -> Language { Language::new( LanguageConfig { name: LanguageName::new("HTML"), - block_comment: Some(("".into())), + block_comment: Some(BlockCommentConfig { + start: "".into(), + tab_size: 0, + }), ..Default::default() }, Some(tree_sitter_html::LANGUAGE.into()), @@ -3521,7 +3562,12 @@ fn erb_lang() -> Language { path_suffixes: vec!["erb".to_string()], ..Default::default() }, - block_comment: Some(("<%#".into(), "%>".into())), + block_comment: Some(BlockCommentConfig { + start: "<%#".into(), + prefix: "".into(), + end: "%>".into(), + tab_size: 0, + }), ..Default::default() }, Some(tree_sitter_embedded_template::LANGUAGE.into()), diff --git a/crates/language/src/language.rs b/crates/language/src/language.rs index 1ad057ff41..1df33286ee 100644 --- a/crates/language/src/language.rs +++ b/crates/language/src/language.rs @@ -727,9 +727,12 @@ pub struct LanguageConfig { /// used for comment continuations on the next line, but only the first one is used for Editor::ToggleComments. #[serde(default)] pub line_comments: Vec>, - /// Starting and closing characters of a block comment. + /// Delimiters and configuration for recognizing and formatting block comments. #[serde(default)] - pub block_comment: Option<(Arc, Arc)>, + pub block_comment: Option, + /// Delimiters and configuration for recognizing and formatting documentation comments. + #[serde(default, alias = "documentation")] + pub documentation_comment: Option, /// A list of additional regex patterns that should be treated as prefixes /// for creating boundaries during rewrapping, ensuring content from one /// prefixed section doesn't merge with another (e.g., markdown list items). @@ -774,10 +777,6 @@ pub struct LanguageConfig { /// A list of preferred debuggers for this language. #[serde(default)] pub debuggers: IndexSet, - /// Whether to treat documentation comment of this language differently by - /// auto adding prefix on new line, adjusting the indenting , etc. - #[serde(default)] - pub documentation: Option, } #[derive(Clone, Debug, Deserialize, Default, JsonSchema)] @@ -837,17 +836,56 @@ pub struct JsxTagAutoCloseConfig { pub erroneous_close_tag_name_node_name: Option, } -/// The configuration for documentation block for this language. -#[derive(Clone, Deserialize, JsonSchema)] -pub struct DocumentationConfig { - /// A start tag of documentation block. +/// The configuration for block comments for this language. +#[derive(Clone, Debug, JsonSchema, PartialEq)] +pub struct BlockCommentConfig { + /// A start tag of block comment. pub start: Arc, - /// A end tag of documentation block. + /// A end tag of block comment. pub end: Arc, - /// A character to add as a prefix when a new line is added to a documentation block. + /// A character to add as a prefix when a new line is added to a block comment. pub prefix: Arc, /// A indent to add for prefix and end line upon new line. - pub tab_size: NonZeroU32, + pub tab_size: u32, +} + +impl<'de> Deserialize<'de> for BlockCommentConfig { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + #[derive(Deserialize)] + #[serde(untagged)] + enum BlockCommentConfigHelper { + New { + start: Arc, + end: Arc, + prefix: Arc, + tab_size: u32, + }, + Old([Arc; 2]), + } + + match BlockCommentConfigHelper::deserialize(deserializer)? { + BlockCommentConfigHelper::New { + start, + end, + prefix, + tab_size, + } => Ok(BlockCommentConfig { + start, + end, + prefix, + tab_size, + }), + BlockCommentConfigHelper::Old([start, end]) => Ok(BlockCommentConfig { + start, + end, + prefix: "".into(), + tab_size: 0, + }), + } + } } /// Represents a language for the given range. Some languages (e.g. HTML) @@ -864,7 +902,7 @@ pub struct LanguageConfigOverride { #[serde(default)] pub line_comments: Override>>, #[serde(default)] - pub block_comment: Override<(Arc, Arc)>, + pub block_comment: Override, #[serde(skip)] pub disabled_bracket_ixs: Vec, #[serde(default)] @@ -916,6 +954,7 @@ impl Default for LanguageConfig { autoclose_before: Default::default(), line_comments: Default::default(), block_comment: Default::default(), + documentation_comment: Default::default(), rewrap_prefixes: Default::default(), scope_opt_in_language_servers: Default::default(), overrides: Default::default(), @@ -929,7 +968,6 @@ impl Default for LanguageConfig { jsx_tag_auto_close: None, completion_query_characters: Default::default(), debuggers: Default::default(), - documentation: None, } } } @@ -1847,12 +1885,17 @@ impl LanguageScope { .map_or([].as_slice(), |e| e.as_slice()) } - pub fn block_comment_delimiters(&self) -> Option<(&Arc, &Arc)> { + /// Config for block comments for this language. + pub fn block_comment(&self) -> Option<&BlockCommentConfig> { Override::as_option( self.config_override().map(|o| &o.block_comment), self.language.config.block_comment.as_ref(), ) - .map(|e| (&e.0, &e.1)) + } + + /// Config for documentation-style block comments for this language. + pub fn documentation_comment(&self) -> Option<&BlockCommentConfig> { + self.language.config.documentation_comment.as_ref() } /// Returns additional regex patterns that act as prefix markers for creating @@ -1897,14 +1940,6 @@ impl LanguageScope { .unwrap_or(false) } - /// Returns config to documentation block for this language. - /// - /// Used for documentation styles that require a leading character on each line, - /// such as the asterisk in JSDoc, Javadoc, etc. - pub fn documentation(&self) -> Option<&DocumentationConfig> { - self.language.config.documentation.as_ref() - } - /// Returns a list of bracket pairs for a given language with an additional /// piece of information about whether the particular bracket pair is currently active for a given language. pub fn brackets(&self) -> impl Iterator { @@ -2299,6 +2334,7 @@ pub fn range_from_lsp(range: lsp::Range) -> Range> { mod tests { use super::*; use gpui::TestAppContext; + use pretty_assertions::assert_matches; #[gpui::test(iterations = 10)] async fn test_language_loading(cx: &mut TestAppContext) { @@ -2460,4 +2496,75 @@ mod tests { "LSP completion items with duplicate label and detail, should omit the detail" ); } + + #[test] + fn test_deserializing_comments_backwards_compat() { + // current version of `block_comment` and `documentation_comment` work + { + let config: LanguageConfig = ::toml::from_str( + r#" + name = "Foo" + block_comment = { start = "a", end = "b", prefix = "c", tab_size = 1 } + documentation_comment = { start = "d", end = "e", prefix = "f", tab_size = 2 } + "#, + ) + .unwrap(); + assert_matches!(config.block_comment, Some(BlockCommentConfig { .. })); + assert_matches!( + config.documentation_comment, + Some(BlockCommentConfig { .. }) + ); + + let block_config = config.block_comment.unwrap(); + assert_eq!(block_config.start.as_ref(), "a"); + assert_eq!(block_config.end.as_ref(), "b"); + assert_eq!(block_config.prefix.as_ref(), "c"); + assert_eq!(block_config.tab_size, 1); + + let doc_config = config.documentation_comment.unwrap(); + assert_eq!(doc_config.start.as_ref(), "d"); + assert_eq!(doc_config.end.as_ref(), "e"); + assert_eq!(doc_config.prefix.as_ref(), "f"); + assert_eq!(doc_config.tab_size, 2); + } + + // former `documentation` setting is read into `documentation_comment` + { + let config: LanguageConfig = ::toml::from_str( + r#" + name = "Foo" + documentation = { start = "a", end = "b", prefix = "c", tab_size = 1} + "#, + ) + .unwrap(); + assert_matches!( + config.documentation_comment, + Some(BlockCommentConfig { .. }) + ); + + let config = config.documentation_comment.unwrap(); + assert_eq!(config.start.as_ref(), "a"); + assert_eq!(config.end.as_ref(), "b"); + assert_eq!(config.prefix.as_ref(), "c"); + assert_eq!(config.tab_size, 1); + } + + // old block_comment format is read into BlockCommentConfig + { + let config: LanguageConfig = ::toml::from_str( + r#" + name = "Foo" + block_comment = ["a", "b"] + "#, + ) + .unwrap(); + assert_matches!(config.block_comment, Some(BlockCommentConfig { .. })); + + let config = config.block_comment.unwrap(); + assert_eq!(config.start.as_ref(), "a"); + assert_eq!(config.end.as_ref(), "b"); + assert_eq!(config.prefix.as_ref(), ""); + assert_eq!(config.tab_size, 0); + } + } } diff --git a/crates/languages/src/c/config.toml b/crates/languages/src/c/config.toml index 78213da5be..74290fd9e2 100644 --- a/crates/languages/src/c/config.toml +++ b/crates/languages/src/c/config.toml @@ -16,4 +16,4 @@ brackets = [ { start = "/*", end = " */", close = true, newline = false, not_in = ["string", "comment"] }, ] debuggers = ["CodeLLDB", "GDB"] -documentation = { start = "/*", end = "*/", prefix = "* ", tab_size = 1 } +documentation_comment = { start = "/*", prefix = "* ", end = "*/", tab_size = 1 } diff --git a/crates/languages/src/cpp/config.toml b/crates/languages/src/cpp/config.toml index 1e28381605..fab88266d7 100644 --- a/crates/languages/src/cpp/config.toml +++ b/crates/languages/src/cpp/config.toml @@ -16,4 +16,4 @@ brackets = [ { start = "/*", end = " */", close = true, newline = false, not_in = ["string", "comment"] }, ] debuggers = ["CodeLLDB", "GDB"] -documentation = { start = "/*", end = "*/", prefix = "* ", tab_size = 1 } +documentation_comment = { start = "/*", prefix = "* ", end = "*/", tab_size = 1 } diff --git a/crates/languages/src/css/config.toml b/crates/languages/src/css/config.toml index 0e0b7315e0..a2ca96e76d 100644 --- a/crates/languages/src/css/config.toml +++ b/crates/languages/src/css/config.toml @@ -10,5 +10,5 @@ brackets = [ { start = "'", end = "'", close = true, newline = false, not_in = ["string", "comment"] }, ] completion_query_characters = ["-"] -block_comment = ["/* ", " */"] +block_comment = { start = "/*", prefix = "* ", end = "*/", tab_size = 1 } prettier_parser_name = "css" diff --git a/crates/languages/src/go/config.toml b/crates/languages/src/go/config.toml index 84e35d8f0f..0a5122c038 100644 --- a/crates/languages/src/go/config.toml +++ b/crates/languages/src/go/config.toml @@ -15,4 +15,4 @@ brackets = [ tab_size = 4 hard_tabs = true debuggers = ["Delve"] -documentation = { start = "/*", end = "*/", prefix = "* ", tab_size = 1 } +documentation_comment = { start = "/*", prefix = "* ", end = "*/", tab_size = 1 } diff --git a/crates/languages/src/javascript/config.toml b/crates/languages/src/javascript/config.toml index ac87a9befd..0df57d985e 100644 --- a/crates/languages/src/javascript/config.toml +++ b/crates/languages/src/javascript/config.toml @@ -4,7 +4,8 @@ path_suffixes = ["js", "jsx", "mjs", "cjs"] # [/ ] is so we match "env node" or "/node" but not "ts-node" first_line_pattern = '^#!.*\b(?:[/ ]node|deno run.*--ext[= ]js)\b' line_comments = ["// "] -block_comment = ["/*", "*/"] +block_comment = { start = "/*", prefix = "* ", end = "*/", tab_size = 1 } +documentation_comment = { start = "/**", prefix = "* ", end = "*/", tab_size = 1 } autoclose_before = ";:.,=}])>" brackets = [ { start = "{", end = "}", close = true, newline = true }, @@ -21,7 +22,6 @@ tab_size = 2 scope_opt_in_language_servers = ["tailwindcss-language-server", "emmet-language-server"] prettier_parser_name = "babel" debuggers = ["JavaScript"] -documentation = { start = "/**", end = "*/", prefix = "* ", tab_size = 1 } [jsx_tag_auto_close] open_tag_node_name = "jsx_opening_element" @@ -31,7 +31,7 @@ tag_name_node_name = "identifier" [overrides.element] line_comments = { remove = true } -block_comment = ["{/* ", " */}"] +block_comment = { start = "{/* ", prefix = "", end = "*/}", tab_size = 0 } opt_into_language_servers = ["emmet-language-server"] [overrides.string] diff --git a/crates/languages/src/markdown/config.toml b/crates/languages/src/markdown/config.toml index 059e52de94..926dcd70d9 100644 --- a/crates/languages/src/markdown/config.toml +++ b/crates/languages/src/markdown/config.toml @@ -2,7 +2,7 @@ name = "Markdown" grammar = "markdown" path_suffixes = ["md", "mdx", "mdwn", "markdown", "MD"] completion_query_characters = ["-"] -block_comment = [""] +block_comment = { start = "", tab_size = 0 } autoclose_before = ";:.,=}])>" brackets = [ { start = "{", end = "}", close = true, newline = true }, diff --git a/crates/languages/src/rust/config.toml b/crates/languages/src/rust/config.toml index b55b6da4ab..fe8b4ffdcb 100644 --- a/crates/languages/src/rust/config.toml +++ b/crates/languages/src/rust/config.toml @@ -16,4 +16,4 @@ brackets = [ ] collapsed_placeholder = " /* ... */ " debuggers = ["CodeLLDB", "GDB"] -documentation = { start = "/*", end = "*/", prefix = "* ", tab_size = 1 } +documentation_comment = { start = "/*", prefix = "* ", end = "*/", tab_size = 1 } diff --git a/crates/languages/src/tsx/config.toml b/crates/languages/src/tsx/config.toml index 4176e62215..5849b9842f 100644 --- a/crates/languages/src/tsx/config.toml +++ b/crates/languages/src/tsx/config.toml @@ -2,7 +2,8 @@ name = "TSX" grammar = "tsx" path_suffixes = ["tsx"] line_comments = ["// "] -block_comment = ["/*", "*/"] +block_comment = { start = "/*", prefix = "* ", end = "*/", tab_size = 1 } +documentation_comment = { start = "/**", prefix = "* ", end = "*/", tab_size = 1 } autoclose_before = ";:.,=}])>" brackets = [ { start = "{", end = "}", close = true, newline = true }, @@ -19,7 +20,6 @@ scope_opt_in_language_servers = ["tailwindcss-language-server", "emmet-language- prettier_parser_name = "typescript" tab_size = 2 debuggers = ["JavaScript"] -documentation = { start = "/**", end = "*/", prefix = "* ", tab_size = 1 } [jsx_tag_auto_close] open_tag_node_name = "jsx_opening_element" @@ -30,7 +30,7 @@ tag_name_node_name_alternates = ["member_expression"] [overrides.element] line_comments = { remove = true } -block_comment = ["{/* ", " */}"] +block_comment = { start = "{/*", prefix = "", end = "*/}", tab_size = 0 } opt_into_language_servers = ["emmet-language-server"] [overrides.string] diff --git a/crates/languages/src/typescript/config.toml b/crates/languages/src/typescript/config.toml index db0f32aa0d..d7e3e4bd3d 100644 --- a/crates/languages/src/typescript/config.toml +++ b/crates/languages/src/typescript/config.toml @@ -3,7 +3,8 @@ grammar = "typescript" path_suffixes = ["ts", "cts", "mts"] first_line_pattern = '^#!.*\b(?:deno run|ts-node|bun|tsx|[/ ]node)\b' line_comments = ["// "] -block_comment = ["/*", "*/"] +block_comment = { start = "/*", prefix = "* ", end = "*/", tab_size = 1 } +documentation_comment = { start = "/**", prefix = "* ", end = "*/", tab_size = 1 } autoclose_before = ";:.,=}])>" brackets = [ { start = "{", end = "}", close = true, newline = true }, @@ -19,7 +20,6 @@ word_characters = ["#", "$"] prettier_parser_name = "typescript" tab_size = 2 debuggers = ["JavaScript"] -documentation = { start = "/**", end = "*/", prefix = "* ", tab_size = 1 } [overrides.string] completion_query_characters = ["."] diff --git a/extensions/glsl/languages/glsl/config.toml b/extensions/glsl/languages/glsl/config.toml index 0144e981cc..0c71419c91 100644 --- a/extensions/glsl/languages/glsl/config.toml +++ b/extensions/glsl/languages/glsl/config.toml @@ -12,7 +12,7 @@ path_suffixes = [ ] first_line_pattern = '^#version \d+' line_comments = ["// "] -block_comment = ["/* ", " */"] +block_comment = { start = "/* ", prefix = "* ", end = "*/", tab_size = 1 } brackets = [ { start = "{", end = "}", close = true, newline = true }, { start = "[", end = "]", close = true, newline = true }, diff --git a/extensions/html/languages/html/config.toml b/extensions/html/languages/html/config.toml index 6f52cc8f65..f74db2888e 100644 --- a/extensions/html/languages/html/config.toml +++ b/extensions/html/languages/html/config.toml @@ -2,7 +2,7 @@ name = "HTML" grammar = "html" path_suffixes = ["html", "htm", "shtml"] autoclose_before = ">})" -block_comment = [""] +block_comment = { start = "", tab_size = 0 } brackets = [ { start = "{", end = "}", close = true, newline = true }, { start = "[", end = "]", close = true, newline = true },