From b0130fbcf5f927702026b476b14483b8fd0d2c1a Mon Sep 17 00:00:00 2001 From: Igor Mikushkin Date: Tue, 28 Nov 2017 02:58:23 +0400 Subject: [PATCH 1/7] Typo fixed --- syntax/go.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/go.vim b/syntax/go.vim index 783912d51f..4aa2f8d5ac 100644 --- a/syntax/go.vim +++ b/syntax/go.vim @@ -350,7 +350,7 @@ if g:go_highlight_functions != 0 syn match goPointerOperator /\*/ nextgroup=goReceiverType contained skipwhite skipnl syn match goReceiverType /\w\+/ contained syn match goFunction /\w\+/ contained - syn match goFunctionCall /\w\+\ze(/ contains=GoBuiltins,goDeclaration + syn match goFunctionCall /\w\+\ze(/ contains=goBuiltins,goDeclaration else syn keyword goDeclaration func endif From f031270dc27cd11cc9fa869eb6bf1cef6818be6b Mon Sep 17 00:00:00 2001 From: Igor Mikushkin Date: Tue, 28 Nov 2017 02:51:10 +0400 Subject: [PATCH 2/7] Highlighting function in and out arguments --- syntax/go.vim | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/syntax/go.vim b/syntax/go.vim index 4aa2f8d5ac..ffb0b89b8f 100644 --- a/syntax/go.vim +++ b/syntax/go.vim @@ -229,14 +229,14 @@ endif " var, const if s:fold_varconst syn region goVar start='var (' end='^\s*)$' transparent fold - \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar + \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goArgumentName,goArgumentType,goSimpleArguments syn region goConst start='const (' end='^\s*)$' transparent fold - \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar + \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goArgumentName,goArgumentType,goSimpleArguments else syn region goVar start='var (' end='^\s*)$' transparent - \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar + \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goArgumentName,goArgumentType,goSimpleArguments syn region goConst start='const (' end='^\s*)$' transparent - \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar + \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goArgumentName,goArgumentType,goSimpleArguments endif " Single-line var, const, and import. @@ -344,13 +344,18 @@ hi def link goOperator Operator " Functions; if g:go_highlight_functions != 0 - syn match goDeclaration /\/ nextgroup=goReceiver,goFunction skipwhite skipnl - syn match goReceiver /(\(\w\|[ *]\)\+)/ contained nextgroup=goFunction contains=goReceiverVar skipwhite skipnl - syn match goReceiverVar /\w\+/ nextgroup=goPointerOperator,goReceiverType skipwhite skipnl contained + syn match goFunctionCall /\w\+\ze(/ contains=goBuiltins,goDeclaration + syn match goDeclaration /\/ nextgroup=goReceiver,goFunction,goSimpleArguments skipwhite skipnl + syn match goReceiverVar /\w\+\ze\s\+\(\w\|\*\)/ nextgroup=goPointerOperator,goReceiverType skipwhite skipnl contained syn match goPointerOperator /\*/ nextgroup=goReceiverType contained skipwhite skipnl + syn match goFunction /\w\+/ nextgroup=goSimpleArguments contained skipwhite skipnl syn match goReceiverType /\w\+/ contained - syn match goFunction /\w\+/ contained - syn match goFunctionCall /\w\+\ze(/ contains=goBuiltins,goDeclaration + syn match goSimpleArguments /(\(\w\|\_s\|[*\.\[\],\{\}<>-]\)\+)/ contained contains=goArgumentName nextgroup=goSimpleArguments skipwhite skipnl + syn match goArgumentName /\w\+\(\s*,\s*\w\+\)*\ze\s\+\(\w\|\.\|\*\|\[\)/ contained nextgroup=goArgumentType skipwhite skipnl + syn match goArgumentType /\([^,)]\|\_s\)\+,\?/ contained nextgroup=goArgumentName skipwhite skipnl + \ contains=goVarArgs,goType,goSignedInts,goUnsignedInts,goFloats,goComplexes,goDeclType,goBlock + syn match goReceiver /(\s*\w\+\(\s\+\*\?\s*\w\+\)\?\s*)\ze\s*\w/ contained nextgroup=goFunction contains=goReceiverVar skipwhite skipnl + hi def link goReceiverVar goArgumentName else syn keyword goDeclaration func endif From 8da1e95f8ee09b1420f9affd30b51a19f85f598c Mon Sep 17 00:00:00 2001 From: Igor Mikushkin Date: Wed, 29 Nov 2017 04:22:03 +0400 Subject: [PATCH 3/7] Return arguments highlighting fixed after empty input arguments list --- syntax/go.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/go.vim b/syntax/go.vim index ffb0b89b8f..aea08f8109 100644 --- a/syntax/go.vim +++ b/syntax/go.vim @@ -350,7 +350,7 @@ if g:go_highlight_functions != 0 syn match goPointerOperator /\*/ nextgroup=goReceiverType contained skipwhite skipnl syn match goFunction /\w\+/ nextgroup=goSimpleArguments contained skipwhite skipnl syn match goReceiverType /\w\+/ contained - syn match goSimpleArguments /(\(\w\|\_s\|[*\.\[\],\{\}<>-]\)\+)/ contained contains=goArgumentName nextgroup=goSimpleArguments skipwhite skipnl + syn match goSimpleArguments /(\(\w\|\_s\|[*\.\[\],\{\}<>-]\)*)/ contained contains=goArgumentName nextgroup=goSimpleArguments skipwhite skipnl syn match goArgumentName /\w\+\(\s*,\s*\w\+\)*\ze\s\+\(\w\|\.\|\*\|\[\)/ contained nextgroup=goArgumentType skipwhite skipnl syn match goArgumentType /\([^,)]\|\_s\)\+,\?/ contained nextgroup=goArgumentName skipwhite skipnl \ contains=goVarArgs,goType,goSignedInts,goUnsignedInts,goFloats,goComplexes,goDeclType,goBlock From 821a7c0baad1f6bd971919608f70b30915eb9eb7 Mon Sep 17 00:00:00 2001 From: Igor Mikushkin Date: Wed, 29 Nov 2017 04:43:49 +0400 Subject: [PATCH 4/7] Option for highlighting arguments added --- syntax/go.vim | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/syntax/go.vim b/syntax/go.vim index aea08f8109..0f6712af05 100644 --- a/syntax/go.vim +++ b/syntax/go.vim @@ -38,6 +38,10 @@ if !exists("g:go_highlight_functions") let g:go_highlight_functions = 0 endif +if !exists("g:go_highlight_function_arguments") + let g:go_highlight_function_arguments = 0 +endif + if !exists("g:go_highlight_methods") let g:go_highlight_methods = 0 endif @@ -350,12 +354,14 @@ if g:go_highlight_functions != 0 syn match goPointerOperator /\*/ nextgroup=goReceiverType contained skipwhite skipnl syn match goFunction /\w\+/ nextgroup=goSimpleArguments contained skipwhite skipnl syn match goReceiverType /\w\+/ contained +if g:go_highlight_function_arguments != 0 syn match goSimpleArguments /(\(\w\|\_s\|[*\.\[\],\{\}<>-]\)*)/ contained contains=goArgumentName nextgroup=goSimpleArguments skipwhite skipnl syn match goArgumentName /\w\+\(\s*,\s*\w\+\)*\ze\s\+\(\w\|\.\|\*\|\[\)/ contained nextgroup=goArgumentType skipwhite skipnl syn match goArgumentType /\([^,)]\|\_s\)\+,\?/ contained nextgroup=goArgumentName skipwhite skipnl \ contains=goVarArgs,goType,goSignedInts,goUnsignedInts,goFloats,goComplexes,goDeclType,goBlock + hi def link goReceiverVar goArgumentName +endif syn match goReceiver /(\s*\w\+\(\s\+\*\?\s*\w\+\)\?\s*)\ze\s*\w/ contained nextgroup=goFunction contains=goReceiverVar skipwhite skipnl - hi def link goReceiverVar goArgumentName else syn keyword goDeclaration func endif From 0a2d89cd03f314b2543ef85c666b6203ec96833d Mon Sep 17 00:00:00 2001 From: Igor Mikushkin Date: Wed, 29 Nov 2017 04:44:41 +0400 Subject: [PATCH 5/7] Highlighting arguments as identifiers if highlighting flag is set --- syntax/go.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/syntax/go.vim b/syntax/go.vim index 0f6712af05..208ea58f5d 100644 --- a/syntax/go.vim +++ b/syntax/go.vim @@ -360,6 +360,7 @@ if g:go_highlight_function_arguments != 0 syn match goArgumentType /\([^,)]\|\_s\)\+,\?/ contained nextgroup=goArgumentName skipwhite skipnl \ contains=goVarArgs,goType,goSignedInts,goUnsignedInts,goFloats,goComplexes,goDeclType,goBlock hi def link goReceiverVar goArgumentName + hi def link goArgumentName Identifier endif syn match goReceiver /(\s*\w\+\(\s\+\*\?\s*\w\+\)\?\s*)\ze\s*\w/ contained nextgroup=goFunction contains=goReceiverVar skipwhite skipnl else From a1a6b46737d0df209e0ccae811bbf31c6016aa70 Mon Sep 17 00:00:00 2001 From: Igor Mikushkin Date: Wed, 29 Nov 2017 05:01:16 +0400 Subject: [PATCH 6/7] Highlighting functions as well if highlighting arguments is on --- syntax/go.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/go.vim b/syntax/go.vim index 208ea58f5d..f3ed29449c 100644 --- a/syntax/go.vim +++ b/syntax/go.vim @@ -347,7 +347,7 @@ endif hi def link goOperator Operator " Functions; -if g:go_highlight_functions != 0 +if g:go_highlight_functions != 0 || go_highlight_function_arguments != 0 syn match goFunctionCall /\w\+\ze(/ contains=goBuiltins,goDeclaration syn match goDeclaration /\/ nextgroup=goReceiver,goFunction,goSimpleArguments skipwhite skipnl syn match goReceiverVar /\w\+\ze\s\+\(\w\|\*\)/ nextgroup=goPointerOperator,goReceiverType skipwhite skipnl contained From 545a645426fe06a25644ea1fa90cc36b87a4a82e Mon Sep 17 00:00:00 2001 From: Martin Tournoij Date: Thu, 7 Dec 2017 17:30:17 +0000 Subject: [PATCH 7/7] Add doc and changelog entry --- CHANGELOG.md | 2 ++ doc/vim-go.txt | 12 ++++++++++-- syntax/go.vim | 8 ++++---- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c90e1af509..8f4f0361ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,8 @@ BUG FIXES: [[GH-1513]](https://github.com/fatih/vim-go/pull/1513) * `:GoImpl` tab-completion would sometimes stop working [[GH-1581]](https://github.com/fatih/vim-go/pull/1581). +* Add `g:go_highlight_function_arguments` to highlight function arguments. + [[GH-1587]](https://github.com/fatih/vim-go/pull/1587). IMPROVEMENTS: diff --git a/doc/vim-go.txt b/doc/vim-go.txt index cf9e711c4d..60218be02e 100644 --- a/doc/vim-go.txt +++ b/doc/vim-go.txt @@ -1094,9 +1094,9 @@ SETTINGS *go-settings* *'g:go_test_prepend_name'* Prepend the name of the failed test to each test message generated by a failed -test. By default it is disabled. +test. By default it is disabled. > - let g:go_test_prepend_name = 0 + let g:go_test_prepend_name = 0 < *'g:go_test_timeout'* @@ -1703,6 +1703,14 @@ Highlight operators such as `:=` , `==`, `-=`, etc. Highlight function names. > let g:go_highlight_functions = 0 +< + *'g:go_highlight_function_arguments'* + +Highlight the variable names in arguments and return values in function +declarations. Setting this implies the functionality from +|'g:go_highlight_functions'|. +> + let g:go_highlight_function_arguments = 0 < *'g:go_highlight_methods'* diff --git a/syntax/go.vim b/syntax/go.vim index f3ed29449c..8e7df12243 100644 --- a/syntax/go.vim +++ b/syntax/go.vim @@ -98,7 +98,7 @@ if exists("g:go_fold_enable") if index(g:go_fold_enable, 'package_comment') == -1 let s:fold_package_comment = 0 endif - + " Disabled by default. if index(g:go_fold_enable, 'comment') > -1 let s:fold_comment = 1 @@ -237,7 +237,7 @@ if s:fold_varconst syn region goConst start='const (' end='^\s*)$' transparent fold \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goArgumentName,goArgumentType,goSimpleArguments else - syn region goVar start='var (' end='^\s*)$' transparent + syn region goVar start='var (' end='^\s*)$' transparent \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goArgumentName,goArgumentType,goSimpleArguments syn region goConst start='const (' end='^\s*)$' transparent \ contains=ALLBUT,goParen,goBlock,goFunction,goTypeName,goReceiverType,goReceiverVar,goArgumentName,goArgumentType,goSimpleArguments @@ -347,14 +347,14 @@ endif hi def link goOperator Operator " Functions; -if g:go_highlight_functions != 0 || go_highlight_function_arguments != 0 +if g:go_highlight_functions isnot 0 || g:go_highlight_function_arguments isnot 0 syn match goFunctionCall /\w\+\ze(/ contains=goBuiltins,goDeclaration syn match goDeclaration /\/ nextgroup=goReceiver,goFunction,goSimpleArguments skipwhite skipnl syn match goReceiverVar /\w\+\ze\s\+\(\w\|\*\)/ nextgroup=goPointerOperator,goReceiverType skipwhite skipnl contained syn match goPointerOperator /\*/ nextgroup=goReceiverType contained skipwhite skipnl syn match goFunction /\w\+/ nextgroup=goSimpleArguments contained skipwhite skipnl syn match goReceiverType /\w\+/ contained -if g:go_highlight_function_arguments != 0 +if g:go_highlight_function_arguments isnot 0 syn match goSimpleArguments /(\(\w\|\_s\|[*\.\[\],\{\}<>-]\)*)/ contained contains=goArgumentName nextgroup=goSimpleArguments skipwhite skipnl syn match goArgumentName /\w\+\(\s*,\s*\w\+\)*\ze\s\+\(\w\|\.\|\*\|\[\)/ contained nextgroup=goArgumentType skipwhite skipnl syn match goArgumentType /\([^,)]\|\_s\)\+,\?/ contained nextgroup=goArgumentName skipwhite skipnl