From 95da682a64a3a45453b10ca39dbe29417adb9217 Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Wed, 22 Mar 2023 19:16:57 +0800 Subject: [PATCH] project: add codebase formatter --- flake.nix | 9 +++++++-- shell.nix | 12 +++++++++++- treefmt.toml | 3 +++ 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 treefmt.toml diff --git a/flake.nix b/flake.nix index 23f86b6..faf374a 100644 --- a/flake.nix +++ b/flake.nix @@ -8,8 +8,13 @@ outputs = inputs@{ self, nixpkgs, ... }: let systems = inputs.flake-utils.lib.defaultSystems; - in inputs.flake-utils.lib.eachSystem systems (system: { + in inputs.flake-utils.lib.eachSystem systems (system: let + pkgs = import nixpkgs { inherit system; }; + in + { devShell = - import ./shell.nix { pkgs = import nixpkgs { inherit system; }; }; + import ./shell.nix { inherit pkgs; }; + + formatter = pkgs.treefmt; }); } diff --git a/shell.nix b/shell.nix index e5f13c2..1d94038 100644 --- a/shell.nix +++ b/shell.nix @@ -16,7 +16,17 @@ with pkgs; mkShell { packages = [ python3 - pyright stow + + # Language servers for... + lua-language-server # ...Lua. + pyright # ...Python. + rnix-lsp # ...Nix. + + # Formatters for... + treefmt # ...everything under the sun. + stylua # ...Lua. + nixpkgs-fmt # ...Nix. + black # ...Python. ]; } diff --git a/treefmt.toml b/treefmt.toml new file mode 100644 index 0000000..06a5cc9 --- /dev/null +++ b/treefmt.toml @@ -0,0 +1,3 @@ +[formatter.lua] +command = "stylua" +includes = [ "*.lua" ]