vim-suda icon indicating copy to clipboard operation
vim-suda copied to clipboard

How can I set this variable in nvim lua?

Open rew1nter opened this issue 1 year ago • 11 comments

This may not be the place to ask but here I am. Im trying to set this in my init.lua file let g:suda#nopass = 1

rew1nter avatar Jul 22 '23 03:07 rew1nter

Setting this in the init.lua file doens't work. I'm using nvchad and this is how I'm installing this plugin:

	{
		"lambdalisue/suda.vim",
		lazy = false,
	},

do you know how I can load this variable before the plugin is loaded?

rew1nter avatar Aug 13 '23 18:08 rew1nter

do you know how I can load this variable before the plugin is loaded?

I think you don't need to load the variable. Just set the variable.

lambdalisue avatar Aug 15 '23 05:08 lambdalisue

I think you don't need to load the variable. Just set the variable.

I tried what was told. And it was not set

rew1nter avatar Aug 17 '23 12:08 rew1nter

How did you set and check?

lambdalisue avatar Aug 17 '23 20:08 lambdalisue

Currently I have this in my init.lua file of nvchad:

vim.g["suda#prompt"] = "Mot de passe: "
vim.g["suda#nopass"] = 1

Here the prompt changes but still asks for the password :/

rew1nter avatar Jan 12 '24 09:01 rew1nter

@lambdalisue this seems to be a documentation issue.

according to the docs, if you set suda#nopass, then suda won't ask for a password, but really, suda attempts to run without a password, then asks for a password. this should be properly reflected in the docs.

alternatively, if this is a bug, then when suda#nopass is set and the first attempt fails, we should stop trying.

I'm happy to submit a PR fixing this issue once I know what the intended behavior is 😃

aarondill avatar Mar 12 '24 07:03 aarondill

@aarondill

You're right, the behavior is different from what one might expect from the variable name suda#nopass. If there is a word that can better explain the current behavior, we could mark suda#nopass as deprecated and change it to a new variable name. Do you have any good suggestions for a new variable name?

However, the intention of the issue creator is unclear (it's not clear whether the behavior of suda#nopass is truly not intended, or if the timing of the configuration is off so it's not being configured properly). So if discussion is needed, please create a new issue. If you have a good name suggestion, feel free to submit a pull request directly.

Come to think of it, I really appreciate all the contributions you've been making recently. A bit off-topic, but would you be interested in joining as a collaborator?

lambdalisue avatar Mar 16 '24 05:03 lambdalisue

@lambdalisue you know how the joke goes: There are only two hard things in Computer Science: cache invalidation and naming things. That being said, perhaps suda#trynopass or suda#nopassfirst would be acceptable names?

I would love to join as a collaborator! This plugin is one of the core plugins that I use almost daily (I hate opening neovim as root and losing my config), so I'd love to help make it better :smiley:

aarondill avatar Mar 16 '24 05:03 aarondill

you know how the joke goes: There are only two hard things in Computer Science: cache invalidation and naming things.

That is a universal truth of this world 📚

That being said, perhaps suda#trynopass or suda#nopassfirst would be acceptable names?

Well, I'm sorry but it's a bit... I feel there is a better name so I made a new issue (https://github.com/lambdalisue/suda.vim/issues/73).

I would love to join as a collaborator! This plugin is one of the core plugins that I use almost daily (I hate opening neovim as root and losing my config), so I'd love to help make it better 😃

👍

lambdalisue avatar Mar 16 '24 06:03 lambdalisue

okay guys so just to be clear, There is currently no way of saving without root password?

rew1nter avatar Mar 16 '24 09:03 rew1nter

@rew1nter if you set suda#nopass, then suda will attempt to save without the root password. If you don't have sudo set up to allow no password, then it will fail, then suda will ask for a password and try to save using it.

so if you want to save without a password, set suda#nopass and setup sudo with NOPASSWD

How to set NOPASSWD: https://askubuntu.com/a/147265

aarondill avatar Mar 16 '24 20:03 aarondill