Tweak HTML indents and highlights

Max Brunsfeld created

Change summary

crates/language/src/buffer.rs                | 2 ++
crates/language/src/language.rs              | 4 ++++
crates/zed/src/languages/html/highlights.scm | 4 ++++
crates/zed/src/languages/html/indents.scm    | 7 ++++++-
crates/zed/src/languages/html/injections.scm | 1 -
5 files changed, 16 insertions(+), 2 deletions(-)

Detailed changes

crates/language/src/buffer.rs 🔗

@@ -1631,6 +1631,8 @@ impl BufferSnapshot {
                 if capture.index == config.indent_capture_ix {
                     start.get_or_insert(Point::from_ts_point(capture.node.start_position()));
                     end.get_or_insert(Point::from_ts_point(capture.node.end_position()));
+                } else if Some(capture.index) == config.start_capture_ix {
+                    start = Some(Point::from_ts_point(capture.node.end_position()));
                 } else if Some(capture.index) == config.end_capture_ix {
                     end = Some(Point::from_ts_point(capture.node.start_position()));
                 }

crates/language/src/language.rs 🔗

@@ -304,6 +304,7 @@ pub struct Grammar {
 struct IndentConfig {
     query: Query,
     indent_capture_ix: u32,
+    start_capture_ix: Option<u32>,
     end_capture_ix: Option<u32>,
 }
 
@@ -661,11 +662,13 @@ impl Language {
         let grammar = self.grammar_mut();
         let query = Query::new(grammar.ts_language, source)?;
         let mut indent_capture_ix = None;
+        let mut start_capture_ix = None;
         let mut end_capture_ix = None;
         get_capture_indices(
             &query,
             &mut [
                 ("indent", &mut indent_capture_ix),
+                ("start", &mut start_capture_ix),
                 ("end", &mut end_capture_ix),
             ],
         );
@@ -673,6 +676,7 @@ impl Language {
             grammar.indents_config = Some(IndentConfig {
                 query,
                 indent_capture_ix,
+                start_capture_ix,
                 end_capture_ix,
             });
         }

crates/zed/src/languages/html/highlights.scm 🔗

@@ -1,11 +1,15 @@
 (tag_name) @keyword
+(erroneous_end_tag_name) @keyword
 (doctype) @constant
 (attribute_name) @property
 (attribute_value) @string
 (comment) @comment
 
+"=" @operator
+
 [
   "<"
   ">"
   "</"
+  "/>"
 ] @punctuation.bracket