Skip to content

Commit

Permalink
fix(javascript): Remove additional whiteline after main function desc…
Browse files Browse the repository at this point in the history
…ription
  • Loading branch information
kkoomen committed Jul 26, 2019
1 parent 33ed53b commit 45eddac
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 124 deletions.
15 changes: 5 additions & 10 deletions ftplugin/javascript.vim
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ let b:doge_patterns = []

" Matches the following pattern:
" <param-access> <param-name>: <param-type> = <param-default-value>
let s:parameters_match_pattern = '\m\%(\%(public\|private\|protected\)\?\s*\)\?\([[:alnum:]_$]\+\)\%(\s*:\s*\([[:alnum:][:space:]._|]\+\%(\[[[:alnum:][:space:]_[\],]*\]\)\?\)\)\?\%(\s*=\s*\([^,]\+\)\+\)\?'
let s:parameters_match_pattern = '\m\%(\%(public\|private\|protected\)\?\s*\)\?\([[:alnum:]_$]\+\)\%(\s*:\s*\([[:alnum:][:space:]._|]\+\%(\[[[:alnum:][:space:]_[\],]*\]\)\?\)\)\?\%(\s*=\s*\([[:alnum:]_.]\+(.\{-})\|[^,]\+\)\+\)\?'

" ==============================================================================
" Matches fat-arrow / functions inside objects.
Expand All @@ -45,7 +45,7 @@ call add(b:doge_patterns, {
\ 'match': s:parameters_match_pattern,
\ 'match_group_names': ['name', 'type'],
\ 'format': {
\ 'jsdoc': '@param {{type|!type}} {name} !description',
\ 'jsdoc': '@param {{type|!type}} {name} - !description',
\ },
\ },
\ 'comment': {
Expand All @@ -54,7 +54,6 @@ call add(b:doge_patterns, {
\ 'jsdoc': [
\ '/**',
\ ' * !description',
\ ' *',
\ '%(async| * @{async})%',
\ ' * @function {funcName|}',
\ '%(parameters| * {parameters})%',
Expand Down Expand Up @@ -87,7 +86,6 @@ call add(b:doge_patterns, {
\ 'jsdoc': [
\ '/**',
\ ' * !description',
\ ' *',
\ '%(parentClassName| * @extends {parentClassName})%',
\ '%(interfaceName| * @implements {interfaceName})%',
\ ' */',
Expand Down Expand Up @@ -119,7 +117,7 @@ call add(b:doge_patterns, {
\ 'match': s:parameters_match_pattern,
\ 'match_group_names': ['name', 'type'],
\ 'format': {
\ 'jsdoc': '@param {{type|!type}} {name} !description',
\ 'jsdoc': '@param {{type|!type}} {name} - !description',
\ },
\ },
\ 'comment': {
Expand All @@ -128,7 +126,6 @@ call add(b:doge_patterns, {
\ 'jsdoc': [
\ '/**',
\ ' * !description',
\ ' *',
\ '%(async| * @{async})%',
\ '%(parameters| * {parameters})%',
\ '%(returnType| * @return {{returnType}} !description)%',
Expand Down Expand Up @@ -156,7 +153,7 @@ call add(b:doge_patterns, {
\ 'match': s:parameters_match_pattern,
\ 'match_group_names': ['name', 'type'],
\ 'format': {
\ 'jsdoc': '@param {{type|!type}} {name} !description',
\ 'jsdoc': '@param {{type|!type}} {name} - !description',
\ },
\ },
\ 'comment': {
Expand All @@ -165,7 +162,6 @@ call add(b:doge_patterns, {
\ 'jsdoc': [
\ '/**',
\ ' * !description',
\ ' *',
\ '%(async| * @{async})%',
\ ' * @function {className}#{funcName}',
\ '%(parameters| * {parameters})%',
Expand Down Expand Up @@ -206,7 +202,7 @@ call add(b:doge_patterns, {
\ 'match': s:parameters_match_pattern,
\ 'match_group_names': ['name', 'type'],
\ 'format': {
\ 'jsdoc': '@param {{type|!type}} {name} !description',
\ 'jsdoc': '@param {{type|!type}} {name} - !description',
\ },
\ },
\ 'comment': {
Expand All @@ -215,7 +211,6 @@ call add(b:doge_patterns, {
\ 'jsdoc': [
\ '/**',
\ ' * !description',
\ ' *',
\ '%(async| * @{async})%',
\ ' * @function {funcName|}',
\ '%(parameters| * {parameters})%',
Expand Down
19 changes: 7 additions & 12 deletions ftplugin/typescript.vim
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ let b:doge_patterns = []

" Matches the following pattern:
" <param-access> <param-name>: <param-type> = <param-default-value>
let s:parameters_match_pattern = '\m\%(\%(public\|private\|protected\)\?\s*\)\?\([[:alnum:]_$]\+\)\%(\s*:\s*\([[:alnum:][:space:]._|]\+\%(\[[[:alnum:][:space:]_[\],]*\]\)\?\)\)\?\%(\s*=\s*\([^,]\+\)\+\)\?'
let s:parameters_match_pattern = '\m\%(\%(public\|private\|protected\)\?\s*\)\?\([[:alnum:]_$]\+\)\%(\s*:\s*\([[:alnum:][:space:]._|]\+\%(\[[[:alnum:][:space:]_[\],]*\]\)\?\)\)\?\%(\s*=\s*\([[:alnum:]_.]\+(.\{-})\|[^,]\+\)\+\)\?'

" ==============================================================================
" Matches fat-arrow / functions inside objects.
Expand All @@ -42,13 +42,13 @@ let s:parameters_match_pattern = '\m\%(\%(public\|private\|protected\)\?\s*\)\?\
"
" myKey: async (p1, p2) => {}
call add(b:doge_patterns, {
\ 'match': '\m^\([[:alnum:]_]\+\)\s*:\s*\(async\)\?\%(function\)\?\s*\%([[:alnum:]_]\+\)\?(\(.\{-}\))\%(\s*:\s*(\?\([[:alnum:][:space:]_[\].,|<>]\+\))\?\)\?\%(\s*=>\s*\)\?\s*[({]',
\ 'match': '\m^[[:punct:]]\?\([[:alnum:]_-]\+\)[[:punct:]]\?\s*:\s*\(async\)\?\s*\%(function\)\?\s*\%([[:alnum:]_]\+\)\?(\(.\{-}\))\%(\s*:\s*(\?\([[:alnum:][:space:]_[\].,|<>]\+\))\?\)\?\%(\s*=>\s*\)\?\s*[({]',
\ 'match_group_names': ['funcName', 'async', 'parameters', 'returnType'],
\ 'parameters': {
\ 'match': s:parameters_match_pattern,
\ 'match_group_names': ['name', 'type'],
\ 'format': {
\ 'jsdoc': '@param {{type|!type}} {name} !description',
\ 'jsdoc': '@param {{type|!type}} {name} - !description',
\ },
\ },
\ 'comment': {
Expand All @@ -57,7 +57,6 @@ call add(b:doge_patterns, {
\ 'jsdoc': [
\ '/**',
\ ' * !description',
\ ' *',
\ '%(async| * @{async})%',
\ ' * @function {funcName|}',
\ '%(parameters| * {parameters})%',
Expand Down Expand Up @@ -90,7 +89,6 @@ call add(b:doge_patterns, {
\ 'jsdoc': [
\ '/**',
\ ' * !description',
\ ' *',
\ '%(parentClassName| * @extends {parentClassName})%',
\ '%(interfaceName| * @implements {interfaceName})%',
\ ' */',
Expand Down Expand Up @@ -122,7 +120,7 @@ call add(b:doge_patterns, {
\ 'match': s:parameters_match_pattern,
\ 'match_group_names': ['name', 'type'],
\ 'format': {
\ 'jsdoc': '@param {{type|!type}} {name} !description',
\ 'jsdoc': '@param {{type|!type}} {name} - !description',
\ },
\ },
\ 'comment': {
Expand All @@ -131,7 +129,6 @@ call add(b:doge_patterns, {
\ 'jsdoc': [
\ '/**',
\ ' * !description',
\ ' *',
\ '%(async| * @{async})%',
\ '%(parameters| * {parameters})%',
\ '%(returnType| * @return {{returnType}} !description)%',
Expand Down Expand Up @@ -159,7 +156,7 @@ call add(b:doge_patterns, {
\ 'match': s:parameters_match_pattern,
\ 'match_group_names': ['name', 'type'],
\ 'format': {
\ 'jsdoc': '@param {{type|!type}} {name} !description',
\ 'jsdoc': '@param {{type|!type}} {name} - !description',
\ },
\ },
\ 'comment': {
Expand All @@ -168,7 +165,6 @@ call add(b:doge_patterns, {
\ 'jsdoc': [
\ '/**',
\ ' * !description',
\ ' *',
\ '%(async| * @{async})%',
\ ' * @function {className}#{funcName}',
\ '%(parameters| * {parameters})%',
Expand Down Expand Up @@ -209,7 +205,7 @@ call add(b:doge_patterns, {
\ 'match': s:parameters_match_pattern,
\ 'match_group_names': ['name', 'type'],
\ 'format': {
\ 'jsdoc': '@param {{type|!type}} {name} !description',
\ 'jsdoc': '@param {{type|!type}} {name} - !description',
\ },
\ },
\ 'comment': {
Expand All @@ -218,7 +214,6 @@ call add(b:doge_patterns, {
\ 'jsdoc': [
\ '/**',
\ ' * !description',
\ ' *',
\ '%(async| * @{async})%',
\ ' * @function {funcName|}',
\ '%(parameters| * {parameters})%',
Expand All @@ -230,4 +225,4 @@ call add(b:doge_patterns, {
\})

let &cpoptions = s:save_cpo
unlet s:save_cpo
u
12 changes: 2 additions & 10 deletions test/filetypes/javascript/classes.vader
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ Do (trigger doge):
Expect javascript (generated comment with nothing but the text 'TODO'):
/**
* [TODO:description]
*
*/
class Child {}

/**
* [TODO:description]
*
*/
export class Child {}

Expand All @@ -40,14 +38,12 @@ Do (trigger doge):
Expect javascript (generated comment with @extends):
/**
* [TODO:description]
*
* @extends Parent
*/
class Child extends Parent {}

/**
* [TODO:description]
*
* @extends Parent
*/
export class Child extends Parent {}
Expand All @@ -62,20 +58,18 @@ Given javascript (class without extends with implements):

Do (trigger doge):
\<C-d>
:8\<CR>
:7\<CR>
\<C-d>

Expect javascript (generated comment with @implements tag):
/**
* [TODO:description]
*
* @implements CustomInterfaceName
*/
class Child implements CustomInterfaceName {}

/**
* [TODO:description]
*
* @implements CustomInterfaceName
*/
export class Child implements CustomInterfaceName {}
Expand All @@ -90,21 +84,19 @@ Given javascript (class with extends and with implements):

Do (trigger doge):
\<C-d>
:10\<CR>
:9\<CR>
\<C-d>

Expect javascript (generated comment with @extends and @implements tags):
/**
* [TODO:description]
*
* @extends Parent
* @implements CustomInterfaceName
*/
class Child extends Parent implements CustomInterfaceName {}

/**
* [TODO:description]
*
* @extends Parent
* @implements CustomInterfaceName
*/
Expand Down
Loading

0 comments on commit 45eddac

Please sign in to comment.