From 5ecb6fe32ca57c30b5507c63fe62c32581b2ddea Mon Sep 17 00:00:00 2001 From: Mike Vink Date: Mon, 30 Oct 2023 13:21:42 +0100 Subject: add rust template --- mut/neovim/fnl/conf/init.fnl | 4 +-- mut/neovim/fnl/conf/pkgs/cmp.fnl | 2 +- templates/rust/.envrc | 4 +++ templates/rust/flake.nix | 56 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 templates/rust/.envrc create mode 100644 templates/rust/flake.nix diff --git a/mut/neovim/fnl/conf/init.fnl b/mut/neovim/fnl/conf/init.fnl index 689769d..2b658b8 100644 --- a/mut/neovim/fnl/conf/init.fnl +++ b/mut/neovim/fnl/conf/init.fnl @@ -27,7 +27,7 @@ {:mappings {:i {"" actions.select_all}}})}) -(local cope #(vim.cmd (.. ":copen " (math.floor (/ vim.o.lines 2.6))))) +(local cope #(vim.cmd (.. ":copen " (math.floor (/ vim.o.lines 2.1))))) (let [map vim.keymap.set] (map :v :y "OSCYankVisual|gvy") (map :n :qf cope) @@ -121,7 +121,7 @@ (if (not= (vim.fn.winnr) winnr) (do (vim.notify "going back") - (vim.cmd "wincmd p")))) + (vim.cmd "wincmd p | cbot")))) (vim.notify (.. "\"" cmd "\" succeeded!"))))})) (set last_job diff --git a/mut/neovim/fnl/conf/pkgs/cmp.fnl b/mut/neovim/fnl/conf/pkgs/cmp.fnl index 0a22f23..a60ee02 100644 --- a/mut/neovim/fnl/conf/pkgs/cmp.fnl +++ b/mut/neovim/fnl/conf/pkgs/cmp.fnl @@ -50,7 +50,7 @@ : (cmp.mapping.scroll_docs 4) : (cmp.mapping.complete) : (cmp.mapping.confirm {:behavior (enum :ConfirmBehavior - :Replace) + :Insert) :select true})} :sources (cmp.config.sources [{:name :nvim_lsp} {:name :path} diff --git a/templates/rust/.envrc b/templates/rust/.envrc new file mode 100644 index 0000000..1305de8 --- /dev/null +++ b/templates/rust/.envrc @@ -0,0 +1,4 @@ +if ! has nix_direnv_version || ! nix_direnv_version 2.2.0; then + source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.2.0/direnvrc" "sha256-5EwyKnkJNQeXrRkYbwwRBcXbibosCJqyIUuz9Xq+LRc=" +fi +use flake diff --git a/templates/rust/flake.nix b/templates/rust/flake.nix new file mode 100644 index 0000000..8a75f83 --- /dev/null +++ b/templates/rust/flake.nix @@ -0,0 +1,56 @@ +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + flake-parts.url = "github:hercules-ci/flake-parts"; + systems.url = "github:nix-systems/default"; + treefmt-nix.url = "github:numtide/treefmt-nix"; + }; + + outputs = inputs: + inputs.flake-parts.lib.mkFlake { inherit inputs; } { + systems = import inputs.systems; + imports = [ + inputs.treefmt-nix.flakeModule + ]; + perSystem = { config, self', pkgs, lib, system, ... }: + let + nonRustDeps = [ + pkgs.libiconv + ]; + in + { + # Rust dev environment + devShells.default = pkgs.mkShell { + inputsFrom = [ + config.treefmt.build.devShell + ]; + shellHook = '' + # For rust-analyzer 'hover' tooltips to work. + export RUST_SRC_PATH=${pkgs.rustPlatform.rustLibSrc} + + echo + echo "🍎🍎 Run 'just ' to get started" + just + ''; + buildInputs = nonRustDeps; + nativeBuildInputs = with pkgs; [ + just + rustc + cargo + cargo-watch + rust-analyzer + ]; + }; + + # Add your auto-formatters here. + # cf. https://numtide.github.io/treefmt/ + treefmt.config = { + projectRootFile = "flake.nix"; + programs = { + nixpkgs-fmt.enable = true; + rustfmt.enable = true; + }; + }; + }; + }; +} -- cgit v1.2.3