From 25c2920fe8d6673886ddb80e969dacf66e606299 Mon Sep 17 00:00:00 2001 From: "James P. Harvey" Date: Sun, 2 Jun 2019 02:32:34 -0400 Subject: [PATCH 01/42] Update documentation for 11 year old NERDCommenter[A-Z] style (#377) 11 years ago, b54d3bb renamed NERDCom[A-Z] mappings to NERDCommenter[A-Z] mappings. But, the docs were never updated. When README.md was later created, it kept the old NERDCom[A-Z] names. Split tag NERDComAlignedComment and use new form NERDCommenterAlign{Left,Both} Update other help tags from NERDCom[A-Z] pattern to NERDCommenter[A-Z] --- README.md | 32 ++++---- doc/NERD_commenter.txt | 175 +++++++++++++++++++++-------------------- 2 files changed, 105 insertions(+), 102 deletions(-) diff --git a/README.md b/README.md index a64b068..659cd2f 100644 --- a/README.md +++ b/README.md @@ -103,57 +103,57 @@ let g:NERDToggleCheckAllLines = 1 The following key mappings are provided by default (there is also a menu provided that contains menu items corresponding to all the below mappings): -Most of the following mappings are for normal/visual mode only. The **|NERDComInsertComment|** mapping is for insert mode only. +Most of the following mappings are for normal/visual mode only. The **|NERDCommenterInsert|** mapping is for insert mode only. - * `[count]cc` **|NERDComComment|** + * `[count]cc` **|NERDCommenterComment|** Comment out the current line or text selected in visual mode. - * `[count]cn` **|NERDComNestedComment|** + * `[count]cn` **|NERDCommenterNested|** Same as cc but forces nesting. - * `[count]c` **|NERDComToggleComment|** + * `[count]c` **|NERDCommenterToggle|** Toggles the comment state of the selected line(s). If the topmost selected line is commented, all selected lines are uncommented and vice versa. - * `[count]cm` **|NERDComMinimalComment|** + * `[count]cm` **|NERDCommenterMinimal|** Comments the given lines using only one set of multipart delimiters. - * `[count]ci` **|NERDComInvertComment|** + * `[count]ci` **|NERDCommenterInvert|** Toggles the comment state of the selected line(s) individually. - * `[count]cs` **|NERDComSexyComment|** + * `[count]cs` **|NERDCommenterSexy|** Comments out the selected lines with a pretty block formatted layout. - * `[count]cy` **|NERDComYankComment|** + * `[count]cy` **|NERDCommenterYank|** Same as cc except that the commented line(s) are yanked first. - * `c$` **|NERDComEOLComment|** + * `c$` **|NERDCommenterToEOL|** Comments the current line from the cursor to the end of line. - * `cA` **|NERDComAppendComment|** + * `cA` **|NERDCommenterAppend|** Adds comment delimiters to the end of line and goes into insert mode between them. - * **|NERDComInsertComment|** + * **|NERDCommenterInsert|** Adds comment delimiters at the current cursor position and inserts between. Disabled by default. - * `ca` **|NERDComAltDelim|** + * `ca` **|NERDCommenterAltDelims|** Switches to the alternative set of delimiters. - * `[count]cl` - `[count]cb` **|NERDComAlignedComment|** + * `[count]cl` **|NERDCommenterAlignLeft** + `[count]cb` **|NERDCommenterAlignBoth** - Same as **|NERDComComment|** except that the delimiters are aligned down the left side (`cl`) or both sides (`cb`). + Same as **|NERDCommenterComment|** except that the delimiters are aligned down the left side (`cl`) or both sides (`cb`). - * `[count]cu` **|NERDComUncommentLine|** + * `[count]cu` **|NERDCommenterUncomment|** Uncomments the selected line(s). diff --git a/doc/NERD_commenter.txt b/doc/NERD_commenter.txt index 5a14a4d..ba19aca 100644 --- a/doc/NERD_commenter.txt +++ b/doc/NERD_commenter.txt @@ -11,38 +11,39 @@ CONTENTS *NERDCommenterContents* 1.Intro...................................|NERDCommenter| - 2.Installation............................|NERDComInstallation| - 3.Functionality provided..................|NERDComFunctionality| - 3.1 Functionality Summary.............|NERDComFunctionalitySummary| - 3.2 Functionality Details.............|NERDComFunctionalityDetails| - 3.2.1 Comment map.................|NERDComComment| - 3.2.2 Nested comment map..........|NERDComNestedComment| - 3.2.3 Toggle comment map..........|NERDComToggleComment| - 3.2.4 Minimal comment map.........|NERDComMinimalComment| - 3.2.5 Invert comment map..........|NERDComInvertComment| - 3.2.6 Sexy comment map............|NERDComSexyComment| - 3.2.7 Yank comment map............|NERDComYankComment| - 3.2.8 Comment to EOL map..........|NERDComEOLComment| - 3.2.9 Append com to line map......|NERDComAppendComment| - 3.2.10 Insert comment map.........|NERDComInsertComment| - 3.2.11 Use alternate delims map...|NERDComAltDelim| - 3.2.12 Comment aligned maps.......|NERDComAlignedComment| - 3.2.13 Uncomment line map.........|NERDComUncommentLine| - 3.3 Sexy Comments.....................|NERDComSexyComments| - 3.4 The NERDComment function..........|NERDComNERDComment| - 3.5 The Hooks.........................|NERDComHooks| - 4.Options.................................|NERDComOptions| - 4.1 Options summary...................|NERDComOptionsSummary| - 4.2 Options details...................|NERDComOptionsDetails| - 4.3 Default delimiter Options.........|NERDComDefaultDelims| - 5. Customising key mappings...............|NERDComMappings| - 6. Issues with the script.................|NERDComIssues| - 6.1 Delimiter detection heuristics....|NERDComHeuristics| - 6.2 Nesting issues....................|NERDComNesting| - 7.About.. ............................|NERDComAbout| - 8.Changelog...............................|NERDComChangelog| - 9.Credits.................................|NERDComCredits| - 10.License................................|NERDComLicense| + 2.Installation............................|NERDCommenterInstallation| + 3.Functionality provided..................|NERDCommenterFunctionality| + 3.1 Functionality Summary.............|NERDCommenterFunctionalitySummary| + 3.2 Functionality Details.............|NERDCommenterFunctionalityDetails| + 3.2.1 Comment map.................|NERDCommenterComment| + 3.2.2 Nested comment map..........|NERDCommenterNested| + 3.2.3 Toggle comment map..........|NERDCommenterToggle| + 3.2.4 Minimal comment map.........|NERDCommenterMinimal| + 3.2.5 Invert comment map..........|NERDCommenterInvert| + 3.2.6 Sexy comment map............|NERDCommenterSexy| + 3.2.7 Yank comment map............|NERDCommenterYank| + 3.2.8 Comment to EOL map..........|NERDCommenterToEOL| + 3.2.9 Append com to line map......|NERDCommenterAppend| + 3.2.10 Insert comment map.........|NERDCommenterInsert| + 3.2.11 Use alternate delims map...|NERDCommenterAltDelims| + 3.2.12 Comment aligned maps.......|NERDCommenterAlignLeft| + |NERDCommenterAlignBoth| + 3.2.13 Uncomment line map.........|NERDCommenterUncomment| + 3.3 Sexy Comments.....................|NERDCommenterSexyComments| + 3.4 The NERDComment function..........|NERDCommenterNERDComment| + 3.5 The Hooks.........................|NERDCommenterHooks| + 4.Options.................................|NERDCommenterOptions| + 4.1 Options summary...................|NERDCommenterOptionsSummary| + 4.2 Options details...................|NERDCommenterOptionsDetails| + 4.3 Default delimiter Options.........|NERDCommenterDefaultDelims| + 5. Customising key mappings...............|NERDCommenterMappings| + 6. Issues with the script.................|NERDCommenterIssues| + 6.1 Delimiter detection heuristics....|NERDCommenterHeuristics| + 6.2 Nesting issues....................|NERDCommenterNesting| + 7.About.. ............................|NERDCommenterAbout| + 8.Changelog...............................|NERDCommenterChangelog| + 9.Credits.................................|NERDCommenterCredits| + 10.License................................|NERDCommenterLicense| ============================================================================== 1. Intro *NERDCommenter* @@ -55,7 +56,7 @@ There are also options that allow to tweak the commenting engine to your taste. ============================================================================== -2. Installation *NERDComInstallation* +2. Installation *NERDCommenterInstallation* The NERD Commenter requires Vim 7 or higher. @@ -76,68 +77,68 @@ See |filetype-plugin-on| for details, but basically, stick this in your vimrc > < ============================================================================== -3. Functionality provided *NERDComFunctionality* +3. Functionality provided *NERDCommenterFunctionality* ------------------------------------------------------------------------------ -3.1 Functionality summary *NERDComFunctionalitySummary* +3.1 Functionality summary *NERDCommenterFunctionalitySummary* The following key mappings are provided by default (there is also a menu with items corresponding to all the mappings below): -[count]||cc |NERDComComment| +[count]||cc |NERDCommenterComment| Comment out the current line or text selected in visual mode. -[count]||cn |NERDComNestedComment| +[count]||cn |NERDCommenterNested| Same as ||cc but forces nesting. -[count]||c |NERDComToggleComment| +[count]||c |NERDCommenterToggle| Toggles the comment state of the selected line(s). If the topmost selected line is commented, all selected lines are uncommented and vice versa. -[count]||cm |NERDComMinimalComment| +[count]||cm |NERDCommenterMinimal| Comments the given lines using only one set of multipart delimiters. -[count]||ci |NERDComInvertComment| +[count]||ci |NERDCommenterInvert| Toggles the comment state of the selected line(s) individually. -[count]||cs |NERDComSexyComment| +[count]||cs |NERDCommenterSexy| Comments out the selected lines ``sexily'' -[count]||cy |NERDComYankComment| +[count]||cy |NERDCommenterYank| Same as ||cc except that the commented line(s) are yanked first. -||c$ |NERDComEOLComment| +||c$ |NERDCommenterToEOL| Comments the current line from the cursor to the end of line. -||cA |NERDComAppendComment| +||cA |NERDCommenterAppend| Adds comment delimiters to the end of line and goes into insert mode between them. -|NERDComInsertComment| +|NERDCommenterInsert| Adds comment delimiters at the current cursor position and inserts between. Disabled by default. -||ca |NERDComAltDelim| +||ca |NERDCommenterAltDelims| Switches to the alternative set of delimiters. -[count]||cl -[count]||cb |NERDComAlignedComment| -Same as |NERDComComment| except that the delimiters are aligned down the +[count]||cl |NERDCommenterAlignLeft| +[count]||cb |NERDCommenterAlignBoth| +Same as |NERDCommenterComment| except that the delimiters are aligned down the left side (||cl) or both sides (||cb). -[count]||cu |NERDComUncommentLine| +[count]||cu |NERDCommenterUncomment| Uncomments the selected line(s). @@ -145,10 +146,10 @@ With the optional repeat.vim plugin (vimscript #2136), the mappings can also be repeated via |.| ------------------------------------------------------------------------------ -3.2 Functionality details *NERDComFunctionalityDetails* +3.2 Functionality details *NERDCommenterFunctionalityDetails* ------------------------------------------------------------------------------ -3.2.1 Comment map *NERDComComment* +3.2.1 Comment map *NERDCommenterComment* Default mapping: [count]||cc Mapped to: NERDCommenterComment @@ -164,7 +165,7 @@ If a [count] is given in normal mode, the mapping works as though that many lines were selected in visual-line mode. ------------------------------------------------------------------------------ -3.2.2 Nested comment map *NERDComNestedComment* +3.2.2 Nested comment map *NERDCommenterNested* Default mapping: [count]||cn Mapped to: NERDCommenterNested @@ -185,7 +186,7 @@ Related options: |'NERDDefaultNesting'| ------------------------------------------------------------------------------ -3.2.3 Toggle comment map *NERDComToggleComment* +3.2.3 Toggle comment map *NERDCommenterToggle* Default mapping: [count]||c Mapped to: NERDCommenterToggle @@ -202,7 +203,7 @@ If a [count] is given in normal mode, the mapping works as though that many lines were selected in visual-line mode. ------------------------------------------------------------------------------ -3.2.4 Minimal comment map *NERDComMinimalComment* +3.2.4 Minimal comment map *NERDCommenterMinimal* Default mapping: [count]||cm Mapped to: NERDCommenterMinimal @@ -224,7 +225,7 @@ If a [count] is given in normal mode, the mapping works as though that many lines were selected in visual-line mode. ------------------------------------------------------------------------------ -3.2.5 Invert comment map *NERDComInvertComment* +3.2.5 Invert comment map *NERDCommenterInvert* Default mapping: ||ci Mapped to: NERDCommenterInvert @@ -241,13 +242,13 @@ If a [count] is given in normal mode, the mapping works as though that many lines were selected in visual-line mode. ------------------------------------------------------------------------------ -3.2.6 Sexy comment map *NERDComSexyComment* +3.2.6 Sexy comment map *NERDCommenterSexy* Default mapping: [count]||cs Mapped to: NERDCommenterSexy Applicable modes: normal, visual-line. -Comments the selected line(s) ``sexily''. See |NERDComSexyComments| for +Comments the selected line(s) ``sexily''. See |NERDCommenterSexyComments| for a description of what sexy comments are. Can only be done on filetypes for which there is at least one set of multipart comment delimiters specified. @@ -261,7 +262,7 @@ Related options: |'NERDCompactSexyComs'| ------------------------------------------------------------------------------ -3.2.7 Yank comment map *NERDComYankComment* +3.2.7 Yank comment map *NERDCommenterYank* Default mapping: [count]||cy Mapped to: NERDCommenterYank @@ -270,7 +271,7 @@ Applicable modes: normal visual visual-line visual-block. Same as ||cc except that it yanks the line(s) that are commented first. ------------------------------------------------------------------------------ -3.2.8 Comment to EOL map *NERDComEOLComment* +3.2.8 Comment to EOL map *NERDCommenterToEOL* Default mapping: ||c$ Mapped to: NERDCommenterToEOL @@ -280,7 +281,7 @@ Comments the current line from the current cursor position up to the end of the line. ------------------------------------------------------------------------------ -3.2.9 Append com to line map *NERDComAppendComment* +3.2.9 Append com to line map *NERDCommenterAppend* Default mapping: ||cA Mapped to: NERDCommenterAppend @@ -290,7 +291,7 @@ Appends comment delimiters to the end of the current line and goes to insert mode between the new delimiters. ------------------------------------------------------------------------------ -3.2.10 Insert comment map *NERDComInsertComment* +3.2.10 Insert comment map *NERDCommenterInsert* Default mapping: disabled by default. Map it to: NERDCommenterInsert @@ -306,7 +307,7 @@ mapping add > to your vimrc. ------------------------------------------------------------------------------ -3.2.11 Use alternate delims map *NERDComAltDelim* +3.2.11 Use alternate delims map *NERDCommenterAltDelims* Default mapping: ||ca Mapped to: NERDCommenterAltDelims @@ -316,10 +317,11 @@ Changes to the alternative commenting style if one is available. For example, if the user is editing a c++ file using // comments and they hit ||ca then they will be switched over to /**/ comments. -See also |NERDComDefaultDelims| +See also |NERDCommenterDefaultDelims| ------------------------------------------------------------------------------ -3.2.12 Comment aligned maps *NERDComAlignedComment* +3.2.12 Comment aligned maps *NERDCommenterAlignLeft* + *NERDCommenterAlignBoth* Default mappings: [count]||cl [count]||cb Mapped to: NERDCommenterAlignLeft @@ -334,7 +336,7 @@ If a [count] is given in normal mode, the mapping works as though that many lines were selected in visual-line mode. ------------------------------------------------------------------------------ -3.2.13 Uncomment line map *NERDComUncommentLine* +3.2.13 Uncomment line map *NERDCommenterUncomment* Default mapping: [count]||cu Mapped to: NERDCommenterUncomment @@ -347,7 +349,7 @@ When uncommenting, if the line contains multiple sets of delimiters then the ``outermost'' pair of delimiters will be removed. The script uses a set of heuristics to distinguish ``real'' delimiters from -``fake'' ones when uncommenting. See |NERDComIssues| for details. +``fake'' ones when uncommenting. See |NERDCommenterIssues| for details. If a [count] is given in normal mode, the mapping works as though that many lines were selected in visual-line mode. @@ -357,7 +359,7 @@ Related options: |'NERDRemoveExtraSpaces'| ------------------------------------------------------------------------------ -3.3 Sexy Comments *NERDComSexyComments* +3.3 Sexy Comments *NERDCommenterSexyComments* These are comments that use one set of multipart comment delimiters as well as one other marker symbol. For example: > /* @@ -372,7 +374,7 @@ one other marker symbol. For example: > Here the multipart delimiters are /* and */ and the marker is *. ------------------------------------------------------------------------------ -3.4 The NERDComment function *NERDComNERDComment* +3.4 The NERDComment function *NERDCommenterNERDComment* All of the NERD commenter mappings and menu items invoke a single function which delegates the commenting work to other functions. This function is @@ -393,7 +395,7 @@ For example, if you typed > then the script would do a sexy comment on the last visual selection. ------------------------------------------------------------------------------ -3.5 The hooks *NERDComHooks* +3.5 The hooks *NERDCommenterHooks* |fu! NERDCommenter_before()| Before NERDComment/SwitchToAlternativeDelimiters |fu! NERDCommenter_after()| After NERDComment/SwitchToAlternativeDelimiters @@ -423,10 +425,10 @@ change the filetype back: > < ============================================================================== -4. Options *NERDComOptions* +4. Options *NERDCommenterOptions* ------------------------------------------------------------------------------ -4.1 Options summary *NERDComOptionsSummary* +4.1 Options summary *NERDCommenterOptionsSummary* |'loaded_nerd_comments'| Turns off the script. @@ -492,7 +494,7 @@ change the filetype back: > all selected lines is commented or not. ------------------------------------------------------------------------------ -4.3 Options details *NERDComOptionsDetails* +4.3 Options details *NERDCommenterOptionsDetails* To enable any of the below options you should put the given line in your ~/.vimrc @@ -626,7 +628,7 @@ Default: 1. If set to 0, none of the default mappings will be created. -See also |NERDComMappings|. +See also |NERDCommenterMappings|. ------------------------------------------------------------------------------ *'NERDCustomDelimiters'* @@ -837,7 +839,7 @@ file by the following line > < ------------------------------------------------------------------------------ -3.3 Default delimiter customisation *NERDComDefaultDelims* +3.3 Default delimiter customisation *NERDCommenterDefaultDelims* If you want the NERD commenter to use the alternative delimiters for a specific filetype by default then put a line of this form into your vimrc: > @@ -848,13 +850,13 @@ Example: java uses // style comments by default, but you want it to default to let g:NERDAltDelims_java = 1 < -See |NERDComAltDelim| for switching commenting styles at runtime. +See |NERDCommenterAltDelims| for switching commenting styles at runtime. ============================================================================== -5. Key mapping customisation *NERDComMappings* +5. Key mapping customisation *NERDCommenterMappings* To change a mapping just map another key combo to the internal mapping. -For example, to remap the |NERDComComment| mapping to ",omg" you would put +For example, to remap the |NERDCommenterComment| mapping to ",omg" you would put this line in your vimrc: > map ,omg NERDCommenterComment < @@ -866,11 +868,11 @@ map to. See also |'NERDCreateDefaultMappings'|. ============================================================================== -6. Issues with the script *NERDComIssues* +6. Issues with the script *NERDCommenterIssues* ------------------------------------------------------------------------------ -6.1 Delimiter detection heuristics *NERDComHeuristics* +6.1 Delimiter detection heuristics *NERDCommenterHeuristics* Heuristics are used to distinguish the real comment delimiters @@ -890,7 +892,7 @@ string. These heuristics, while usually pretty accurate, will not work for all cases. ------------------------------------------------------------------------------ -6.2 Nesting issues *NERDComNesting* +6.2 Nesting issues *NERDCommenterNesting* If we have some line of code like this: > /*int foo */ = /*5 + 9;*/ @@ -910,7 +912,7 @@ will become: > for simplicity) ============================================================================== -7. About *NERDComAbout* +7. About *NERDCommenterAbout* The author of the NERD commenter is Martyzillatron --- the half robot, half dinosaur bastard son of Megatron and Godzilla. He enjoys destroying @@ -927,7 +929,7 @@ The latest dev versions are on github http://github.com/scrooloose/nerdcommenter ============================================================================== -8. Changelog *NERDComChangelog* +8. Changelog *NERDCommenterChangelog* 2.3.0 - remove all filetypes which have a &commentstring in the standard vim @@ -990,10 +992,10 @@ The latest dev versions are on github - applied a patch from ewfalor to fix an error in the help file with the NERDMapleader doc - disable the insert mode ctrl-c mapping by default, see :help - NERDComInsertComment if you wish to restore it + NERDCommenterInsert if you wish to restore it ============================================================================== -9. Credits *NERDComCredits* +9. Credits *NERDCommenterCredits* Thanks to the follow people for suggestions and patches: @@ -1040,6 +1042,7 @@ JaGoTerr Elias Pipping mntnoe Mark S. +James P. Harvey Thanks to the following people for sending me new filetypes to support: @@ -1131,7 +1134,7 @@ Ivan Devat javascript.jquery tpope cucumber,pdf Lyude Paul piglit shader_test ============================================================================== -10. License *NERDComLicense* +10. License *NERDCommenterLicense* The NERD commenter is released under the wtfpl. See http://sam.zoy.org/wtfpl/COPYING. From e6fd663def132bcbcd7fdb6ab34be117437b6944 Mon Sep 17 00:00:00 2001 From: grenzionky Date: Tue, 4 Jun 2019 09:58:21 -0400 Subject: [PATCH 02/42] Add gdscript filetype (#378) --- plugin/NERD_commenter.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index 5005b22..7fe9884 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -186,6 +186,7 @@ let s:delimiterMap = { \ 'gams': { 'left': '*' }, \ 'gdb': { 'left': '#' }, \ 'gdmo': { 'left': '--' }, + \ 'gdscript3': { 'left': '# ', 'leftAlt': '#' }, \ 'geek': { 'left': 'GEEK_COMMENT:' }, \ 'genshi': { 'left': '', 'leftAlt': '{#', 'rightAlt': '#}' }, \ 'gentoo-conf-d': { 'left': '#' }, From 17cec9747e464867676d8bee6cb7b411f17bd006 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 8 Jun 2019 14:12:34 +0300 Subject: [PATCH 03/42] Add Ledger file support --- plugin/NERD_commenter.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index 7fe9884..ea672d4 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -250,6 +250,7 @@ let s:delimiterMap = { \ 'lace': { 'left': '--' }, \ 'laravel': { 'left': '{{--', 'right': '--}}' }, \ 'ldif': { 'left': '#' }, + \ 'ledger': { 'left': '#', 'leftAlt': ';' }, \ 'less': { 'left': '/*', 'right': '*/' }, \ 'lhaskell': { 'left': '>{-', 'right': '-}', 'leftAlt': '>-- ' }, \ 'lilo': { 'left': '#' }, From 14cd7719acde39595ef408853123e208b906cf58 Mon Sep 17 00:00:00 2001 From: Edison Lim <6057323+edisonljh@users.noreply.github.com> Date: Tue, 18 Jun 2019 14:16:06 +0800 Subject: [PATCH 04/42] feat: added scilla support (#381) --- plugin/NERD_commenter.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index ea672d4..f690e68 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -377,6 +377,7 @@ let s:delimiterMap = { \ 'scala': { 'left': '//', 'nested': 1, 'leftAlt': '/*', 'rightAlt': '*/', 'nestedAlt': 1 }, \ 'scheme': { 'left': ';', 'nested': 1, 'leftAlt': '#|', 'rightAlt': '|#', 'nestedAlt': 1 }, \ 'scilab': { 'left': '//' }, + \ 'scilla': { 'left': '(*', 'right': '*)', 'nested': 1 }, \ 'scons': { 'left': '#' }, \ 'scsh': { 'left': ';' }, \ 'scss': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, From 7f5c217f79b8fce063fec490ab0b2814dd480f08 Mon Sep 17 00:00:00 2001 From: Brent McKain Date: Wed, 3 Jul 2019 08:47:32 -0500 Subject: [PATCH 05/42] Add multipart/block comments to SQL filetype Fixes #382 --- plugin/NERD_commenter.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index f690e68..178adab 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -412,7 +412,7 @@ let s:delimiterMap = { \ 'spectre': { 'left': '//', 'leftAlt': '*' }, \ 'spice': { 'left': '$' }, \ 'spin': { 'left': '''', 'leftAlt': '{', 'rightAlt': '}' }, - \ 'sql': { 'left': '-- ' }, + \ 'sql': { 'left': '-- ', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'sqlforms': { 'left': '-- ' }, \ 'sqlj': { 'left': '-- ' }, \ 'sqr': { 'left': '!' }, From df2f6825f4ad61a0e413df4dff7d2cf6ccc2ce8b Mon Sep 17 00:00:00 2001 From: ufengzh Date: Tue, 6 Aug 2019 21:08:49 +0800 Subject: [PATCH 06/42] Add proto filetype to support protobuf (#390) --- plugin/NERD_commenter.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index 178adab..c13ef9d 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -345,6 +345,7 @@ let s:delimiterMap = { \ 'privoxy': { 'left': '#' }, \ 'processing': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'prolog': { 'left': '%', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'proto': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'ps1': { 'left': '#' }, \ 'psf': { 'left': '#' }, \ 'ptcap': { 'left': '#' }, From a05185584d7cae7791fb40b7656cf642fdbe4938 Mon Sep 17 00:00:00 2001 From: Nagidal Date: Wed, 7 Aug 2019 16:27:35 +0200 Subject: [PATCH 07/42] Added help section about the Leader key (#385) --- doc/NERD_commenter.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/doc/NERD_commenter.txt b/doc/NERD_commenter.txt index ba19aca..27f5775 100644 --- a/doc/NERD_commenter.txt +++ b/doc/NERD_commenter.txt @@ -11,6 +11,7 @@ CONTENTS *NERDCommenterContents* 1.Intro...................................|NERDCommenter| + 1.1 Leader............................|NERDCommenterLeader| 2.Installation............................|NERDCommenterInstallation| 3.Functionality provided..................|NERDCommenterFunctionality| 3.1 Functionality Summary.............|NERDCommenterFunctionalitySummary| @@ -55,6 +56,20 @@ for most filetypes. There are also options that allow to tweak the commenting engine to your taste. +------------------------------------------------------------------------------ +1.1 Leader key *NERDCommenterLeader* + +Most NERD commenter commands are executed using the || key. In Vim +this is a key dedicated for user-specific customizations. It effectively +creates a namespace so that custom commands don't interfere with Vim's +built-in shortcuts. + +The leader key can be mapped to whatever the user likes (see :help mapleader). +In the definition of custom commands || is the placeholder for the +leader key. To see the current mapping for || type :echo mapleader. +If it reports an undefined variable it means the leader key is set to the +default of '\'. + ============================================================================== 2. Installation *NERDCommenterInstallation* From 2504a3d84e97be144019ef184f0c2aed42f3152d Mon Sep 17 00:00:00 2001 From: impulse Date: Tue, 27 Aug 2019 12:58:11 +0200 Subject: [PATCH 08/42] Add comment styles for React filetypes .jsx/.tsx (#393) Note that to-date there has not been an official vim filetype for React-Javascript and React-Typescript. The `javascriptreact` and `typescriptreact` filetypes were added upstream to both Vim (8.1.1890) and NeoVim during the course of discussion on this PR. Some other Vim plugins are known to use filetype hacks such as `javascript.jsx` or `typescript.jsx`. This plugin supports the now official upstream designations. If this conflicts with your usage you can either tweak the other plugins (and/or submit a fix to use the official filetypes upstream) or add custom file type comment setting in your vim rc/init file. Co-Authored-By: Caleb Maclennan --- plugin/NERD_commenter.vim | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index c13ef9d..0e27d24 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -237,6 +237,7 @@ let s:delimiterMap = { \ 'java': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'javacc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'javascript': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'javascriptreact': { 'left': '//', 'leftAlt': '{/*', 'rightAlt': '*/}' }, \ 'javascript.jquery': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'jess': { 'left': ';' }, \ 'jgraph': { 'left': '(*', 'right': '*)' }, @@ -451,6 +452,7 @@ let s:delimiterMap = { \ 'twig': { 'left': '{#', 'right': '#}' }, \ 'txt2tags': { 'left': '%' }, \ 'typescript': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'typescriptreact': { 'left': '//', 'leftAlt': '{/*', 'rightAlt': '*/}' }, \ 'uc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'uil': { 'left': '!' }, \ 'upstart': { 'left': '#' }, From 8228c7b0a7aa46b7846f7bf21bcb89ce24b9c20e Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Fri, 13 Sep 2019 14:30:20 +0300 Subject: [PATCH 09/42] Add comment syntax for FTL (Fluent) filetype --- plugin/NERD_commenter.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index 0e27d24..6e44a3c 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -181,6 +181,7 @@ let s:delimiterMap = { \ 'foxpro': { 'left': '*' }, \ 'fsharp': { 'left': '(*', 'right': '*)', 'leftAlt': '//' }, \ 'fstab': { 'left': '#' }, + \ 'ftl': { 'left': '#', 'leftAlt': '##' }, \ 'fvwm': { 'left': '#' }, \ 'fx': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'gams': { 'left': '*' }, From 50f307bbf68e7402a1564689910ec65ae7ab1781 Mon Sep 17 00:00:00 2001 From: horst5000 <54308725+horst5000@users.noreply.github.com> Date: Fri, 20 Sep 2019 07:52:44 +0200 Subject: [PATCH 10/42] Change delimiters of CUDA to match the defaults of C/C++ --- plugin/NERD_commenter.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index 6e44a3c..705cf1a 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -133,7 +133,7 @@ let s:delimiterMap = { \ 'csp': { 'left': '--' }, \ 'cterm': { 'left': '*' }, \ 'cucumber': { 'left': '#' }, - \ 'cuda': { 'left': '/*', 'right': '*/', 'leftAlt': '//' }, + \ 'cuda': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'cvs': { 'left': 'CVS:' }, \ 'cython': { 'left': '# ', 'leftAlt': '#' }, \ 'd': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, From a4b7c046b3d3e170c6f62a6209abfa0760d6694a Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Thu, 26 Sep 2019 14:32:13 +0300 Subject: [PATCH 11/42] Fix Fluent file type as set by fluent.vim --- plugin/NERD_commenter.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index 705cf1a..12e9476 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -175,13 +175,13 @@ let s:delimiterMap = { \ 'fancy': { 'left': '#' }, \ 'faust': { 'left': '//' }, \ 'fgl': { 'left': '#' }, + \ 'fluent': { 'left': '#', 'leftAlt': '##' }, \ 'focexec': { 'left': '-*' }, \ 'form': { 'left': '*' }, \ 'fortran': { 'left': '!' }, \ 'foxpro': { 'left': '*' }, \ 'fsharp': { 'left': '(*', 'right': '*)', 'leftAlt': '//' }, \ 'fstab': { 'left': '#' }, - \ 'ftl': { 'left': '#', 'leftAlt': '##' }, \ 'fvwm': { 'left': '#' }, \ 'fx': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'gams': { 'left': '*' }, From 92082862364cf5ec3eec79a025bbc7bc5165e05f Mon Sep 17 00:00:00 2001 From: Rory Bradford Date: Sat, 5 Oct 2019 15:39:51 +0100 Subject: [PATCH 12/42] Add syntax for troff family languages (#397) --- plugin/NERD_commenter.vim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index 12e9476..0758542 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -204,6 +204,7 @@ let s:delimiterMap = { \ 'glsl': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'gnuplot': { 'left': '#' }, \ 'go': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, + \ 'groff': { 'left': '\#' }, \ 'groovy': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'gsp': { 'left': '<%--', 'right': '--%>', 'leftAlt': '' }, \ 'gtkrc': { 'left': '#' }, @@ -273,6 +274,7 @@ let s:delimiterMap = { \ 'mail': { 'left': '> ' }, \ 'mako': { 'left': '##' }, \ 'man': { 'left': '."' }, + \ 'mandoc': { 'left': '.\\"' }, \ 'map': { 'left': '%' }, \ 'maple': { 'left': '#' }, \ 'markdown': { 'left': '' }, @@ -445,6 +447,7 @@ let s:delimiterMap = { \ 'tmux': { 'left': '#' }, \ 'toml': { 'left': '#' }, \ 'trasys': { 'left': "$" }, + \ 'troff': { 'left': '.\\"' }, \ 'tsalt': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'tsscl': { 'left': '#' }, \ 'tssgm': { 'left': "comment = '", 'right': "'" }, From 023cc20324c41059b5ce79edaef0ffeef8bf5923 Mon Sep 17 00:00:00 2001 From: Nicholas Cronquist Date: Tue, 26 Nov 2019 02:11:36 -0500 Subject: [PATCH 13/42] Add new delimiter for Hashicorp 'sentinel' files (#406) - Sentinel is a new language developed by Hashicorp - Sentinel supports three types of comments, `#` and `//` for single line comments and `/* ... */` for multi-line comments as described in their documentation - https://docs.hashicorp.com/sentinel/language/spec/#comments - Since sentinel and terraform, .tf extension, are related, the `#` symbol was chosen to keep in line with the tf single line comment --- plugin/NERD_commenter.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index 0758542..ce7693b 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -388,6 +388,7 @@ let s:delimiterMap = { \ 'scss': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'sdc': { 'left': '#' }, \ 'sed': { 'left': '#' }, + \ 'sentinel': { 'left': '#', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'sgmldecl': { 'left': '--', 'right': '--' }, \ 'sgmllnx': { 'left': '' }, \ 'sh': { 'left': '#' }, From 023f2d10d58e34186c8cc4372951870225e6d079 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Fri, 20 Dec 2019 07:39:25 +0300 Subject: [PATCH 14/42] Add snakemake filetype support, closes #313 --- plugin/NERD_commenter.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index ce7693b..903bcf1 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -408,6 +408,7 @@ let s:delimiterMap = { \ 'smil': { 'left': '' }, \ 'smith': { 'left': ';' }, \ 'sml': { 'left': '(*', 'right': '*)', 'nested': 1 }, + \ 'snakemake': { 'left': '#' }, \ 'snippets': { 'left': '#' }, \ 'snnsnet': { 'left': '#' }, \ 'snnspat': { 'left': '#' }, From ce590719f67ec031f75935bdbfe0c9616ea878b9 Mon Sep 17 00:00:00 2001 From: Jaskaran Singh Date: Sat, 21 Dec 2019 13:29:38 +0530 Subject: [PATCH 15/42] Add semantic patch (.cocci) to delimiterMap (#408) Coccinelle is a tool used for transforming C source code. It uses the Semantic Patch Language (.cocci files) for doing this. The conventional notation for commenting in semantic patches is "//". Used in conjunction with this plugin: https://github.com/ahf/cocci-syntax The cocci filetype is set, following which NERD_commenter can be used in .cocci files. Signed-off-by: Jaskaran Singh --- plugin/NERD_commenter.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index 903bcf1..bd53c0c 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -123,6 +123,7 @@ let s:delimiterMap = { \ 'clipper': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'clojure': { 'left': ';' }, \ 'cmake': { 'left': '#' }, + \ 'cocci': { 'left': '//' }, \ 'coffee': { 'left': '#', 'leftAlt': '###', 'rightAlt': '###' }, \ 'conkyrc': { 'left': '#' }, \ 'context': { 'left': '%', 'leftAlt': '--' }, From f5525720ec6915a3a177965fd1502f781515be03 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sun, 29 Dec 2019 11:14:31 +0300 Subject: [PATCH 16/42] Create FUNDING.yml --- .github/FUNDING.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..dc20bd4 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +github: [alerque, scrooloose] From 8786861a3caffb6e1122def808d6c2cd4f434ec3 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sun, 29 Dec 2019 11:01:36 +0300 Subject: [PATCH 17/42] Update repository URLs with new org namespace See https://github.com/preservim/nerdcommenter/issues/400 Old URLs will continue to work for the foreseeable future since Github forwards them, but new users in particular should be encouraged to use the new org namespace when installing the plugin. --- README.md | 16 ++++++++-------- doc/NERD_commenter.txt | 2 +- plugin/NERD_commenter.vim | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 659cd2f..5f07bc6 100644 --- a/README.md +++ b/README.md @@ -8,19 +8,19 @@ Comment functions so powerful—no comment necessary. #### [Vim-Plug](https://github.com/junegunn/vim-plug) -1. Add `Plug 'scrooloose/nerdcommenter'` to your vimrc file. +1. Add `Plug 'preservim/nerdcommenter'` to your vimrc file. 2. Reload your vimrc or restart 3. Run `:PlugInstall` #### [Vundle](https://github.com/VundleVim/Vundle.vim) or similar -1. Add `Plugin 'scrooloose/nerdcommenter'` to your vimrc file. +1. Add `Plugin 'preservim/nerdcommenter'` to your vimrc file. 2. Reload your vimrc or restart 3. Run `:BundleInstall` #### [NeoBundle](https://github.com/Shougo/neobundle.vim) -1. Add `NeoBundle 'scrooloose/nerdcommenter'` to your vimrc file. +1. Add `NeoBundle 'preservim/nerdcommenter'` to your vimrc file. 2. Reload your vimrc or restart 3. Run `:NeoUpdate` @@ -28,7 +28,7 @@ Comment functions so powerful—no comment necessary. ```sh cd ~/.vim/bundle -git clone https://github.com/scrooloose/nerdcommenter.git +git clone https://github.com/preservim/nerdcommenter.git ``` ### Manual Installation @@ -39,9 +39,9 @@ git clone https://github.com/scrooloose/nerdcommenter.git ```sh curl -fLo ~/.vim/plugin/NERD_Commenter.vim --create-dirs \ - https://raw.githubusercontent.com/scrooloose/nerdcommenter/master/plugin/NERD_commenter.vim + https://raw.githubusercontent.com/preservim/nerdcommenter/master/plugin/NERD_commenter.vim curl -fLo ~/.vim/doc/NERD_Commenter.txt --create-dirs \ - https://raw.githubusercontent.com/scrooloose/nerdcommenter/master/doc/NERD_commenter.txt + https://raw.githubusercontent.com/preservim/nerdcommenter/master/doc/NERD_commenter.txt ``` #### Windows (PowerShell) @@ -49,8 +49,8 @@ curl -fLo ~/.vim/doc/NERD_Commenter.txt --create-dirs \ ```powershell md ~\vimfiles\plugin md ~\vimfiles\doc -$pluguri = 'https://raw.githubusercontent.com/scrooloose/nerdcommenter/master/plugin/NERD_commenter.vim' -$docsuri = 'https://raw.githubusercontent.com/scrooloose/nerdcommenter/master/doc/NERD_commenter.txt' +$pluguri = 'https://raw.githubusercontent.com/preservim/nerdcommenter/master/plugin/NERD_commenter.vim' +$docsuri = 'https://raw.githubusercontent.com/preservim/nerdcommenter/master/doc/NERD_commenter.txt' (New-Object Net.WebClient).DownloadFile($pluguri, $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath("~\vimfiles\plugin\NERD_commenter.vim")) (New-Object Net.WebClient).DownloadFile($docsuri, $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath("~\vimfiles\doc\NERD_commenter.txt")) ``` diff --git a/doc/NERD_commenter.txt b/doc/NERD_commenter.txt index 27f5775..0ae7582 100644 --- a/doc/NERD_commenter.txt +++ b/doc/NERD_commenter.txt @@ -941,7 +941,7 @@ The latest stable versions can be found at http://www.vim.org/scripts/script.php?script_id=1218 The latest dev versions are on github - http://github.com/scrooloose/nerdcommenter + http://github.com/preservim/nerdcommenter ============================================================================== 8. Changelog *NERDCommenterChangelog* diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index bd53c0c..c5805fc 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -3090,7 +3090,7 @@ inoremap NERDCommenterInsert :call NERDComment('i nnoremap NERDCommenterAltDelims :call SwitchToAlternativeDelimiters(1) " This is a workaround to enable lazy-loading from supported plugin managers: -" See https://github.com/scrooloose/nerdcommenter/issues/176 +" See https://github.com/preservim/nerdcommenter/issues/176 call s:SetUpForNewFiletype(&filetype, 1) " vim: set foldmethod=marker : From 8a688729338120cefb768b97229c7cf468a68338 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Mon, 30 Dec 2019 10:40:47 +0300 Subject: [PATCH 18/42] Add vimscript linter as CI check --- .github/workflows/vint.yml | 18 ++++++++++++++++++ README.md | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/vint.yml diff --git a/.github/workflows/vint.yml b/.github/workflows/vint.yml new file mode 100644 index 0000000..054da4e --- /dev/null +++ b/.github/workflows/vint.yml @@ -0,0 +1,18 @@ +name: Vint +on: [push, pull_request] +jobs: + vint: + strategy: + fail-fast: false + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@master + - name: Set up Python + uses: actions/setup-python@v1 + with: + python-version: 3.7 + - name: Setup dependencies + run: pip install vim-vint + - name: Run Vimscript Linter + run: vint . diff --git a/README.md b/README.md index 5f07bc6..dec0bb7 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# NERD Commenter +# NERD Commenter [![Vint](https://github.com/preservim/nerdcommenter/workflows/Vint/badge.svg)](https://github.com/preservim/nerdcommenter/actions?workflow=Vint) Comment functions so powerful—no comment necessary. From 6d51d1b334704349eb0e80534c2a76344a712093 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Mon, 30 Dec 2019 10:51:34 +0300 Subject: [PATCH 19/42] Fix VimL syntax error --- plugin/NERD_commenter.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index c5805fc..e7aaff0 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -2591,8 +2591,8 @@ function s:IsSexyComment(topline, bottomline) let topline = a:topline let bottomline = a:bottomline if bottomline < topline - topline = bottomline - bottomline = a:topline + let topline = bottomline + let bottomline = a:topline endif "if there is < 2 lines in the comment it cannot be sexy From ac3db1e70a95fde31f9adc3caa96357b6f8cc513 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Mon, 30 Dec 2019 10:53:41 +0300 Subject: [PATCH 20/42] Fix lint warning: prefer single quoted strings --- plugin/NERD_commenter.vim | 180 +++++++++++++++++++------------------- 1 file changed, 90 insertions(+), 90 deletions(-) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index e7aaff0..a916197 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -14,7 +14,7 @@ " ============================================================================ " Section: script init stuff {{{1 -if exists("loaded_nerd_comments") +if exists('loaded_nerd_comments') finish endif if v:version < 700 @@ -49,24 +49,24 @@ let s:spaceStr = ' ' let s:lenSpaceStr = strlen(s:spaceStr) " Section: variable initialization {{{2 -call s:InitVariable("g:NERDAllowAnyVisualDelims", 1) -call s:InitVariable("g:NERDBlockComIgnoreEmpty", 0) -call s:InitVariable("g:NERDCommentWholeLinesInVMode", 0) -call s:InitVariable("g:NERDCommentEmptyLines", 0) -call s:InitVariable("g:NERDCompactSexyComs", 0) -call s:InitVariable("g:NERDCreateDefaultMappings", 1) -call s:InitVariable("g:NERDDefaultNesting", 1) -call s:InitVariable("g:NERDMenuMode", 3) -call s:InitVariable("g:NERDLPlace", "[>") -call s:InitVariable("g:NERDUsePlaceHolders", 1) -call s:InitVariable("g:NERDRemoveAltComs", 1) -call s:InitVariable("g:NERDRemoveExtraSpaces", 0) -call s:InitVariable("g:NERDRPlace", "<]") -call s:InitVariable("g:NERDSpaceDelims", 0) -call s:InitVariable("g:NERDDefaultAlign", "none") -call s:InitVariable("g:NERDTrimTrailingWhitespace", 0) -call s:InitVariable("g:NERDToggleCheckAllLines", 0) -call s:InitVariable("g:NERDDisableTabsInBlockComm", 0) +call s:InitVariable('g:NERDAllowAnyVisualDelims', 1) +call s:InitVariable('g:NERDBlockComIgnoreEmpty', 0) +call s:InitVariable('g:NERDCommentWholeLinesInVMode', 0) +call s:InitVariable('g:NERDCommentEmptyLines', 0) +call s:InitVariable('g:NERDCompactSexyComs', 0) +call s:InitVariable('g:NERDCreateDefaultMappings', 1) +call s:InitVariable('g:NERDDefaultNesting', 1) +call s:InitVariable('g:NERDMenuMode', 3) +call s:InitVariable('g:NERDLPlace', '[>') +call s:InitVariable('g:NERDUsePlaceHolders', 1) +call s:InitVariable('g:NERDRemoveAltComs', 1) +call s:InitVariable('g:NERDRemoveExtraSpaces', 0) +call s:InitVariable('g:NERDRPlace', '<]') +call s:InitVariable('g:NERDSpaceDelims', 0) +call s:InitVariable('g:NERDDefaultAlign', 'none') +call s:InitVariable('g:NERDTrimTrailingWhitespace', 0) +call s:InitVariable('g:NERDToggleCheckAllLines', 0) +call s:InitVariable('g:NERDDisableTabsInBlockComm', 0) let s:NERDFileNameEscape="[]#*$%'\" ?`!&();<>\\" @@ -320,7 +320,7 @@ let s:delimiterMap = { \ 'omnimark': { 'left': ';' }, \ 'ooc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'openroad': { 'left': '//' }, - \ 'opl': { 'left': "REM" }, + \ 'opl': { 'left': 'REM' }, \ 'ora': { 'left': '#' }, \ 'ox': { 'left': '//' }, \ 'paludis-use-conf': { 'left': '#' }, @@ -442,14 +442,14 @@ let s:delimiterMap = { \ 'teak': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'terraform': { 'left': '#', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'tex': { 'left': '%' }, - \ 'texinfo': { 'left': "@c " }, + \ 'texinfo': { 'left': '@c ' }, \ 'texmf': { 'left': '%' }, \ 'tf': { 'left': '#' }, \ 'tidy': { 'left': '#' }, \ 'tli': { 'left': '#' }, \ 'tmux': { 'left': '#' }, \ 'toml': { 'left': '#' }, - \ 'trasys': { 'left': "$" }, + \ 'trasys': { 'left': '$' }, \ 'troff': { 'left': '.\\"' }, \ 'tsalt': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'tsscl': { 'left': '#' }, @@ -466,7 +466,7 @@ let s:delimiterMap = { \ 'vala': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'vasp': { 'left': '!' }, \ 'vb': { 'left': "'" }, - \ 'velocity': { 'left': "##", 'right': "", 'leftAlt': '#*', 'rightAlt': '*#' }, + \ 'velocity': { 'left': '##', 'right': '', 'leftAlt': '#*', 'rightAlt': '*#' }, \ 'vera': { 'left': '/*', 'right': '*/', 'leftAlt': '//' }, \ 'verilog': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'verilog_systemverilog': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, @@ -493,7 +493,7 @@ let s:delimiterMap = { let g:NERDDelimiterMap = s:delimiterMap -if exists("g:NERDCustomDelimiters") +if exists('g:NERDCustomDelimiters') call extend(s:delimiterMap, g:NERDCustomDelimiters) endif @@ -553,7 +553,7 @@ function s:SetUpForNewFiletype(filetype, forceReset) endif endfor " if g:NERD__alt_style is defined, use the alternate style - let b:NERDCommenterFirstInit = getbufvar(1,"NERDCommenterFirstInit") + let b:NERDCommenterFirstInit = getbufvar(1,'NERDCommenterFirstInit') if exists('g:NERDAltDelims_'.ft) && eval('g:NERDAltDelims_'.ft) && !b:NERDCommenterFirstInit call s:SwitchToAlternativeDelimiters(0) let b:NERDCommenterFirstInit = 1 @@ -594,13 +594,13 @@ endfunction " if this function changed the delimiters or not function s:SwitchToAlternativeDelimiters(printMsgs) if exists('*NERDCommenter_before') - exe "call NERDCommenter_before()" + exe 'call NERDCommenter_before()' endif "if both of the alternative delimiters are empty then there is no "alternative comment style so bail out if b:NERDCommenterDelims['leftAlt'] == '' && b:NERDCommenterDelims['rightAlt'] == '' if a:printMsgs - call s:NerdEcho("Cannot use alternative delimiters, none are specified", 0) + call s:NerdEcho('Cannot use alternative delimiters, none are specified', 0) endif return 0 endif @@ -623,11 +623,11 @@ function s:SwitchToAlternativeDelimiters(printMsgs) "tell the user what comment delimiters they are now using if a:printMsgs - call s:NerdEcho("Now using " . s:Left() . " " . s:Right() . " to delimit comments", 1) + call s:NerdEcho('Now using ' . s:Left() . ' ' . s:Right() . ' to delimit comments', 1) endif if exists('*NERDCommenter_after') - exe "call NERDCommenter_after()" + exe 'call NERDCommenter_after()' endif return 1 @@ -645,18 +645,18 @@ function s:AppendCommentToLine() " get the length of the right delimiter let lenRight = strlen(right) - let isLineEmpty = strlen(getline(".")) == 0 + let isLineEmpty = strlen(getline('.')) == 0 let insOrApp = (isLineEmpty==1 ? 'i' : 'A') "stick the delimiters down at the end of the line. We have to format the "comment with spaces as appropriate - execute ":normal! " . insOrApp . (isLineEmpty ? '' : ' ') . left . right + execute ':normal! ' . insOrApp . (isLineEmpty ? '' : ' ') . left . right " if there is a right delimiter then we gotta move the cursor left " by the length of the right delimiter so we insert between the delimiters if lenRight > 0 let leftMoveAmount = lenRight - 1 - execute ":normal! " . leftMoveAmount . "h" + execute ':normal! ' . leftMoveAmount . 'h' startinsert else startinsert! @@ -809,7 +809,7 @@ function s:CommentLines(forceNested, align, firstLine, lastLine) " we need to get the left and right indexes of the leftmost char in the " block of of lines and the right most char so that we can do alignment of " the delimiters if the user has specified - let leftAlignIndx = a:align == "start" ? 0 : s:LeftMostIndx(a:forceNested, 0, a:firstLine, a:lastLine) + let leftAlignIndx = a:align == 'start' ? 0 : s:LeftMostIndx(a:forceNested, 0, a:firstLine, a:lastLine) let rightAlignIndx = s:RightMostIndx(a:forceNested, 0, a:firstLine, a:lastLine) " gotta add the length of the left delimiter onto the rightAlignIndx cos @@ -837,12 +837,12 @@ function s:CommentLines(forceNested, align, firstLine, lastLine) " check if we can comment this line if !isCommented || g:NERDUsePlaceHolders || s:Multipart() - if a:align == "left" || a:align == "start" || a:align == "both" + if a:align == 'left' || a:align == 'start' || a:align == 'both' let theLine = s:AddLeftDelimAligned(s:Left({'space': 1}), theLine, leftAlignIndx) else let theLine = s:AddLeftDelim(s:Left({'space': 1}), theLine) endif - if a:align == "both" + if a:align == 'both' let theLine = s:AddRightDelimAligned(s:Right({'space': 1}), theLine, rightAlignIndx) else let theLine = s:AddRightDelim(s:Right({'space': 1}), theLine) @@ -1073,7 +1073,7 @@ function s:CommentLinesToggle(forceNested, firstLine, lastLine) let currentLine = a:firstLine let align = g:NERDDefaultAlign - let leftAlignIndx = align == "start" ? 0 : s:LeftMostIndx(a:forceNested, 0, a:firstLine, a:lastLine) + let leftAlignIndx = align == 'start' ? 0 : s:LeftMostIndx(a:forceNested, 0, a:firstLine, a:lastLine) let rightAlignIndx = s:RightMostIndx(a:forceNested, 0, a:firstLine, a:lastLine) let rightAlignIndx = rightAlignIndx + strlen(s:Left({'space': 1})) @@ -1096,7 +1096,7 @@ function s:CommentLinesToggle(forceNested, firstLine, lastLine) else let theLine = s:AddLeftDelim(s:Left({'space': 1}), theLine) endif - if align == "both" + if align == 'both' let theLine = s:AddRightDelimAligned(s:Right({'space': 1}), theLine, rightAlignIndx) else let theLine = s:AddRightDelim(s:Right({'space': 1}), theLine) @@ -1225,13 +1225,13 @@ endfunction " 'Nested', 'ToEOL', 'Append', 'Insert', 'Uncomment', 'Yank' function! NERDComment(mode, type) range if exists('*NERDCommenter_before') - exe "call NERDCommenter_before()" + exe 'call NERDCommenter_before()' endif let isVisual = a:mode =~ '[vsx]' - if !exists("g:did_load_ftplugin") || g:did_load_ftplugin != 1 - call s:NerdEcho("filetype plugins should be enabled. See :help NERDComInstallation and :help :filetype-plugin-on", 0) + if !exists('g:did_load_ftplugin') || g:did_load_ftplugin != 1 + call s:NerdEcho('filetype plugins should be enabled. See :help NERDComInstallation and :help :filetype-plugin-on', 0) endif if isVisual @@ -1254,18 +1254,18 @@ function! NERDComment(mode, type) range if a:type ==? 'Comment' || a:type ==? 'Nested' if isVisual && visualmode() == "\" call s:CommentBlock(firstLine, lastLine, firstCol, lastCol, forceNested) - elseif isVisual && visualmode() == "v" && (g:NERDCommentWholeLinesInVMode==0 || (g:NERDCommentWholeLinesInVMode==2 && s:HasMultipartDelims())) + elseif isVisual && visualmode() == 'v' && (g:NERDCommentWholeLinesInVMode==0 || (g:NERDCommentWholeLinesInVMode==2 && s:HasMultipartDelims())) call s:CommentRegion(firstLine, firstCol, lastLine, lastCol, forceNested) else call s:CommentLines(forceNested, g:NERDDefaultAlign, firstLine, lastLine) endif elseif a:type ==? 'AlignLeft' || a:type ==? 'AlignBoth' - let align = "none" - if a:type ==? "AlignLeft" - let align = "left" - elseif a:type ==? "AlignBoth" - let align = "both" + let align = 'none' + if a:type ==? 'AlignLeft' + let align = 'left' + elseif a:type ==? 'AlignBoth' + let align = 'both' endif call s:CommentLines(forceNested, align, firstLine, lastLine) @@ -1278,7 +1278,7 @@ function! NERDComment(mode, type) range catch /NERDCommenter.Delimiters/ call s:CommentLines(forceNested, g:NERDDefaultAlign, firstLine, lastLine) catch /NERDCommenter.Nesting/ - call s:NerdEcho("Sexy comment aborted. Nested sexy cannot be nested", 0) + call s:NerdEcho('Sexy comment aborted. Nested sexy cannot be nested', 0) endtry elseif a:type ==? 'Toggle' @@ -1311,14 +1311,14 @@ function! NERDComment(mode, type) range try call s:CommentLinesMinimal(firstLine, lastLine) catch /NERDCommenter.Delimiters/ - call s:NerdEcho("Minimal comments can only be used for filetypes that have multipart delimiters.", 0) + call s:NerdEcho('Minimal comments can only be used for filetypes that have multipart delimiters.', 0) catch /NERDCommenter.Settings/ - call s:NerdEcho("Place holders are required but disabled.", 0) + call s:NerdEcho('Place holders are required but disabled.', 0) endtry elseif a:type ==? 'ToEOL' call s:SaveScreenState() - call s:CommentBlock(firstLine, firstLine, col("."), col("$")-1, 1) + call s:CommentBlock(firstLine, firstLine, col('.'), col('$')-1, 1) call s:RestoreScreenState() elseif a:type ==? 'Append' @@ -1345,13 +1345,13 @@ function! NERDComment(mode, type) range if isVisual let nlines = lastLine - firstLine - silent! call repeat#set("V" . nlines . "jo" . "\NERDCommenter". a:type) + silent! call repeat#set('V' . nlines . 'jo' . "\NERDCommenter". a:type) else silent! call repeat#set("\NERDCommenter". a:type) endif if exists('*NERDCommenter_after') - exe "call NERDCommenter_after()" + exe 'call NERDCommenter_after()' endif endfunction @@ -1364,40 +1364,40 @@ function s:PlaceDelimitersAndInsBetween() let left = s:Left({'space': 1}) let right = s:Right({'space': 1}) - let theLine = getline(".") + let theLine = getline('.') let lineHasLeadTabs = s:HasLeadingTabs(theLine) || (theLine =~ '^ *$' && !&expandtab) "convert tabs to spaces and adjust the cursors column to take this into "account - let untabbedCol = s:UntabbedCol(theLine, col(".")) - call setline(line("."), s:ConvertLeadingTabsToSpaces(theLine)) - call cursor(line("."), untabbedCol) + let untabbedCol = s:UntabbedCol(theLine, col('.')) + call setline(line('.'), s:ConvertLeadingTabsToSpaces(theLine)) + call cursor(line('.'), untabbedCol) " get the length of the right delimiter let lenRight = strlen(right) - let isDelimOnEOL = col(".") >= strlen(getline(".")) + let isDelimOnEOL = col('.') >= strlen(getline('.')) " if the cursor is in the first col then we gotta insert rather than " append the comment delimiters here - let insOrApp = (col(".")==1 ? 'i' : 'a') + let insOrApp = (col('.')==1 ? 'i' : 'a') " place the delimiters down. We do it differently depending on whether " there is a left AND right delimiter if lenRight > 0 - execute ":normal! " . insOrApp . left . right - execute ":normal! " . lenRight . "h" + execute ':normal! ' . insOrApp . left . right + execute ':normal! ' . lenRight . 'h' else - execute ":normal! " . insOrApp . left + execute ':normal! ' . insOrApp . left endif silent! normal! l "if needed convert spaces back to tabs and adjust the cursors col "accordingly if lineHasLeadTabs - let tabbedCol = s:TabbedCol(getline("."), col(".")) - call setline(line("."), s:ConvertLeadingSpacesToTabs(getline("."))) - call cursor(line("."), tabbedCol) + let tabbedCol = s:TabbedCol(getline('.'), col('.')) + call setline(line('.'), s:ConvertLeadingSpacesToTabs(getline('.'))) + call cursor(line('.'), tabbedCol) endif if isDelimOnEOL && lenRight == 0 @@ -1412,7 +1412,7 @@ endfunction " last right delimiter of the given line. " " The arguments left and right must be strings. If there is no right delimiter (as -" is the case for e.g vim file comments) them the argument right should be "" +" is the case for e.g vim file comments) them the argument right should be '' " " Args: " -left: the left comment delimiter @@ -1475,7 +1475,7 @@ function s:SetupStateBeforeLineComment(topLine, bottomLine) " manual, do the commenting stuff and recover it later. To avoid slowing " down commenting few lines, we avoid doing this for ranges smaller than " 10 lines - if a:bottomLine - a:topLine >= 10 && &foldmethod != "manual" + if a:bottomLine - a:topLine >= 10 && &foldmethod != 'manual' set foldmethod=manual endif @@ -1814,7 +1814,7 @@ endfunction " Function: s:AddRightDelimAligned(delim, theLine, alignIndx) {{{2 " Args: function s:AddRightDelimAligned(delim, theLine, alignIndx) - if a:delim == "" + if a:delim == '' return a:theLine else @@ -1881,10 +1881,10 @@ endfunction " Function: s:CanPlaceCursor(line, col) {{{2 " returns 1 if the cursor can be placed exactly in the given position function s:CanPlaceCursor(line, col) - let c = col(".") - let l = line(".") + let c = col('.') + let l = line('.') call cursor(a:line, a:col) - let success = (line(".") == a:line && col(".") == a:col) + let success = (line('.') == a:line && col('.') == a:col) call cursor(l,c) return success endfunction @@ -1942,7 +1942,7 @@ endfunction function s:ConvertLeadingSpacesToTabs(line) let toReturn = a:line while toReturn =~ '^\t*' . s:TabSpace() . '\(.*\)$' - let toReturn = substitute(toReturn, '^\(\t*\)' . s:TabSpace() . '\(.*\)$' , '\1\t\2' , "") + let toReturn = substitute(toReturn, '^\(\t*\)' . s:TabSpace() . '\(.*\)$' , '\1\t\2' , '') endwhile return toReturn @@ -1958,7 +1958,7 @@ endfunction function s:ConvertLeadingTabsToSpaces(line) let toReturn = a:line while toReturn =~ '^\( *\)\t' - let toReturn = substitute(toReturn, '^\( *\)\t', '\1' . s:TabSpace() , "") + let toReturn = substitute(toReturn, '^\( *\)\t', '\1' . s:TabSpace() , '') endwhile return toReturn @@ -1972,7 +1972,7 @@ endfunction function s:ConvertLeadingWhiteSpace(line) let toReturn = a:line while toReturn =~ '^ *\t' - let toReturn = substitute(toReturn, '^ *\zs\t\ze', s:TabSpace(), "g") + let toReturn = substitute(toReturn, '^ *\zs\t\ze', s:TabSpace(), 'g') endwhile if !&expandtab @@ -2062,7 +2062,7 @@ endfunction function s:FindDelimiterIndex(delimiter, line) "make sure the delimiter isn't empty otherwise we go into an infinite loop. - if a:delimiter == "" + if a:delimiter == '' return -1 endif @@ -2474,13 +2474,13 @@ function s:IsDelimValid(delimiter, delIndx, line) "to check if the delimiter is real, make sure it isn't preceded by "an odd number of quotes and followed by the same (which would indicate "that it is part of a string and therefore is not a comment) - if !s:IsNumEven(s:CountNonESCedOccurances(preComStr, '"', "\\")) && !s:IsNumEven(s:CountNonESCedOccurances(postComStr, '"', "\\")) + if !s:IsNumEven(s:CountNonESCedOccurances(preComStr, '"', "\\")) && !s:IsNumEven(s:CountNonESCedOccurances(postComStr, '"', '\\')) return 0 endif - if !s:IsNumEven(s:CountNonESCedOccurances(preComStr, "'", "\\")) && !s:IsNumEven(s:CountNonESCedOccurances(postComStr, "'", "\\")) + if !s:IsNumEven(s:CountNonESCedOccurances(preComStr, "'", '\\')) && !s:IsNumEven(s:CountNonESCedOccurances(postComStr, "'", '\\')) return 0 endif - if !s:IsNumEven(s:CountNonESCedOccurances(preComStr, "`", "\\")) && !s:IsNumEven(s:CountNonESCedOccurances(postComStr, "`", "\\")) + if !s:IsNumEven(s:CountNonESCedOccurances(preComStr, '`', '\\')) && !s:IsNumEven(s:CountNonESCedOccurances(postComStr, '`', '\\')) return 0 endif @@ -2493,7 +2493,7 @@ function s:IsDelimValid(delimiter, delIndx, line) "vim comments are so fucking stupid!! Why the hell do they have comment "delimiters that are used elsewhere in the syntax?!?! We need to check "some conditions especially for vim - if &filetype == "vim" + if &filetype == 'vim' if !s:IsNumEven(s:CountNonESCedOccurances(preComStr, '"', "\\")) return 0 endif @@ -2504,8 +2504,8 @@ function s:IsDelimValid(delimiter, delIndx, line) return 1 endif - let numLeftParen =s:CountNonESCedOccurances(preComStr, "(", "\\") - let numRightParen =s:CountNonESCedOccurances(preComStr, ")", "\\") + let numLeftParen =s:CountNonESCedOccurances(preComStr, '(', '\\') + let numRightParen =s:CountNonESCedOccurances(preComStr, ')', '\\') "if the quote is inside brackets then assume it isn't a comment if numLeftParen > numRightParen @@ -2514,7 +2514,7 @@ function s:IsDelimValid(delimiter, delIndx, line) "if the line has an even num of unescaped "'s then we can assume that "any given " is not a comment delimiter - if s:IsNumEven(s:CountNonESCedOccurances(a:line, "\"", "\\")) + if s:IsNumEven(s:CountNonESCedOccurances(a:line, '"', '\\')) return 0 endif endif @@ -2781,7 +2781,7 @@ endfunction " Function: s:NumberOfLeadingTabs(s) {{{2 " returns the number of leading tabs in the given string function s:NumberOfLeadingTabs(s) - return strlen(substitute(a:s, '^\(\t*\).*$', '\1', "")) + return strlen(substitute(a:s, '^\(\t*\).*$', '\1', '')) endfunction " Function: s:NumLinesInBuf() {{{2 @@ -2861,13 +2861,13 @@ endfunction "called. " function s:RestoreScreenState() - if !exists("t:NERDComOldTopLine") || !exists("t:NERDComOldPos") + if !exists('t:NERDComOldTopLine') || !exists('t:NERDComOldPos') throw 'NERDCommenter exception: cannot restore screen' endif call cursor(t:NERDComOldTopLine, 0) normal! zt - call setpos(".", t:NERDComOldPos) + call setpos('.', t:NERDComOldPos) endfunction " Function: s:Right(...) {{{2 @@ -2935,8 +2935,8 @@ endfunction "Saves the current cursor position in the current buffer and the window "scroll position function s:SaveScreenState() - let t:NERDComOldPos = getpos(".") - let t:NERDComOldTopLine = line("w0") + let t:NERDComOldPos = getpos('.') + let t:NERDComOldTopLine = line('w0') endfunction " Function: s:SwapOuterMultiPartDelimsForPlaceHolders(line) {{{2 @@ -3001,10 +3001,10 @@ endfunction "FUNCTION: s:TabSpace() {{{2 "returns a string of spaces equal in length to &tabstop function s:TabSpace() - let tabSpace = "" + let tabSpace = '' let spacesPerTab = &tabstop while spacesPerTab > 0 - let tabSpace = tabSpace . " " + let tabSpace = tabSpace . ' ' let spacesPerTab = spacesPerTab - 1 endwhile return tabSpace @@ -3016,7 +3016,7 @@ endfunction " -str: the string to remove esc chars from " -escChar: the escape char to be removed function s:UnEsc(str, escChar) - return substitute(a:str, a:escChar, "", "g") + return substitute(a:str, a:escChar, '', 'g') endfunction " Function: s:UntabbedCol(line, col) {{{2 @@ -3084,7 +3084,7 @@ call s:CreateMaps('i', 'Insert', 'Insert Comment Here', '') call s:CreateMaps('', ':', '-Sep3-', '') call s:CreateMaps('', ':help NERDCommenterContents', 'Help', '') -inoremap NERDCommenterInsert :call NERDComment('i', "insert") +inoremap NERDCommenterInsert :call NERDComment('i', 'insert') " switch to/from alternative delimiters (does not use wrapper function) nnoremap NERDCommenterAltDelims :call SwitchToAlternativeDelimiters(1) From 277986725dbd4afd203ae81e3275a7f902463e73 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Mon, 30 Dec 2019 11:02:22 +0300 Subject: [PATCH 21/42] Fix lint warning: use robust operators --- plugin/NERD_commenter.vim | 222 +++++++++++++++++++------------------- 1 file changed, 111 insertions(+), 111 deletions(-) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index a916197..b55221c 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -528,7 +528,7 @@ function s:SetUpForNewFiletype(filetype, forceReset) "for compound filetypes, if we don't know how to handle the full filetype "then break it down and use the first part that we know how to handle - if ft =~ '\.' && !has_key(s:delimiterMap, ft) + if ft =~# '\.' && !has_key(s:delimiterMap, ft) let filetypes = split(a:filetype, '\.') for i in filetypes if has_key(s:delimiterMap, i) @@ -565,7 +565,7 @@ function s:SetUpForNewFiletype(filetype, forceReset) endfunction function s:CreateDelimMapFromCms() - if &ft == '' && exists('g:NERDDefaultDelims') + if &ft ==# '' && exists('g:NERDDefaultDelims') let delims = g:NERDDefaultDelims for i in ['left', 'leftAlt', 'right', 'rightAlt'] if !has_key(delims, i) @@ -598,7 +598,7 @@ function s:SwitchToAlternativeDelimiters(printMsgs) endif "if both of the alternative delimiters are empty then there is no "alternative comment style so bail out - if b:NERDCommenterDelims['leftAlt'] == '' && b:NERDCommenterDelims['rightAlt'] == '' + if b:NERDCommenterDelims['leftAlt'] ==# '' && b:NERDCommenterDelims['rightAlt'] ==# '' if a:printMsgs call s:NerdEcho('Cannot use alternative delimiters, none are specified', 0) endif @@ -645,8 +645,8 @@ function s:AppendCommentToLine() " get the length of the right delimiter let lenRight = strlen(right) - let isLineEmpty = strlen(getline('.')) == 0 - let insOrApp = (isLineEmpty==1 ? 'i' : 'A') + let isLineEmpty = strlen(getline('.')) ==# 0 + let insOrApp = (isLineEmpty==#1 ? 'i' : 'A') "stick the delimiters down at the end of the line. We have to format the "comment with spaces as appropriate @@ -740,7 +740,7 @@ function s:CommentBlock(top, bottom, lSide, rSide, forceNested ) "don't comment lines that begin after the right boundary of the "block unless the user has specified to do so - if theLine !~ '^ \{' . rSide . '\}' || !g:NERDBlockComIgnoreEmpty + if theLine !~# '^ \{' . rSide . '\}' || !g:NERDBlockComIgnoreEmpty "attempt to place the cursor in on the left of the boundary box, "then check if we were successful, if not then we cant comment this @@ -761,7 +761,7 @@ function s:CommentBlock(top, bottom, lSide, rSide, forceNested ) let firstLeftDelim = s:FindDelimiterIndex(s:Left(), theLine) let lastRightDelim = s:LastIndexOfDelim(s:Right(), theLine) - if firstLeftDelim != -1 && lastRightDelim != -1 + if firstLeftDelim !=# -1 && lastRightDelim !=# -1 let searchStr = strpart(theLine, 0, lastRightDelim) let searchStr = strpart(searchStr, firstLeftDelim+strlen(s:Left())) @@ -781,7 +781,7 @@ function s:CommentBlock(top, bottom, lSide, rSide, forceNested ) let theLine = s:ConvertLeadingSpacesToTabs(theLine) endif - if g:NERDTrimTrailingWhitespace == 1 + if g:NERDTrimTrailingWhitespace ==# 1 let theLine = s:TrimTrailingWhitespace(theLine) endif @@ -792,7 +792,7 @@ function s:CommentBlock(top, bottom, lSide, rSide, forceNested ) endwhile "if we switched delimiterss then we gotta go back to what they were before - if switchedDelims == 1 + if switchedDelims ==# 1 call s:SwitchToAlternativeDelimiters(0) endif endfunction @@ -809,7 +809,7 @@ function s:CommentLines(forceNested, align, firstLine, lastLine) " we need to get the left and right indexes of the leftmost char in the " block of of lines and the right most char so that we can do alignment of " the delimiters if the user has specified - let leftAlignIndx = a:align == 'start' ? 0 : s:LeftMostIndx(a:forceNested, 0, a:firstLine, a:lastLine) + let leftAlignIndx = a:align ==# 'start' ? 0 : s:LeftMostIndx(a:forceNested, 0, a:firstLine, a:lastLine) let rightAlignIndx = s:RightMostIndx(a:forceNested, 0, a:firstLine, a:lastLine) " gotta add the length of the left delimiter onto the rightAlignIndx cos @@ -837,12 +837,12 @@ function s:CommentLines(forceNested, align, firstLine, lastLine) " check if we can comment this line if !isCommented || g:NERDUsePlaceHolders || s:Multipart() - if a:align == 'left' || a:align == 'start' || a:align == 'both' + if a:align ==# 'left' || a:align ==# 'start' || a:align ==# 'both' let theLine = s:AddLeftDelimAligned(s:Left({'space': 1}), theLine, leftAlignIndx) else let theLine = s:AddLeftDelim(s:Left({'space': 1}), theLine) endif - if a:align == 'both' + if a:align ==# 'both' let theLine = s:AddRightDelimAligned(s:Right({'space': 1}), theLine, rightAlignIndx) else let theLine = s:AddRightDelim(s:Right({'space': 1}), theLine) @@ -855,7 +855,7 @@ function s:CommentLines(forceNested, align, firstLine, lastLine) let theLine = s:ConvertLeadingSpacesToTabs(theLine) endif - if g:NERDTrimTrailingWhitespace == 1 + if g:NERDTrimTrailingWhitespace ==# 1 let theLine = s:TrimTrailingWhitespace(theLine) endif @@ -920,7 +920,7 @@ function s:CommentLinesMinimal(firstLine, lastLine) let theLine = s:ConvertLeadingSpacesToTabs(theLine) endif - if g:NERDTrimTrailingWhitespace == 1 + if g:NERDTrimTrailingWhitespace ==# 1 let theLine = s:TrimTrailingWhitespace(theLine) endif @@ -940,7 +940,7 @@ function s:CommentLinesSexy(topline, bottomline) let right = s:GetSexyComRight(0, 0) "check if we can do a sexy comment with the available delimiters - if left == -1 || right == -1 + if left ==# -1 || right ==# -1 throw 'NERDCommenter.Delimiters exception: cannot perform sexy comments with available delimiters.' endif @@ -979,7 +979,7 @@ function s:CommentLinesSexy(topline, bottomline) call setline(a:topline, theLine) "comment the bottom line - if a:bottomline != a:topline + if a:bottomline !=# a:topline let theLine = getline(a:bottomline) let lineHasTabs = s:HasLeadingTabs(theLine) if lineHasTabs @@ -1051,7 +1051,7 @@ function s:CommentLinesSexy(topline, bottomline) let theLine = s:ConvertLeadingSpacesToTabs(theLine) endif - if g:NERDTrimTrailingWhitespace == 1 + if g:NERDTrimTrailingWhitespace ==# 1 let theLine = s:TrimTrailingWhitespace(theLine) endif @@ -1073,7 +1073,7 @@ function s:CommentLinesToggle(forceNested, firstLine, lastLine) let currentLine = a:firstLine let align = g:NERDDefaultAlign - let leftAlignIndx = align == 'start' ? 0 : s:LeftMostIndx(a:forceNested, 0, a:firstLine, a:lastLine) + let leftAlignIndx = align ==# 'start' ? 0 : s:LeftMostIndx(a:forceNested, 0, a:firstLine, a:lastLine) let rightAlignIndx = s:RightMostIndx(a:forceNested, 0, a:firstLine, a:lastLine) let rightAlignIndx = rightAlignIndx + strlen(s:Left({'space': 1})) @@ -1091,12 +1091,12 @@ function s:CommentLinesToggle(forceNested, firstLine, lastLine) let theLine = s:SwapOuterMultiPartDelimsForPlaceHolders(theLine) endif - if align == 'left' || align == 'start' || align == 'both' + if align ==# 'left' || align ==# 'start' || align ==# 'both' let theLine = s:AddLeftDelimAligned(s:Left({'space': 1}), theLine, leftAlignIndx) else let theLine = s:AddLeftDelim(s:Left({'space': 1}), theLine) endif - if align == 'both' + if align ==# 'both' let theLine = s:AddRightDelimAligned(s:Right({'space': 1}), theLine, rightAlignIndx) else let theLine = s:AddRightDelim(s:Right({'space': 1}), theLine) @@ -1108,7 +1108,7 @@ function s:CommentLinesToggle(forceNested, firstLine, lastLine) let theLine = s:ConvertLeadingSpacesToTabs(theLine) endif - if g:NERDTrimTrailingWhitespace == 1 + if g:NERDTrimTrailingWhitespace ==# 1 let theLine = s:TrimTrailingWhitespace(theLine) endif @@ -1139,7 +1139,7 @@ function s:CommentRegion(topLine, topCol, bottomLine, bottomCol, forceNested) endif "if there is only one line in the comment then just do it - if a:topLine == a:bottomLine + if a:topLine ==# a:bottomLine call s:CommentBlock(a:topLine, a:bottomLine, a:topCol, a:bottomCol, a:forceNested) "there are multiple lines in the comment @@ -1165,7 +1165,7 @@ function s:CommentRegion(topLine, topCol, bottomLine, bottomCol, forceNested) call cursor(a:topLine, a:topCol + strlen(s:Left()) + g:NERDSpaceDelims) "if we switched delimiters then we gotta go back to what they were before - if switchedDelims == 1 + if switchedDelims ==# 1 call s:SwitchToAlternativeDelimiters(0) endif @@ -1228,9 +1228,9 @@ function! NERDComment(mode, type) range exe 'call NERDCommenter_before()' endif - let isVisual = a:mode =~ '[vsx]' + let isVisual = a:mode =~# '[vsx]' - if !exists('g:did_load_ftplugin') || g:did_load_ftplugin != 1 + if !exists('g:did_load_ftplugin') || g:did_load_ftplugin !=# 1 call s:NerdEcho('filetype plugins should be enabled. See :help NERDComInstallation and :help :filetype-plugin-on', 0) endif @@ -1238,7 +1238,7 @@ function! NERDComment(mode, type) range let firstLine = line("'<") let lastLine = line("'>") let firstCol = col("'<") - let lastCol = col("'>") - (&selection == 'exclusive' ? 1 : 0) + let lastCol = col("'>") - (&selection ==# 'exclusive' ? 1 : 0) else let firstLine = a:firstline let lastLine = a:lastline @@ -1247,14 +1247,14 @@ function! NERDComment(mode, type) range " Save options we need to change so we can recover them later let state = s:SetupStateBeforeLineComment(firstLine, lastLine) - let countWasGiven = (!isVisual && firstLine != lastLine) + let countWasGiven = (!isVisual && firstLine !=# lastLine) let forceNested = (a:type ==? 'Nested' || g:NERDDefaultNesting) if a:type ==? 'Comment' || a:type ==? 'Nested' - if isVisual && visualmode() == "\" + if isVisual && visualmode() ==# "\" call s:CommentBlock(firstLine, lastLine, firstCol, lastCol, forceNested) - elseif isVisual && visualmode() == 'v' && (g:NERDCommentWholeLinesInVMode==0 || (g:NERDCommentWholeLinesInVMode==2 && s:HasMultipartDelims())) + elseif isVisual && visualmode() ==# 'v' && (g:NERDCommentWholeLinesInVMode==#0 || (g:NERDCommentWholeLinesInVMode==#2 && s:HasMultipartDelims())) call s:CommentRegion(firstLine, firstCol, lastLine, lastCol, forceNested) else call s:CommentLines(forceNested, g:NERDDefaultAlign, firstLine, lastLine) @@ -1294,7 +1294,7 @@ function! NERDComment(mode, type) range for i in range(firstLine, lastLine) let theLine = getline(i) " if have one line no comment(not include blank/whitespace-only lines), then comment all lines - if theLine =~ '[^ \t]\+' && !s:IsInSexyComment(firstLine) && !s:IsCommentedFromStartOfLine(s:Left(), theLine) && !s:IsCommentedFromStartOfLine(s:Left({'alt': 1}), theLine) + if theLine =~# '[^ \t]\+' && !s:IsInSexyComment(firstLine) && !s:IsCommentedFromStartOfLine(s:Left(), theLine) && !s:IsCommentedFromStartOfLine(s:Left({'alt': 1}), theLine) let l:commentAllLines = 1 break else @@ -1365,7 +1365,7 @@ function s:PlaceDelimitersAndInsBetween() let right = s:Right({'space': 1}) let theLine = getline('.') - let lineHasLeadTabs = s:HasLeadingTabs(theLine) || (theLine =~ '^ *$' && !&expandtab) + let lineHasLeadTabs = s:HasLeadingTabs(theLine) || (theLine =~# '^ *$' && !&expandtab) "convert tabs to spaces and adjust the cursors column to take this into "account @@ -1400,7 +1400,7 @@ function s:PlaceDelimitersAndInsBetween() call cursor(line('.'), tabbedCol) endif - if isDelimOnEOL && lenRight == 0 + if isDelimOnEOL && lenRight ==# 0 startinsert! else startinsert @@ -1431,24 +1431,24 @@ function s:RemoveDelimiters(left, right, line) "look for the left delimiter, if we find it, remove it. let leftIndx = s:FindDelimiterIndex(a:left, line) - if leftIndx != -1 + if leftIndx !=# -1 let line = strpart(line, 0, leftIndx) . strpart(line, leftIndx+lenLeft) "if the user has specified that there is a space after the left delimiter "then check for the space and remove it if it is there - if delimsSpaced && strpart(line, leftIndx, s:lenSpaceStr) == s:spaceStr + if delimsSpaced && strpart(line, leftIndx, s:lenSpaceStr) ==# s:spaceStr let line = strpart(line, 0, leftIndx) . strpart(line, leftIndx+s:lenSpaceStr) endif endif "look for the right delimiter, if we find it, remove it let rightIndx = s:LastIndexOfDelim(a:right, line) - if rightIndx != -1 + if rightIndx !=# -1 let line = strpart(line, 0, rightIndx) . strpart(line, rightIndx+lenRight) "if the user has specified that there is a space before the right delimiter "then check for the space and remove it if it is there - if delimsSpaced && strpart(line, rightIndx-s:lenSpaceStr, s:lenSpaceStr) == s:spaceStr && (s:Multipart() || s:AltMultipart()) + if delimsSpaced && strpart(line, rightIndx-s:lenSpaceStr, s:lenSpaceStr) ==# s:spaceStr && (s:Multipart() || s:AltMultipart()) let line = strpart(line, 0, rightIndx-s:lenSpaceStr) . strpart(line, rightIndx) endif endif @@ -1475,7 +1475,7 @@ function s:SetupStateBeforeLineComment(topLine, bottomLine) " manual, do the commenting stuff and recover it later. To avoid slowing " down commenting few lines, we avoid doing this for ranges smaller than " 10 lines - if a:bottomLine - a:topLine >= 10 && &foldmethod != 'manual' + if a:bottomLine - a:topLine >= 10 && &foldmethod !=# 'manual' set foldmethod=manual endif @@ -1493,10 +1493,10 @@ endfunction " state: the top line of the visual selection to uncomment " bottomLine: the bottom line of the visual selection to uncomment function s:RecoverStateAfterLineComment(state) - if a:state['foldmethod'] != &foldmethod + if a:state['foldmethod'] !=# &foldmethod let &foldmethod = a:state['foldmethod'] endif - if a:state['ignorecase'] != &ignorecase + if a:state['ignorecase'] !=# &ignorecase let &ignorecase = a:state['ignorecase'] endif endfunction @@ -1568,7 +1568,7 @@ function s:UncommentLinesSexy(topline, bottomline) "check if it is even possible for sexy comments to exist with the "available delimiters - if left == -1 || right == -1 + if left ==# -1 || right ==# -1 throw 'NERDCommenter.Delimiters exception: cannot uncomment sexy comments with available delimiters.' endif @@ -1592,7 +1592,7 @@ function s:UncommentLinesSexy(topline, bottomline) " remove the sexy comment marker from the line. We also remove the " space after it if there is one and if appropriate options are set let sexyComMarkerIndx = stridx(theLine, sexyComMarkerUnEsc) - if strpart(theLine, sexyComMarkerIndx+strlen(sexyComMarkerUnEsc), s:lenSpaceStr) == s:spaceStr && g:NERDSpaceDelims + if strpart(theLine, sexyComMarkerIndx+strlen(sexyComMarkerUnEsc), s:lenSpaceStr) ==# s:spaceStr && g:NERDSpaceDelims let theLine = strpart(theLine, 0, sexyComMarkerIndx - markerOffset) . strpart(theLine, sexyComMarkerIndx+strlen(sexyComMarkerUnEsc)+s:lenSpaceStr) else let theLine = strpart(theLine, 0, sexyComMarkerIndx - markerOffset) . strpart(theLine, sexyComMarkerIndx+strlen(sexyComMarkerUnEsc)) @@ -1602,7 +1602,7 @@ function s:UncommentLinesSexy(topline, bottomline) let theLine = s:ConvertLeadingWhiteSpace(theLine) - if g:NERDTrimTrailingWhitespace == 1 + if g:NERDTrimTrailingWhitespace ==# 1 let theLine = s:TrimTrailingWhitespace(theLine) endif @@ -1619,7 +1619,7 @@ function s:UncommentLinesSexy(topline, bottomline) let theLine = getline(a:topline) " if the first line contains only the left delimiter then just delete it - if theLine =~ '^[ \t]*' . left . '[ \t]*$' && !g:NERDCompactSexyComs + if theLine =~# '^[ \t]*' . left . '[ \t]*$' && !g:NERDCompactSexyComs call cursor(a:topline, 1) normal! dd let bottomline = bottomline - 1 @@ -1630,7 +1630,7 @@ function s:UncommentLinesSexy(topline, bottomline) " remove the delimiter. If there is a space after it " then remove this too if appropriate let delimIndx = stridx(theLine, leftUnEsc) - if strpart(theLine, delimIndx+strlen(leftUnEsc), s:lenSpaceStr) == s:spaceStr && g:NERDSpaceDelims + if strpart(theLine, delimIndx+strlen(leftUnEsc), s:lenSpaceStr) ==# s:spaceStr && g:NERDSpaceDelims let theLine = strpart(theLine, 0, delimIndx) . strpart(theLine, delimIndx+strlen(leftUnEsc)+s:lenSpaceStr) else let theLine = strpart(theLine, 0, delimIndx) . strpart(theLine, delimIndx+strlen(leftUnEsc)) @@ -1643,7 +1643,7 @@ function s:UncommentLinesSexy(topline, bottomline) let theLine = getline(bottomline) " if the bottomline contains only the right delimiter then just delete it - if theLine =~ '^[ \t]*' . right . '[ \t]*$' + if theLine =~# '^[ \t]*' . right . '[ \t]*$' call cursor(bottomline, 1) normal! dd @@ -1652,7 +1652,7 @@ function s:UncommentLinesSexy(topline, bottomline) " remove the right delimiter. If there is a space after it and " if the appropriate options are set then remove this too. let delimIndx = s:LastIndexOfDelim(rightUnEsc, theLine) - if strpart(theLine, delimIndx+strlen(leftUnEsc), s:lenSpaceStr) == s:spaceStr && g:NERDSpaceDelims + if strpart(theLine, delimIndx+strlen(leftUnEsc), s:lenSpaceStr) ==# s:spaceStr && g:NERDSpaceDelims let theLine = strpart(theLine, 0, delimIndx) . strpart(theLine, delimIndx+strlen(rightUnEsc)+s:lenSpaceStr) else let theLine = strpart(theLine, 0, delimIndx) . strpart(theLine, delimIndx+strlen(rightUnEsc)) @@ -1660,12 +1660,12 @@ function s:UncommentLinesSexy(topline, bottomline) " if the last line also starts with a sexy comment marker then we " remove this as well - if theLine =~ '^[ \t]*' . sexyComMarker + if theLine =~# '^[ \t]*' . sexyComMarker " remove the sexyComMarker. If there is a space after it then " remove that too let sexyComMarkerIndx = stridx(theLine, sexyComMarkerUnEsc) - if strpart(theLine, sexyComMarkerIndx+strlen(sexyComMarkerUnEsc), s:lenSpaceStr) == s:spaceStr && g:NERDSpaceDelims + if strpart(theLine, sexyComMarkerIndx+strlen(sexyComMarkerUnEsc), s:lenSpaceStr) ==# s:spaceStr && g:NERDSpaceDelims let theLine = strpart(theLine, 0, sexyComMarkerIndx - markerOffset ) . strpart(theLine, sexyComMarkerIndx+strlen(sexyComMarkerUnEsc)+s:lenSpaceStr) else let theLine = strpart(theLine, 0, sexyComMarkerIndx - markerOffset ) . strpart(theLine, sexyComMarkerIndx+strlen(sexyComMarkerUnEsc)) @@ -1677,7 +1677,7 @@ function s:UncommentLinesSexy(topline, bottomline) endif " remove trailing whitespaces for first and last line - if g:NERDTrimTrailingWhitespace == 1 + if g:NERDTrimTrailingWhitespace ==# 1 let theLine = getline(a:bottomline) let theLine = s:TrimTrailingWhitespace(theLine) call setline(a:bottomline, theLine) @@ -1704,27 +1704,27 @@ function s:UncommentLineNormal(line) let lineCommentStatus = s:IsCommentedOutermost(s:Left(), s:Right(), s:Left({'alt': 1}), s:Right({'alt': 1}), line) "it is commented with s:Left() and s:Right() so remove these delimiters - if lineCommentStatus == 1 + if lineCommentStatus ==# 1 let line = s:RemoveDelimiters(s:Left(), s:Right(), line) "it is commented with s:Left({'alt': 1}) and s:Right({'alt': 1}) so remove these delimiters - elseif lineCommentStatus == 2 && g:NERDRemoveAltComs + elseif lineCommentStatus ==# 2 && g:NERDRemoveAltComs let line = s:RemoveDelimiters(s:Left({'alt': 1}), s:Right({'alt': 1}), line) "it is not properly commented with any delimiters so we check if it has "any random left or right delimiters on it and remove the outermost ones else "remove the outer most left comment delimiter - if indxLeft != -1 && (indxLeft < indxLeftAlt || indxLeftAlt == -1) + if indxLeft !=# -1 && (indxLeft < indxLeftAlt || indxLeftAlt ==# -1) let line = s:RemoveDelimiters(s:Left(), '', line) - elseif indxLeftAlt != -1 && g:NERDRemoveAltComs + elseif indxLeftAlt !=# -1 && g:NERDRemoveAltComs let line = s:RemoveDelimiters(s:Left({'alt': 1}), '', line) endif "remove the outer most right comment delimiter - if indxRight != -1 && (indxRight < indxRightAlt || indxRightAlt == -1) + if indxRight !=# -1 && (indxRight < indxRightAlt || indxRightAlt ==# -1) let line = s:RemoveDelimiters('', s:Right(), line) - elseif indxRightAlt != -1 && g:NERDRemoveAltComs + elseif indxRightAlt !=# -1 && g:NERDRemoveAltComs let line = s:RemoveDelimiters('', s:Right({'alt': 1}), line) endif endif @@ -1744,11 +1744,11 @@ function s:UncommentLineNormal(line) "if there are place-holders on the line then we check to see if they are "the outermost delimiters on the line. If so then we replace them with "real delimiters - if indxLeftPlace != -1 + if indxLeftPlace !=# -1 if (indxLeftPlace < indxLeft || indxLeft==-1) && (indxLeftPlace < indxLeftAlt || indxLeftAlt==-1) let line = s:ReplaceDelims(g:NERDLPlace, g:NERDRPlace, left, right, line) endif - elseif indxRightPlace != -1 + elseif indxRightPlace !=# -1 if (indxRightPlace < indxLeft || indxLeft==-1) && (indxLeftPlace < indxLeftAlt || indxLeftAlt==-1) let line = s:ReplaceDelims(g:NERDLPlace, g:NERDRPlace, left, right, line) endif @@ -1757,7 +1757,7 @@ function s:UncommentLineNormal(line) let line = s:ConvertLeadingWhiteSpace(line) - if g:NERDTrimTrailingWhitespace == 1 + if g:NERDTrimTrailingWhitespace ==# 1 let line = s:TrimTrailingWhitespace(line) endif @@ -1804,7 +1804,7 @@ endfunction " Function: s:AddRightDelim(delim, theLine) {{{2 " Args: function s:AddRightDelim(delim, theLine) - if a:delim == '' + if a:delim ==# '' return a:theLine else return substitute(a:theLine, '$', a:delim, '') @@ -1814,7 +1814,7 @@ endfunction " Function: s:AddRightDelimAligned(delim, theLine, alignIndx) {{{2 " Args: function s:AddRightDelimAligned(delim, theLine, alignIndx) - if a:delim == '' + if a:delim ==# '' return a:theLine else @@ -1832,7 +1832,7 @@ endfunction " Function: s:AltMultipart() {{{2 " returns 1 if the alternative delimiters are multipart function s:AltMultipart() - return b:NERDCommenterDelims['rightAlt'] != '' + return b:NERDCommenterDelims['rightAlt'] !=# '' endfunction " Function: s:AltNested() {{{2 @@ -1854,7 +1854,7 @@ function s:CanCommentLine(forceNested, lineNum) " make sure we don't comment lines that are just spaces or tabs or empty, " unless configured otherwise - if g:NERDCommentEmptyLines == 0 && theLine =~ "^[ \t]*$" + if g:NERDCommentEmptyLines ==# 0 && theLine =~# "^[ \t]*$" return 0 endif @@ -1884,7 +1884,7 @@ function s:CanPlaceCursor(line, col) let c = col('.') let l = line('.') call cursor(a:line, a:col) - let success = (line('.') == a:line && col('.') == a:col) + let success = (line('.') ==# a:line && col('.') ==# a:col) call cursor(l,c) return success endfunction @@ -1921,7 +1921,7 @@ function s:CanToggleCommentLine(forceNested, lineNum) " make sure we don't comment lines that are just spaces or tabs or empty, " unless configured otherwise - if g:NERDCommentEmptyLines == 0 && theLine =~ "^[ \t]*$" + if g:NERDCommentEmptyLines ==# 0 && theLine =~# "^[ \t]*$" return 0 endif @@ -1941,7 +1941,7 @@ endfunction " -line: the line whose leading tabs will be converted function s:ConvertLeadingSpacesToTabs(line) let toReturn = a:line - while toReturn =~ '^\t*' . s:TabSpace() . '\(.*\)$' + while toReturn =~# '^\t*' . s:TabSpace() . '\(.*\)$' let toReturn = substitute(toReturn, '^\(\t*\)' . s:TabSpace() . '\(.*\)$' , '\1\t\2' , '') endwhile @@ -1957,7 +1957,7 @@ endfunction " -line: the line whose leading spaces will be converted function s:ConvertLeadingTabsToSpaces(line) let toReturn = a:line - while toReturn =~ '^\( *\)\t' + while toReturn =~# '^\( *\)\t' let toReturn = substitute(toReturn, '^\( *\)\t', '\1' . s:TabSpace() , '') endwhile @@ -1971,7 +1971,7 @@ endfunction " -line: the line to convert function s:ConvertLeadingWhiteSpace(line) let toReturn = a:line - while toReturn =~ '^ *\t' + while toReturn =~# '^ *\t' let toReturn = substitute(toReturn, '^ *\zs\t\ze', s:TabSpace(), 'g') endwhile @@ -1996,7 +1996,7 @@ function s:CountNonESCedOccurances(str, searchstr, escChar) let indx = stridx(a:str, a:searchstr) "if there is an instance of searchstr in str process it - if indx != -1 + if indx !=# -1 "get the remainder of str after this instance of searchstr is removed let lensearchstr = strlen(a:searchstr) let strLeft = strpart(a:str, indx+lensearchstr) @@ -2020,7 +2020,7 @@ function s:DoesBlockHaveDelim(delim, top, bottom) let currentLine = a:top while currentLine < a:bottom let theline = getline(currentLine) - if s:FindDelimiterIndex(a:delim, theline) != -1 + if s:FindDelimiterIndex(a:delim, theline) !=# -1 return 1 endif let currentLine = currentLine + 1 @@ -2062,7 +2062,7 @@ endfunction function s:FindDelimiterIndex(delimiter, line) "make sure the delimiter isn't empty otherwise we go into an infinite loop. - if a:delimiter == '' + if a:delimiter ==# '' return -1 endif @@ -2075,12 +2075,12 @@ function s:FindDelimiterIndex(delimiter, line) "keep looping thru the line till we either find a real comment delimiter "or run off the EOL - while delIndx != -1 + while delIndx !=# -1 "if we are not off the EOL get the str before the possible delimiter "in question and check if it really is a delimiter. If it is, return "its position - if delIndx != -1 + if delIndx !=# -1 if s:IsDelimValid(l:delimiter, delIndx, a:line) return delIndx endif @@ -2094,7 +2094,7 @@ function s:FindDelimiterIndex(delimiter, line) "if distToNextDelim is -1 then there is no more potential delimiters "on the line so set delIndx to -1. Otherwise, move along the line by "distToNextDelim - if distToNextDelim == -1 + if distToNextDelim ==# -1 let delIndx = -1 else let delIndx = delIndx + lenDel + distToNextDelim @@ -2138,20 +2138,20 @@ function s:FindBoundingLinesOfSexyCom(lineNum) let bottom = -1 let currentLine = a:lineNum - while top == -1 || bottom == -1 + while top ==# -1 || bottom ==# -1 let theLine = getline(currentLine) "check if the current line is the top of the sexy comment - if currentLine <= a:lineNum && theLine =~ '^[ \t]*' . left && theLine !~ '.*' . right && currentLine < s:NumLinesInBuf() + if currentLine <= a:lineNum && theLine =~# '^[ \t]*' . left && theLine !~# '.*' . right && currentLine < s:NumLinesInBuf() let top = currentLine let currentLine = a:lineNum "check if the current line is the bottom of the sexy comment - elseif theLine =~ '^[ \t]*' . right && theLine !~ '.*' . left && currentLine > 1 + elseif theLine =~# '^[ \t]*' . right && theLine !~# '.*' . left && currentLine > 1 let bottom = currentLine "the right delimiter is on the same line as the last sexyComMarker - elseif theLine =~ '^[ \t]*' . sexyComMarker . '.*' . right + elseif theLine =~# '^[ \t]*' . sexyComMarker . '.*' . right let bottom = currentLine "we have not found the top or bottom line so we assume currentLine is an @@ -2160,14 +2160,14 @@ function s:FindBoundingLinesOfSexyCom(lineNum) "if the line doesn't start with a sexyComMarker then it is not a sexy "comment - if theLine !~ '^[ \t]*' . sexyComMarker + if theLine !~# '^[ \t]*' . sexyComMarker return [] endif endif "if top is -1 then we haven't found the top yet so keep looking up - if top == -1 + if top ==# -1 let currentLine = currentLine - 1 "if we have found the top line then go down looking for the bottom else @@ -2195,7 +2195,7 @@ function s:GetSexyComMarker(space, esc) let sexyComMarker = b:NERDSexyComMarker "if there is no hardcoded marker then we find one - if sexyComMarker == '' + if sexyComMarker ==# '' "if the filetype has c style comments then use standard c sexy "comments @@ -2242,7 +2242,7 @@ function s:SexyNested() "assume c style sexy comments if possible if s:HasCStyleComments() - return (s:Left() == '/*' && s:Nested()) || (s:Left({'alt': 1}) == '/*' && s:AltNested()) + return (s:Left() ==# '/*' && s:Nested()) || (s:Left({'alt': 1}) ==# '/*' && s:AltNested()) else "grab the longest left delim that has a right if s:Multipart() && lenLeft >= lenLeftAlt @@ -2340,7 +2340,7 @@ endfunction " Returns 1 if any of the given strings have leading tabs function s:HasLeadingTabs(...) for s in a:000 - if s =~ '^\t.*' + if s =~# '^\t.*' return 1 end endfor @@ -2349,7 +2349,7 @@ endfunction " Function: s:HasCStyleComments() {{{2 " Returns 1 if the current filetype has c style comment delimiters function s:HasCStyleComments() - return (s:Left() == '/*' && s:Right() == '*/') || (s:Left({'alt': 1}) == '/*' && s:Right({'alt': 1}) == '*/') + return (s:Left() ==# '/*' && s:Right() ==# '*/') || (s:Left({'alt': 1}) ==# '/*' && s:Right({'alt': 1}) ==# '*/') endfunction " Function: s:IsCommentedNormOrSexy(lineNum) {{{2 @@ -2382,7 +2382,7 @@ endfunction " -left/right: the left and right delimiters to check for function s:IsCommented(left, right, line) "if the line isn't commented return true - if s:FindDelimiterIndex(a:left, a:line) != -1 && (s:LastIndexOfDelim(a:right, a:line) != -1 || !s:Multipart()) + if s:FindDelimiterIndex(a:left, a:line) !=# -1 && (s:LastIndexOfDelim(a:right, a:line) !=# -1 || !s:Multipart()) return 1 endif return 0 @@ -2400,7 +2400,7 @@ function s:IsCommentedFromStartOfLine(left, line) let theLine = s:ConvertLeadingTabsToSpaces(a:line) let numSpaces = strlen(substitute(theLine, '^\( *\).*$', '\1', '')) let delimIndx = s:FindDelimiterIndex(a:left, theLine) - return delimIndx == numSpaces + return delimIndx ==# numSpaces endfunction " Function: s:IsCommentedOutermost(left, right, leftAlt, rightAlt, line) {{{2 @@ -2425,14 +2425,14 @@ function s:IsCommentedOutermost(left, right, leftAlt, rightAlt, line) let indxRightAlt = s:LastIndexOfDelim(a:rightAlt, a:line) "check if the line has a left delimiter before a leftAlt delimiter - if (indxLeft <= indxLeftAlt || indxLeftAlt == -1) && indxLeft != -1 + if (indxLeft <= indxLeftAlt || indxLeftAlt ==# -1) && indxLeft !=# -1 "check if the line has a right delimiter after any rightAlt delimiter if (indxRight > indxRightAlt && indxRight > indxLeft) || !s:Multipart() return 1 endif "check if the line has a leftAlt delimiter before a left delimiter - elseif (indxLeftAlt <= indxLeft || indxLeft == -1) && indxLeftAlt != -1 + elseif (indxLeftAlt <= indxLeft || indxLeft ==# -1) && indxLeftAlt !=# -1 "check if the line has a rightAlt delimiter after any right delimiter if (indxRightAlt > indxRight && indxRightAlt > indxLeftAlt) || !s:AltMultipart() return 2 @@ -2493,14 +2493,14 @@ function s:IsDelimValid(delimiter, delIndx, line) "vim comments are so fucking stupid!! Why the hell do they have comment "delimiters that are used elsewhere in the syntax?!?! We need to check "some conditions especially for vim - if &filetype == 'vim' + if &filetype ==# 'vim' if !s:IsNumEven(s:CountNonESCedOccurances(preComStr, '"', "\\")) return 0 endif "if the delimiter is on the very first char of the line or is the "first non-tab/space char on the line then it is a valid comment delimiter - if a:delIndx == 0 || a:line =~ "^[ \t]\\{" . a:delIndx . "\\}\".*$" + if a:delIndx ==# 0 || a:line =~# "^[ \t]\\{" . a:delIndx . "\\}\".*$" return 1 endif @@ -2528,7 +2528,7 @@ endfunction " Args: " -num: the number to check function s:IsNumEven(num) - return (a:num % 2) == 0 + return (a:num % 2) ==# 0 endfunction " Function: s:IsEscaped(str, indx, escChar) {{{2 @@ -2546,7 +2546,7 @@ function s:IsEscaped(str, indx, escChar) "keep going back thru str until we either reach the start of the str or "run out of esc chars - while curIndx >= 0 && strpart(a:str, curIndx, 1) == a:escChar + while curIndx >= 0 && strpart(a:str, curIndx, 1) ==# a:escChar "we have found another esc char so add one to the count and move left "one char @@ -2601,23 +2601,23 @@ function s:IsSexyComment(topline, bottomline) endif "if the top line doesn't begin with a left delimiter then the comment isn't sexy - if getline(a:topline) !~ '^[ \t]*' . left + if getline(a:topline) !~# '^[ \t]*' . left return 0 endif "if there is a right delimiter on the top line then this isn't a sexy comment - if s:LastIndexOfDelim(right, getline(a:topline)) != -1 + if s:LastIndexOfDelim(right, getline(a:topline)) !=# -1 return 0 endif "if there is a left delimiter on the bottom line then this isn't a sexy comment - if s:FindDelimiterIndex(left, getline(a:bottomline)) != -1 + if s:FindDelimiterIndex(left, getline(a:bottomline)) !=# -1 return 0 endif "if the bottom line doesn't begin with a right delimiter then the comment isn't "sexy - if getline(a:bottomline) !~ '^.*' . right . '$' + if getline(a:bottomline) !~# '^.*' . right . '$' return 0 endif @@ -2629,13 +2629,13 @@ function s:IsSexyComment(topline, bottomline) while currentLine < a:bottomline let theLine = getline(currentLine) - if theLine !~ '^[ \t]*' . sexyComMarker + if theLine !~# '^[ \t]*' . sexyComMarker return 0 endif "if there is a right delimiter in an intermediate line then the block isn't "a sexy comment - if s:LastIndexOfDelim(right, theLine) != -1 + if s:LastIndexOfDelim(right, theLine) !=# -1 return 0 endif @@ -2660,7 +2660,7 @@ function s:LastIndexOfDelim(delim, str) "set index to the first occurrence of delimiter. If there is no occurrence then "bail let indx = s:FindDelimiterIndex(delim, a:str) - if indx == -1 + if indx ==# -1 return -1 endif @@ -2674,7 +2674,7 @@ function s:LastIndexOfDelim(delim, str) "if we find a delimiter update indx to record the position of it, if we "don't find another delimiter then indx is the last one so break out of "this loop - if indx2 != -1 + if indx2 !=# -1 let indx = indx + indx2 + lenDelim else break @@ -2692,7 +2692,7 @@ function s:Left(...) let delim = has_key(params, 'alt') ? b:NERDCommenterDelims['leftAlt'] : b:NERDCommenterDelims['left'] - if delim == '' + if delim ==# '' return '' endif @@ -2728,7 +2728,7 @@ function s:LeftMostIndx(countCommentedLines, countEmptyLines, topline, bottomlin " get the next line and if it is allowed to be commented, or is not " commented, check it let theLine = getline(currentLine) - if a:countEmptyLines || theLine !~ '^[ \t]*$' + if a:countEmptyLines || theLine !~# '^[ \t]*$' if a:countCommentedLines || (!s:IsCommented(s:Left(), s:Right(), theLine) && !s:IsCommented(s:Left({'alt': 1}), s:Right({'alt': 1}), theLine)) " convert spaces to tabs and get the number of leading spaces for " this line and update leftMostIndx if need be @@ -2744,7 +2744,7 @@ function s:LeftMostIndx(countCommentedLines, countEmptyLines, topline, bottomlin let currentLine = currentLine + 1 endwhile - if leftMostIndx == 1000 + if leftMostIndx ==# 1000 return 0 else return leftMostIndx @@ -2754,7 +2754,7 @@ endfunction " Function: s:Multipart() {{{2 " returns 1 if the current delimiters are multipart function s:Multipart() - return s:Right() != '' + return s:Right() !=# '' endfunction " Function: s:NerdEcho(msg, typeOfMsg) {{{2 @@ -2763,11 +2763,11 @@ endfunction " -typeOfMsg: 0 = warning message " 1 = normal message function s:NerdEcho(msg, typeOfMsg) - if a:typeOfMsg == 0 + if a:typeOfMsg ==# 0 echohl WarningMsg echom 'NERDCommenter:' . a:msg echohl None - elseif a:typeOfMsg == 1 + elseif a:typeOfMsg ==# 1 echom 'NERDCommenter:' . a:msg endif endfunction @@ -2822,7 +2822,7 @@ function s:ReplaceLeftMostDelim(toReplace, replacor, str) "if there IS an occurrence of toReplace in str then replace it and return "the resulting string - if indxToReplace != -1 + if indxToReplace !=# -1 let line = strpart(a:str, 0, indxToReplace) . replacor . strpart(a:str, indxToReplace+strlen(toReplace)) return line endif @@ -2849,7 +2849,7 @@ function s:ReplaceRightMostDelim(toReplace, replacor, str) "if there IS a delimiter in str, replace it and return the result let line = a:str - if indxToReplace != -1 + if indxToReplace !=# -1 let line = strpart(a:str, 0, indxToReplace) . replacor . strpart(a:str, indxToReplace+strlen(toReplace)) endif return line @@ -2877,7 +2877,7 @@ function s:Right(...) let delim = has_key(params, 'alt') ? b:NERDCommenterDelims['rightAlt'] : b:NERDCommenterDelims['right'] - if delim == '' + if delim ==# '' return '' endif @@ -2911,7 +2911,7 @@ function s:RightMostIndx(countCommentedLines, countEmptyLines, topline, bottomli " get the next line and see if it is commentable, otherwise it doesn't " count let theLine = getline(currentLine) - if a:countEmptyLines || theLine !~ '^[ \t]*$' + if a:countEmptyLines || theLine !~# '^[ \t]*$' if a:countCommentedLines || (!s:IsCommented(s:Left(), s:Right(), theLine) && !s:IsCommented(s:Left({'alt': 1}), s:Right({'alt': 1}), theLine)) @@ -3052,7 +3052,7 @@ function! s:CreateMaps(modes, target, desc, combo) endif let menu_command .= ' ' . (strlen(a:combo) ? plug : a:target) " Execute the commands built above for each requested mode. - for mode in (a:modes == '') ? [''] : split(a:modes, '\zs') + for mode in (a:modes ==# '') ? [''] : split(a:modes, '\zs') if strlen(a:combo) execute mode . plug_start . mode . plug_end if g:NERDCreateDefaultMappings && !hasmapto(plug, mode) @@ -3060,7 +3060,7 @@ function! s:CreateMaps(modes, target, desc, combo) endif endif " Check if the user wants the menu to be displayed. - if g:NERDMenuMode != 0 + if g:NERDMenuMode !=# 0 execute mode . menu_command endif endfor From 6295aeba66f6304eb49a567ef031a0049519c130 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Mon, 30 Dec 2019 11:12:01 +0300 Subject: [PATCH 22/42] Fix lint warning: use the full option names --- plugin/NERD_commenter.vim | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index b55221c..a844474 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -524,15 +524,15 @@ augroup END " set for this buffer. " function s:SetUpForNewFiletype(filetype, forceReset) - let ft = a:filetype + let filetype = a:filetype "for compound filetypes, if we don't know how to handle the full filetype "then break it down and use the first part that we know how to handle - if ft =~# '\.' && !has_key(s:delimiterMap, ft) + if filetype =~# '\.' && !has_key(s:delimiterMap, filetype) let filetypes = split(a:filetype, '\.') for i in filetypes if has_key(s:delimiterMap, i) - let ft = i + let filetype = i break endif endfor @@ -540,8 +540,8 @@ function s:SetUpForNewFiletype(filetype, forceReset) let b:NERDSexyComMarker = '' - if has_key(s:delimiterMap, ft) - let b:NERDCommenterDelims = s:delimiterMap[ft] + if has_key(s:delimiterMap, filetype) + let b:NERDCommenterDelims = s:delimiterMap[filetype] for i in ['left', 'leftAlt', 'right', 'rightAlt'] if !has_key(b:NERDCommenterDelims, i) let b:NERDCommenterDelims[i] = '' @@ -554,7 +554,7 @@ function s:SetUpForNewFiletype(filetype, forceReset) endfor " if g:NERD__alt_style is defined, use the alternate style let b:NERDCommenterFirstInit = getbufvar(1,'NERDCommenterFirstInit') - if exists('g:NERDAltDelims_'.ft) && eval('g:NERDAltDelims_'.ft) && !b:NERDCommenterFirstInit + if exists('g:NERDAltDelims_'.filetype) && eval('g:NERDAltDelims_'.filetype) && !b:NERDCommenterFirstInit call s:SwitchToAlternativeDelimiters(0) let b:NERDCommenterFirstInit = 1 endif @@ -565,7 +565,7 @@ function s:SetUpForNewFiletype(filetype, forceReset) endfunction function s:CreateDelimMapFromCms() - if &ft ==# '' && exists('g:NERDDefaultDelims') + if &filetype ==# '' && exists('g:NERDDefaultDelims') let delims = g:NERDDefaultDelims for i in ['left', 'leftAlt', 'right', 'rightAlt'] if !has_key(delims, i) @@ -690,15 +690,15 @@ function s:CommentBlock(top, bottom, lSide, rSide, forceNested ) "boundary accordingly let numTabs = s:NumberOfLeadingTabs(topline) if lSide < numTabs - let lSide = &ts * lSide + let lSide = &tabstop * lSide else - let lSide = (lSide - numTabs) + (&ts * numTabs) + let lSide = (lSide - numTabs) + (&tabstop * numTabs) endif "find out how many tabs are in the bottom line and adjust the right "boundary accordingly let numTabs = s:NumberOfLeadingTabs(bottomline) - let rSide = (rSide - numTabs) + (&ts * numTabs) + let rSide = (rSide - numTabs) + (&tabstop * numTabs) endif "we must check that bottom IS actually below top, if it is not then we @@ -1965,7 +1965,7 @@ function s:ConvertLeadingTabsToSpaces(line) endfunction " Function: s:ConvertLeadingWhiteSpace(line) {{{2 -" Converts the leading white space to tabs/spaces depending on &ts +" Converts the leading white space to tabs/spaces depending on &tabstop " " Args: " -line: the line to convert From 24df32304e20677ab061115e7bc8a37f382c60e9 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Mon, 30 Dec 2019 11:25:16 +0300 Subject: [PATCH 23/42] Add automated PR review comments based on Vint linter (#410) --- .github/workflows/vint.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/vint.yml b/.github/workflows/vint.yml index 054da4e..d686760 100644 --- a/.github/workflows/vint.yml +++ b/.github/workflows/vint.yml @@ -8,11 +8,10 @@ jobs: steps: - name: Checkout uses: actions/checkout@master - - name: Set up Python - uses: actions/setup-python@v1 + - name: Run vint with reviewdog + uses: reviewdog/action-vint@v1.0.1 with: - python-version: 3.7 - - name: Setup dependencies - run: pip install vim-vint - - name: Run Vimscript Linter - run: vint . + github_token: ${{ secrets.github_token }} + reporter: github-pr-review + + From e6510c1a71f227385e3c3d6a04e5a1453886035e Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Mon, 30 Dec 2019 12:21:34 +0300 Subject: [PATCH 24/42] Create LICENSE file for CC0 --- LICENSE | 121 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..0e259d4 --- /dev/null +++ b/LICENSE @@ -0,0 +1,121 @@ +Creative Commons Legal Code + +CC0 1.0 Universal + + CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE + LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN + ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS + INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES + REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS + PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM + THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED + HEREUNDER. + +Statement of Purpose + +The laws of most jurisdictions throughout the world automatically confer +exclusive Copyright and Related Rights (defined below) upon the creator +and subsequent owner(s) (each and all, an "owner") of an original work of +authorship and/or a database (each, a "Work"). + +Certain owners wish to permanently relinquish those rights to a Work for +the purpose of contributing to a commons of creative, cultural and +scientific works ("Commons") that the public can reliably and without fear +of later claims of infringement build upon, modify, incorporate in other +works, reuse and redistribute as freely as possible in any form whatsoever +and for any purposes, including without limitation commercial purposes. +These owners may contribute to the Commons to promote the ideal of a free +culture and the further production of creative, cultural and scientific +works, or to gain reputation or greater distribution for their Work in +part through the use and efforts of others. + +For these and/or other purposes and motivations, and without any +expectation of additional consideration or compensation, the person +associating CC0 with a Work (the "Affirmer"), to the extent that he or she +is an owner of Copyright and Related Rights in the Work, voluntarily +elects to apply CC0 to the Work and publicly distribute the Work under its +terms, with knowledge of his or her Copyright and Related Rights in the +Work and the meaning and intended legal effect of CC0 on those rights. + +1. Copyright and Related Rights. A Work made available under CC0 may be +protected by copyright and related or neighboring rights ("Copyright and +Related Rights"). Copyright and Related Rights include, but are not +limited to, the following: + + i. the right to reproduce, adapt, distribute, perform, display, + communicate, and translate a Work; + ii. moral rights retained by the original author(s) and/or performer(s); +iii. publicity and privacy rights pertaining to a person's image or + likeness depicted in a Work; + iv. rights protecting against unfair competition in regards to a Work, + subject to the limitations in paragraph 4(a), below; + v. rights protecting the extraction, dissemination, use and reuse of data + in a Work; + vi. database rights (such as those arising under Directive 96/9/EC of the + European Parliament and of the Council of 11 March 1996 on the legal + protection of databases, and under any national implementation + thereof, including any amended or successor version of such + directive); and +vii. other similar, equivalent or corresponding rights throughout the + world based on applicable law or treaty, and any national + implementations thereof. + +2. Waiver. To the greatest extent permitted by, but not in contravention +of, applicable law, Affirmer hereby overtly, fully, permanently, +irrevocably and unconditionally waives, abandons, and surrenders all of +Affirmer's Copyright and Related Rights and associated claims and causes +of action, whether now known or unknown (including existing as well as +future claims and causes of action), in the Work (i) in all territories +worldwide, (ii) for the maximum duration provided by applicable law or +treaty (including future time extensions), (iii) in any current or future +medium and for any number of copies, and (iv) for any purpose whatsoever, +including without limitation commercial, advertising or promotional +purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each +member of the public at large and to the detriment of Affirmer's heirs and +successors, fully intending that such Waiver shall not be subject to +revocation, rescission, cancellation, termination, or any other legal or +equitable action to disrupt the quiet enjoyment of the Work by the public +as contemplated by Affirmer's express Statement of Purpose. + +3. Public License Fallback. Should any part of the Waiver for any reason +be judged legally invalid or ineffective under applicable law, then the +Waiver shall be preserved to the maximum extent permitted taking into +account Affirmer's express Statement of Purpose. In addition, to the +extent the Waiver is so judged Affirmer hereby grants to each affected +person a royalty-free, non transferable, non sublicensable, non exclusive, +irrevocable and unconditional license to exercise Affirmer's Copyright and +Related Rights in the Work (i) in all territories worldwide, (ii) for the +maximum duration provided by applicable law or treaty (including future +time extensions), (iii) in any current or future medium and for any number +of copies, and (iv) for any purpose whatsoever, including without +limitation commercial, advertising or promotional purposes (the +"License"). The License shall be deemed effective as of the date CC0 was +applied by Affirmer to the Work. Should any part of the License for any +reason be judged legally invalid or ineffective under applicable law, such +partial invalidity or ineffectiveness shall not invalidate the remainder +of the License, and in such case Affirmer hereby affirms that he or she +will not (i) exercise any of his or her remaining Copyright and Related +Rights in the Work or (ii) assert any associated claims and causes of +action with respect to the Work, in either case contrary to Affirmer's +express Statement of Purpose. + +4. Limitations and Disclaimers. + + a. No trademark or patent rights held by Affirmer are waived, abandoned, + surrendered, licensed or otherwise affected by this document. + b. Affirmer offers the Work as-is and makes no representations or + warranties of any kind concerning the Work, express, implied, + statutory or otherwise, including without limitation warranties of + title, merchantability, fitness for a particular purpose, non + infringement, or the absence of latent or other defects, accuracy, or + the present or absence of errors, whether or not discoverable, all to + the greatest extent permissible under applicable law. + c. Affirmer disclaims responsibility for clearing rights of other persons + that may apply to the Work or any use thereof, including without + limitation any person's Copyright and Related Rights in the Work. + Further, Affirmer disclaims responsibility for obtaining any necessary + consents, permissions or other rights required for any use of the + Work. + d. Affirmer understands and acknowledges that Creative Commons is not a + party to this document and has no duty or obligation with respect to + this CC0 or use of the Work. From ec16c09a0b23241def6500e02520797e7b35342e Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Mon, 30 Dec 2019 12:33:26 +0300 Subject: [PATCH 25/42] Add blurb to readme about original author and current contribution status --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index dec0bb7..98530aa 100644 --- a/README.md +++ b/README.md @@ -157,3 +157,7 @@ Most of the following mappings are for normal/visual mode only. The **|NERDComme * `[count]cu` **|NERDCommenterUncomment|** Uncomments the selected line(s). + +## Contributions + +This plugin was originally written in 2007 by [Martin Grenfell (@scrooloose)](https://github.com/scrooloose/). Lots of features and many of the supported filetypes have come from [community contributors](https://github.com/preservim/nerdcommenter/graphs/contributors). Since 2016 it has been maintained primarily by [Caleb Maclennan (@alerque)](https://github.com/alerque). Additional file type support, bug fixes, and new feature contributons are all welcome, please send them as Pull Requests on Github. If you can't contribute yourself please also feel free to open issues to report problems or request features. From 70b5b933cd838f8a4fa5d90d074c47a3c8336429 Mon Sep 17 00:00:00 2001 From: li-zhaoyang Date: Mon, 20 Jan 2020 19:49:52 +0800 Subject: [PATCH 26/42] First version of 'NERDCommentIsCharCommented' API (Untested) --- plugin/NERD_commenter.vim | 95 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index a844474..5c78574 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -1356,6 +1356,101 @@ function! NERDComment(mode, type) range endfunction +" Function: NERDCommentIsCharCommented(line, col) abort +" Check if the character at [line, col] is inside a comment +" Note the Comment delimeter it self is considered as part of the comment +" +" Args: +" -line the line number of the character +" -col the column number of the character +" Return: Number, 1 if the character is inside a comment, 0 if is not +function! NERDCommentIsCharCommented(line, col) abort + " Function: searchfor(str, line, col, direction, [maxline]) + " search str in the buffer, including the character at [line, col] + " Args: + " -str: the string for search + " -line: the line number where search begins + " -col: the column number where search begins + " -direction: 0 if forward, and 1 if backward + " -maxline: the max lines the search would look up + " 1 if search only one line + " if not given, search until reaches the begining or end of file + " Return: List, in the format of [line, col], where line and col is the + " position of first found result; If str cannot be found, returns + " [0, 0] + function! l:searchfor(str, line, col, direction, ...) abort + let l:curlinenr = a:line + let l:maxline = (a:0 > 4) ? a:5 : (direction ? a:line : line('$') - a:line + 1) + while abs(curlinenr - a:line) < maxline + let linestr = getline(a:line) + if curlinenr == a:line + if direction == 0 + let l:partstr = strpart(linestr, a:col - strlen(a:str)) + else + let l:partstr = strpart(linestr, 0, a:col + strlen(a:str) - 1) + endif + else + let l:partstr = linestr + endif + if !direction + let idx = stridx(a:str, partstr) + if idx != -1 + return [curlinenr, idx + 1] + endif + else + let idx = strridx(a:str, partstr) + if idx != -1 + return [curlinenr, idx + 1] + endif + endif + let curlinenr += direction ? 1 : -1 + endwhile + return [0, 0] + endfunction + function! l:checkwith(left, right, line, col) abort + let linecommented = 0 + let blockcommented = 0 + if a:right ==# '' + let leftpos = searchfor(a:left, a:line, a:col, 1, 1) + if leftpos == [0, 0] + if !linecommented | let linecommented = 0 | endif + else + if !linecommented | let linecommented = 1 | endif + endif + else + let leftpos = searchfor(a:left, a:line, a:col, 1) + if leftpos == [0, 0] + if !blockcommented | let linecommented = 0 | endif + else + call searchfor(a:right, a:line, a:col, 0) + let rightpos = searchfor(a:right, a:line, a:col, 0) + if rightpos != [0, 0] + if rightpos[0] < a:line + if !blockcommented | let blockcommented = 0 | endif + else + if !blockcommented + let blockcommented = (rightpos[1] + strlen(a:right) >= a:col) ? 0 : 1 + endif + endif + else + if !blockcommented | let blockcommented = 1 | endif + endif + endif + endif + return linecommented || blockcommented + endfunction + return checkwith( + \ b:NERDCommenterDelims['left'], + \ b:NERDCommenterDelims['right'], + \ a:line, + \ a:col) || + checkwith( + \ b:NERDCommenterDelims['leftAlt'], + \ b:NERDCommenterDelims['rightAlt'], + \ a:line, + \ a:col) +endfunction + " Function: s:PlaceDelimitersAndInsBetween() function {{{2 " This is function is called to place comment delimiters down and place the " cursor between them From eb6243c0c8566d4fc164e5c9da99faae9482117b Mon Sep 17 00:00:00 2001 From: li-zhaoyang Date: Tue, 21 Jan 2020 04:16:18 +0800 Subject: [PATCH 27/42] Finished and tested NERDCommentIsCharCommented() --- plugin/NERD_commenter.vim | 54 +++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index 5c78574..a001455 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -1365,7 +1365,7 @@ endfunction " -col the column number of the character " Return: Number, 1 if the character is inside a comment, 0 if is not function! NERDCommentIsCharCommented(line, col) abort - " Function: searchfor(str, line, col, direction, [maxline]) + " Function: s:searchfor(str, line, col, direction, [maxline]) " search str in the buffer, including the character at [line, col] " Args: " -str: the string for search @@ -1378,13 +1378,13 @@ function! NERDCommentIsCharCommented(line, col) abort " Return: List, in the format of [line, col], where line and col is the " position of first found result; If str cannot be found, returns " [0, 0] - function! l:searchfor(str, line, col, direction, ...) abort + function! s:searchfor(str, line, col, direction, ...) abort let l:curlinenr = a:line - let l:maxline = (a:0 > 4) ? a:5 : (direction ? a:line : line('$') - a:line + 1) + let l:maxline = (a:0 > 0) ? a:1 : (a:direction ? a:line : line('$') - a:line + 1) while abs(curlinenr - a:line) < maxline - let linestr = getline(a:line) + let linestr = getline(curlinenr) if curlinenr == a:line - if direction == 0 + if !a:direction let l:partstr = strpart(linestr, a:col - strlen(a:str)) else let l:partstr = strpart(linestr, 0, a:col + strlen(a:str) - 1) @@ -1392,45 +1392,61 @@ function! NERDCommentIsCharCommented(line, col) abort else let l:partstr = linestr endif - if !direction - let idx = stridx(a:str, partstr) + if !a:direction + " forward + let idx = stridx(partstr, a:str) if idx != -1 + if curlinenr == a:line + let idx += a:col - strlen(a:str) + else + endif return [curlinenr, idx + 1] endif else - let idx = strridx(a:str, partstr) + " backward + let idx = strridx(partstr, a:str) if idx != -1 return [curlinenr, idx + 1] endif endif - let curlinenr += direction ? 1 : -1 + let curlinenr += a:direction ? -1 : 1 endwhile return [0, 0] endfunction - function! l:checkwith(left, right, line, col) abort + " Function: s:checkwith(left, right, line, col) abort + " check if the char at [line, col] is commented using [left, right] pair + " Args: + " -left: the string begins a comment + " -right: the string ends a comment + " -line: the line position of the character + " -col: the column position of the character + " Return: Number, 1 if is in a comment, 0 else + function! s:checkwith(left, right, line, col) abort let linecommented = 0 let blockcommented = 0 if a:right ==# '' - let leftpos = searchfor(a:left, a:line, a:col, 1, 1) + let leftpos = s:searchfor(a:left, a:line, a:col, 1, 1) if leftpos == [0, 0] if !linecommented | let linecommented = 0 | endif else if !linecommented | let linecommented = 1 | endif endif else - let leftpos = searchfor(a:left, a:line, a:col, 1) + let leftpos = s:searchfor(a:left, a:line, a:col, 1) if leftpos == [0, 0] - if !blockcommented | let linecommented = 0 | endif + if !blockcommented | let blockcommented = 0 | endif else - call searchfor(a:right, a:line, a:col, 0) - let rightpos = searchfor(a:right, a:line, a:col, 0) + " call s:searchfor(a:right, a:line, a:col, 0) + let rightpos = s:searchfor(a:right, leftpos[0], leftpos[1] + strlen(a:right) + 1, 0) if rightpos != [0, 0] if rightpos[0] < a:line if !blockcommented | let blockcommented = 0 | endif - else + elseif rightpos[0] == a:line if !blockcommented - let blockcommented = (rightpos[1] + strlen(a:right) >= a:col) ? 0 : 1 + let blockcommented = (rightpos[1] + strlen(a:right) > a:col) ? 1 : 0 endif + else " rightpos > a:line + if !blockcommented | let blockcommented = 1 | endif endif else if !blockcommented | let blockcommented = 1 | endif @@ -1439,12 +1455,12 @@ function! NERDCommentIsCharCommented(line, col) abort endif return linecommented || blockcommented endfunction - return checkwith( + return s:checkwith( \ b:NERDCommenterDelims['left'], \ b:NERDCommenterDelims['right'], \ a:line, \ a:col) || - checkwith( + \ s:checkwith( \ b:NERDCommenterDelims['leftAlt'], \ b:NERDCommenterDelims['rightAlt'], \ a:line, From 53f5710627c0c2230dccbbfeb08a7c080f9e545d Mon Sep 17 00:00:00 2001 From: li-zhaoyang Date: Tue, 21 Jan 2020 14:42:18 +0800 Subject: [PATCH 28/42] Added 'Interface' section to the documention --- .gitignore | 1 + doc/NERD_commenter.txt | 64 ++++++++++++++++++++++++++++++--------- plugin/NERD_commenter.vim | 6 ++++ 3 files changed, 57 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 3698c0e..fcfaaec 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *~ *.swp tags +DEBUG diff --git a/doc/NERD_commenter.txt b/doc/NERD_commenter.txt index 0ae7582..55fea8a 100644 --- a/doc/NERD_commenter.txt +++ b/doc/NERD_commenter.txt @@ -38,13 +38,14 @@ CONTENTS *NERDCommenterContents* 4.2 Options details...................|NERDCommenterOptionsDetails| 4.3 Default delimiter Options.........|NERDCommenterDefaultDelims| 5. Customising key mappings...............|NERDCommenterMappings| - 6. Issues with the script.................|NERDCommenterIssues| - 6.1 Delimiter detection heuristics....|NERDCommenterHeuristics| - 6.2 Nesting issues....................|NERDCommenterNesting| - 7.About.. ............................|NERDCommenterAbout| - 8.Changelog...............................|NERDCommenterChangelog| - 9.Credits.................................|NERDCommenterCredits| - 10.License................................|NERDCommenterLicense| + 6. Interfaces............................. NERDCommenterInterfaces + 7. Issues with the script.................|NERDCommenterIssues| + 7.1 Delimiter detection heuristics....|NERDCommenterHeuristics| + 7.2 Nesting issues....................|NERDCommenterNesting| + 8.About.. ............................|NERDCommenterAbout| + 9.Changelog...............................|NERDCommenterChangelog| + 10.Credits................................|NERDCommenterCredits| + 11.License................................|NERDCommenterLicense| ============================================================================== 1. Intro *NERDCommenter* @@ -883,11 +884,46 @@ map to. See also |'NERDCreateDefaultMappings'|. ============================================================================== -6. Issues with the script *NERDCommenterIssues* +6. Interfaces *NERDCommenterInterfaces* + +NERDCommentIsLineCommented({lineNo}) *NERDCommentIsLineCommented()* + Check if the line is a comment + Note this function checks if the line is **completely** a comment + Args: + {lineNo}: the line number of the line to check + Return: Number, 1 if the line is a comment, 0 else + + +NERDComment({mode}, {type}) *NERDComment()* + This function is a Wrapper for the main commenting functions + + Args: + {mode}: character indicating the mode in which the comment + is requested: + 'n' for Normal mode, 'x' for Visual mode + {type}: the type of commenting requested. Can be 'Sexy', + 'Invert', 'Minimal', 'Toggle', 'AlignLeft', + 'AlignBoth', 'Comment', 'Nested', 'ToEOL', 'Append', + 'Insert', 'Uncomment', 'Yank' + + +NERDCommentIsCharCommented({line}, {col}) *NERDCommentIsCharCommented()* + Check if the character at [{line}, {col}] is inside a comment + Note the Comment delimeter it self is considered as part of the + comment + + Args: + {line} the line number of the character + {col} the column number of the character + Return: Number, 1 if the character is inside a comment, 0 else + + +============================================================================== +7. Issues with the script *NERDCommenterIssues* ------------------------------------------------------------------------------ -6.1 Delimiter detection heuristics *NERDCommenterHeuristics* +7.1 Delimiter detection heuristics *NERDCommenterHeuristics* Heuristics are used to distinguish the real comment delimiters @@ -907,7 +943,7 @@ string. These heuristics, while usually pretty accurate, will not work for all cases. ------------------------------------------------------------------------------ -6.2 Nesting issues *NERDCommenterNesting* +7.2 Nesting issues *NERDCommenterNesting* If we have some line of code like this: > /*int foo */ = /*5 + 9;*/ @@ -927,7 +963,7 @@ will become: > for simplicity) ============================================================================== -7. About *NERDCommenterAbout* +8. About *NERDCommenterAbout* The author of the NERD commenter is Martyzillatron --- the half robot, half dinosaur bastard son of Megatron and Godzilla. He enjoys destroying @@ -944,7 +980,7 @@ The latest dev versions are on github http://github.com/preservim/nerdcommenter ============================================================================== -8. Changelog *NERDCommenterChangelog* +9. Changelog *NERDCommenterChangelog* 2.3.0 - remove all filetypes which have a &commentstring in the standard vim @@ -1010,7 +1046,7 @@ The latest dev versions are on github NERDCommenterInsert if you wish to restore it ============================================================================== -9. Credits *NERDCommenterCredits* +10. Credits *NERDCommenterCredits* Thanks to the follow people for suggestions and patches: @@ -1149,7 +1185,7 @@ Ivan Devat javascript.jquery tpope cucumber,pdf Lyude Paul piglit shader_test ============================================================================== -10. License *NERDCommenterLicense* +11. License *NERDCommenterLicense* The NERD commenter is released under the wtfpl. See http://sam.zoy.org/wtfpl/COPYING. diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index a001455..a6583e7 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -1209,6 +1209,12 @@ function s:InvertComment(firstLine, lastLine) endwhile endfunction +" Function: NERDCommentIsLineCommented(lineNo) +" Check if the line is a comment +" Note this function checks if the line is **completely** a comment +" Args: +" -lineNo: the line number of the line to check +" Return: Number, 1 if the line is a comment, 0 else function! NERDCommentIsLineCommented(lineNo) let theLine = getline(a:lineNo) return s:IsInSexyComment(a:lineNo) || s:IsCommentedFromStartOfLine(s:Left(), theLine) || s:IsCommentedFromStartOfLine(s:Left({'alt': 1}), theLine) From 6f1f2894cbfd11af964c613bcd96608a77a9c17a Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Thu, 23 Jan 2020 22:18:50 +0300 Subject: [PATCH 29/42] Use HTML comment syntax for Rmarkdown Closes #415 While Markdown doesn't officially have a comment syntax, HTML comments are widely parsed as such. This is what most Markdown treat as Markdown comments. As a Markdown derivative it seams logical to do the same thing in Rmarkdown. The previously added '#' syntax seems to be for inside code blocks, and that would be language dependent anyway. I've left the hash option as the alternate. --- plugin/NERD_commenter.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index a6583e7..3069cbe 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -370,7 +370,7 @@ let s:delimiterMap = { \ 'resolv': { 'left': '#' }, \ 'rgb': { 'left': '!' }, \ 'rib': { 'left': '#' }, - \ 'rmd': { 'left': '#' }, + \ 'rmd': { 'left': '', 'leftalt': '#' }, \ 'robot': { 'left': '#' }, \ 'robots': { 'left': '#' }, \ 'rspec': { 'left': '#' }, From fa00e9820cd5b54b5ec37d2bf1de7c40c4f08896 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Thu, 23 Jan 2020 23:36:27 +0300 Subject: [PATCH 30/42] Use Jinja comment style first, HTML as alternate (closes #414) --- plugin/NERD_commenter.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index 3069cbe..19f9b50 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -244,7 +244,7 @@ let s:delimiterMap = { \ 'javascript.jquery': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }, \ 'jess': { 'left': ';' }, \ 'jgraph': { 'left': '(*', 'right': '*)' }, - \ 'jinja': { 'left': '', 'leftAlt': '{#', 'rightAlt': '#}' }, + \ 'jinja': { 'left': '{#', 'right': '#}', 'leftAlt': '' }, \ 'jproperties': { 'left': '#' }, \ 'jsp': { 'left': '<%--', 'right': '--%>' }, \ 'julia': { 'left': '# ', 'leftAlt': '#=', 'rightAlt': '=#' }, From cbadb3d93e5dcb121793b182880ee784dbd78978 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 25 Jan 2020 13:33:48 +0300 Subject: [PATCH 31/42] Fix minor syntax error in help file, see #416 --- doc/NERD_commenter.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/NERD_commenter.txt b/doc/NERD_commenter.txt index 55fea8a..995c31c 100644 --- a/doc/NERD_commenter.txt +++ b/doc/NERD_commenter.txt @@ -38,7 +38,7 @@ CONTENTS *NERDCommenterContents* 4.2 Options details...................|NERDCommenterOptionsDetails| 4.3 Default delimiter Options.........|NERDCommenterDefaultDelims| 5. Customising key mappings...............|NERDCommenterMappings| - 6. Interfaces............................. NERDCommenterInterfaces + 6. Interfaces.............................|NERDCommenterInterfaces| 7. Issues with the script.................|NERDCommenterIssues| 7.1 Delimiter detection heuristics....|NERDCommenterHeuristics| 7.2 Nesting issues....................|NERDCommenterNesting| From c62e618a1ab5a50a4028e3296500ba29d9b033d8 Mon Sep 17 00:00:00 2001 From: Jaehwang Jerry Jung Date: Wed, 19 Feb 2020 13:52:10 +0900 Subject: [PATCH 32/42] Make insert independent of whichwrap setting (#419) If `set whichwrap+=l`, `normal! l` may move the cursor to the next line. Use `feedkeys('a', 'ni')` instead. --- plugin/NERD_commenter.vim | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index 19f9b50..21f0a3b 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -1507,7 +1507,6 @@ function s:PlaceDelimitersAndInsBetween() else execute ':normal! ' . insOrApp . left endif - silent! normal! l "if needed convert spaces back to tabs and adjust the cursors col "accordingly @@ -1520,7 +1519,7 @@ function s:PlaceDelimitersAndInsBetween() if isDelimOnEOL && lenRight ==# 0 startinsert! else - startinsert + call feedkeys('a', 'ni') endif endfunction From 97c79a541f159872ad1909c26bb9f28fc8310e16 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Mon, 8 Jun 2020 14:01:59 +0300 Subject: [PATCH 33/42] Split push vs. pull_request lint tooling (#426) --- .github/workflows/reviewdog.yml | 16 ++++++++++++++++ .github/workflows/vint.yml | 17 ++++++++--------- README.md | 4 +++- 3 files changed, 27 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/reviewdog.yml diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml new file mode 100644 index 0000000..db1dbfa --- /dev/null +++ b/.github/workflows/reviewdog.yml @@ -0,0 +1,16 @@ +name: Reviewdog +on: [pull_request] +jobs: + vint: + strategy: + fail-fast: false + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Lint Vimscript in PR changes + uses: reviewdog/action-vint@v1 + with: + github_token: ${{ secrets.github_token }} + reporter: github-pr-review + level: info diff --git a/.github/workflows/vint.yml b/.github/workflows/vint.yml index d686760..2cfaeb4 100644 --- a/.github/workflows/vint.yml +++ b/.github/workflows/vint.yml @@ -1,5 +1,5 @@ name: Vint -on: [push, pull_request] +on: [push] jobs: vint: strategy: @@ -7,11 +7,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@master - - name: Run vint with reviewdog - uses: reviewdog/action-vint@v1.0.1 - with: - github_token: ${{ secrets.github_token }} - reporter: github-pr-review - - + uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + - name: Setup dependencies + run: pip install vim-vint + - name: Lint Vimscript + run: vint . diff --git a/README.md b/README.md index dec0bb7..9076ac5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ -# NERD Commenter [![Vint](https://github.com/preservim/nerdcommenter/workflows/Vint/badge.svg)](https://github.com/preservim/nerdcommenter/actions?workflow=Vint) +# NERD Commenter + +[![Vint](https://github.com/preservim/nerdcommenter/workflows/Vint/badge.svg)](https://github.com/preservim/nerdcommenter/actions?workflow=Vint) Comment functions so powerful—no comment necessary. From f72adff4044fe11200916f733495c96ed1605a43 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Mon, 8 Jun 2020 14:17:43 +0300 Subject: [PATCH 34/42] Remove obsolete file comments header The days when vim plugins were distributed as individual files are long gone, these days they are almost always git repositories or tarballs. As such the relevant meta data is included, just not in this way. Not only does this information have a habit of being absurdly out of date, it's not really useful any more to try to update it. --- plugin/NERD_commenter.vim | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index a844474..73ddf5d 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -1,18 +1,3 @@ -" ============================================================================ -" File: NERD_commenter.vim -" Description: vim global plugin that provides easy code commenting -" Author: Martin Grenfell -" Maintainer: Caleb Maclennan -" Version: 2.5.1 -" Last Change: Tue Nov 7 10:45:53 +03 2017 -" License: This program is free software. It comes without any warranty, -" to the extent permitted by applicable law. You can redistribute -" it and/or modify it under the terms of the Do What The Fuck You -" Want To Public License, Version 2, as published by Sam Hocevar. -" See http://sam.zoy.org/wtfpl/COPYING for more details. -" -" ============================================================================ - " Section: script init stuff {{{1 if exists('loaded_nerd_comments') finish From 8f375b0bbb22285cc04489f2b69097d5655d3554 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Mon, 8 Jun 2020 14:23:02 +0300 Subject: [PATCH 35/42] Update help documentation with relicense to CC0 --- doc/NERD_commenter.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/NERD_commenter.txt b/doc/NERD_commenter.txt index 0ae7582..863d1f4 100644 --- a/doc/NERD_commenter.txt +++ b/doc/NERD_commenter.txt @@ -1151,5 +1151,5 @@ Lyude Paul piglit shader_test ============================================================================== 10. License *NERDCommenterLicense* -The NERD commenter is released under the wtfpl. -See http://sam.zoy.org/wtfpl/COPYING. +NERD Commenter is released under the Creative-Commons CCO 1.0 Universal +license. See the included LICENE file for details. From 90f7606234e3b66dc51b7d21564c09db3733ca46 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Mon, 8 Jun 2020 14:35:34 +0300 Subject: [PATCH 36/42] Remove contributor list from help docs, link to Contributors Not only is the list hopelessly out of date, it's almost impossible to keep it up to date in any balance way. The only reasonably thing I could think to put here would be a normalized list of authors scrapped from git commit history, but Github's view of that is nicer anyway. --- doc/NERD_commenter.txt | 138 ++--------------------------------------- 1 file changed, 4 insertions(+), 134 deletions(-) diff --git a/doc/NERD_commenter.txt b/doc/NERD_commenter.txt index 0ae7582..953d4a5 100644 --- a/doc/NERD_commenter.txt +++ b/doc/NERD_commenter.txt @@ -1012,142 +1012,12 @@ The latest dev versions are on github ============================================================================== 9. Credits *NERDCommenterCredits* -Thanks to the follow people for suggestions and patches: +Well over 100 people have contributed towards this plugin, it's functions, and +specific filetype support. Please check out the up do date list of all +contributors on Github: -Nick Brettell -Matthew Hawkins -Mathieu Clabaut -Greg Searle -Nguyen -Litchi -Jorge Scandaliaris -Shufeng Zheng -Martin Stubenschrott -Markus Erlmann -Brent Rice -Richard Willis -Igor Prischepoff -Harry -David Bourgeois -Eike Von Seggern -Torsten Blix -Alexander Bosecke -Stefano Zacchiroli -Norick Chen -Joseph Barker -Gary Church -Tim Carey-Smith -Markus Klinik -Anders -Seth Mason -James Hales -Heptite -Cheng Fang -Yongwei Wu -David Miani -Jeremy Hinegardner -Marco -Ingo Karkat -Zhang Shuhan -tpope -Ben Schmidt -David Fishburn -Erik Falor -JaGoTerr -Elias Pipping -mntnoe -Mark S. -James P. Harvey +https://github.com/preservim/nerdcommenter/graphs/contributors - -Thanks to the following people for sending me new filetypes to support: - -The hackers The filetypes~ -Sam R verilog -Jonathan Derque context, plaintext and mail -Vigil fetchmail -Michael Brunner kconfig -Antono Vasiljev netdict -Melissa Reid omlet -Ilia N Ternovich quickfix -John O'Shea RTF, SVNcommitlog and vcscommit, SVNCommit -Anders occam -Mark Woodward csv -fREW gentoo-package-mask, - gentoo-package-keywords, - gentoo-package-use, and vo_base -Alexey verilog_systemverilog, systemverilog -Lizendir fstab -Michael Böhler autoit, autohotkey and docbk -Aaron Small cmake -Ramiro htmldjango and django -Stefano Zacchiroli debcontrol, debchangelog, mkd -Alex Tarkovsky ebuild and eclass -Jorge Rodrigues gams -Rainer Müller Objective C -Jason Mills Groovy, ps1 -Normandie Azucena vera -Florian Apolloner ldif -David Fishburn lookupfile -Niels Aan de Brugh rst -Don Hatlestad ahk -Christophe Benz Desktop and xsd -Eyolf Østrem lilypond, bbx and lytex -Ingo Karkat dosbatch -Nicolas Weber markdown, objcpp -tinoucas gentoo-conf-d -Greg Weber D, haml -Bruce Sherrod velocity -timberke cobol, calibre -Aaron Schaefer factor -Mr X asterisk, mplayerconf -Kuchma Michael plsql -Brett Warneke spectre -Pipp lhaskell -Renald Buter scala -Vladimir Lomov asymptote -Marco mrxvtrc, aap -nicothakis SVNAnnotate, CVSAnnotate, SVKAnnotate, - SVNdiff, gitAnnotate, gitdiff, dtrace - llvm, applescript -Chen Xing Wikipedia -Jacobo Diaz dakota, patran -Li Jin gentoo-env-d, gentoo-init-d, - gentoo-make-conf, grub, modconf, sudoers -SpookeyPeanut rib -Greg Jandl pyrex/cython -Christophe Benz services, gitcommit -A Pontus vimperator -Stromnov slice, bzr -Martin Kustermann pamconf -Indriði Einarsson mason -Chris map -Krzysztof A. Adamski group -Pascal Brueckner mailcap -Jerónimo Carballo stata -Phillip Kovalev xquery -Bernhard Grotz potwiki -sgronblo man -François txt2tags -Giacomo Mariani SVNinfo -Matthew Lee Hinman newlisp, clojure -Elias Pipping automake -Edwin Benavides actionscript, processing -Thomas Rowe hostsaccess -Simon Ruderich asciidoc, git, gitcommit, gitrebase -Keitheis mako, genshi -David conkyrc -Miguel Jaque Barbero SVNannotate -Stefan Walk sieve -Adam Thorsen objj -Thilo Six dhcpd, limits, ntp, resolv, rgb, sysctl, - udevconf, udevrules -Andrey Skvortsov mp -Simon Hengel htmlcheetah -Matt Tolton javacc -Ivan Devat javascript.jquery -tpope cucumber,pdf -Lyude Paul piglit shader_test ============================================================================== 10. License *NERDCommenterLicense* From 700b7d29168ec72d83c5dfe240f0b2a2740ed2f3 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Mon, 8 Jun 2020 14:42:05 +0300 Subject: [PATCH 37/42] Update About section with current relevant links --- doc/NERD_commenter.txt | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/doc/NERD_commenter.txt b/doc/NERD_commenter.txt index 953d4a5..c83e5d9 100644 --- a/doc/NERD_commenter.txt +++ b/doc/NERD_commenter.txt @@ -929,19 +929,19 @@ for simplicity) ============================================================================== 7. About *NERDCommenterAbout* -The author of the NERD commenter is Martyzillatron --- the half robot, half -dinosaur bastard son of Megatron and Godzilla. He enjoys destroying -metropolises and eating tourist buses. +This plugin was originally written in 2007 by Martin Grenfell, aka @scrooloose +on Github: https://github.com/scrooloose -Drop him a line at martin_grenfell at msn.com. He would love to hear from you. -It's a lonely life being the worlds premier terror machine. How would you feel -if your face looked like a toaster and a t-rex put together? :( +Since 2016 it has been maintained primarily by Caleb Maclennan, aka @alerque +on Github: https://github.com/alerque -The latest stable versions can be found at - http://www.vim.org/scripts/script.php?script_id=1218 +Lots of features and many of the supported filetypes have come from the +community, see |NERDCommenterCredits|. -The latest dev versions are on github - http://github.com/preservim/nerdcommenter +Additional file type support, bug fixes, and new feature contributons are all +welcome, please send them as Pull Requests on Github. If you can't contribute +yourself please also feel free to open issues to report problems or request +features: https://github.com/preservim/nerdcommenter ============================================================================== 8. Changelog *NERDCommenterChangelog* @@ -977,7 +977,7 @@ The latest dev versions are on github - add support for actionscript and processing thanks to Edwin Benavides - add support for ps1 (powershell), thanks to Jason Mills - add support for hostsaccess, thanks to Thomas Rowe - - add support for CVScommit + - add support for CVScommit - add support for asciidoc, git and gitrebase. Thanks to Simon Ruderich. - use # for gitcommit comments, thanks to Simon Ruderich. - add support for mako and genshi, thanks to Keitheis. From 5e2aeffb03a400ce8642ece0e36d79b11903a69b Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Mon, 8 Jun 2020 14:49:47 +0300 Subject: [PATCH 38/42] Move change log to separate file for easier maintenance --- CHANGELOG.md | 59 ++++++++++++++++++++++++++++++++++++++ doc/NERD_commenter.txt | 65 +++--------------------------------------- 2 files changed, 63 insertions(+), 61 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..a6c4210 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,59 @@ +### 2.3.0 + +* remove all filetypes which have a &commentstring in the standard vim runtime +for vim > 7.0 unless the script stores an alternate set of delimiters +* make the script complain if the user doesn't have filetype plugins enabled +* use || instead of comma to start the default mappings +* fix a couple of bugs with sexy comments - thanks to Tim Smart +* lots of refactoring + +### 2.2.2 + +* remove the NERDShutup option and the message is suppresses, this makes the plugin silently rely on &commentstring for unknown filetypes. +* add support for dhcpd, limits, ntp, resolv, rgb, sysctl, udevconf and udevrules. Thanks to Thilo Six. +* match filetypes case insensitively +* add support for mp (metapost), thanks to Andrey Skvortsov. +* add support for htmlcheetah, thanks to Simon Hengel. +* add support for javacc, thanks to Matt Tolton. +* make <%# %> the default delims for eruby, thanks to tpope. +* add support for javascript.jquery, thanks to Ivan Devat. +* add support for cucumber and pdf. Fix sass and railslog delims, thanks to tpope + +### 2.2.1 + +* add support for newlisp and clojure, thanks to Matthew Lee Hinman. +* fix automake comments, thanks to Elias Pipping +* make haml comments default to -# with / as the alternative delimiter, thanks to tpope +* add support for actionscript and processing thanks to Edwin Benavides +* add support for ps1 (powershell), thanks to Jason Mills +* add support for hostsaccess, thanks to Thomas Rowe +* add support for CVScommit +* add support for asciidoc, git and gitrebase. Thanks to Simon Ruderich. +* use # for gitcommit comments, thanks to Simon Ruderich. +* add support for mako and genshi, thanks to Keitheis. +* add support for conkyrc, thanks to David +* add support for SVNannotate, thanks to Miguel Jaque Barbero. +* add support for sieve, thanks to Stefan Walk +* add support for objj, thanks to Adam Thorsen. + +### 2.2.0 + +* rewrote the mappings system to be more "standard". +* removed all the mapping options. Now, mappings to mappings are used +* see :help NERDComMappings, and :help NERDCreateDefaultMappings for more info +* remove "prepend comments" and "right aligned comments". +* add support for applescript, calbire, man, SVNcommit, potwiki, txt2tags and SVNinfo. Thanks to nicothakis, timberke, sgronblo, mntnoe, Bernhard Grotz, John O'Shea, François and Giacomo Mariani respectively. +* bugfix for haskell delimiters. Thanks to mntnoe. + +### 2.1.18 + +* add support for llvm. Thanks to nicothakis. +* add support for xquery. Thanks to Phillip Kovalev. + +### 2.1.17 + +* fixed haskell delimiters (hackily). Thanks to Elias Pipping. +* add support for mailcap. Thanks to Pascal Brueckner. +* add support for stata. Thanks to Jerónimo Carballo. +* applied a patch from ewfalor to fix an error in the help file with the NERDMapleader doc +* disable the insert mode ctrl-c mapping by default, see :help NERDCommenterInsert if you wish to restore it diff --git a/doc/NERD_commenter.txt b/doc/NERD_commenter.txt index c83e5d9..2b633b2 100644 --- a/doc/NERD_commenter.txt +++ b/doc/NERD_commenter.txt @@ -946,68 +946,11 @@ features: https://github.com/preservim/nerdcommenter ============================================================================== 8. Changelog *NERDCommenterChangelog* -2.3.0 - - remove all filetypes which have a &commentstring in the standard vim - runtime for vim > 7.0 unless the script stores an alternate set of - delimiters - - make the script complain if the user doesn't have filetype plugins enabled - - use || instead of comma to start the default mappings - - fix a couple of bugs with sexy comments - thanks to Tim Smart - - lots of refactoring +See the included CHANGELOG.md file or the Github Releases page for the latest +info on tagged releases. https://github.com/preservim/nerdcommenter/releases -2.2.2 - - remove the NERDShutup option and the message is suppresses, this makes - the plugin silently rely on &commentstring for unknown filetypes. - - add support for dhcpd, limits, ntp, resolv, rgb, sysctl, udevconf and - udevrules. Thanks to Thilo Six. - - match filetypes case insensitively - - add support for mp (metapost), thanks to Andrey Skvortsov. - - add support for htmlcheetah, thanks to Simon Hengel. - - add support for javacc, thanks to Matt Tolton. - - make <%# %> the default delims for eruby, thanks to tpope. - - add support for javascript.jquery, thanks to Ivan Devat. - - add support for cucumber and pdf. Fix sass and railslog delims, - thanks to tpope - -2.2.1 - - add support for newlisp and clojure, thanks to Matthew Lee Hinman. - - fix automake comments, thanks to Elias Pipping - - make haml comments default to -# with / as the alternative delimiter, - thanks to tpope - - add support for actionscript and processing thanks to Edwin Benavides - - add support for ps1 (powershell), thanks to Jason Mills - - add support for hostsaccess, thanks to Thomas Rowe - - add support for CVScommit - - add support for asciidoc, git and gitrebase. Thanks to Simon Ruderich. - - use # for gitcommit comments, thanks to Simon Ruderich. - - add support for mako and genshi, thanks to Keitheis. - - add support for conkyrc, thanks to David - - add support for SVNannotate, thanks to Miguel Jaque Barbero. - - add support for sieve, thanks to Stefan Walk - - add support for objj, thanks to Adam Thorsen. - -2.2.0 - - rewrote the mappings system to be more "standard". - - removed all the mapping options. Now, mappings to mappings are - used - - see :help NERDComMappings, and :help NERDCreateDefaultMappings for - more info - - remove "prepend comments" and "right aligned comments". - - add support for applescript, calbire, man, SVNcommit, potwiki, txt2tags and SVNinfo. - Thanks to nicothakis, timberke, sgronblo, mntnoe, Bernhard Grotz, John - O'Shea, François and Giacomo Mariani respectively. - - bugfix for haskell delimiters. Thanks to mntnoe. -2.1.18 - - add support for llvm. Thanks to nicothakis. - - add support for xquery. Thanks to Phillip Kovalev. -2.1.17 - - fixed haskell delimiters (hackily). Thanks to Elias Pipping. - - add support for mailcap. Thanks to Pascal Brueckner. - - add support for stata. Thanks to Jerónimo Carballo. - - applied a patch from ewfalor to fix an error in the help file with the - NERDMapleader doc - - disable the insert mode ctrl-c mapping by default, see :help - NERDCommenterInsert if you wish to restore it +The `master` branch is considered stable and will have the latest filetype +support and bugfixes. ============================================================================== 9. Credits *NERDCommenterCredits* From be1a24d6d8f147c763ee6acf66a9932dcd87f115 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Mon, 8 Jun 2020 14:55:53 +0300 Subject: [PATCH 39/42] Backfill some Changelog data from Github releases --- CHANGELOG.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a6c4210..9408b3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,23 @@ +# Changelog + +### 2.5.2 + +* Minor update to include new file types contributed by the community over the last few months. +* Also adds a customization option to the sexy comment style. + +### 2.5.1 + +* Minor update release that adds a few new contributed filetypes and normalizes the code format a little bit. + +### 2.5.0 + +* Add lots of new contributed file types, cleanup some odds and ends. +* Bump "release" for the sake of plugin managers still not tracking master. + +### 2.4.0 + +* Bump release number for the benefit of plugin managers that update to tags + ### 2.3.0 * remove all filetypes which have a &commentstring in the standard vim runtime From c3e308c2ca01dc4569cdbb211e1eca37d3a34646 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Mon, 8 Jun 2020 15:17:03 +0300 Subject: [PATCH 40/42] Drop rakefile historically used to cut releases We no longer release this way at all, nor is this the way to install it locally. --- Rakefile | 76 -------------------------------------------------------- 1 file changed, 76 deletions(-) delete mode 100644 Rakefile diff --git a/Rakefile b/Rakefile deleted file mode 100644 index c7bf9e6..0000000 --- a/Rakefile +++ /dev/null @@ -1,76 +0,0 @@ -# written by travis jeffery -# contributions by scrooloose - -require 'rake' -require 'find' -require 'pathname' - -IGNORE = [/\.gitignore$/, /Rakefile$/] - -files = `git ls-files`.split("\n") -files.reject! { |f| IGNORE.any? { |re| f.match(re) } } - -desc 'Zip up the project files' -task :zip do - zip_name = File.basename(File.dirname(__FILE__)) - zip_name.gsub!(/ /, '_') - zip_name = "#{zip_name}.zip" - - if File.exist?(zip_name) - abort("Zip file #{zip_name} already exists. Remove it first.") - end - - puts "Creating zip file: #{zip_name}" - system("zip #{zip_name} #{files.join(" ")}") -end - -desc 'Install plugin and documentation' -task :install do - vimfiles = if ENV['VIMFILES'] - ENV['VIMFILES'] - elsif RUBY_PLATFORM =~ /(win|w)32$/ - File.expand_path("~/vimfiles") - else - File.expand_path("~/.vim") - end - files.each do |file| - target_file = File.join(vimfiles, file) - FileUtils.mkdir_p File.dirname(target_file) - FileUtils.cp file, target_file - - puts "Installed #{file} to #{target_file}" - end - -end - -desc 'Pulls from origin' -task :pull do - puts "Updating local repo..." - system("cd " << Dir.new(File.dirname(__FILE__)).path << " && git pull") -end - -desc 'Calls pull task and then install task' -task :update => ['pull', 'install'] do - puts "Update of vim script complete." -end - -desc 'Uninstall plugin and documentation' -task :uninstall do - vimfiles = if ENV['VIMFILES'] - ENV['VIMFILES'] - elsif RUBY_PLATFORM =~ /(win|w)32$/ - File.expand_path("~/vimfiles") - else - File.expand_path("~/.vim") - end - files.each do |file| - target_file = File.join(vimfiles, file) - FileUtils.rm target_file - - puts "Uninstalled #{target_file}" - end - -end - -task :default => ['update'] - From 6b49172f9bf03bd855afa65876df43a1a7321b86 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Mon, 8 Jun 2020 15:20:59 +0300 Subject: [PATCH 41/42] Remove obsolete (unmaintained) fold markers The fold markers were unmaintained anyway and hence not working. No folding is better than broken folding, and setting nothing allows user configs such as language syntax based folding to work properly. --- plugin/NERD_commenter.vim | 174 +++++++++++++++++++------------------- 1 file changed, 87 insertions(+), 87 deletions(-) diff --git a/plugin/NERD_commenter.vim b/plugin/NERD_commenter.vim index aece2d9..5d32d38 100644 --- a/plugin/NERD_commenter.vim +++ b/plugin/NERD_commenter.vim @@ -1,4 +1,4 @@ -" Section: script init stuff {{{1 +" Section: script init stuff if exists('loaded_nerd_comments') finish endif @@ -8,7 +8,7 @@ if v:version < 700 endif let loaded_nerd_comments = 1 -" Function: s:InitVariable() function {{{2 +" Function: s:InitVariable() function " This function is used to initialise a given variable to a given value. The " variable is only initialised if it does not exist prior " @@ -26,14 +26,14 @@ function s:InitVariable(var, value) return 0 endfunction -" Section: space string init{{{2 +" Section: space string init " When putting spaces after the left delimiter and before the right we use " s:spaceStr for the space char. This way we can make it add anything after " the left and before the right by modifying this variable let s:spaceStr = ' ' let s:lenSpaceStr = strlen(s:spaceStr) -" Section: variable initialization {{{2 +" Section: variable initialization call s:InitVariable('g:NERDAllowAnyVisualDelims', 1) call s:InitVariable('g:NERDBlockComIgnoreEmpty', 0) call s:InitVariable('g:NERDCommentWholeLinesInVMode', 0) @@ -482,9 +482,9 @@ if exists('g:NERDCustomDelimiters') call extend(s:delimiterMap, g:NERDCustomDelimiters) endif -" Section: Comment mapping functions, autocommands and commands {{{1 +" Section: Comment mapping functions, autocommands and commands " ============================================================================ -" Section: Comment enabler autocommands {{{2 +" Section: Comment enabler autocommands " ============================================================================ augroup NERDCommenter @@ -499,7 +499,7 @@ augroup NERDCommenter augroup END -" Function: s:SetUpForNewFiletype(filetype) function {{{2 +" Function: s:SetUpForNewFiletype(filetype) function " This function is responsible for setting up buffer scoped variables for the " given filetype. " @@ -568,7 +568,7 @@ function s:CreateDelimMapFromCms() \ 'nestedAlt': 0} endfunction -" Function: s:SwitchToAlternativeDelimiters(printMsgs) function {{{2 +" Function: s:SwitchToAlternativeDelimiters(printMsgs) function " This function is used to swap the delimiters that are being used to the " alternative delimiters for that filetype. For example, if a c++ file is " being edited and // comments are being used, after this function is called @@ -618,9 +618,9 @@ function s:SwitchToAlternativeDelimiters(printMsgs) return 1 endfunction -" Section: Comment delimiter add/removal functions {{{1 +" Section: Comment delimiter add/removal functions " ============================================================================ -" Function: s:AppendCommentToLine(){{{2 +" Function: s:AppendCommentToLine() " This function appends comment delimiters at the EOL and places the cursor in " position to start typing the comment function s:AppendCommentToLine() @@ -648,7 +648,7 @@ function s:AppendCommentToLine() endif endfunction -" Function: s:CommentBlock(top, bottom, lSide, rSide, forceNested ) {{{2 +" Function: s:CommentBlock(top, bottom, lSide, rSide, forceNested ) " This function is used to comment out a region of code. This region is " specified as a bounding box by arguments to the function. " @@ -782,7 +782,7 @@ function s:CommentBlock(top, bottom, lSide, rSide, forceNested ) endif endfunction -" Function: s:CommentLines(forceNested, alignLeft, alignRight, firstLine, lastLine) {{{2 +" Function: s:CommentLines(forceNested, alignLeft, alignRight, firstLine, lastLine) " This function comments a range of lines. " " Args: @@ -851,7 +851,7 @@ function s:CommentLines(forceNested, align, firstLine, lastLine) endfunction -" Function: s:CommentLinesMinimal(firstLine, lastLine) {{{2 +" Function: s:CommentLinesMinimal(firstLine, lastLine) " This function comments a range of lines in a minimal style. I " " Args: @@ -912,7 +912,7 @@ function s:CommentLinesMinimal(firstLine, lastLine) call setline(a:lastLine, theLine) endfunction -" Function: s:CommentLinesSexy(topline, bottomline) function {{{2 +" Function: s:CommentLinesSexy(topline, bottomline) function " This function is used to comment lines in the 'Sexy' style. E.g., in c: " /* " * This is a sexy comment @@ -1047,7 +1047,7 @@ function s:CommentLinesSexy(topline, bottomline) endfunction -" Function: s:CommentLinesToggle(forceNested, firstLine, lastLine) {{{2 +" Function: s:CommentLinesToggle(forceNested, firstLine, lastLine) " Applies "toggle" commenting to the given range of lines " " Args: @@ -1104,7 +1104,7 @@ function s:CommentLinesToggle(forceNested, firstLine, lastLine) endfunction -" Function: s:CommentRegion(topline, topCol, bottomLine, bottomCol) function {{{2 +" Function: s:CommentRegion(topline, topCol, bottomLine, bottomCol) function " This function comments chunks of text selected in visual mode. " It will comment exactly the text that they have selected. " Args: @@ -1156,7 +1156,7 @@ function s:CommentRegion(topLine, topCol, bottomLine, bottomCol, forceNested) endfunction -" Function: s:InvertComment(firstLine, lastLine) function {{{2 +" Function: s:InvertComment(firstLine, lastLine) function " Inverts the comments on the lines between and including the given line " numbers i.e all commented lines are uncommented and vice versa " Args: @@ -1205,7 +1205,7 @@ function! NERDCommentIsLineCommented(lineNo) return s:IsInSexyComment(a:lineNo) || s:IsCommentedFromStartOfLine(s:Left(), theLine) || s:IsCommentedFromStartOfLine(s:Left({'alt': 1}), theLine) endfunction -" Function: NERDComment(mode, type) function {{{2 +" Function: NERDComment(mode, type) function " This function is a Wrapper for the main commenting functions " " Args: @@ -1458,7 +1458,7 @@ function! NERDCommentIsCharCommented(line, col) abort \ a:col) endfunction -" Function: s:PlaceDelimitersAndInsBetween() function {{{2 +" Function: s:PlaceDelimitersAndInsBetween() function " This is function is called to place comment delimiters down and place the " cursor between them function s:PlaceDelimitersAndInsBetween() @@ -1508,7 +1508,7 @@ function s:PlaceDelimitersAndInsBetween() endif endfunction -" Function: s:RemoveDelimiters(left, right, line) {{{2 +" Function: s:RemoveDelimiters(left, right, line) " this function is called to remove the first left comment delimiter and the " last right delimiter of the given line. " @@ -1557,7 +1557,7 @@ function s:RemoveDelimiters(left, right, line) return line endfunction -" Function: s:SetupStateBeforeLineComment(topLine, bottomLine) {{{2 +" Function: s:SetupStateBeforeLineComment(topLine, bottomLine) " Changes ignorecase and foldmethod options before commenting lines and saves " their original values in a dict, which is returned as a result " @@ -1586,7 +1586,7 @@ function s:SetupStateBeforeLineComment(topLine, bottomLine) return state endfunction -" Function: s:RecoverStateAfterLineComment(state) {{{2 +" Function: s:RecoverStateAfterLineComment(state) " Receives the state returned by s:SetupStateBeforeLineComment and restores " the state accordingly " @@ -1602,7 +1602,7 @@ function s:RecoverStateAfterLineComment(state) endif endfunction -" Function: s:TrimTrailingWhitespace(line) {{{2 +" Function: s:TrimTrailingWhitespace(line) " This function removes all the trailing whitespace " Args: " -line: the target line @@ -1611,7 +1611,7 @@ function s:TrimTrailingWhitespace(line) return toReturn endfunction -" Function: s:UncommentLines(topLine, bottomLine) {{{2 +" Function: s:UncommentLines(topLine, bottomLine) " This function uncomments the given lines " " Args: @@ -1657,7 +1657,7 @@ function s:UncommentLines(topLine, bottomLine) endfunction -" Function: s:UncommentLinesSexy(topline, bottomline) {{{2 +" Function: s:UncommentLinesSexy(topline, bottomline) " This function removes all the comment characters associated with the sexy " comment spanning the given lines " Args: @@ -1788,7 +1788,7 @@ function s:UncommentLinesSexy(topline, bottomline) endif endfunction -" Function: s:UncommentLineNormal(line) {{{2 +" Function: s:UncommentLineNormal(line) " uncomments the given line and returns the result " Args: " -line: the line to uncomment @@ -1865,7 +1865,7 @@ function s:UncommentLineNormal(line) return line endfunction -" Function: s:UncommentLinesNormal(topline, bottomline) {{{2 +" Function: s:UncommentLinesNormal(topline, bottomline) " This function is called to uncomment lines that aren't a sexy comment " Args: " -topline/bottomline: the top/bottom line numbers of the comment @@ -1879,16 +1879,16 @@ function s:UncommentLinesNormal(topline, bottomline) endfunction -" Section: Other helper functions {{{1 +" Section: Other helper functions " ============================================================================ -" Function: s:AddLeftDelim(delim, theLine) {{{2 +" Function: s:AddLeftDelim(delim, theLine) " Args: function s:AddLeftDelim(delim, theLine) return substitute(a:theLine, '^\([ \t]*\)', '\1' . a:delim, '') endfunction -" Function: s:AddLeftDelimAligned(delim, theLine) {{{2 +" Function: s:AddLeftDelimAligned(delim, theLine) " Args: function s:AddLeftDelimAligned(delim, theLine, alignIndx) @@ -1902,7 +1902,7 @@ function s:AddLeftDelimAligned(delim, theLine, alignIndx) return strpart(theLine, 0, a:alignIndx) . a:delim . strpart(theLine, a:alignIndx) endfunction -" Function: s:AddRightDelim(delim, theLine) {{{2 +" Function: s:AddRightDelim(delim, theLine) " Args: function s:AddRightDelim(delim, theLine) if a:delim ==# '' @@ -1912,7 +1912,7 @@ function s:AddRightDelim(delim, theLine) endif endfunction -" Function: s:AddRightDelimAligned(delim, theLine, alignIndx) {{{2 +" Function: s:AddRightDelimAligned(delim, theLine, alignIndx) " Args: function s:AddRightDelimAligned(delim, theLine, alignIndx) if a:delim ==# '' @@ -1930,19 +1930,19 @@ function s:AddRightDelimAligned(delim, theLine, alignIndx) endif endfunction -" Function: s:AltMultipart() {{{2 +" Function: s:AltMultipart() " returns 1 if the alternative delimiters are multipart function s:AltMultipart() return b:NERDCommenterDelims['rightAlt'] !=# '' endfunction -" Function: s:AltNested() {{{2 +" Function: s:AltNested() " returns 1 if the alternate multipart (if any) delimiters allow nesting function s:AltNested() return b:NERDCommenterDelims['nestedAlt'] endfunction -" Function: s:CanCommentLine(forceNested, line) {{{2 +" Function: s:CanCommentLine(forceNested, line) "This function is used to determine whether the given line can be commented. "It returns 1 if it can be and 0 otherwise " @@ -1979,7 +1979,7 @@ function s:CanCommentLine(forceNested, lineNum) return 0 endfunction -" Function: s:CanPlaceCursor(line, col) {{{2 +" Function: s:CanPlaceCursor(line, col) " returns 1 if the cursor can be placed exactly in the given position function s:CanPlaceCursor(line, col) let c = col('.') @@ -1990,7 +1990,7 @@ function s:CanPlaceCursor(line, col) return success endfunction -" Function: s:CanSexyCommentLines(topline, bottomline) {{{2 +" Function: s:CanSexyCommentLines(topline, bottomline) " Return: 1 if the given lines can be commented sexually, 0 otherwise function s:CanSexyCommentLines(topline, bottomline) " see if the selected regions have any sexy comments @@ -2008,7 +2008,7 @@ function s:CanSexyCommentLines(topline, bottomline) endwhile return 1 endfunction -" Function: s:CanToggleCommentLine(forceNested, line) {{{2 +" Function: s:CanToggleCommentLine(forceNested, line) "This function is used to determine whether the given line can be toggle commented. "It returns 1 if it can be and 0 otherwise " @@ -2034,7 +2034,7 @@ function s:CanToggleCommentLine(forceNested, lineNum) return 1 endfunction -" Function: s:ConvertLeadingSpacesToTabs(line) {{{2 +" Function: s:ConvertLeadingSpacesToTabs(line) " This function takes a line and converts all leading tabs on that line into " spaces " @@ -2050,7 +2050,7 @@ function s:ConvertLeadingSpacesToTabs(line) endfunction -" Function: s:ConvertLeadingTabsToSpaces(line) {{{2 +" Function: s:ConvertLeadingTabsToSpaces(line) " This function takes a line and converts all leading spaces on that line into " tabs " @@ -2065,7 +2065,7 @@ function s:ConvertLeadingTabsToSpaces(line) return toReturn endfunction -" Function: s:ConvertLeadingWhiteSpace(line) {{{2 +" Function: s:ConvertLeadingWhiteSpace(line) " Converts the leading white space to tabs/spaces depending on &tabstop " " Args: @@ -2084,7 +2084,7 @@ function s:ConvertLeadingWhiteSpace(line) endfunction -" Function: s:CountNonESCedOccurances(str, searchstr, escChar) {{{2 +" Function: s:CountNonESCedOccurances(str, searchstr, escChar) " This function counts the number of substrings contained in another string. " These substrings are only counted if they are not escaped with escChar " Args: @@ -2111,7 +2111,7 @@ function s:CountNonESCedOccurances(str, searchstr, escChar) endif endif endfunction -" Function: s:DoesBlockHaveDelim(delim, top, bottom) {{{2 +" Function: s:DoesBlockHaveDelim(delim, top, bottom) " Returns 1 if the given block of lines has a delimiter (a:delim) in it " Args: " -delim: the comment delimiter to check the block for @@ -2129,7 +2129,7 @@ function s:DoesBlockHaveDelim(delim, top, bottom) return 0 endfunction -" Function: s:DoesBlockHaveMultipartDelim(top, bottom) {{{2 +" Function: s:DoesBlockHaveMultipartDelim(top, bottom) " Returns 1 if the given block has a >= 1 multipart delimiter in it " Args: " -top: the top line number of the block @@ -2146,14 +2146,14 @@ function s:DoesBlockHaveMultipartDelim(top, bottom) endfunction -" Function: s:Esc(str) {{{2 +" Function: s:Esc(str) " Escapes all the tricky chars in the given string function s:Esc(str) let charsToEsc = '*/\."&$+' return escape(a:str, charsToEsc) endfunction -" Function: s:FindDelimiterIndex(delimiter, line) {{{2 +" Function: s:FindDelimiterIndex(delimiter, line) " This function is used to get the string index of the input comment delimiter " on the input line. If no valid comment delimiter is found in the line then " -1 is returned @@ -2206,7 +2206,7 @@ function s:FindDelimiterIndex(delimiter, line) return -1 endfunction -" Function: s:FindBoundingLinesOfSexyCom(lineNum) {{{2 +" Function: s:FindBoundingLinesOfSexyCom(lineNum) " This function takes in a line number and tests whether this line number is " the top/bottom/middle line of a sexy comment. If it is then the top/bottom " lines of the sexy comment are returned @@ -2281,7 +2281,7 @@ function s:FindBoundingLinesOfSexyCom(lineNum) endfunction -" Function: s:GetSexyComMarker() {{{2 +" Function: s:GetSexyComMarker() " Returns the sexy comment marker for the current filetype. " " C style sexy comments are assumed if possible. If not then the sexy comment @@ -2333,7 +2333,7 @@ function s:GetSexyComMarker(space, esc) return sexyComMarker endfunction -" Function: s:SexyNested() {{{2 +" Function: s:SexyNested() " Returns 1 if the sexy delimeters allow nesting " TODO this is ugly copy&paste from the GetSexyComLeft/Right functions, " these could all be cleaned up @@ -2356,7 +2356,7 @@ function s:SexyNested() endif endfunction -" Function: s:GetSexyComLeft(space, esc) {{{2 +" Function: s:GetSexyComLeft(space, esc) " Returns the left delimiter for sexy comments for this filetype or -1 if " there is none. C style sexy comments are used if possible " Args: @@ -2393,7 +2393,7 @@ function s:GetSexyComLeft(space, esc) return left endfunction -" Function: s:GetSexyComRight(space, esc) {{{2 +" Function: s:GetSexyComRight(space, esc) " Returns the right delimiter for sexy comments for this filetype or -1 if " there is none. C style sexy comments are used if possible. " Args: @@ -2431,13 +2431,13 @@ function s:GetSexyComRight(space, esc) return right endfunction -" Function: s:HasMultipartDelims() {{{2 +" Function: s:HasMultipartDelims() " Returns 1 if the current filetype has at least one set of multipart delimiters function s:HasMultipartDelims() return s:Multipart() || s:AltMultipart() endfunction -" Function: s:HasLeadingTabs(...) {{{2 +" Function: s:HasLeadingTabs(...) " Returns 1 if any of the given strings have leading tabs function s:HasLeadingTabs(...) for s in a:000 @@ -2447,13 +2447,13 @@ function s:HasLeadingTabs(...) endfor return 0 endfunction -" Function: s:HasCStyleComments() {{{2 +" Function: s:HasCStyleComments() " Returns 1 if the current filetype has c style comment delimiters function s:HasCStyleComments() return (s:Left() ==# '/*' && s:Right() ==# '*/') || (s:Left({'alt': 1}) ==# '/*' && s:Right({'alt': 1}) ==# '*/') endfunction -" Function: s:IsCommentedNormOrSexy(lineNum) {{{2 +" Function: s:IsCommentedNormOrSexy(lineNum) "This function is used to determine whether the given line is commented with "either set of delimiters or if it is part of a sexy comment " @@ -2474,7 +2474,7 @@ function s:IsCommentedNormOrSexy(lineNum) return 0 endfunction -" Function: s:IsCommented(left, right, line) {{{2 +" Function: s:IsCommented(left, right, line) "This function is used to determine whether the given line is commented with "the given delimiters " @@ -2489,7 +2489,7 @@ function s:IsCommented(left, right, line) return 0 endfunction -" Function: s:IsCommentedFromStartOfLine(left, line) {{{2 +" Function: s:IsCommentedFromStartOfLine(left, line) "This function is used to determine whether the given line is commented with "the given delimiters at the start of the line i.e the left delimiter is the "first thing on the line (apart from spaces\tabs) @@ -2504,7 +2504,7 @@ function s:IsCommentedFromStartOfLine(left, line) return delimIndx ==# numSpaces endfunction -" Function: s:IsCommentedOutermost(left, right, leftAlt, rightAlt, line) {{{2 +" Function: s:IsCommentedOutermost(left, right, leftAlt, rightAlt, line) " Finds the type of the outermost delimiters on the line " " Args: @@ -2547,7 +2547,7 @@ function s:IsCommentedOutermost(left, right, leftAlt, rightAlt, line) endfunction -" Function: s:IsDelimValid(delimiter, delIndx, line) {{{2 +" Function: s:IsDelimValid(delimiter, delIndx, line) " This function is responsible for determining whether a given instance of a " comment delimiter is a real delimiter or not. For example, in java the " // string is a comment delimiter but in the line: @@ -2624,7 +2624,7 @@ function s:IsDelimValid(delimiter, delIndx, line) endfunction -" Function: s:IsNumEven(num) {{{2 +" Function: s:IsNumEven(num) " A small function the returns 1 if the input number is even and 0 otherwise " Args: " -num: the number to check @@ -2632,7 +2632,7 @@ function s:IsNumEven(num) return (a:num % 2) ==# 0 endfunction -" Function: s:IsEscaped(str, indx, escChar) {{{2 +" Function: s:IsEscaped(str, indx, escChar) " This function takes a string, an index into that string and an esc char and " returns 1 if the char at the index is escaped (i.e if it is preceded by an " odd number of esc chars) @@ -2661,13 +2661,13 @@ function s:IsEscaped(str, indx, escChar) return !s:IsNumEven(numEscChars) endfunction -" Function: s:IsInSexyComment(line) {{{2 +" Function: s:IsInSexyComment(line) " returns 1 if the given line number is part of a sexy comment function s:IsInSexyComment(line) return !empty(s:FindBoundingLinesOfSexyCom(a:line)) endfunction -" Function: s:IsSexyComment(topline, bottomline) {{{2 +" Function: s:IsSexyComment(topline, bottomline) " This function takes in 2 line numbers and returns 1 if the lines between and " including the given line numbers are a sexy comment. It returns 0 otherwise. " Args: @@ -2748,7 +2748,7 @@ function s:IsSexyComment(topline, bottomline) endfunction -" Function: s:LastIndexOfDelim(delim, str) {{{2 +" Function: s:LastIndexOfDelim(delim, str) " This function takes a string and a delimiter and returns the last index of " that delimiter in string " Args: @@ -2786,7 +2786,7 @@ function s:LastIndexOfDelim(delim, str) endfunction -" Function: s:Left(...) {{{2 +" Function: s:Left(...) " returns left delimiter data function s:Left(...) let params = a:0 ? a:1 : {} @@ -2808,7 +2808,7 @@ function s:Left(...) return delim endfunction -" Function: s:LeftMostIndx(countCommentedLines, countEmptyLines, topline, bottomline) {{{2 +" Function: s:LeftMostIndx(countCommentedLines, countEmptyLines, topline, bottomline) " This function takes in 2 line numbers and returns the index of the left most " char (that is not a space or a tab) on all of these lines. " Args: @@ -2852,13 +2852,13 @@ function s:LeftMostIndx(countCommentedLines, countEmptyLines, topline, bottomlin endif endfunction -" Function: s:Multipart() {{{2 +" Function: s:Multipart() " returns 1 if the current delimiters are multipart function s:Multipart() return s:Right() !=# '' endfunction -" Function: s:NerdEcho(msg, typeOfMsg) {{{2 +" Function: s:NerdEcho(msg, typeOfMsg) " Args: " -msg: the message to echo " -typeOfMsg: 0 = warning message @@ -2873,25 +2873,25 @@ function s:NerdEcho(msg, typeOfMsg) endif endfunction -" Function: s:Nested() {{{2 +" Function: s:Nested() " returns 1 if the current multipart (if any) delimiters allow nesting function s:Nested() return b:NERDCommenterDelims['nested'] endfunction -" Function: s:NumberOfLeadingTabs(s) {{{2 +" Function: s:NumberOfLeadingTabs(s) " returns the number of leading tabs in the given string function s:NumberOfLeadingTabs(s) return strlen(substitute(a:s, '^\(\t*\).*$', '\1', '')) endfunction -" Function: s:NumLinesInBuf() {{{2 +" Function: s:NumLinesInBuf() " Returns the number of lines in the current buffer function s:NumLinesInBuf() return line('$') endfunction -" Function: s:ReplaceDelims(toReplace1, toReplace2, replacor1, replacor2, str) {{{2 +" Function: s:ReplaceDelims(toReplace1, toReplace2, replacor1, replacor2, str) " This function takes in a string, 2 delimiters in that string and 2 strings " to replace these delimiters with. " @@ -2907,7 +2907,7 @@ function s:ReplaceDelims(toReplace1, toReplace2, replacor1, replacor2, str) return line endfunction -" Function: s:ReplaceLeftMostDelim(toReplace, replacor, str) {{{2 +" Function: s:ReplaceLeftMostDelim(toReplace, replacor, str) " This function takes a string and a delimiter and replaces the left most " occurrence of this delimiter in the string with a given string " @@ -2931,7 +2931,7 @@ function s:ReplaceLeftMostDelim(toReplace, replacor, str) return a:str endfunction -" Function: s:ReplaceRightMostDelim(toReplace, replacor, str) {{{2 +" Function: s:ReplaceRightMostDelim(toReplace, replacor, str) " This function takes a string and a delimiter and replaces the right most " occurrence of this delimiter in the string with a given string " @@ -2956,7 +2956,7 @@ function s:ReplaceRightMostDelim(toReplace, replacor, str) return line endfunction -"FUNCTION: s:RestoreScreenState() {{{2 +"FUNCTION: s:RestoreScreenState() " "Sets the screen state back to what it was when s:SaveScreenState was last "called. @@ -2971,7 +2971,7 @@ function s:RestoreScreenState() call setpos('.', t:NERDComOldPos) endfunction -" Function: s:Right(...) {{{2 +" Function: s:Right(...) " returns right delimiter data function s:Right(...) let params = a:0 ? a:1 : {} @@ -2993,7 +2993,7 @@ function s:Right(...) return delim endfunction -" Function: s:RightMostIndx(countCommentedLines, countEmptyLines, topline, bottomline) {{{2 +" Function: s:RightMostIndx(countCommentedLines, countEmptyLines, topline, bottomline) " This function takes in 2 line numbers and returns the index of the right most " char on all of these lines. " Args: @@ -3032,7 +3032,7 @@ function s:RightMostIndx(countCommentedLines, countEmptyLines, topline, bottomli return rightMostIndx endfunction -"FUNCTION: s:SaveScreenState() {{{2 +"FUNCTION: s:SaveScreenState() "Saves the current cursor position in the current buffer and the window "scroll position function s:SaveScreenState() @@ -3040,7 +3040,7 @@ function s:SaveScreenState() let t:NERDComOldTopLine = line('w0') endfunction -" Function: s:SwapOuterMultiPartDelimsForPlaceHolders(line) {{{2 +" Function: s:SwapOuterMultiPartDelimsForPlaceHolders(line) " This function takes a line and swaps the outer most multi-part delimiters for " place holders " Args: @@ -3068,7 +3068,7 @@ function s:SwapOuterMultiPartDelimsForPlaceHolders(line) return line2 endfunction -" Function: s:SwapOuterPlaceHoldersForMultiPartDelims(line) {{{2 +" Function: s:SwapOuterPlaceHoldersForMultiPartDelims(line) " This function takes a line and swaps the outermost place holders for " multi-part delimiters " Args: @@ -3088,7 +3088,8 @@ function s:SwapOuterPlaceHoldersForMultiPartDelims(line) let line = s:ReplaceDelims(g:NERDLPlace, g:NERDRPlace, left, right, a:line) return line endfunction -" Function: s:TabbedCol(line, col) {{{2 + +" Function: s:TabbedCol(line, col) " Gets the col number for given line and existing col number. The new col " number is the col number when all leading spaces are converted to tabs " Args: @@ -3099,7 +3100,8 @@ function s:TabbedCol(line, col) let lineSpacesToTabs = substitute(lineTruncated, s:TabSpace(), '\t', 'g') return strlen(lineSpacesToTabs) endfunction -"FUNCTION: s:TabSpace() {{{2 + +"FUNCTION: s:TabSpace() "returns a string of spaces equal in length to &tabstop function s:TabSpace() let tabSpace = '' @@ -3111,7 +3113,7 @@ function s:TabSpace() return tabSpace endfunction -" Function: s:UnEsc(str, escChar) {{{2 +" Function: s:UnEsc(str, escChar) " This function removes all the escape chars from a string " Args: " -str: the string to remove esc chars from @@ -3120,7 +3122,7 @@ function s:UnEsc(str, escChar) return substitute(a:str, a:escChar, '', 'g') endfunction -" Function: s:UntabbedCol(line, col) {{{2 +" Function: s:UntabbedCol(line, col) " Takes a line and a col and returns the absolute column of col taking into " account that a tab is worth 3 or 4 (or whatever) spaces. " Args: @@ -3131,7 +3133,7 @@ function s:UntabbedCol(line, col) let lineTabsToSpaces = substitute(lineTruncated, '\t', s:TabSpace(), 'g') return strlen(lineTabsToSpaces) endfunction -" Section: Comment mapping and menu item setup {{{1 +" Section: Comment mapping and menu item setup " =========================================================================== " Create menu items for the specified modes. If a:combo is not empty, then @@ -3193,5 +3195,3 @@ nnoremap NERDCommenterAltDelims :call SwitchToAlternativeDelimiters(1 " This is a workaround to enable lazy-loading from supported plugin managers: " See https://github.com/preservim/nerdcommenter/issues/176 call s:SetUpForNewFiletype(&filetype, 1) - -" vim: set foldmethod=marker : From bedc6dc3845119e9e92fe664fb0f48561e194800 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Mon, 8 Jun 2020 15:23:56 +0300 Subject: [PATCH 42/42] Add vint configuratio to enforce more sensitive rules --- .vintrc.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .vintrc.yaml diff --git a/.vintrc.yaml b/.vintrc.yaml new file mode 100644 index 0000000..c44b6ab --- /dev/null +++ b/.vintrc.yaml @@ -0,0 +1,5 @@ +cmdargs: + severity: style_problem + color: true + env: + neovim: false