diff --git a/flake.lock b/flake.lock index 8cbb30c..b83ba03 100644 --- a/flake.lock +++ b/flake.lock @@ -213,11 +213,11 @@ }, "nix2lua": { "locked": { - "lastModified": 1713641247, - "narHash": "sha256-UDAxwO1vSkaPtmby04xjiHq5dxd03IBD3lkpFKYlV7Q=", + "lastModified": 1713645801, + "narHash": "sha256-pev5YkdskHDS4OpGdYb5F/44hKrFmqzCwNGs0vSzqM8=", "ref": "refs/heads/main", - "rev": "8c4f3ca834ef7c07c9e3be3e006d7395c69a176c", - "revCount": 36, + "rev": "3c08fa87d14704db1c1648b2486ed49e721dfe18", + "revCount": 37, "type": "git", "url": "https://git.pleshevski.ru/mynix/nix2lua" }, diff --git a/flake.nix b/flake.nix index 2be899f..80dd7bf 100644 --- a/flake.nix +++ b/flake.nix @@ -250,13 +250,10 @@ group_empty = true; full_name = true; }; - keymaps = [ - { mode = "n"; bind = "nt"; command = "NvimTreeToggle"; } - { mode = "n"; bind = "nf"; command = "NvimTreeFindFile"; } - ]; }; nvim-treesitter = { }; - git = { }; + gitsigns-nvim = { }; + neoformat = { }; }; plugins = with prev.nix2lua.lib; { diff --git a/lib/vim.nix b/lib/vim.nix index 973c8ca..75610a9 100644 --- a/lib/vim.nix +++ b/lib/vim.nix @@ -2,8 +2,10 @@ with nix2lua.lib; { + g = varName: expr: set "vim.g.${varName}" expr; fn.isdirectory = file: call1 "vim.fn.isdirectory" (var file); + cmd' = expr: call1 "vim.cmd" expr; cmd.cd = file: call1 "vim.cmd.cd" (var file); keymap.set = { mode, bind, command, opts ? { } }: diff --git a/modules/git.nix b/modules/gitsigns-nvim.nix similarity index 100% rename from modules/git.nix rename to modules/gitsigns-nvim.nix diff --git a/modules/neoformat.nix b/modules/neoformat.nix new file mode 100644 index 0000000..d38a5d6 --- /dev/null +++ b/modules/neoformat.nix @@ -0,0 +1,32 @@ +{ vim, ... }: + +{ configs ? { + neoformat_enabled_markdown = [ "denofmt" ]; + neoformat_rust_rustfmt = { + exe = "rustfmt"; + args = [ "--edition 2021" ]; + stdin = 1; + }; + } +}: + +let inherit (builtins) concatLists attrValues mapAttrs; in +{ + neoformat = concatLists [ + [ + (vim.g "neoformat_try_node_exe" 1) + (vim.g "neoformat_only_msg_on_error" 1) + ] + + (attrValues (mapAttrs vim.g configs)) + + [ + (vim.cmd' '' + aug fmt + au! + au BufWritePre * try | undojoin | Neoformat | catch /E790/ | Neoformat | endtry + aug END + '') + ] + ]; +}