-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
:GoDoc (K) does not highlight the syntax of the method declaration. #3365
Comments
The difficulting with doing something like this is that Vim's syntax highlighting is based purely on regular expressions, and the syntax highlighting in godoc that you may expect wouldn't be possible to fully achieve in all cases; there would be edge cases where it wouldn't be possible to highlight correctly. It does appear that something like this used to exist, but was removed about 6 years ago, though I don't fully understand why (see #48 and #782) |
Why do you think so? What I have in mind would be just the very first line, which is usually the Method/Type/Constant declaration. I wouldn't bother highlighting the rest of the docs. Although I don't have much experience with vim plug-in development, I would be eager to help on this one. |
Because it won't take long for people to want that highlighting in any examples and package indexes. (e.g. the examples in
Highlighting in vim is driven by regular expressions; I don't know of a way to restrict to only a particular set of lines within a buffer. It's probably possible to do this based on the presence of leading whitespace or not; it appears that godoc uses spaces for leading whitespace in doc, and tabs in the types that are being documented, and of course no whitespace for package level identifiers. One would think one could merely reuse the syntax for go files, but that would surely be incorrect (especially if one wanted to highlight examples due to the way some examples are written). |
I found a way to highlight the function names by editing the go.vim file that comes with vim. I don't know how to write regex's so i just copied someone else's for a C highlight. All i did was check if a word has a "(" at the end, If it does then draw it yellow.
I could fix this by checking if it starts with the word "func" or a "." This is what i put at the bottom of the go.vim file
|
Title is very straightforward. Is this a "bug" or a feature?
As you can see in the screenshot, in the very first part of the window, the window created with the
:GoDoc
command, is not syntax highlighted. This is very nit of course, but I was wondering if is something I can clearly accomplish with some config.Vim version (first three lines from
:version
):NVIM v0.7.0-dev+971-g4b719e4a1
Build type: Release
LuaJIT 2.1.0-beta3
Go version (
go version
):go version go1.17.7 darwin/amd64
Go environment
go env
Output:gopls version
gopls version
Output:vim-go configuration:
vim-go configuration
filetype detection configuration:
filetype detection
The text was updated successfully, but these errors were encountered: