Skip to content

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

Open
@paskozdilar

Description

@paskozdilar

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions