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

add --readonly flag to enter readonly mode #7128

Closed
wants to merge 13 commits into from

Conversation

ds-cbo
Copy link
Contributor

@ds-cbo ds-cbo commented May 24, 2023

This is a very rough approach, but I was missing something like vim's -R where you can open a file without accidentally writing to it

It can probably be adapted to recognise no-write files (r-- or r-x) as well, as suggested in #2627

And it can probably also be adapted to enable readonly for specific buffers instead of editor-wide, as suggested in #3709

@kirawi kirawi added the A-helix-term Area: Helix term improvements label May 24, 2023
@mcdoker18
Copy link
Contributor

But it's not a readonly mode because I can still modify documents. Maybe would be better to forbid switching to insert mode or show error if user trying to?

LSP also can modify documents.

And there is the auto save option in the editor config.

@ds-cbo
Copy link
Contributor Author

ds-cbo commented May 30, 2023

Just blocking insert mode wouldn't be enough, since there are several ways to change the buffer in normal mode (eg. paste or execute shell commands). In my experience, LSP's only modify on save, which is blocked with these changes already. I didn't check out the auto-save option, but I expect it to use the same save_impl. Though I agree it would be nicer to not even trigger auto-save in the first place, so I'll add a task for that:

  • disable auto-save when readonly mode is on

@the-mikedavis
Copy link
Member

I definitely want a concept of read-only in Helix but it should be more extensive, and I think the design of the feature needs some discussion (i.e. an idea discussion). I'm hesitant about an editor-wide read-only mode and I'm fairly certain a Document should not be locked in a read-only state: it should be possible to write a read-only Document to a path which isn't read-only.

Kakoune has a nice read-only feature including refusal to enter insert-mode that could be inspiration for this in Helix.

@pascalkuthe pascalkuthe mentioned this pull request Jul 26, 2023
@3f6a
Copy link

3f6a commented Feb 27, 2024

+1. What is the current status of this PR? I'd really like having a readonly flag. Thanks!

@ds-cbo
Copy link
Contributor Author

ds-cbo commented Feb 28, 2024

@3f6a On my part the current status is that I occasionally rebase this branch and use that (plus the patch from #8362) for my custom build. I'm happy with this minimal patch as-is and am not planning to lead the idea discussion or extend the code accordingly. I'm keeping this patch relatively up-to-date for my own workflows, and I'm sharing it with the community in case other people would like the same, but I don't expect this PR to be merged any time soon.

@pascalkuthe
Copy link
Member

Closing this one out as this feature needs design dicussion and major changes and will not be merged in this form (see @the-mikedavis comment above). Thank you for contributing

@heaths
Copy link
Contributor

heaths commented Aug 27, 2024

I started #11586 to discuss. I'm interest in seeing this and even working on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants