From 36731ba6b3a046ce28a9652d7fe6fbd646914d29 Mon Sep 17 00:00:00 2001 From: Julia Date: Thu, 19 Oct 2023 01:54:42 -0400 Subject: [PATCH] Magic incantations for Tailwind autocomplete in Svelte, Elixir ~H, Heex --- crates/zed/src/languages.rs | 17 ++++++++++++----- crates/zed/src/languages/elixir/config.toml | 5 +++++ crates/zed/src/languages/heex/config.toml | 5 +++++ crates/zed/src/languages/heex/overrides.scm | 4 ++++ crates/zed/src/languages/svelte/config.toml | 7 ++++--- crates/zed/src/languages/svelte/overrides.scm | 7 +++++++ crates/zed/src/languages/tailwind.rs | 3 +++ 7 files changed, 40 insertions(+), 8 deletions(-) create mode 100644 crates/zed/src/languages/heex/overrides.scm create mode 100644 crates/zed/src/languages/svelte/overrides.scm diff --git a/crates/zed/src/languages.rs b/crates/zed/src/languages.rs index caf3cbf7c9..e5b3dfdcae 100644 --- a/crates/zed/src/languages.rs +++ b/crates/zed/src/languages.rs @@ -76,7 +76,10 @@ pub fn init( elixir::ElixirLspSetting::ElixirLs => language( "elixir", tree_sitter_elixir::language(), - vec![Arc::new(elixir::ElixirLspAdapter)], + vec![ + Arc::new(elixir::ElixirLspAdapter), + Arc::new(tailwind::TailwindLspAdapter::new(node_runtime.clone())), + ], ), elixir::ElixirLspSetting::NextLs => language( "elixir", @@ -101,7 +104,10 @@ pub fn init( language( "heex", tree_sitter_heex::language(), - vec![Arc::new(elixir::ElixirLspAdapter)], + vec![ + Arc::new(elixir::ElixirLspAdapter), + Arc::new(tailwind::TailwindLspAdapter::new(node_runtime.clone())), + ], ); language( "json", @@ -184,9 +190,10 @@ pub fn init( language( "svelte", tree_sitter_svelte::language(), - vec![Arc::new(svelte::SvelteLspAdapter::new( - node_runtime.clone(), - ))], + vec![ + Arc::new(svelte::SvelteLspAdapter::new(node_runtime.clone())), + Arc::new(tailwind::TailwindLspAdapter::new(node_runtime.clone())), + ], ); language( "php", diff --git a/crates/zed/src/languages/elixir/config.toml b/crates/zed/src/languages/elixir/config.toml index 05c126e9da..8983c0e49b 100644 --- a/crates/zed/src/languages/elixir/config.toml +++ b/crates/zed/src/languages/elixir/config.toml @@ -9,3 +9,8 @@ brackets = [ { start = "\"", end = "\"", close = true, newline = false, not_in = ["string", "comment"] }, { start = "'", end = "'", close = true, newline = false, not_in = ["string", "comment"] }, ] +scope_opt_in_language_servers = ["tailwindcss-language-server"] + +[overrides.string] +word_characters = ["-"] +opt_into_language_servers = ["tailwindcss-language-server"] diff --git a/crates/zed/src/languages/heex/config.toml b/crates/zed/src/languages/heex/config.toml index c9f952ee3c..74cb5ac9ff 100644 --- a/crates/zed/src/languages/heex/config.toml +++ b/crates/zed/src/languages/heex/config.toml @@ -5,3 +5,8 @@ brackets = [ { start = "<", end = ">", close = true, newline = true }, ] block_comment = ["<%!-- ", " --%>"] +scope_opt_in_language_servers = ["tailwindcss-language-server"] + +[overrides.string] +word_characters = ["-"] +opt_into_language_servers = ["tailwindcss-language-server"] diff --git a/crates/zed/src/languages/heex/overrides.scm b/crates/zed/src/languages/heex/overrides.scm new file mode 100644 index 0000000000..35ac9fe15f --- /dev/null +++ b/crates/zed/src/languages/heex/overrides.scm @@ -0,0 +1,4 @@ +[ + (attribute_value) + (quoted_attribute_value) +] @string diff --git a/crates/zed/src/languages/svelte/config.toml b/crates/zed/src/languages/svelte/config.toml index 41bb21a45d..8a07b012c7 100644 --- a/crates/zed/src/languages/svelte/config.toml +++ b/crates/zed/src/languages/svelte/config.toml @@ -12,7 +12,8 @@ brackets = [ { start = "`", end = "`", close = true, newline = false, not_in = ["string"] }, { start = "/*", end = " */", close = true, newline = false, not_in = ["string", "comment"] }, ] +scope_opt_in_language_servers = ["tailwindcss-language-server"] -[overrides.element] -line_comment = { remove = true } -block_comment = ["{/* ", " */}"] +[overrides.string] +word_characters = ["-"] +opt_into_language_servers = ["tailwindcss-language-server"] diff --git a/crates/zed/src/languages/svelte/overrides.scm b/crates/zed/src/languages/svelte/overrides.scm new file mode 100644 index 0000000000..2a76410297 --- /dev/null +++ b/crates/zed/src/languages/svelte/overrides.scm @@ -0,0 +1,7 @@ +(comment) @comment + +[ + (raw_text) + (attribute_value) + (quoted_attribute_value) +] @string diff --git a/crates/zed/src/languages/tailwind.rs b/crates/zed/src/languages/tailwind.rs index 8e81f728dc..ef19b858be 100644 --- a/crates/zed/src/languages/tailwind.rs +++ b/crates/zed/src/languages/tailwind.rs @@ -123,6 +123,9 @@ impl LspAdapter for TailwindLspAdapter { ("CSS".to_string(), "css".to_string()), ("JavaScript".to_string(), "javascript".to_string()), ("TSX".to_string(), "typescriptreact".to_string()), + ("Svelte".to_string(), "svelte".to_string()), + ("Elixir".to_string(), "phoenix-heex".to_string()), + ("HEEX".to_string(), "phoenix-heex".to_string()), ] .into_iter(), )