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

Vim syntax match for variable definitions #1426

Merged
merged 6 commits into from
Sep 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions doc/vim-go.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1331,6 +1331,13 @@ Use this option to highlight printf-style operators inside string literals.
By default it's enabled. >

let g:go_highlight_format_strings = 1
<
*'g:go_highlight_variable_declarations'*

Highlight variable declarations (`:=`). Variable assignments (`=`) are not
highlighted. By default it's disabled. >

let g:go_highlight_variable_declarations = 0
<
*'g:go_autodetect_gopath'*

Expand Down
10 changes: 10 additions & 0 deletions syntax/go.vim
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ if !exists("g:go_highlight_generate_tags")
let g:go_highlight_generate_tags = 0
endif

if !exists("g:go_highlight_variable_declarations")
let g:go_highlight_variable_declarations = 0
endif

let s:fold_block = 1
let s:fold_import = 1
let s:fold_varconst = 1
Expand Down Expand Up @@ -382,6 +386,12 @@ hi def link goTypeName Type
hi def link goTypeDecl Keyword
hi def link goDeclType Keyword

" Variable Declarations
if g:go_highlight_variable_declarations != 0
syn match goVarDefs /\v\w+(,\s*\w+)*\ze(\s*:\=)/
hi def link goVarDefs Special
endif

" Build Constraints
if g:go_highlight_build_constraints != 0
syn match goBuildKeyword display contained "+build"
Expand Down