Skip to content

Commit

Permalink
Merge pull request #22 from praveenperera/ci-github-action
Browse files Browse the repository at this point in the history
CI GitHub action
  • Loading branch information
ThePrimeagen committed Sep 27, 2023
2 parents cb9982d + 587562f commit 86d3bf8
Show file tree
Hide file tree
Showing 11 changed files with 281 additions and 254 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: CI
on: [push, pull_request]

jobs:
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: clippy
override: true
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}

- run: cargo clippy -- -D warnings

rustfmt:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install stable toolchain with rustfmt available
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt

- run: cargo fmt --check

test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup Rust env
uses: "./.github/actions/setup-rust-env"

- name: Rust test
run: cargo test --workspace
20 changes: 0 additions & 20 deletions .github/workflows/test.yml

This file was deleted.

21 changes: 10 additions & 11 deletions lsp/src/handle.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::{
htmx::{hx_completion, hx_hover, HxCompletion},
text_store::TEXT_STORE,
tree_sitter::{get_position_from_lsp_completion, Position},
};
use log::{debug, error, warn};
use lsp_server::{Message, Notification, Request, RequestId};
Expand Down Expand Up @@ -78,7 +77,7 @@ fn handle_didChange(noti: Notification) -> Option<HtmxResult> {
.texts
.insert(uri, text);

return None;
None
}

#[allow(non_snake_case)]
Expand All @@ -103,7 +102,7 @@ fn handle_didOpen(noti: Notification) -> Option<HtmxResult> {
text_document_changes.text.to_string(),
);

return None;
None
}

#[allow(non_snake_case)]
Expand Down Expand Up @@ -134,16 +133,16 @@ fn handle_completion(req: Request) -> Option<HtmxResult> {
completion.context, items
);

return Some(HtmxResult::AttributeCompletion(HtmxAttributeCompletion {
Some(HtmxResult::AttributeCompletion(HtmxAttributeCompletion {
items,
id: req.id,
}));
}))
}
_ => {
error!("unhandled completion context: {:?}", completion.context);
return None;
None
}
};
}
}

fn handle_hover(req: Request) -> Option<HtmxResult> {
Expand All @@ -158,10 +157,10 @@ fn handle_hover(req: Request) -> Option<HtmxResult> {

debug!("handle_request attribute: {:?}", attribute);

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

pub fn handle_request(req: Request) -> Option<HtmxResult> {
Expand Down Expand Up @@ -189,7 +188,7 @@ pub fn handle_notification(noti: Notification) -> Option<HtmxResult> {

pub fn handle_other(msg: Message) -> Option<HtmxResult> {
warn!("unhandled message {:?}", msg);
return None;
None
}

#[cfg(test)]
Expand All @@ -200,7 +199,7 @@ mod tests {
use std::sync::Once;

static SETUP: Once = Once::new();
fn prepare_store(file: &str, content: &str) -> () {
fn prepare_store(file: &str, content: &str) {
SETUP.call_once(|| {
htmx::init_hx_tags();
init_text_store();
Expand Down
Loading

0 comments on commit 86d3bf8

Please sign in to comment.