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

adding strings in multiple lines in var or const block statement breaks Go syntax highlighting #3699

Open
paskozdilar opened this issue Feb 13, 2025 · 1 comment

Comments

@paskozdilar
Copy link
Contributor

I've opened an issue on NeoVim repository, and I was directed to open an issue here.

The same issue also exists on Vim. Vim ./runtime/syntax/go.vim is (allegedly) up-to-date with vim-go, but I don't know how to verify that since injecting the go.vim file from vim-go into vim repository causes errors. I assume Vim does some kind of transformations on it?


Anyways, here's the details of the issue:

The following Go snippet breaks syntax highlighting in Vim:

package main

var (
	host  string
	usage string = "" +
		"\"\""
)

func main() {}

This can be reproduced in a Docker container by downloading the latest nightly Vim AppImage:

FROM ubuntu:24.04

RUN apt-get -y update && apt-get -y install curl

WORKDIR /app

RUN curl -LO https://github.com/vim/vim-appimage/releases/download/v9.1.1106/Vim-v9.1.1106.glibc2.29-x86_64.AppImage

RUN chmod u+x Vim-v9.1.1106.glibc2.29-x86_64.AppImage

RUN ./Vim-v9.1.1106.glibc2.29-x86_64.AppImage --appimage-extract

RUN echo 'package main' >> main.go
RUN echo '' >> main.go
RUN echo 'var (' >> main.go
RUN echo '	host  string' >> main.go
RUN echo '	usage string = "" +' >> main.go
RUN echo '		"\"\""' >> main.go
RUN echo ')' >> main.go
RUN echo '' >> main.go
RUN echo 'func main() {}' >> main.go

CMD ["/app/squashfs-root/AppRun", "main.go"]

Running docker build . -t test && docker run --rm -it test shows the following screen:

Image

The statement func main() {} and everything after it is completely devoid of syntax highlighting.

@bhcleek
Copy link
Collaborator

bhcleek commented Mar 10, 2025

That's interesting. Strangely, there are no syntax highlighting problems if this is done without using a var or const block.

@bhcleek bhcleek changed the title Vim: Adding strings in multiple lines in var statement breaks Go syntax highlighting Vim: Adding strings in multiple lines in var or const block statement breaks Go syntax highlighting Mar 10, 2025
@bhcleek bhcleek changed the title Vim: Adding strings in multiple lines in var or const block statement breaks Go syntax highlighting adding strings in multiple lines in var or const block statement breaks Go syntax highlighting Mar 10, 2025
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

No branches or pull requests

2 participants