From 2c324ccaf7e6f0ee60ee62f2cdf2a07862f5c411 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cyryl=20P=C5=82otnicki?= Date: Mon, 19 Dec 2022 09:04:27 +0000 Subject: [PATCH] basic autoformat in helix --- flake.lock | 79 +++++++++++++++++++++++++++ flake.nix | 10 +++- nixos/home-manager/programs/helix.nix | 35 +++++++++--- 3 files changed, 114 insertions(+), 10 deletions(-) diff --git a/flake.lock b/flake.lock index b18a7e10..753f43df 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,28 @@ { "nodes": { + "alejandra": { + "inputs": { + "fenix": "fenix", + "flakeCompat": "flakeCompat", + "nixpkgs": [ + "nixpkgs-nixos-unstable" + ] + }, + "locked": { + "lastModified": 1668317688, + "narHash": "sha256-wC04cwcKyV2TUYXqMibFWkq7WOMIXHw5DrfAJrWHzgI=", + "owner": "kamadorueda", + "repo": "alejandra", + "rev": "378cde949be70caea431682756b36552a58e965d", + "type": "github" + }, + "original": { + "owner": "kamadorueda", + "ref": "main", + "repo": "alejandra", + "type": "github" + } + }, "crane": { "flake": false, "locked": { @@ -113,6 +136,28 @@ "type": "github" } }, + "fenix": { + "inputs": { + "nixpkgs": [ + "alejandra", + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1668234453, + "narHash": "sha256-FmuZThToBvRsqCauYJ3l8HJoGLAY5cMULeYEKIaGrRw=", + "owner": "nix-community", + "repo": "fenix", + "rev": "8f219f6b36e8d0d56afa7f67e6e3df63ef013cdb", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, "flake-compat": { "flake": false, "locked": { @@ -160,6 +205,22 @@ "type": "github" } }, + "flakeCompat": { + "flake": false, + "locked": { + "lastModified": 1650374568, + "narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "b4a34015c698c7793d592d66adbab377907a2be8", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "helix": { "inputs": { "nci": "nci", @@ -339,6 +400,7 @@ }, "root": { "inputs": { + "alejandra": "alejandra", "darwin": "darwin", "flake-compat": "flake-compat", "flake-utils": "flake-utils", @@ -353,6 +415,23 @@ "sops": "sops" } }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1668182250, + "narHash": "sha256-PYGaOCiFvnJdVz+ZCaKF8geGdffXjJUNcMwaBHv0FT4=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "45ec315e01dc8dd1146dfeb65f0ef6e5c2efed78", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + }, "rust-overlay": { "inputs": { "flake-utils": "flake-utils_2", diff --git a/flake.nix b/flake.nix index e6e5b53f..9a340db1 100644 --- a/flake.nix +++ b/flake.nix @@ -2,7 +2,7 @@ description = "NixOS configuration with flakes"; outputs = { self, flake-utils, flake-compat, home-manager , nixpkgs-nixos-unstable, nixpkgs-master, nixpkgs-stable, darwin - , nixos-hardware, nur, sops, nil, helix }@inputs: + , nixos-hardware, nur, sops, nil, helix, alejandra }@inputs: let mkServer = pkgs: system: hostname: @@ -262,7 +262,13 @@ inputs.nixpkgs.follows = "nixpkgs-stable"; inputs.nixpkgs-stable.follows = "nixpkgs-stable"; }; - +alejandra = { + type = "github"; + owner = "kamadorueda"; + repo = "alejandra"; + ref = "main"; + inputs.nixpkgs.follows = "nixpkgs-nixos-unstable"; + }; flake-compat = { url = "github:edolstra/flake-compat"; flake = false; diff --git a/nixos/home-manager/programs/helix.nix b/nixos/home-manager/programs/helix.nix index 2fe21f2a..8b77ad98 100644 --- a/nixos/home-manager/programs/helix.nix +++ b/nixos/home-manager/programs/helix.nix @@ -1,14 +1,33 @@ -{ config, pkgs, lib, inputs, system, ... }: { +{ + config, + pkgs, + lib, + inputs, + system, + ... +}: let + alejandra = lib.getExe inputs.alejandra.packages.${system}.default; + nil = lib.getExe inputs.nil.packages.${system}.default; +in { programs.helix = { enable = true; package = inputs.helix.packages."${system}".helix; - settings = { theme = "solarized_dark"; }; - languages = [{ - name = "nix"; - auto-format = true; - language-server = { - command = "${inputs.nil.packages.${system}.default}/bin/nil"; + settings = { + keys.normal = { + C-p = "file_picker"; + C-b = "buffer_picker"; }; - }]; + }; + languages = [ + { + name = "nix"; + auto-format = true; + language-server = {command = nil;}; + formatter = { + command = alejandra; + args = ["-q"]; + }; + } + ]; }; }