Skip to content

Commit

Permalink
feat: support org sections
Browse files Browse the repository at this point in the history
  • Loading branch information
polarmutex committed Jun 28, 2022
1 parent 78b8ddc commit 1b06224
Show file tree
Hide file tree
Showing 14 changed files with 11,703 additions and 5,839 deletions.
20 changes: 20 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
BasedOnStyle: LLVM
IndentWidth: 4
---
Language: Cpp
# Force pointers to the type for C.
DerivePointerAlignment: false
PointerAlignment: Right

# Short functions should not be on a single line, unless empty
AllowShortFunctionsOnASingleLine: Empty

# It makes more sense this way
BreakBeforeBinaryOperators: All
BreakBeforeTernaryOperators: true

# Aesthetic
AlignOperands: AlignAfterOperator
BinPackParameters: false
---
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
node_modules
build

.direnv
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
67 changes: 67 additions & 0 deletions flake.lock

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

122 changes: 122 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
{
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs = {
url = "github:NixOS/nixpkgs/nixos-unstable";
};
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs = {
flake-utils.follows = "flake-utils";
nixpkgs.follows = "nixpkgs";
};
};
};

outputs = { self, nixpkgs, flake-utils, pre-commit-hooks }:
{ } //
flake-utils.lib.eachDefaultSystem
(
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ self.overlays.default ];
};

tree-sitter-env = pkgs.stdenv.mkDerivation {
name = "tree-sitter-env";

nativeBuildInputs = with pkgs; [
makeWrapper
];

dontUnpack = true;

dontBuild = true;

installPhase = ''
mkdir -p $out/bin
makeWrapper \
${pkgs.tree-sitter}/bin/tree-sitter \
$out/bin/tree-sitter \
--prefix PATH : "${with pkgs; lib.makeBinPath [stdenv.cc nodejs]}"
'';
};

in
rec {
checks = {
pre-commit = pre-commit-hooks.lib.${system}.run {
src = ./.;

hooks = {
clang-format = {
enable = true;
name = "clang-format";
entry = "${pkgs.clang-tools}/bin/clang-format -style=file -i";
types = [ "text" "c" ];
# I don't care for generated files' formatting
excludes = [ "src/parser.c" "src/tree_sitter/parser.h" ];
language = "system";
};

nixpkgs-fmt = {
enable = true;
};

tree-sitter = {
enable = true;
name = "tree-sitter tests";
entry = "${tree-sitter-env}/bin/tree-sitter test";
pass_filenames = false;
};

tree-sitter-files = {
enable = true;
name = "tree-sitter generated files";
entry = "${tree-sitter-env}/bin/tree-sitter generate";
pass_filenames = false;
};
};
};
};

devShells = {
default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
nodejs-16_x
nodePackages.typescript
rustc
cargo
rustfmt
clippy
(tree-sitter.override { webUISupport = true; })
];

inherit (checks.pre-commit) shellHook;
};
};

packages = {
default = packages.tree-sitter-beancount;

inherit (pkgs.tree-sitter.passthru.builtGrammars) tree-sitter-beancount;

inherit (pkgs) tree-sitter;
};
}
) // {
overlays = {
default = final: prev: {
tree-sitter = prev.tree-sitter.override {
extraGrammars = {
tree-sitter-beancount = {
src = ./.;
};
};
};
};
};
};
}
Loading

0 comments on commit 1b06224

Please sign in to comment.