Skip to content

Commit

Permalink
Merge pull request #104 from brack-lang/feat/#46-check_formatted
Browse files Browse the repository at this point in the history
feat: check formatted ci
  • Loading branch information
momeemt authored Oct 23, 2024
2 parents 2a1caf3 + ceb01e7 commit 271d307
Show file tree
Hide file tree
Showing 14 changed files with 49 additions and 18 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ on:
- '**/*.md'

jobs:
cargo-fmt:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v27
- uses: cachix/cachix-action@v15
with:
name: brack-lang
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: nix build ".#cargo-fmt"
test:
runs-on: ubuntu-22.04
steps:
Expand Down
1 change: 0 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ fn main() {
eprintln!("Failed to read VERSION file");
}
}

6 changes: 5 additions & 1 deletion crates/brack-codegen/src/curly.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
use anyhow::Result;
use brack_plugin::{plugins::Plugins, types::{arg_counter, Type}, value::Value};
use brack_plugin::{
plugins::Plugins,
types::{arg_counter, Type},
value::Value,
};
use brack_transformer::ast::AST;

use crate::{expr, square, text};
Expand Down
6 changes: 5 additions & 1 deletion crates/brack-codegen/src/square.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
use anyhow::Result;
use brack_plugin::{plugins::Plugins, types::{arg_counter, Type}, value::Value};
use brack_plugin::{
plugins::Plugins,
types::{arg_counter, Type},
value::Value,
};
use brack_transformer::ast::AST;

use crate::{curly, expr, text};
Expand Down
5 changes: 4 additions & 1 deletion crates/brack-codegen/src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ use brack_plugin::{plugins::Plugins, value::Value};
use brack_transformer::ast::AST;

pub(crate) fn generate(ast: &AST, plugins: &mut Plugins) -> Result<String> {
let result = ast.value().ok_or_else(|| anyhow::anyhow!("No value found"))?.to_string();
let result = ast
.value()
.ok_or_else(|| anyhow::anyhow!("No value found"))?
.to_string();
let hook_result = plugins.call_text_hook(vec![Value::Text(result.clone())])?;
match hook_result {
Some(result) => Ok(result),
Expand Down
3 changes: 2 additions & 1 deletion crates/brack-expander/src/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ fn expand_angle(overall_ast: &AST, ast: &AST, plugins: &mut Plugins) -> Result<A
}
}

let new_ast = plugins.call_macro_command(&module_name, &ident_name, overall_ast.clone(), ast.id())?;
let new_ast =
plugins.call_macro_command(&module_name, &ident_name, overall_ast.clone(), ast.id())?;
Ok(new_ast)
}

Expand Down
2 changes: 1 addition & 1 deletion crates/brack-language-server/src/notification/did_open.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ impl Server {
.uri
.to_file_path()
.map_err(|_| anyhow::anyhow!("Invalid file path"))?;

// root/docs/file.[] -> root
let root = file_path
.parent()
Expand Down
5 changes: 4 additions & 1 deletion crates/brack-language-server/src/request.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use anyhow::Result;
use lsp_types::{
CompletionOptions, CompletionParams, InitializeParams, InitializeResult, SemanticTokenModifier, SemanticTokenType, SemanticTokensFullOptions, SemanticTokensLegend, SemanticTokensOptions, SemanticTokensParams, SemanticTokensServerCapabilities, ServerCapabilities, ServerInfo, TextDocumentSyncCapability, TextDocumentSyncKind
CompletionOptions, CompletionParams, InitializeParams, InitializeResult, SemanticTokenModifier,
SemanticTokenType, SemanticTokensFullOptions, SemanticTokensLegend, SemanticTokensOptions,
SemanticTokensParams, SemanticTokensServerCapabilities, ServerCapabilities, ServerInfo,
TextDocumentSyncCapability, TextDocumentSyncKind,
};
use serde::Deserialize;
use serde_json::Value;
Expand Down
2 changes: 1 addition & 1 deletion crates/brack-language-server/src/request/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl Server {
) -> Result<Option<CompletionResponse>> {
if self.project.is_none() {
// BLS doesn't support single-file mode now.
return Ok(None)
return Ok(None);
}
let project = self.project.as_ref().unwrap();
let mut completion_items = vec![];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fn token_kind_to_type(token: &Token) -> u32 {
Token::AngleBracketOpen(_) | Token::AngleBracketClose(_) => SemanticTokenType::MACRO,
Token::CurlyBracketOpen(_) | Token::CurlyBracketClose(_) => SemanticTokenType::METHOD,
Token::SquareBracketOpen(_) | Token::SquareBracketClose(_) => SemanticTokenType::FUNCTION,
_ => return 100 // no decoration
_ => return 100, // no decoration
};
token_type_as_u32(typ)
}
Expand Down
6 changes: 0 additions & 6 deletions crates/brack-parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,3 @@ features = ["v4", "fast-rng", "macro-diagnostics", "serde"]
[features]
default = []
debug = []

[[bin]]
name = "debug_parse"
path = "src/debug/debug_parse.rs"
required-features = ["debug"]

2 changes: 1 addition & 1 deletion crates/brack-plugin/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub mod feature_flag;
pub mod metadata;
pub mod plugin;
pub mod plugins;
pub mod metadata;
pub mod types;
pub mod value;
9 changes: 7 additions & 2 deletions crates/brack-plugin/src/plugins.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{collections::HashMap};
use std::collections::HashMap;

use anyhow::Result;
use brack_transformer::ast::AST;
Expand Down Expand Up @@ -61,7 +61,12 @@ impl Plugins {
})
}

pub fn argument_types(&self, module_name: &str, command_name: &str, typ: Type) -> Result<Vec<(String, Type)>> {
pub fn argument_types(
&self,
module_name: &str,
command_name: &str,
typ: Type,
) -> Result<Vec<(String, Type)>> {
let plugin = self
.name_to_plugin
.get(module_name)
Expand Down
8 changes: 8 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@
};
})
workspaceMemberNames);
packages.cargo-fmt =
pkgs.runCommand "cargo-fmt-check" {
buildInputs = with pkgs; [cargo rustfmt];
src = ./.;
} ''
mkdir -p $out
cargo fmt --all --check --manifest-path $src/Cargo.toml
'';
packages.brack = generatedBuild.workspaceMembers."brack".build;
packages.default = packages.brack;
apps.${system}.default = {
Expand Down

0 comments on commit 271d307

Please sign in to comment.