devos/users/modules/neovim/hexeditor.nix

23 lines
606 B
Nix
Raw Normal View History

2023-04-30 18:26:56 +02:00
{ 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
'';
};
}