Add vim/emacs modeline support #49267
Merged
ConradIrwin merged 21 commits intozed-industries:mainfrom Mar 25, 2026
Merged
Conversation
Contributor
Author
|
@ConradIrwin do you want me to rebase again? anything I can do to help? thanks |
Member
|
I'm sorry, I thought I had merged this already! Asking Claude to re-try the merge, if it struggles I'd love for you to take a pass. |
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit refactors how language settings are accessed across various crates. Instead of passing individual parameters like `language` and `file` explicitly, it now utilizes a more fluent builder pattern that can optionally take a `Buffer` or `BufferSnapshot` to infer these details. In a later patch, modeline settings support can be added seamlessly thanks to this refactoring. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Co-authored-by: Claude <noreply@anthropic.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Co-authored-by: Claude <noreply@anthropic.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This will allow to configure vim/emacs modeline support. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Add an optional ModelineSettings to Buffer and BufferSnapshot. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
When the buffer is added on reloaded, parse the modelines and update the detected language. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Suggested by Conrad: zed-industries#44210 (comment)
Associated buffer's modeline is now merged. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Now we need to take modeline into account they are not viable.
Buffers have their own language, so it's almost always an error to specify the buffer and the language (unless you're in a situation where you already did .language_at() or equivalent).
The builder methods were not composible (i.e. you had to be careful to call .language() after .buffer()), so it seems safer to not do that.
Contributor
Author
|
@ConradIrwin rebased, thanks |
📏 PR Size: 2126 lines changed (Size XL)Please note: this PR exceeds the 400 LOC soft limit.
|
booch
reviewed
Apr 1, 2026
|
|
||
| ## Notes | ||
|
|
||
| - The first kilobyte of a file is searched for modelines. |
There was a problem hiding this comment.
Is this still true? If so how does it interact with the modeline_lines line count? @elmarco
Contributor
Author
There was a problem hiding this comment.
yes, it applies the 1kb limit, then the line count.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Many editors such as vim and emacs support "modelines", a comment at the beginning of the file that allows the file type to be explicitly specified along with per-file specific settings
This is my first contribution to zed, be kind. I struggled a bit to find the right place to add those settings. I use a similar approach as done with editorconfig (merge_with_editorconfig). There might be better ways.
Closes #4762
Release Notes:
Supersedes #41899, changes:
modeline_aliaseslanguage config