Skip to content

Commit

Permalink
feat: use macros to build completions statically (#34)
Browse files Browse the repository at this point in the history
* feat: use macros to build completions statically

* fix: remove references to init_hx_tags

* fix: satisfy clippy warnings

* refactor: coerce sized slice to normal slice, eliminate enum

* feat: add hx-disable-elt

* fix: macro bickers with trailing comma

* fix: typo at hx-disabled-elt
  • Loading branch information
lavafroth committed Dec 9, 2023
1 parent 1f4071f commit 9cbd8d9
Show file tree
Hide file tree
Showing 5 changed files with 234 additions and 227 deletions.
64 changes: 64 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lsp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ htmx-lsp-util = { version = "0.1", path = "../util" }
tree-sitter.workspace = true
tree-sitter-html.workspace = true
maplit = "1.0.2"
phf = { version = "0.11.2", features = ["macros"] }
6 changes: 2 additions & 4 deletions lsp/src/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ fn handle_completion(req: Request) -> Option<HtmxResult> {
);

Some(HtmxResult::AttributeCompletion(HtmxAttributeCompletion {
items,
items: items.to_vec(),
id: req.id,
}))
}
Expand All @@ -154,7 +154,7 @@ fn handle_hover(req: Request) -> Option<HtmxResult> {

Some(HtmxResult::AttributeHover(HtmxAttributeHoverResult {
id: req.id,
value: attribute.desc,
value: attribute.desc.to_string(),
}))
}

Expand Down Expand Up @@ -189,14 +189,12 @@ pub fn handle_other(msg: Message) -> Option<HtmxResult> {
#[cfg(test)]
mod tests {
use super::{handle_request, HtmxResult, Request};
use crate::htmx;
use crate::text_store::{init_text_store, TEXT_STORE};
use std::sync::Once;

static SETUP: Once = Once::new();
fn prepare_store(file: &str, content: &str) {
SETUP.call_once(|| {
htmx::init_hx_tags();
init_text_store();
});

Expand Down

0 comments on commit 9cbd8d9

Please sign in to comment.