cleaned up warnings and added javascript

KCaverly created

Change summary

crates/vector_store/src/parsing.rs                | 10 ++
crates/vector_store/src/vector_store.rs           |  3 
crates/zed/src/languages/javascript/embedding.scm | 56 +++++++++++++++++
crates/zed/src/languages/tsx/embedding.scm        |  2 
4 files changed, 68 insertions(+), 3 deletions(-)

Detailed changes

crates/vector_store/src/parsing.rs 🔗

@@ -1,4 +1,4 @@
-use std::{ops::Range, path::PathBuf, sync::Arc, time::SystemTime};
+use std::{path::PathBuf, sync::Arc, time::SystemTime};
 
 use anyhow::{anyhow, Ok, Result};
 use project::Fs;
@@ -61,6 +61,8 @@ impl CodeContextRetriever {
             tree.root_node(),
             content.as_bytes(),
         ) {
+            // log::info!("-----MATCH-----");
+
             let mut name: Vec<&str> = vec![];
             let mut item: Option<&str> = None;
             let mut offset: Option<usize> = None;
@@ -89,6 +91,12 @@ impl CodeContextRetriever {
                     .replace("<language>", &pending_file.language.name().to_lowercase())
                     .replace("<item>", item.unwrap());
 
+                let mut truncated_span = context_span.clone();
+                truncated_span.truncate(100);
+
+                // log::info!("Name:       {:?}", name);
+                // log::info!("Span:       {:?}", truncated_span);
+
                 context_spans.push(context_span);
                 documents.push(Document {
                     name: name.join(" "),

crates/vector_store/src/vector_store.rs 🔗

@@ -386,7 +386,8 @@ impl VectorStore {
             let (parsing_files_tx, parsing_files_rx) = channel::unbounded::<PendingFile>();
 
             let mut _parsing_files_tasks = Vec::new();
-            for _ in 0..cx.background().num_cpus() {
+            // for _ in 0..cx.background().num_cpus() {
+            for _ in 0..1 {
                 let fs = fs.clone();
                 let parsing_files_rx = parsing_files_rx.clone();
                 let batch_files_tx = batch_files_tx.clone();

crates/zed/src/languages/javascript/embedding.scm 🔗

@@ -0,0 +1,56 @@
+; (internal_module
+;     "namespace" @context
+;     name: (_) @name) @item
+
+(enum_declaration
+    "enum" @context
+    name: (_) @name) @item
+
+(function_declaration
+    "async"? @context
+    "function" @context
+    name: (_) @name) @item
+
+(interface_declaration
+    "interface" @context
+    name: (_) @name) @item
+
+; (program
+;     (export_statement
+;         (lexical_declaration
+;             ["let" "const"] @context
+;             (variable_declarator
+;                 name: (_) @name) @item)))
+
+(program
+    (lexical_declaration
+        ["let" "const"] @context
+        (variable_declarator
+            name: (_) @name) @item))
+
+(class_declaration
+    "class" @context
+    name: (_) @name) @item
+
+(method_definition
+    [
+        "get"
+        "set"
+        "async"
+        "*"
+        "readonly"
+        "static"
+        (override_modifier)
+        (accessibility_modifier)
+        ]* @context
+    name: (_) @name) @item
+
+; (public_field_definition
+;     [
+;         "declare"
+;         "readonly"
+;         "abstract"
+;         "static"
+;         (accessibility_modifier)
+;         ]* @context
+;     name: (_) @name) @item