Skip to content

Commit

Permalink
plugins/vim-suda: add back the smart_edit option
Browse files Browse the repository at this point in the history
  • Loading branch information
GaetanLepage committed Jan 19, 2025
1 parent 85e4e16 commit ab693bb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
31 changes: 15 additions & 16 deletions plugins/by-name/vim-suda/default.nix
Original file line number Diff line number Diff line change
@@ -1,41 +1,40 @@
{ lib, helpers, ... }:

{ lib, ... }:
let
inherit (lib.nixvim) defaultNullOpts;
in
lib.nixvim.plugins.mkVimPlugin {
name = "vim-suda";
globalPrefix = "suda#";
maintainers = [ lib.maintainers.marcel ];

settingsOptions = {
executable = helpers.defaultNullOpts.mkStr "sudo" ''
executable = defaultNullOpts.mkStr "sudo" ''
Path to the sudo binary.
'';

noninteractive = helpers.defaultNullOpts.mkFlagInt 0 ''
noninteractive = defaultNullOpts.mkFlagInt 0 ''
If set, suda will not prompt you for a password before saving a file.
It is supposed to support a setup with passwordless sudo or doas.
Use with care.
'';

prompt = helpers.defaultNullOpts.mkStr "Password: " ''
prompt = defaultNullOpts.mkStr "Password: " ''
A prompt string used to ask password.
'';

# TODO: til https://github.com/lambdalisue/vim-suda/pull/84
# makes it into nixos-unstable
# NOTE: also update in `settingsExample` and test cases
#smart_edit = helpers.defaultNullOpts.mkFlagInt 0 ''
# If set, an `|autocmd|` is created that performs a heuristic check on
# every buffer and decides whether to replace it with a suda buffer.
# The check is done only once for every buffer and it is designed to be
# optimized as possible so you shouldn't feel any slowdown when opening
# buffers.
#'';
smart_edit = defaultNullOpts.mkFlagInt 0 ''
If set, an `|autocmd|` is created that performs a heuristic check on
every buffer and decides whether to replace it with a suda buffer.
The check is done only once for every buffer and it is designed to be
optimized as possible so you shouldn't feel any slowdown when opening
buffers.
'';
};

settingsExample = {
path = "doas";
noninteractive = 1;
prompt = "Pass: ";
#smart_edit = 1;
smart_edit = 1;
};
}
4 changes: 2 additions & 2 deletions tests/test-sources/plugins/by-name/vim-suda/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
path = "sudo";
noninteractive = 0;
prompt = "Password: ";
#smart_edit = 0;
smart_edit = 0;
};
};
};
Expand All @@ -22,7 +22,7 @@
path = "doas";
noninteractive = 1;
prompt = "Pass: ";
#smart_edit = 1;
smart_edit = 1;
};
};
};
Expand Down

0 comments on commit ab693bb

Please sign in to comment.