From 30cc4f16e5d433295f92219170fdfb6900e16d0d Mon Sep 17 00:00:00 2001 From: mae Date: Sun, 30 Apr 2023 18:26:56 +0200 Subject: [PATCH] Add support for hexediting to nvim --- users/modules/neovim/default.nix | 1 + users/modules/neovim/hexeditor.nix | 22 ++++++++++++++++++++++ users/profiles/neovim/default.nix | 1 + 3 files changed, 24 insertions(+) create mode 100644 users/modules/neovim/hexeditor.nix diff --git a/users/modules/neovim/default.nix b/users/modules/neovim/default.nix index 90e368d..8cc78bd 100644 --- a/users/modules/neovim/default.nix +++ b/users/modules/neovim/default.nix @@ -14,6 +14,7 @@ in ./clangd.nix ./elixir.nix ./dart.nix + ./hexeditor.nix ]; options.mae.nvim = { diff --git a/users/modules/neovim/hexeditor.nix b/users/modules/neovim/hexeditor.nix new file mode 100644 index 0000000..7685e79 --- /dev/null +++ b/users/modules/neovim/hexeditor.nix @@ -0,0 +1,22 @@ +{ lib, pkgs, config, ... }: +let + cfg = config.mae.nvim.hexeditor; +in +{ + options.mae.nvim.hexeditor.enable = lib.mkEnableOption "Enable hexediting in neovim"; + config = lib.mkIf cfg.enable { + programs.neovim.extraConfig = '' + augroup Binary + au! + au BufReadPre *.bin let &bin=1 + au BufReadPost *.bin if &bin | %!xxd + au BufReadPost *.bin set ft=xxd | endif + au BufWritePre *.bin if &bin | %!xxd -r + au BufWritePre *.bin endif + au BufWritePost *.bin if &bin | %!xxd + au BufWritePost *.bin set nomod | endif + augroup END + ''; + }; +} + diff --git a/users/profiles/neovim/default.nix b/users/profiles/neovim/default.nix index 29a8f39..515a36f 100644 --- a/users/profiles/neovim/default.nix +++ b/users/profiles/neovim/default.nix @@ -12,5 +12,6 @@ python.enable = true; elixir.enable = true; dart.enable = true; + hexeditor.enable = true; }; }