12
44
Fork
You've already forked zig.vim
10

make string highlighting start at opening quote #127

Merged
Techatrix merged 1 commit from jpk68/zig.vim:string-syntax into master 2026年07月12日 21:23:46 +02:00
Contributor
Copy link

Begins syntax highlighting of string literals at the opening quote rather than the closing one. This is consistent with syntax highlighting used for strings in other languages.

Begins syntax highlighting of string literals at the opening quote rather than the closing one. This is consistent with syntax highlighting used for strings in other languages.
Collaborator
Copy link

Could you explain what exactly this PR changes and how it can be observed or tested?

Could you explain what exactly this PR changes and how it can be observed or tested?
Author
Contributor
Copy link

Before these changes, a string literal would only be highlighted when there is a double quotation mark at both ends. This can be thought of as "highlighting only once you finish typing the string" rather than "highlighting from when you start typing the string". For example:

constx="syntax is not highlightedconsty="syntax is highlighted";// As it turns out, Codeberg's syntax highlighting for Zig does do it 'correctly' in both cases.

In almost all other languages in Vim (C, C++, Rust...), string literals will be highlighted starting with the opening quotation mark, even before the string is closed. This PR aims to make Zig's syntax highlighting consistent with others; I also personally believe it looks better this way, but that's a matter of opinion.

In terms of how this patch can be tested, I just did so by replacing the modified file in the repo cloned by vim-plug with my own changes. A similar approach can likely be taken with other setups.

Before these changes, a string literal would only be highlighted when there is a double quotation mark at both ends. This can be thought of as "highlighting only once you finish typing the string" rather than "highlighting from when you start typing the string". For example: ```zig const x = "syntax is not highlighted const y = "syntax is highlighted"; // As it turns out, Codeberg's syntax highlighting for Zig does do it 'correctly' in both cases. ``` In almost all other languages in Vim (C, C++, Rust...), string literals will be highlighted starting with the opening quotation mark, even before the string is closed. This PR aims to make Zig's syntax highlighting consistent with others; I also personally believe it looks better this way, but that's a matter of opinion. In terms of how this patch can be tested, I just did so by replacing the modified file in the repo cloned by `vim-plug` with my own changes. A similar approach can likely be taken with other setups.
Techatrix left a comment
Copy link

So this is about how to highlight when the closing quotation mark is missing. That's what I was missing. Looks good to me.

So this is about how to highlight when the closing quotation mark is missing. That's what I was missing. Looks good to me.
Sign in to join this conversation.
No reviewers
Labels
Clear labels
bounty
https://ziglang.org/news/announcing-donor-bounties
bug
Observed behavior contradicts documented or intended behavior.
contributor-friendly
This issue is limited in scope and/or knowledge of project internals.
downstream
An issue with a third-party project that uses this project.
enhancement
Solving this issue will likely involve adding new logic or components to the codebase.
infra
An issue related to project infrastructure, e.g. continuous integration.
optimization
A task to improve performance and/or resource usage.
question
No questions on the issue tracker; use a community space instead.
regression
Something that used to work in a previous version stopped working
upstream
An issue with a third-party project that this project uses.
use case
Describes a real use case that is difficult or impossible, but does not propose a solution.
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ziglang/zig.vim!127
Reference in a new issue
ziglang/zig.vim
No description provided.
Delete branch "jpk68/zig.vim:string-syntax"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?