├── .github └── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── .gitignore ├── README.md ├── autoload └── ingo │ ├── actions.vim │ ├── actions │ ├── iterations.vim │ └── special.vim │ ├── area.vim │ ├── area │ └── frompattern.vim │ ├── avoidprompt.vim │ ├── binary.vim │ ├── buffer.vim │ ├── buffer │ ├── ephemeral.vim │ ├── generate.vim │ ├── locate.vim │ ├── network.vim │ ├── scratch.vim │ ├── scratch │ │ └── converted.vim │ ├── temp.vim │ ├── temprange.vim │ └── visible.vim │ ├── buffers.vim │ ├── change.vim │ ├── change │ ├── processed.vim │ └── virtcols.vim │ ├── cmdargs.vim │ ├── cmdargs │ ├── command.vim │ ├── commandcommands.vim │ ├── file.vim │ ├── glob.vim │ ├── pattern.vim │ ├── range.vim │ ├── register.vim │ └── substitute.vim │ ├── cmdline │ └── showmode.vim │ ├── cmdrange.vim │ ├── cmdrangeconverter.vim │ ├── codec │ └── URL.vim │ ├── collections.vim │ ├── collections │ ├── differences.vim │ ├── find.vim │ ├── fromsplit.vim │ ├── memoized.vim │ ├── permute.vim │ ├── recursive.vim │ ├── rotate.vim │ └── unique.vim │ ├── comments.vim │ ├── comments │ └── indent.vim │ ├── compat.vim │ ├── compat │ ├── command.vim │ ├── commands.vim │ ├── complete.vim │ ├── regexp.vim │ ├── shellcommand.vim │ ├── substitution.vim │ └── window.vim │ ├── convert.vim │ ├── cursor.vim │ ├── cursor │ ├── keep.vim │ └── move.vim │ ├── date.vim │ ├── date │ ├── epoch.vim │ └── format.vim │ ├── dict.vim │ ├── dict │ ├── count.vim │ └── find.vim │ ├── digest.vim │ ├── digraph.vim │ ├── encoding.vim │ ├── err.vim │ ├── escape.vim │ ├── escape │ ├── command.vim │ ├── file.vim │ ├── mapping.vim │ └── shellcommand.vim │ ├── event.vim │ ├── external.vim │ ├── file.vim │ ├── filetype.vim │ ├── folds.vim │ ├── folds │ ├── containment.vim │ └── persistence.vim │ ├── foldtext.vim │ ├── format.vim │ ├── format │ └── columns.vim │ ├── fs │ ├── path.vim │ ├── path │ │ ├── asfilename.vim │ │ └── split.vim │ ├── tempfile.vim │ └── traversal.vim │ ├── ftplugin │ ├── converter.vim │ ├── converter │ │ ├── builder.vim │ │ └── external.vim │ ├── onbufwinenter.vim │ ├── setting.vim │ └── windowsettings.vim │ ├── funcref.vim │ ├── function │ └── uniquify.vim │ ├── gui │ └── position.vim │ ├── hlgroup.vim │ ├── indent.vim │ ├── join.vim │ ├── line │ └── replace.vim │ ├── lines.vim │ ├── lines │ ├── empty.vim │ └── replace.vim │ ├── list.vim │ ├── list │ ├── find.vim │ ├── lcs.vim │ ├── merge.vim │ ├── pattern.vim │ ├── reduce.vim │ ├── sequence.vim │ ├── split.vim │ └── transform.vim │ ├── lists.vim │ ├── lists │ └── find.vim │ ├── lnum.vim │ ├── mapmaker.vim │ ├── matches.vim │ ├── math.vim │ ├── mbyte │ └── virtcol.vim │ ├── motion │ ├── boundary.vim │ ├── helper.vim │ └── omap.vim │ ├── msg.vim │ ├── nary.vim │ ├── number.vim │ ├── option.vim │ ├── option │ ├── autochdir.vim │ └── listchars.vim │ ├── os.vim │ ├── plugin │ ├── cmd │ │ └── withpattern.vim │ ├── cmdcomplete.vim │ ├── cmdcomplete │ │ └── dirforaction.vim │ ├── compiler.vim │ ├── historyrecall.vim │ ├── marks.vim │ ├── persistence.vim │ ├── register.vim │ ├── rendered.vim │ ├── rendered │ │ ├── Confirmeach.vim │ │ └── Subset.vim │ └── setting.vim │ ├── pos.vim │ ├── print.vim │ ├── print │ └── highlighted.vim │ ├── query.vim │ ├── query │ ├── confirm.vim │ ├── file.vim │ ├── fromlist.vim │ ├── get.vim │ ├── motion.vim │ ├── recall.vim │ └── substitute.vim │ ├── range.vim │ ├── range │ ├── borders.vim │ ├── invert.vim │ ├── lines.vim │ ├── merge.vim │ └── sort.vim │ ├── ranges.vim │ ├── record.vim │ ├── regexp.vim │ ├── regexp │ ├── build.vim │ ├── capture.vim │ ├── collection.vim │ ├── comments.vim │ ├── deconstruct.vim │ ├── fromwildcard.vim │ ├── length.vim │ ├── magic.vim │ ├── pairs.vim │ ├── parse.vim │ ├── previoussubstitution.vim │ ├── split.vim │ └── virtcols.vim │ ├── register.vim │ ├── register │ ├── accumulate.vim │ └── pending.vim │ ├── search │ ├── buffer.vim │ ├── pattern.vim │ └── timelimited.vim │ ├── selection.vim │ ├── selection │ ├── area.vim │ ├── frompattern.vim │ ├── patternmatch.vim │ └── virtcols.vim │ ├── smartcase.vim │ ├── str.vim │ ├── str │ ├── find.vim │ ├── frompattern.vim │ ├── fromrange.vim │ ├── join.vim │ ├── list.vim │ ├── remove.vim │ ├── restricted.vim │ └── split.vim │ ├── strdisplaywidth.vim │ ├── strdisplaywidth │ └── pad.vim │ ├── subs │ ├── BraceCreation.vim │ ├── BraceExpansion.vim │ └── apply.vim │ ├── subst.vim │ ├── subst │ ├── expr │ │ └── emulation.vim │ ├── pairs.vim │ └── replacement.vim │ ├── swap.vim │ ├── syntaxitem.vim │ ├── system.vim │ ├── tabpage.vim │ ├── tabstops.vim │ ├── text.vim │ ├── text │ ├── frompattern.vim │ ├── replace.vim │ ├── searchhighlights.vim │ ├── surroundings.vim │ └── surroundings │ │ ├── Lines.vim │ │ └── Lines │ │ └── Creator.vim │ ├── undo.vim │ ├── units.vim │ ├── version.vim │ ├── view.vim │ ├── window.vim │ ├── window │ ├── adjacent.vim │ ├── cmdwin.vim │ ├── dimensions.vim │ ├── iterate.vim │ ├── locate.vim │ ├── preview.vim │ ├── quickfix.vim │ ├── special.vim │ └── switches.vim │ └── workingdir.vim ├── doc └── ingo-library.txt ├── ingo-library.manifest └── tests ├── EchoLine.txt ├── all.suite ├── change └── processed │ └── t1000-NetChange.vim ├── cmdargs ├── file │ ├── t1000-FilterFileOptionsAndCommands.vim │ ├── t1010-FilterFileOptionsAndCommands-side-effects.vim │ ├── t1020-FilterFileOptionsAndCommandsToEscaped.vim │ ├── t1100-FilterFileOptions.vim │ ├── t1110-FilterFileOptions-side-effects.vim │ ├── t1120-FilterFileOptionsToEscaped.vim │ ├── t1200-FileOptionsAndCommandsToEscapedExCommandLine.vim │ └── t1210-FileOptionsAndCommandsToEscapedExCommandLine-no-side-effect.vim └── register │ ├── t1000-ParsePrependedWritableRegister.vim │ └── t1100-ParseAppendedWritableRegister.vim ├── collections ├── recursive │ ├── t1000-map.vim │ └── t1010-map-simple.vim ├── t1000-SplitKeepSeparators.vim ├── t1100-SeparateItemsAndSeparators.vim ├── t1200-SplitIntoMatches.vim ├── t1210-SplitIntoMatches-allowedDiscardPattern.vim ├── t2000-SortOnOneAttribute.vim ├── t2010-PrioritySort.vim └── t2020-SortOnTwoAttributes.vim ├── compat ├── helpers │ └── CompatChecker.vim ├── substitution │ └── t1000-RecursiveSubstitutionExpression.vim ├── t1000-matchstrpos.vim ├── t1100-trim.vim ├── t1200-strcharpart.vim └── t1300-maparg.vim ├── date └── t1000-strftime.vim ├── dict ├── t1000-FromValues.vim ├── t1100-FromKeys.vim └── t1110-FromKeys-extractor.vim ├── digest ├── t1000-get.vim └── t1010-get-long.vim ├── escape └── t1000-CmdlineSpecialEscape.vim ├── file ├── ipsum.txt ├── lorem.txt ├── nulla.txt ├── t1000-GetLines-uncached.vim ├── t1010-GetLines-cached.vim ├── t1020-GetLines-cache-too-small.vim ├── t1030-GetLines-immutable-cache.vim ├── t1040-GetLines-nonexisting-file.vim └── t1050-GetLines-cache-update.vim ├── fs └── paths │ ├── split │ ├── t1000-TruncateTo.vim │ ├── t1010-TruncateTo-backslash.vim │ ├── t1020-TruncateTo-truncation-indicator.vim │ └── t1100-PathAndName.vim │ └── t1000-IsPath.vim ├── function └── uniquify │ ├── t1000-ReturnValue.vim │ ├── t1010-ReturnValue-scopes.vim │ ├── t1050-Clear.vim │ └── t1060-SetMaxAttempts.vim ├── join ├── t1000-lines-plain.ok ├── t1000-lines-plain.vim ├── t1010-lines-indented.ok ├── t1010-lines-indented.vim ├── t1015-lines-indented-nokeep.ok ├── t1015-lines-indented-nokeep.vim ├── t1020-lines-trailing.ok ├── t1020-lines-trailing.vim ├── t1025-lines-trailing-nokeep.ok ├── t1025-lines-trailing-nokeep.vim ├── t1030-lines-with-empty.ok ├── t1030-lines-with-empty.vim ├── t1035-lines-with-empty-nokeep.ok ├── t1035-lines-with-empty-nokeep.vim ├── t1040-lines-at-end.ok ├── t1040-lines-at-end.vim ├── t1045-lines-at-end-nokeep.ok ├── t1045-lines-at-end-nokeep.vim ├── t1050-lines-closing-paren.ok ├── t1050-lines-closing-paren.vim ├── t1055-lines-closing-paren-nokeep.ok ├── t1055-lines-closing-paren-nokeep.vim └── t1060-lines-return-value.vim ├── list ├── lcs │ ├── t1000-FindLongestCommon.vim │ ├── t1010-FindLongestCommon-minimumLength.vim │ ├── t1030-FindLongestCommon-ignoreCase.vim │ ├── t2000-FindAllCommon.vim │ ├── t2010-FindAllCommon-minimumCommon.vim │ ├── t2020-FindAllCommon-minimumDiffering.vim │ └── t2030-FindAllCommon-ignoreCase.vim ├── merge │ └── t1000-Distinct.vim ├── pattern │ ├── t1000-AllItemsMatch.vim │ ├── t1100-FirstMatchIndex.vim │ ├── t1110-FirstMatch.vim │ ├── t1200-AllMatchIndices.vim │ └── t1210-AllMatches.vim ├── sequence │ ├── t1000-FindNumerical.vim │ └── t1010-FindCharacter.vim ├── split │ └── t1000-RemoveFromStartWhilePredicate.vim └── t1000-AddNonEmpty.vim ├── lists └── t1000-StartsWith.vim ├── lnum └── t1000-AddOffsetWithWrapping.vim ├── matches ├── t1000-Any.vim ├── t1010-All.vim └── t2000-CountMatches.vim ├── option └── listchars │ ├── t1000-GetValue.vim │ ├── t1010-GetValues.vim │ ├── t1100-Render.vim │ ├── t1110-Render-3char-tab.vim │ ├── t1120-Render-lead.vim │ ├── t1120-Render-multibyte.vim │ ├── t1130-Render-override-listchars.vim │ └── t1140-Render-fallback.vim ├── print └── highlighted │ └── line.txt ├── range ├── merge │ ├── t1000-FromLnums.vim │ └── t1100-Merge.vim └── sort │ └── t1000-AscendingByStartLnum.vim ├── regexp ├── capture │ └── t1000-MakeCapturing.vim ├── collection │ ├── t1000-ToBranches.vim │ └── t1100-Expr.vim ├── deconstruct │ ├── t1000-RemovePositionAtoms.vim │ ├── t1100-RemoveMultis.vim │ ├── t2000-UnescapeSpecialCharacters.vim │ ├── t3000-ToQuasiLiteral.vim │ ├── t4000-TranslateCharacterClasses.vim │ ├── t4100-RemoveCharacterClasses.vim │ ├── t5000-TranslateNumberEscapes.vim │ └── t6000-TranslateBranches.vim ├── length │ ├── t1000-Project-basic.vim │ ├── t1010-Project-multis.vim │ ├── t1015-Project-multis.vim │ ├── t1020-Project-nested-branches.vim │ ├── t1030-Project-patterns.vim │ ├── t1040-Project-collection.vim │ ├── t1050-Project-global-flags.vim │ ├── t1090-Project-combinations.vim │ └── t1100-Project-invalid.vim ├── parse │ ├── t1000-MultiExpr.vim │ ├── t1100-PositionAtomExpr.vim │ ├── t1200-NumberEscapedExpr.vim │ ├── t1300-CharacterClassesExpr.vim │ ├── t1400-OptionalSequenceExpr.vim │ ├── t1500-GroupBranchExpr.vim │ ├── t1600-SingleCharacterExpr.vim │ ├── t1700-OtherAtomExpr.vim │ ├── t1800-EscapedCharacterExpr.vim │ └── t1900-NonOrdinaryAtomExpr.vim ├── split │ ├── t1000-TopLevelBranches.vim │ ├── t2000-PrefixGroupsSuffix.vim │ ├── t2090-PrefixGroupsSuffix-invalid.vim │ ├── t3000-AddPatternByProjectedMatchLength-literals.vim │ ├── t3010-AddPatternByProjectedMatchLength-minmax.vim │ ├── t3090-AddPatternByProjectedMatchLength-invalid.vim │ └── t4000-GlobalFlags.vim ├── t1000-IsValid.vim ├── t1100-EscapeLiteralReplacement.ok └── t1100-EscapeLiteralReplacement.vim ├── smartcase ├── t1000-IsSmartCasePattern.vim └── t2000-Undo.vim ├── str ├── remove │ ├── t1000-Leading.vim │ └── t1100-Trailing.vim ├── t1000-Trim.vim ├── t1010-TrimTrailing.vim └── t1100-TrimPattern.vim ├── strdisplaywidth ├── pad │ ├── t1000-Repeat.vim │ ├── t1100-RepeatExact.vim │ └── t1110-RepeatExact-filler.vim └── t1000-strleft.vim ├── subs ├── BraceCreation │ ├── t1000-BraceCreation.vim │ ├── t1010-BraceCreation-options.vim │ ├── t1020-BraceCreation-strict.vim │ └── t1030-BraceCreation-0numbers.vim └── BraceExpansion │ ├── t1000-BraceExpansion.vim │ ├── t1010-BraceExpansion-options.vim │ ├── t1020-BraceExpansion-minimal.vim │ └── t1030-BraceExpansion-sequences.vim └── subst ├── expr └── t1000-emulation.vim ├── t1000-Indexed.vim └── t2000-Recurringly.vim /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: The plugin isn't working at all or shows wrong or unexpected behavior 4 | title: '' 5 | labels: '' 6 | 7 | --- 8 | **Frequent Issues** 9 | 10 | * **Sudden problems after updating**: Did you check out the default _master_ branch? Unless you want to participate in feature development and alpha testing, I would recommend that you switch from _master_ to the _stable_ branch; this way, you'll only update to released versions that are (hopefully) better tested and documented. 11 | * **Neovim**: I don't explicitly consider nor test Neovim compatibility; my plugins are written for Vim. If a plugin can be made to work on Neovim with trivial changes, I wouldn't mind including them, but anything more involved should in my opinion be filed as a compatibility bug against Neovim (as its homepage proclaims: _Fully compatible with Vim's editing model and the Vimscript language._) 12 | 13 | **Describe the bug** 14 | 15 | _A clear and concise description of what the bug is._ 16 | 17 | **How to Reproduce** 18 | 19 | _Detailed steps to reproduce the behavior._ 20 | 21 | **Expected Behavior** 22 | 23 | _A clear and concise description of what you expected to happen._ 24 | 25 | **Environment** 26 | - Plugin version (e.g. stable version _1.10_) / revision _a1b2c3d4_ from the master branch 27 | - Vim version (e.g. _8.1.1234_) Or paste the result of `vim --version`. 28 | - OS: (e.g. _Ubuntu 18.04_, _Windows 10 1809_, _macOS 10.14_) 29 | - Install method: (e.g. manually via Vimball or ZIP file, GitHub clone as pack plugin, Plugin manager _NAME_) 30 | - Other plugins / additional context if you think this could be important 31 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an enhancement for the plugin 4 | title: '' 5 | labels: enhancement 6 | 7 | --- 8 | 9 | **Motivation** 10 | 11 | _A clear and concise description of what currently is hard to do._ 12 | 13 | **Request and Purpose** 14 | 15 | _A clear and concise description of what you want to happen. Possible fit criteria._ 16 | 17 | **Alternatives** 18 | 19 | _A clear and concise description of any alternative solutions or features you've considered._ 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.msgout 2 | *.msgresult 3 | *.out 4 | *.tap 5 | doc/*.description 6 | doc/*.install 7 | tags 8 | -------------------------------------------------------------------------------- /autoload/ingo/actions/special.vim: -------------------------------------------------------------------------------- 1 | " ingo/actions/special.vim: Action execution within special environments. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2016-2022 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | 10 | function! ingo#actions#special#NoAutoChdir( ... ) 11 | "****************************************************************************** 12 | "* PURPOSE: 13 | " Execute a:Action with :set noautochdir. 14 | "* ASSUMPTIONS / PRECONDITIONS: 15 | " None. 16 | "* EFFECTS / POSTCONDITIONS: 17 | " None. 18 | "* INPUTS: 19 | " a:Action Either a Funcref or Ex commands to be executed. 20 | " ... Arguments passed to an a:Action Funcref. 21 | "* RETURN VALUES: 22 | " Result of Funcref, or empty string in case of Ex commands. 23 | "****************************************************************************** 24 | " Unfortunately, restoring the 'autochdir' option clobbers any temporary CWD 25 | " override. So we may have to restore the CWD, too. 26 | let l:save_cwd = getcwd() 27 | let l:chdirCommand = ingo#workingdir#ChdirCommand() 28 | 29 | " The 'autochdir' option adapts the CWD, so any (relative) filepath to the 30 | " filename in the other window would be omitted. Temporarily turn this off; 31 | " may be a little bit faster, too. 32 | let l:save_autochdir = ingo#option#autochdir#Disable() 33 | try 34 | return call(function('ingo#actions#ExecuteOrFunc'), a:000) 35 | finally 36 | call ingo#option#autochdir#Restore(l:save_autochdir) 37 | if getcwd() !=# l:save_cwd 38 | execute l:chdirCommand ingo#compat#fnameescape(l:save_cwd) 39 | endif 40 | endtry 41 | endfunction 42 | 43 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 44 | -------------------------------------------------------------------------------- /autoload/ingo/area.vim: -------------------------------------------------------------------------------- 1 | " ingo/area.vim: Functions to deal with areas. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2017-2019 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | 10 | function! ingo#area#IsEmpty( area ) 11 | "****************************************************************************** 12 | "* PURPOSE: 13 | " Test whether a:area is empty (or even invalid, with the end before the 14 | " start). Does not check whether the positions actually exist in the current 15 | " buffer. 16 | "* ASSUMPTIONS / PRECONDITIONS: 17 | " None. 18 | "* EFFECTS / POSTCONDITIONS: 19 | " None. 20 | "* INPUTS: 21 | " a:area [[startLnum, startCol], [endLnum, endCol]] 22 | "* RETURN VALUES: 23 | " 1 if area is valid and covers at least one character, 0 otherwise. 24 | "****************************************************************************** 25 | if empty(a:area) 26 | return 1 27 | elseif a:area[0][0] == 0 || a:area[1][0] == 0 28 | return 1 29 | elseif a:area[0][0] > a:area[1][0] 30 | return 1 31 | elseif a:area[0][0] == a:area[1][0] && a:area[0][1] > a:area[1][1] 32 | return 1 33 | endif 34 | return 0 35 | endfunction 36 | 37 | function! ingo#area#EmptyArea( pos ) abort 38 | return [a:pos, ingo#pos#Before(a:pos)] 39 | endfunction 40 | 41 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 42 | -------------------------------------------------------------------------------- /autoload/ingo/buffer/network.vim: -------------------------------------------------------------------------------- 1 | " ingo/buffer/network.vim: Functions for loading buffers from the network. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2021 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | 10 | function! ingo#buffer#network#Read( bufferName, networkLocation ) abort 11 | "****************************************************************************** 12 | "* PURPOSE: 13 | " Load a:networkLocation into a split scratch buffer named a:bufferName. 14 | "* ASSUMPTIONS / PRECONDITIONS: 15 | " None. 16 | "* EFFECTS / POSTCONDITIONS: 17 | " - Creates scratch buffer and opens it in a split window. 18 | " - Emits a custom NetworkLocationRead User event if successful. 19 | "* INPUTS: 20 | " a:bufferName The name for the scratch buffer. If this already exists (but 21 | " isn't a scratch buffer), a different one will be generated. 22 | " a:networkLocation Network location in a format suitable for |:Nread|. 23 | "* RETURN VALUES: 24 | " 1 if successful, 0 if ingo#err#Set(). 25 | "****************************************************************************** 26 | if ! ingo#buffer#scratch#Create('', a:bufferName, 0, '1Nread ' . a:networkLocation, 'new') 27 | call ingo#err#Set('Failed to open scratch buffer for ' . a:bufferName) 28 | return 0 29 | endif 30 | 31 | call ingo#event#TriggerCustom('NetworkLocationRead') 32 | return 1 33 | endfunction 34 | 35 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 36 | -------------------------------------------------------------------------------- /autoload/ingo/buffers.vim: -------------------------------------------------------------------------------- 1 | " ingo/buffers.vim: Functions to manipulate buffers. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2021 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | 10 | function! ingo#buffers#Delete( buffersToDelete, isForce ) abort 11 | "****************************************************************************** 12 | "* PURPOSE: 13 | " Delete (:bdelete) all buffers in a:buffersToDelete, and report any 14 | " encountered errors (with the affected buffer name prepended). 15 | "* ASSUMPTIONS / PRECONDITIONS: 16 | " None. 17 | "* EFFECTS / POSTCONDITIONS: 18 | " - Buffers in a:buffersToDelete are deleted from the buffer list. 19 | "* INPUTS: 20 | " a:buffersToDelete List of buffer numbers. 21 | " a:isForce Force flag; uses :bdelete! if true. 22 | "* RETURN VALUES: 23 | " 1 if complete success, 0 if error(s) / exception(s) occurred. The last error 24 | " message is then available from ingo#err#Get(); previous errors have already 25 | " been echoed. 26 | "****************************************************************************** 27 | call ingo#err#Clear() 28 | let l:isSuccess = 1 29 | for l:bufNr in a:buffersToDelete 30 | try 31 | execute l:bufNr . 'bdelete' . (a:isForce ? '!' : '') 32 | catch /^Vim\%((\a\+)\)\=:/ 33 | let l:isSuccess = 0 34 | 35 | if ingo#err#IsSet() 36 | call ingo#msg#ErrorMsg(ingo#err#Get()) 37 | endif 38 | call ingo#err#Set(printf('%s: %s', ingo#buffer#NameOrDefault(bufname(l:bufNr)), ingo#msg#MsgFromVimException())) 39 | endtry 40 | endfor 41 | 42 | return l:isSuccess 43 | endfunction 44 | 45 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 46 | -------------------------------------------------------------------------------- /autoload/ingo/change/processed.vim: -------------------------------------------------------------------------------- 1 | " ingo/change/processed.vim: Functions for processing changes. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2020 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | 10 | function! ingo#change#processed#NetChange( ... ) abort 11 | let l:change = (a:0 ? a:1 : @.) 12 | let l:previousChange = '' 13 | while l:change !=# l:previousChange 14 | let l:previousChange = l:change 15 | let l:change = substitute(l:change, "[^\]\", '', 'g') 16 | endwhile 17 | 18 | return l:change 19 | endfunction 20 | 21 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 22 | -------------------------------------------------------------------------------- /autoload/ingo/change/virtcols.vim: -------------------------------------------------------------------------------- 1 | " ingo/change/virtcols.vim: Functions for defining the change based on virtual columns. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2019 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | 10 | function! ingo#change#virtcols#Get( ... ) abort 11 | "****************************************************************************** 12 | "* PURPOSE: 13 | " Get a selectionObject that contains information about the cell-based, 14 | " virtual screen columns that the last changed text occupies. 15 | "* ASSUMPTIONS / PRECONDITIONS: 16 | " None. 17 | "* EFFECTS / POSTCONDITIONS: 18 | " None. 19 | "* INPUTS: 20 | " a:type Optional type (e.g. from g@); "char" is converted to a mode "v", 21 | " etc. 22 | "* RETURN VALUES: 23 | " a:selection object 24 | "****************************************************************************** 25 | let l:selection = {'startLnum': line("'["), 'startVirtCol': virtcol("'["), 'endLnum': line("']"), 'endVirtCol': virtcol("']"), 'effectiveEndVirtCol': virtcol("']")} 26 | if a:0 27 | let l:selection.mode = get({'char': 'v', 'line': 'V', 'block': "\"}, a:1, a:1) 28 | endif 29 | return l:selection 30 | endfunction 31 | 32 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 33 | -------------------------------------------------------------------------------- /autoload/ingo/cmdrange.vim: -------------------------------------------------------------------------------- 1 | " ingo/cmdrange.vim: Functions for working with command ranges. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2019 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | let s:save_cpo = &cpo 10 | set cpo&vim 11 | 12 | function! ingo#cmdrange#FromCount( ... ) 13 | "****************************************************************************** 14 | "* PURPOSE: 15 | " Convert the passed a:count / v:count into a command-line range, defaulting 16 | " to the current line / a:defaultRange if count is 0. 17 | "* ASSUMPTIONS / PRECONDITIONS: 18 | " None. 19 | "* EFFECTS / POSTCONDITIONS: 20 | " None. 21 | "* INPUTS: 22 | " a:defaultRange Optional default range when count is 0. 23 | " a:count Optional given count. 24 | "* RETURN VALUES: 25 | " Command-line range to be prepended to an Ex command. 26 | "****************************************************************************** 27 | let l:defaultRange = (a:0 && a:1 isnot# '' ? a:1 : '.') 28 | let l:count = (a:0 >= 2 ? a:2 : v:count) 29 | return (l:count ? 30 | \ (l:count == 1 ? '.' : '.,.+' . (l:count - 1)) : 31 | \ l:defaultRange 32 | \) 33 | endfunction 34 | 35 | let &cpo = s:save_cpo 36 | unlet s:save_cpo 37 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 38 | -------------------------------------------------------------------------------- /autoload/ingo/collections/permute.vim: -------------------------------------------------------------------------------- 1 | " ingo/collections/permute.vim: Functions to permute a List. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2014 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | " 10 | " REVISION DATE REMARKS 11 | " 1.021.001 27-Jun-2014 file creation 12 | 13 | function! ingo#collections#permute#Shuffle( list, Rand ) 14 | " Fisher-Yates shuffle 15 | let [l:list, l:len] = [a:list, len(a:list)] 16 | 17 | let i = l:len 18 | while i > 0 19 | let i -= 1 20 | let j = a:Rand() * i % l:len 21 | if i == j 22 | continue 23 | endif 24 | let l:swap = l:list[i] 25 | let l:list[i] = list[j] 26 | let l:list[j] = l:swap 27 | endwhile 28 | 29 | return l:list 30 | endfunction 31 | 32 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 33 | -------------------------------------------------------------------------------- /autoload/ingo/collections/recursive.vim: -------------------------------------------------------------------------------- 1 | " ingo/collections/recursive.vim: Recursively map a data structure. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2019 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | 10 | function! ingo#collections#recursive#map( expr1, expr2 ) 11 | return s:Map(0, a:expr1, a:expr2) 12 | endfunction 13 | function! ingo#collections#recursive#MapWithCopy( expr1, expr2 ) 14 | return s:Map(1, copy(a:expr1), a:expr2) 15 | endfunction 16 | function! s:Map( isCopy, expr1, expr2 ) 17 | return map(a:expr1, 's:RecursiveMap(a:isCopy, v:val, a:expr2)') 18 | endfunction 19 | function! s:RecursiveMap( isCopy, value, expr2 ) 20 | let l:value = (a:isCopy ? copy(a:value) : a:value) 21 | 22 | if type(a:value) == type([]) || type(a:value) == type({}) 23 | return s:Map(a:isCopy, l:value, a:expr2) 24 | else 25 | return map([l:value], a:expr2)[0] 26 | endif 27 | endfunction 28 | 29 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 30 | -------------------------------------------------------------------------------- /autoload/ingo/collections/rotate.vim: -------------------------------------------------------------------------------- 1 | " ingo/collections/rotate.vim: Functions to rotate items in a List. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2013 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | " 10 | " REVISION DATE REMARKS 11 | " 1.006.001 25-May-2013 file creation 12 | 13 | function! ingo#collections#rotate#Right( list ) 14 | return insert(a:list, remove(a:list, -1)) 15 | endfunction 16 | function! ingo#collections#rotate#Left( list ) 17 | return add(a:list, remove(a:list, 0)) 18 | endfunction 19 | 20 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 21 | -------------------------------------------------------------------------------- /autoload/ingo/compat/command.vim: -------------------------------------------------------------------------------- 1 | " ingo/compat/command.vim: Compatibility functions for commands. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2017-2019 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | " 10 | " REVISION DATE REMARKS 11 | " 1.030.001 20-Feb-2017 file creation 12 | 13 | function! ingo#compat#command#Mods( mods ) 14 | "****************************************************************************** 15 | "* PURPOSE: 16 | " Return the command modifiers || passed in raw as a:mods. 17 | " In order to support older Vim versions that don't have this (prior to 18 | " Vim 7.4.1898), one cannot use ; this isn't understood and raises an 19 | " error. Instead, we can benefit from the fact that the modifiers do not 20 | " contain special characters, and do the quoting ourselves: ''. Now we 21 | " only need to remove the identifer in case it hasn't been understood, and 22 | " this is what this function is about. 23 | " -command! Sedit call SpecialEdit() 24 | " +command! Sedit call SpecialEdit(ingo#compat#command#Mods('')) 25 | "* ASSUMPTIONS / PRECONDITIONS: 26 | " None. 27 | "* EFFECTS / POSTCONDITIONS: 28 | " None. 29 | "* INPUTS: 30 | " '' 31 | "* RETURN VALUES: 32 | " Usable modifiers. 33 | "****************************************************************************** 34 | return (a:mods ==# '' ? '' : a:mods) 35 | endfunction 36 | 37 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 38 | -------------------------------------------------------------------------------- /autoload/ingo/compat/regexp.vim: -------------------------------------------------------------------------------- 1 | " ingo/compat/regexp.vim: Functions for regular expression compatibility. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2015 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | " 10 | " REVISION DATE REMARKS 11 | " 1.024.001 20-Feb-2015 file creation 12 | 13 | if exists('+regexpengine') " {{{2 14 | " XXX: The new NFA-based regexp engine has a problem with non-greedy \s\{-} 15 | " match together with the branches where only one is anchored; cp. 16 | " http://article.gmane.org/gmane.editors.vim.devel/43712 17 | " XXX: The new NFA-based regexp engine has a problem with the /\@<= pattern 18 | " in combination with a back reference \1; cp. 19 | " http://article.gmane.org/gmane.editors.vim.devel/46596 20 | function! ingo#compat#regexp#GetOldEnginePrefix() 21 | return '\%#=1' 22 | endfunction 23 | else 24 | function! ingo#compat#regexp#GetOldEnginePrefix() 25 | return '' 26 | endfunction 27 | endif 28 | 29 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 30 | -------------------------------------------------------------------------------- /autoload/ingo/compat/window.vim: -------------------------------------------------------------------------------- 1 | " ingo/compat/window.vim: Compatibility functions for windows. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2016 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | " 10 | " REVISION DATE REMARKS 11 | " 1.028.001 10-Oct-2016 file creation 12 | 13 | if exists('*getcmdwintype') 14 | function! ingo#compat#window#IsCmdlineWindow() 15 | return ! empty(getcmdwintype()) 16 | endfunction 17 | elseif v:version >= 702 18 | function! ingo#compat#window#IsCmdlineWindow() 19 | return bufname('') ==# '[Command Line]' 20 | endfunction 21 | else 22 | function! ingo#compat#window#IsCmdlineWindow() 23 | return bufname('') ==# 'command-line' 24 | endfunction 25 | endif 26 | 27 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 28 | -------------------------------------------------------------------------------- /autoload/ingo/convert.vim: -------------------------------------------------------------------------------- 1 | " ingo/convert.vim: Functions for type conversions. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2022 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | 10 | function! ingo#convert#ToSingleLineString( expr ) abort 11 | "****************************************************************************** 12 | "* PURPOSE: 13 | " Convert a:expr to a String that does not contain newline characters, but the 14 | " "\n" notation instead. 15 | "* ASSUMPTIONS / PRECONDITIONS: 16 | " None. 17 | "* EFFECTS / POSTCONDITIONS: 18 | " None. 19 | "* INPUTS: 20 | " a:expr Variable (of arbitrary type, but likely String). 21 | "* RETURN VALUES: 22 | " String. 23 | "****************************************************************************** 24 | return substitute(string(a:expr), '\n', "'.\"\\\\n\".'", 'g') 25 | endfunction 26 | 27 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 28 | -------------------------------------------------------------------------------- /autoload/ingo/dict/count.vim: -------------------------------------------------------------------------------- 1 | " ingo/dict/count.vim: Functions for counting with Dictionaries. 2 | " 3 | " DEPENDENCIES: 4 | " - ingo/collections.vim autoload script 5 | " - ingo/dict.vim autoload script 6 | " 7 | " Copyright: (C) 2017 Ingo Karkat 8 | " The VIM LICENSE applies to this script; see ':help copyright'. 9 | " 10 | " Maintainer: Ingo Karkat 11 | " 12 | " REVISION DATE REMARKS 13 | " 001 24-May-2017 file creation 14 | 15 | function! ingo#dict#count#Items( dict, items, ... ) 16 | "****************************************************************************** 17 | "* PURPOSE: 18 | " For each item in a:items, create a key with count 1 / increment the value of 19 | " an existing key in a:dict. 20 | "* ASSUMPTIONS / PRECONDITIONS: 21 | " None. 22 | "* EFFECTS / POSTCONDITIONS: 23 | " None. 24 | "* INPUTS: 25 | " a:dict Dictionary that holds the items -> counts. Need not be empty. 26 | " a:items List of items to be counted. 27 | " a:emptyValue Optional value for items in a:list that yield an empty 28 | " string, which (in Vim versions prior to 7.4.1707) cannot be 29 | " used as a Dictionary key. 30 | " If omitted, empty values are not included in the Dictionary. 31 | "* RETURN VALUES: 32 | " a:dict 33 | "* SEE ALSO: 34 | " ingo#collections#ToDict() does not count, just uses a hard-coded value 35 | " ingo#dict#FromKeys() also does not count but allows to specify a default value 36 | "****************************************************************************** 37 | for l:item in a:items 38 | if l:item ==# '' 39 | if a:0 40 | let l:item = a:1 41 | else 42 | continue 43 | endif 44 | endif 45 | 46 | if has_key(a:dict, l:item) 47 | let a:dict[l:item] += 1 48 | else 49 | let a:dict[l:item] = 1 50 | endif 51 | endfor 52 | return a:dict 53 | endfunction 54 | 55 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 56 | -------------------------------------------------------------------------------- /autoload/ingo/digraph.vim: -------------------------------------------------------------------------------- 1 | " ingo/digraph.vim: Functions around digraphs. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2022 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | 10 | " Source: http://stackoverflow.com/a/18726519/813602 11 | " Source: unicode#Digraph(char) in https://github.com/chrisbra/unicode.vim/blob/eddd9791c226a211fc3e433d5ecccb836364dd86/autoload/unicode.vim#L85 12 | function! ingo#digraph#Get( char, ... ) abort 13 | "****************************************************************************** 14 | "* PURPOSE: 15 | " Obtain the digraph expansion of a:char. 16 | "* ASSUMPTIONS / PRECONDITIONS: 17 | " None. 18 | "* EFFECTS / POSTCONDITIONS: 19 | " None. 20 | "* INPUTS: 21 | " a:char First char or two-char combination. 22 | " a:char2 Second char (optional). 23 | "* RETURN VALUES: 24 | " Digraph or fallback; i.e. exactly what would be returned by typing CTRL-K + 25 | " a:char + a:char2 26 | "****************************************************************************** 27 | let s:digraph = '' 28 | execute 'silent normal!' ":\" . a:char . join(a:000, '') . "\eextend(s:, {'digraph': getcmdline()}).digraph\n" 29 | return s:digraph 30 | endfunction 31 | 32 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 33 | -------------------------------------------------------------------------------- /autoload/ingo/encoding.vim: -------------------------------------------------------------------------------- 1 | " ingo/encoding.vim: Functions for dealing with character encodings. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2015-2021 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | " 10 | " REVISION DATE REMARKS 11 | " 1.024.001 20-Feb-2015 file creation 12 | 13 | function! ingo#encoding#GetFileEncoding() abort 14 | return (empty(&l:fileencoding) ? &encoding : &l:fileencoding) 15 | endfunction 16 | 17 | function! ingo#encoding#IsUnicode() abort 18 | return (ingo#encoding#GetFileEncoding() ==# 'utf-8') 19 | endfunction 20 | 21 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 22 | -------------------------------------------------------------------------------- /autoload/ingo/escape/mapping.vim: -------------------------------------------------------------------------------- 1 | " ingo/escape/mapping.vim: Additional escapings of mappings. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2021-2022 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | 10 | function! ingo#escape#mapping#keys( keys ) abort 11 | "****************************************************************************** 12 | "* PURPOSE: 13 | " Escape a:keys for use in the left-hand side of a mapping. 14 | "* SEE ALSO: 15 | " - ingo#escape#command#mapescape() for the right-hand side. 16 | "* ASSUMPTIONS / PRECONDITIONS: 17 | " None. 18 | "* EFFECTS / POSTCONDITIONS: 19 | " None. 20 | "* INPUTS: 21 | " a:keys Mapping keys. 22 | "* RETURN VALUES: 23 | " a:keys for use in a :map command. 24 | "****************************************************************************** 25 | let l:keys = a:keys 26 | let l:keys = substitute(l:keys, ' ', '', 'g') 27 | let l:keys = substitute(l:keys, "\n", '', 'g') 28 | let l:keys = substitute(l:keys, '\', '', 'g') 29 | let l:keys = substitute(l:keys, '|', '', 'g') 30 | return l:keys 31 | endfunction 32 | 33 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 34 | -------------------------------------------------------------------------------- /autoload/ingo/escape/shellcommand.vim: -------------------------------------------------------------------------------- 1 | " ingo/escape/shellcommand.vim: Additional escapings of shell commands. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2013-2014 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | " 10 | " REVISION DATE REMARKS 11 | " 1.016.003 21-Jan-2014 Move ingo#escape#shellcommand#shellcmdescape() 12 | " to ingo#compat#shellcommand#escape(), as it is 13 | " only required for older Vim versions. 14 | " 1.012.002 09-Aug-2013 Rename file. 15 | " 001 08-Aug-2013 file creation from escapings.vim. 16 | 17 | function! ingo#escape#shellcommand#exescape( command ) 18 | "******************************************************************************* 19 | "* PURPOSE: 20 | " Escape a shell command (potentially consisting of multiple commands and 21 | " including (already quoted) command-line arguments) so that it can be used in 22 | " Ex commands. For example: 'hostname && ps -ef | grep -e "foo"'. 23 | " 24 | "* ASSUMPTIONS / PRECONDITIONS: 25 | " ? List of any external variable, control, or other element whose state affects this procedure. 26 | "* EFFECTS / POSTCONDITIONS: 27 | " ? List of the procedure's effect on each external variable, control, or other element. 28 | "* INPUTS: 29 | " a:command Shell command-line. 30 | " 31 | "* RETURN VALUES: 32 | " Escaped shell command to be passed to the !{cmd} or :r !{cmd} commands. 33 | "******************************************************************************* 34 | if exists('*fnameescape') 35 | return join(map(split(a:command, ' '), 'fnameescape(v:val)'), ' ') 36 | else 37 | return escape(a:command, '\%#|' ) 38 | endif 39 | endfunction 40 | 41 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 42 | -------------------------------------------------------------------------------- /autoload/ingo/event.vim: -------------------------------------------------------------------------------- 1 | " ingo/event.vim: Functions for triggering events. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2015-2017 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | 10 | if v:version == 703 && has('patch438') || v:version > 703 11 | function! ingo#event#Trigger( arguments ) 12 | execute 'doautocmd ' a:arguments 13 | endfunction 14 | function! ingo#event#TriggerEverywhere( arguments ) 15 | execute 'doautoall ' a:arguments 16 | endfunction 17 | else 18 | function! ingo#event#Trigger( arguments ) 19 | let l:save_modeline = &l:modeline 20 | setlocal nomodeline 21 | try 22 | execute 'doautocmd ' a:arguments 23 | finally 24 | let &l:modeline = l:save_modeline 25 | endtry 26 | endfunction 27 | function! ingo#event#TriggerEverywhere( arguments ) 28 | let l:save_modeline = &l:modeline 29 | setlocal nomodeline 30 | try 31 | execute 'doautoall ' a:arguments 32 | finally 33 | let &l:modeline = l:save_modeline 34 | endtry 35 | endfunction 36 | endif 37 | 38 | function! ingo#event#TriggerCustom( eventName ) 39 | silent call ingo#event#Trigger('User ' . a:eventName) 40 | endfunction 41 | function! ingo#event#TriggerEverywhereCustom( eventName ) 42 | silent call ingo#event#TriggerEverywhere('User ' . a:eventName) 43 | endfunction 44 | 45 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 46 | -------------------------------------------------------------------------------- /autoload/ingo/external.vim: -------------------------------------------------------------------------------- 1 | " ingo/external.vim: Functions to launch an external Vim instance. 2 | " 3 | " DEPENDENCIES: 4 | " - ingo/compat.vim autoload script 5 | " - ingo/os.vim autoload script 6 | " 7 | " Copyright: (C) 2013 Ingo Karkat 8 | " The VIM LICENSE applies to this script; see ':help copyright'. 9 | " 10 | " Maintainer: Ingo Karkat 11 | " 12 | " REVISION DATE REMARKS 13 | " 1.013.005 13-Sep-2013 Use operating system detection functions from 14 | " ingo/os.vim. 15 | " 1.012.004 08-Aug-2013 Move escapings.vim into ingo-library. 16 | " 1.004.003 09-Apr-2013 FIX: "E117: Unknown function: s:externalLaunch". 17 | " 1.002.002 25-Feb-2013 ENH: Allow to specify filespec of GVIM 18 | " executable. 19 | " 1.000.001 28-Jan-2013 file creation from DropQuery.vim 20 | 21 | let s:externalLaunch = (ingo#os#IsWindows() ? 'silent !start' : 'silent !') 22 | function! ingo#external#LaunchGvim( commands, ... ) 23 | execute s:externalLaunch . ' ' . (a:0 ? a:1 : 'gvim') join(map(a:commands, '"-c " . ingo#compat#shellescape(v:val, 1)')) 24 | endfunction 25 | 26 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 27 | -------------------------------------------------------------------------------- /autoload/ingo/filetype.vim: -------------------------------------------------------------------------------- 1 | " ingo/filetype.vim: Functions for the buffer's filetype(s). 2 | " 3 | " DEPENDENCIES: 4 | " - ingo/list.vim autoload script 5 | 6 | " Copyright: (C) 2012-2017 Ingo Karkat 7 | " The VIM LICENSE applies to this script; see ':help copyright'. 8 | " 9 | " Maintainer: Ingo Karkat 10 | 11 | function! ingo#filetype#Is( filetypes ) 12 | for l:ft in split(&filetype, '\.') 13 | if (index(ingo#list#Make(a:filetypes), l:ft) != -1) 14 | return 1 15 | endif 16 | endfor 17 | 18 | return 0 19 | endfunction 20 | 21 | function! ingo#filetype#GetPrimary( ... ) 22 | return get(split((a:0 ? a:1 : &filetype), '\.'), 0, '') 23 | endfunction 24 | function! ingo#filetype#IsPrimary( filetypes ) 25 | return (index(ingo#list#Make(a:filetypes), ingo#filetype#GetPrimary()) != -1) 26 | endfunction 27 | 28 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 29 | -------------------------------------------------------------------------------- /autoload/ingo/folds/persistence.vim: -------------------------------------------------------------------------------- 1 | " ingo/folds/persistence.vim: Functions to persist and restore manual folds. 2 | " 3 | " DEPENDENCIES: 4 | " - ingo/compat.vim autoload script 5 | " 6 | " Copyright: (C) 2015 Ingo Karkat 7 | " The VIM LICENSE applies to this script; see ':help copyright'. 8 | " 9 | " Maintainer: Ingo Karkat 10 | " 11 | " REVISION DATE REMARKS 12 | " 1.023.001 01-Jan-2015 file creation 13 | 14 | function! ingo#folds#persistence#SaveManualFolds() 15 | if &foldmethod !=# 'manual' 16 | return '' 17 | endif 18 | 19 | let l:filespec = tempname() 20 | let l:save_viewoptions = &viewoptions 21 | set viewoptions=folds 22 | try 23 | execute 'mkview' ingo#compat#fnameescape(l:filespec) 24 | return l:filespec 25 | finally 26 | let &viewoptions = l:save_viewoptions 27 | endtry 28 | 29 | return '' 30 | endfunction 31 | function! ingo#folds#persistence#RestoreManualFolds( handle ) 32 | if empty(a:handle) 33 | return 34 | endif 35 | 36 | silent! execute 'source' ingo#compat#fnameescape(a:handle) 37 | endfunction 38 | 39 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 40 | -------------------------------------------------------------------------------- /autoload/ingo/foldtext.vim: -------------------------------------------------------------------------------- 1 | " ingo/foldtext.vim: Functions for creating a custom foldtext. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2013 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | " 10 | " REVISION DATE REMARKS 11 | " 1.014.001 19-Sep-2013 file creation 12 | 13 | function! ingo#foldtext#DefaultPrefix( text ) 14 | let l:num = v:foldend - v:foldstart + 1 15 | return printf("+-%s %2d line%s%s%s", v:folddashes, l:num, (l:num == 1 ? '' : 's'), (empty(a:text) ? '' : ': '), a:text) 16 | endfunction 17 | 18 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 19 | -------------------------------------------------------------------------------- /autoload/ingo/ftplugin/setting.vim: -------------------------------------------------------------------------------- 1 | " ingo/ftplugin/setting.vim: Functions for filetype plugin settings in a buffer-local Dict. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2018 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | 10 | function! s:GetOption( variableName ) 11 | return 'b:' . a:variableName 12 | endfunction 13 | 14 | function! ingo#ftplugin#setting#Get( variableName, key, default ) 15 | let l:option = s:GetOption(a:variableName) 16 | if ! exists(l:option) 17 | return a:default 18 | endif 19 | execute 'return get(' . l:option . ', a:key, a:default)' 20 | endfunction 21 | 22 | function! ingo#ftplugin#setting#Set( variableName, key, value ) 23 | let l:option = s:GetOption(a:variableName) 24 | if ! exists(l:option) 25 | execute 'let' l:option '= {}' 26 | endif 27 | 28 | execute 'let' l:option . '[a:key] = a:value' 29 | endfunction 30 | 31 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 32 | -------------------------------------------------------------------------------- /autoload/ingo/funcref.vim: -------------------------------------------------------------------------------- 1 | " ingo/funcref.vim: Functions for handling Funcrefs. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2013-2019 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | 10 | function! ingo#funcref#UnaryIdentity( value ) abort 11 | return a:value 12 | endfunction 13 | 14 | function! ingo#funcref#ToString( Funcref ) 15 | let l:functionName = matchstr(string(a:Funcref), "^function('\\zs.*\\ze')$") 16 | return (empty(l:functionName) ? '' . a:Funcref : l:functionName) 17 | endfunction 18 | 19 | function! ingo#funcref#AsString( Funcref ) 20 | return (type(a:Funcref) == 2 ? string(a:Funcref) : a:Funcref) 21 | endfunction 22 | 23 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 24 | -------------------------------------------------------------------------------- /autoload/ingo/gui/position.vim: -------------------------------------------------------------------------------- 1 | " ingo/gui/position.vim: Functions for the GVIM position and size. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2013-2023 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | 10 | if exists('*getwinpos') 11 | function! ingo#gui#position#Get() abort 12 | return [&columns, &lines] + getwinpos() 13 | endfunction 14 | else 15 | function! ingo#gui#position#Get() abort 16 | redir => l:winpos 17 | silent! winpos 18 | redir END 19 | return [&columns, &lines, str2nr(matchstr(l:winpos, '\CX \zs-\?\d\+')), str2nr(matchstr(l:winpos, '\CY \zs-\?\d\+'))] 20 | endfunction 21 | endif 22 | 23 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 24 | -------------------------------------------------------------------------------- /autoload/ingo/indent.vim: -------------------------------------------------------------------------------- 1 | " ingo/indent.vim: Functions for working with indent. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2016 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | " 10 | " REVISION DATE REMARKS 11 | " 1.029.002 02-Dec-2016 Add ingo#indent#Split(), a simpler version of 12 | " ingo#comments#SplitIndentAndText(). 13 | " 1.028.001 25-Nov-2016 file creation 14 | 15 | function! ingo#indent#RangeSeveralTimes( firstLnum, lastLnum, command, times ) 16 | for l:i in range(a:times) 17 | silent execute a:firstLnum . ',' . a:lastLnum . a:command 18 | endfor 19 | endfunction 20 | 21 | function! ingo#indent#GetIndent( lnum ) 22 | return matchstr(getline(a:lnum), '^\s*') 23 | endfunction 24 | function! ingo#indent#GetIndentLevel( lnum ) 25 | return indent(a:lnum) / &l:shiftwidth 26 | endfunction 27 | function! ingo#indent#Split( lnum ) 28 | "****************************************************************************** 29 | "* PURPOSE: 30 | " Split the line into any leading indent, and the text after it. 31 | "* SEE ALSO: 32 | " ingo#comments#SplitIndentAndText() also considers any comment prefix as part 33 | " of the indent. 34 | "* ASSUMPTIONS / PRECONDITIONS: 35 | " None. 36 | "* EFFECTS / POSTCONDITIONS: 37 | " None. 38 | "* INPUTS: 39 | " a:lnum Number of the line to be split. 40 | "* RETURN VALUES: 41 | " Returns [a:indent, a:text]. 42 | "****************************************************************************** 43 | return matchlist(getline(a:lnum), '^\(\s*\)\(.*\)$')[1:2] 44 | endfunction 45 | 46 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 47 | -------------------------------------------------------------------------------- /autoload/ingo/line/replace.vim: -------------------------------------------------------------------------------- 1 | " ingo/line/replace.vim: Functions to replace text in a single line. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2016 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | " 10 | " REVISION DATE REMARKS 11 | " 1.029.001 22-Dec-2016 file creation 12 | 13 | function! ingo#line#replace#Substitute( lnum, pat, sub, flags ) 14 | "****************************************************************************** 15 | "* PURPOSE: 16 | " Substitute a pattern in a single line in the current buffer. Low-level 17 | " alternative to :substitute without the need to suppress messages, undo 18 | " search history clobbering, cursor move. 19 | "* SEE ALSO: 20 | " - ingo#lines#replace#Substitute() handles multiple lines, but is more 21 | " costly. 22 | "* ASSUMPTIONS / PRECONDITIONS: 23 | " Does not handle inserted newlines; i.e. no additional lines will be created, 24 | " the newline will be persisted as-is (^@). 25 | "* EFFECTS / POSTCONDITIONS: 26 | " Updates a:lnum. 27 | "* INPUTS: 28 | " a:lnum Existing line number. 29 | " a:pat Regular expression to match. 30 | " a:sub Replacement string. 31 | " a:flags "g" for global replacement. 32 | "* RETURN VALUES: 33 | " If this succeeds, 0 is returned. If this fails (most likely because a:lnum is 34 | " invalid) 1 is returned. 35 | "****************************************************************************** 36 | return setline(a:lnum, substitute(getline(a:lnum), a:pat, a:sub, a:flags)) 37 | endfunction 38 | 39 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 40 | -------------------------------------------------------------------------------- /autoload/ingo/lines/empty.vim: -------------------------------------------------------------------------------- 1 | " ingo/lines/empty.vim: Functions to search for empty lines. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2017 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | 10 | function! ingo#lines#empty#IsEmptyLine( lnum ) 11 | return empty(getline(a:lnum)) 12 | endfunction 13 | function! ingo#lines#empty#IsEmptyLines( lnum1, lnum2 ) 14 | return len(filter(getline(a:lnum1, a:lnum2), '! empty(v:val)')) == 0 15 | endfunction 16 | 17 | function! ingo#lines#empty#GetNextNonEmptyLnum( lnum ) 18 | let l:lnum = (a:lnum < 0 ? line('$') + a:lnum + 2 : a:lnum) + 1 19 | while l:lnum <= line('$') 20 | if ingo#lines#empty#IsEmptyLine(l:lnum) 21 | let l:lnum += 1 22 | else 23 | return l:lnum 24 | endif 25 | endwhile 26 | return 0 27 | endfunction 28 | function! ingo#lines#empty#GetPreviousNonEmptyLnum( lnum ) 29 | let l:lnum = (a:lnum < 0 ? line('$') + a:lnum + 2 : a:lnum) - 1 30 | while l:lnum >= 1 31 | if ingo#lines#empty#IsEmptyLine(l:lnum) 32 | let l:lnum -= 1 33 | else 34 | return l:lnum 35 | endif 36 | endwhile 37 | return 0 38 | endfunction 39 | 40 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 41 | -------------------------------------------------------------------------------- /autoload/ingo/list/merge.vim: -------------------------------------------------------------------------------- 1 | " ingo/list/merge.vim: Functions for merging lists. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2020 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | let s:save_cpo = &cpo 10 | set cpo&vim 11 | 12 | function! ingo#list#merge#Distinct( ... ) abort 13 | "****************************************************************************** 14 | "* PURPOSE: 15 | " From several Lists where there's only one non-empty value at each index 16 | " position, create a combined list taking that non-empty value from each index 17 | " position (or the empty value from the first list). 18 | "* ASSUMPTIONS / PRECONDITIONS: 19 | " None. 20 | "* EFFECTS / POSTCONDITIONS: 21 | " None. 22 | "* INPUTS: 23 | " a:list1, a:list2 24 | "* RETURN VALUES: 25 | " Combined List with as many elements as the longest passed List. 26 | " Throws "Distinct: Multiple non-empty values at index N" 27 | "****************************************************************************** 28 | let l:result = [] 29 | for l:i in range(max(map(copy(a:000), 'len(v:val)'))) 30 | let l:nonEmptyIndexValues = filter( 31 | \ map(range(a:0), 'get(a:000[v:val], l:i, "")'), 32 | \ '! empty(v:val)' 33 | \) 34 | if len(l:nonEmptyIndexValues) > 1 35 | throw 'Distinct: Multiple non-empty values at index ' . l:i 36 | endif 37 | call add(l:result, (empty(l:nonEmptyIndexValues) ? 38 | \ map(range(a:0), 'len(a:000[v:val]) >= l:i ? a:000[v:val][l:i] : ""')[0] : 39 | \ l:nonEmptyIndexValues[0] 40 | \)) 41 | endfor 42 | return l:result 43 | endfunction 44 | 45 | let &cpo = s:save_cpo 46 | unlet s:save_cpo 47 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 48 | -------------------------------------------------------------------------------- /autoload/ingo/list/reduce.vim: -------------------------------------------------------------------------------- 1 | " ingo/list/reduce.vim: Functions for reducing lists to single scalar values. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2021 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | 10 | function! ingo#list#reduce#Sum( list ) abort 11 | return ingo#collections#Reduce(a:list, 'v:val[0] + v:val[1]', 0) 12 | endfunction 13 | 14 | function! ingo#list#reduce#Product( list ) abort 15 | return ingo#collections#Reduce(a:list, 'v:val[0] * v:val[1]', 1) 16 | endfunction 17 | 18 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 19 | -------------------------------------------------------------------------------- /autoload/ingo/list/transform.vim: -------------------------------------------------------------------------------- 1 | " ingo/list/transform.vim: Functions to transform list elements. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2021 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | 10 | function! ingo#list#transform#str2nr( list, ... ) abort 11 | "****************************************************************************** 12 | "* PURPOSE: 13 | " Convert elements of a:list to numbers (replacing the original items). 14 | "* ASSUMPTIONS / PRECONDITIONS: 15 | " None. 16 | "* EFFECTS / POSTCONDITIONS: 17 | " None. 18 | "* INPUTS: 19 | " a:list Source list. 20 | " a:base Optional conversion base. 21 | " a:quoted Flag whether embedded single quotes are ignored. 22 | "* RETURN VALUES: 23 | " The modified a:list. 24 | "****************************************************************************** 25 | if a:0 > 0 26 | return map(a:list, 'call("str2nr", [v:val] + a:000)') 27 | else 28 | return map(a:list, 'str2nr(v:val)') 29 | endif 30 | endfunction 31 | 32 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 33 | -------------------------------------------------------------------------------- /autoload/ingo/lists.vim: -------------------------------------------------------------------------------- 1 | " ingo/lists.vim: Functions to compare Lists. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2018 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | 10 | function! ingo#lists#StartsWith( list, sublist, ... ) 11 | if len(a:list) < len(a:sublist) 12 | return 0 13 | elseif len(a:sublist) == 0 14 | return 1 15 | endif 16 | 17 | let l:ignorecase = (a:0 && a:1) 18 | if l:ignorecase 19 | return (a:list[0 : len(a:sublist) - 1] ==? a:sublist) 20 | else 21 | return (a:list[0 : len(a:sublist) - 1] ==# a:sublist) 22 | endif 23 | endfunction 24 | 25 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 26 | -------------------------------------------------------------------------------- /autoload/ingo/lists/find.vim: -------------------------------------------------------------------------------- 1 | " ingo/lists/find.vim: Functions for comparing Lists. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2018 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | 10 | function! ingo#lists#find#FirstDifferent( list1, list2 ) 11 | "****************************************************************************** 12 | "* PURPOSE: 13 | " Compare elements in a:list1 and a:list2 and return the index of the first 14 | " elements that are not equal. 15 | "* ASSUMPTIONS / PRECONDITIONS: 16 | " None. 17 | "* EFFECTS / POSTCONDITIONS: 18 | " None. 19 | "* INPUTS: 20 | " a:list1 A list. 21 | " a:list2 Another list. 22 | "* RETURN VALUES: 23 | " Index of the first element not equal / not existing in one of the lists. 24 | " -1 if both lists are identical; i.e. have the same number of elements and 25 | " all elements are equal.. 26 | "****************************************************************************** 27 | let l:i = 0 28 | while l:i < len(a:list1) 29 | if l:i >= len(a:list2) 30 | return l:i 31 | elseif a:list1[l:i] != a:list2[l:i] 32 | return l:i 33 | endif 34 | 35 | let l:i += 1 36 | endwhile 37 | return -1 38 | endfunction 39 | 40 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 41 | -------------------------------------------------------------------------------- /autoload/ingo/lnum.vim: -------------------------------------------------------------------------------- 1 | " ingo/lnum.vim: Functions to work with line numbers. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2018 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | 10 | function! ingo#lnum#AddOffsetWithWrapping( lnum, offset, ... ) 11 | "****************************************************************************** 12 | "* PURPOSE: 13 | " Add a:offset to a:lnum; if the result is less than 1 or larger than 14 | " a:maxLnum, wrap around. 15 | "* ASSUMPTIONS / PRECONDITIONS: 16 | " None. 17 | "* EFFECTS / POSTCONDITIONS: 18 | " None. 19 | "* INPUTS: 20 | " a:lnum Source line number. 21 | " a:offset Positive or negative offset to apply to a:lnum. 22 | " a:maxLnum Maximum allowed line number; defaults to line('$'), the last 23 | " line of the current buffer. 24 | "* RETURN VALUES: 25 | " 1 <= result <= a:maxLnum 26 | "****************************************************************************** 27 | let l:lnum = a:lnum + a:offset 28 | let l:maxLnum = (a:0 ? a:1 : line('$')) 29 | 30 | if l:lnum < 1 31 | return l:maxLnum + l:lnum % l:maxLnum 32 | elseif l:lnum > l:maxLnum 33 | return l:lnum % l:maxLnum 34 | else 35 | return l:lnum 36 | endif 37 | endfunction 38 | 39 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 40 | -------------------------------------------------------------------------------- /autoload/ingo/math.vim: -------------------------------------------------------------------------------- 1 | " ingo/math.vim: Mathematical functions. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2016 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | " 10 | " REVISION DATE REMARKS 11 | " 1.029.001 27-Dec-2016 file creation 12 | 13 | "****************************************************************************** 14 | "* PURPOSE: 15 | " Return the power of a:x to the exponent a:y as a Number. 16 | "* ASSUMPTIONS / PRECONDITIONS: 17 | " None. 18 | "* EFFECTS / POSTCONDITIONS: 19 | " None. 20 | "* INPUTS: 21 | " a:x Number. 22 | " a:y Exponent. 23 | "* RETURN VALUES: 24 | " Number. 25 | "****************************************************************************** 26 | if exists('*pow') 27 | function! ingo#math#PowNr( x, y ) 28 | return float2nr(pow(a:x, a:y)) 29 | endfunction 30 | else 31 | function! ingo#math#PowNr( x, y ) 32 | let l:r = a:x 33 | for l:i in range(a:y - 1) 34 | let l:r = l:r * a:x 35 | endfor 36 | return l:r 37 | endfunction 38 | endif 39 | 40 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 41 | -------------------------------------------------------------------------------- /autoload/ingo/motion/omap.vim: -------------------------------------------------------------------------------- 1 | " ingo/motion/omap.vim: Helper function to repeat special operator-pending mappings. 2 | " 3 | " DEPENDENCIES: 4 | " - repeat.vim (vimscript #2136) autoload script (optional) 5 | " 6 | " Copyright: (C) 2014 Ingo Karkat 7 | " The VIM LICENSE applies to this script; see ':help copyright'. 8 | " 9 | " Maintainer: Ingo Karkat 10 | " 11 | " REVISION DATE REMARKS 12 | " 1.016.001 15-Jan-2014 file creation 13 | let s:save_cpo = &cpo 14 | set cpo&vim 15 | 16 | function! ingo#motion#omap#repeat( repeatMapping, operator, count ) 17 | if a:operator ==# 'y' && &cpoptions !~# 'y' 18 | " A yank usually doesn't repeat. 19 | return 20 | endif 21 | 22 | silent! call repeat#set(a:operator . a:repeatMapping . 23 | \ (a:operator ==# 'c' ? "\(IngoLibraryOmapRepeatReinsert)" : ''), 24 | \ a:count 25 | \) 26 | endfunction 27 | 28 | " This is for the special repeat of a "c" command, to insert the last entered 29 | " text and leave insert mode. We define a :noremap so that any user mappings do 30 | " not affect this. 31 | inoremap (IngoLibraryOmapRepeatReinsert) . 32 | 33 | let &cpo = s:save_cpo 34 | unlet s:save_cpo 35 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 36 | -------------------------------------------------------------------------------- /autoload/ingo/number.vim: -------------------------------------------------------------------------------- 1 | " ingo/number.vim: Functions for dealing with numbers. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2013 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | " 10 | " REVISION DATE REMARKS 11 | " 1.005.001 12-Apr-2013 file creation 12 | 13 | function! ingo#number#DecimalStringIncrement( number, offset ) 14 | "****************************************************************************** 15 | "* PURPOSE: 16 | " Increment the decimal number in a:number by a:offset while keeping (the 17 | " width of) leading zeros. 18 | "* ASSUMPTIONS / PRECONDITIONS: 19 | " None. 20 | "* EFFECTS / POSTCONDITIONS: 21 | " None. 22 | "* INPUTS: 23 | " a:number String (or number) to be incremented. 24 | " a:offset Offset to add to a:number. 25 | "* RETURN VALUES: 26 | " Incremented number as String. 27 | "****************************************************************************** 28 | " Note: Need to use str2nr() to avoid interpreting leading zeros as octal 29 | " number. 30 | return printf('%0' . strlen(a:number) . 'd', str2nr(a:number) + a:offset) 31 | endfunction 32 | 33 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 34 | -------------------------------------------------------------------------------- /autoload/ingo/os.vim: -------------------------------------------------------------------------------- 1 | " ingo/os.vim: Functions for operating system-specific stuff. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2013-2017 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | " 10 | " REVISION DATE REMARKS 11 | " 1.030.005 21-Apr-2017 Add ingo#os#IsWindowsShell(). 12 | " 1.014.004 26-Sep-2013 Add ingo#os#IsCygwin(). 13 | " 1.014.003 13-Sep-2013 Add ingo#os#PathSeparator(). 14 | " 1.013.002 13-Sep-2013 FIX: Correct case of ingo#os#IsWin*() function 15 | " names. 16 | " 1.012.001 08-Aug-2013 file creation 17 | 18 | function! ingo#os#IsWindows() 19 | return has('win16') || has('win95') || has('win32') || has('win64') 20 | endfunction 21 | 22 | function! ingo#os#IsWinOrDos() 23 | return has('dos16') || has('dos32') || ingo#os#IsWindows() 24 | endfunction 25 | 26 | function! ingo#os#IsCygwin() 27 | return has('win32unix') 28 | endfunction 29 | 30 | function! ingo#os#PathSeparator() 31 | return (ingo#os#IsWinOrDos() ? ';' : ':') 32 | endfunction 33 | 34 | function! ingo#os#IsWindowsShell() 35 | return (&shell =~? 'cmd\.exe$') 36 | endfunction 37 | 38 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 39 | -------------------------------------------------------------------------------- /autoload/ingo/plugin/compiler.vim: -------------------------------------------------------------------------------- 1 | " ingo/plugin/compiler.vim: Functions for compiler plugins. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2014 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | " 10 | " REVISION DATE REMARKS 11 | " 1.016.001 21-Jan-2014 file creation 12 | 13 | function! ingo#plugin#compiler#CompilerSet( optionname, expr ) 14 | execute 'CompilerSet' a:optionname . '=' . escape(a:expr, ' "|\') 15 | endfunction 16 | 17 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 18 | -------------------------------------------------------------------------------- /autoload/ingo/plugin/rendered/Confirmeach.vim: -------------------------------------------------------------------------------- 1 | " ingo/plugin/rendered/Confirmeach.vim: Filter items by confirming each, as with :s///c. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2015-2022 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | let s:save_cpo = &cpo 10 | set cpo&vim 11 | 12 | function! ingo#plugin#rendered#Confirmeach#Filter( items ) 13 | let l:confirmedItems = [] 14 | let l:idx = 0 15 | while l:idx < len(a:items) 16 | let l:match = a:items[l:idx] 17 | 18 | echo l:match . "\t" 19 | echohl Question 20 | echon ' Use (y/n/a/q/l; to abort)?' 21 | echohl None 22 | 23 | let l:choice = ingo#query#get#Char({ 24 | \ 'isBeepOnInvalid': 0, 'validExpr': "[ynl\aq]", 25 | \ 'isAllowDigraphs': 0, 26 | \}) 27 | if l:choice ==# "\" 28 | return a:items 29 | elseif l:choice ==# 'q' 30 | break 31 | elseif l:choice ==# 'y' 32 | call add(l:confirmedItems, l:match) 33 | elseif l:choice ==# 'l' 34 | call add(l:confirmedItems, l:match) 35 | break 36 | elseif l:choice ==# 'a' 37 | let l:confirmedItems += a:items[l:idx : -1] 38 | break 39 | endif 40 | 41 | let l:idx += 1 42 | endwhile 43 | 44 | return l:confirmedItems 45 | endfunction 46 | 47 | let &cpo = s:save_cpo 48 | unlet s:save_cpo 49 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 50 | -------------------------------------------------------------------------------- /autoload/ingo/plugin/rendered/Subset.vim: -------------------------------------------------------------------------------- 1 | " ingo/plugin/rendered/Subset.vim: Filter items by List indices. 2 | " 3 | " DEPENDENCIES: 4 | " - ingo/cmdargs/pattern.vim autoload script 5 | " - ingo/list.vim autoload script 6 | " - ingo/msg.vim autoload script 7 | " 8 | " Copyright: (C) 2015-2018 Ingo Karkat 9 | " The VIM LICENSE applies to this script; see ':help copyright'. 10 | " 11 | " Maintainer: Ingo Karkat 12 | 13 | function! ingo#plugin#rendered#Subset#Filter( items ) 14 | echohl Question 15 | let l:subsets = input('Enter subsets in Vim List notation, e.g. "0 3:5 -1", or matching /pattern/ (non-matching with !/.../): ') 16 | echohl None 17 | 18 | let l:subsetsPattern = ingo#cmdargs#pattern#ParseUnescaped(l:subsets) 19 | if l:subsetsPattern !=# l:subsets 20 | return s:FilterByPattern(a:items, l:subsetsPattern, 0) 21 | elseif l:subsets[0] ==# '!' 22 | let l:subsetsPattern = ingo#cmdargs#pattern#ParseUnescaped(l:subsets[1:]) 23 | if l:subsetsPattern !=# l:subsets 24 | return s:FilterByPattern(a:items, l:subsetsPattern, 1) 25 | endif 26 | endif 27 | return s:Slice(a:items, split(l:subsets)) 28 | endfunction 29 | 30 | function! s:FilterByPattern( items, pattern, isKeepNonMatching ) 31 | return filter(a:items, printf('v:val %s~ a:pattern', a:isKeepNonMatching ? '!' : '=')) 32 | endfunction 33 | 34 | function! s:Slice( items, subsets ) 35 | try 36 | let l:subsetItems = [] 37 | for l:subset in a:subsets 38 | execute printf('let l:subsetItems += ingo#list#Make(a:items[%s])', l:subset) 39 | endfor 40 | return l:subsetItems 41 | catch /^Vim\%((\a\+)\)\=:/ 42 | redraw 43 | call ingo#msg#VimExceptionMsg() 44 | sleep 500m 45 | return ingo#plugin#rendered#Subset#Filter(a:items) 46 | endtry 47 | endfunction 48 | 49 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 50 | -------------------------------------------------------------------------------- /autoload/ingo/print.vim: -------------------------------------------------------------------------------- 1 | " ingo/print.vim: Functions for printling lines. 2 | " 3 | " DEPENDENCIES: 4 | " - ingo/window/dimensions.vim autoload script 5 | " 6 | " Copyright: (C) 2013 Ingo Karkat 7 | " The VIM LICENSE applies to this script; see ':help copyright'. 8 | " 9 | " Maintainer: Ingo Karkat 10 | " 11 | " REVISION DATE REMARKS 12 | " 1.015.001 22-Nov-2013 file creation 13 | 14 | function! ingo#print#Number( lnum, ... ) 15 | "****************************************************************************** 16 | "* PURPOSE: 17 | " Like :number, but does not move the cursor to the line, and only prints the 18 | " passed a:lnum, not all lines in a (potential) closed fold. 19 | "* ASSUMPTIONS / PRECONDITIONS: 20 | " None. 21 | "* EFFECTS / POSTCONDITIONS: 22 | " :echos output. 23 | "* INPUTS: 24 | " a:lnum Line number; when the line does not exist, nothing is printed. 25 | " a:hlgroup Optional highlight group for the number, default is "LineNr". 26 | "* RETURN VALUES: 27 | " 1 is line exists and was printed; 0 otherwise. 28 | "****************************************************************************** 29 | if a:lnum < 1 || a:lnum > line('$') 30 | return 0 31 | endif 32 | 33 | execute 'echohl' (a:0 ? a:1 : 'LineNr') 34 | echo printf('%' . (ingo#window#dimensions#GetNumberWidth(1) - 1) . 'd ', a:lnum) 35 | echohl None 36 | echon getline(a:lnum) 37 | endfunction 38 | 39 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 40 | -------------------------------------------------------------------------------- /autoload/ingo/query/substitute.vim: -------------------------------------------------------------------------------- 1 | " ingo/query/substitute.vim: Functions for confirming a command like :substitute//c. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2014-2022 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | let s:save_cpo = &cpo 10 | set cpo&vim 11 | 12 | function! s:Question( msg ) 13 | call ingo#query#Question(a:msg . ' (y/n/a/q/l/^E/^Y)?') 14 | endfunction 15 | function! ingo#query#substitute#Get( msg ) 16 | "****************************************************************************** 17 | "* PURPOSE: 18 | " Query a response like |:s_c|, with choices of yes, no, last, quit, Ctrl-E, 19 | " Ctrl-Y. The latter two are handled transparently by this function. 20 | "* ASSUMPTIONS / PRECONDITIONS: 21 | " None. 22 | "* EFFECTS / POSTCONDITIONS: 23 | " Moves the view on Ctrl-E / Ctrl-Y. 24 | "* INPUTS: 25 | " a:msg Message to be presented for acknowledging. 26 | "* RETURN VALUES: 27 | " One of [ynlaq\e]. 28 | "****************************************************************************** 29 | call s:Question(a:msg) 30 | 31 | while 1 32 | let l:choice = ingo#query#get#Char({ 33 | \ 'isBeepOnInvalid': 0, 34 | \ 'validExpr': "[ynl\aq\\]", 35 | \ 'isAllowDigraphs': 0, 36 | \}) 37 | if l:choice ==# "\" || l:choice ==# "\" 38 | execute 'normal!' l:choice 39 | redraw 40 | call s:Question(a:msg) 41 | elseif l:choice ==# "\" 42 | return 'q' 43 | elseif ! empty(l:choice) 44 | return l:choice 45 | endif 46 | endwhile 47 | endfunction 48 | 49 | let &cpo = s:save_cpo 50 | unlet s:save_cpo 51 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 52 | -------------------------------------------------------------------------------- /autoload/ingo/range/borders.vim: -------------------------------------------------------------------------------- 1 | " ingo/range/borders.vim: Functions for determining ranges at the borders of the buffer. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2016 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | " 10 | " REVISION DATE REMARKS 11 | " 001 13-Jul-2016 file creation 12 | 13 | function! ingo#range#borders#StartAndEndRange( startOffset, endOffset ) 14 | "****************************************************************************** 15 | "* PURPOSE: 16 | " Determine non-overlapping range(s) for a:startOffset lines from the start of 17 | " the current buffer, and a:endOffset lines from the end of the current 18 | " buffer. 19 | "* ASSUMPTIONS / PRECONDITIONS: 20 | " None. 21 | "* EFFECTS / POSTCONDITIONS: 22 | " None. 23 | "* INPUTS: 24 | " a:startOffset Number of lines to get from the start. 25 | " a:endOffset Number of lines to get from the end. 26 | "* RETURN VALUES: 27 | " List of ranges, in the form ['1,3', '8,$'] 28 | "****************************************************************************** 29 | let l:ranges = [] 30 | let l:lastStartLnum = min([line('$'), a:startOffset]) 31 | if a:startOffset > 0 32 | call add(l:ranges, '1,' . l:lastStartLnum) 33 | endif 34 | 35 | let l:firstEndLnum = max([1, line('$') - a:endOffset + 1]) 36 | let l:firstEndLnum = max([l:lastStartLnum + 1, l:firstEndLnum]) 37 | if l:firstEndLnum <= line('$') 38 | call add(l:ranges, l:firstEndLnum . ',$') 39 | endif 40 | return l:ranges 41 | endfunction 42 | 43 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 44 | -------------------------------------------------------------------------------- /autoload/ingo/range/sort.vim: -------------------------------------------------------------------------------- 1 | " ingo/range/sort.vim: Functions for sorting ranges. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2019 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | 10 | function! ingo#range#sort#AscendingByStartLnum( ranges ) abort 11 | "****************************************************************************** 12 | "* PURPOSE: 13 | " Sort ranges ascending by start line number. 14 | "* ASSUMPTIONS / PRECONDITIONS: 15 | " None. 16 | "* EFFECTS / POSTCONDITIONS: 17 | " None. 18 | "* INPUTS: 19 | " a:ranges List of [start, end] pairs. 20 | "* RETURN VALUES: 21 | " List of [start, end] pairs in ascending order. 22 | "****************************************************************************** 23 | return sort(a:ranges, function('ingo#collections#SortOnFirstListElement')) 24 | endfunction 25 | 26 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 27 | -------------------------------------------------------------------------------- /autoload/ingo/search/buffer.vim: -------------------------------------------------------------------------------- 1 | " ingo/search/buffer.vim: Functions for searching a buffer. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2013-2019 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | " 10 | " REVISION DATE REMARKS 11 | " 1.005.001 10-Apr-2013 file creation 12 | 13 | function! ingo#search#buffer#IsKeywordMatch( pattern, startVirtCol ) 14 | return search( 15 | \ printf('\%%%dv\<%s\>', a:startVirtCol, a:pattern), 16 | \ 'cnW', line('.') 17 | \) 18 | endfunction 19 | 20 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 21 | -------------------------------------------------------------------------------- /autoload/ingo/search/pattern.vim: -------------------------------------------------------------------------------- 1 | " ingo/search/pattern.vim: Functions for the search pattern. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2011-2013 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | " 10 | " REVISION DATE REMARKS 11 | " 1.013.002 11-Sep-2013 Minor: Return last search pattern instead of 12 | " empty string on 13 | " ingo#search#pattern#GetLastForwardSearch(0). 14 | " 1.006.001 24-May-2013 file creation 15 | 16 | function! ingo#search#pattern#GetLastForwardSearch( ... ) 17 | "****************************************************************************** 18 | "* PURPOSE: 19 | " Get @/, or the a:count'th last search pattern, but also handle the case 20 | " where the pattern was set from a backward search, and doesn't have "/" 21 | " characters properly escaped. 22 | "* ASSUMPTIONS / PRECONDITIONS: 23 | " None. 24 | "* EFFECTS / POSTCONDITIONS: 25 | " None. 26 | "* INPUTS: 27 | " a:count Optional index into the end of the search history. 0 returns the 28 | " last search pattern, 1 the last from the history. (Usually, those should be 29 | " equal). 30 | "* RETURN VALUES: 31 | " Last search pattern ready to use in a :s/{pat}/ command, with forward 32 | " slashes properly escaped. 33 | "****************************************************************************** 34 | return substitute((a:0 && a:1 ? histget('search', -1 * a:1) : @/), '\%(\%(^\|[^\\]\)\%(\\\\\)*\\\)\@ 9 | " 10 | " REVISION DATE REMARKS 11 | " 1.006.001 23-May-2013 file creation 12 | 13 | function! ingo#selection#patternmatch#AdaptEmptySelection() 14 | "****************************************************************************** 15 | "* PURPOSE: 16 | " With :set selection=exclusive, one can create an empty selection with |v| or 17 | " |CTRL-V|. The |/\%V| atom does not match anywhere then. However, (built-in) 18 | " commands like gU do work on one selected character. For consistency, custom 19 | " mappings should, too. Invoke this function at the beginning of your mapping 20 | " to adapt the selection in this special case. You can then use a pattern with 21 | " |/\%V| without worrying. 22 | "* ASSUMPTIONS / PRECONDITIONS: 23 | " A visual selection has previously been established. 24 | "* EFFECTS / POSTCONDITIONS: 25 | " Changes the visual selection. 26 | " Clobbers v:count when active. 27 | "* INPUTS: 28 | " None. 29 | "* RETURN VALUES: 30 | " None. 31 | "****************************************************************************** 32 | if &selection ==# 'exclusive' && virtcol("'<") == virtcol("'>") 33 | silent! execute "normal! gvl\" 34 | endif 35 | endfunction 36 | 37 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 38 | -------------------------------------------------------------------------------- /autoload/ingo/str/join.vim: -------------------------------------------------------------------------------- 1 | " ingo/str/join.vim: Functions for joining lists of strings. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2015 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | " 10 | " REVISION DATE REMARKS 11 | " 1.024.001 24-Feb-2015 file creation 12 | 13 | function! ingo#str#join#NonEmpty( list, ... ) 14 | return call('join', [filter(a:list, '! empty(v:val)')] + a:000) 15 | endfunction 16 | 17 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 18 | -------------------------------------------------------------------------------- /autoload/ingo/str/list.vim: -------------------------------------------------------------------------------- 1 | " ingo/str/list.vim: Functions for dealing with Strings as Lists. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2018 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | 10 | function! ingo#str#list#OfCharacters( string ) 11 | return split(a:string, '\zs') 12 | endfunction 13 | 14 | function! ingo#str#list#OfBytes( string ) 15 | let l:i = 0 16 | let l:len = len(a:string) 17 | let l:list = [] 18 | while l:i < l:len 19 | call add(l:list, a:string[l:i]) 20 | let l:i += 1 21 | endwhile 22 | 23 | return l:list 24 | endfunction 25 | 26 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 27 | -------------------------------------------------------------------------------- /autoload/ingo/subst/expr/emulation.vim: -------------------------------------------------------------------------------- 1 | " ingo/subst/expr/emulation.vim: Function to emulate sub-replace-expression for recursive use. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2014-2020 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | 10 | " Deprecated since 1.043. 11 | " Use ingo#compat#substitution#RecursiveSubstitutionExpression() instead. 12 | function! ingo#subst#expr#emulation#Substitute( expr, pat, sub, flags ) 13 | return ingo#compat#substitution#RecursiveSubstitutionExpression(a:expr, a:pat, a:sub, a:flags) 14 | endfunction 15 | 16 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 17 | -------------------------------------------------------------------------------- /autoload/ingo/swap.vim: -------------------------------------------------------------------------------- 1 | " ingo/swap.vim: Functions around the swap file. 2 | " 3 | " DEPENDENCIES: 4 | " - ingo/buffer/visible.vim autoload script 5 | " 6 | " Copyright: (C) 2016 Ingo Karkat 7 | " The VIM LICENSE applies to this script; see ':help copyright'. 8 | " 9 | " Maintainer: Ingo Karkat 10 | " 11 | " REVISION DATE REMARKS 12 | " 1.025.001 29-Jan-2016 file creation 13 | 14 | function! ingo#swap#GetNameImpl() 15 | " Use silent! so a failing redir (e.g. recursive redir call) won't hurt. 16 | silent! redir => o | silent swapname | redir END 17 | return (o[1:] ==# 'No swap file' ? '' : o[1:]) 18 | return '' 19 | else 20 | return o[1:] 21 | endif 22 | endfunction 23 | function! ingo#swap#GetName( ... ) 24 | "****************************************************************************** 25 | "* PURPOSE: 26 | " Obtain the filespec of the swap file (like :swapname), for the current 27 | " buffer or the passed buffer number. 28 | "* ASSUMPTIONS / PRECONDITIONS: 29 | " None. 30 | "* EFFECTS / POSTCONDITIONS: 31 | " None. 32 | "* INPUTS: 33 | " a:bufnr Optional buffer number of an existing buffer where the swap file 34 | " should be obtained from. 35 | "* RETURN VALUES: 36 | " filespec of current swapfile, or empty string. 37 | "****************************************************************************** 38 | if a:0 39 | silent! return ingo#buffer#visible#Call(a:1, 'ingo#swap#GetNameImpl', []) 40 | else 41 | return ingo#swap#GetNameImpl() 42 | endif 43 | endfunction 44 | 45 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 46 | -------------------------------------------------------------------------------- /autoload/ingo/system.vim: -------------------------------------------------------------------------------- 1 | " ingo/system.vim: Functions for invoking shell commands. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2013 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | " 10 | " REVISION DATE REMARKS 11 | " 1.003.001 22-Mar-2013 file creation 12 | 13 | function! ingo#system#Chomped( ... ) 14 | "****************************************************************************** 15 | "* PURPOSE: 16 | " Wrapper around system() that strips off trailing newline(s). 17 | "* ASSUMPTIONS / PRECONDITIONS: 18 | " None. 19 | "* EFFECTS / POSTCONDITIONS: 20 | " None. 21 | "* INPUTS: 22 | " As |system()| 23 | "* RETURN VALUES: 24 | " Output of the shell command, without trailing newline(s). 25 | "****************************************************************************** 26 | return substitute(call('system', a:000), '\n\+$', '', '') 27 | endfunction 28 | 29 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 30 | -------------------------------------------------------------------------------- /autoload/ingo/tabpage.vim: -------------------------------------------------------------------------------- 1 | " ingo/tabpage.vim: Functions for tab page information. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2017-2019 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | let s:save_cpo = &cpo 10 | set cpo&vim 11 | 12 | function! ingo#tabpage#IsBlank( ... ) 13 | if a:0 14 | let l:tabPageNr = a:1 15 | let l:currentBufNr = tabpagebuflist(l:tabPageNr)[0] 16 | else 17 | let l:tabPageNr = tabpagenr() 18 | let l:currentBufNr = bufnr('') 19 | endif 20 | 21 | return ( 22 | \ empty(bufname(l:currentBufNr)) && 23 | \ tabpagewinnr(l:tabPageNr, '$') <= 1 && 24 | \ getbufvar(l:currentBufNr, '&modified') == 0 && 25 | \ empty(getbufvar(l:currentBufNr, '&buftype')) 26 | \) 27 | endfunction 28 | 29 | let &cpo = s:save_cpo 30 | unlet s:save_cpo 31 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 32 | -------------------------------------------------------------------------------- /autoload/ingo/text/searchhighlights.vim: -------------------------------------------------------------------------------- 1 | " ingo/text/searchhighlights.vim: Functions to obtain search highlights. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2022 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | 10 | function! ingo#text#searchhighlights#GetForLine( lnum, column, pattern ) 11 | let l:save_cursor = ingo#compat#getcurpos() 12 | " Start at the beginning of the passed line. 13 | call cursor(a:lnum, 1) 14 | 15 | let l:highlights = [] 16 | let l:startSearchFlags = 'c' 17 | while 1 18 | let [l:lnum, l:startCol] = searchpos(a:pattern, l:startSearchFlags, a:lnum) 19 | let [l:lnum, l:endCol] = searchpos(a:pattern, 'cen', a:lnum) 20 | let l:startSearchFlags = '' 21 | if l:startCol == 0 22 | " No more matches in this line. 23 | break 24 | endif 25 | if l:endCol == 0 26 | " The end of the match is not in this line any more. 27 | let l:endCol = col('$') 28 | endif 29 | 30 | call add(l:highlights, [ l:startCol, l:endCol, (l:startCol == a:column ? 'IncSearch' : 'Search') ]) 31 | endwhile 32 | 33 | " Restore the cursor position. 34 | call setpos('.', l:save_cursor) 35 | 36 | return l:highlights 37 | endfunction 38 | 39 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 40 | -------------------------------------------------------------------------------- /autoload/ingo/window.vim: -------------------------------------------------------------------------------- 1 | " ingo/window.vim: Functions for dealing with windows. 2 | " 3 | " DEPENDENCIES: 4 | " 5 | " Copyright: (C) 2017 Ingo Karkat 6 | " The VIM LICENSE applies to this script; see ':help copyright'. 7 | " 8 | " Maintainer: Ingo Karkat 9 | 10 | function! ingo#window#GotoNext( direction, ... ) 11 | "****************************************************************************** 12 | "* PURPOSE: 13 | " Go to the next window in a:direction. 14 | "* ASSUMPTIONS / PRECONDITIONS: 15 | " None. 16 | "* EFFECTS / POSTCONDITIONS: 17 | " Activates another window. 18 | "* INPUTS: 19 | " a:direction One of 'j', 'k', 'h', 'l'. 20 | " a:count Number of windows to move (default 1). 21 | "* RETURN VALUES: 22 | " 1 if the move was successful, 0 if there's no [a:count] window[s] in that 23 | " direction. 24 | "****************************************************************************** 25 | let l:prevWinNr = winnr() 26 | execute (a:0 > 0 ? a:1 : '') . 'wincmd' a:direction 27 | return winnr() != l:prevWinNr 28 | endfunction 29 | 30 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 31 | -------------------------------------------------------------------------------- /autoload/ingo/workingdir.vim: -------------------------------------------------------------------------------- 1 | " ingo/workingdir.vim: Functions to deal with the current working directory. 2 | " 3 | " DEPENDENCIES: 4 | " - ingo/compat.vim autoload script 5 | " 6 | " Copyright: (C) 2018 Ingo Karkat 7 | " The VIM LICENSE applies to this script; see ':help copyright'. 8 | " 9 | " Maintainer: Ingo Karkat 10 | 11 | let s:compatFor = (exists('g:IngoLibrary_CompatFor') ? ingo#collections#ToDict(split(g:IngoLibrary_CompatFor, ',')) : {}) 12 | 13 | if exists('*haslocaldir') && ! has_key(s:compatFor, 'haslocaldir') 14 | function! ingo#workingdir#ChdirCommand() 15 | return (haslocaldir() ? 'lchdir!' : 'chdir!') 16 | endfunction 17 | else 18 | function! ingo#workingdir#ChdirCommand() 19 | return 'chdir!' 20 | endfunction 21 | endif 22 | 23 | function! ingo#workingdir#Chdir( dirspec ) 24 | execute ingo#workingdir#ChdirCommand() ingo#compat#fnameescape(a:dirspec) 25 | endfunction 26 | function! ingo#workingdir#ChdirToSpecial( cmdlineSpecial ) 27 | execute ingo#workingdir#ChdirCommand() a:cmdlineSpecial 28 | endfunction 29 | 30 | " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax : 31 | -------------------------------------------------------------------------------- /tests/all.suite: -------------------------------------------------------------------------------- 1 | change/processed/ 2 | cmdargs/file/ 3 | cmdargs/register/ 4 | collections/ 5 | collections/recursive/ 6 | compat/ 7 | compat/substitution/ 8 | date/ 9 | dict/ 10 | digest/ 11 | escape/ 12 | file/ 13 | function/uniquify/ 14 | fs/paths/ 15 | fs/paths/split/ 16 | join/ 17 | list/ 18 | list/lcs/ 19 | list/merge/ 20 | list/pattern/ 21 | list/sequence/ 22 | list/split/ 23 | lists/ 24 | lnum/ 25 | matches/ 26 | option/listchars/ 27 | range/merge/ 28 | range/sort/ 29 | regexp/ 30 | regexp/capture/ 31 | regexp/collection/ 32 | regexp/deconstruct/ 33 | regexp/length/ 34 | regexp/parse/ 35 | regexp/split/ 36 | smartcase/ 37 | str/ 38 | str/remove/ 39 | strdisplaywidth/ 40 | strdisplaywidth/pad/ 41 | subs/BraceCreation/ 42 | subs/BraceExpansion/ 43 | subst/ 44 | subst/expr/ 45 | -------------------------------------------------------------------------------- /tests/change/processed/t1000-NetChange.vim: -------------------------------------------------------------------------------- 1 | " Test determining the net change. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(4) 5 | 6 | call vimtap#Is(ingo#change#processed#NetChange('foo bar'), 'foo bar', 'original text without backspaces is returned as-is') 7 | call vimtap#Is(ingo#change#processed#NetChange("f\Foo\x"), 'Fox', 'two single backspaces are removed') 8 | call vimtap#Is(ingo#change#processed#NetChange("f\Foo\\\Bas\r"), 'Bar', 'consecutive backspaces are removed') 9 | call vimtap#Is(ingo#change#processed#NetChange("\\foo\x"), "\\fox", 'backspaces at the beginning are kept') 10 | 11 | call vimtest#Quit() 12 | -------------------------------------------------------------------------------- /tests/cmdargs/file/t1010-FilterFileOptionsAndCommands-side-effects.vim: -------------------------------------------------------------------------------- 1 | " Test modification of the passed-in fileglobs List when stripping options and commands. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(2) 5 | 6 | let g:fileglobs = ['++ff=unix', '++enc=utf-8', '+setl et', 'foo*', 'bar'] 7 | call vimtap#Is(ingo#cmdargs#file#FilterFileOptionsAndCommands(g:fileglobs), [['foo*', 'bar'], ['++ff=unix', '++enc=utf-8', '+setl et']], 'two options, command, and two files') 8 | call vimtap#Is(g:fileglobs, ['foo*', 'bar'], 'original argument list has been reduced') 9 | 10 | call vimtest#Quit() 11 | -------------------------------------------------------------------------------- /tests/cmdargs/file/t1020-FilterFileOptionsAndCommandsToEscaped.vim: -------------------------------------------------------------------------------- 1 | " Test stripping file options and commands with joining and escaping. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(2) 5 | 6 | call vimtap#Is(ingo#cmdargs#file#FilterFileOptionsAndCommandsToEscaped(['++ff=unix', '+setl et| echomsg "foobar"', 'bar']), [['bar'], '++ff=unix +setl\ et|\ \ echomsg\ "foobar"'], 'option, command, and file') 7 | call vimtap#Is(ingo#cmdargs#file#FilterFileOptionsAndCommandsToEscaped(["+echomsg 'foo with \\% and # and \\\\'", 'bar']), [['bar'], "+echomsg\\ 'foo\\ with\\ %\\ and\\ #\\ and\\ \\\\'"], 'command with cmdline-special escaping variants and file') 8 | 9 | call vimtest#Quit() 10 | -------------------------------------------------------------------------------- /tests/cmdargs/file/t1100-FilterFileOptions.vim: -------------------------------------------------------------------------------- 1 | " Test stripping file options. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(8) 5 | 6 | call vimtap#Is(ingo#cmdargs#file#FilterFileOptions([]), [[], []], 'empty fileglobs') 7 | call vimtap#Is(ingo#cmdargs#file#FilterFileOptions(['/tmp/foo']), [['/tmp/foo'], []], 'just a file') 8 | call vimtap#Is(ingo#cmdargs#file#FilterFileOptions(['foo*', 'bar']), [['foo*', 'bar'], []], 'just two files') 9 | call vimtap#Is(ingo#cmdargs#file#FilterFileOptions(['+setl et', 'foo*', 'bar']), [['+setl et', 'foo*', 'bar'], []], 'command is treated as file') 10 | call vimtap#Is(ingo#cmdargs#file#FilterFileOptions(['foo*', '++ff=unix']), [['foo*', '++ff=unix'], []], 'option after fileglob is treated as fileglob') 11 | call vimtap#Is(ingo#cmdargs#file#FilterFileOptions(['++ff=unix', 'foo*', 'bar']), [['foo*', 'bar'], ['++ff=unix']], 'option and two files') 12 | call vimtap#Is(ingo#cmdargs#file#FilterFileOptions(['++ff=unix', '++enc=utf-8', 'foo*', 'bar']), [['foo*', 'bar'], ['++ff=unix', '++enc=utf-8']], 'two options and two files') 13 | 14 | call vimtap#Is(ingo#cmdargs#file#FilterFileOptions(['++whatis=that', 'foo*', 'bar']), [['++whatis=that', 'foo*', 'bar'], []], 'invalid option is treated as fileglob') 15 | 16 | call vimtest#Quit() 17 | -------------------------------------------------------------------------------- /tests/cmdargs/file/t1110-FilterFileOptions-side-effects.vim: -------------------------------------------------------------------------------- 1 | " Test modification of the passed-in fileglobs List when stripping options. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(2) 5 | 6 | let g:fileglobs = ['++ff=unix', '++enc=utf-8', 'foo*', 'bar'] 7 | call vimtap#Is(ingo#cmdargs#file#FilterFileOptions(g:fileglobs), [['foo*', 'bar'], ['++ff=unix', '++enc=utf-8']], 'two options and two files') 8 | call vimtap#Is(g:fileglobs, ['foo*', 'bar'], 'original argument list has been reduced') 9 | 10 | call vimtest#Quit() 11 | -------------------------------------------------------------------------------- /tests/cmdargs/file/t1120-FilterFileOptionsToEscaped.vim: -------------------------------------------------------------------------------- 1 | " Test stripping file options and commands with joining and escaping. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(1) 5 | 6 | call vimtap#Is(ingo#cmdargs#file#FilterFileOptionsToEscaped(['++enc=utf-8', '++ff=unix', 'bar']), [['bar'], '++enc=utf-8 ++ff=unix'], 'two options, and file') 7 | 8 | call vimtest#Quit() 9 | -------------------------------------------------------------------------------- /tests/cmdargs/file/t1200-FileOptionsAndCommandsToEscapedExCommandLine.vim: -------------------------------------------------------------------------------- 1 | " Test joining and escaping of file options and commands. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(3) 5 | 6 | call vimtap#Is(ingo#cmdargs#file#FileOptionsAndCommandsToEscapedExCommandLine(['++nobin', '++ff=dos']), '++nobin ++ff=dos', 'two options') 7 | call vimtap#Is(ingo#cmdargs#file#FileOptionsAndCommandsToEscapedExCommandLine(['setl et | echomsg "foobar"|set wrap']), 'setl\ et\ |\ echomsg\ "foobar"|set\ wrap', 'one command') 8 | call vimtap#Is(ingo#cmdargs#file#FileOptionsAndCommandsToEscapedExCommandLine(['++ff=unix', '++enc=utf-8', 'setl et | echomsg "foobar"|set wrap']), '++ff=unix ++enc=utf-8 setl\ et\ |\ echomsg\ "foobar"|set\ wrap', 'two options and one command') 9 | 10 | call vimtest#Quit() 11 | -------------------------------------------------------------------------------- /tests/cmdargs/file/t1210-FileOptionsAndCommandsToEscapedExCommandLine-no-side-effect.vim: -------------------------------------------------------------------------------- 1 | " Test joining and escaping of file options and commands has no side effect. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(2) 5 | 6 | let s:fileglobs = ['++nobin', 'setl et | echomsg "foobar"|set wrap'] 7 | let s:originalFileGlobs = copy(s:fileglobs) 8 | call vimtap#Is(ingo#cmdargs#file#FileOptionsAndCommandsToEscapedExCommandLine(s:fileglobs), '++nobin setl\ et\ |\ echomsg\ "foobar"|set\ wrap', 'one option one command') 9 | call vimtap#Is(s:fileglobs, s:originalFileGlobs, 'original fileglobs are not modified') 10 | 11 | call vimtest#Quit() 12 | -------------------------------------------------------------------------------- /tests/collections/recursive/t1000-map.vim: -------------------------------------------------------------------------------- 1 | " Test recursive mapping. 2 | 3 | let s:expr = 'toupper(v:val)' 4 | function! s:CreateData() 5 | return ['a', 'b', [{'foo': 'bar', 'rec': ['e', 'ff']}, 'd']] 6 | endfunction 7 | 8 | call vimtest#StartTap() 9 | call vimtap#Plan(4) 10 | 11 | let s:data = s:CreateData() 12 | call vimtap#Is(ingo#collections#recursive#map(s:data, s:expr), ['A', 'B', [{'foo': 'BAR', 'rec': ['E', 'FF']}, 'D']], 'in-place toupper') 13 | call vimtap#Is(s:data, ['A', 'B', [{'foo': 'BAR', 'rec': ['E', 'FF']}, 'D']], 'in-place toupper modifies original') 14 | 15 | let s:data = s:CreateData() 16 | call vimtap#Is(ingo#collections#recursive#MapWithCopy(s:data, s:expr), ['A', 'B', [{'foo': 'BAR', 'rec': ['E', 'FF']}, 'D']], 'copied toupper') 17 | call vimtap#Is(s:data, ['a', 'b', [{'foo': 'bar', 'rec': ['e', 'ff']}, 'd']], 'copied toupper keeps original') 18 | 19 | call vimtest#Quit() 20 | -------------------------------------------------------------------------------- /tests/collections/recursive/t1010-map-simple.vim: -------------------------------------------------------------------------------- 1 | " Test recursive mapping of simple collections. 2 | 3 | let s:expr = 'toupper(v:val)' 4 | 5 | call vimtest#StartTap() 6 | call vimtap#Plan(8) 7 | 8 | let s:data = ['a', 'b', 'c'] 9 | call vimtap#Is(ingo#collections#recursive#map(s:data, s:expr), ['A', 'B', 'C'], 'in-place toupper of simple List') 10 | call vimtap#Is(s:data, ['A', 'B', 'C'], 'in-place toupper modifies original') 11 | 12 | let s:data = ['a', 'b', 'c'] 13 | call vimtap#Is(ingo#collections#recursive#MapWithCopy(s:data, s:expr), ['A', 'B', 'C'], 'copied toupper of simple List') 14 | call vimtap#Is(s:data, ['a', 'b', 'c'], 'copied toupper keeps original') 15 | 16 | let s:data = {'a': 'x', 'b': 'y'} 17 | call vimtap#Is(ingo#collections#recursive#map(s:data, s:expr), {'a': 'X', 'b': 'Y'}, 'in-place toupper of simple Dict') 18 | call vimtap#Is(s:data, {'a': 'X', 'b': 'Y'}, 'in-place toupper modifies original') 19 | 20 | let s:data = {'a': 'x', 'b': 'y'} 21 | call vimtap#Is(ingo#collections#recursive#MapWithCopy(s:data, s:expr), {'a': 'X', 'b': 'Y'}, 'copied toupper of simple Dict') 22 | call vimtap#Is(s:data, {'a': 'x', 'b': 'y'}, 'copied toupper keeps original') 23 | 24 | call vimtest#Quit() 25 | -------------------------------------------------------------------------------- /tests/collections/t1000-SplitKeepSeparators.vim: -------------------------------------------------------------------------------- 1 | " Test splitting including separators. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(8) 5 | 6 | call vimtap#Is(ingo#collections#SplitKeepSeparators('foo-bar.baz.,.a;b;c.', '\A'), ['foo', '-', 'bar', '.', 'baz', '.', '', ',', '', '.', 'a', ';', 'b', ';', 'c', '.'], 'splitting on single non-alpha') 7 | call vimtap#Is(ingo#collections#SplitKeepSeparators('foo-bar.baz.,.a;b;c.', '\A\+'), ['foo', '-', 'bar', '.', 'baz', '.,.', 'a', ';', 'b', ';', 'c', '.'], 'splitting on non-alphas') 8 | call vimtap#Is(ingo#collections#SplitKeepSeparators('-foo-', '\A', 0), ['-', 'foo', '-'], 'omit first and last empty') 9 | call vimtap#Is(ingo#collections#SplitKeepSeparators('-foo-', '\A', 1), ['', '-', 'foo', '-', ''], 'keep first and last empty') 10 | 11 | call vimtap#Is(ingo#collections#SplitKeepSeparators('', '\A'), [], 'empty text') 12 | call vimtap#Is(ingo#collections#SplitKeepSeparators('x', '\A'), ['x'], 'no separator') 13 | call vimtap#Is(ingo#collections#SplitKeepSeparators('-', '\A', 0), ['-'], 'nokeep on separator only text') 14 | call vimtap#Is(ingo#collections#SplitKeepSeparators('-', '\A', 1), ['', '-', ''], 'keep on separator only text') 15 | 16 | call vimtest#Quit() 17 | -------------------------------------------------------------------------------- /tests/collections/t1100-SeparateItemsAndSeparators.vim: -------------------------------------------------------------------------------- 1 | " Test splitting into two Lists. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(8) 5 | 6 | call vimtap#Is(ingo#collections#SeparateItemsAndSeparators('foo-bar.baz.,.a;b;c.', '\A'), [['foo', 'bar', 'baz', '', '', 'a', 'b', 'c'], ['-', '.', '.', ',', '.', ';', ';', '.']], 'splitting on single non-alpha') 7 | call vimtap#Is(ingo#collections#SeparateItemsAndSeparators('foo-bar.baz.,.a;b;c.', '\A\+'), [['foo', 'bar', 'baz', 'a', 'b', 'c'], ['-', '.', '.,.', ';', ';', '.']], 'splitting on non-alphas') 8 | call vimtap#Is(ingo#collections#SeparateItemsAndSeparators('-foo-', '\A', 0), [['foo'], ['-', '-']], 'omit first and last empty') 9 | call vimtap#Is(ingo#collections#SeparateItemsAndSeparators('-foo-', '\A', 1), [['', 'foo', ''], ['-', '-']], 'keep first and last empty') 10 | 11 | call vimtap#Is(ingo#collections#SeparateItemsAndSeparators('', '\A'), [[], []], 'empty text') 12 | call vimtap#Is(ingo#collections#SeparateItemsAndSeparators('x', '\A'), [['x',], []], 'no separator') 13 | call vimtap#Is(ingo#collections#SeparateItemsAndSeparators('-', '\A', 0), [[], ['-']], 'nokeep on separator only text') 14 | call vimtap#Is(ingo#collections#SeparateItemsAndSeparators('-', '\A', 1), [['', ''], ['-']], 'keep on separator only text') 15 | 16 | call vimtest#Quit() 17 | -------------------------------------------------------------------------------- /tests/collections/t1200-SplitIntoMatches.vim: -------------------------------------------------------------------------------- 1 | " Test splitting into matches. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(9) 5 | 6 | call vimtap#Is(ingo#collections#SplitIntoMatches('foo-bar.baz.,.a;b;c.', '\A'), ['-', '.', '.', ',', '.', ';', ';', '.'], 'splitting for single non-alpha') 7 | call vimtap#Is(ingo#collections#SplitIntoMatches('foo-bar.baz.,.a;b;c.', '\A\+'), ['-', '.', '.,.', ';', ';', '.'], 'splitting for non-alphas') 8 | call vimtap#Is(ingo#collections#SplitIntoMatches('-foo-', '\A'), ['-', '-'], 'start and end with match') 9 | 10 | call vimtap#Is(ingo#collections#SplitIntoMatches('foo-bar.baz.,.a;b;c.', '\a'), ['f', 'o', 'o', 'b', 'a', 'r', 'b', 'a', 'z', 'a', 'b', 'c'], 'splitting for single alpha') 11 | call vimtap#Is(ingo#collections#SplitIntoMatches('foo-bar.baz.,.a;b;c.', '\a\+'), ['foo', 'bar', 'baz', 'a', 'b', 'c'], 'splitting for alphas') 12 | 13 | call vimtap#Is(ingo#collections#SplitIntoMatches('', '\A'), [], 'empty text') 14 | call vimtap#Is(ingo#collections#SplitIntoMatches('x', '\A'), [], 'no separator') 15 | call vimtap#Is(ingo#collections#SplitIntoMatches('-', '\A', 0), ['-'], 'nokeep on separator only text') 16 | call vimtap#Is(ingo#collections#SplitIntoMatches('-', '\A', 1), ['-'], 'keep on separator only text') 17 | 18 | call vimtest#Quit() 19 | -------------------------------------------------------------------------------- /tests/collections/t1210-SplitIntoMatches-allowedDiscardPattern.vim: -------------------------------------------------------------------------------- 1 | " Test completely splitting into matches. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(10) 5 | 6 | call vimtap#Is(ingo#collections#SplitIntoMatches('foo-bar.baz.,.a;b;c.', '\a\+\A\+', ''), ['foo-', 'bar.', 'baz.,.', 'a;', 'b;', 'c.'], 'splitting for alphas-non-alphas') 7 | call vimtap#err#Throws("SplitIntoMatches: Cannot discard 'c'", "call ingo#collections#SplitIntoMatches('foo-bar.baz.,.a;b;c', '\\a\\+\\A\\+', '')", 'exception thrown') 8 | 9 | call vimtap#Is(ingo#collections#SplitIntoMatches('foo-bar!baz', '\a\+', '[^.;?]'), ['foo', 'bar', 'baz'], 'splitting for alphas-non-alpha') 10 | call vimtap#err#Throws("SplitIntoMatches: Cannot discard '.'", "call ingo#collections#SplitIntoMatches('foo-bar.baz', '\\a\\+', '[^.;?]')", 'exception thrown') 11 | call vimtap#err#Throws("SplitIntoMatches: Cannot discard '.'", "call ingo#collections#SplitIntoMatches('foo-bar.baz', '\\a\\+', '-')", 'exception thrown') 12 | 13 | call vimtap#Is(ingo#collections#SplitIntoMatches('foo-bar.baz.,.a;b;c.', '\a\+\A\+', '^$'), ['foo-', 'bar.', 'baz.,.', 'a;', 'b;', 'c.'], 'splitting for alphas-non-alphas with ^$') 14 | call vimtap#Is(ingo#collections#SplitIntoMatches('foo-bar.baz.,.a;b;c.', '\a\+\A', '\A\{0,2\}'), ['foo-', 'bar.', 'baz.', 'a;', 'b;', 'c.'], 'splitting for alphas-non-alphas with ^$') 15 | 16 | call vimtap#err#Throws("SplitIntoMatches: Cannot discard '.,.'", "call ingo#collections#SplitIntoMatches('foo-bar.baz.,.a;b;c.', '\\a\\+', '\\A\\?')", 'exception thrown') 17 | 18 | call vimtap#Is(ingo#collections#SplitIntoMatches('foobarbaz', '...', ''), ['foo', 'bar', 'baz'], 'splitting into three-char groups') 19 | call vimtap#err#Throws("SplitIntoMatches: Cannot discard 'xy'", "call ingo#collections#SplitIntoMatches('foobarquuxy', '...', '')", 'exception thrown') 20 | 21 | call vimtest#Quit() 22 | -------------------------------------------------------------------------------- /tests/collections/t2000-SortOnOneAttribute.vim: -------------------------------------------------------------------------------- 1 | " Test sorting dicts based on one attribute. 2 | 3 | function! s:SortOnFoo( o1, o2 ) 4 | return ingo#collections#SortOnOneAttribute('foo', a:o1, a:o2) 5 | endfunction 6 | function! s:SortOnBar( o1, o2 ) 7 | return ingo#collections#SortOnOneAttribute('bar', a:o1, a:o2) 8 | endfunction 9 | function! s:SortOnBarWithDefault( o1, o2 ) 10 | return ingo#collections#SortOnOneAttribute('bar', a:o1, a:o2, 'z') 11 | endfunction 12 | 13 | let s:one = {'foo': 1, 'bar': 'first'} 14 | let s:two = {'foo': 2} 15 | let s:three = {'foo': 3, 'bar': 'third'} 16 | let s:objects = [s:two, s:three, s:one] 17 | 18 | call vimtest#StartTap() 19 | call vimtap#Plan(3) 20 | 21 | call vimtap#Is(sort(copy(s:objects), 's:SortOnFoo'), [s:one, s:two, s:three], 'sorted based on foo attribute') 22 | call vimtap#Is(sort(copy(s:objects), 's:SortOnBar'), [s:two, s:one, s:three], 'sorted based on (partially missing) bar attribute') 23 | call vimtap#Is(sort(copy(s:objects), 's:SortOnBarWithDefault'), [s:one, s:three, s:two], 'sorted based on (partially missing) bar attribute with default z') 24 | 25 | call vimtest#Quit() 26 | -------------------------------------------------------------------------------- /tests/collections/t2010-PrioritySort.vim: -------------------------------------------------------------------------------- 1 | " Test sorting dicts based on a priority attribute. 2 | 3 | let s:one = {'priority': 1, 'bar': 'first'} 4 | let s:two = {'priority': 2} 5 | let s:three = {'priority': 3, 'bar': 'third'} 6 | let s:objects = [s:two, s:three, s:one] 7 | 8 | call vimtest#StartTap() 9 | call vimtap#Plan(1) 10 | 11 | call vimtap#Is(sort(copy(s:objects), 'ingo#collections#PrioritySort'), [s:one, s:two, s:three], 'sorted based on priority') 12 | 13 | call vimtest#Quit() 14 | -------------------------------------------------------------------------------- /tests/collections/t2020-SortOnTwoAttributes.vim: -------------------------------------------------------------------------------- 1 | " Test sorting dicts based on two attributes. 2 | 3 | function! s:SortOnFooThenBar( o1, o2 ) 4 | return ingo#collections#SortOnTwoAttributes('foo', 'bar', a:o1, a:o2) 5 | endfunction 6 | function! s:SortWithDefault( o1, o2 ) 7 | return ingo#collections#SortOnTwoAttributes('foo', 'bar', a:o1, a:o2, 99) 8 | endfunction 9 | function! s:SortWithDefaults( o1, o2 ) 10 | return ingo#collections#SortOnTwoAttributes('foo', 'bar', a:o1, a:o2, 99, 'zzz') 11 | endfunction 12 | 13 | let s:one = { 'bar': 'first'} 14 | let s:two = {'foo': 2 } 15 | let s:three = { 'bar': 'third'} 16 | let s:four = {'foo': 4, 'bar': 'fourth'} 17 | let s:five = {'foo': 4, 'bar': 'fifth'} 18 | let s:objects = [s:four, s:two, s:five, s:three, s:five, s:one] 19 | 20 | call vimtest#StartTap() 21 | call vimtap#Plan(3) 22 | 23 | call vimtap#Is(sort(copy(s:objects), 's:SortOnFooThenBar'), [s:one, s:three, s:two, s:five, s:five, s:four], 'sorted based on foo then bar attributes') 24 | call vimtap#Is(sort(copy(s:objects), 's:SortWithDefault'), [s:two, s:five, s:five, s:four, s:one, s:three], 'sorted based on foo (default 99) then bar (same default) attributes') 25 | let s:twoBe = {'foo': 2, 'bar': 'exists'} 26 | call vimtap#Is(sort([s:four, s:two, s:three, s:twoBe, s:one], 's:SortWithDefaults'), [s:twoBe, s:two, s:four, s:one, s:three], 'sorted based on foo (default 99) then bar (default zzz) attributes') 27 | 28 | call vimtest#Quit() 29 | -------------------------------------------------------------------------------- /tests/compat/helpers/CompatChecker.vim: -------------------------------------------------------------------------------- 1 | function! IsCompatible( originalFunctionName, description, ... ) 2 | let l:compatFunctionName = 'ingo#compat#' . a:originalFunctionName 3 | 4 | let l:expected = call(a:originalFunctionName, a:000) 5 | let l:got = call(l:compatFunctionName, a:000) 6 | call vimtap#Is(l:got, l:expected, a:description) 7 | endfunction 8 | -------------------------------------------------------------------------------- /tests/compat/substitution/t1000-RecursiveSubstitutionExpression.vim: -------------------------------------------------------------------------------- 1 | " Test recursive invocation of sub-replace-expression. 2 | 3 | let g:IngoLibrary_CompatFor = 'RecursiveSubstitutionExpression' 4 | 5 | call vimtest#StartTap() 6 | call vimtap#Plan(5) 7 | 8 | call vimtap#Is(ingo#compat#substitution#RecursiveSubstitutionExpression('foobor', 'o\+', 'X', 'g'), 'fXbXr', 'plain substitution') 9 | call vimtap#Is(ingo#compat#substitution#RecursiveSubstitutionExpression('foobor', 'o\+', '\=repeat(submatch(0), 2)', 'g'), 'fooooboor', 'non-recursive expression substitution') 10 | call vimtap#Is(substitute('foobor', '.o\+', '\=ingo#compat#substitution#RecursiveSubstitutionExpression(submatch(0), "^.", "\\=toupper(submatch(0))", "")', 'g'), 'FooBor', 'recursive expression substitution with inner compat function') 11 | call vimtap#Is(ingo#compat#substitution#RecursiveSubstitutionExpression('foobor', '.o\+', '\=ingo#compat#substitution#RecursiveSubstitutionExpression(submatch(0), "^.", "\\=toupper(submatch(0))", "")', 'g'), 'FooBor', 'recursive expression substitution both using compat function') 12 | 13 | function! Recurse() abort 14 | return ingo#compat#substitution#RecursiveSubstitutionExpression('yyy', '.\(.\).', '\=submatch(1) . submatch(1)', '') 15 | endfunction 16 | call vimtap#Is(substitute('foobor', 'o\+', '\=Recurse() . submatch(0)', 'g'), 'fyyoobyyor', 'recursive expression substitution through function') 17 | 18 | call vimtest#Quit() 19 | -------------------------------------------------------------------------------- /tests/compat/t1000-matchstrpos.vim: -------------------------------------------------------------------------------- 1 | " Test matchstrpos() compatibility. 2 | 3 | call vimtest#SkipAndQuitIf(! exists('*matchstrpos'), 'Need support for matchstrpos') 4 | 5 | source helpers/CompatChecker.vim 6 | let g:IngoLibrary_CompatFor = 'matchstrpos' 7 | 8 | call vimtest#StartTap() 9 | call vimtap#Plan(12) 10 | 11 | call IsCompatible('matchstrpos', 'string match', 'testing', 'ing') 12 | call IsCompatible('matchstrpos', 'string not matching', 'testing', 'xxx') 13 | call IsCompatible('matchstrpos', 'first match', 'testing', 't') 14 | 15 | call IsCompatible('matchstrpos', 'start to second match', 'testing', 't', 3) 16 | call IsCompatible('matchstrpos', 'start beyond matches', 'testing', 't', 7) 17 | 18 | call IsCompatible('matchstrpos', 'string count 2', "testing", "..", 0, 2) 19 | 20 | 21 | call IsCompatible('matchstrpos', 'List match', [1, '__x'], '\a') 22 | call IsCompatible('matchstrpos', 'List not matching', [1, '__x'], 'xxx') 23 | 24 | call IsCompatible('matchstrpos', 'List start to second match', ['foxy', 'foobar', 'foony', 'bar'], 'o', 1) 25 | call IsCompatible('matchstrpos', 'List start beyond matches', ['foxy', 'foobar', 'foony', 'bar'], 'o', 3) 26 | 27 | call IsCompatible('matchstrpos', 'List count 2', ['foxy', 'foobar', 'foony', 'bar'], 'o', 0, 2) 28 | call IsCompatible('matchstrpos', 'List start to second, count 2', ['foony', 'faabar', 'fiiny', 'bar'], '\(.\)\1', 1, 2) 29 | 30 | call vimtest#Quit() 31 | -------------------------------------------------------------------------------- /tests/compat/t1100-trim.vim: -------------------------------------------------------------------------------- 1 | " Test trim() compatibility. 2 | 3 | call vimtest#SkipAndQuitIf(! exists('*trim'), 'Need support for trim') 4 | 5 | source helpers/CompatChecker.vim 6 | let g:IngoLibrary_CompatFor = 'trim' 7 | 8 | call vimtest#StartTap() 9 | call vimtap#Plan(6) 10 | 11 | call IsCompatible('trim', 'trim on empty string', "") 12 | call IsCompatible('trim', 'trim nothing', "some text") 13 | call IsCompatible('trim', 'trim spaces', " some text ") 14 | call IsCompatible('trim', 'trim defaults', " \r\t\t\r RESERVE \t\n\x0B\xA0") 15 | call IsCompatible('trim', 'trim custom mask', "rmX>rrm", "rm<>") 16 | call IsCompatible('trim', 'trim spaces around non-ASCII text', " \u222A\uFF4E\u30A7\u00E7\u00F8\u03B4\u0639\u3128\uC6C3\u8A9E ") 17 | 18 | call vimtest#Quit() 19 | -------------------------------------------------------------------------------- /tests/compat/t1200-strcharpart.vim: -------------------------------------------------------------------------------- 1 | " Test strcharpart() compatibility. 2 | 3 | call vimtest#SkipAndQuitIf(! exists('*strcharpart'), 'Need support for strcharpart') 4 | 5 | source helpers/CompatChecker.vim 6 | let g:IngoLibrary_CompatFor = 'strcharpart' 7 | 8 | call vimtest#StartTap() 9 | call vimtap#Plan(5) 10 | 11 | call IsCompatible('strcharpart', 'middle ASCII part with length', 'anASCIItext', 2, 5) 12 | call IsCompatible('strcharpart', 'middle ASCII part without length', 'anASCIItext', 2) 13 | call IsCompatible('strcharpart', 'middle Unicode part with length', 'an\u222A\uFF4E\u30A7\u00E7\u00F8\u03B4\u0639\u3128\uC6C3\u8A9Etext', 5, 4) 14 | call IsCompatible('strcharpart', 'middle Unicode part without length', 'an\u222A\uFF4E\u30A7\u00E7\u00F8\u03B4\u0639\u3128\uC6C3\u8A9Etext', 5) 15 | 16 | call IsCompatible('strcharpart', 'negative start', 'anASCIItext', -2, 5) 17 | 18 | call vimtest#Quit() 19 | -------------------------------------------------------------------------------- /tests/compat/t1300-maparg.vim: -------------------------------------------------------------------------------- 1 | " Test maparg() compatibility. 2 | 3 | call vimtest#SkipAndQuitIf(v:version < 704, 'Need support for extended maparg().rhs') 4 | 5 | " Cannot use the one from helpers/CompatChecker.vim because we need to pass 6 | " additional arguments to the original maparg() one here, and use the rhs 7 | " attribute from the result. 8 | function! IsCompatible( originalFunctionName, description, ... ) 9 | let l:expected = call(a:originalFunctionName, [a:1, '', 0, 1]).rhs 10 | let l:got = call('ingo#compat#maparg', a:000) 11 | call vimtap#Is(l:got, l:expected, a:description) 12 | endfunction 13 | let g:IngoLibrary_CompatFor = 'maparg' 14 | 15 | call vimtest#StartTap() 16 | call vimtap#Plan(6) 17 | 18 | nnoremap TestEasy simple 19 | call IsCompatible('maparg', 'simple mapping', 'TestEasy') 20 | 21 | nnoremap TestKeyNotation :echo 22 | call IsCompatible('maparg', 'key notation', 'TestKeyNotation') 23 | 24 | nnoremap TestBar :echo "foo"version quit 25 | call IsCompatible('maparg', 'bar', 'TestBar') 26 | 27 | nnoremap TestLt echo "\Plug>NONO" 28 | call IsCompatible('maparg', '', 'TestLt') 29 | 30 | nnoremap (JustATest) gaga 31 | nnoremap TestSID :(JustATest): 32 | call vimtap#Is(maparg('TestSID', '', 0, 1).rhs, ':(JustATest):', 'original does not resolve ') 33 | call vimtap#Like(ingo#compat#maparg('TestSID'), '^:\d\+_(JustATest):$', 'compatibility wrapper resolves to ') 34 | 35 | call vimtest#Quit() 36 | -------------------------------------------------------------------------------- /tests/date/t1000-strftime.vim: -------------------------------------------------------------------------------- 1 | " Test strftime() emulation. 2 | 3 | function! MyTime( format, ... ) 4 | return (a:0 ? a:1[0] . a:1[0] . ':' . a:1[1] . a:1[1] : '23:59') 5 | endfunction 6 | let g:IngoLibrary_StrftimeEmulation = {'%Y': '1999', '%H:%M': function('MyTime'), '*': 'Joker'} 7 | 8 | call vimtest#StartTap() 9 | call vimtap#Plan(7) 10 | 11 | call vimtap#Is(ingo#date#strftime('%Y'), '1999', 'Emulated %Y') 12 | call vimtap#Is(ingo#date#strftime('%Y', 1540148357), '1999', 'Emulated %Y with time') 13 | 14 | call vimtap#Is(ingo#date#strftime('%H:%M'), '23:59', 'Emulated %H:M') 15 | call vimtap#Is(ingo#date#strftime('%H:%M', 1540148357), '11:55', 'Emulated %H:M with time') 16 | 17 | call vimtap#Is(ingo#date#strftime('%c'), 'Joker', 'Emulated fallback') 18 | call vimtap#Is(ingo#date#strftime('%c', 1540148357), 'Joker', 'Emulated fallback with time') 19 | 20 | unlet g:IngoLibrary_StrftimeEmulation['*'] 21 | call vimtap#err#Throws('strftime: Unhandled format %c and no fallback * key in g:IngoLibrary_StrftimeEmulation', "call ingo#date#strftime('%c')", 'Exception without fallback') 22 | 23 | call vimtest#Quit() 24 | -------------------------------------------------------------------------------- /tests/dict/t1000-FromValues.vim: -------------------------------------------------------------------------------- 1 | " Test creating Dict from values. 2 | 3 | function! BothExtractor( val ) abort 4 | return a:val[0] . a:val[-1:-1] 5 | endfunction 6 | function! FrontExtractor( val ) abort 7 | return a:val[0] 8 | endfunction 9 | call vimtest#StartTap() 10 | call vimtap#Plan(3) 11 | 12 | call vimtap#Is(ingo#dict#FromValues(function('BothExtractor'), []), {}, 'create with empty values') 13 | call vimtap#Is(ingo#dict#FromValues(function('BothExtractor'), ['foo', 'bar', 'baz']), {'fo': 'foo', 'br': 'bar', 'bz': 'baz'}, 'create with keys from first + last letter') 14 | call vimtap#Is(ingo#dict#FromValues(function('FrontExtractor'), ['foo', 'bar', 'baz']), {'f': 'foo', 'b': 'baz'}, 'create with keys from first letter, removing duplicate') 15 | 16 | call vimtest#Quit() 17 | -------------------------------------------------------------------------------- /tests/dict/t1100-FromKeys.vim: -------------------------------------------------------------------------------- 1 | " Test creating Dict from keys. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(2) 5 | 6 | call vimtap#Is(ingo#dict#FromKeys([], 1), {}, 'create with empty keys') 7 | call vimtap#Is(ingo#dict#FromKeys(['foo', 'bar', 'baz'], 1), {'foo': 1, 'bar': 1, 'baz': 1}, 'create with default value 1') 8 | 9 | call vimtest#Quit() 10 | -------------------------------------------------------------------------------- /tests/dict/t1110-FromKeys-extractor.vim: -------------------------------------------------------------------------------- 1 | " Test creating Dict from keys via extractor. 2 | 3 | let s:count = 0 4 | function! Counter( key ) abort 5 | let s:count += 1 6 | return s:count 7 | endfunction 8 | function! Duplicator( key ) abort 9 | return a:key . a:key 10 | endfunction 11 | 12 | call vimtest#StartTap() 13 | call vimtap#Plan(2) 14 | 15 | call vimtap#Is(ingo#dict#FromKeys(['foo', 'bar', 'baz'], function('Counter')), {'foo': 1, 'bar': 2, 'baz': 3}, 'create with values from counter') 16 | call vimtap#Is(ingo#dict#FromKeys(['foo', 'bar', 'baz'], function('Duplicator')), {'foo': 'foofoo', 'bar': 'barbar', 'baz': 'bazbaz'}, 'create with values as duplicated keys') 17 | 18 | call vimtest#Quit() 19 | -------------------------------------------------------------------------------- /tests/digest/t1010-get-long.vim: -------------------------------------------------------------------------------- 1 | " Test digesting long lists of strings. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(3) 5 | 6 | call vimtap#Is(ingo#digest#Get( 7 | \ [ 8 | \ 'a-long-list-of-various-stuff-and-so-see-here', 9 | \ 'the-long-list-has-various-things-in-here-and-nowhere', 10 | \ 'my-long-list-can-do-various-things-for-here-and-there', 11 | \ ], '\A'), 12 | \ ['-long-list-', '-various-', '-and-', 'here'], 'long list') " Note: 'here' loses its preceding separator because in other items is is grouped together with '-here-and-', so it's missing at that position. 13 | 14 | call vimtap#Is(ingo#digest#Get( 15 | \ [ 16 | \ 'the-long-list-has-various-things-in-here-and-nowhere', 17 | \ 'a-long-list-of-various-stuff-and-so-see-here', 18 | \ 'my-long-list-can-do-various-things-for-here-and-there', 19 | \ ], '\A'), 20 | \ ['-long-list-', '-various-', '-here-and'], 'long list, different ordering') 21 | 22 | call vimtap#Is(ingo#digest#Get( 23 | \ [ 24 | \ 'a-long-list-of-various-stuff-and-so-see-here', 25 | \ 'the-long-list-has-various-things-in-here-and-nowhere', 26 | \ 'my-long-list-can-do-various-things-for-here-and-there', 27 | \ ], '\A', 60), 28 | \ ['-long-list-', '-various-things-', '-here-and-'], 'long list with percentage') 29 | 30 | call vimtest#Quit() 31 | -------------------------------------------------------------------------------- /tests/escape/t1000-CmdlineSpecialEscape.vim: -------------------------------------------------------------------------------- 1 | " Test escaping special cmdline characters. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(7) 5 | 6 | call vimtap#Is(ingo#escape#file#CmdlineSpecialEscape('foo'), 'foo', 'string without special characters is returned as-is') 7 | call vimtap#Is(ingo#escape#file#CmdlineSpecialEscape('%'), '\%', 'standalone % gets escaped') 8 | call vimtap#Is(ingo#escape#file#CmdlineSpecialEscape('this # and ##'), 'this \# and \#\#', '# and ## within a string get escaped') 9 | call vimtap#Is(ingo#escape#file#CmdlineSpecialEscape('.txt'), '\.txt', ' gets escaped') 10 | call vimtap#Is(ingo#escape#file#CmdlineSpecialEscape(''), '\', ' gets escaped') 11 | 12 | call vimtap#Is(ingo#escape#file#CmdlineSpecialEscape('foo/bar and foo\bar'), 'foo/bar and foo\bar', 'string without special characters but spaces and slashes is returned as-is') 13 | call vimtap#Is(ingo#escape#file#CmdlineSpecialEscape('\% and % or \'), '\% and \% or \', 'already escaped stuff does not get escaped') 14 | 15 | call vimtest#Quit() 16 | -------------------------------------------------------------------------------- /tests/file/ipsum.txt: -------------------------------------------------------------------------------- 1 | Suspendisse potenti. Aenean sed velit. Nunc a urna quis turpis imperdiet 2 | sollicitudin. Mauris aliquam mauris ut tortor. Pellentesque tincidunt mattis 3 | nibh. In id lectus eu magna vulputate ultrices. Aliquam interdum varius enim. 4 | Maecenas at mauris. Sed sed nibh. Nam non turpis. Maecenas fermentum ni 5 | -------------------------------------------------------------------------------- /tests/file/lorem.txt: -------------------------------------------------------------------------------- 1 | Dapibus pellentesque. In non lacus. Nullam tristique nunc ut arcu scelerisque 2 | aliquam. Nullam viverra magna vitae leo. Vestibulum in lacus sit amet lectus 3 | tempus aliquet. Duis cursus nisl ac orci. Do 4 | -------------------------------------------------------------------------------- /tests/file/nulla.txt: -------------------------------------------------------------------------------- 1 | Phasellus ipsum odio, suscipit nec, fringilla at, vehicula quis, tellus. 2 | Phasellus gravida condimentum dui. Aenean imperdiet arcu vitae ipsum. Duis 3 | dapibus, nisi non porttitor iaculis, ligula odio sollicitudin mauris, non 4 | luctus nunc massa a velit. Fusce ac nisi. Integer volutpat elementum metus. 5 | Vivamus luctus ultricies diam. Curabitur euismod. Vivamus quam. Nunc ante. 6 | Nulla mi nulla, vehicula!! 7 | -------------------------------------------------------------------------------- /tests/file/t1000-GetLines-uncached.vim: -------------------------------------------------------------------------------- 1 | " Test gettings lines from a file without the cache. 2 | 3 | let g:IngoLibrary_FileCacheMaxSize = 0 4 | 5 | call vimtest#StartTap() 6 | call vimtap#Plan(6) 7 | 8 | call vimtap#Is(len(ingo#file#GetLines('lorem.txt')), 3, 'Get lorem') 9 | call vimtap#Is(ingo#file#GetCachedFilesByAge(), [], 'Nothing cached') 10 | call vimtap#Is(len(ingo#file#GetLines('ipsum.txt')), 4, 'Get ipsum') 11 | call vimtap#Is(len(ingo#file#GetLines('nulla.txt')), 6, 'Get nulla') 12 | call vimtap#Is(len(ingo#file#GetLines('lorem.txt')), 3, 'Get lorem again') 13 | call vimtap#Is(ingo#file#GetCachedFilesByAge(), [], 'Nothing cached') 14 | 15 | call vimtest#Quit() 16 | -------------------------------------------------------------------------------- /tests/file/t1010-GetLines-cached.vim: -------------------------------------------------------------------------------- 1 | " Test gettings lines from a file with a small cache. 2 | 3 | let g:IngoLibrary_FileCacheMaxSize = 600 4 | 5 | function! s:GetCachedFilenamesByAge() 6 | return map(ingo#file#GetCachedFilesByAge(), 'fnamemodify(v:val, ":t:r")') 7 | endfunction 8 | call vimtest#StartTap() 9 | call vimtap#Plan(15) 10 | 11 | call vimtap#Is(len(ingo#file#GetLines('lorem.txt')), 3, 'Get lorem') 12 | call vimtap#Is(s:GetCachedFilenamesByAge(), ['lorem'], 'lorem cached') 13 | 14 | call vimtap#Is(len(ingo#file#GetLines('lorem.txt')), 3, 'Get lorem again') 15 | call vimtap#Is(s:GetCachedFilenamesByAge(), ['lorem'], 'lorem cached') 16 | 17 | sleep 1 18 | call vimtap#Is(len(ingo#file#GetLines('ipsum.txt')), 4, 'Get ipsum') 19 | call vimtap#Is(s:GetCachedFilenamesByAge(), ['lorem', 'ipsum'], 'lorem > ipsum cached') 20 | 21 | sleep 1 22 | call vimtap#Is(len(ingo#file#GetLines('lorem.txt')), 3, 'Get lorem again') 23 | call vimtap#Is(s:GetCachedFilenamesByAge(), ['ipsum', 'lorem'], 'ipsum > lorem cached') 24 | 25 | sleep 1 26 | call vimtap#Is(len(ingo#file#GetLines('nulla.txt')), 6, 'Get nulla') 27 | call vimtap#Is(s:GetCachedFilenamesByAge(), ['lorem', 'nulla'], 'lorem > nulla cached; ipsum got evicted') 28 | 29 | sleep 1 30 | call vimtap#Is(len(ingo#file#GetLines('ipsum.txt')), 4, 'Get ipsum again') 31 | sleep 1 32 | call vimtap#Is(len(ingo#file#GetLines('nulla.txt')), 6, 'Get nulla again') 33 | call vimtap#Is(s:GetCachedFilenamesByAge(), ['nulla'], 'only nulla cached; ipsum got evicted') 34 | 35 | sleep 1 36 | call vimtap#Is(len(ingo#file#GetLines('lorem.txt')), 3, 'Get lorem again') 37 | call vimtap#Is(s:GetCachedFilenamesByAge(), ['nulla', 'lorem'], 'nulla > lorem cached') 38 | 39 | call vimtest#Quit() 40 | -------------------------------------------------------------------------------- /tests/file/t1020-GetLines-cache-too-small.vim: -------------------------------------------------------------------------------- 1 | " Test gettings lines from a file with a too small small cache. 2 | 3 | let g:IngoLibrary_FileCacheMaxSize = 200 4 | 5 | call vimtest#StartTap() 6 | call vimtap#Plan(4) 7 | 8 | call vimtap#Is(len(ingo#file#GetLines('ipsum.txt')), 4, 'Get ipsum') 9 | call vimtap#Is(ingo#file#GetCachedFilesByAge(), [], 'ipsum too large; nothing cached') 10 | 11 | call vimtap#Is(len(ingo#file#GetLines('lorem.txt')), 3, 'Get lorem') 12 | call vimtap#Is(len(ingo#file#GetCachedFilesByAge()), 1, 'lorem cached, it fits the cache') 13 | 14 | call vimtest#Quit() 15 | -------------------------------------------------------------------------------- /tests/file/t1030-GetLines-immutable-cache.vim: -------------------------------------------------------------------------------- 1 | " Test that lines from a file do no modify the cache itself. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(4) 5 | 6 | let s:lines = ingo#file#GetLines('lorem.txt') 7 | let s:firstLine = s:lines[0] 8 | call vimtap#Is(len(ingo#file#GetLines('lorem.txt')), 3, 'Get lorem') 9 | 10 | call remove(s:lines, -1) 11 | let s:lines[0] = 'Changed!' 12 | call vimtap#Is(len(s:lines), 2, 'Removed last line') 13 | 14 | call vimtap#Is(len(ingo#file#GetLines('lorem.txt')), 3, 'Get lorem again still returns three lines') 15 | call vimtap#Is(ingo#file#GetLines('lorem.txt')[0], s:firstLine, 'Get lorem again still returns the original first line') 16 | 17 | call vimtest#Quit() 18 | -------------------------------------------------------------------------------- /tests/file/t1040-GetLines-nonexisting-file.vim: -------------------------------------------------------------------------------- 1 | " Test reading a non-existing file. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(1) 5 | 6 | call vimtap#Is(ingo#file#GetLines('doesnotexist.txt'), [], 'Get non-existing file returns empty List') 7 | 8 | call vimtest#Quit() 9 | -------------------------------------------------------------------------------- /tests/file/t1050-GetLines-cache-update.vim: -------------------------------------------------------------------------------- 1 | " Test getting lines from a file that is updated and then deleted. 2 | 3 | let s:tempfile = tempname() 4 | call writefile(['foo', 'bar'], s:tempfile, 's') 5 | 6 | call vimtest#StartTap() 7 | call vimtap#Plan(4) 8 | 9 | call vimtap#Is(ingo#file#GetLines(s:tempfile), ['foo', 'bar'], 'Get tempfile') 10 | 11 | sleep 1 12 | call writefile(['fox', 'booze', 'more'], s:tempfile, 's') 13 | call vimtap#Is(ingo#file#GetLines(s:tempfile), ['fox', 'booze', 'more'], 'Get updated tempfile') 14 | 15 | sleep 1 16 | if delete(s:tempfile) != 0 17 | call vimtap#BailOut('Failed to delete temp file: ' . s:tempfile) 18 | endif 19 | call vimtap#Is(ingo#file#GetLines(s:tempfile), [], 'Get deleted tempfile returns empty List') 20 | call vimtap#Is(ingo#file#GetCachedFilesByAge(), [], 'Nothing is cached any longer') 21 | 22 | call vimtest#Quit() 23 | -------------------------------------------------------------------------------- /tests/fs/paths/split/t1010-TruncateTo-backslash.vim: -------------------------------------------------------------------------------- 1 | " Test truncation of backslash-separated filespec. 2 | 3 | scriptencoding utf-8 4 | 5 | call vimtest#StartTap() 6 | call vimtap#Plan(2) 7 | let s:longFile = 'C:\tmp\with one of\these\very\loooooong\path\in\there\before\filename.txt' 8 | 9 | call vimtap#Is(ingo#fs#path#split#TruncateTo(s:longFile, 50, '\'), 'C:\tmp\with one of\…\in\there\before\filename.txt', 'drop four directories') 10 | call vimtap#Is(ingo#fs#path#split#TruncateTo(s:longFile, 50, '/'), 'C:\tmp\with one of\these\…here\before\filename.txt', 'truncation as one string with wrong path separator') 11 | 12 | call vimtest#Quit() 13 | -------------------------------------------------------------------------------- /tests/fs/paths/split/t1020-TruncateTo-truncation-indicator.vim: -------------------------------------------------------------------------------- 1 | " Test truncation with custom truncation indicator. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(2) 5 | 6 | let s:longFile = '/tmp/with/this/very/loooooong/path/in/there/before/filename.txt' 7 | call vimtap#Is(ingo#fs#path#split#TruncateTo(s:longFile, 52, '/', ' - '), '/tmp/with/this/ - /path/in/there/before/filename.txt', 'drop three directories') 8 | call vimtap#Is(ingo#fs#path#split#TruncateTo(s:longFile, 52, '/', '........'), '/tmp/with/this/......../in/there/before/filename.txt', 'drop four directories with long truncation indicator') 9 | 10 | call vimtest#Quit() 11 | -------------------------------------------------------------------------------- /tests/fs/paths/t1000-IsPath.vim: -------------------------------------------------------------------------------- 1 | " Test check for path. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(16) 5 | 6 | call vimtap#Is(ingo#fs#path#IsPath(''), 0, 'empty String is not a path') 7 | call vimtap#Is(ingo#fs#path#IsPath(ingo#fs#path#Normalize('foo.txt')), 0, 'foo.txt is not a path') 8 | call vimtap#Is(ingo#fs#path#IsPath(ingo#fs#path#Normalize('./foo.txt')), 0, './foo.txt is not a path') 9 | call vimtap#Is(ingo#fs#path#IsPath(ingo#fs#path#Normalize('../foo.txt')), 1, '../foo.txt is a path') 10 | call vimtap#Is(ingo#fs#path#IsPath(ingo#fs#path#Normalize('./bar/foo.txt')), 1, './bar/foo.txt is a path') 11 | call vimtap#Is(ingo#fs#path#IsPath(ingo#fs#path#Normalize('/bar')), 1, '/bar is a path') 12 | call vimtap#Is(ingo#fs#path#IsPath(ingo#fs#path#Normalize('/bar/')), 1, '/bar/ is a path') 13 | call vimtap#Is(ingo#fs#path#IsPath(ingo#fs#path#Normalize('/bar/foo.txt')), 1, '/bar/foo.txt is a path') 14 | call vimtap#Is(ingo#fs#path#IsPath(ingo#fs#path#Normalize('bar/foo.txt')), 1, 'bar/foo.txt is a path') 15 | call vimtap#Is(ingo#fs#path#IsPath(ingo#fs#path#Normalize('bar/../foo.txt')), 0, 'bar/../foo.txt is not a path') 16 | call vimtap#Is(ingo#fs#path#IsPath(ingo#fs#path#Normalize('boo/bar/../foo.txt')), 1, 'boo/bar/../foo.txt is a path') 17 | 18 | call vimtap#Is(ingo#fs#path#IsPath(ingo#fs#path#Normalize('C:/bar/foo.txt')), 1, 'C:/bar/foo.txt is a path') 19 | call vimtap#Is(ingo#fs#path#IsPath(ingo#fs#path#Normalize('C:/')), 1, 'C:/ is a path') 20 | call vimtap#Is(ingo#fs#path#IsPath(ingo#fs#path#Normalize('/')), 1, '/ is a path') 21 | call vimtap#Is(ingo#fs#path#IsPath(ingo#fs#path#Normalize('..')), 1, '.. is a path') 22 | call vimtap#Is(ingo#fs#path#IsPath(ingo#fs#path#Normalize('.')), 1, '. is a path') 23 | 24 | call vimtest#Quit() 25 | -------------------------------------------------------------------------------- /tests/function/uniquify/t1000-ReturnValue.vim: -------------------------------------------------------------------------------- 1 | " Test unique return values. 2 | 3 | function! TestFunction() 4 | return remove(s:values, 0) 5 | endfunction 6 | 7 | call vimtest#StartTap() 8 | call vimtap#Plan(9) 9 | 10 | let s:values = [1, 2, 3] 11 | call vimtap#Is(ingo#function#uniquify#ReturnValue('t1', 'TestFunction'), 1, 't1 1.') 12 | call vimtap#Is(ingo#function#uniquify#ReturnValue('t1', 'TestFunction'), 2, 't1 2.') 13 | call vimtap#Is(ingo#function#uniquify#ReturnValue('t1', 'TestFunction'), 3, 't1 3.') 14 | 15 | let s:values = [1, 1, 3, 4] 16 | call vimtap#Is(ingo#function#uniquify#ReturnValue('t2', 'TestFunction'), 1, 't2 1.') 17 | call vimtap#Is(ingo#function#uniquify#ReturnValue('t2', 'TestFunction'), 3, 't2 2.') 18 | call vimtap#Is(ingo#function#uniquify#ReturnValue('t2', 'TestFunction'), 4, 't2 3.') 19 | 20 | let s:values = [1, 1, 1, 4, 4, 4, 4, 5] 21 | call vimtap#Is(ingo#function#uniquify#ReturnValue('t3', 'TestFunction'), 1, 't3 1.') 22 | call vimtap#Is(ingo#function#uniquify#ReturnValue('t3', 'TestFunction'), 4, 't3 2.') 23 | call vimtap#Is(ingo#function#uniquify#ReturnValue('t3', 'TestFunction'), 5, 't3 3.') 24 | 25 | call vimtest#Quit() 26 | -------------------------------------------------------------------------------- /tests/function/uniquify/t1010-ReturnValue-scopes.vim: -------------------------------------------------------------------------------- 1 | " Test unique return values with different scopes. 2 | 3 | function! TestFunctionA() 4 | return remove(s:valuesA, 0) 5 | endfunction 6 | function! TestFunctionB() 7 | return remove(s:valuesB, 0) 8 | endfunction 9 | 10 | call vimtest#StartTap() 11 | call vimtap#Plan(6) 12 | 13 | let s:valuesA = [1, 1, 3, 4] 14 | let s:valuesB = [1, 1, 9, 3] 15 | call vimtap#Is(ingo#function#uniquify#ReturnValue('A', 'TestFunctionA'), 1, 'A 1.') 16 | call vimtap#Is(ingo#function#uniquify#ReturnValue('B', 'TestFunctionB'), 1, 'B 1.') 17 | call vimtap#Is(ingo#function#uniquify#ReturnValue('A', 'TestFunctionA'), 3, 'A 2.') 18 | call vimtap#Is(ingo#function#uniquify#ReturnValue('B', 'TestFunctionB'), 9, 'B 2.') 19 | call vimtap#Is(ingo#function#uniquify#ReturnValue('A', 'TestFunctionA'), 4, 'A 3.') 20 | call vimtap#Is(ingo#function#uniquify#ReturnValue('B', 'TestFunctionB'), 3, 'B 3.') 21 | 22 | call vimtest#Quit() 23 | -------------------------------------------------------------------------------- /tests/function/uniquify/t1050-Clear.vim: -------------------------------------------------------------------------------- 1 | " Test clearing records for unique return values. 2 | 3 | function! TestFunction() 4 | return remove(s:values, 0) 5 | endfunction 6 | 7 | call vimtest#StartTap() 8 | call vimtap#Plan(3) 9 | 10 | let s:values = [1, 1, 3, 4] 11 | call vimtap#Is(ingo#function#uniquify#ReturnValue('t1', 'TestFunction'), 1, 't1 1.') 12 | call ingo#function#uniquify#Clear('t1') 13 | call vimtap#Is(ingo#function#uniquify#ReturnValue('t1', 'TestFunction'), 1, 't1 after clear') 14 | call vimtap#Is(ingo#function#uniquify#ReturnValue('t1', 'TestFunction'), 3, 't1 3.') 15 | 16 | call vimtest#Quit() 17 | -------------------------------------------------------------------------------- /tests/function/uniquify/t1060-SetMaxAttempts.vim: -------------------------------------------------------------------------------- 1 | " Test maximum attempts for unique return values. 2 | 3 | function! TestFunction() 4 | return remove(s:values, 0) 5 | endfunction 6 | 7 | call vimtest#StartTap() 8 | call vimtap#Plan(2) 9 | 10 | let s:values = [1, 1, 1, 1, 5] 11 | call ingo#function#uniquify#SetMaxAttempts('t1', 3) 12 | call vimtap#Is(ingo#function#uniquify#ReturnValue('t1', 'TestFunction'), 1, 't1 1.') 13 | call vimtap#err#Throws('ReturnValue: Too many invocations with same return value: 3', 'call ingo#function#uniquify#ReturnValue("t1", "TestFunction")', 'Unique value only after fourth attempt') 14 | 15 | call vimtest#Quit() 16 | -------------------------------------------------------------------------------- /tests/join/t1000-lines-plain.ok: -------------------------------------------------------------------------------- 1 | plain - with space-space separator 2 | plainXXwith XX separator 3 | plain-with - separator 4 | plain with space separator 5 | plainwithout separator 6 | 7 | -------------------------------------------------------------------------------- /tests/join/t1000-lines-plain.vim: -------------------------------------------------------------------------------- 1 | " Test joining of plain unindented lines. 2 | 3 | call append(0, ['plain', 'without separator']) 4 | call ingo#join#Lines(1, 1, '') 5 | 6 | call append(0, ['plain', 'with space separator']) 7 | call ingo#join#Lines(1, 1, ' ') 8 | 9 | call append(0, ['plain', 'with - separator']) 10 | call ingo#join#Lines(1, 1, '-') 11 | 12 | call append(0, ['plain', 'with XX separator']) 13 | call ingo#join#Lines(1, 1, 'XX') 14 | 15 | call append(0, ['plain', 'with space-space separator']) 16 | call ingo#join#Lines(1, 1, ' - ') 17 | 18 | call vimtest#SaveOut() 19 | call vimtest#Quit() 20 | -------------------------------------------------------------------------------- /tests/join/t1010-lines-indented.ok: -------------------------------------------------------------------------------- 1 | softtabstop;; indented with ;; separator 2 | tab;; indented with ;; separator 3 | 4space;; indented with ;; separator 4 | softtabstop indented with space separator 5 | tab indented with space separator 6 | 4space indented with space separator 7 | softtabstop indented 8 | tab indented 9 | 4space indented 10 | 11 | -------------------------------------------------------------------------------- /tests/join/t1010-lines-indented.vim: -------------------------------------------------------------------------------- 1 | " Test joining of indented lines. 2 | 3 | call append(0, ['4space', ' indented']) 4 | call ingo#join#Lines(1, 1, '') 5 | 6 | call append(0, ['tab', "\tindented"]) 7 | call ingo#join#Lines(1, 1, '') 8 | 9 | call append(0, ['softtabstop', "\t indented"]) 10 | call ingo#join#Lines(1, 1, '') 11 | 12 | call append(0, ['4space', ' indented with space separator']) 13 | call ingo#join#Lines(1, 1, ' ') 14 | 15 | call append(0, ['tab', "\tindented with space separator"]) 16 | call ingo#join#Lines(1, 1, ' ') 17 | 18 | call append(0, ['softtabstop', "\t indented with space separator"]) 19 | call ingo#join#Lines(1, 1, ' ') 20 | 21 | call append(0, ['4space', ' indented with ;; separator']) 22 | call ingo#join#Lines(1, 1, ';;') 23 | 24 | call append(0, ['tab', "\tindented with ;; separator"]) 25 | call ingo#join#Lines(1, 1, ';;') 26 | 27 | call append(0, ['softtabstop', "\t indented with ;; separator"]) 28 | call ingo#join#Lines(1, 1, ';;') 29 | 30 | call vimtest#SaveOut() 31 | call vimtest#Quit() 32 | -------------------------------------------------------------------------------- /tests/join/t1015-lines-indented-nokeep.ok: -------------------------------------------------------------------------------- 1 | softtabstop;;indented with ;; separator 2 | tab;;indented with ;; separator 3 | 4space;;indented with ;; separator 4 | softtabstop indented with space separator 5 | tab indented with space separator 6 | 4space indented with space separator 7 | softtabstopindented 8 | tabindented 9 | 4spaceindented 10 | 11 | -------------------------------------------------------------------------------- /tests/join/t1015-lines-indented-nokeep.vim: -------------------------------------------------------------------------------- 1 | " Test joining of indented lines not keeping whitespace. 2 | 3 | call append(0, ['4space', ' indented']) 4 | call ingo#join#Lines(1, 0, '') 5 | 6 | call append(0, ['tab', "\tindented"]) 7 | call ingo#join#Lines(1, 0, '') 8 | 9 | call append(0, ['softtabstop', "\t indented"]) 10 | call ingo#join#Lines(1, 0, '') 11 | 12 | call append(0, ['4space', ' indented with space separator']) 13 | call ingo#join#Lines(1, 0, ' ') 14 | 15 | call append(0, ['tab', "\tindented with space separator"]) 16 | call ingo#join#Lines(1, 0, ' ') 17 | 18 | call append(0, ['softtabstop', "\t indented with space separator"]) 19 | call ingo#join#Lines(1, 0, ' ') 20 | 21 | call append(0, ['4space', ' indented with ;; separator']) 22 | call ingo#join#Lines(1, 0, ';;') 23 | 24 | call append(0, ['tab', "\tindented with ;; separator"]) 25 | call ingo#join#Lines(1, 0, ';;') 26 | 27 | call append(0, ['softtabstop', "\t indented with ;; separator"]) 28 | call ingo#join#Lines(1, 0, ';;') 29 | 30 | call vimtest#SaveOut() 31 | call vimtest#Quit() 32 | -------------------------------------------------------------------------------- /tests/join/t1020-lines-trailing.ok: -------------------------------------------------------------------------------- 1 | softtabstop ;; trailing and indented with ;; separator 2 | tab ;; trailing and indented with ;; separator 3 | 4space ;; trailing and indented with ;; separator 4 | softtabstop trailing and indented with space separator 5 | tab trailing and indented with space separator 6 | 4space trailing and indented with space separator 7 | softtabstop trailing and indented 8 | tab trailing and indented 9 | 4space trailing and indented 10 | 11 | -------------------------------------------------------------------------------- /tests/join/t1020-lines-trailing.vim: -------------------------------------------------------------------------------- 1 | " Test joining of lines with trailing whitespace and indentation. 2 | 3 | call append(0, ['4space ', ' trailing and indented']) 4 | call ingo#join#Lines(1, 1, '') 5 | 6 | call append(0, ["tab\t", "\ttrailing and indented"]) 7 | call ingo#join#Lines(1, 1, '') 8 | 9 | call append(0, ['softtabstop ', " \t trailing and indented"]) 10 | call ingo#join#Lines(1, 1, '') 11 | 12 | call append(0, ['4space ', ' trailing and indented with space separator']) 13 | call ingo#join#Lines(1, 1, ' ') 14 | 15 | call append(0, ["tab\t", "\ttrailing and indented with space separator"]) 16 | call ingo#join#Lines(1, 1, ' ') 17 | 18 | call append(0, ['softtabstop ', " \t trailing and indented with space separator"]) 19 | call ingo#join#Lines(1, 1, ' ') 20 | 21 | call append(0, ['4space ', ' trailing and indented with ;; separator']) 22 | call ingo#join#Lines(1, 1, ';;') 23 | 24 | call append(0, ["tab\t", "\ttrailing and indented with ;; separator"]) 25 | call ingo#join#Lines(1, 1, ';;') 26 | 27 | call append(0, ['softtabstop ', " \t trailing and indented with ;; separator"]) 28 | call ingo#join#Lines(1, 1, ';;') 29 | 30 | call vimtest#SaveOut() 31 | call vimtest#Quit() 32 | -------------------------------------------------------------------------------- /tests/join/t1025-lines-trailing-nokeep.ok: -------------------------------------------------------------------------------- 1 | softtabstop;;trailing and indented with ;; separator 2 | tab;;trailing and indented with ;; separator 3 | 4space;;trailing and indented with ;; separator 4 | softtabstop trailing and indented with space separator 5 | tab trailing and indented with space separator 6 | 4space trailing and indented with space separator 7 | softtabstoptrailing and indented 8 | tabtrailing and indented 9 | 4spacetrailing and indented 10 | 11 | -------------------------------------------------------------------------------- /tests/join/t1025-lines-trailing-nokeep.vim: -------------------------------------------------------------------------------- 1 | " Test joining of lines with trailing whitespace and indentation not keeping whitespace. 2 | 3 | call append(0, ['4space ', ' trailing and indented']) 4 | call ingo#join#Lines(1, 0, '') 5 | 6 | call append(0, ["tab\t", "\ttrailing and indented"]) 7 | call ingo#join#Lines(1, 0, '') 8 | 9 | call append(0, ['softtabstop ', " \t trailing and indented"]) 10 | call ingo#join#Lines(1, 0, '') 11 | 12 | call append(0, ['4space ', ' trailing and indented with space separator']) 13 | call ingo#join#Lines(1, 0, ' ') 14 | 15 | call append(0, ["tab\t", "\ttrailing and indented with space separator"]) 16 | call ingo#join#Lines(1, 0, ' ') 17 | 18 | call append(0, ['softtabstop ', " \t trailing and indented with space separator"]) 19 | call ingo#join#Lines(1, 0, ' ') 20 | 21 | call append(0, ['4space ', ' trailing and indented with ;; separator']) 22 | call ingo#join#Lines(1, 0, ';;') 23 | 24 | call append(0, ["tab\t", "\ttrailing and indented with ;; separator"]) 25 | call ingo#join#Lines(1, 0, ';;') 26 | 27 | call append(0, ['softtabstop ', " \t trailing and indented with ;; separator"]) 28 | call ingo#join#Lines(1, 0, ';;') 29 | 30 | call vimtest#SaveOut() 31 | call vimtest#Quit() 32 | -------------------------------------------------------------------------------- /tests/join/t1030-lines-with-empty.ok: -------------------------------------------------------------------------------- 1 | softtabstop 2 | tab 3 | 4space 4 | plain 5 | 6 | -------------------------------------------------------------------------------- /tests/join/t1030-lines-with-empty.vim: -------------------------------------------------------------------------------- 1 | " Test joining of lines with following empty line. 2 | 3 | call append(0, ['plain', '']) 4 | call ingo#join#Lines(1, 1, '') 5 | 6 | call append(0, ['4space ', '']) 7 | call ingo#join#Lines(1, 1, '') 8 | 9 | call append(0, ["tab\t", '']) 10 | call ingo#join#Lines(1, 1, '') 11 | 12 | call append(0, ['softtabstop ', '']) 13 | call ingo#join#Lines(1, 1, '') 14 | 15 | call vimtest#SaveOut() 16 | call vimtest#Quit() 17 | -------------------------------------------------------------------------------- /tests/join/t1035-lines-with-empty-nokeep.ok: -------------------------------------------------------------------------------- 1 | softtabstop 2 | tab 3 | 4space 4 | plain 5 | 6 | -------------------------------------------------------------------------------- /tests/join/t1035-lines-with-empty-nokeep.vim: -------------------------------------------------------------------------------- 1 | " Test joining of lines with following empty line not keeping whitespace. 2 | 3 | call append(0, ['plain', '']) 4 | call ingo#join#Lines(1, 0, '') 5 | 6 | call append(0, ['4space ', '']) 7 | call ingo#join#Lines(1, 0, '') 8 | 9 | call append(0, ["tab\t", '']) 10 | call ingo#join#Lines(1, 0, '') 11 | 12 | call append(0, ['softtabstop ', '']) 13 | call ingo#join#Lines(1, 0, '') 14 | 15 | call vimtest#SaveOut() 16 | call vimtest#Quit() 17 | -------------------------------------------------------------------------------- /tests/join/t1040-lines-at-end.ok: -------------------------------------------------------------------------------- 1 | 2 | plain 3 | 4space 4 | tab 5 | softtabstop 6 | -------------------------------------------------------------------------------- /tests/join/t1040-lines-at-end.vim: -------------------------------------------------------------------------------- 1 | " Test joining of lines at end of buffer. 2 | " Tests that trailing whitespace is kept, as no join takes place. 3 | 4 | call append(line('$'), ['plain']) 5 | call ingo#join#Lines(line('$'), 1, '') 6 | 7 | call append(line('$'), ['4space ']) 8 | call ingo#join#Lines(line('$'), 1, '') 9 | 10 | call append(line('$'), ["tab\t"]) 11 | call ingo#join#Lines(line('$'), 1, '') 12 | 13 | call append(line('$'), ['softtabstop ']) 14 | call ingo#join#Lines(line('$'), 1, '') 15 | 16 | call vimtest#SaveOut() 17 | call vimtest#Quit() 18 | -------------------------------------------------------------------------------- /tests/join/t1045-lines-at-end-nokeep.ok: -------------------------------------------------------------------------------- 1 | 2 | plain 3 | 4space 4 | tab 5 | softtabstop 6 | -------------------------------------------------------------------------------- /tests/join/t1045-lines-at-end-nokeep.vim: -------------------------------------------------------------------------------- 1 | " Test joining of lines at end of buffer not keeping whitespace. 2 | " Tests that trailing whitespace is kept, as no join takes place. 3 | 4 | call append(line('$'), ['plain']) 5 | call ingo#join#Lines(line('$'), 0, '') 6 | 7 | call append(line('$'), ['4space ']) 8 | call ingo#join#Lines(line('$'), 0, '') 9 | 10 | call append(line('$'), ["tab\t"]) 11 | call ingo#join#Lines(line('$'), 0, '') 12 | 13 | call append(line('$'), ['softtabstop ']) 14 | call ingo#join#Lines(line('$'), 0, '') 15 | 16 | call vimtest#SaveOut() 17 | call vimtest#Quit() 18 | -------------------------------------------------------------------------------- /tests/join/t1050-lines-closing-paren.ok: -------------------------------------------------------------------------------- 1 | softtabstop ;;) parenthesis with ;; separator 2 | tab ;;) parenthesis with ;; separator 3 | 4space ;;) parenthesis with ;; separator 4 | plain;;) parenthesis with ;; separator 5 | softtabstop ) indented parenthesis 6 | tab ) indented parenthesis 7 | 4space ) indented parenthesis 8 | plain ) indented parenthesis 9 | softtabstop ) parenthesis 10 | tab ) parenthesis 11 | 4space ) parenthesis 12 | plain) parenthesis 13 | 14 | -------------------------------------------------------------------------------- /tests/join/t1050-lines-closing-paren.vim: -------------------------------------------------------------------------------- 1 | " Test joining of lines with closing parenthesis. 2 | 3 | call append(0, ['plain', ') parenthesis']) 4 | call ingo#join#Lines(1, 1, '') 5 | 6 | call append(0, ['4space ', ') parenthesis']) 7 | call ingo#join#Lines(1, 1, '') 8 | 9 | call append(0, ["tab\t", ') parenthesis']) 10 | call ingo#join#Lines(1, 1, '') 11 | 12 | call append(0, ['softtabstop ', ') parenthesis']) 13 | call ingo#join#Lines(1, 1, '') 14 | 15 | 16 | call append(0, ['plain', ' ) indented parenthesis']) 17 | call ingo#join#Lines(1, 1, '') 18 | 19 | call append(0, ['4space ', ' ) indented parenthesis']) 20 | call ingo#join#Lines(1, 1, '') 21 | 22 | call append(0, ["tab\t", "\t) indented parenthesis"]) 23 | call ingo#join#Lines(1, 1, '') 24 | 25 | call append(0, ['softtabstop ', "\t ) indented parenthesis"]) 26 | call ingo#join#Lines(1, 1, '') 27 | 28 | 29 | call append(0, ['plain', ') parenthesis with ;; separator']) 30 | call ingo#join#Lines(1, 1, ';;') 31 | 32 | call append(0, ['4space ', ') parenthesis with ;; separator']) 33 | call ingo#join#Lines(1, 1, ';;') 34 | 35 | call append(0, ["tab\t", ') parenthesis with ;; separator']) 36 | call ingo#join#Lines(1, 1, ';;') 37 | 38 | call append(0, ['softtabstop ', ') parenthesis with ;; separator']) 39 | call ingo#join#Lines(1, 1, ';;') 40 | 41 | call vimtest#SaveOut() 42 | call vimtest#Quit() 43 | -------------------------------------------------------------------------------- /tests/join/t1055-lines-closing-paren-nokeep.ok: -------------------------------------------------------------------------------- 1 | softtabstop;;) parenthesis with ;; separator 2 | tab;;) parenthesis with ;; separator 3 | 4space;;) parenthesis with ;; separator 4 | plain;;) parenthesis with ;; separator 5 | softtabstop) indented parenthesis 6 | tab) indented parenthesis 7 | 4space) indented parenthesis 8 | plain) indented parenthesis 9 | softtabstop) parenthesis 10 | tab) parenthesis 11 | 4space) parenthesis 12 | plain) parenthesis 13 | 14 | -------------------------------------------------------------------------------- /tests/join/t1055-lines-closing-paren-nokeep.vim: -------------------------------------------------------------------------------- 1 | " Test joining of lines with closing parenthesis. 2 | 3 | call append(0, ['plain', ') parenthesis']) 4 | call ingo#join#Lines(1, 0, '') 5 | 6 | call append(0, ['4space ', ') parenthesis']) 7 | call ingo#join#Lines(1, 0, '') 8 | 9 | call append(0, ["tab\t", ') parenthesis']) 10 | call ingo#join#Lines(1, 0, '') 11 | 12 | call append(0, ['softtabstop ', ') parenthesis']) 13 | call ingo#join#Lines(1, 0, '') 14 | 15 | 16 | call append(0, ['plain', ' ) indented parenthesis']) 17 | call ingo#join#Lines(1, 0, '') 18 | 19 | call append(0, ['4space ', ' ) indented parenthesis']) 20 | call ingo#join#Lines(1, 0, '') 21 | 22 | call append(0, ["tab\t", "\t) indented parenthesis"]) 23 | call ingo#join#Lines(1, 0, '') 24 | 25 | call append(0, ['softtabstop ', "\t ) indented parenthesis"]) 26 | call ingo#join#Lines(1, 0, '') 27 | 28 | 29 | call append(0, ['plain', ') parenthesis with ;; separator']) 30 | call ingo#join#Lines(1, 0, ';;') 31 | 32 | call append(0, ['4space ', ') parenthesis with ;; separator']) 33 | call ingo#join#Lines(1, 0, ';;') 34 | 35 | call append(0, ["tab\t", ') parenthesis with ;; separator']) 36 | call ingo#join#Lines(1, 0, ';;') 37 | 38 | call append(0, ['softtabstop ', ') parenthesis with ;; separator']) 39 | call ingo#join#Lines(1, 0, ';;') 40 | 41 | call vimtest#SaveOut() 42 | call vimtest#Quit() 43 | -------------------------------------------------------------------------------- /tests/join/t1060-lines-return-value.vim: -------------------------------------------------------------------------------- 1 | " Test return value from joining of lines. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(2) 5 | 6 | call append(0, ['plain', 'next']) 7 | call vimtap#Is(ingo#join#Lines(1, 1, ''), 1, 'plain join successful') 8 | 9 | call append(line('$'), ['plain']) 10 | call vimtap#Is(ingo#join#Lines(line('$'), 1, ''), 0, 'cannot join at last line') 11 | 12 | call vimtest#Quit() 13 | -------------------------------------------------------------------------------- /tests/list/lcs/t1000-FindLongestCommon.vim: -------------------------------------------------------------------------------- 1 | " Test find longest common substrings. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(6) 5 | 6 | call vimtap#Is(ingo#list#lcs#FindLongestCommon( 7 | \ ['foobar', 'fooxy', 'foobitch']), 8 | \ 'foo', 9 | \ 'one common at front' 10 | \) 11 | call vimtap#Is(ingo#list#lcs#FindLongestCommon( 12 | \ ['myfoo', 'thefoo', 'theyfoo']), 13 | \ 'foo', 14 | \ 'one common at end' 15 | \) 16 | call vimtap#Is(ingo#list#lcs#FindLongestCommon( 17 | \ ['myfoobar', 'thefooxy', 'theyfoobitch']), 18 | \ 'foo', 19 | \ 'one common in middle' 20 | \) 21 | 22 | call vimtap#Is(ingo#list#lcs#FindLongestCommon( 23 | \ ['metfooforbarbi', 'havefootobasil', 'gotfooinbasin']), 24 | \ 'foo', 25 | \ 'longer common before shorter' 26 | \) 27 | call vimtap#Is(ingo#list#lcs#FindLongestCommon( 28 | \ ['barbigetfoofor', 'basilgivefooto', 'basingotfooin']), 29 | \ 'foo', 30 | \ 'longer common after shorter' 31 | \) 32 | call vimtap#Is(ingo#list#lcs#FindLongestCommon( 33 | \ ['basbigetfoofor', 'basilgivefooto', 'basingotfooin']), 34 | \ 'bas', 35 | \ 'same length common prefers first' 36 | \) 37 | 38 | call vimtest#Quit() 39 | -------------------------------------------------------------------------------- /tests/list/lcs/t1010-FindLongestCommon-minimumLength.vim: -------------------------------------------------------------------------------- 1 | " Test find longest common substrings with a mimimum length. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(2) 5 | 6 | call vimtap#Is(ingo#list#lcs#FindLongestCommon( 7 | \ ['myfoobar', 'thefooxy', 'theyfoobitch'], 3), 8 | \ 'foo', 9 | \ 'minimumLength reached' 10 | \) 11 | call vimtap#Is(ingo#list#lcs#FindLongestCommon( 12 | \ ['myfoobar', 'thefooxy', 'theyfoobitch'], 4), 13 | \ '', 14 | \ 'minimumLength missed' 15 | \) 16 | 17 | call vimtest#Quit() 18 | -------------------------------------------------------------------------------- /tests/list/lcs/t1030-FindLongestCommon-ignoreCase.vim: -------------------------------------------------------------------------------- 1 | " Test find longest common substrings case-insensitive. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(4) 5 | 6 | call vimtap#Is(ingo#list#lcs#FindLongestCommon( 7 | \ ['Foobar', 'fooxy', 'FOObitch'], 1, 1), 8 | \ 'Foo', 9 | \ 'one common at front, first capitalization' 10 | \) 11 | call vimtap#Is(ingo#list#lcs#FindLongestCommon( 12 | \ ['myFOO', 'theFoo', 'theyfoo'], 1, 1), 13 | \ 'FOO', 14 | \ 'one common at end, first capitalization' 15 | \) 16 | call vimtap#Is(ingo#list#lcs#FindLongestCommon( 17 | \ ['myFoObar', 'thefOoxy', 'theyfOObitch'], 1, 1), 18 | \ 'FoO', 19 | \ 'one common in middle, first capitalization' 20 | \) 21 | 22 | call vimtap#Is(ingo#list#lcs#FindLongestCommon( 23 | \ ['myfoobar', 'thefooxy', 'theyfoobitch']), 24 | \ 'foo', 25 | \ 'one common same capitalization in middle' 26 | \) 27 | 28 | call vimtest#Quit() 29 | -------------------------------------------------------------------------------- /tests/list/lcs/t2000-FindAllCommon.vim: -------------------------------------------------------------------------------- 1 | " Test find all common substrings. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(6) 5 | 6 | call vimtap#Is(ingo#list#lcs#FindAllCommon( 7 | \ ['foobar', 'fooxy', 'foobitch']), 8 | \ [[[], ['bar', 'xy', 'bitch']], ['foo']], 9 | \ 'one common at front' 10 | \) 11 | call vimtap#Is(ingo#list#lcs#FindAllCommon( 12 | \ ['myfoo', 'thefoo', 'theyfoo']), 13 | \ [[['my', 'the', 'they'], []], ['foo']], 14 | \ 'one common at end' 15 | \) 16 | call vimtap#Is(ingo#list#lcs#FindAllCommon( 17 | \ ['myfoobar', 'thefooxy', 'theyfoobitch']), 18 | \ [[['my', 'the', 'they'], ['bar', 'xy', 'bitch']], ['foo']], 19 | \ 'one common in middle' 20 | \) 21 | 22 | call vimtap#Is(ingo#list#lcs#FindAllCommon( 23 | \ ['metfooforbarby', 'havefootobasil', 'gotfooinbasin']), 24 | \ [[['met', 'have', 'got'], ['for', 'to', 'in'], ['rby', 'sil', 'sin']], ['foo', 'ba']], 25 | \ 'longer common before shorter' 26 | \) 27 | call vimtap#Is(ingo#list#lcs#FindAllCommon( 28 | \ ['barbygetfoofor', 'basilgivefooto', 'basingotfooin']), 29 | \ [[[], ['rby', 'sil', 'sin'], ['et', 'ive', 'ot'], ['for', 'to', 'in']], ['ba', 'g', 'foo']], 30 | \ 'longer common after shorter' 31 | \) 32 | call vimtap#Is(ingo#list#lcs#FindAllCommon( 33 | \ ['basbygetfoofor', 'basilgivefooto', 'basingotfooin']), 34 | \ [[[], ['by', 'il', 'in'], ['et', 'ive', 'ot'], ['for', 'to', 'in']], ['bas', 'g', 'foo']], 35 | \ 'same length common prefers first' 36 | \) 37 | 38 | call vimtest#Quit() 39 | -------------------------------------------------------------------------------- /tests/list/lcs/t2010-FindAllCommon-minimumCommon.vim: -------------------------------------------------------------------------------- 1 | " Test find all common substrings with a minimum length. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(3) 5 | 6 | call vimtap#Is(ingo#list#lcs#FindAllCommon( 7 | \ ['myfoobar', 'thefooxy', 'theyfoobitch'], 3), 8 | \ [[['my', 'the', 'they'], ['bar', 'xy', 'bitch']], ['foo']], 9 | \ 'minimumCommonLength reached' 10 | \) 11 | call vimtap#Is(ingo#list#lcs#FindAllCommon( 12 | \ ['myfoobar', 'thefooxy', 'theyfoobitch'], 4), 13 | \ [[['myfoobar', 'thefooxy', 'theyfoobitch']], []], 14 | \ 'minimumCommonLength missed' 15 | \) 16 | 17 | call vimtap#Is(ingo#list#lcs#FindAllCommon( 18 | \ ['metfooforbarby', 'havefootobasil', 'gotfooinbasin'], 3), 19 | \ [[['met', 'have', 'got'], ['forbarby', 'tobasil', 'inbasin']], ['foo']], 20 | \ 'minimumCommonLength filters out shorter' 21 | \) 22 | 23 | call vimtest#Quit() 24 | -------------------------------------------------------------------------------- /tests/list/lcs/t2030-FindAllCommon-ignoreCase.vim: -------------------------------------------------------------------------------- 1 | " Test find all common substrings case-insensitive. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(4) 5 | 6 | call vimtap#Is(ingo#list#lcs#FindAllCommon( 7 | \ ['Foobar', 'fooxy', 'FOObitch'], 1, 0, 1), 8 | \ [[[], ['bar', 'xy', 'bitch']], ['Foo']], 9 | \ 'one common at front, first capitalization' 10 | \) 11 | call vimtap#Is(ingo#list#lcs#FindAllCommon( 12 | \ ['myFOO', 'theFoo', 'theyfoo'], 1, 0, 1), 13 | \ [[['my', 'the', 'they'], []], ['FOO']], 14 | \ 'one common at end, first capitalization' 15 | \) 16 | call vimtap#Is(ingo#list#lcs#FindAllCommon( 17 | \ ['myFoObar', 'thefOoxy', 'theyfOObitch'], 1, 0, 1), 18 | \ [[['my', 'the', 'they'], ['bar', 'xy', 'bitch']], ['FoO']], 19 | \ 'one common in middle, first capitalization' 20 | \) 21 | 22 | call vimtap#Is(ingo#list#lcs#FindAllCommon( 23 | \ ['foobar', 'fooxy', 'foobitch'], 1, 0, 1), 24 | \ [[[], ['bar', 'xy', 'bitch']], ['foo']], 25 | \ 'one common same capitalization at front' 26 | \) 27 | 28 | call vimtest#Quit() 29 | -------------------------------------------------------------------------------- /tests/list/pattern/t1000-AllItemsMatch.vim: -------------------------------------------------------------------------------- 1 | " Test AllItemsMatch. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(8) 5 | 6 | call vimtap#Is(ingo#list#pattern#AllItemsMatch(['x'], 'x'), 1, 'single element is exact') 7 | call vimtap#Is(ingo#list#pattern#AllItemsMatch(['x'], 'Y'), 0, 'single element is different') 8 | 9 | call vimtap#Is(ingo#list#pattern#AllItemsMatch([1, 2, 3], '^.$'), 1, 'small digits are all single character') 10 | call vimtap#Is(ingo#list#pattern#AllItemsMatch([1, 22, 3], '^.$'), 0, 'digits are not all single character') 11 | call vimtap#Is(ingo#list#pattern#AllItemsMatch([11, 22, 33], '^.$'), 0, 'no digits are single character') 12 | 13 | call vimtap#Is(ingo#list#pattern#AllItemsMatch(['foo', 'fox', 'fozzy'], 'fo'), 1, 'all contain fo') 14 | call vimtap#Is(ingo#list#pattern#AllItemsMatch(['foo', 'fox', 'fozzy'], '\(.\)\1'), 0, 'all contain doubled character') 15 | 16 | call vimtap#Is(ingo#list#pattern#AllItemsMatch([], '^.$'), 1, 'empty list') 17 | 18 | call vimtest#Quit() 19 | -------------------------------------------------------------------------------- /tests/list/pattern/t1100-FirstMatchIndex.vim: -------------------------------------------------------------------------------- 1 | " Test FirstMatchIndex. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(3) 5 | 6 | call vimtap#Is(ingo#list#pattern#FirstMatchIndex(['foo', 'fox', 'fozzy'], 'o[^o]'), 1, 'return first of two matching indices') 7 | call vimtap#Is(ingo#list#pattern#FirstMatchIndex(['foo', 'fox', 'fozzy'], 'noMatch'), -1, 'no matches return -1') 8 | call vimtap#Is(ingo#list#pattern#FirstMatchIndex([], '^'), -1, 'empty list with matching pattern returns -1') 9 | 10 | call vimtest#Quit() 11 | -------------------------------------------------------------------------------- /tests/list/pattern/t1110-FirstMatch.vim: -------------------------------------------------------------------------------- 1 | " Test FirstMatch. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(3) 5 | 6 | call vimtap#Is(ingo#list#pattern#FirstMatch(['foo', 'fox', 'fozzy'], 'o[^o]'), 'fox', 'return first of two matches') 7 | call vimtap#Is(ingo#list#pattern#FirstMatch(['foo', 'fox', 'fozzy'], 'noMatch'), '', 'no matches return empty String') 8 | call vimtap#Is(ingo#list#pattern#FirstMatch(['foo', 'fox', 'fozzy'], 'noMatch', 42), 42, 'no matches return custom noMatchValue') 9 | 10 | call vimtest#Quit() 11 | -------------------------------------------------------------------------------- /tests/list/pattern/t1200-AllMatchIndices.vim: -------------------------------------------------------------------------------- 1 | " Test AllMatchIndices. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(3) 5 | 6 | call vimtap#Is(ingo#list#pattern#AllMatchIndices(['foo', 'fox', 'fozzy'], 'o[^o]'), [1, 2], 'return two matching indices') 7 | call vimtap#Is(ingo#list#pattern#AllMatchIndices(['foo', 'fox', 'fozzy'], 'noMatch'), [], 'no matches return empty List') 8 | call vimtap#Is(ingo#list#pattern#AllMatchIndices([], '^'), [], 'empty list with matching pattern returns empty List') 9 | 10 | call vimtest#Quit() 11 | -------------------------------------------------------------------------------- /tests/list/pattern/t1210-AllMatches.vim: -------------------------------------------------------------------------------- 1 | " Test AllMatches. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(3) 5 | 6 | call vimtap#Is(ingo#list#pattern#AllMatches(['foo', 'fox', 'fozzy'], 'o[^o]'), ['fox', 'fozzy'], 'return two matches') 7 | call vimtap#Is(ingo#list#pattern#AllMatches(['foo', 'fox', 'fozzy'], 'noMatch'), [], 'no matches return empty List') 8 | 9 | let s:list = ['foo', 'fox', 'fozzy'] 10 | let s:inputList = copy(s:list) 11 | call ingo#list#pattern#AllMatches(s:inputList, 'o[^o]') 12 | call vimtap#Is(s:inputList, s:list, 'the original List is left untouched') 13 | 14 | call vimtest#Quit() 15 | -------------------------------------------------------------------------------- /tests/list/sequence/t1010-FindCharacter.vim: -------------------------------------------------------------------------------- 1 | " Test find character sequences. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(11) 5 | 6 | call vimtap#Is(ingo#list#sequence#FindCharacter([]), [0, 0], 'empty list') 7 | call vimtap#Is(ingo#list#sequence#FindCharacter(['a']), [0, 0], 'single element list') 8 | call vimtap#Is(ingo#list#sequence#FindCharacter(['a', 123, 'c']), [0, 0], 'non-character element list') 9 | call vimtap#Is(ingo#list#sequence#FindCharacter(['a', 'foo', 'c']), [0, 0], 'non-single-character element list') 10 | 11 | call vimtap#Is(ingo#list#sequence#FindCharacter(['b', 'c']), [2, 1], 'b, c list') 12 | call vimtap#Is(ingo#list#sequence#FindCharacter(['c', 'i']), [2, 6], 'c, i list') 13 | call vimtap#Is(ingo#list#sequence#FindCharacter(['b', 'c', 'd']), [3, 1], 'b, c, d list') 14 | call vimtap#Is(ingo#list#sequence#FindCharacter(['c', 'e', 'g', 'i']), [4, 2], 'c, e, g, i list') 15 | 16 | call vimtap#Is(ingo#list#sequence#FindCharacter(['b', 'c', 'e']), [2, 1], 'b, c list with additional e') 17 | call vimtap#Is(ingo#list#sequence#FindCharacter(['c', 'e', 'g', 'i', 'f', 'z']), [4, 2], 'c, e, g, i list with additional f, z') 18 | 19 | call vimtap#Is(ingo#list#sequence#FindCharacter(['1', 3, '5']), [3, 2], 'list with number') 20 | 21 | call vimtest#Quit() 22 | -------------------------------------------------------------------------------- /tests/list/split/t1000-RemoveFromStartWhilePredicate.vim: -------------------------------------------------------------------------------- 1 | " Test split off elements from the start with predicate. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(14) 5 | 6 | let g:list = [] | call vimtap#Is(ingo#list#split#RemoveFromStartWhilePredicate(g:list, '0'), [], 'nothing removed from empty list') | call vimtap#Is(g:list, [], 'unchanged source list') 7 | let g:list = [] | call vimtap#Is(ingo#list#split#RemoveFromStartWhilePredicate(g:list, '1'), [], 'nothing removed from empty list') | call vimtap#Is(g:list, [], 'unchanged source list') 8 | 9 | let g:list = [1, 2, 3] | call vimtap#Is(ingo#list#split#RemoveFromStartWhilePredicate(g:list, '0'), [], 'nothing removed from list') | call vimtap#Is(g:list, [1, 2, 3], 'unchanged source list') 10 | let g:list = [1, 2, 3] | call vimtap#Is(ingo#list#split#RemoveFromStartWhilePredicate(g:list, '1'), [1, 2, 3], 'everything removed from list') | call vimtap#Is(g:list, [], 'emptied source list') 11 | 12 | let g:list = [1, 2, 3] | call vimtap#Is(ingo#list#split#RemoveFromStartWhilePredicate(g:list, 'v:val <= 2'), [1, 2], 'two elements removed from list with expression') | call vimtap#Is(g:list, [3], 'last element left in source list') 13 | function! MyPredicate( value ) 14 | return (a:value <= 2) 15 | endfunction 16 | let g:list = [1, 2, 3] | call vimtap#Is(ingo#list#split#RemoveFromStartWhilePredicate(g:list, function('MyPredicate')), [1, 2], 'two elements removed from list with Funcref') | call vimtap#Is(g:list, [3], 'last element left in source list') 17 | 18 | let g:list = [1, 2, 2, 3, 2, 1] | call vimtap#Is(ingo#list#split#RemoveFromStartWhilePredicate(g:list, 'v:val <= 2'), [1, 2, 2], 'three elements removed from list with expression, later matches are ignored') | call vimtap#Is(g:list, [3, 2, 1], 'elements left in source list') 19 | 20 | call vimtest#Quit() 21 | -------------------------------------------------------------------------------- /tests/list/t1000-AddNonEmpty.vim: -------------------------------------------------------------------------------- 1 | " Test add non-empty items. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(7) 5 | 6 | let s:list = [] 7 | call vimtap#Is(ingo#list#AddNonEmpty(s:list, ''), [], 'Add empty String to empty List gives empty List') 8 | call vimtap#Is(ingo#list#AddNonEmpty(s:list, []), [], 'Add empty List to empty List gives empty List') 9 | call vimtap#Is(ingo#list#AddNonEmpty(s:list, ['']), [['']], 'Add List with empty String to empty List') 10 | call vimtap#Is(ingo#list#AddNonEmpty(s:list, 42), [[''], 42], 'Add 42') 11 | call vimtap#Is(ingo#list#AddNonEmpty(s:list, 'foobar'), [[''], 42, 'foobar'], 'Add foobar') 12 | 13 | let s:originalList = s:list 14 | call vimtap#Ok(ingo#list#AddNonEmpty(s:list, '') is# s:originalList, 'Add empty String to List gives same List') 15 | call vimtap#Is(ingo#list#AddNonEmpty(s:list, [[]]), [[''], 42, 'foobar', [[]]], 'Add List with empty List') 16 | 17 | call vimtest#Quit() 18 | -------------------------------------------------------------------------------- /tests/lists/t1000-StartsWith.vim: -------------------------------------------------------------------------------- 1 | " Test StartsWith. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(11) 5 | 6 | call vimtap#Is(ingo#lists#StartsWith([1, 2, 3], []), 1, 'list starts with empty sublist') 7 | call vimtap#Is(ingo#lists#StartsWith([1, 2, 3], [1]), 1, 'list starts with same first element') 8 | call vimtap#Is(ingo#lists#StartsWith([1, 2, 3], [1, 2]), 1, 'list starts with same first elements') 9 | call vimtap#Is(ingo#lists#StartsWith([1, 2, 3], [1, 2, 3]), 1, 'list is identical with sublist') 10 | call vimtap#Is(ingo#lists#StartsWith([1, 2, 3], [1, 9]), 0, 'sublist differs in second element') 11 | call vimtap#Is(ingo#lists#StartsWith([1, 2, 3], [1, 2, 3, 4]), 0, 'sublist has more elements than list') 12 | call vimtap#Is(ingo#lists#StartsWith([1, 2, 3], [9, 7, 5]), 0, 'sublist has different elements') 13 | call vimtap#Is(ingo#lists#StartsWith([1, 2, 3], ['a']), 0, 'sublist has different elements') 14 | 15 | call vimtap#Is(ingo#lists#StartsWith(['a', 'b', 'c'], ['a', 'b'], 0), 1, 'case-sensistive comparison with identical cases') 16 | call vimtap#Is(ingo#lists#StartsWith(['a', 'b', 'c'], ['a', 'B'], 0), 0, 'case-sensistive comparison with different case in second element') 17 | call vimtap#Is(ingo#lists#StartsWith(['a', 'b', 'c'], ['a', 'B'], 1), 1, 'case-insensistive comparison with different case in second element') 18 | 19 | call vimtest#Quit() 20 | -------------------------------------------------------------------------------- /tests/lnum/t1000-AddOffsetWithWrapping.vim: -------------------------------------------------------------------------------- 1 | " Test adding offsets with wrap-around. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(12) 5 | 6 | call vimtap#Is(ingo#lnum#AddOffsetWithWrapping(2, 1, 10), 3, 'simple add') 7 | call vimtap#Is(ingo#lnum#AddOffsetWithWrapping(2, 7, 10), 9, 'simple add') 8 | call vimtap#Is(ingo#lnum#AddOffsetWithWrapping(2, 8, 10), 10, 'simple add to max') 9 | call vimtap#Is(ingo#lnum#AddOffsetWithWrapping(2, 9, 10), 1, 'wrap-around') 10 | call vimtap#Is(ingo#lnum#AddOffsetWithWrapping(2, 13, 10), 5, 'more wrap-around') 11 | call vimtap#Is(ingo#lnum#AddOffsetWithWrapping(2, 23, 10), 5, 'wrap-around twice') 12 | 13 | call vimtap#Is(ingo#lnum#AddOffsetWithWrapping(5, -3, 10), 2, 'subtract') 14 | call vimtap#Is(ingo#lnum#AddOffsetWithWrapping(2, -1, 10), 1, 'subtract to min') 15 | call vimtap#Is(ingo#lnum#AddOffsetWithWrapping(2, -2, 10), 10, 'wrap-around') 16 | call vimtap#Is(ingo#lnum#AddOffsetWithWrapping(2, -3, 10), 9, 'more wrap-around') 17 | call vimtap#Is(ingo#lnum#AddOffsetWithWrapping(2, -13, 10), 9, 'wrap-around twice') 18 | call vimtap#Is(ingo#lnum#AddOffsetWithWrapping(2, -23, 10), 9, 'wrap-around thrice') 19 | 20 | call vimtest#Quit() 21 | -------------------------------------------------------------------------------- /tests/matches/t1000-Any.vim: -------------------------------------------------------------------------------- 1 | " Test matching any pattern. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(6) 5 | 6 | call vimtap#Is(ingo#matches#Any('foobar', []), 1, 'matches no patterns') 7 | call vimtap#Is(ingo#matches#Any('foobar', ['xy']), 0, 'does not match only pattern xy') 8 | call vimtap#Is(ingo#matches#Any('foobar', ['o\+']), 1, 'matches only pattern o\+') 9 | call vimtap#Is(ingo#matches#Any('foobar', ['o\+', 'xy', '^.\{6}$']), 1, 'matches first pattern o\+') 10 | call vimtap#Is(ingo#matches#Any('foobar', ['xy', 'o\+', '^.\{6}$']), 1, 'matches second pattern o\+') 11 | call vimtap#Is(ingo#matches#Any('foobar', ['xy', 'X\+', '^.\{6}$']), 1, 'matches last pattern ^.\{6}$') 12 | 13 | call vimtest#Quit() 14 | -------------------------------------------------------------------------------- /tests/matches/t1010-All.vim: -------------------------------------------------------------------------------- 1 | " Test matching all patterns. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(5) 5 | 6 | call vimtap#Is(ingo#matches#All('foobar', []), 1, 'matches no patterns') 7 | call vimtap#Is(ingo#matches#All('foobar', ['xy']), 0, 'does not match only pattern xy') 8 | call vimtap#Is(ingo#matches#All('foobar', ['o\+']), 1, 'matches only pattern o\+') 9 | call vimtap#Is(ingo#matches#All('foobar', ['o\+', 'xy', '^.\{6}$']), 0, 'does not match second pattern') 10 | call vimtap#Is(ingo#matches#All('foobar', ['^[fF]', 'o\+', '^.\{6}$']), 1, 'matches all three patterns') 11 | 12 | call vimtest#Quit() 13 | -------------------------------------------------------------------------------- /tests/matches/t2000-CountMatches.vim: -------------------------------------------------------------------------------- 1 | " Test counting matches in text. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(6) 5 | 6 | call vimtap#Is(ingo#matches#CountMatches('foobar', ''), 7, 'matches before / after every character with empty pattern') 7 | call vimtap#Is(ingo#matches#CountMatches('', 'o\+'), 0, 'no matches with empty text') 8 | call vimtap#Is(ingo#matches#CountMatches('our house is foobar', 'o\+'), 3, '3 occurrences of o\+ in String') 9 | call vimtap#Is(ingo#matches#CountMatches(['our', 'house', 'is', 'foobar'], 'o\+'), 3, '3 occurrences of o\+ in List') 10 | call vimtap#Is(ingo#matches#CountMatches('our house is foobar', '.*'), 1, '1 occurrence of .* with String') 11 | call vimtap#Is(ingo#matches#CountMatches(['our', 'house', 'is', 'foobar', ''], '.*'), 5, '5 of .* in 5-element List') 12 | 13 | call vimtest#Quit() 14 | -------------------------------------------------------------------------------- /tests/option/listchars/t1000-GetValue.vim: -------------------------------------------------------------------------------- 1 | " Test getting listchars values. 2 | 3 | set listchars=precedes:<,extends:>,tab:>-,trail:.,eol:$ 4 | 5 | call vimtest#StartTap() 6 | call vimtap#Plan(5) 7 | 8 | call vimtap#Is(ingo#option#listchars#GetValue('precedes'), '<', 'precedes element value') 9 | call vimtap#Is(ingo#option#listchars#GetValue('tab'), '>-', 'tab element 2-character value') 10 | call vimtap#Is(ingo#option#listchars#GetValue('eol'), '$', 'eol element value') 11 | call vimtap#Is(ingo#option#listchars#GetValue('space'), '', 'space element missing value') 12 | call vimtap#Is(ingo#option#listchars#GetValue('doesnotexist'), '', 'doesnotexist element missing value') 13 | 14 | call vimtest#Quit() 15 | -------------------------------------------------------------------------------- /tests/option/listchars/t1010-GetValues.vim: -------------------------------------------------------------------------------- 1 | " Test getting listchars values. 2 | 3 | set listchars=precedes:<,extends:>,tab:>-,trail:.,eol:$ 4 | 5 | call vimtest#StartTap() 6 | call vimtap#Plan(1) 7 | 8 | call vimtap#Is(ingo#option#listchars#GetValues(), {'precedes': '<', 'extends': '>', 'tab': '>-', 'trail': '.', 'eol': '$'}, 'listchars Dict') 9 | 10 | call vimtest#Quit() 11 | -------------------------------------------------------------------------------- /tests/option/listchars/t1110-Render-3char-tab.vim: -------------------------------------------------------------------------------- 1 | " Test rendering listchar tab value with three characters. 2 | 3 | call vimtest#SkipAndQuitIf(v:version < 801 || v:version == 801 && ! has('patch759'), 'Need support for three-character listchar tab setting') 4 | 5 | set listchars=tab:<->,eol:$ 6 | 7 | call vimtest#StartTap() 8 | call vimtap#Plan(5) 9 | 10 | call vimtap#Is(ingo#option#listchars#Render("\t\t some text\t", {'isTextAtEnd': 1}), '<------><------> some text<------>$', 'tab text rendered at end') 11 | call vimtap#Is(ingo#option#listchars#Render("\t\t some text\t", {'isTextAtEnd': 1, 'tabWidth': 4}), '<--><--> some text<-->$', 'tab text with shorter tab width 4') 12 | call vimtap#Is(ingo#option#listchars#Render("\t\t some text\t", {'isTextAtEnd': 1, 'tabWidth': 3}), '<-><-> some text<->$', 'tab text with shorter tab width 3') 13 | call vimtap#Is(ingo#option#listchars#Render("\t\t some text\t", {'isTextAtEnd': 1, 'tabWidth': 2}), '<><> some text<>$', 'tab text with tab width 2') 14 | call vimtap#Is(ingo#option#listchars#Render("\t\t some text\t", {'isTextAtEnd': 1, 'tabWidth': 1}), '>> some text>$', 'tab text with tab width 1') 15 | 16 | call vimtest#Quit() 17 | -------------------------------------------------------------------------------- /tests/option/listchars/t1120-Render-lead.vim: -------------------------------------------------------------------------------- 1 | " Test rendering listchar lead value. 2 | 3 | call vimtest#SkipAndQuitIf(v:version < 802 || v:version == 802 && ! has('patch2454'), 'Need support for listchar lead setting') 4 | 5 | set listchars=tab:>-,lead:^,space:-,trail:.,eol:$ 6 | 7 | call vimtest#StartTap() 8 | call vimtap#Plan(3) 9 | 10 | call vimtap#Is(ingo#option#listchars#Render(' some text here '), '----some-text----here----', 'space rendered') 11 | call vimtap#Is(ingo#option#listchars#Render(' some text here ', {'isTextAtStart': 1}), '^^^^some-text----here----', 'lead and space rendered') 12 | call vimtap#Is(ingo#option#listchars#Render(' some text here ', {'isTextAtStart': 1, 'isTextAtEnd': 1}), '^^^^some-text----here....$', 'lead, space, trail, and eol rendered') 13 | 14 | call vimtest#Quit() 15 | -------------------------------------------------------------------------------- /tests/option/listchars/t1120-Render-multibyte.vim: -------------------------------------------------------------------------------- 1 | " Test rendering listchar tab value with three characters. 2 | scriptencoding utf-8 3 | 4 | call vimtest#SkipAndQuitIf(&encoding !=# 'utf-8', 'Need Unicode encoding') 5 | 6 | set listchars=precedes:<,extends:>,tab:»·,trail:¬,eol:¶,nbsp:× 7 | 8 | call vimtest#StartTap() 9 | call vimtap#Plan(1) 10 | 11 | call vimtap#Is(ingo#option#listchars#Render("\t\t some text\t", 1), '»·······»······· some text»·······¶', 'text rendered at end') 12 | 13 | call vimtest#Quit() 14 | -------------------------------------------------------------------------------- /tests/option/listchars/t1130-Render-override-listchars.vim: -------------------------------------------------------------------------------- 1 | " Test rendering with a passed listchars Dictionary. 2 | 3 | set listchars=tab:>-,eol:$ 4 | 5 | call vimtest#StartTap() 6 | call vimtap#Plan(1) 7 | 8 | call vimtap#Is(ingo#option#listchars#Render("\t\t some text\t", 1, {'listchars': {'tab': '^I', 'eol': '^J'}}), '^IIIIIII^IIIIIII some text^IIIIIII^J', 'text rendered at end') 9 | 10 | call vimtest#Quit() 11 | -------------------------------------------------------------------------------- /tests/option/listchars/t1140-Render-fallback.vim: -------------------------------------------------------------------------------- 1 | " Test rendering with fallback. 2 | 3 | set listchars=eol:$ 4 | 5 | call vimtest#StartTap() 6 | call vimtap#Plan(1) 7 | 8 | call vimtap#Is(ingo#option#listchars#Render("\t\t some text\t", 1, {'listchars': {'eol': '^J'}, 'fallback': {'tab': '^I'}}), '^I^I some text^I^J', 'text rendered at end') 9 | 10 | call vimtest#Quit() 11 | -------------------------------------------------------------------------------- /tests/range/merge/t1000-FromLnums.vim: -------------------------------------------------------------------------------- 1 | " Test merging of line numbers. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(2) 5 | 6 | let s:source = [1, 2, 3, 6, 8, 9, 10, 10, 11, 19, 18, 20, 15, 16, 20, 21, 22, 24, 23, 25] 7 | let s:expected = [[1, 3], [6, 6], [8, 11], [15, 16], [18, 25]] 8 | 9 | call vimtap#Is(ingo#range#merge#FromLnums(s:source), s:expected, 'merge of List of line numbers') 10 | call vimtap#Is(ingo#range#merge#FromLnums(ingo#collections#ToDict(s:source)), s:expected, 'merge of Dict of line numbers') 11 | 12 | call vimtest#Quit() 13 | -------------------------------------------------------------------------------- /tests/range/merge/t1100-Merge.vim: -------------------------------------------------------------------------------- 1 | " Test merging of ranges. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(1) 5 | 6 | call vimtap#Is(ingo#range#merge#Merge([[1, 3], [6, 6], [8, 10], [10, 11], [18, 20], [15, 16], [20, 25]]), [[1, 3], [6, 6], [8, 11], [15, 16], [18, 25]], 'merge of ranges') 7 | 8 | call vimtest#Quit() 9 | -------------------------------------------------------------------------------- /tests/range/sort/t1000-AscendingByStartLnum.vim: -------------------------------------------------------------------------------- 1 | " Test sorting of ranges. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(4) 5 | 6 | call vimtap#Is(ingo#range#sort#AscendingByStartLnum([]), [], 'sorting empty List') 7 | call vimtap#Is(ingo#range#sort#AscendingByStartLnum([[3, 3], [2, 7]]), [[2, 7], [3, 3]], 'sorting two ranges') 8 | call vimtap#Is(ingo#range#sort#AscendingByStartLnum([[2, 7], [2, 1]]), [[2, 7], [2, 1]], 'sorting just considers start line number, not end') 9 | call vimtap#Is(ingo#range#sort#AscendingByStartLnum([[2, 18], [3, 3], [2, 7]]), [[2, 18], [2, 7], [3, 3]], 'sorting three ranges') 10 | 11 | call vimtest#Quit() 12 | -------------------------------------------------------------------------------- /tests/regexp/capture/t1000-MakeCapturing.vim: -------------------------------------------------------------------------------- 1 | " Test conversion of capturing groups into non-capturing ones. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(4) 5 | 6 | call vimtap#Is(ingo#regexp#capture#MakeNonCapturing('^\(foo\|ba\(r\|la\|lo\)\)-\(no\%(hi\)\?\)'), '^\%(foo\|ba\%(r\|la\|lo\)\)-\%(no\%(hi\)\?\)', 'make all non-capturing') 7 | call vimtap#Is(ingo#regexp#capture#MakeNonCapturing('^\(foo\|ba\(r\|la\|lo\)\)-\(no\%(hi\)\?\)', [0, 2]), '^\%(foo\|ba\(r\|la\|lo\)\)-\%(no\%(hi\)\?\)', 'make some non-capturing') 8 | 9 | call vimtap#Is(ingo#regexp#capture#MakeCapturing('^\%(foo\|ba\%(r\|la\|lo\)\)-\%(no\(hi\)\?\)'), '^\(foo\|ba\(r\|la\|lo\)\)-\(no\(hi\)\?\)', 'make all capturing') 10 | call vimtap#Is(ingo#regexp#capture#MakeCapturing('^\%(foo\|ba\%(r\|la\|lo\)\)-\%(no\(hi\)\?\)', [0, 2]), '^\(foo\|ba\%(r\|la\|lo\)\)-\(no\(hi\)\?\)', 'make some capturing') 11 | 12 | call vimtest#Quit() 13 | -------------------------------------------------------------------------------- /tests/regexp/collection/t1000-ToBranches.vim: -------------------------------------------------------------------------------- 1 | " Test conversion of a collection to branches. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(7) 5 | 6 | call vimtap#Is(ingo#regexp#collection#ToBranches(''), '', 'empty pattern') 7 | call vimtap#Is(ingo#regexp#collection#ToBranches('^foo bar$'), '^foo bar$', 'no collection') 8 | call vimtap#Is(ingo#regexp#collection#ToBranches('[abcAZ]'), '\%(a\|b\|c\|A\|Z\)', 'simple five-character collection') 9 | call vimtap#Is(ingo#regexp#collection#ToBranches('My [xy] is \([yY]\?\|ey\)'), 'My \%(x\|y\) is \(\%(y\|Y\)\?\|ey\)', 'two simple collections') 10 | call vimtap#Is(ingo#regexp#collection#ToBranches('[abc[:digit:]xyz[:space:][:lower:]]'), '\%(a\|b\|c\|[[:digit:]]\|x\|y\|z\|[[:space:]]\|[[:lower:]]\)', 'collection with multiple character classes') 11 | call vimtap#Is(ingo#regexp#collection#ToBranches('[abcA-EU-Zxyz<->]'), '\%(a\|b\|c\|[A-E]\|[U-Z]\|x\|y\|z\|[<->]\)', 'collection with multiple ranges') 12 | call vimtap#Is(ingo#regexp#collection#ToBranches('[^abc]'), '[^abc]', 'negative collection') 13 | 14 | call vimtest#Quit() 15 | -------------------------------------------------------------------------------- /tests/regexp/collection/t1100-Expr.vim: -------------------------------------------------------------------------------- 1 | " Test parsing of collections. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(6) 5 | 6 | call vimtap#Is(substitute('f[^[:lower:]]oob[[:alpha:]]ar[[:space:][:xdigit:]]', ingo#regexp#collection#Expr(), '', 'g'), 'foobar', 'collection classes') 7 | 8 | call vimtap#Is(substitute('f\k\kbar', ingo#regexp#collection#Expr(), '', 'g'), 'f\k\kbar', 'a character class') 9 | call vimtap#Is(substitute('fo[abcopq]!', ingo#regexp#collection#Expr(), '', 'g'), 'fo!', 'simple collection') 10 | call vimtap#Is(substitute('fo[[:alnum:]xyz][^a-z]!', ingo#regexp#collection#Expr(), '', 'g'), 'fo!', 'multiple collections') 11 | call vimtap#Is(substitute('fo\_[abcopq]!', ingo#regexp#collection#Expr(), '', 'g'), 'fo!', 'collection including EOL') 12 | 13 | call vimtap#Is(substitute('[[]foo[]]b[a]r[^!]', ingo#regexp#collection#Expr(), '', 'g'), 'foobr', 'single-literal collections') 14 | 15 | call vimtest#Quit() 16 | -------------------------------------------------------------------------------- /tests/regexp/deconstruct/t1000-RemovePositionAtoms.vim: -------------------------------------------------------------------------------- 1 | " Test removing position atoms. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(7) 5 | 6 | call vimtap#Is(ingo#regexp#deconstruct#RemovePositionAtoms('foobar'), 'foobar', 'no position atoms') 7 | call vimtap#Is(ingo#regexp#deconstruct#RemovePositionAtoms('fo\{1,10}bar\? .* l\([aeiou]\)ll\1'), 'fo\{1,10}bar\? .* l\([aeiou]\)ll\1', 'only various other atoms') 8 | call vimtap#Is(ingo#regexp#deconstruct#RemovePositionAtoms('^fo\+bar$'), 'fo\+bar', 'beginning and end of line atoms') 9 | call vimtap#Is(ingo#regexp#deconstruct#RemovePositionAtoms('\'), 'foobar', 'beginning and end of word atoms') 10 | call vimtap#Is(ingo#regexp#deconstruct#RemovePositionAtoms('\%^file\%$'), 'file', 'beginning and end of file atoms') 11 | call vimtap#Is(ingo#regexp#deconstruct#RemovePositionAtoms('the \%Vfoo\%V here'), 'the foo here', 'two visual area atoms') 12 | call vimtap#Is(ingo#regexp#deconstruct#RemovePositionAtoms('found \%10l\%>2chere\s.*\%<20v\%>''x'), 'found here\s.*', 'various line, column, mark atoms') 13 | 14 | call vimtest#Quit() 15 | -------------------------------------------------------------------------------- /tests/regexp/deconstruct/t1100-RemoveMultis.vim: -------------------------------------------------------------------------------- 1 | " Test removing multis. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(4) 5 | 6 | call vimtap#Is(ingo#regexp#deconstruct#RemoveMultis('foobar'), 'foobar', 'no multis') 7 | call vimtap#Is(ingo#regexp#deconstruct#RemoveMultis('fo\{1,10}bar\? .* l\([aeiou]\)ll\1'), 'fobar . l\([aeiou]\)ll\1', '\? * \{} multis') 8 | call vimtap#Is(ingo#regexp#deconstruct#RemoveMultis('fo\{-}ba\{-1}r\{-,10} \{2,7}x\\{1,2}'), 'fobar x\\{1,2}', 'various \{} multis') 9 | call vimtap#Is(ingo#regexp#deconstruct#RemoveMultis('a\@<= foo\(bar\)\@=bar'), 'a foo\(bar\)bar', '\@= multis') 10 | 11 | call vimtest#Quit() 12 | -------------------------------------------------------------------------------- /tests/regexp/deconstruct/t2000-UnescapeSpecialCharacters.vim: -------------------------------------------------------------------------------- 1 | " Test unescaping of special characters. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(6) 5 | 6 | call vimtap#Is(ingo#regexp#deconstruct#UnescapeSpecialCharacters('foobar'), 'foobar', 'no special characters') 7 | call vimtap#Is(ingo#regexp#deconstruct#UnescapeSpecialCharacters('^foo[bar]$'), '^foo[bar]$', 'keep regular atoms') 8 | 9 | call vimtap#Is(ingo#regexp#deconstruct#UnescapeSpecialCharacters('\^foo\[bar\]\$'), '^foo[bar]$', 'literal ^[]$') 10 | call vimtap#Is(ingo#regexp#deconstruct#UnescapeSpecialCharacters('f\~o\.\.\.b\*r'), 'f~o...b*r', 'literal ~.*') 11 | call vimtap#Is(ingo#regexp#deconstruct#UnescapeSpecialCharacters('/foo\\bar\\\\'), '/foo\bar\\', 'literal \') 12 | 13 | call vimtap#Is(ingo#regexp#deconstruct#UnescapeSpecialCharacters('\tfoo\r\nbar\e\e'), "\tfoo\r\nbar\e\e", 'special escape sequences') 14 | call vimtap#Is(ingo#regexp#deconstruct#UnescapeSpecialCharacters('\~\~fox\bob\\ar\*\*'), "~~fox\bob\\ar**", 'literals and escape sequences') 15 | 16 | call vimtest#Quit() 17 | -------------------------------------------------------------------------------- /tests/regexp/deconstruct/t3000-ToQuasiLiteral.vim: -------------------------------------------------------------------------------- 1 | " Test converting to somewhat literal text. 2 | 3 | scriptencoding utf-8 4 | 5 | call vimtest#StartTap() 6 | call vimtap#Plan(9) 7 | 8 | call vimtap#Is(ingo#regexp#deconstruct#ToQuasiLiteral('foobar'), 'foobar', 'no regexp, already literal text') 9 | call vimtap#Is(ingo#regexp#deconstruct#ToQuasiLiteral('fo*bar\?$'), 'fobar', 'simple regexp') 10 | call vimtap#Is(ingo#regexp#deconstruct#ToQuasiLiteral('^\'), 'fo…(bar|hos)', 'medium-complexity regexp') 11 | call vimtap#Is(ingo#regexp#deconstruct#ToQuasiLiteral('^\%10lfo\{1,10}\~bar\?\n.*\t\$'), "fo~bar\n•\tl(…)ll", 'complex regexp') 12 | call vimtap#Is(ingo#regexp#deconstruct#ToQuasiLiteral('/a\*b\[cdef\]g\\'), '/a*b[cdef]g\', 'escaped special characters') 13 | call vimtap#Is(ingo#regexp#deconstruct#ToQuasiLiteral('f\(oo\)b\([aeiou]\)r-\1\2'), 'f(oo)b(…)r-', 'regexp with capture groups and references to them') 14 | call vimtap#Is(ingo#regexp#deconstruct#ToQuasiLiteral('fo\zsob\zear'), 'foobar', 'regexp with \zs...\ze match limiting') 15 | call vimtap#Is(ingo#regexp#deconstruct#ToQuasiLiteral('f.*x\_.\+bar'), 'f•x•bar', 'regexp with . and \_.') 16 | call vimtap#Is(ingo#regexp#deconstruct#ToQuasiLiteral('\%#=0\V\Cfoo\n\mbar'), "foo\nbar", 'regexp with \%#=0, \V\C\m') 17 | 18 | call vimtest#Quit() 19 | -------------------------------------------------------------------------------- /tests/regexp/deconstruct/t4000-TranslateCharacterClasses.vim: -------------------------------------------------------------------------------- 1 | " Test removing character classes and similar. 2 | 3 | scriptencoding utf-8 4 | 5 | call vimtest#StartTap() 6 | call vimtap#Plan(11) 7 | 8 | call vimtap#Is(ingo#regexp#deconstruct#TranslateCharacterClasses('foobar'), 'foobar', 'no character classes') 9 | call vimtap#Is(ingo#regexp#deconstruct#TranslateCharacterClasses('\i\I\k\K\f\F\p\P\s\S\d\D\x\X\o\O\w\W\h\H\a\A\l\L\u\U'), '𝑖𝐼𝑘𝐾𝑓𝐹𝑝𝑃𝑠𝑆𝑑𝐷𝑥𝑋𝑜𝑂𝑤𝑊𝑕𝐻𝑎𝐴𝑙𝐿𝑢𝑈', 'all character classes') 10 | call vimtap#Is(ingo#regexp#deconstruct#TranslateCharacterClasses('[^[:lower:]]oo[[:alpha:]]ar[[:space:][:xdigit:]]'), '𝐿oo𝑎ar…', 'collection classes') 11 | 12 | call vimtap#Is(ingo#regexp#deconstruct#TranslateCharacterClasses('f\k\kbar'), 'f𝑘𝑘bar', 'a character class') 13 | call vimtap#Is(ingo#regexp#deconstruct#TranslateCharacterClasses('fo[abcopq]!'), 'fo…!', 'simple collection') 14 | call vimtap#Is(ingo#regexp#deconstruct#TranslateCharacterClasses('fo[[:alnum:]xyz][^a-z]!'), 'fo……!', 'multiple collections') 15 | call vimtap#Is(ingo#regexp#deconstruct#TranslateCharacterClasses('fo\_[abcopq]!'), 'fo…!', 'collection including EOL') 16 | 17 | call vimtap#Is(ingo#regexp#deconstruct#TranslateCharacterClasses('[[]foo[]]b[a]r[^!]'), '[foo]bar…', 'single-literal collections') 18 | 19 | call vimtap#Is(ingo#regexp#deconstruct#TranslateCharacterClasses('foo\%[bar]quux'), 'foobarquux', 'optional sequence') 20 | call vimtap#Is(ingo#regexp#deconstruct#TranslateCharacterClasses('r\%[[eo]ad]'), "r…ad", 'optional sequence with character class inside') 21 | call vimtap#Is(ingo#regexp#deconstruct#TranslateCharacterClasses('index\%[[[]0[]]]'), 'index[0]', 'optional sequence with square brackets') 22 | 23 | call vimtest#Quit() 24 | -------------------------------------------------------------------------------- /tests/regexp/deconstruct/t4100-RemoveCharacterClasses.vim: -------------------------------------------------------------------------------- 1 | " Test removing character classes and similar. 2 | 3 | scriptencoding utf-8 4 | 5 | call vimtest#StartTap() 6 | call vimtap#Plan(11) 7 | 8 | call vimtap#Is(ingo#regexp#deconstruct#RemoveCharacterClasses('foobar'), 'foobar', 'no character classes') 9 | call vimtap#Is(ingo#regexp#deconstruct#RemoveCharacterClasses('\i\I\k\K\f\F\p\P\s\S\d\D\x\X\o\O\w\W\h\H\a\A\l\L\u\U'), '', 'all character classes') 10 | call vimtap#Is(ingo#regexp#deconstruct#RemoveCharacterClasses('[^[:lower:]]oo[[:alpha:]]ar[[:space:][:xdigit:]]'), 'ooar', 'collection classes') 11 | 12 | call vimtap#Is(ingo#regexp#deconstruct#RemoveCharacterClasses('f\k\kbar'), 'fbar', 'a character class') 13 | call vimtap#Is(ingo#regexp#deconstruct#RemoveCharacterClasses('fo[abcopq]!'), 'fo!', 'simple collection') 14 | call vimtap#Is(ingo#regexp#deconstruct#RemoveCharacterClasses('fo[[:alnum:]xyz][^a-z]!'), 'fo!', 'multiple collections') 15 | call vimtap#Is(ingo#regexp#deconstruct#RemoveCharacterClasses('fo\_[abcopq]!'), 'fo!', 'collection including EOL') 16 | 17 | call vimtap#Is(ingo#regexp#deconstruct#RemoveCharacterClasses('[[]foo[]]b[a]r[^!]'), '[foo]bar', 'single-literal collections') 18 | 19 | call vimtap#Is(ingo#regexp#deconstruct#RemoveCharacterClasses('foo\%[bar]quux'), 'foobarquux', 'optional sequence') 20 | call vimtap#Is(ingo#regexp#deconstruct#RemoveCharacterClasses('r\%[[eo]ad]'), "rad", 'optional sequence with character class inside') 21 | call vimtap#Is(ingo#regexp#deconstruct#RemoveCharacterClasses('index\%[[[]0[]]]'), 'index[0]', 'optional sequence with square brackets') 22 | 23 | call vimtest#Quit() 24 | -------------------------------------------------------------------------------- /tests/regexp/deconstruct/t5000-TranslateNumberEscapes.vim: -------------------------------------------------------------------------------- 1 | " Test translating numbered escapes. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(6) 5 | 6 | call vimtap#Is(ingo#regexp#deconstruct#TranslateNumberEscapes('foobar'), 'foobar', 'no character classes') 7 | call vimtap#Is(ingo#regexp#deconstruct#TranslateNumberEscapes('fo\%d120bar'), 'foxbar', 'decimal escape') 8 | call vimtap#Is(ingo#regexp#deconstruct#TranslateNumberEscapes('fo\%o170bar'), 'foxbar', 'octal escape') 9 | call vimtap#Is(ingo#regexp#deconstruct#TranslateNumberEscapes('fo\%x78bar\%x2e'), 'foxbar.', 'hex escapes') 10 | call vimtap#Is(ingo#regexp#deconstruct#TranslateNumberEscapes('\%u20ac\%u269B'), "\u20ac\u269b", 'unicode BMP escapes') 11 | call vimtap#Is(ingo#regexp#deconstruct#TranslateNumberEscapes('\%U1F4A5'), "\U1f4a5", 'unicode non-BMP escape') 12 | 13 | call vimtest#Quit() 14 | -------------------------------------------------------------------------------- /tests/regexp/deconstruct/t6000-TranslateBranches.vim: -------------------------------------------------------------------------------- 1 | " Test translating branches. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(4) 5 | 6 | call vimtap#Is(ingo#regexp#deconstruct#TranslateBranches('foobar'), 'foobar', 'no group') 7 | call vimtap#Is(ingo#regexp#deconstruct#TranslateBranches('\\(foo(bar)\\)'), '\\(foo(bar)\\)', 'no group') 8 | call vimtap#Is(ingo#regexp#deconstruct#TranslateBranches('my\(foo\|bar\)z'), 'my(foo|bar)z', 'translate capture group') 9 | call vimtap#Is(ingo#regexp#deconstruct#TranslateBranches('my\%(fo\(o\|u\|xy\)\|bar\)z'), 'my(fo(o|u|xy)|bar)z', 'translate mixed nested groups') 10 | 11 | call vimtest#Quit() 12 | -------------------------------------------------------------------------------- /tests/regexp/length/t1000-Project-basic.vim: -------------------------------------------------------------------------------- 1 | " Test estimation of matched characters. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(6) 5 | 6 | call vimtap#Is(ingo#regexp#length#Project(''), [0, 0], 'empty pattern') 7 | call vimtap#Is(ingo#regexp#length#Project('a'), [1, 1], 'single literal character') 8 | call vimtap#Is(ingo#regexp#length#Project('abc'), [3, 3], '3-character literal word') 9 | 10 | call vimtap#Is(ingo#regexp#length#Project('a\|xyz'), [1, 3], 'two literal branches') 11 | call vimtap#Is(ingo#regexp#length#Project('abc\|z'), [1, 3], 'two literal branches') 12 | call vimtap#Is(ingo#regexp#length#Project('a\|fghijklm\|xyz'), [1, 8], 'three literal branches') 13 | 14 | call vimtest#Quit() 15 | -------------------------------------------------------------------------------- /tests/regexp/length/t1010-Project-multis.vim: -------------------------------------------------------------------------------- 1 | " Test estimation of matched character multiple times with various multis. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(18) 5 | 6 | call vimtap#Is(ingo#regexp#length#Project('a*'), [0, 0x7FFFFFFF], '* multi') 7 | call vimtap#Is(ingo#regexp#length#Project('a\+'), [1, 0x7FFFFFFF], '\+ multi') 8 | call vimtap#Is(ingo#regexp#length#Project('a\?'), [0, 1], '\? multi') 9 | call vimtap#Is(ingo#regexp#length#Project('a\{2,5}'), [2, 5], '\{n,m} multi') 10 | call vimtap#Is(ingo#regexp#length#Project('a\{3}'), [3, 3], '\{n} multi') 11 | call vimtap#Is(ingo#regexp#length#Project('a\{3,}'), [3, 0x7FFFFFFF], '\{n,} multi') 12 | call vimtap#Is(ingo#regexp#length#Project('a\{,3}'), [0, 3], '\{,n} multi') 13 | call vimtap#Is(ingo#regexp#length#Project('a\{}'), [0, 0x7FFFFFFF], '\{} multi') 14 | call vimtap#Is(ingo#regexp#length#Project('a\{-2,5}'), [2, 5], '\{-n,m} multi') 15 | call vimtap#Is(ingo#regexp#length#Project('a\{-3}'), [3, 3], '\{-n} multi') 16 | call vimtap#Is(ingo#regexp#length#Project('a\{-3,}'), [3, 0x7FFFFFFF], '\{-n,} multi') 17 | call vimtap#Is(ingo#regexp#length#Project('a\{-,3}'), [0, 3], '\{-,n} multi') 18 | call vimtap#Is(ingo#regexp#length#Project('a\{-}'), [0, 0x7FFFFFFF], '\{-} multi') 19 | 20 | call vimtap#Is(ingo#regexp#length#Project('a\@>'), [1, 1], '\@> multi') 21 | call vimtap#Is(ingo#regexp#length#Project('a\@='), [0, 0], '\@= multi') 22 | call vimtap#Is(ingo#regexp#length#Project('a\@!'), [0, 0], '\@! multi') 23 | call vimtap#Is(ingo#regexp#length#Project('a\@<='), [0, 0], '\@<= multi') 24 | call vimtap#Is(ingo#regexp#length#Project('a\@'), [3, 3], '3-character keyword') 7 | call vimtap#Is(ingo#regexp#length#Project('^abc$'), [3, 3], '3-character anchored line') 8 | call vimtap#Is(ingo#regexp#length#Project('\%>10l\%<80vword\%$'), [4, 4], '4-character position-anchored word') 9 | 10 | call vimtap#Is(ingo#regexp#length#Project('foo\.\.\.'), [6, 6], 'word with ellipsis') 11 | call vimtap#Is(ingo#regexp#length#Project('\tThis is\tit\n'), [12, 12], 'sentence with tabs and newline') 12 | call vimtap#Is(ingo#regexp#length#Project('/\~-\~-\*-\*\\'), [9, 9], 'mix of escaped special characters') 13 | 14 | call vimtest#Quit() 15 | -------------------------------------------------------------------------------- /tests/regexp/length/t1040-Project-collection.vim: -------------------------------------------------------------------------------- 1 | " Test estimation of matched characters in patterns with collections. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(4) 5 | 6 | call vimtap#Is(ingo#regexp#length#Project('ab[cdef]'), [3, 3], 'word with one collection') 7 | call vimtap#Is(ingo#regexp#length#Project('[Aa]b\_[cdef]'), [3, 3], 'word with two collections, one the EOL variant') 8 | call vimtap#Is(ingo#regexp#length#Project('[Aa][Bc][Cc]'), [3, 3], 'three concatenated collections') 9 | 10 | call vimtap#Is(ingo#regexp#length#Project('ab\[cdef\]'), [8, 8], 'word with escaped collection characters') 11 | 12 | call vimtest#Quit() 13 | -------------------------------------------------------------------------------- /tests/regexp/length/t1050-Project-global-flags.vim: -------------------------------------------------------------------------------- 1 | " Test estimation of matched characters in patterns with global flags. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(4) 5 | 6 | call vimtap#Is(ingo#regexp#length#Project('\cfoo'), [3, 3], 'word with case-insensitive flag') 7 | call vimtap#Is(ingo#regexp#length#Project('\cf\Co\co\C'), [3, 3], 'word with multiple case-[in]sensitive flags') 8 | 9 | call vimtap#Is(ingo#regexp#length#Project('\%#=2foo'), [3, 3], 'word with regexp engine type flag') 10 | call vimtap#Is(ingo#regexp#length#Project('\%#=2\cfoo'), [3, 3], 'word with regexp engine type and case-insensitive flags') 11 | 12 | call vimtest#Quit() 13 | -------------------------------------------------------------------------------- /tests/regexp/length/t1090-Project-combinations.vim: -------------------------------------------------------------------------------- 1 | " Test estimation of match length of complex patterns. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(7) 5 | 6 | call vimtap#Is(ingo#regexp#length#Project('nu\%(la\)\{2,5}'), [6, 12], '\{n,m} two-character group multi with prefix') 7 | call vimtap#Is(ingo#regexp#length#Project('fo\?\|nul\{2,5}am\|x\{3}'), [1, 9], 'three branches with multi ranges') 8 | call vimtap#Is(ingo#regexp#length#Project('fo\?\|nu\%(la\|y\)\{2,5}am\|x\{3}'), [1, 14], 'three branches, one with inner group with multi') 9 | call vimtap#Is(ingo#regexp#length#Project('fo\?\|nu\%(la\{1,2}\|y\)\{2,5}am\|x\{3}'), [1, 19], 'three branches, one with inner group with multi with multi') 10 | call vimtap#Is(ingo#regexp#length#Project('fo\?\|nu\%(\%(I\%(M\|NN\)\)\{1,2}\|y\)\{2,5}am\|x\{3}'), [1, 34], 'three branches, one with inner group with multi with inner group with multi') 11 | 12 | call vimtap#Is(ingo#regexp#length#Project('nul*am\|xu\?t'), [2, 0x7FFFFFFF], 'branches with * / \? multis with prefix and suffix') 13 | call vimtap#Is(ingo#regexp#length#Project('nul\{100,200}am\|xu\{10,99}t'), [12, 204], 'branches with \{n,m} multis with prefix and suffix') 14 | 15 | call vimtest#Quit() 16 | -------------------------------------------------------------------------------- /tests/regexp/length/t1100-Project-invalid.vim: -------------------------------------------------------------------------------- 1 | " Test estimation of invalid pattern. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(1) 5 | 6 | call vimtap#err#Throws('PrefixGroupsSuffix: Unmatched \(', "call ingo#regexp#length#Project('my\\%(Foo\\|B\\(ar\\|il\\|ox\\|Fox\\)Trott')", 'missing closing paren throws exception') 7 | 8 | call vimtest#Quit() 9 | -------------------------------------------------------------------------------- /tests/regexp/parse/t1000-MultiExpr.vim: -------------------------------------------------------------------------------- 1 | " Test parsing of multis. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(5) 5 | 6 | call vimtap#Is(substitute('foobar', ingo#regexp#parse#MultiExpr(), '', 'g'), 'foobar', 'no multis') 7 | call vimtap#Is(substitute('fo*bar', ingo#regexp#parse#MultiExpr(), '', 'g'), 'fobar', '* multi') 8 | call vimtap#Is(substitute('fo\{1,10}', ingo#regexp#parse#MultiExpr(), '', 'g'), 'fo', '\{} multi') 9 | call vimtap#Is(substitute('fo\{-}ba\{-1}r\{-,10} \{2,7}x\\{1,2}', ingo#regexp#parse#MultiExpr(), '', 'g'), 'fobar x\\{1,2}', 'various \{} multis') 10 | call vimtap#Is(substitute('a\@<= foo\(bar\)\@=bar', ingo#regexp#parse#MultiExpr(), '', 'g'), 'a foo\(bar\)bar', '\@= multis') 11 | 12 | call vimtest#Quit() 13 | -------------------------------------------------------------------------------- /tests/regexp/parse/t1100-PositionAtomExpr.vim: -------------------------------------------------------------------------------- 1 | " Test parsing of position atoms. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(5) 5 | 6 | call vimtap#Is(substitute('foobar', ingo#regexp#parse#PositionAtomExpr(), '', 'g'), 'foobar', 'no position atoms') 7 | call vimtap#Is(substitute('^', ingo#regexp#parse#PositionAtomExpr(), '', 'g'), '', '^') 8 | call vimtap#Is(substitute('\%^foo\%$', ingo#regexp#parse#PositionAtomExpr(), '', 'g'), 'foo', '\%^ and \%$') 9 | call vimtap#Is(substitute('\%#foo', ingo#regexp#parse#PositionAtomExpr(), '', 'g'), 'foo', '\%#') 10 | call vimtap#Is(substitute('foo\%>42lbar', ingo#regexp#parse#PositionAtomExpr(), '', 'g'), 'foobar', '\%>l') 11 | 12 | call vimtest#Quit() 13 | -------------------------------------------------------------------------------- /tests/regexp/parse/t1200-NumberEscapedExpr.vim: -------------------------------------------------------------------------------- 1 | " Test parsing of number escapes. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(5) 5 | 6 | call vimtap#Is(substitute('foobar', ingo#regexp#parse#NumberEscapesExpr(), '', 'g'), 'foobar', 'no number escapes') 7 | call vimtap#Is(substitute('foo\%d34bar', ingo#regexp#parse#NumberEscapesExpr(), '', 'g'), 'foobar', '\%d') 8 | call vimtap#Is(substitute('foo\%xFFbar', ingo#regexp#parse#NumberEscapesExpr(), '', 'g'), 'foobar', '\%x') 9 | call vimtap#Is(substitute('foo\%u03eabar', ingo#regexp#parse#NumberEscapesExpr(), '', 'g'), 'foobar', '\%u') 10 | call vimtap#Is(substitute('foo\%U', ingo#regexp#parse#NumberEscapesExpr(), '', 'g'), 'foo\%U', 'too short \%U') 11 | 12 | call vimtest#Quit() 13 | -------------------------------------------------------------------------------- /tests/regexp/parse/t1300-CharacterClassesExpr.vim: -------------------------------------------------------------------------------- 1 | " Test parsing of character classes. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(2) 5 | 6 | call vimtap#Is(substitute('foobar', ingo#regexp#parse#CharacterClassesExpr(), '', 'g'), 'foobar', 'no character classes') 7 | call vimtap#Is(substitute('f\i\I\k\K\fo\F\po\P\sba\S\d\D\x\X\o\O\w\W\h\H\a\A\l\L\u\Ur', ingo#regexp#parse#CharacterClassesExpr(), '', 'g'), 'foobar', 'all character classes') 8 | 9 | call vimtest#Quit() 10 | -------------------------------------------------------------------------------- /tests/regexp/parse/t1400-OptionalSequenceExpr.vim: -------------------------------------------------------------------------------- 1 | " Test parsing of optional sequences. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(3) 5 | 6 | call vimtap#Is(substitute('foo\%[bar]quux', ingo#regexp#parse#OptionalSequenceExpr(), '', 'g'), 'fooquux', 'optional sequence') 7 | call vimtap#Is(substitute('r\%[[eo]ad]', ingo#regexp#parse#OptionalSequenceExpr(), '', 'g'), 'r', 'optional sequence with character class inside') 8 | call vimtap#Is(substitute('index\%[[[]0[]]]', ingo#regexp#parse#OptionalSequenceExpr(), '', 'g'), 'index', 'optional sequence with square brackets') 9 | 10 | call vimtest#Quit() 11 | -------------------------------------------------------------------------------- /tests/regexp/parse/t1500-GroupBranchExpr.vim: -------------------------------------------------------------------------------- 1 | " Test parsing of groups and branches. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(5) 5 | 6 | call vimtap#Is(substitute('foobar', ingo#regexp#parse#GroupBranchExpr(), '', 'g'), 'foobar', 'no branches') 7 | call vimtap#Is(substitute('foo\(bar\)', ingo#regexp#parse#GroupBranchExpr(), '', 'g'), 'foobar', 'captured group') 8 | call vimtap#Is(substitute('\%(x\)', ingo#regexp#parse#GroupBranchExpr(), '', 'g'), 'x', 'non-capturing group') 9 | call vimtap#Is(substitute('foo\|bar', ingo#regexp#parse#GroupBranchExpr(), '', 'g'), 'foobar', 'branch') 10 | call vimtap#Is(substitute('|(f)\|oo\(b\%(a\|u\+\)r\)', ingo#regexp#parse#GroupBranchExpr(), '', 'g'), '|(f)oobau\+r', 'complex branches and nested groups') 11 | 12 | call vimtest#Quit() 13 | -------------------------------------------------------------------------------- /tests/regexp/parse/t1600-SingleCharacterExpr.vim: -------------------------------------------------------------------------------- 1 | " Test parsing of single characters. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(3) 5 | 6 | call vimtap#Is(substitute('foobar', ingo#regexp#parse#SingleCharacterExpr(), '', 'g'), 'foobar', 'no single character match atom') 7 | call vimtap#Is(substitute('f..bar', ingo#regexp#parse#SingleCharacterExpr(), '', 'g'), 'fbar', '..') 8 | call vimtap#Is(substitute('foo\.\_.b.a.r.', ingo#regexp#parse#SingleCharacterExpr(), '', 'g'), 'foo\.bar', '..') 9 | 10 | call vimtest#Quit() 11 | -------------------------------------------------------------------------------- /tests/regexp/parse/t1700-OtherAtomExpr.vim: -------------------------------------------------------------------------------- 1 | " Test parsing of other atoms. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(9) 5 | 6 | call vimtap#Is(substitute('foobar', ingo#regexp#parse#OtherAtomExpr(), '', 'g'), 'foobar', 'no other atoms') 7 | call vimtap#Is(substitute('^\', ingo#regexp#parse#OtherAtomExpr(), '', 'g'), '^\', 'no other atoms in complex pattern') 8 | call vimtap#Is(substitute('\%#=1foobar', ingo#regexp#parse#OtherAtomExpr(), '', 'g'), 'foobar', 'regexp engine atom') 9 | call vimtap#Is(substitute('bad\%#=1foobar', ingo#regexp#parse#OtherAtomExpr(), '', 'g'), 'bad\%#=1foobar', 'regexp engine atom not in front') 10 | call vimtap#Is(substitute('foo\zsb\zear', ingo#regexp#parse#OtherAtomExpr(), '', 'g'), 'foobar', '\zs and \ze') 11 | call vimtap#Is(substitute('foo\nbar', ingo#regexp#parse#OtherAtomExpr(), '', 'g'), 'foo\nbar', '\n') 12 | call vimtap#Is(substitute('f\(o\+\)b\1r', ingo#regexp#parse#OtherAtomExpr(), '', 'g'), 'f\(o\+\)br', '\1') 13 | call vimtap#Is(substitute('\cfoobar', ingo#regexp#parse#OtherAtomExpr(), '', 'g'), 'foobar', '\c') 14 | call vimtap#Is(substitute('\C\V', ingo#regexp#parse#OtherAtomExpr(), '', 'g'), '', '\C\V') 15 | 16 | call vimtest#Quit() 17 | -------------------------------------------------------------------------------- /tests/regexp/parse/t1800-EscapedCharacterExpr.vim: -------------------------------------------------------------------------------- 1 | " Test parsing of escaped characters. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(3) 5 | 6 | call vimtap#Is(substitute('foobar', ingo#regexp#parse#EscapedCharacterExpr(), '', 'g'), 'foobar', 'no other atoms') 7 | call vimtap#Is(substitute('foo\nbar', ingo#regexp#parse#EscapedCharacterExpr(), '', 'g'), 'foobar', '\n') 8 | call vimtap#Is(substitute('\\n\e\t\r\b\\\n\\t', ingo#regexp#parse#EscapedCharacterExpr(), '', 'g'), '\\n\\\\t', 'both escaped and non-escaped') 9 | 10 | call vimtest#Quit() 11 | -------------------------------------------------------------------------------- /tests/regexp/parse/t1900-NonOrdinaryAtomExpr.vim: -------------------------------------------------------------------------------- 1 | " Test parsing any non-ordinary atoms. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(11) 5 | 6 | call vimtap#Is(substitute('foobar', ingo#regexp#parse#NonOrdinaryAtomExpr(), '', 'g'), 'foobar', 'no non-ordinary atoms') 7 | call vimtap#Is(substitute('fo\+ba*r', ingo#regexp#parse#NonOrdinaryAtomExpr(), '', 'g'), 'fobar', '\+ and *') 8 | call vimtap#Is(substitute('|(f)\|oo\(b\%(a\|u\+\)r\)', ingo#regexp#parse#NonOrdinaryAtomExpr(), '', 'g'), '|(f)oobaur', 'complex branches and nested groups') 9 | call vimtap#Is(substitute('fo\{-}ba\{-1}r\{-,10} \{2,7}x\\{1,2}', ingo#regexp#parse#NonOrdinaryAtomExpr(), '', 'g'), 'fobar x\\{1,2}', 'various \{} multis') 10 | call vimtap#Is(substitute('^foo\%>42lbar$', ingo#regexp#parse#NonOrdinaryAtomExpr(), '', 'g'), 'foobar', '^ \%>l $') 11 | call vimtap#Is(substitute('f..b\_.r', ingo#regexp#parse#NonOrdinaryAtomExpr(), '', 'g'), 'fbr', '. and \_.') 12 | call vimtap#Is(substitute('\%d34foo\%u03eabar\%xFFr', ingo#regexp#parse#NonOrdinaryAtomExpr(), '', 'g'), 'foobarr', '\%d \%u \%x') 13 | call vimtap#Is(substitute('\%#=2f\(oo\)b\([aeiou]\)r-\1\2', ingo#regexp#parse#NonOrdinaryAtomExpr(), '', 'g'), 'foobr-', 'regexp with re, capture groups and references') 14 | call vimtap#Is(substitute('\if\I\k\K\f\F\p\Po\s\So\d\D\x\Xb\o\O\wa\W\h\H\a\A\l\L\u\Ur', ingo#regexp#parse#NonOrdinaryAtomExpr(), '', 'g'), 'foobar', 'character classes') 15 | call vimtap#Is(substitute('f[^[:lower:]]oob[[:alpha:]]ar[[:space:][:xdigit:]]', ingo#regexp#parse#NonOrdinaryAtomExpr(), '', 'g'), 'foobar', 'collection classes') 16 | call vimtap#Is(substitute('f[^oO]\%[bar]', ingo#regexp#parse#NonOrdinaryAtomExpr(), '', 'g'), 'f', 'inverted collection and optional sequence') 17 | 18 | call vimtest#Quit() 19 | -------------------------------------------------------------------------------- /tests/regexp/split/t2000-PrefixGroupsSuffix.vim: -------------------------------------------------------------------------------- 1 | " Test splitting prefix, group(s), suffix. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(9) 5 | 6 | call vimtap#Is(ingo#regexp#split#PrefixGroupsSuffix(''), [''], 'empty pattern') 7 | call vimtap#Is(ingo#regexp#split#PrefixGroupsSuffix('foo'), ['foo'], 'simple literal pattern') 8 | call vimtap#Is(ingo#regexp#split#PrefixGroupsSuffix('Foo\|Bar\|Fox'), ['Foo\|Bar\|Fox'], 'toplevel branches without group') 9 | 10 | call vimtap#Is(ingo#regexp#split#PrefixGroupsSuffix('\%(Foo\|Bar\|Fox\)'), ['', 'Foo\|Bar\|Fox', ''], 'group with branches') 11 | call vimtap#Is(ingo#regexp#split#PrefixGroupsSuffix('my\%(Foo\|Bar\|Fox\)Trott'), ['my', 'Foo\|Bar\|Fox', 'Trott'], 'group with branches inside literal prefix and suffix') 12 | call vimtap#Is(ingo#regexp#split#PrefixGroupsSuffix('my\%(Foo\|Bar\|Fox\)In\(Our\|Their\)Trott'), ['my', 'Foo\|Bar\|Fox', 'In', 'Our\|Their', 'Trott'], 'two groups surrounded by literals') 13 | call vimtap#Is(ingo#regexp#split#PrefixGroupsSuffix('\%(Foo\|Bar\|Fox\)\(Our\|Their\)'), ['', 'Foo\|Bar\|Fox', '', 'Our\|Their', ''], 'two groups unsurrounded') 14 | 15 | call vimtap#Is(ingo#regexp#split#PrefixGroupsSuffix('my\%(Foo\|B\(ar\|il\|ox\)\|Fox\)Trott'), ['my', 'Foo\|B\(ar\|il\|ox\)\|Fox', 'Trott'], 'group with another group inside') 16 | call vimtap#Is(ingo#regexp#split#PrefixGroupsSuffix('my\%(F\(al\)\?oo\|B\(ar\|il\|ox\)\|\(F\|\%(Var\)\?i\)ox\)Trott'), ['my', 'F\(al\)\?oo\|B\(ar\|il\|ox\)\|\(F\|\%(Var\)\?i\)ox', 'Trott'], 'group with other groups inside') 17 | 18 | call vimtest#Quit() 19 | -------------------------------------------------------------------------------- /tests/regexp/split/t2090-PrefixGroupsSuffix-invalid.vim: -------------------------------------------------------------------------------- 1 | " Test splitting prefix, group(s), suffix of invalid pattern. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(2) 5 | 6 | call vimtap#err#Throws('PrefixGroupsSuffix: Unmatched \(', "call ingo#regexp#split#PrefixGroupsSuffix('my\\%(Foo\\|B\\(ar\\|il\\|ox\\|Fox\\)Trott')", 'missing closing paren throws exception') 7 | call vimtap#err#Throws('PrefixGroupsSuffix: Unmatched \)', "call ingo#regexp#split#PrefixGroupsSuffix('my\\%(Foo\\|B\\(ar\\|il\\)\\|ox\\)\\|Fox\\)Trott')", 'missing opening paren throws exception') 8 | 9 | call vimtest#Quit() 10 | -------------------------------------------------------------------------------- /tests/regexp/split/t3000-AddPatternByProjectedMatchLength-literals.vim: -------------------------------------------------------------------------------- 1 | " Test addition of literal patterns based on length. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(8) 5 | 6 | call vimtap#Is(ingo#regexp#split#AddPatternByProjectedMatchLength([], 'foo'), ['foo'], 'add literal pattern to empty list') 7 | call vimtap#Is(ingo#regexp#split#AddPatternByProjectedMatchLength(['foo'], 'fo'), ['foo', 'fo'], 'add shorter literal pattern to one-element list') 8 | call vimtap#Is(ingo#regexp#split#AddPatternByProjectedMatchLength(['foo'], 'fooy'), ['fooy', 'foo'], 'add longer literal pattern to one-element list') 9 | call vimtap#Is(ingo#regexp#split#AddPatternByProjectedMatchLength(['foo'], 'fox'), ['foo', 'fox'], 'add same-length literal pattern to one-element list') 10 | 11 | call vimtap#Is(ingo#regexp#split#AddPatternByProjectedMatchLength(['foo', 'fo'], 'f'), ['foo', 'fo', 'f'], 'add shorter literal pattern to two-element list') 12 | call vimtap#Is(ingo#regexp#split#AddPatternByProjectedMatchLength(['fooxies', 'fo'], 'foox'), ['fooxies', 'foox', 'fo'], 'add literal pattern to middle of two-element list') 13 | call vimtap#Is(ingo#regexp#split#AddPatternByProjectedMatchLength(['fooxies', 'foox', 'fo'], 'foo'), ['fooxies', 'foox', 'foo', 'fo'], 'add literal pattern to middle of three-element list') 14 | 15 | call vimtap#Is(ingo#regexp#split#AddPatternByProjectedMatchLength(['fooxies', 'fo', 'boobies', 'bo'], 'boo'), ['fooxies', 'boo', 'fo', 'boobies', 'bo'], 'add literal pattern to middle of not fully sorted four-element list') 16 | 17 | call vimtest#Quit() 18 | -------------------------------------------------------------------------------- /tests/regexp/split/t3010-AddPatternByProjectedMatchLength-minmax.vim: -------------------------------------------------------------------------------- 1 | " Test considering min or max length. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(6) 5 | 6 | call vimtap#Is(ingo#regexp#split#AddPatternByProjectedMatchLength(['abcd\+', 'abc\+', 'ab\+', 'a\+', '0*'], 'ooo'), ['abcd\+', 'abc\+', 'ooo', 'ab\+', 'a\+', '0*'], 'add ooo to staggered multis behind max=3') 7 | call vimtap#Is(ingo#regexp#split#AddPatternByProjectedMatchLength(['abcd\+', 'abc\+', 'ab\+', 'a\+', '0*'], 'ooo\+'), ['abcd\+', 'abc\+', 'ooo\+', 'ab\+', 'a\+', '0*'], 'add ooo\+ to staggered multis behind max=3') 8 | call vimtap#Is(ingo#regexp#split#AddPatternByProjectedMatchLength(['abcd\+', 'abc\+', 'ab\+', 'a\+', '0*'], 'o\{2,4}'), ['abcd\+', 'abc\+', 'ab\+', 'o\{2,4}', 'a\+', '0*'], 'add o\{2,4} to staggered multis behind max=2') 9 | 10 | call vimtap#Is(ingo#regexp#split#AddPatternByProjectedMatchLength(['a\{6,9}', 'b\{5,7}', 'c\{2,5}', 'd\{1,3}'], 'oooooo'), ['a\{6,9}', 'b\{5,7}', 'oooooo', 'c\{2,5}', 'd\{1,3}'], 'add ooooo to staged ranges') 11 | call vimtap#Is(ingo#regexp#split#AddPatternByProjectedMatchLength(['a\{6,9}', 'b\{5,7}', 'c\{2,5}', 'd\{1,3}'], 'o\{6}'), ['a\{6,9}', 'b\{5,7}', 'o\{6}', 'c\{2,5}', 'd\{1,3}'], 'add o\{6} to various ranges') 12 | call vimtap#Is(ingo#regexp#split#AddPatternByProjectedMatchLength(['a\{6,9}', 'b\{5,7}', 'c\{2,5}', 'd\{1,3}'], 'o\{4,8}'), ['a\{6,9}', 'b\{5,7}', 'c\{2,5}', 'o\{4,8}', 'd\{1,3}'], 'o\{4,8} uses min to sort in max values') 13 | 14 | call vimtest#Quit() 15 | -------------------------------------------------------------------------------- /tests/regexp/split/t3090-AddPatternByProjectedMatchLength-invalid.vim: -------------------------------------------------------------------------------- 1 | " Test addition of/to invalid patterns. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(2) 5 | 6 | call vimtap#Is(ingo#regexp#split#AddPatternByProjectedMatchLength(['fooxies', 'f\%(Foo\|B\(ar\|il\|ox\|Fox\)Trott', 'fo'], 'foo'), ['fooxies', 'f\%(Foo\|B\(ar\|il\|ox\|Fox\)Trott', 'foo', 'fo'], 'add, skip invalid pattern') 7 | call vimtap#Is(ingo#regexp#split#AddPatternByProjectedMatchLength(['fooxies', 'fo'], 'f\%(Foo\|B\(ar\|il\|ox\|Fox\)Trott'), ['fooxies', 'fo', 'f\%(Foo\|B\(ar\|il\|ox\|Fox\)Trott'], 'invalid pattern added at end') 8 | 9 | call vimtest#Quit() 10 | -------------------------------------------------------------------------------- /tests/regexp/t1000-IsValid.vim: -------------------------------------------------------------------------------- 1 | " Test testing regular expression for correctness. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(8) 5 | 6 | call vimtap#Is(ingo#regexp#IsValid(''), 1, 'empty pattern is valid') 7 | call vimtap#Is(ingo#regexp#IsValid('foo'), 1, 'literal pattern is valid') 8 | call vimtap#Is(ingo#regexp#IsValid('^[fF]o\+$'), 1, 'simple pattern is valid') 9 | 10 | call vimtap#Is(ingo#regexp#IsValid('fo**'), 0, 'fo** is invalid') 11 | call vimtap#Like(ingo#err#Get(), '^E871:', "fo** gives E871: (NFA regexp) Can't have a multi follow a multi") 12 | 13 | call ingo#err#Clear() 14 | call vimtap#Is(ingo#regexp#IsValid('foo\(bar', 'custom'), 0, 'foo\(bar is invalid') 15 | call vimtap#Is(ingo#err#Get(), '', 'custom error context keeps default context') 16 | call vimtap#Like(ingo#err#Get('custom'), '^E54:', "fo** gives E54: Unmatched \(") 17 | 18 | call vimtest#Quit() 19 | -------------------------------------------------------------------------------- /tests/regexp/t1100-EscapeLiteralReplacement.ok: -------------------------------------------------------------------------------- 1 | fA\OA\O 2 | f#A\O#A\O 3 | f/\1&\/\1&\ 4 | f/&~\/&~\ 5 | f/&~\/&~\ 6 | -------------------------------------------------------------------------------- /tests/regexp/t1100-EscapeLiteralReplacement.vim: -------------------------------------------------------------------------------- 1 | " Test literal replacement. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(5) 5 | 6 | call vimtap#Is(substitute('foo', 'o', ingo#regexp#EscapeLiteralReplacement('A\O'), 'g'), 'fA\OA\O', 'substitute() of backslash') 7 | call vimtap#Is(substitute('foo', 'o', ingo#regexp#EscapeLiteralReplacement('A&O'), 'g'), 'fA&OA&O', 'substitute() of &') 8 | call vimtap#Is(substitute('foo', 'o', ingo#regexp#EscapeLiteralReplacement('A~O'), 'g'), 'fA~OA~O', 'substitute() of ~') 9 | call vimtap#Is(substitute('foo', 'o', ingo#regexp#EscapeLiteralReplacement('A/~&\O', ''), 'g'), 'fA/~&\OA/~&\O', 'substitute() with (wrong) empty optional argument') 10 | 11 | call setline(1, repeat(['foo'], 5)) 12 | execute '1substitute/o/' . ingo#regexp#EscapeLiteralReplacement("A\\O", '/') . '/g' 13 | execute '2substitute#o#' . ingo#regexp#EscapeLiteralReplacement("#A\\O", '#') . '#g' 14 | execute '3substitute/o/' . ingo#regexp#EscapeLiteralReplacement("/\\1&\\", '/') . '/g' 15 | execute '4substitute/o/' . ingo#regexp#EscapeLiteralReplacement("/&~\\", '/') . '/g' 16 | set nomagic 17 | execute '5substitute/o/' . ingo#regexp#EscapeLiteralReplacement("/&~\\", '/') . '/g' 18 | call vimtap#Is(substitute('foo', 'o', ingo#regexp#EscapeLiteralReplacement('A/~&\O', ''), 'g'), 'fA/~o\OA/~o\O', 'nomagic substitute() with (wrong) empty optional argument evaluates &') 19 | 20 | call vimtest#SaveOut() 21 | call vimtest#Quit() 22 | -------------------------------------------------------------------------------- /tests/smartcase/t1000-IsSmartCasePattern.vim: -------------------------------------------------------------------------------- 1 | " Test testing for smartcase pattern. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(9) 5 | 6 | call vimtap#Ok(ingo#smartcase#IsSmartCasePattern(ingo#smartcase#FromPattern('fooBar')), 'smartcase from fooBar') 7 | call vimtap#Ok(ingo#smartcase#IsSmartCasePattern(ingo#smartcase#FromPattern('foo bar')), 'smartcase from foo bar') 8 | call vimtap#Ok(ingo#smartcase#IsSmartCasePattern(ingo#smartcase#FromPattern('foo')), 'smartcase from foo') 9 | call vimtap#Ok(ingo#smartcase#IsSmartCasePattern(ingo#smartcase#FromPattern('FOO')), 'smartcase from FOO') 10 | call vimtap#Ok(ingo#smartcase#IsSmartCasePattern(ingo#smartcase#FromPattern('not one')), 'smartcase from FOO') 11 | 12 | call vimtap#Ok(ingo#smartcase#IsSmartCasePattern('\cnot\A\=one'), 'smartcase: \cnot\A\=one') 13 | call vimtap#Ok(! ingo#smartcase#IsSmartCasePattern('not one'), 'not smartcase: not one') 14 | call vimtap#Ok(! ingo#smartcase#IsSmartCasePattern('\cnot one'), 'not smartcase: \cnot one') 15 | call vimtap#Ok(! ingo#smartcase#IsSmartCasePattern('not\A\=one'), 'not smartcase: not\A\=one') 16 | 17 | call vimtest#Quit() 18 | -------------------------------------------------------------------------------- /tests/smartcase/t2000-Undo.vim: -------------------------------------------------------------------------------- 1 | " Test undoing of smartcasing pattern. 2 | 3 | function! s:DoUndo( pattern ) abort 4 | return ingo#smartcase#Undo(ingo#smartcase#FromPattern(a:pattern)) 5 | endfunction 6 | 7 | call vimtest#StartTap() 8 | call vimtap#Plan(5) 9 | 10 | call vimtap#Is(s:DoUndo('fooBar'), 'fooBar', 'Undo of smartcased fooBar') 11 | call vimtap#Is(s:DoUndo('foo bar'), 'foobar', 'Undo of smartcased foo bar') 12 | call vimtap#Is(s:DoUndo('foo'), 'foo', 'Undo of smartcased foo') 13 | call vimtap#Is(s:DoUndo('FOO'), 'FOO', 'Undo of smartcased FOO') 14 | call vimtap#Is(s:DoUndo('not one'), 'notone', 'Undo of smartcased not one') 15 | 16 | call vimtest#Quit() 17 | -------------------------------------------------------------------------------- /tests/str/remove/t1000-Leading.vim: -------------------------------------------------------------------------------- 1 | " Test remove trailing text 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(13) 5 | 6 | call vimtap#Is(ingo#str#remove#Leading('foobar', 'foo'), 'bar', 'remove foo from foobar') 7 | call vimtap#Is(ingo#str#remove#Leading('foo', 'foo'), '', 'remove foo from foo') 8 | call vimtap#Is(ingo#str#remove#Leading('oo', 'foo'), 'oo', 'remove foo from oo') 9 | call vimtap#Is(ingo#str#remove#Leading('fo', 'foo'), 'fo', 'remove foo from fo') 10 | call vimtap#Is(ingo#str#remove#Leading('f', 'foo'), 'f', 'remove foo from f') 11 | call vimtap#Is(ingo#str#remove#Leading('', 'foo'), '', 'remove foo from empty string') 12 | call vimtap#Is(ingo#str#remove#Leading('foo', ''), 'foo', 'remove empty string from foo') 13 | call vimtap#Is(ingo#str#remove#Leading('foobar', '...'), 'foobar', 'remove ... from foobar') 14 | 15 | call vimtap#Is(ingo#str#remove#Leading('foobar', 'fxo'), 'foobar', 'ignore non-matching prefix by default') 16 | call vimtap#Is(ingo#str#remove#Leading('foobar', 'fxo', 'ignore'), 'foobar', 'ignore non-matching prefix with ignore') 17 | call vimtap#Is(ingo#str#remove#Leading('foobar', 'fxo', 'nocheck'), 'bar', 'remove non-matching prefix with nocheck') 18 | call vimtap#err#Throws('Leading: "foobar" does not start with "fxo"', "call ingo#str#remove#Leading('foobar', 'fxo', 'throw')", 'exception on non-matching prefix with throw') 19 | call vimtap#err#Throws('ASSERT: Invalid errorStrategy: doesNotExist', "call ingo#str#remove#Leading('foobar', 'fxo', 'doesNotExist')", 'assertion failure on invalid errorStrategy') 20 | 21 | call vimtest#Quit() 22 | -------------------------------------------------------------------------------- /tests/str/remove/t1100-Trailing.vim: -------------------------------------------------------------------------------- 1 | " Test remove trailing text 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(13) 5 | 6 | call vimtap#Is(ingo#str#remove#Trailing('foobar', 'bar'), 'foo', 'remove bar from foobar') 7 | call vimtap#Is(ingo#str#remove#Trailing('foo', 'foo'), '', 'remove foo from foo') 8 | call vimtap#Is(ingo#str#remove#Trailing('oo', 'foo'), 'oo', 'remove foo from oo') 9 | call vimtap#Is(ingo#str#remove#Trailing('fo', 'foo'), 'fo', 'remove foo from fo') 10 | call vimtap#Is(ingo#str#remove#Trailing('f', 'foo'), 'f', 'remove foo from f') 11 | call vimtap#Is(ingo#str#remove#Trailing('', 'foo'), '', 'remove foo from empty string') 12 | call vimtap#Is(ingo#str#remove#Trailing('foo', ''), 'foo', 'remove empty string from foo') 13 | call vimtap#Is(ingo#str#remove#Trailing('foobar', '...'), 'foobar', 'remove ... from foobar') 14 | 15 | call vimtap#Is(ingo#str#remove#Trailing('foobar', 'bxr'), 'foobar', 'ignore non-matching suffix by default') 16 | call vimtap#Is(ingo#str#remove#Trailing('foobar', 'bxr', 'ignore'), 'foobar', 'ignore non-matching suffix with ignore') 17 | call vimtap#Is(ingo#str#remove#Trailing('foobar', 'bxr', 'nocheck'), 'foo', 'remove non-matching suffix with nocheck') 18 | call vimtap#err#Throws('Trailing: "foobar" does not end with "bxr"', "call ingo#str#remove#Trailing('foobar', 'bxr', 'throw')", 'exception on non-matching suffix with throw') 19 | call vimtap#err#Throws('ASSERT: Invalid errorStrategy: doesNotExist', "call ingo#str#remove#Trailing('foobar', 'bxr', 'doesNotExist')", 'assertion failure on invalid errorStrategy') 20 | 21 | call vimtest#Quit() 22 | -------------------------------------------------------------------------------- /tests/str/t1000-Trim.vim: -------------------------------------------------------------------------------- 1 | " Test removal of leading and trailing whitespace. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(6) 5 | 6 | call vimtap#Is(ingo#str#Trim(''), '', 'no-op on empty string') 7 | call vimtap#Is(ingo#str#Trim('foo bar'), 'foo bar', 'no surrounding whitespace, inner kept intact') 8 | call vimtap#Is(ingo#str#Trim(' foo bar'), 'foo bar', 'remove just from front') 9 | call vimtap#Is(ingo#str#Trim('foo bar '), 'foo bar', 'remove just from back') 10 | call vimtap#Is(ingo#str#Trim("\t\t foo\tbar \t "), "foo\tbar", 'remove mixed surrounding whitespace') 11 | call vimtap#Is(ingo#str#Trim("\n\nfoo\n\nbar\n"), "foo\n\nbar", 'remove surrounding newlines') 12 | 13 | call vimtest#Quit() 14 | -------------------------------------------------------------------------------- /tests/str/t1010-TrimTrailing.vim: -------------------------------------------------------------------------------- 1 | " Test removal of trailing whitespace. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(6) 5 | 6 | call vimtap#Is(ingo#str#TrimTrailing(''), '', 'no-op on empty string') 7 | call vimtap#Is(ingo#str#TrimTrailing('foo bar'), 'foo bar', 'no surrounding whitespace, inner kept intact') 8 | call vimtap#Is(ingo#str#TrimTrailing(' foo bar'), ' foo bar', 'remove nothing from front') 9 | call vimtap#Is(ingo#str#TrimTrailing('foo bar '), 'foo bar', 'remove from back') 10 | call vimtap#Is(ingo#str#TrimTrailing("\t\t foo\tbar \t "), "\t\t foo\tbar", 'remove mixed trailing whitespace') 11 | call vimtap#Is(ingo#str#TrimTrailing("\n\nfoo\n\nbar\n"), "\n\nfoo\n\nbar", 'remove trailing newlines') 12 | 13 | call vimtest#Quit() 14 | -------------------------------------------------------------------------------- /tests/str/t1100-TrimPattern.vim: -------------------------------------------------------------------------------- 1 | " Test removal of leading and trailing pattern. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(5) 5 | 6 | call vimtap#Is(ingo#str#TrimPattern('', '[xX]\+'), '', 'no-op on empty string') 7 | call vimtap#Is(ingo#str#TrimPattern('fox bar', '[xX]\+'), 'fox bar', 'no surrounding matches, inner kept intact') 8 | call vimtap#Is(ingo#str#TrimPattern('xXxXfox barXx', '[xX]\+'), 'fox bar', 'remove surrounding matches') 9 | 10 | call vimtap#Is(ingo#str#TrimPattern('xXxXfox barXxX', 'x\+', 'X\+'), 'XxXfox barXx', 'use different patterns for leading and trailing matches') 11 | call vimtap#Is(ingo#str#TrimPattern('xXxXfox barXx', '[uU]\+', '[xX]\+'), 'xXxXfox bar', 'only trailing pattern matches') 12 | 13 | call vimtest#Quit() 14 | -------------------------------------------------------------------------------- /tests/strdisplaywidth/pad/t1000-Repeat.vim: -------------------------------------------------------------------------------- 1 | " Test duplicate to exceed width. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(10) 5 | 6 | call vimtap#Is(ingo#strdisplaywidth#pad#Repeat('', 1), '', 'empty text') 7 | call vimtap#Is(ingo#strdisplaywidth#pad#Repeat('x', 5), 'xxxxx', 'single-width text') 8 | call vimtap#Is(ingo#strdisplaywidth#pad#Repeat('Abc', 1), 'Abc', 'text longer than enough') 9 | call vimtap#Is(ingo#strdisplaywidth#pad#Repeat('Abc', 3), 'Abc', 'text exactly long enough') 10 | call vimtap#Is(ingo#strdisplaywidth#pad#Repeat('Abc', 4), 'AbcAbc', 'need one duplication to exceed') 11 | call vimtap#Is(ingo#strdisplaywidth#pad#Repeat('Abc', 6), 'AbcAbc', 'need one duplication to match') 12 | call vimtap#Is(ingo#strdisplaywidth#pad#Repeat('Abc', 7), 'AbcAbcAbc', 'need two duplications to exceed') 13 | 14 | call vimtap#Is(ingo#strdisplaywidth#pad#Repeat('', 5), '', 'double-width text') 15 | call vimtap#Is(ingo#strdisplaywidth#pad#Repeat("\t\t", 10), ' ', 'two tabs text are rendered as spaces') 16 | call vimtap#Is(ingo#strdisplaywidth#pad#Repeat("|\t", 10), '| | ', 'char+tab text is duplicated') 17 | 18 | call vimtest#Quit() 19 | -------------------------------------------------------------------------------- /tests/strdisplaywidth/pad/t1100-RepeatExact.vim: -------------------------------------------------------------------------------- 1 | " Test duplicate to exactly match width. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(10) 5 | 6 | call vimtap#Is(ingo#strdisplaywidth#pad#RepeatExact('', 1), ' ', 'empty text') 7 | call vimtap#Is(ingo#strdisplaywidth#pad#RepeatExact('x', 5), 'xxxxx', 'single-width text') 8 | call vimtap#Is(ingo#strdisplaywidth#pad#RepeatExact('Abc', 1), 'A', 'text longer than enough') 9 | call vimtap#Is(ingo#strdisplaywidth#pad#RepeatExact('Abc', 3), 'Abc', 'text exactly long enough') 10 | call vimtap#Is(ingo#strdisplaywidth#pad#RepeatExact('Abc', 4), 'AbcA', 'need one duplication to exceed') 11 | call vimtap#Is(ingo#strdisplaywidth#pad#RepeatExact('Abc', 6), 'AbcAbc', 'need one duplication to match') 12 | call vimtap#Is(ingo#strdisplaywidth#pad#RepeatExact('Abc', 7), 'AbcAbcA', 'need two duplications to exceed') 13 | 14 | call vimtap#Is(ingo#strdisplaywidth#pad#RepeatExact('', 5), ' ', 'double-width text') 15 | call vimtap#Is(ingo#strdisplaywidth#pad#RepeatExact("\t\t", 10), ' ', 'two tabs text are rendered as spaces') 16 | call vimtap#Is(ingo#strdisplaywidth#pad#RepeatExact("|\t", 10), '| | ', 'char+tab text is duplicated') 17 | 18 | call vimtest#Quit() 19 | -------------------------------------------------------------------------------- /tests/strdisplaywidth/pad/t1110-RepeatExact-filler.vim: -------------------------------------------------------------------------------- 1 | " Test duplicate to exactly match width with custom filler. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(3) 5 | 6 | call vimtap#Is(ingo#strdisplaywidth#pad#RepeatExact('', 2, 'x'), 'xx', 'empty text') 7 | call vimtap#Is(ingo#strdisplaywidth#pad#RepeatExact('', 5, '.'), '.', 'double-width text') 8 | call vimtap#Is(ingo#strdisplaywidth#pad#RepeatExact("\t\t", 10), ' ', 'two tabs text are rendered as spaces, no filler necessary') 9 | 10 | call vimtest#Quit() 11 | -------------------------------------------------------------------------------- /tests/strdisplaywidth/t1000-strleft.vim: -------------------------------------------------------------------------------- 1 | " Test extracting a certain width from left. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(8) 5 | 6 | call vimtap#Is(ingo#strdisplaywidth#strleft('foobar', 2), 'fo', '2 single-width characters') 7 | call vimtap#Is(ingo#strdisplaywidth#strleft('foobar', 9), 'foobar', 'width exceeds actual one') 8 | call vimtap#Is(ingo#strdisplaywidth#strleft('foobar', 0), '', 'zero width') 9 | 10 | call vimtap#Is(ingo#strdisplaywidth#strleft('fbar', 2), 'f', 'double-width character in the middle is excluded') 11 | call vimtap#Is(ingo#strdisplaywidth#strleft('fbar', 3), 'f', 'include double-width character') 12 | call vimtap#Is(ingo#strdisplaywidth#strleft('fbar', 4), 'f', 'double-width character in the middle is excluded') 13 | call vimtap#Is(ingo#strdisplaywidth#strleft("f\tbar", 3), 'f', 'tab in the middle is excluded') 14 | call vimtap#Is(ingo#strdisplaywidth#strleft("f\t\tbar", 8), "f\t", 'include tab') 15 | 16 | call vimtest#Quit() 17 | -------------------------------------------------------------------------------- /tests/subs/BraceCreation/t1030-BraceCreation-0numbers.vim: -------------------------------------------------------------------------------- 1 | " Test brace creation with 0-prefixed numbers. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(4) 5 | 6 | function! s:Call( text ) 7 | return ingo#subs#BraceCreation#FromSplitString(a:text) 8 | endfunction 9 | 10 | call vimtap#Is(s:Call('foo1 foo2 foo3'), 'foo{1..3}', 'single digit number sequence') 11 | call vimtap#Is(s:Call('foo01 foo02 foo03'), 'foo0{1..3}', 'single digit 0-number sequence') 12 | call vimtap#Is(s:Call('foo06 foo08 foo10 foo12'), 'foo{06..12..2}', '1-2 digit 0-number sequence') 13 | call vimtap#Is(s:Call('foo005 foo056 foo107 foo158'), 'foo{005..158..51}', '1-3 digit 0-number sequence') 14 | 15 | call vimtest#Quit() 16 | -------------------------------------------------------------------------------- /tests/subs/BraceExpansion/t1010-BraceExpansion-options.vim: -------------------------------------------------------------------------------- 1 | " Test brace expansion with options. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(2) 5 | 6 | function! s:Call( text, options ) 7 | return ingo#subs#BraceExpansion#ExpandToString(a:text, ' ', a:options) 8 | endfunction 9 | 10 | call vimtap#Is(s:Call('Foo{Has,}Bo{o,o,x}', {}), 'FooHasBoo FooHasBoo FooHasBox FooBoo FooBoo FooBox', 'optional inner in default curly braces') 11 | call vimtap#Is(s:Call('Foo[Has]Bo{o,o,x}', {'optionalElementInSquareBraces': 1}), 'FooHasBoo FooHasBoo FooHasBox FooBoo FooBoo FooBox', 'optional inner in square braces') 12 | 13 | call vimtest#Quit() 14 | -------------------------------------------------------------------------------- /tests/subs/BraceExpansion/t1030-BraceExpansion-sequences.vim: -------------------------------------------------------------------------------- 1 | " Test brace expansion of sequences. 2 | 3 | function! s:Call( text ) 4 | return join(ingo#subs#BraceExpansion#ExpandStrict(a:text), ' ') 5 | endfunction 6 | 7 | call vimtest#StartTap() 8 | call vimtap#Plan(6) 9 | 10 | call vimtap#Is(s:Call('foo{1..10}'), 'foo1 foo2 foo3 foo4 foo5 foo6 foo7 foo8 foo9 foo10', 'same prefix, number sequence') 11 | call vimtap#Is(s:Call('foo{01..10}'), 'foo01 foo02 foo03 foo04 foo05 foo06 foo07 foo08 foo09 foo10', 'same prefix, 0-padded start number') 12 | call vimtap#Is(s:Call('foo{001..10}'), 'foo001 foo002 foo003 foo004 foo005 foo006 foo007 foo008 foo009 foo010', 'same prefix, 00-padded start number') 13 | call vimtap#Is(s:Call('foo{1..010}'), 'foo001 foo002 foo003 foo004 foo005 foo006 foo007 foo008 foo009 foo010', 'same prefix, 0-padded end number') 14 | call vimtap#Is(s:Call('foo{01..010}'), 'foo001 foo002 foo003 foo004 foo005 foo006 foo007 foo008 foo009 foo010', 'same prefix, 0-padded start and end number') 15 | call vimtap#Is(s:Call('foo{00..100..010}'), 'foo000 foo010 foo020 foo030 foo040 foo050 foo060 foo070 foo080 foo090 foo100', 'same prefix, 00-padded start number, 0-padded step') 16 | 17 | call vimtest#Quit() 18 | 19 | -------------------------------------------------------------------------------- /tests/subst/expr/t1000-emulation.vim: -------------------------------------------------------------------------------- 1 | " Test substition with replacement emulation. 2 | 3 | function! s:IsEquivalent( expr, pat, sub, description ) 4 | call vimtap#Is(ingo#subst#expr#emulation#Substitute(a:expr, a:pat, a:sub, ''), substitute(a:expr, a:pat, a:sub, ''), a:description) 5 | call vimtap#Is(ingo#subst#expr#emulation#Substitute(a:expr, a:pat, a:sub, 'g'), substitute(a:expr, a:pat, a:sub, 'g'), 'global ' . a:description) 6 | endfunction 7 | 8 | call vimtest#StartTap() 9 | call vimtap#Plan(22) 10 | 11 | call s:IsEquivalent('foobar', '[ao]', 'x', 'normal substitution') 12 | call s:IsEquivalent('foobar', '[ao]', '\=toupper(submatch(0))', 'expression with submatch(0)') 13 | call s:IsEquivalent('foobar', '\([ao]\)[ao]\?', '\=toupper(submatch(1))', 'expression with submatch(1)') 14 | call s:IsEquivalent('this foo bar', '\<\(.\)\(.\)\(.\)\>', '\=submatch(3).submatch(2).submatch(2).submatch(1)', 'expression with many submatches') 15 | 16 | call s:IsEquivalent('my foo your bar my baz your hihi', 'my \zs\<...\>', '\=toupper(submatch(0))', 'with \zs') 17 | call s:IsEquivalent('my foo your bar my baz your hihi', '\<...\>\ze my', '\=toupper(submatch(0))', 'with \ze') 18 | call s:IsEquivalent('my foo. your bar! my baz. your hihi.', 'my \zs\<...\>\ze[.!]', '\=toupper(submatch(0))', 'with \zs and \ze') 19 | 20 | call s:IsEquivalent('foo can and foo cannot foo', '^foo\s', '\=toupper(submatch(0))', 'with ^ anchor') 21 | call s:IsEquivalent('foo foo can and foo cannot foo', '^foo\s', '\=toupper(submatch(0))', 'with ^ anchor') 22 | call s:IsEquivalent('foo can and foo cannot foo', '\sfoo$', '\=toupper(submatch(0))', 'with $ anchor') 23 | call s:IsEquivalent('foo can and foo cannot foo foo', '\sfoo$', '\=toupper(submatch(0))', 'with $ anchor') 24 | 25 | call vimtest#Quit() 26 | -------------------------------------------------------------------------------- /tests/subst/t2000-Recurringly.vim: -------------------------------------------------------------------------------- 1 | " Test recurring substitution. 2 | 3 | call vimtest#StartTap() 4 | call vimtap#Plan(5) 5 | 6 | call vimtap#Is(ingo#subst#Recurringly('foobar', 'o', 'X', 'g'), 'fXXbar', 'plain foobar global substitution') 7 | call vimtap#Is(ingo#subst#Recurringly('foobar', 'o', 'X', ''), 'fXXbar', 'foobar once substitution is equivalent to global substitution') 8 | 9 | call vimtap#Is(ingo#subst#Recurringly('camelCaseConstructCreation', '\(\k*\%(\k\&\U\)\+\)\(\u\k\+\)', '\1 \L\2', 'g'), 'camel case construct creation', 'split all camelCase humps') 10 | 11 | call vimtap#Is(ingo#subst#Recurringly('foobar', '[^o]\zso\{2,6}\ze[^o]', '&o', 'g'), 'fooooooobar', 'limit appending via multi') 12 | call vimtap#Is(ingo#subst#Recurringly('foobar', 'o\+', '&o', 'g', 5), 'fooooooobar', 'stop endless appending after 5 counts') 13 | 14 | call vimtest#Quit() 15 | --------------------------------------------------------------------------------