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

Ignore readonly files #20

Merged
merged 3 commits into from
May 17, 2024
Merged

Ignore readonly files #20

merged 3 commits into from
May 17, 2024

Conversation

tmillr
Copy link
Owner

@tmillr tmillr commented May 17, 2024

It is not enough to just check vim's 'ro' option and only write a buffer when it is unset. For one, 'ro' may be (or become) unset even when the file is unwritable. By default, vim also unsets 'ro' after writing a readonly buffer, regardless of whether the file permissions have changed or not (see also the Z flag from the 'cpo' option). Even when unset, vim will prompt (or error if 'confirm' is unset) every time to write a buffer whose file has insufficient permissions to do a simple write (i.e. a write w/o resorting to a cp or mv of the file), which can quickly become annoying when the writing is done frequently/automatically.

Additional Comments

In the future, consider allowing the user to opt-into forcefully writing readonly buffers. There could also be an option to ignore any resulting errors in this case as well. These options might not be very safe though, and they would require W to be absent from 'cpo'.

It is not enough to just check vim's `'ro'` option and only write a
buffer when it is unset. For one, `'ro'` may be (or become) unset even
when the file is unwritable. By default, vim also unsets `'ro'` after
writing a readonly buffer, regardless of whether the file permissions
have changed or not (see also the `Z` flag from the `'cpo'` option).
Even when unset, vim will prompt (or error if `'confirm'` is unset)
every time to write a buffer whose file has insufficient permissions to
do a simple write (i.e. a write w/o resorting to a `cp` or `mv` of the
file), which can quickly become annoying when the writing is done
frequently/automatically.

Additional Comments

In the future, consider allowing the user to opt-into forcefully writing
readonly buffers. There could also be an option to ignore any resulting
errors in this case as well. These options might not be very safe
though, and they would require `W` to be absent from `'cpo'`.
NOTE: this feature should not require newer versions of neovim; only a
neovim with the `mkdir()` builtin function supporting the `p` flag is
required
@tmillr tmillr merged commit ae1493c into master May 17, 2024
2 of 4 checks passed
@tmillr tmillr deleted the ignore-readonly-files branch May 17, 2024 04:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant