Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request: set modifiable to true if the user is in the directory group #342

Closed
1 task done
DerpDays opened this issue Mar 31, 2024 · 2 comments · Fixed by #428
Closed
1 task done

feature request: set modifiable to true if the user is in the directory group #342

DerpDays opened this issue Mar 31, 2024 · 2 comments · Fixed by #428
Labels
enhancement New feature or request question Further information is requested

Comments

@DerpDays
Copy link
Contributor

Did you check existing requests?

  • I have searched the existing issues

Describe the feature

Currently, when checking if a buffer should be modifiable, it only checks if the group is the same group as what neovim is opened with, it would be nice if it would check if the user is in the group regardless if they have opened neovim with the specific group that the folder needs.

Provide background

I'm trying to edit files belonging to another group, but although I'm in the group needed for the directory I'm trying to open it still sets modifiable as false since I haven't opened neovim with the specific group. To get around this I can just set modifiable to true or run sg GROUPNAME "nvim ...." but it's quite tedious to remember to do so.

What is the significance of this feature?

nice to have

Additional details

Not quite sure how you'd want this to be implemented, we could read from /etc/group and check if the user is part of the group.
Or more simply, split vim.fn.system("id -G") and check if the directory's group id is in the result.

I'd be happy to implement this

@DerpDays DerpDays added the enhancement New feature or request label Mar 31, 2024
splondike added a commit to splondike/dotfiles that referenced this issue May 26, 2024
It made the /sdcard/ dir unmodifiable by default in Termux.

See stevearc/oil.nvim#342
@DerpDays
Copy link
Contributor Author

DerpDays commented Jun 8, 2024

I've done a quick implementation both of the ways I mentioned, @stevearc, it'd be great if you could have a quick glance over these and tell me which you prefer so I can send a PR, where it can be further polished - or if you have a better idea on how to do this.

https://github.com/DerpDays/oil.nvim/tree/id - Simpler, uses the id -G command and iterates through the result, standard on linux and bsd, I don't think it's likely someone wouldn't have the command.
https://github.com/DerpDays/oil.nvim/tree/groupfile - Uses /etc/group to check if the user is in the group for the directory, the file is standard on linux and bsd.

@stevearc
Copy link
Owner

stevearc commented Jun 9, 2024

I think the id -G approach is fine. I'd make two requests for your current implementation:

  1. cache the result. We should only ever have to call it once.
  2. gracefully fall back to the previous behavior if anything fails with id -G (a vim.notify warning would be appropriate)

@stevearc stevearc added the question Further information is requested label Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants