pax_global_header00006660000000000000000000000064147262555550014532gustar00rootroot0000000000000052 comment=f1329bd68c97355c02bbef039b87a0e8b3a6829f link.vim-1.4.0/000077500000000000000000000000001472625555500132635ustar00rootroot00000000000000link.vim-1.4.0/.github/000077500000000000000000000000001472625555500146235ustar00rootroot00000000000000link.vim-1.4.0/.github/ISSUE_TEMPLATE/000077500000000000000000000000001472625555500170065ustar00rootroot00000000000000link.vim-1.4.0/.github/ISSUE_TEMPLATE/bug-report.md000066400000000000000000000004411472625555500214150ustar00rootroot00000000000000--- name: Bug report about: Create a report to help us improve title: '' labels: '' assignees: '' --- Make sure the plugin is updated to the latest version. Complete the following information: - Vim or Neovim version: [e.g. Vim 9.1 or Neovim 0.10.0] - Filetype: [e.g. markdown or mail] link.vim-1.4.0/.gitignore000066400000000000000000000000131472625555500152450ustar00rootroot00000000000000!README.md link.vim-1.4.0/.vintrc.yaml000066400000000000000000000024141472625555500155330ustar00rootroot00000000000000# See https://github.com/Vimjas/vint/wiki/Config cmdargs: # Checking more strictly (report errors, warnings and style problems) severity: style_problem # Enable coloring color: true # Enable Neovim syntax env: neovim: true # Limit max violations count error-limit: 10 # Print statistics like `Total violations: 20` stat: true # Print JSON instead of the human-readable output json: false # Change human-readable output format format: '{file_path}:{line_number}:{column_number}: {description}' policies: ProhibitAutocmdWithNoGroup: enabled: true ProhibitCommandRelyOnUser: enabled: true ProhibitCommandWithUnintendedSideEffect: enabled: true ProhibitEncodingOptionAfterScriptEncoding: enabled: true ProhibitEqualTildeOperator: enabled: true ProhibitImplicitScopeBuiltinVariable: enabled: true ProhibitMissingScriptEncoding: enabled: true ProhibitNoAbortFunction: enabled: true ProhibitSetNoCompatible: enabled: true ProhibitUnnecessaryDoubleQuote: enabled: true ProhibitUnusedVariable: enabled: true ignored_patterns: - '^_' ProhibitUsingUndeclaredVariable: enabled: true ProhibitAbbreviationOption: enabled: true ProhibitImplicitScopeVariable: enabled: true link.vim-1.4.0/Dockerfile000066400000000000000000000023031472625555500152530ustar00rootroot00000000000000# Run tests in a Docker container to avoid any interference from existing # settings and plugins. ARG BASE_IMAGE=ubuntu:latest FROM ${BASE_IMAGE} ARG DEBIAN_FRONTEND=noninteractive # Install packages RUN apt-get update && \ apt-get install --yes curl git pipx vim neovim && \ rm -rf /var/lib/apt/lists/* # Ensure that `vim` doesn't point to `nvim` on Ubuntu RUN update-alternatives --set vim /usr/bin/vim.basic RUN useradd --create-home vimmer USER vimmer WORKDIR /home/vimmer # Install linter RUN pipx install git+https://github.com/Vimjas/vint.git # Copy Vim/Neovim configuration COPY --chown=vimmer:vimmer test/docker.vimrc .vimrc COPY --chown=vimmer:vimmer test/docker.vimrc .config/nvim/init.vim # Install `vim-plug` plugin manager, then install plugins RUN vim +qall && vim -es -u .vimrc -i NONE +PlugInstall +qall RUN nvim +qall && nvim -E -s -u .config/nvim/init.vim +PlugInstall +qall # Copy (possibly modified) plugin, instead of pulling latest release from GitHub COPY --chown=vimmer:vimmer ./ plugged/link.vim/ WORKDIR /home/vimmer/plugged/link.vim # Lint RUN /home/vimmer/.local/bin/vint ./ # Run tests RUN vim '+Vader! **/*.vader' RUN nvim '+Vader! **/*.vader' CMD [ "echo", "Success" ] link.vim-1.4.0/LICENSE000066400000000000000000000020471472625555500142730ustar00rootroot00000000000000MIT License Copyright (c) 2024 qadzek Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. link.vim-1.4.0/README.md000066400000000000000000000060001472625555500145360ustar00rootroot00000000000000# link.vim `link.vim` is a plugin for Vim and Neovim that keeps long URLs out of your way. It supports links in Markdown syntax and plaintext links (e.g. in emails, in text files etc.) Inline links will be moved to a reference section. For instance, the following Markdown document: ```md # Notes [Vim](https://www.vim.org) and [Neovim](https://neovim.io) are text editors. ``` will be turned into ```md # Notes [Vim][0] and [Neovim][1] are text editors. ## Links [0]: https://www.vim.org [1]: https://neovim.io ``` Watch the screencast for a quick overview of the plugin: https://github.com/qadzek/link.vim/assets/84473512/7be44a63-677c-4477-8e30-fa6090e3c6d9 ## Installation Use your favorite plugin manager to install this plugin. For instance, if you use [vim-plug][0]: ```vim Plug 'qadzek/link.vim' ``` ## Usage By default, this plugin is activated for Markdown, [Vimwiki][1], email and text files. You can customize the filetypes on which the plugin operates in your `vimrc`: ```vim let g:link_enabled_filetypes = [ 'markdown', 'gitcommit' ] ``` `link.vim` can be used by executing one of the following commands: | Command | Key binding | Description | |----------------------|-------------------|------------------------------------------| | `:LinkConvertSingle` | `LocalLeader` + c | Convert link under cursor | | | `` + c | Same, but from insert mode | | `:LinkConvertRange` | `LocalLeader` + c | Convert links on visually selected lines | | `:LinkConvertAll` | `LocalLeader` + a | Convert all links in document | | `:LinkJump` | `LocalLeader` + j | Jump to and from reference section | | `:LinkOpen` | `LocalLeader` + o | Open link in browser | | `:LinkPeek` | `LocalLeader` + p | Show link preview | | `:LinkReformat` | `LocalLeader` + r | Renumber/merge/delete unneeded links | No mappings are built-in to avoid conflicts with your existing key bindings. You can enable the key bindings suggested above by adding this line to your `vimrc`: ```vim let g:link_use_default_mappings = 1 ``` Note that by default, `` is the backslash key. Run `:help link-mappings` to view how to change these key bindings. Read `:help link-configuration` to learn how to customize or disable the heading, the position of the reference section, which lines to skip and more. The [Wiki][2] contains some snippets submitted by users, showing configuration for e.g. `gitcommit` buffers. ## Misc Questions, suggestions, comments, feature requests... everything is welcome in the _Issues_ tab. If you would like to contribute, see `:help link-contributing`. This plugin uses the [Vint][3] linter and the [Vader][4] test framework. [0]: https://github.com/junegunn/vim-plug [1]: https://github.com/vimwiki/vimwiki [2]: https://github.com/qadzek/link.vim/wiki [3]: https://github.com/Vimjas/vint [4]: https://github.com/junegunn/vader.vim link.vim-1.4.0/autoload/000077500000000000000000000000001472625555500150735ustar00rootroot00000000000000link.vim-1.4.0/autoload/link.vim000066400000000000000000000262031472625555500165500ustar00rootroot00000000000000" Convert inline links to reference links within a range " Type : `multiple-links` or `single-link` " Mode : `normal` or `insert` function! link#Convert(type = 'multiple-links', mode = 'normal') abort range let [l:orig_view, l:orig_line_nr, l:orig_col_nr, l:orig_fold_option] = \ link#lifecycle#Initialize() " Use cursor position before range function moves cursor to first line of " range: https://vi.stackexchange.com/questions/6036/ if exists('b:init_view') let l:orig_view = b:init_view unlet b:init_view endif let [ l:first_label_line_nr, @_] = link#label#GetInfo('first') let [ l:last_label_line_nr, l:last_label_idx ] = link#label#GetInfo('last') let l:heading_text = link#heading#GetText() let l:heading_is_empty = link#heading#IsEmpty(l:heading_text) let l:heading_is_needed = link#heading#IsNeeded(l:heading_is_empty, l:heading_text) " No reference section present if l:first_label_line_nr == -1 call link#reference#PositionSection() let l:divider_line_nr = line('.') let l:last_label_line_nr = line('.') let l:range_end_line_nr = a:lastline let l:new_label_idx = link#label#GetStartIndex() let l:first_ref_added = 0 " Reference section present else let l:divider_line_nr = l:first_label_line_nr - 1 let l:range_end_line_nr = link#body#LimitRange(l:divider_line_nr, a:lastline) let l:new_label_idx = l:last_label_idx + 1 let l:first_ref_added = 1 endif let l:conversion_counter = 0 " Loop over all lines within the range for l:cur_line_nr in range(a:firstline, l:range_end_line_nr) " Necessary if reference section is positioned if l:cur_line_nr > l:divider_line_nr break endif if link#body#SkipLine(l:cur_line_nr) continue endif let l:all_links_on_line = link#body#ParseLineFor('inline', l:cur_line_nr) " Display error when trying to convert a single link but there is none if a:type ==# 'single-link' && len(l:all_links_on_line) == 0 call link#utils#DisplayError('no_inline_link') call link#lifecycle#Finalize(l:orig_view, l:orig_fold_option) return endif " Limit list of links to one link when converting a single inline link if a:type ==# 'single-link' let l:all_links_on_line = [ link#body#PickClosestLink(l:all_links_on_line, l:orig_col_nr) ] endif " Loop over all inline links on current line for l:link in l:all_links_on_line " In case of an empty heading, add a blank line if l:first_ref_added == 0 && l:heading_is_empty call append( line('.'), '') let l:last_label_line_nr += 1 let l:first_ref_added = 1 endif " Add a (non-empty) heading if l:heading_is_needed call link#heading#Add(l:heading_text, l:divider_line_nr) let l:last_label_line_nr += 3 " Three lines were added let l:heading_is_needed = 0 endif let l:cur_line_content = getline(l:cur_line_nr) call link#body#ReplaceLink(l:cur_line_content, l:link['full_link'], \ l:link['link_text'], l:new_label_idx, l:cur_line_nr) call link#reference#Add(l:new_label_idx, l:link['destination'], \ l:last_label_line_nr) let l:conversion_counter += 1 let l:last_label_line_nr += 1 let l:new_label_idx += 1 endfor " End looping over all links on current line endfor " End looping over all lines call link#lifecycle#Finalize(l:orig_view, l:orig_fold_option) " Display how many links were converted if a:type !=# 'single-link' call link#utils#DisplayMsg(l:conversion_counter .. ' link(s) were converted') endif " Move cursor when function is called from Insert mode, so user can continue " typing after the converted link if a:type ==# 'single-link' && a:mode ==# 'insert' " Move to end of reference link: first to start, then to 1st/2nd `]` call cursor(l:orig_line_nr, l:link['col_start']) if link#utils#IsFiletypeMarkdown() keepjumps normal! 2f] else keepjumps normal! f] endif " Determine if link is at the very end of the line let l:orig_line_len = len(l:cur_line_content) let l:sum = l:link['col_start'] + l:link['length'] - 1 " Return to insert mode; link is at the very end of the line if l:sum == l:orig_line_len startinsert! " Return to insert mode; link is in the middle of the line else normal! l startinsert endif endif endfunction " Connect a reference link and the corresponding link reference definition and " perform some action " Action : `jump`, `open` or `peek` function! link#Connect(action) abort let [l:orig_view, l:orig_line_nr, l:orig_col_nr, l:orig_fold_option] = \ link#lifecycle#Initialize() let [ l:first_label_line_nr, @_] = link#label#GetInfo('first') " No reference section present if l:first_label_line_nr == -1 call link#utils#DisplayError('no_ref_section') call link#lifecycle#Finalize(l:orig_view, l:orig_fold_option) return endif let l:divider_line_nr = l:first_label_line_nr - 1 " No opening/peeking from reference section if (a:action ==# 'open' || a:action ==# 'peek') && l:orig_line_nr >= l:divider_line_nr call link#utils#DisplayError('not_from_ref') call link#lifecycle#Finalize(l:orig_view, l:orig_fold_option) return endif " Determine if we should jump to the reference section or to the document body if l:orig_line_nr < l:divider_line_nr let l:line_nr = link#jump#ToReferenceSection(l:orig_line_nr, l:orig_col_nr, l:divider_line_nr) else let l:line_nr = link#jump#ToBody(l:orig_line_nr, l:divider_line_nr) endif " 0 gets returned if the jump failed if l:line_nr == 0 call link#lifecycle#Finalize(l:orig_view, l:orig_fold_option) return endif " Open URL from corresponding link reference definition in browser if a:action ==# 'open' let l:ref_link = link#reference#Parse(l:line_nr, 'one')[0] let l:url = l:ref_link['destination'] " Add protocol if URL starts with `www` if l:url =~# '^www' | let l:url = 'https://' .. l:url | endif " Not a valid URL if it doesn't start with a protocol if l:url !~# '\v^' .. g:link#globals#re['protocol'] call link#utils#DisplayError('no_valid_url', l:url) call link#lifecycle#Finalize(l:orig_view, l:orig_fold_option) return endif " When running tests, don't open links in browser, if `-b` flag is set if $VADER_OPEN_IN_BROWSER ==# 'false' call link#lifecycle#Finalize(l:orig_view, l:orig_fold_option) return endif " Decide which command to use, based on the OS let l:operating_system = link#utils#GetOperatingSystem() let l:open_cmd = link#utils#GetOpenCommand(l:operating_system) " Escape URL, to support URLs containing e.g. a question mark let l:esc_url = shellescape(l:url) " Open URL in browser; capture command's output and remove trailing newline let l:output = substitute( system(l:open_cmd .. ' ' .. l:esc_url), '\n\+$', '', '' ) if v:shell_error != 0 call link#utils#DisplayError('open_in_browser_failed', l:output) endif call link#lifecycle#Finalize(l:orig_view, l:orig_fold_option) endif " Display corresponding link reference definition if a:action ==# 'peek' let l:line_content = getline('.') call link#utils#DisplayMsg(l:line_content) call link#lifecycle#Finalize(l:orig_view, l:orig_fold_option) endif endfunction " Reformat reference links and reference section: renumber, merge, delete, mark function! link#Reformat() abort let [l:orig_view, @_, @_, l:orig_fold_option] = link#lifecycle#Initialize() let [ l:first_label_line_nr, @_] = link#label#GetInfo('first') let [ l:last_label_line_nr, @_ ] = link#label#GetInfo('last') let l:orig_ref_len = l:last_label_line_nr - l:first_label_line_nr + 1 " No reference section present if l:first_label_line_nr == -1 call link#utils#DisplayError('no_ref_section') call link#lifecycle#Finalize(l:orig_view, l:orig_fold_option) return endif let l:divider_line_nr = l:first_label_line_nr - 1 let l:ref_section_start = l:first_label_line_nr let l:ref_section_end = l:last_label_line_nr let l:ref_section = link#reference#Parse(l:ref_section_start, 'all') " Nth reference link, counting from start of document body let l:index = link#label#GetStartIndex() let l:all_ref_links = [] " Loop over all lines from first line until heading for l:body_line_nr in range(1, l:divider_line_nr) if link#body#SkipLine(l:body_line_nr) continue endif let l:all_links_on_line = link#body#ParseLineFor('reference', l:body_line_nr) " Loop over all links on current line for l:link in l:all_links_on_line let l:body_line_content = getline(l:body_line_nr) let l:link['line_nr'] = l:body_line_nr " Find the link reference definition with a corresponding label let l:ref_section_copy = deepcopy(l:ref_section) let l:corresponding_refs = filter(l:ref_section_copy, \ {_, val -> val['label'] ==# l:link['destination']}) " Corresponding label was not found in reference section, so label will be " changed to '???', to mark that it's broken if len(l:corresponding_refs) == 0 call link#body#ReplaceLink(l:body_line_content, l:link['full_link'], \ l:link['link_text'], '???', l:body_line_nr) continue endif let l:link['url'] = l:corresponding_refs[0]['destination'] let l:link['index'] = l:index " Determine if exactly the same URL was already encountered before let l:all_ref_links_copy = deepcopy(l:all_ref_links) let l:url_matches = filter( l:all_ref_links_copy, \ { _, val -> val['url'] ==# l:link['url'] } ) " 'Merge' labels if len(l:url_matches) >= 1 let l:link['index'] = l:url_matches[0]['index'] call link#body#ReplaceLink(l:body_line_content, l:link['full_link'], \ l:link['link_text'], l:link['index'], l:body_line_nr) continue endif " Label differs from index: e.g. label says 5 while it's the 3rd link if l:link['destination'] !=# l:link['index'] call link#body#ReplaceLink(l:body_line_content, l:link['full_link'], \ l:link['link_text'], l:link['index'], l:body_line_nr) endif call add(l:all_ref_links, l:link) let l:index += 1 endfor endfor " Delete current reference section to black hole register silent execute 'normal! :' .. l:ref_section_start .. ',' .. l:ref_section_end \ .. "$ delete _ \" " Generate new reference section for l:idx in range( len(l:all_ref_links) ) let l:ref_link = l:all_ref_links[l:idx] let l:line_nr = l:divider_line_nr + l:idx call link#reference#Add(l:ref_link['index'], l:ref_link['url'], l:line_nr) endfor let [ l:first_label_line_nr, @_] = link#label#GetInfo('first') let [ l:last_label_line_nr, @_ ] = link#label#GetInfo('last') let l:new_ref_len = l:last_label_line_nr - l:ref_section_start + 1 call link#utils#DisplayMsg('Finished reformatting reference links and reference section') call link#utils#DisplayMsg('Number of lines in reference section -- Before: ' \ .. l:orig_ref_len .. ' -- After: ' .. l:new_ref_len) call link#lifecycle#Finalize(l:orig_view, l:orig_fold_option) endfunction link.vim-1.4.0/autoload/link/000077500000000000000000000000001472625555500160305ustar00rootroot00000000000000link.vim-1.4.0/autoload/link/body.vim000066400000000000000000000106131472625555500175030ustar00rootroot00000000000000" Scan single line in document body for inline link [foo](http://bar.com) or " reference link [foo][5] " Return list of dictionaries, containing full link [foo](http://bar.com), link " text, destination (URL or reference), length of total match and start position " of total match function! link#body#ParseLineFor(type, line_nr) abort if a:type ==# 'inline' " Match `http://`, `ftp://`, `www.` etc. let l:protocol = g:link#globals#re['protocol'] .. '|www\.' if link#utils#IsFiletypeMarkdown() let l:regex_start = '\v' .. '\[(' .. '[^]]+' .. ')\]' .. '\((' let l:regex_end = '[^)]+' .. ')\)' " Match link to URL, e.g. [foo](http://bar.com) if link#utils#ConvertUrlsOnly() let l:regex = l:regex_start .. '%(' .. l:protocol .. ')' .. l:regex_end " Match link to URL, or to internal wiki page, e.g. [foo](bar.md) else let l:regex = l:regex_start .. l:regex_end endif " Match http://bar.com else " Avoid trailing punctuation character from being considered part of URL let l:last_url_char = '[a-zA-Z0-9/#-]' " '()' ensures the right match ends up in the right subgroup let l:regex = '\v' .. '()' .. '(%(' .. l:protocol .. ')' .. '\S+' .. \ l:last_url_char .. ')' endif elseif a:type ==# 'reference' " Match [foo][3] if link#utils#IsFiletypeMarkdown() let l:regex = '\v' .. '\[(' .. '[^]]+' .. ')\]' .. '\[(' .. '[^]]+' .. ')\]' " Match [3] else let l:regex = '\v' .. '()' .. '\[(' .. '[^]]+' .. ')\]' endif else throw 'Invalid type' endif let l:line_content = getline(a:line_nr) let l:line_len = len(l:line_content) let l:all_links = [] let l:col = 0 " Get all links on the specified line while l:col < l:line_len let l:match_list = matchlist(l:line_content, l:regex, l:col) if len(l:match_list) == 0 break endif " First character is considered as 0 let l:match_start = match(l:line_content, '\V' .. l:match_list[0], l:col) + 1 let l:total_len = strlen(l:match_list[0]) let l:link = { \ 'full_link': l:match_list[0], \ 'link_text': l:match_list[1], \ 'destination': l:match_list[2], \ 'length': l:total_len, \ 'col_start': l:match_start, \ } call add(l:all_links, l:link) let l:new_col = l:match_start + l:total_len if l:new_col == l:col let l:new_col += 1 " Avoid infinite loop endif let l:col = l:new_col endwhile return l:all_links endfunction " Determine which link to use, if there are multiple links on one line " The link that is positioned behind or on the cursor will be picked function! link#body#PickClosestLink(links, col_nr) abort if len(a:links) == 1 return a:links[0] endif for l:link in a:links if a:col_nr < l:link['col_start'] + l:link['length'] break endif endfor return l:link endfunction " Convert inline link to reference link by replacing line content function! link#body#ReplaceLink(line_content, full_link, link_text, label, line_nr) abort " URLs containing the * character are not supported let l:esc_full_link = escape(a:full_link, '[]') if link#utils#IsFiletypeMarkdown() let l:ref_link = '[' .. a:link_text .. '][' .. a:label .. ']' else let l:ref_link = '[' .. a:label .. ']' endif let l:new_line_content = substitute(a:line_content, l:esc_full_link, l:ref_link, '') call setline(a:line_nr, l:new_line_content) endfunction " Return boolean indicating if line should be skipped function! link#body#SkipLine(cur_line_nr) abort let l:line_content = getline(a:cur_line_nr) " In `markdown` and `mail` buffers skip links in blockquotes, except if " variable is set if (link#utils#IsFiletypeMarkdown() || &filetype ==# 'mail') && \ l:line_content =~# '^>' && \ get(b:, 'link_include_blockquotes', 0) != 1 return 1 endif if exists('b:link_skip_line') " Use custom pattern let l:regex = b:link_skip_line else " Use a default let l:regex = '\V\^' .. substitute( escape(&commentstring, '\'), '%s', '\\.\\*', 'g' ) .. '\$' endif return match( l:line_content, l:regex ) >= 0 endfunction " Limit range to line containing heading/divider, so reference section stays " untouched function! link#body#LimitRange(divider_line_nr, range_end_line_nr) abort range if a:range_end_line_nr >= a:divider_line_nr return a:divider_line_nr - 1 endif return a:range_end_line_nr endfunction link.vim-1.4.0/autoload/link/globals.vim000066400000000000000000000027711472625555500201770ustar00rootroot00000000000000" Default values, can be overridden by vimrc let g:link#globals#defaults = { \ 'filetypes': [ 'markdown', 'vimwiki', 'mail', 'text' ], \ 'heading_markdown': '## Links', \ 'heading_other': 'Links:', \ 'start_index': 0, \ } " Error messages let g:link#globals#errors = { \ 'no_inline_link': \ 'No inline link found on this line in the format of "[foo](http://bar.com)" (Markdown) or "http://bar.com" (other)', \ 'no_reference_link': \ 'No reference link found on this line in the format of "[foo][3]" (Markdown) or "[3]" (other)', \ 'no_ref_def': \ 'No link reference definition in the format of "[3]: ..." found on this line', \ 'no_label_ref_section': \ 'The following label was not found in the reference section:', \ 'no_label_body': \ 'The following label was not found in the document body:', \ 'not_from_ref': \ 'This action is only possible from the document body, not from the reference section', \ 'no_valid_url': \ 'Not a valid URL:', \ 'open_in_browser_failed': \ 'Failed to open the URL, because of this error:', \ 'no_position_pattern': \ 'Failed to detect pattern to position reference section:', \ 'no_ref_section': \ 'No reference section was found', \ } let s:re_ref_def_pre = '\v^\s*\[\zs' let s:re_ref_def_suf = '\ze\]:\s+' let g:link#globals#re = { \ 'ref_def_pre': s:re_ref_def_pre, \ 'ref_def_suf': s:re_ref_def_suf, \ 'ref_def': s:re_ref_def_pre .. '\d+' .. s:re_ref_def_suf, \ 'protocol': '[a-zA-Z][a-zA-Z0-9.-]{1,9}:\/\/' \ } link.vim-1.4.0/autoload/link/heading.vim000066400000000000000000000020771472625555500201520ustar00rootroot00000000000000" Return applicable heading, in order: buffer-local, global or default heading function! link#heading#GetText() abort if exists('b:link_heading') | return b:link_heading | endif if exists('g:link_heading') | return g:link_heading | endif if link#utils#IsFiletypeMarkdown() return g:link#globals#defaults['heading_markdown'] else return g:link#globals#defaults['heading_other'] endif endfunction " Return boolean, indicating whether heading is set to empty string function! link#heading#IsEmpty(heading_text) abort return empty(a:heading_text) endfunction " Return boolean indicating if heading needs to be added function! link#heading#IsNeeded(is_empty, heading_text) abort if a:is_empty | return 0 | endif let l:match_line_nr = search('^' .. a:heading_text .. '\s*$', 'nw') return l:match_line_nr == 0 endfunction " Add the specified heading to the buffer function! link#heading#Add(heading_text, line_nr) abort " Add a blank line above and below the heading let l:lines = [ '', a:heading_text, '' ] call append( a:line_nr , l:lines ) endfunction link.vim-1.4.0/autoload/link/jump.vim000066400000000000000000000034631472625555500175260ustar00rootroot00000000000000" Jump from a reference link in the document body to the corresponding link " reference definition in the reference section " Return line number of match, or 0 in case of no match function! link#jump#ToReferenceSection(orig_line_nr, orig_col_nr, divider_line_nr) abort let l:all_links = link#body#ParseLineFor('reference', a:orig_line_nr) if len(l:all_links) == 0 call link#utils#DisplayError('no_reference_link') return 0 endif let l:link = link#body#PickClosestLink(l:all_links, a:orig_col_nr) let l:label = l:link['destination'] " Start search at heading call cursor(a:divider_line_nr, 1) " Move cursor to match let l:regex = g:link#globals#re['ref_def_pre'] .. l:label .. g:link#globals#re['ref_def_suf'] let l:match_line_nr = search(l:regex, 'cW') " Put cursor on start of URL keepjumps normal! W " No match if l:match_line_nr == 0 call link#utils#DisplayError('no_label_ref_section', l:label) endif return l:match_line_nr endfunction " Jump from a link reference definition in the reference section to the " corresponding reference link in the document body " Return line number of match, or 0 in case of no match function! link#jump#ToBody(orig_line_nr, divider_line_nr) abort let l:reference_section = link#reference#Parse(a:orig_line_nr, 'one') if len(l:reference_section) == 0 call link#utils#DisplayError('no_ref_def') return 0 endif let l:link_reference_definition = l:reference_section[0] let l:label_idx = l:link_reference_definition['label'] " Start search at first line call cursor(1, 1) " Stop search at heading let l:body_line_nr = search('\v\[' .. l:label_idx .. '\]', 'cWe', a:divider_line_nr) " No match if l:body_line_nr == 0 call link#utils#DisplayError('no_label_body', l:label_idx) endif return l:body_line_nr endfunction link.vim-1.4.0/autoload/link/label.vim000066400000000000000000000024121472625555500176230ustar00rootroot00000000000000" Return the start index for the first label, buffer-local or global, or default function! link#label#GetStartIndex() abort if exists('b:link_start_index') | return b:link_start_index | endif if exists('g:link_start_index') | return g:link_start_index | endif return g:link#globals#defaults['start_index'] endfunction " Return list of line number and label index, for first or last label in " reference section " Position : `first` or `last` function! link#label#GetInfo(position) abort let l:save_cursor = getcurpos() let l:search_flags = 'cW' if a:position ==# 'first' call link#utils#MoveCursorTo('start') elseif a:position ==# 'last' call link#utils#MoveCursorTo('end') let l:search_flags ..= 'b' else throw 'Invalid position' endif let l:regex = g:link#globals#re['ref_def'] " Move cursor to search result let l:match_line_nr = search(l:regex, l:search_flags) " Return -1 when no link reference definition is found if l:match_line_nr == 0 return [ -1, -1 ] endif " Get number between square brackets let l:line_content = getline(l:match_line_nr) let l:match = matchstr(l:line_content, l:regex) let l:label_idx = str2nr(l:match) call setpos('.', l:save_cursor) return [ l:match_line_nr, l:label_idx ] endfunction link.vim-1.4.0/autoload/link/lifecycle.vim000066400000000000000000000016761472625555500205160ustar00rootroot00000000000000" Disable folding " Return list of original view, line number, column number and folding option function! link#lifecycle#Initialize() abort let l:orig_view = winsaveview() let l:line_nr = l:orig_view['lnum'] let l:col_nr = l:orig_view['col'] + 1 let l:orig_fold_option = &foldenable setlocal nofoldenable return [ l:orig_view, l:line_nr, l:col_nr, l:orig_fold_option ] endfunction " Restore original view and folding option function! link#lifecycle#Finalize(orig_view, orig_fold_option) abort call winrestview(a:orig_view) let &l:foldenable = a:orig_fold_option call s:VimwikiRefLinksRefresh() endfunction " Fix Vimwiki bug where newly created reference links don't work instantly " See https://github.com/vimwiki/vimwiki/issues/1005 and " https://github.com/vimwiki/vimwiki/issues/1351 function! s:VimwikiRefLinksRefresh() abort if &filetype !~# 'vimwiki' | return | endif call vimwiki#markdown_base#scan_reflinks() endfunction link.vim-1.4.0/autoload/link/reference.vim000066400000000000000000000036241472625555500205100ustar00rootroot00000000000000" Add a link reference definition to the reference section function! link#reference#Add(label, url, last_label_line_nr = '$') abort let l:new_line_content = '[' .. a:label .. ']: ' .. a:url call append(a:last_label_line_nr, l:new_line_content) endfunction " Parse the reference section, in its entirety or just one line " Return a list of dictionaries " Type : `all` or `one` function! link#reference#Parse(start_line_nr, type) abort let l:cur_line_nr = a:start_line_nr if a:type ==# 'all' let l:last_line_nr = line('$') elseif a:type ==# 'one' let l:last_line_nr = a:start_line_nr else throw 'Invalid type: ' .. a:type endif " https://github.github.com/gfm/#link-reference-definition let l:all_link_reference_definitions = [] let l:regex = '\v^\s*\[(\d+)\]:\s+(\S+)' " Loop over one line, or over all lines from divider/heading until last line for l:cur_line_nr in range(l:cur_line_nr, l:last_line_nr) let l:cur_line_content = getline(l:cur_line_nr) let l:match_list = matchlist(l:cur_line_content, l:regex) if len(l:match_list) == 0 continue endif let l:link_ref_def = { \ 'line_nr': l:cur_line_nr - 1, \ 'full_match': l:match_list[0], \ 'label': l:match_list[1], \ 'destination': l:match_list[2], \ } call add(l:all_link_reference_definitions, l:link_ref_def) endfor return l:all_link_reference_definitions endfunction " Position reference section, so it isn't at the bottom of the buffer function! link#reference#PositionSection() abort if !exists('b:link_heading_before') | return | endif " Move cursor to line matching pattern let l:match_line_nr = search(b:link_heading_before, 'bcWz') " Cannot find pattern: show error if l:match_line_nr == 0 call link#utils#DisplayError('no_position_pattern', b:link_heading_before) " Can find pattern: move 2 lines up else keepjumps normal! 2k endif endfunction link.vim-1.4.0/autoload/link/utils.vim000066400000000000000000000040141472625555500177040ustar00rootroot00000000000000" Display message in Vim's command-line function! link#utils#DisplayMsg(msg) abort echohl WarningMsg echomsg a:msg echohl None endfunction " Display error in Vim's command-line function! link#utils#DisplayError(error_key, suffix = '') abort echohl ErrorMsg let l:msg = g:link#globals#errors[a:error_key] if len(a:suffix) | let l:msg ..= ' ' .. a:suffix | endif echomsg l:msg echohl None endfunction " Move cursor to first character of first line or last char of last line function! link#utils#MoveCursorTo(destination) abort if a:destination ==# 'start' let l:row = 1 let l:col = 1 elseif a:destination ==# 'end' let l:row = line('$') let l:col = col( [ l:row, '$' ] ) " Last char of last line else throw 'Invalid destination' endif call cursor(l:row, l:col) endfunction " Return boolean indicating if filetype includes Markdown or Vimwiki function! link#utils#IsFiletypeMarkdown() abort " NOTE This assumes that Vimwiki uses Markdown syntax return &filetype =~# 'markdown' || &filetype =~# 'vimwiki' endfunction " Return operating system: 'Darwin', 'Linux' or 'Windows' function! link#utils#GetOperatingSystem() abort " https://vi.stackexchange.com/a/2577/50213 if has('win64') || has('win32') || has('win16') return 'Windows' else return substitute(system('uname'), '\n', '', '') endif endfunction " Return command to open URL in default application, based on operating system function! link#utils#GetOpenCommand(os) abort if a:os ==? 'Darwin' return 'open' elseif a:os ==? 'Linux' return 'xdg-open' elseif a:os ==? 'Windows' return 'start' else throw 'Unknown operating system' endif endfunction " Return boolean indicating if only URLs should be converted, not links to " internal wiki pages function! link#utils#ConvertUrlsOnly() abort if exists('b:link_disable_internal_links') return b:link_disable_internal_links endif if exists('g:link_disable_internal_links') return g:link_disable_internal_links endif return 0 endfunction link.vim-1.4.0/doc/000077500000000000000000000000001472625555500140305ustar00rootroot00000000000000link.vim-1.4.0/doc/link.txt000066400000000000000000000362301472625555500155320ustar00rootroot00000000000000*link.txt* Convert inline links (Markdown or plaintext) to reference links *link* *link.vim* > __ __ .__ __. __ ___ ____ ____ __ .___ ___. | | | | | \ | | | |/ / \ \ / / | | | \/ | | | | | | \| | | ' / \ \/ / | | | \ / | | | | | | . ` | | < \ / | | | |\/| | | `----.| | | |\ | | . \ __ \ / | | | | | | |_______||__| |__| \__| |__|\__\ (__) \__/ |__| |__| |__| < Version: 1.4.0 Author: qadzek License: MIT ============================================================================== CONTENTS *link-contents* 1. Introduction ......... |link-introduction| 2. Usage ................ |link-usage| 3. Mappings ............. |link-mappings| 4. Configuration ........ |link-configuration| 5. Misc ................. |link-misc| 6. Limitations .......... |link-limitations| 7. Contributing ......... |link-contributing| 8. Changelog ............ |link-changelog| 9. Credits .............. |link-credits| ============================================================================== INTRODUCTION *link-introduction* Reference links allow for cleaner documents. Storing (long) URLs at the bottom of your document helps maintain the flow of the body of the text. However, managing reference links manually can be tedious. This plugin for Vim and Neovim helps converting and handling these links. Links in Markdown syntax and plaintext links (e.g. in emails, in text files etc.) are supported. The main command will convert > # Notes [Vim](https://www.vim.org) and [Neovim](https://neovim.io) are text editors. into > # Notes [Vim][0] and [Neovim][1] are text editors. ## Links [0]: https://www.vim.org [1]: https://neovim.io < URLs are moved to a reference section. A heading is used to mark the divide between the document body and the reference section. It will be added automatically if needed and can be customized or disabled. Terminology ~ Markdown format Plaintext format - inline link: `[Vim](https://www.vim.org)` `Vim https://www.vim.org` - reference link: `[Vim][0]` `Vim [0]` - link text: `[Vim]` `none` - label: `[0]` `[0]` - link reference definition: `[0]: https://www.vim.org` `[0]: https://www.vim.org` - heading: `## Links` `Links:` - document body: part of buffer above heading, containing the main text - reference section: part of buffer below heading, containing link reference definitions For more information about the syntax Markdown uses for links, refer to the CommonMark Specification at https://spec.commonmark.org/0.31.2/#links ============================================================================== USAGE *link-usage* The link.vim plugin exposes the following commands. All `:LinkConvert*` commands will add a heading below the document body if needed. *:LinkConvertSingle* Convert one inline link on the current line of the document body to a reference link. If there are multiple links on the current line, pick the (first) link that is positioned on the cursor or behind the cursor. *:LinkConvertSingleInsert* Same as above; intended to be used with an Insert mode mapping. Return to Insert mode after conversion and position the cursor just outside the reference link. *:LinkConvertRange* Convert all inline links within a range of lines to reference links. Intended to be used: - with a Visual mode mapping, - after selecting lines in Visual mode `:'<,'>LinkConvertRange`, or - with an explicit range `:5,12 LinkConvertRange` *:LinkConvertAll* Convert all inline links in the document body to reference links. *:LinkOpen* For a reference link within the document body, open the URL of the corresponding link reference definition in the default browser. *:LinkPeek* For a reference link within the document body, show a preview of the corresponding link reference definition. *:LinkJump* Move the cursor from a reference link within the document body to a corresponding link reference definition in the reference section, and the other way around. *:LinkReformat* Reformat reference links and reference section. This command is powerful; use it with care. It deletes the current reference section and reconstructs it. It performs the following actions: - Renumber links in document body and in reference section: > [Vim][1] is a text editor. [Neovim][0] is another one. ## Links [0]: https://neovim.io [1]: https://www.vim.org < is turned into > [Vim][0] is a text editor. [Neovim][1] is another one. ## Links [0]: https://www.vim.org [1]: https://neovim.io < - Merge links sharing the same URL: > Vim [0] is a text editor. Bram Moolenaar created Vim [1]. Links: [0]: https://www.vim.org [1]: https://www.vim.org < is turned into > Vim [0] is a text editor. Bram Moolenaar created Vim [0]. Links: [0]: https://www.vim.org < - Delete link reference definitions that are no longer needed: > [Vim][0] is a text editor. Neovim is another one. ## Links [0]: https://www.vim.org [1]: https://neovim.io < is turned into > [Vim][0] is a text editor. Neovim is another one. ## Links [0]: https://www.vim.org < - Mark missing links as '???': > Vim [0] is a text editor. Neovim [1] is another one. Links: [0]: https://www.vim.org < is turned into > Vim [0] is a text editor. Neovim [???] is another one. Links: [0]: https://www.vim.org < ============================================================================== MAPPINGS *link-mappings* No mappings are built-in to avoid conflicts with existing key bindings. *g:link_use_default_mappings* Enable the suggested key bindings (the same as mentioned below) by adding this line to your `vimrc`: > let g:link_use_default_mappings = 1 < If you prefer to specify your own key bindings, ensure the variable mentioned above is not set (or set to `0`) and add the following to your `vimrc`: > augroup linkvim_key_bindings autocmd! autocmd Filetype markdown,vimwiki,mail,text :call LinkVimAddKeyBindings() augroup END function! LinkVimAddKeyBindings() nmap c (LinkVim-ConvertSingle) imap c (LinkVim-ConvertSingleInsert) vmap c (LinkVim-ConvertRange) nmap a (LinkVim-ConvertAll) nmap j (LinkVim-Jump) nmap o (LinkVim-Open) nmap p (LinkVim-Peek) nmap r (LinkVim-Reformat) endfunction < You might want to change the filetypes mentioned in the |autocmd|. Another way to ensure that these key bindings are only applied to certain filetypes is to add them to e.g. `~/.vim/ftplugin/markdown.vim`. That way, you don't need to use an |autocmd| or function. ============================================================================== CONFIGURATION *link-configuration* By default, the plugin operates on the following filetypes: `markdown`, `vimwiki`, `email` and `text`. *g:link_enabled_filetypes* These filetypes can be customized: > let g:link_enabled_filetypes = [ 'markdown', 'gitcommit' ] < For examples of how users have configured this plugin for particular filetypes, e.g. `gitcommit` buffers, visit the Wiki: https://github.com/qadzek/link.vim/wiki ------------------------------------------------------------------------------ Some of the following configuration options exist as a local buffer variable (`b:`) or as a global variable (`g:`). The buffer-local variables enjoy a higher priority. Global variables are specified in `vimrc`. Local buffer variables can be set in their corresponding file, e.g. for mail buffers in `~/.vim/ftplugin/mail.vim` They can also be set in `vimrc`, if they are wrapped in an |autocmd|: > augroup link_mail autocmd! autocmd Filetype mail let b:link_heading = 'My Links:' augroup END < ------------------------------------------------------------------------------ *b:link_heading* *g:link_heading* By default, the heading `## Links` (Markdown) or `Links:` (other filetypes) will be used to mark the divide between the document body and the reference section. To modify this heading: `let g:link_heading = '# My Resources'` The heading can be disabled by setting it to an empty string. This is especially useful when link reference definitions won't be visible in the rendered output, e.g., for `README.md` files displayed on GitHub: > augroup linkvim_readme autocmd! autocmd BufRead,BufNewFile README.md let b:link_heading = '' augroup END < *b:link_start_index* *g:link_start_index* By default, the first converted link gets a label of 0. To change this: `let g:link_start_index = 1` *b:link_heading_before* By default, the heading is added to the last line. You can specify a pattern to which the cursor will be moved before the heading is added. This works even if the heading is disabled. This regular expression is matched starting from the bottom of the document. This allows to position the heading, and the entire reference section, elsewhere. E.g. for a `gitcommit` buffer, the following could be useful: `let b:link_heading_before = '^# Please enter the commit message'` *b:link_skip_line* By default, links in lines matching |commentstring| are not converted. This pattern can be modified. E.g. to skip blockquotes: `let b:link_skip_line = '^>'` *b:link_include_blockquotes* By default, in `markdown` and `mail` buffers, links in blockquotes (lines starting with `>`) are not converted. To include them: `let b:link_include_blockquotes = 1` *b:link_disable_internal_links* *g:link_disable_internal_links* Popular knowledge base plugins, such as Vimwiki, obsidian.nvim, and wiki.vim, support links to internal wiki pages. To assist their users, by default a link like `[strawberry cake](recipes.md)` will be converted in Markdown buffers. To disable this feature and convert only URLs: `let g:link_disable_internal_links = 1` ============================================================================== MISC *link-misc* Consider using an alternative Markdown plugin for additional link-related features. For example, https://github.com/preservim/vim-markdown supports concealing, so `[Foo][3]` is displayed as just `Foo` when not in insert mode. Other options: - https://github.com/tpope/vim-markdown (this is the default) - https://github.com/SidOfc/mkdx/ - https://github.com/vim-pandoc/vim-pandoc-syntax - https://github.com/MeanderingProgrammer/render-markdown.nvim ------------------------------------------------------------------------------ Images using Markdown syntax are supported. `![Sun](https://example.com/sun.jpg)` will be converted to `![Sun][2]`. ============================================================================== LIMITATIONS *link-limitations* - When converting an inline link to a reference link, a link reference definition will be created, even if the same URL is already present in the reference section. It would be better if the same label were reused. Using `:LinkReformat` fixes this though. - URLs containing the asterisk character (`*`) are not supported. - Only numeric labels are supported. ============================================================================== CONTRIBUTING *link-contributing* Pull requests are welcome. The Vint linter, the Vader test framework and the Google Style Guide are being used. https://github.com/Vimjas/vint https://github.com/junegunn/vader.vim https://google.github.io/styleguide/vimscriptguide.xml https://google.github.io/styleguide/vimscriptfull.xml To analyze the code for issues: `vint **/*.vim` To execute the tests: `./test/run_tests.sh` ============================================================================== CHANGELOG *link-changelog* 1.4.0 2024-12-11 - Skip links in blockquotes (#16) 1.3.0 2024-11-28 - Support converting links to internal wiki pages (#14) 1.2.0 2024-11-07 - Support link conversion without using a heading 1.1.0 2024-11-04 - Support `` mappings 1.0.5 2024-09-11 - Fix trailing punctuation characters being seen as part of the URL (#12) 1.0.4 2024-09-10 - Fix issue with identical links on the same line - Fix unintended scrolling 1.0.3 2024-05-13 - Support special characters in URLs when opening them in browser 1.0.2 2024-05-08 - Convert filetype plugin to global plugin BREAKING CHANGE - `Links:` is default heading if filetype is not Markdown - Support `b:link_start_index` - Rename plugin BREAKING CHANGE 1.0.1 2024-05-06 - Remove :MdLinkDelete BREAKING CHANGE - Add :MdLinkReformat to renumber, merge and delete links 1.0.0 2024-05-04 - Remove pre- and post-processing commands BREAKING CHANGE - Add native support for plaintext links - Rename :MdLinkDeleteUnneededRefs BREAKING CHANGE 0.5.0 2024-04-17 - Allow positioning of reference section - Add pre- and post-processing of plaintext links - Allow lines to be skipped if pattern matches 0.4.1 2024-04-10 - Fix cursor position not getting restored (#9) 0.4.0 2024-04-08 - Allow buffer-local heading (#7) 0.3.1 2024-04-08 - Fix too lenient regex for inline links (#4) 0.3.0 2024-04-05 - Add :MdLinkConvertRange (#2) 0.2.0 2024-03-19 - Add :MdLinkOpen 0.1.0 2024-03-15 - Initial version ============================================================================== CREDITS *link-credits* Learn Vimscript the Hard Way by Steve Losh: https://learnvimscriptthehardway.stevelosh.com/ Contributors and their GitHub usernames: - Enno (@Konfekt) ============================================================================== vim:tw=78:ts=8:ft=help:norl: link.vim-1.4.0/doc/tags000066400000000000000000000026721472625555500147200ustar00rootroot00000000000000:LinkConvertAll link.txt /*:LinkConvertAll* :LinkConvertRange link.txt /*:LinkConvertRange* :LinkConvertSingle link.txt /*:LinkConvertSingle* :LinkConvertSingleInsert link.txt /*:LinkConvertSingleInsert* :LinkJump link.txt /*:LinkJump* :LinkOpen link.txt /*:LinkOpen* :LinkPeek link.txt /*:LinkPeek* :LinkReformat link.txt /*:LinkReformat* b:link_disable_internal_links link.txt /*b:link_disable_internal_links* b:link_heading link.txt /*b:link_heading* b:link_heading_before link.txt /*b:link_heading_before* b:link_include_blockquotes link.txt /*b:link_include_blockquotes* b:link_skip_line link.txt /*b:link_skip_line* b:link_start_index link.txt /*b:link_start_index* g:link_disable_internal_links link.txt /*g:link_disable_internal_links* g:link_enabled_filetypes link.txt /*g:link_enabled_filetypes* g:link_heading link.txt /*g:link_heading* g:link_start_index link.txt /*g:link_start_index* g:link_use_default_mappings link.txt /*g:link_use_default_mappings* link link.txt /*link* link-changelog link.txt /*link-changelog* link-configuration link.txt /*link-configuration* link-contents link.txt /*link-contents* link-contributing link.txt /*link-contributing* link-credits link.txt /*link-credits* link-introduction link.txt /*link-introduction* link-limitations link.txt /*link-limitations* link-mappings link.txt /*link-mappings* link-misc link.txt /*link-misc* link-usage link.txt /*link-usage* link.txt link.txt /*link.txt* link.vim link.txt /*link.vim* link.vim-1.4.0/plugin/000077500000000000000000000000001472625555500145615ustar00rootroot00000000000000link.vim-1.4.0/plugin/link.vim000066400000000000000000000053251472625555500162400ustar00rootroot00000000000000" Boilerplate; see `:help use-cpo-save` if exists('g:loaded_link') | finish | endif let g:loaded_link = 1 let s:save_compatible_options = &cpoptions set cpoptions&vim " User can specify for which filetypes the plugin should be enabled let s:fts = get(g:, 'link_enabled_filetypes', g:link#globals#defaults['filetypes']) let s:fts = join(s:fts, ',') " Enable plugin on desired filetypes augroup link_vim_filetypes autocmd! execute 'autocmd FileType ' .. s:fts .. ' call LinkEnable()' augroup end function! LinkEnable() abort " Define commands " `init_view` stores view of current window (cursor position etc.) before " range function moves cursor to first line of range command! -buffer -bar -range LinkConvertRange \ let b:init_view = winsaveview() | \ :,call link#Convert() command! -buffer -bar LinkConvertAll :% LinkConvertRange command! -buffer -bar LinkConvertSingle \ let b:init_view = winsaveview() | \ :call link#Convert('single-link') command! -buffer -bar LinkConvertSingleInsert \ let b:init_view = winsaveview() | \ :call link#Convert('single-link', 'insert') command! -buffer -bar LinkJump :call link#Connect('jump') command! -buffer -bar LinkOpen :call link#Connect('open') command! -buffer -bar LinkPeek :call link#Connect('peek') command! -buffer -bar LinkReformat :call link#Reformat() " Initialize mappings nnoremap (LinkVim-ConvertSingle) :LinkConvertSingle inoremap (LinkVim-ConvertSingleInsert) :LinkConvertSingleInsert vnoremap (LinkVim-ConvertRange) :LinkConvertRange nnoremap (LinkVim-ConvertAll) :LinkConvertAll nnoremap (LinkVim-Jump) :LinkJump nnoremap (LinkVim-Open) :LinkOpen nnoremap (LinkVim-Peek) :LinkPeek nnoremap (LinkVim-Reformat) :LinkReformat " Apply default mappings, if user has set special variable in vimrc if get(g:, 'link_use_default_mappings', 0) nmap c (LinkVim-ConvertSingle) imap c (LinkVim-ConvertSingleInsert) vmap c (LinkVim-ConvertRange) nmap a (LinkVim-ConvertAll) nmap j (LinkVim-Jump) nmap o (LinkVim-Open) nmap p (LinkVim-Peek) nmap r (LinkVim-Reformat) endif endfunction let &cpoptions = s:save_compatible_options unlet s:save_compatible_options link.vim-1.4.0/test/000077500000000000000000000000001472625555500142425ustar00rootroot00000000000000link.vim-1.4.0/test/README.md000066400000000000000000000023621472625555500155240ustar00rootroot00000000000000# Tests ## Workstation To run the tests on your workstation, use the `run_tests.sh` script. Run it with the `-h` flag to view its available options. ## Docker Build the Docker image: `docker image build --build-arg BASE_IMAGE=debian:bookworm-slim -t link.vim ./` Another possible value for `BASE_IMAGE` is for instance `ubuntu:24.04`. Run the container to lint the source code and execute the tests in both Vim and Neovim: `docker container run -it --rm link.vim` If an error occurs, access the container with: `docker container run -it --rm link.vim bash` Once inside, lint the code manually: `~/.local/bin/vint ~/plugged/link.vim/` Run the tests manually: `:Vader **/*.vader` ## Misc The tests that involve opening a URL in a browser will always fail in a Docker container. These tests are marked with the `FIXME` label to prevent them from affecting the exit status. The following Vim and Neovim versions are supported: ```text Vim Neovim Ubuntu 22.04 (Jammy) 8.2 0.6.1 Debian 12 (Bookworm) 9.0 0.7.2 Ubuntu 24.04 (Noble) 9.1 0.9.5 ``` See the [Vim][1] and [Neovim][2] Repology pages for details. [1]: https://repology.org/project/vim/versions [2]: https://repology.org/project/neovim/versions link.vim-1.4.0/test/common/000077500000000000000000000000001472625555500155325ustar00rootroot00000000000000link.vim-1.4.0/test/common/_filetypes.vader000066400000000000000000000021101472625555500207120ustar00rootroot00000000000000" For an unknown reason, both the order of the tests in this file and the order " in which the tests are run, seem to matter. This is why this filename is " prefixed with `_`. Before: unlet! g:vader_exception unlet! g:vader_throwpoint unlet! g:link_enabled_filetypes After: unlet! g:vader_exception unlet! g:vader_throwpoint ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given ruby: filler Execute (Filetype not included in defaults): AssertThrows LinkConvertAll AssertEqual g:vader_exception, 'Vim:E492: Not an editor command: LinkConvertAll' Expect ruby: filler ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: filler Execute (Filetype included in defaults (markdown)): LinkConvertAll Expect markdown: filler ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: filler Execute (Filetype included in defaults (mail)): LinkConvertAll Expect mail: filler ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link.vim-1.4.0/test/common/blockquotes.vader000066400000000000000000000055611472625555500211170ustar00rootroot00000000000000Before: unlet! b:link_include_blockquotes unlet! b:link_heading unlet! b:link_heading_before unlet! b:link_skip_line After: unlet! b:link_include_blockquotes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: lorem [magna](www.magna.com) > Blockquote: [lacus](http://lacus.org/lacus) [vitae](https://vitae.net/index.html) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (By default, in `markdown` buffers links in blockquotes are skipped): LinkConvertAll ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expect markdown: lorem [magna][0] > Blockquote: [lacus](http://lacus.org/lacus) [vitae][1] ## Links [0]: www.magna.com [1]: https://vitae.net/index.html ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: lorem www.magna.com > Blockquote: http://lacus.org/lacus https://vitae.net/index.html ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (By default, in `mail` buffers links in blockquotes are skipped): LinkConvertAll ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expect mail: lorem [0] > Blockquote: http://lacus.org/lacus [1] Links: [0]: www.magna.com [1]: https://vitae.net/index.html ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given gitcommit: lorem www.magna.com > Blockquote: http://lacus.org/lacus https://vitae.net/index.html ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (By default, in `gitcommit` buffers links in blockquotes aren't skipped): LinkConvertAll ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expect gitcommit: lorem [0] > Blockquote: [1] [2] Links: [0]: www.magna.com [1]: http://lacus.org/lacus [2]: https://vitae.net/index.html ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: lorem [magna](www.magna.com) > Blockquote: [lacus](http://lacus.org/lacus) [vitae](https://vitae.net/index.html) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (Links in blockquotes can be included in `markdown` buffers): let b:link_include_blockquotes = 1 LinkConvertAll ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expect markdown: lorem [magna][0] > Blockquote: [lacus][1] [vitae][2] ## Links [0]: www.magna.com [1]: http://lacus.org/lacus [2]: https://vitae.net/index.html ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: lorem www.magna.com > Blockquote: http://lacus.org/lacus https://vitae.net/index.html ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (Links in blockquotes can be included in `mail` buffers): let b:link_include_blockquotes = 1 LinkConvertAll ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expect mail: lorem [0] > Blockquote: [1] [2] Links: [0]: www.magna.com [1]: http://lacus.org/lacus [2]: https://vitae.net/index.html ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link.vim-1.4.0/test/common/heading_add.vader000066400000000000000000000042461472625555500207720ustar00rootroot00000000000000Before: unlet! b:link_heading_before After: unlet! b:link_heading_before ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: # A consectetuer nunc justo ac nisl. ## Nam vitae purus Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Praesent semper magna. In eu justo. Nunc vitae risus nec sem scelerisque consequat. In hac habitasse platea dictumst. Nam posuere Execute (Add heading to bottom of buffer): call link#heading#Add('## My Resources', '$') Expect markdown: # A consectetuer nunc justo ac nisl. ## Nam vitae purus Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Praesent semper magna. In eu justo. Nunc vitae risus nec sem scelerisque consequat. In hac habitasse platea dictumst. Nam posuere ## My Resources ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: Hi Recipient, I hope this email finds you well. Best regards, Your Name -- Your Job Title Your Company Name Your Contact Information Execute (Add heading to top of buffer): call link#heading#Add('Links:', 0) Expect mail: Links: Hi Recipient, I hope this email finds you well. Best regards, Your Name -- Your Job Title Your Company Name Your Contact Information ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given gitcommit: Git commit title Git commit body Body continued # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # # On branch main # Changes to be committed: # modified: foo.txt # Execute (Add heading to middle of buffer): call link#heading#Add('Links:', 5) Expect gitcommit: Git commit title Git commit body Body continued Links: # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # # On branch main # Changes to be committed: # modified: foo.txt # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link.vim-1.4.0/test/common/heading_get_text.vader000066400000000000000000000027131472625555500220620ustar00rootroot00000000000000Before: unlet! g:link_heading unlet! b:link_heading After: unlet! g:link_heading unlet! b:link_heading ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: Execute (Use default heading (Markdown)): let expected = '## Links' let actual = link#heading#GetText() AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: Execute (Use default heading (mail)): let expected = 'Links:' let actual = link#heading#GetText() AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (Modify global heading): let g:link_heading = '# My Resources' let expected = g:link_heading let actual = link#heading#GetText() AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (Modify buffer-local heading): let b:link_heading = 'My Links:' let expected = b:link_heading let actual = link#heading#GetText() AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (Modify global and buffer-local heading): let b:link_heading = 'My Links:' let g:link_heading = '# My Resources' let expected = b:link_heading let actual = link#heading#GetText() AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link.vim-1.4.0/test/common/label_get_info.vader000066400000000000000000000056171472625555500215170ustar00rootroot00000000000000Given markdown; # A consectetuer nunc justo ac nisl. Praesent semper magna. In eu justo. Nunc vitae risus nec sem scelerisque consequat. In hac habitasse platea dictumst. Nam posuere ## Links [2]: http://www.loremipsumdolorsitamet.com [3]: http://www.ipsumloremconsecteturadipiscing.com [4]: http://www.dolorsitametconsecteturadipiscingelit.com [5]: http://www.adipiscingelitipsumdolorsitamet.com Execute (Last line contains label; cursor at top/bottom): call cursor(1, 1) let expected = [ 8, 2 ] let actual = link#label#GetInfo('first') AssertEqual expected, actual call cursor('$', 99) let expected = [ 8, 2 ] let actual = link#label#GetInfo('first') AssertEqual expected, actual call cursor(1, 1) let expected = [ 11, 5 ] let actual = link#label#GetInfo('last') AssertEqual expected, actual call cursor('$', 99) let expected = [ 11, 5 ] let actual = link#label#GetInfo('last') AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown; # A consectetuer nunc justo ac nisl. Praesent semper magna. In eu justo. Nunc vitae risus nec sem scelerisque consequat. In hac habitasse platea dictumst. Nam posuere ## Links [2]: http://www.loremipsumdolorsitamet.com [3]: http://www.ipsumloremconsecteturadipiscing.com [4]: http://www.dolorsitametconsecteturadipiscingelit.com [5]: http://www.adipiscingelitipsumdolorsitamet.com Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Execute (Last line does not contain label; cursor at top/bottom): call cursor(1, 1) let expected = [ 8, 2 ] let actual = link#label#GetInfo('first') AssertEqual expected, actual call cursor('$', 99) let expected = [ 8, 2 ] let actual = link#label#GetInfo('first') AssertEqual expected, actual call cursor(1, 1) let expected = [ 11, 5 ] let actual = link#label#GetInfo('last') AssertEqual expected, actual call cursor('$', 99) let expected = [ 11, 5 ] let actual = link#label#GetInfo('last') AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown; # A consectetuer nunc justo ac nisl. Praesent semper magna. In eu justo. Nunc vitae risus nec sem scelerisque consequat. In hac habitasse platea dictumst. Nam posuere Execute (No labels; cursor at top/bottom): call cursor(1, 1) let expected = [ -1, -1 ] let actual = link#label#GetInfo('first') AssertEqual expected, actual call cursor('$', 99) let expected = [ -1, -1 ] let actual = link#label#GetInfo('first') AssertEqual expected, actual call cursor(1, 1) let expected = [ -1, -1 ] let actual = link#label#GetInfo('last') AssertEqual expected, actual call cursor('$', 99) let expected = [ -1, -1 ] let actual = link#label#GetInfo('last') AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link.vim-1.4.0/test/common/label_get_start_index.vader000066400000000000000000000023731472625555500231040ustar00rootroot00000000000000Before: unlet! g:link_start_index unlet! b:link_start_index After: unlet! g:link_start_index unlet! b:link_start_index ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (Use default label start index): let expected = 0 let actual = link#label#GetStartIndex() AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (Modify global label start index): let g:link_start_index = 100 let expected = g:link_start_index let actual = link#label#GetStartIndex() AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (Modify buffer-local label start index): let b:link_start_index = 50 let expected = b:link_start_index let actual = link#label#GetStartIndex() AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (Modify global and buffer-local label start index): let g:link_start_index = 100 let b:link_start_index = 10 let expected = b:link_start_index let actual = link#label#GetStartIndex() AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link.vim-1.4.0/test/common/reference_add.vader000066400000000000000000000015431472625555500213260ustar00rootroot00000000000000Given markdown: # A consectetuer nunc justo ac nisl. ## Nam vitae purus Cum sociis natoque [penatibus][0] et magnis dis parturient montes, nascetur ridiculus mus. Praesent semper magna. In eu justo. Nunc vitae risus nec sem scelerisque consequat. In hac habitasse platea dictumst. Nam posuere ## Links [0]: http://ipsum.com Execute (Add link reference definition): call link#reference#Add('1', 'https://lorem.com/') Expect markdown: # A consectetuer nunc justo ac nisl. ## Nam vitae purus Cum sociis natoque [penatibus][0] et magnis dis parturient montes, nascetur ridiculus mus. Praesent semper magna. In eu justo. Nunc vitae risus nec sem scelerisque consequat. In hac habitasse platea dictumst. Nam posuere ## Links [0]: http://ipsum.com [1]: https://lorem.com/ ------------------------------------------------------------ link.vim-1.4.0/test/docker.vimrc000066400000000000000000000023231472625555500165530ustar00rootroot00000000000000" Settings --------------------------------------------------------- {{{1 filetype plugin indent on syntax enable " Disable the pager prompt `-- More --`; see `:help pager` and `:help more` set nomore " Key bindings ----------------------------------------------------- {{{1 " Exit tests nnoremap Q :qa! inoremap Q :qa! " Download Plug ---------------------------------------------------- {{{1 " https://github.com/junegunn/vim-plug/wiki/tips let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim' if empty(glob(data_dir . '/autoload/plug.vim')) silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' autocmd VimEnter * PlugInstall --sync | source $MYVIMRC endif " Plug start ------------------------------------------------------- {{{1 " Custom plugin directory, same for Vim and Neovim silent! call plug#begin('~/plugged') " Activate plugins ------------------------------------------------- {{{1 Plug 'junegunn/vader.vim' " Latest release " Plug 'qadzek/link.vim' " Modified plugin Plug '~/plugged/link.vim' " Plug end --------------------------------------------------------- {{{1 call plug#end() link.vim-1.4.0/test/markdown_ft/000077500000000000000000000000001472625555500165555ustar00rootroot00000000000000link.vim-1.4.0/test/markdown_ft/convert_all.vader000066400000000000000000000443221472625555500221150ustar00rootroot00000000000000Before: unlet! g:link_heading unlet! b:link_heading unlet! b:link_heading_before unlet! b:link_skip_line unlet! g:link_start_index After: unlet! g:link_heading unlet! b:link_heading unlet! b:link_heading_before unlet! b:link_skip_line unlet! g:link_start_index ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: Sapien ac iaculis feugiat, lacus lacus accumsan lorem, quis volutpat justo turpis ac mauris. Duis velit magna, scelerisque vitae, varius ut, aliquam vel, justo. Proin ac augue. Nullam auctor lectus vitae arcu. Vestibulum porta justo placerat purus. Ut sem nunc, vestibulum nec, sodales vitae, vehicula eget, ipsum. Sed nec tortor. Aenean malesuada. Nunc convallis, massa eu vestibulum commodo, quam mauris interdum arcu, at pellentesque diam metus ut nulla. Vestibulum eu dolor sit amet lacus varius fermentum. Morbi dolor enim, pulvinar eget, lobortis ac, fringilla ac, turpis. Duis ac erat. Etiam consequat. Integer sed est eu elit pellentesque dapibus. Duis venenatis magna feugiat. Execute (No links): LinkConvertAll Expect markdown: Sapien ac iaculis feugiat, lacus lacus accumsan lorem, quis volutpat justo turpis ac mauris. Duis velit magna, scelerisque vitae, varius ut, aliquam vel, justo. Proin ac augue. Nullam auctor lectus vitae arcu. Vestibulum porta justo placerat purus. Ut sem nunc, vestibulum nec, sodales vitae, vehicula eget, ipsum. Sed nec tortor. Aenean malesuada. Nunc convallis, massa eu vestibulum commodo, quam mauris interdum arcu, at pellentesque diam metus ut nulla. Vestibulum eu dolor sit amet lacus varius fermentum. Morbi dolor enim, pulvinar eget, lobortis ac, fringilla ac, turpis. Duis ac erat. Etiam consequat. Integer sed est eu elit pellentesque dapibus. Duis venenatis magna feugiat. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: Sapien ac iaculis feugiat, [lacus](http://lacus.org/lacus) lacus accumsan lorem, quis volutpat justo turpis ac mauris. Duis velit [magna](www.magna.com), scelerisque [vitae](https://vitae.net/index.html), varius ut, aliquam vel, justo. Proin ac augue. Nullam auctor lectus vitae arcu. Vestibulum porta justo placerat purus. Ut [sem](www.sem.com) [nunc](ftp://nunc.com), vestibulum [nec](www.nec.com), sodales vitae, vehicula eget, ipsum. Sed nec tortor. Aenean malesuada. Nunc convallis, massa eu vestibulum commodo, quam mauris interdum arcu, at [pellentesque](https://pellentesque.com) diam metus ut nulla. Vestibulum eu dolor sit amet lacus varius fermentum. Morbi dolor enim, pulvinar eget, lobortis ac, [fringilla](www.fringilla.com) ac, [turpis](http://turpis.net). Duis ac erat. Etiam consequat. Integer sed est eu elit pellentesque dapibus. Duis venenatis magna feugiat. Execute (Multiple links, no heading): LinkConvertAll Expect markdown: Sapien ac iaculis feugiat, [lacus][0] lacus accumsan lorem, quis volutpat justo turpis ac mauris. Duis velit [magna][1], scelerisque [vitae][2], varius ut, aliquam vel, justo. Proin ac augue. Nullam auctor lectus vitae arcu. Vestibulum porta justo placerat purus. Ut [sem][3] [nunc][4], vestibulum [nec][5], sodales vitae, vehicula eget, ipsum. Sed nec tortor. Aenean malesuada. Nunc convallis, massa eu vestibulum commodo, quam mauris interdum arcu, at [pellentesque][6] diam metus ut nulla. Vestibulum eu dolor sit amet lacus varius fermentum. Morbi dolor enim, pulvinar eget, lobortis ac, [fringilla][7] ac, [turpis][8]. Duis ac erat. Etiam consequat. Integer sed est eu elit pellentesque dapibus. Duis venenatis magna feugiat. ## Links [0]: http://lacus.org/lacus [1]: www.magna.com [2]: https://vitae.net/index.html [3]: www.sem.com [4]: ftp://nunc.com [5]: www.nec.com [6]: https://pellentesque.com [7]: www.fringilla.com [8]: http://turpis.net ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: Sapien ac iaculis feugiat, [lacus](http://lacus.org/lacus) lacus accumsan lorem, quis volutpat justo turpis ac mauris. Duis velit [magna](www.magna.com), scelerisque [vitae](https://vitae.net/index.html), varius ut, aliquam vel, justo. Proin ac augue. Nullam auctor lectus vitae arcu. Vestibulum porta justo placerat purus. Ut [sem](www.sem.com) [nunc](ftp://nunc.com), vestibulum [nec](www.nec.com), sodales vitae, vehicula eget, ipsum. Sed nec tortor. Aenean malesuada. Nunc convallis, massa eu vestibulum commodo, quam mauris interdum arcu, at [pellentesque](https://pellentesque.com) diam metus ut nulla. Vestibulum eu dolor sit amet lacus varius fermentum. Morbi dolor enim, pulvinar eget, lobortis ac, [fringilla](www.fringilla.com) ac, [turpis](http://turpis.net). Duis ac erat. Etiam consequat. Integer sed est eu elit pellentesque dapibus. Duis venenatis magna feugiat. ## Links Execute (Multiple links, heading present, no references yet): LinkConvertAll Expect markdown: Sapien ac iaculis feugiat, [lacus][0] lacus accumsan lorem, quis volutpat justo turpis ac mauris. Duis velit [magna][1], scelerisque [vitae][2], varius ut, aliquam vel, justo. Proin ac augue. Nullam auctor lectus vitae arcu. Vestibulum porta justo placerat purus. Ut [sem][3] [nunc][4], vestibulum [nec][5], sodales vitae, vehicula eget, ipsum. Sed nec tortor. Aenean malesuada. Nunc convallis, massa eu vestibulum commodo, quam mauris interdum arcu, at [pellentesque][6] diam metus ut nulla. Vestibulum eu dolor sit amet lacus varius fermentum. Morbi dolor enim, pulvinar eget, lobortis ac, [fringilla][7] ac, [turpis][8]. Duis ac erat. Etiam consequat. Integer sed est eu elit pellentesque dapibus. Duis venenatis magna feugiat. ## Links [0]: http://lacus.org/lacus [1]: www.magna.com [2]: https://vitae.net/index.html [3]: www.sem.com [4]: ftp://nunc.com [5]: www.nec.com [6]: https://pellentesque.com [7]: www.fringilla.com [8]: http://turpis.net ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: Sapien ac iaculis feugiat, [lacus][0] lacus accumsan lorem, quis volutpat justo turpis ac mauris. Duis velit [magna](www.magna.com), scelerisque [vitae](https://vitae.net/index.html), varius ut, aliquam vel, justo. Proin ac augue. Nullam auctor lectus vitae arcu. Vestibulum porta justo placerat purus. Ut [sem](www.sem.com) [nunc](ftp://nunc.com), vestibulum [nec](www.nec.com), sodales vitae, vehicula eget, ipsum. Sed nec tortor. Aenean malesuada. Nunc convallis, massa eu vestibulum commodo, quam mauris interdum arcu, at [pellentesque][1] diam metus ut nulla. Vestibulum eu dolor sit amet lacus varius fermentum. Morbi dolor enim, pulvinar eget, lobortis ac, [fringilla](www.fringilla.com) ac, [turpis](http://turpis.net). Duis ac erat. Etiam consequat. Integer sed est eu elit pellentesque dapibus. Duis venenatis magna feugiat. ## Links [0]: http://lacus.org/lacus [1]: https://pellentesque.com Execute (Multiple links, heading and references present): LinkConvertAll Expect markdown: Sapien ac iaculis feugiat, [lacus][0] lacus accumsan lorem, quis volutpat justo turpis ac mauris. Duis velit [magna][2], scelerisque [vitae][3], varius ut, aliquam vel, justo. Proin ac augue. Nullam auctor lectus vitae arcu. Vestibulum porta justo placerat purus. Ut [sem][4] [nunc][5], vestibulum [nec][6], sodales vitae, vehicula eget, ipsum. Sed nec tortor. Aenean malesuada. Nunc convallis, massa eu vestibulum commodo, quam mauris interdum arcu, at [pellentesque][1] diam metus ut nulla. Vestibulum eu dolor sit amet lacus varius fermentum. Morbi dolor enim, pulvinar eget, lobortis ac, [fringilla][7] ac, [turpis][8]. Duis ac erat. Etiam consequat. Integer sed est eu elit pellentesque dapibus. Duis venenatis magna feugiat. ## Links [0]: http://lacus.org/lacus [1]: https://pellentesque.com [2]: www.magna.com [3]: https://vitae.net/index.html [4]: www.sem.com [5]: ftp://nunc.com [6]: www.nec.com [7]: www.fringilla.com [8]: http://turpis.net ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: Sapien ac iaculis feugiat, [lacus][0] lacus accumsan lorem, quis volutpat justo turpis ac mauris. Duis velit [magna](www.magna.com), scelerisque [vitae](https://vitae.net/index.html), varius ut, aliquam vel, justo. Proin ac augue. Nullam auctor lectus vitae arcu. Vestibulum porta justo placerat purus. Ut [sem](www.sem.com) [nunc](ftp://nunc.com), vestibulum [nec](www.nec.com), sodales vitae, vehicula eget, ipsum. Sed nec tortor. Aenean malesuada. Nunc convallis, massa eu vestibulum commodo, quam mauris interdum arcu, at [pellentesque][1] diam metus ut nulla. Vestibulum eu dolor sit amet lacus varius fermentum. Morbi dolor enim, pulvinar eget, lobortis ac, [fringilla](www.fringilla.com) ac, [turpis](http://turpis.net). Duis ac erat. Etiam consequat. Integer sed est eu elit pellentesque dapibus. Duis venenatis magna feugiat. ## Links [0]: http://lacus.org/lacus [1]: https://pellentesque.com Execute (Cursor should not move): call cursor(10, 5) LinkConvertAll let [line_nr, col_nr] = getcurpos()[1:2] AssertEqual line_nr, 10 AssertEqual col_nr, 5 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: Sapien ac iaculis feugiat, [lacus](http://lacus.org/lacus) lacus accumsan lorem, quis volutpat justo turpis ac mauris. Duis velit [magna](www.magna.com), scelerisque > [vitae](https://vitae.net/index.html), varius ut, aliquam vel, justo. Proin > augue. Nullam auctor lectus vitae arcu. Vestibulum porta justo placerat. > Ut [sem](www.sem.com) [nunc](ftp://nunc.com), vestibulum [nec](www.nec.com), sodales vitae, vehicula eget, ipsum. Sed nec tortor. Aenean malesuada. Nunc convallis, massa eu vestibulum commodo, quam mauris interdum arcu, at [pellentesque](https://pellentesque.com) diam metus ut nulla. Vestibulum eu dolor sit amet lacus varius fermentum. Morbi dolor enim, pulvinar eget, lobortis ac, [fringilla](www.fringilla.com) ac, [turpis](http://turpis.net). Duis ac erat. Etiam consequat. Integer sed est eu elit pellentesque dapibus. Duis venenatis magna feugiat. Execute (Skip some lines): let b:link_skip_line = '^>' LinkConvertAll Expect markdown: Sapien ac iaculis feugiat, [lacus][0] lacus accumsan lorem, quis volutpat justo turpis ac mauris. Duis velit [magna][1], scelerisque > [vitae](https://vitae.net/index.html), varius ut, aliquam vel, justo. Proin > augue. Nullam auctor lectus vitae arcu. Vestibulum porta justo placerat. > Ut [sem](www.sem.com) [nunc](ftp://nunc.com), vestibulum [nec](www.nec.com), sodales vitae, vehicula eget, ipsum. Sed nec tortor. Aenean malesuada. Nunc convallis, massa eu vestibulum commodo, quam mauris interdum arcu, at [pellentesque][2] diam metus ut nulla. Vestibulum eu dolor sit amet lacus varius fermentum. Morbi dolor enim, pulvinar eget, lobortis ac, [fringilla][3] ac, [turpis][4]. Duis ac erat. Etiam consequat. Integer sed est eu elit pellentesque dapibus. Duis venenatis magna feugiat. ## Links [0]: http://lacus.org/lacus [1]: www.magna.com [2]: https://pellentesque.com [3]: www.fringilla.com [4]: http://turpis.net ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: Sapien ac iaculis feugiat, [lacus](http://lacus.org/lacus) lacus accumsan lorem, quis volutpat justo turpis ac mauris. Duis velit [magna](www.magna.com), scelerisque [vitae](https://vitae.net/index.html), varius ut, aliquam vel, justo. Proin ac augue. Nullam auctor lectus vitae arcu. Vestibulum porta justo placerat purus. Ut [sem](www.sem.com) [nunc](ftp://nunc.com), vestibulum [nec](www.nec.com), sodales vitae, vehicula eget, ipsum. Sed nec tortor. Aenean malesuada. Nunc convallis, massa eu vestibulum commodo, quam mauris interdum arcu, at [pellentesque](https://pellentesque.com) diam metus ut nulla. Vestibulum eu dolor sit amet lacus varius fermentum. Morbi dolor enim, pulvinar eget, lobortis ac, [fringilla](www.fringilla.com) ac, [turpis](http://turpis.net). Duis ac erat. Etiam consequat. Integer sed est eu elit pellentesque dapibus. Duis venenatis magna feugiat. ~~~~~~~~~~~~~ Execute (Change label start index): let g:link_start_index = 100 LinkConvertAll ~~~~~~~~~~~~~ Expect markdown: Sapien ac iaculis feugiat, [lacus][100] lacus accumsan lorem, quis volutpat justo turpis ac mauris. Duis velit [magna][101], scelerisque [vitae][102], varius ut, aliquam vel, justo. Proin ac augue. Nullam auctor lectus vitae arcu. Vestibulum porta justo placerat purus. Ut [sem][103] [nunc][104], vestibulum [nec][105], sodales vitae, vehicula eget, ipsum. Sed nec tortor. Aenean malesuada. Nunc convallis, massa eu vestibulum commodo, quam mauris interdum arcu, at [pellentesque][106] diam metus ut nulla. Vestibulum eu dolor sit amet lacus varius fermentum. Morbi dolor enim, pulvinar eget, lobortis ac, [fringilla][107] ac, [turpis][108]. Duis ac erat. Etiam consequat. Integer sed est eu elit pellentesque dapibus. Duis venenatis magna feugiat. ## Links [100]: http://lacus.org/lacus [101]: www.magna.com [102]: https://vitae.net/index.html [103]: www.sem.com [104]: ftp://nunc.com [105]: www.nec.com [106]: https://pellentesque.com [107]: www.fringilla.com [108]: http://turpis.net ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: foo [Vim](https://www.vim.org) bar [Vim](https://www.vim.org) Execute (Two identical links on the same line): LinkConvertAll Expect markdown: foo [Vim][0] bar [Vim][1] ## Links [0]: https://www.vim.org [1]: https://www.vim.org ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: foo [Vim](https://www.vim.org), bar baz [Neovim](https://neovim.io). qux Execute (URLs with trailing punctuation characters): LinkConvertAll Expect markdown: foo [Vim][0], bar baz [Neovim][1]. qux ## Links [0]: https://www.vim.org [1]: https://neovim.io ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: Sapien ac iaculis feugiat, [lacus](http://lacus.org/lacus) lacus accumsan lorem, quis volutpat justo turpis ac mauris. Duis velit [magna](www.magna.com), scelerisque [vitae](https://vitae.net/index.html), varius ut, aliquam vel, justo. Proin ac augue. Nullam auctor lectus vitae arcu. Vestibulum porta justo placerat purus. Ut [sem](www.sem.com) [nunc](ftp://nunc.com), vestibulum [nec](www.nec.com), sodales vitae, vehicula eget, ipsum. Sed nec tortor. Aenean malesuada. Nunc convallis, massa eu vestibulum commodo, quam mauris interdum arcu, at [pellentesque](https://pellentesque.com) diam metus ut nulla. Vestibulum eu dolor sit amet lacus varius fermentum. Morbi dolor enim, pulvinar eget, lobortis ac, [fringilla](www.fringilla.com) ac, [turpis](http://turpis.net). Duis ac erat. Etiam consequat. Integer sed est eu elit pellentesque dapibus. Duis venenatis magna feugiat. Execute (Empty heading, no reference section present): let b:link_heading = '' LinkConvertAll Expect markdown: Sapien ac iaculis feugiat, [lacus][0] lacus accumsan lorem, quis volutpat justo turpis ac mauris. Duis velit [magna][1], scelerisque [vitae][2], varius ut, aliquam vel, justo. Proin ac augue. Nullam auctor lectus vitae arcu. Vestibulum porta justo placerat purus. Ut [sem][3] [nunc][4], vestibulum [nec][5], sodales vitae, vehicula eget, ipsum. Sed nec tortor. Aenean malesuada. Nunc convallis, massa eu vestibulum commodo, quam mauris interdum arcu, at [pellentesque][6] diam metus ut nulla. Vestibulum eu dolor sit amet lacus varius fermentum. Morbi dolor enim, pulvinar eget, lobortis ac, [fringilla][7] ac, [turpis][8]. Duis ac erat. Etiam consequat. Integer sed est eu elit pellentesque dapibus. Duis venenatis magna feugiat. [0]: http://lacus.org/lacus [1]: www.magna.com [2]: https://vitae.net/index.html [3]: www.sem.com [4]: ftp://nunc.com [5]: www.nec.com [6]: https://pellentesque.com [7]: www.fringilla.com [8]: http://turpis.net ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: Sapien ac iaculis feugiat, [lacus][0] lacus accumsan lorem, quis volutpat justo turpis ac mauris. Duis velit [magna](www.magna.com), scelerisque [vitae](https://vitae.net/index.html), varius ut, aliquam vel, justo. Proin ac augue. Nullam auctor lectus vitae arcu. Vestibulum porta justo placerat purus. Ut [sem](www.sem.com) [nunc](ftp://nunc.com), vestibulum [nec](www.nec.com), sodales vitae, vehicula eget, ipsum. Sed nec tortor. Aenean malesuada. Nunc convallis, massa eu vestibulum commodo, quam mauris interdum arcu, at [pellentesque][1] diam metus ut nulla. Vestibulum eu dolor sit amet lacus varius fermentum. Morbi dolor enim, pulvinar eget, lobortis ac, [fringilla](www.fringilla.com) ac, [turpis](http://turpis.net). Duis ac erat. Etiam consequat. Integer sed est eu elit pellentesque dapibus. Duis venenatis magna feugiat. [0]: http://lacus.org/lacus [1]: https://pellentesque.com Execute (Empty heading, reference section present): let b:link_heading = '' LinkConvertAll Expect markdown: Sapien ac iaculis feugiat, [lacus][0] lacus accumsan lorem, quis volutpat justo turpis ac mauris. Duis velit [magna][2], scelerisque [vitae][3], varius ut, aliquam vel, justo. Proin ac augue. Nullam auctor lectus vitae arcu. Vestibulum porta justo placerat purus. Ut [sem][4] [nunc][5], vestibulum [nec][6], sodales vitae, vehicula eget, ipsum. Sed nec tortor. Aenean malesuada. Nunc convallis, massa eu vestibulum commodo, quam mauris interdum arcu, at [pellentesque][1] diam metus ut nulla. Vestibulum eu dolor sit amet lacus varius fermentum. Morbi dolor enim, pulvinar eget, lobortis ac, [fringilla][7] ac, [turpis][8]. Duis ac erat. Etiam consequat. Integer sed est eu elit pellentesque dapibus. Duis venenatis magna feugiat. [0]: http://lacus.org/lacus [1]: https://pellentesque.com [2]: www.magna.com [3]: https://vitae.net/index.html [4]: www.sem.com [5]: ftp://nunc.com [6]: www.nec.com [7]: www.fringilla.com [8]: http://turpis.net ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link.vim-1.4.0/test/markdown_ft/convert_range.vader000066400000000000000000000233531472625555500224420ustar00rootroot00000000000000Given markdown: Sapien ac iaculis feugiat, lacus lacus accumsan lorem, quis volutpat justo turpis ac mauris. Duis velit magna, scelerisque vitae, varius ut, aliquam vel, justo. Proin ac augue. Nullam auctor lectus vitae arcu. Vestibulum porta justo placerat purus. Ut sem nunc, vestibulum nec, sodales vitae, vehicula eget, ipsum. Sed nec tortor. Aenean malesuada. Nunc convallis, massa eu vestibulum commodo, quam mauris interdum arcu, at pellentesque diam metus ut nulla. Vestibulum eu dolor sit amet lacus varius fermentum. Morbi dolor enim, pulvinar eget, lobortis ac, fringilla ac, turpis. Duis ac erat. Etiam consequat. Integer sed est eu elit pellentesque dapibus. Duis venenatis magna feugiat. Execute (No links): 3,11 LinkConvertRange Expect markdown: Sapien ac iaculis feugiat, lacus lacus accumsan lorem, quis volutpat justo turpis ac mauris. Duis velit magna, scelerisque vitae, varius ut, aliquam vel, justo. Proin ac augue. Nullam auctor lectus vitae arcu. Vestibulum porta justo placerat purus. Ut sem nunc, vestibulum nec, sodales vitae, vehicula eget, ipsum. Sed nec tortor. Aenean malesuada. Nunc convallis, massa eu vestibulum commodo, quam mauris interdum arcu, at pellentesque diam metus ut nulla. Vestibulum eu dolor sit amet lacus varius fermentum. Morbi dolor enim, pulvinar eget, lobortis ac, fringilla ac, turpis. Duis ac erat. Etiam consequat. Integer sed est eu elit pellentesque dapibus. Duis venenatis magna feugiat. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: Sapien ac iaculis feugiat, [lacus](http://lacus.org/lacus) lacus accumsan lorem, quis volutpat justo turpis ac mauris. Duis velit [magna](www.magna.com), scelerisque [vitae](https://vitae.net/index.html), varius ut, aliquam vel, justo. Proin ac augue. Nullam auctor lectus vitae arcu. Vestibulum porta justo placerat purus. Ut [sem](www.sem.com) [nunc](ftp://nunc.com), vestibulum [nec](www.nec.com), sodales vitae, vehicula eget, ipsum. Sed nec tortor. Aenean malesuada. Nunc convallis, massa eu vestibulum commodo, quam mauris interdum arcu, at [pellentesque](https://pellentesque.com) diam metus ut nulla. Vestibulum eu dolor sit amet lacus varius fermentum. Morbi dolor enim, pulvinar eget, lobortis ac, [fringilla](www.fringilla.com) ac, [turpis](http://turpis.net). Duis ac erat. Etiam consequat. Integer sed est eu elit pellentesque dapibus. Duis venenatis magna feugiat. Execute (Multiple links, no heading): 3,11 LinkConvertRange Expect markdown: Sapien ac iaculis feugiat, [lacus](http://lacus.org/lacus) lacus accumsan lorem, quis volutpat justo turpis ac mauris. Duis velit [magna][0], scelerisque [vitae][1], varius ut, aliquam vel, justo. Proin ac augue. Nullam auctor lectus vitae arcu. Vestibulum porta justo placerat purus. Ut [sem][2] [nunc][3], vestibulum [nec][4], sodales vitae, vehicula eget, ipsum. Sed nec tortor. Aenean malesuada. Nunc convallis, massa eu vestibulum commodo, quam mauris interdum arcu, at [pellentesque][5] diam metus ut nulla. Vestibulum eu dolor sit amet lacus varius fermentum. Morbi dolor enim, pulvinar eget, lobortis ac, [fringilla](www.fringilla.com) ac, [turpis](http://turpis.net). Duis ac erat. Etiam consequat. Integer sed est eu elit pellentesque dapibus. Duis venenatis magna feugiat. ## Links [0]: www.magna.com [1]: https://vitae.net/index.html [2]: www.sem.com [3]: ftp://nunc.com [4]: www.nec.com [5]: https://pellentesque.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: Sapien ac iaculis feugiat, [lacus](http://lacus.org/lacus) lacus accumsan lorem, quis volutpat justo turpis ac mauris. Duis velit [magna](www.magna.com), scelerisque [vitae](https://vitae.net/index.html), varius ut, aliquam vel, justo. Proin ac augue. Nullam auctor lectus vitae arcu. Vestibulum porta justo placerat purus. Ut [sem](www.sem.com) [nunc](ftp://nunc.com), vestibulum [nec](www.nec.com), sodales vitae, vehicula eget, ipsum. Sed nec tortor. Aenean malesuada. Nunc convallis, massa eu vestibulum commodo, quam mauris interdum arcu, at [pellentesque](https://pellentesque.com) diam metus ut nulla. Vestibulum eu dolor sit amet lacus varius fermentum. Morbi dolor enim, pulvinar eget, lobortis ac, [fringilla](www.fringilla.com) ac, [turpis](http://turpis.net). Duis ac erat. Etiam consequat. Integer sed est eu elit pellentesque dapibus. Duis venenatis magna feugiat. ## Links Execute (Multiple links, heading present, no references yet): 3,11 LinkConvertRange Expect markdown: Sapien ac iaculis feugiat, [lacus](http://lacus.org/lacus) lacus accumsan lorem, quis volutpat justo turpis ac mauris. Duis velit [magna][0], scelerisque [vitae][1], varius ut, aliquam vel, justo. Proin ac augue. Nullam auctor lectus vitae arcu. Vestibulum porta justo placerat purus. Ut [sem][2] [nunc][3], vestibulum [nec][4], sodales vitae, vehicula eget, ipsum. Sed nec tortor. Aenean malesuada. Nunc convallis, massa eu vestibulum commodo, quam mauris interdum arcu, at [pellentesque][5] diam metus ut nulla. Vestibulum eu dolor sit amet lacus varius fermentum. Morbi dolor enim, pulvinar eget, lobortis ac, [fringilla](www.fringilla.com) ac, [turpis](http://turpis.net). Duis ac erat. Etiam consequat. Integer sed est eu elit pellentesque dapibus. Duis venenatis magna feugiat. ## Links [0]: www.magna.com [1]: https://vitae.net/index.html [2]: www.sem.com [3]: ftp://nunc.com [4]: www.nec.com [5]: https://pellentesque.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: Sapien ac iaculis feugiat, [lacus][0] lacus accumsan lorem, quis volutpat justo turpis ac mauris. Duis velit [magna](www.magna.com), scelerisque [vitae](https://vitae.net/index.html), varius ut, aliquam vel, justo. Proin ac augue. Nullam auctor lectus vitae arcu. Vestibulum porta justo placerat purus. Ut [sem](www.sem.com) [nunc](ftp://nunc.com), vestibulum [nec](www.nec.com), sodales vitae, vehicula eget, ipsum. Sed nec tortor. Aenean malesuada. Nunc convallis, massa eu vestibulum commodo, quam mauris interdum arcu, at [pellentesque][1] diam metus ut nulla. Vestibulum eu dolor sit amet lacus varius fermentum. Morbi dolor enim, pulvinar eget, lobortis ac, [fringilla](www.fringilla.com) ac, [turpis](http://turpis.net). Duis ac erat. Etiam consequat. Integer sed est eu elit pellentesque dapibus. Duis venenatis magna feugiat. ## Links [0]: http://lacus.org/lacus [1]: https://pellentesque.com Execute (Multiple links, heading and references present): 3,11 LinkConvertRange Expect markdown: Sapien ac iaculis feugiat, [lacus][0] lacus accumsan lorem, quis volutpat justo turpis ac mauris. Duis velit [magna][2], scelerisque [vitae][3], varius ut, aliquam vel, justo. Proin ac augue. Nullam auctor lectus vitae arcu. Vestibulum porta justo placerat purus. Ut [sem][4] [nunc][5], vestibulum [nec][6], sodales vitae, vehicula eget, ipsum. Sed nec tortor. Aenean malesuada. Nunc convallis, massa eu vestibulum commodo, quam mauris interdum arcu, at [pellentesque][1] diam metus ut nulla. Vestibulum eu dolor sit amet lacus varius fermentum. Morbi dolor enim, pulvinar eget, lobortis ac, [fringilla](www.fringilla.com) ac, [turpis](http://turpis.net). Duis ac erat. Etiam consequat. Integer sed est eu elit pellentesque dapibus. Duis venenatis magna feugiat. ## Links [0]: http://lacus.org/lacus [1]: https://pellentesque.com [2]: www.magna.com [3]: https://vitae.net/index.html [4]: www.sem.com [5]: ftp://nunc.com [6]: www.nec.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: Sapien ac iaculis feugiat, [lacus][0] lacus accumsan lorem, quis volutpat justo turpis ac mauris. Duis velit [magna](www.magna.com), scelerisque [vitae](https://vitae.net/index.html), varius ut, aliquam vel, justo. Proin ac augue. Nullam auctor lectus vitae arcu. Vestibulum porta justo placerat purus. Ut [sem](www.sem.com) [nunc](ftp://nunc.com), vestibulum [nec](www.nec.com), sodales vitae, vehicula eget, ipsum. Sed nec tortor. Aenean malesuada. Nunc convallis, massa eu vestibulum commodo, quam mauris interdum arcu, at [pellentesque][1] diam metus ut nulla. Vestibulum eu dolor sit amet lacus varius fermentum. Morbi dolor enim, pulvinar eget, lobortis ac, [fringilla](www.fringilla.com) ac, [turpis](http://turpis.net). Duis ac erat. Etiam consequat. Integer sed est eu elit pellentesque dapibus. Duis venenatis magna feugiat. ## Links [0]: http://lacus.org/lacus [1]: https://pellentesque.com Execute (Range includes reference section): 7,19 LinkConvertRange Expect markdown: Sapien ac iaculis feugiat, [lacus][0] lacus accumsan lorem, quis volutpat justo turpis ac mauris. Duis velit [magna](www.magna.com), scelerisque [vitae](https://vitae.net/index.html), varius ut, aliquam vel, justo. Proin ac augue. Nullam auctor lectus vitae arcu. Vestibulum porta justo placerat purus. Ut [sem][2] [nunc][3], vestibulum [nec][4], sodales vitae, vehicula eget, ipsum. Sed nec tortor. Aenean malesuada. Nunc convallis, massa eu vestibulum commodo, quam mauris interdum arcu, at [pellentesque][1] diam metus ut nulla. Vestibulum eu dolor sit amet lacus varius fermentum. Morbi dolor enim, pulvinar eget, lobortis ac, [fringilla][5] ac, [turpis][6]. Duis ac erat. Etiam consequat. Integer sed est eu elit pellentesque dapibus. Duis venenatis magna feugiat. ## Links [0]: http://lacus.org/lacus [1]: https://pellentesque.com [2]: www.sem.com [3]: ftp://nunc.com [4]: www.nec.com [5]: www.fringilla.com [6]: http://turpis.net ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link.vim-1.4.0/test/markdown_ft/convert_single.vader000066400000000000000000000057301472625555500226260ustar00rootroot00000000000000Given markdown: Cum sociis natoque penatibus et magnis dis parturient montes, Execute (No link): LinkConvertSingle Expect markdown: Cum sociis natoque penatibus et magnis dis parturient montes, ------------------------------------------------------------------- Given markdown: Cum sociis natoque [penatibus](http://www.loremipsum.com) et magnis dis parturient montes, Execute (Single link): LinkConvertSingle Expect markdown: Cum sociis natoque [penatibus][0] et magnis dis parturient montes, ## Links [0]: http://www.loremipsum.com ------------------------------------------------------------------- Given markdown: Cum sociis natoque [penatibus](http://www.loremipsum.com) et [magnis](http://www.dolorsitamet.com) dis parturient montes, Execute (Two links): LinkConvertSingle LinkConvertSingle Expect markdown: Cum sociis natoque [penatibus][0] et [magnis][1] dis parturient montes, ## Links [0]: http://www.loremipsum.com [1]: http://www.dolorsitamet.com ----------------------------------------------- Given markdown: [penatibus](http://www.loremipsum.com) et magnis dis parturient montes Execute (Link at start of line): LinkConvertSingle Expect markdown: [penatibus][0] et magnis dis parturient montes ## Links [0]: http://www.loremipsum.com ----------------------------------------------- Given markdown: Cum sociis natoque [penatibus](http://www.loremipsum.com) Execute (Link at end of line): LinkConvertSingle Expect markdown: Cum sociis natoque [penatibus][0] ## Links [0]: http://www.loremipsum.com ----------------------------------------------- Given markdown: [penatibus](http://www.loremipsum.com) et [magnis](http://www.dolorsitamet.com) Execute (Two links, one at start of line, one at end of line): LinkConvertSingle LinkConvertSingle Expect markdown: [penatibus][0] et [magnis][1] ## Links [0]: http://www.loremipsum.com [1]: http://www.dolorsitamet.com ----------------------------------------------- Given markdown: Cum sociis natoque [penatibus](http://www.loremipsum.com) et [magnis](http://www.dolorsitamet.com) dis [parturient](http://www.adipiscingelitipsum.com) montes, Execute (Three links): LinkConvertSingle LinkConvertSingle LinkConvertSingle Expect markdown: Cum sociis natoque [penatibus][0] et [magnis][1] dis [parturient][2] montes, ## Links [0]: http://www.loremipsum.com [1]: http://www.dolorsitamet.com [2]: http://www.adipiscingelitipsum.com ----------------------------------------------- " NOTE the * character causes issues, so is not included here Given markdown: Cum sociis natoque [penatibus](http://www.lorem-ipsum.com/foo_bar.html?bar=baz+alpha$bravo!charlie'delta,echo%foxtrot) et magnis Execute (Link containing special characters): LinkConvertSingle Expect markdown: Cum sociis natoque [penatibus][0] et magnis ## Links [0]: http://www.lorem-ipsum.com/foo_bar.html?bar=baz+alpha$bravo!charlie'delta,echo%foxtrot ----------------------------------------------- link.vim-1.4.0/test/markdown_ft/convert_single_insert.vader000066400000000000000000000036271472625555500242150ustar00rootroot00000000000000~~~ Insert X to mark cursor position ~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: [Penatibus](http://www.loremipsum.com) et [magnis](http://www.dolorsitamet.com) dis [parturient](http://www.adipiscingelitipsum.com) montes, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (Link at start of line): LinkConvertSingleInsert normal! iX ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expect markdown: [Penatibus][0]X et [magnis](http://www.dolorsitamet.com) dis [parturient](http://www.adipiscingelitipsum.com) montes, ## Links [0]: http://www.loremipsum.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: [Penatibus](http://www.loremipsum.com) et [magnis](http://www.dolorsitamet.com) dis [parturient](http://www.adipiscingelitipsum.com) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (Link at end of line): normal! $ LinkConvertSingleInsert " Use a instead of i because we are at the end of the line normal! aX ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expect markdown: [Penatibus](http://www.loremipsum.com) et [magnis](http://www.dolorsitamet.com) dis [parturient][0]X ## Links [0]: http://www.adipiscingelitipsum.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: [Penatibus](http://www.loremipsum.com) et [magnis](http://www.dolorsitamet.com) dis [parturient](http://www.adipiscingelitipsum.com) montes, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (Cursor in middle of second link): normal! 2f)3b LinkConvertSingleInsert normal! iX ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expect markdown: [Penatibus](http://www.loremipsum.com) et [magnis][0]X dis [parturient](http://www.adipiscingelitipsum.com) montes, ## Links [0]: http://www.dolorsitamet.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link.vim-1.4.0/test/markdown_ft/internal_links.vader000066400000000000000000000150671472625555500226250ustar00rootroot00000000000000Before: unlet! b:link_disable_internal_links unlet! g:link_disable_internal_links After: unlet! b:link_disable_internal_links unlet! g:link_disable_internal_links ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: URL [foo](http://bar.com) Internal wiki page [alfa](bravo.md) Execute (Default settings): LinkConvertAll Expect markdown: URL [foo][0] Internal wiki page [alfa][1] ## Links [0]: http://bar.com [1]: bravo.md ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: URL [foo](http://bar.com) Internal wiki page [alfa](bravo.md) Execute (Disabled globally): let g:link_disable_internal_links = 1 LinkConvertAll Expect markdown: URL [foo][0] Internal wiki page [alfa](bravo.md) ## Links [0]: http://bar.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: URL [foo](http://bar.com) Internal wiki page [alfa](bravo.md) Execute (Disabled buffer-local): let b:link_disable_internal_links = 1 LinkConvertAll Expect markdown: URL [foo][0] Internal wiki page [alfa](bravo.md) ## Links [0]: http://bar.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: URL [foo](http://bar.com) Internal wiki page [alfa](bravo.md) Execute (Enabled globally, disabled buffer-local): let g:link_disable_internal_links = 0 let b:link_disable_internal_links = 1 LinkConvertAll Expect markdown: URL [foo][0] Internal wiki page [alfa](bravo.md) ## Links [0]: http://bar.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: URL [foo](http://bar.com) Internal wiki page [alfa](bravo.md) Execute (Disabled globally, enabled buffer-local): let g:link_disable_internal_links = 1 let b:link_disable_internal_links = 0 LinkConvertAll Expect markdown: URL [foo][0] Internal wiki page [alfa][1] ## Links [0]: http://bar.com [1]: bravo.md ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: A regular [URL](https://github.com). A URL without a protocol but including 'www' or [world wide web](www.google.com)! Not a Markdown extension but a Moldovan [domain](https://nic.md). A .wiki top-level [domain name](https://kodi.wiki/view/Main_Page). A link to an internal wiki page; in this case a regular [file](file.md). A file inside a [subdirectory](subdir/file.md). A file in a [parent](../file.md) directory. Just a [directory](subdir/), no filename. A filename containing [spaces](file with spaces.md). The same filename but this time [percent-encoded](file%20with%20spaces.md). A filename containing [Unicode](önskelistä.md) characters. An anchor, pointing to a heading inside a [file](file.md#heading). Execute (Default (so enabled); list of URLs and internal wiki pages): LinkConvertAll Expect markdown: A regular [URL][0]. A URL without a protocol but including 'www' or [world wide web][1]! Not a Markdown extension but a Moldovan [domain][2]. A .wiki top-level [domain name][3]. A link to an internal wiki page; in this case a regular [file][4]. A file inside a [subdirectory][5]. A file in a [parent][6] directory. Just a [directory][7], no filename. A filename containing [spaces][8]. The same filename but this time [percent-encoded][9]. A filename containing [Unicode][10] characters. An anchor, pointing to a heading inside a [file][11]. ## Links [0]: https://github.com [1]: www.google.com [2]: https://nic.md [3]: https://kodi.wiki/view/Main_Page [4]: file.md [5]: subdir/file.md [6]: ../file.md [7]: subdir/ [8]: file with spaces.md [9]: file%20with%20spaces.md [10]: önskelistä.md [11]: file.md#heading ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: A regular [URL](https://github.com). A URL without a protocol but including 'www' or [world wide web](www.google.com)! Not a Markdown extension but a Moldovan [domain](https://nic.md). A .wiki top-level [domain name](https://kodi.wiki/view/Main_Page). A link to an internal wiki page; in this case a regular [file](file.md). A file inside a [subdirectory](subdir/file.md). A file in a [parent](../file.md) directory. Just a [directory](subdir/), no filename. A filename containing [spaces](file with spaces.md). The same filename but this time [percent-encoded](file%20with%20spaces.md). A filename containing [Unicode](önskelistä.md) characters. An anchor, pointing to a heading inside a [file](file.md#heading). Execute (Disabled; list of URLs and internal wiki pages): let g:link_disable_internal_links = 1 LinkConvertAll Expect markdown: A regular [URL][0]. A URL without a protocol but including 'www' or [world wide web][1]! Not a Markdown extension but a Moldovan [domain][2]. A .wiki top-level [domain name][3]. A link to an internal wiki page; in this case a regular [file](file.md). A file inside a [subdirectory](subdir/file.md). A file in a [parent](../file.md) directory. Just a [directory](subdir/), no filename. A filename containing [spaces](file with spaces.md). The same filename but this time [percent-encoded](file%20with%20spaces.md). A filename containing [Unicode](önskelistä.md) characters. An anchor, pointing to a heading inside a [file](file.md#heading). ## Links [0]: https://github.com [1]: www.google.com [2]: https://nic.md [3]: https://kodi.wiki/view/Main_Page ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: A regular [URL](https://github.com). A regex like [a-zA-Z](\d+) could be interpreted as a Markdown inline link. Code snippets can resemble an inline link too: command! -buffer -range=% -bar TagLinks silent keeppatterns ,substitute#\v%(\[[^\]]+\]\(\s*)@https?://([^.]+)\S+#[\1](\0)#giep Yet another regular [URL](https://www.vim.org). Execute (Similar to inline links; causes issues if internal links aren't disabled): let g:link_disable_internal_links = 1 LinkConvertAll Expect markdown: A regular [URL][0]. A regex like [a-zA-Z](\d+) could be interpreted as a Markdown inline link. Code snippets can resemble an inline link too: command! -buffer -range=% -bar TagLinks silent keeppatterns ,substitute#\v%(\[[^\]]+\]\(\s*)@https?://([^.]+)\S+#[\1](\0)#giep Yet another regular [URL][1]. ## Links [0]: https://github.com [1]: https://www.vim.org ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link.vim-1.4.0/test/markdown_ft/jump.vader000066400000000000000000000032501472625555500205530ustar00rootroot00000000000000Before: find **/lorem-converted.md normal! gg ============================================== Execute (): Log 'From document body to reference section' ============================================== Execute (Valid jump, from single reference link on line, [2]): call cursor(6, 1) LinkJump let [line_nr, col_nr] = getcurpos()[1:2] AssertEqual line_nr, 23 AssertEqual col_nr, 6 Execute (Valid jump, from second reference link on line, [5]): call cursor(9, 15) LinkJump let [line_nr, col_nr] = getcurpos()[1:2] AssertEqual line_nr, 26 AssertEqual col_nr, 6 Execute (Invalid jump, no reference link on line): call cursor(4, 20) LinkJump let [line_nr, col_nr] = getcurpos()[1:2] AssertEqual line_nr, 4 AssertEqual col_nr, 20 Execute (Invalid jump, single reference link on line with no corresponding link reference definition, [9]): call cursor(16, 1) LinkJump let [line_nr, col_nr] = getcurpos()[1:2] AssertEqual line_nr, 16 AssertEqual col_nr, 1 ============================================== Execute (): Log 'From reference section to document body' ============================================== Execute (Valid jump, to a line with a single link, [3]): call cursor(24, 1) LinkJump let [line_nr, col_nr] = getcurpos()[1:2] AssertEqual line_nr, 7 AssertEqual col_nr, 10 Execute (Valid jump, to a line with multiple links, [6]): call cursor(27, 1) LinkJump let [line_nr, col_nr] = getcurpos()[1:2] AssertEqual line_nr, 9 AssertEqual col_nr, 42 Execute (Invalid jump, no corresponding reference link, [10]): call cursor(30, 1) LinkJump let [line_nr, col_nr] = getcurpos()[1:2] AssertEqual line_nr, 30 AssertEqual col_nr, 1 link.vim-1.4.0/test/markdown_ft/open.vader000066400000000000000000000071041472625555500205430ustar00rootroot00000000000000Before: messages clear Given markdown: Nascetur [ridiculus][0] mus. ## Links [0]: https://www.vim.org/ ~~~~~~~~~~~~~~~~~~~~~~~~~ " These tests always fail in a container; adding FIXME marks the block as a " pending test case and ensures it doesn't affect the exit status Execute (FIXME Regular URL): LinkOpen AssertEqual 0, v:shell_error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: Nascetur [ridiculus][0] mus. ## Links [0]: https://en.wikipedia.org/wiki/Giro_d%27Italia ~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (FIXME URL containing percent-encoding): LinkOpen AssertEqual 0, v:shell_error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: Nascetur [ridiculus][0] mus. ## Links [0]: https://en.wikipedia.org/wiki/Giro_d%27Italia#Defunct_classifications ~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (FIXME URL containing percent-encoding and hash sign): LinkOpen AssertEqual 0, v:shell_error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: Nascetur [ridiculus][0] mus. ## Links [0]: https://www.mobileread.com/forums/showthread.php?p=1769412 ~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (FIXME URL containing question mark): LinkOpen AssertEqual 0, v:shell_error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: Nascetur [ridiculus][0] mus. ## Links [0]: https://www.mobileread.com/forums/showpost.php?p=1769412&postcount=1 ~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (FIXME URL containing question mark and ampersand): LinkOpen AssertEqual 0, v:shell_error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown; # A consectetuer nunc justo ac nisl. ## Nam vitae purus Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. ## Links [0]: http://www.loremipsumdolorsitamet.com ~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (From reference section): call cursor('$', 1) LinkOpen let expected = g:link#globals#errors['not_from_ref'] let actual = split( execute('messages'), '\n')[-1] AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown; # A consectetuer nunc justo ac nisl. ## Nam vitae purus Cum sociis [natoque][0] penatibus et magnis dis parturient montes, nascetur ridiculus mus. Praesent semper magna. In eu justo. Nunc vitae risus nec sem scelerisque consequat. In hac habitasse platea dictumst. Nam posuere ## Links [0]: loremipsumdolorsitamet.com ~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (No reference link on line): LinkOpen let expected = g:link#globals#errors['no_reference_link'] let actual = split( execute('messages'), '\n')[-1] AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown; # A consectetuer nunc justo ac nisl. ## Nam vitae purus Cum sociis [natoque][0] penatibus et magnis dis parturient montes, nascetur ridiculus mus. Praesent semper magna. In eu justo. Nunc vitae risus nec sem scelerisque consequat. In hac habitasse platea dictumst. Nam posuere ## Links [0]: loremipsum.com ~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (No valid URL: does not start with a protocol like 'http' or with 'www'): call cursor(5, 1) LinkOpen let expected = g:link#globals#errors['no_valid_url'] .. ' loremipsum.com' let actual = split( execute('messages'), '\n')[-1] AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link.vim-1.4.0/test/markdown_ft/parse_inline_links.vader000066400000000000000000000145501472625555500234550ustar00rootroot00000000000000Given markdown; Cum sociis natoque penatibus et magnis dis parturient montes, Execute (No link): let expected = [] let actual = link#body#ParseLineFor('inline', 1) AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown; Cum sociis natoque [penatibus](http://www.loremipsum.com) et magnis dis parturient montes, Execute (Single link): let expected = [ \ { \ 'full_link': '[penatibus](http://www.loremipsum.com)', \ 'link_text': 'penatibus', \ 'destination': 'http://www.loremipsum.com', \ 'length': 38, \ 'col_start': 20, \ } \ ] let actual = link#body#ParseLineFor('inline', 1) AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown; Cum sociis natoque [penatibus](http://www.loremipsum.com) et [magnis](http://www.dolorsitamet.com) dis parturient montes, Execute (Two links): let expected = [ \ { \ 'full_link': '[penatibus](http://www.loremipsum.com)', \ 'link_text': 'penatibus', \ 'destination': 'http://www.loremipsum.com', \ 'length': 38, \ 'col_start': 20, \ }, \ { \ 'full_link': '[magnis](http://www.dolorsitamet.com)', \ 'link_text': 'magnis', \ 'destination': 'http://www.dolorsitamet.com', \ 'length': 37, \ 'col_start': 62, \ } \ ] let actual = link#body#ParseLineFor('inline', 1) AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown; [penatibus](http://www.loremipsum.com) et magnis dis parturient montes Execute (Link at start of line): let expected = [ \ { \ 'full_link': '[penatibus](http://www.loremipsum.com)', \ 'link_text': 'penatibus', \ 'destination': 'http://www.loremipsum.com', \ 'length': 38, \ 'col_start': 1, \ } \ ] let actual = link#body#ParseLineFor('inline', 1) AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown; Cum sociis natoque [penatibus](http://www.loremipsum.com) Execute (Link at end of line): let expected = [ \ { \ 'full_link': '[penatibus](http://www.loremipsum.com)', \ 'link_text': 'penatibus', \ 'destination': 'http://www.loremipsum.com', \ 'length': 38, \ 'col_start': 20, \ } \ ] let actual = link#body#ParseLineFor('inline', 1) AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown; [penatibus](http://www.loremipsum.com) et [magnis](http://www.dolorsitamet.com) Execute (Two links, one at start of line, one at end of line): let expected = [ \ { \ 'full_link': '[penatibus](http://www.loremipsum.com)', \ 'link_text': 'penatibus', \ 'destination': 'http://www.loremipsum.com', \ 'length': 38, \ 'col_start': 1, \ }, \ { \ 'full_link': '[magnis](http://www.dolorsitamet.com)', \ 'link_text': 'magnis', \ 'destination': 'http://www.dolorsitamet.com', \ 'length': 37, \ 'col_start': 43, \ } \ ] let actual = link#body#ParseLineFor('inline', 1) AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown; Cum sociis natoque [penatibus](http://www.loremipsum.com) et [magnis](http://www.dolorsitamet.com) dis [parturient](http://www.adipiscingelitipsum.com) montes, Execute (Three links): let expected = [ \ { \ 'full_link': '[penatibus](http://www.loremipsum.com)', \ 'link_text': 'penatibus', \ 'destination': 'http://www.loremipsum.com', \ 'length': 38, \ 'col_start': 20, \ }, \ { \ 'full_link': '[magnis](http://www.dolorsitamet.com)', \ 'link_text': 'magnis', \ 'destination': 'http://www.dolorsitamet.com', \ 'length': 37, \ 'col_start': 62, \ }, \ { \ 'full_link': '[parturient](http://www.adipiscingelitipsum.com)', \ 'link_text': 'parturient', \ 'destination': 'http://www.adipiscingelitipsum.com', \ 'length': 48, \ 'col_start': 104, \ } \ ] let actual = link#body#ParseLineFor('inline', 1) AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown; Cum sociis natoque [penatibus](http://www.loremipsum.com/foo.html?bar=baz#alfa) et magnis Execute (Link containing special characters): let expected = [ \ { \ 'full_link': '[penatibus](http://www.loremipsum.com/foo.html?bar=baz#alfa)', \ 'link_text': 'penatibus', \ 'destination': 'http://www.loremipsum.com/foo.html?bar=baz#alfa', \ 'length': 60, \ 'col_start': 20, \ } \ ] let actual = link#body#ParseLineFor('inline', 1) AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown; Cum sociis natoque [penatibus](http://www.lorem-ipsum.com/foo_bar.html?bar=baz+alpha$bravo!charlie*delta,echo'foxtrot) et magnis Execute (Link containing more special characters): let expected = [ \ { \ 'full_link': "[penatibus](http://www.lorem-ipsum.com/foo_bar.html?bar=baz+alpha$bravo!charlie*delta,echo'foxtrot)", \ 'link_text': 'penatibus', \ 'destination': "http://www.lorem-ipsum.com/foo_bar.html?bar=baz+alpha$bravo!charlie*delta,echo'foxtrot", \ 'length': 99, \ 'col_start': 20, \ } \ ] let actual = link#body#ParseLineFor('inline', 1) AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown; volutpat. [Donec](www.donec.org) odio. Quisque nunc. [Integer](http://integ.er) cursus [feugiat](www.feugi.at) magna Execute (Long line): let expected = [ \ { \ 'full_link': "[Donec](www.donec.org)", \ 'link_text': 'Donec', \ 'destination': "www.donec.org", \ 'length': 22, \ 'col_start': 11, \ }, \ { \ 'full_link': "[Integer](http://integ.er)", \ 'link_text': 'Integer', \ 'destination': "http://integ.er", \ 'length': 26, \ 'col_start': 54, \ }, \ { \ 'full_link': "[feugiat](www.feugi.at)", \ 'link_text': 'feugiat', \ 'destination': "www.feugi.at", \ 'length': 23, \ 'col_start': 88, \ } \ ] let actual = link#body#ParseLineFor('inline', 1) AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link.vim-1.4.0/test/markdown_ft/parse_reference_links.vader000066400000000000000000000115441472625555500241350ustar00rootroot00000000000000Given markdown; Cum sociis natoque penatibus et magnis dis parturient montes, Execute (No link): let expected = [] let actual = link#body#ParseLineFor('reference', 1) AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown; Cum sociis natoque [penatibus][3] et magnis dis parturient montes, Execute (Single link): let expected = [ \ { \ 'full_link': '[penatibus][3]', \ 'link_text': 'penatibus', \ 'destination': '3', \ 'length': 14, \ 'col_start': 20, \ } \ ] let actual = link#body#ParseLineFor('reference', 1) AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown; Cum sociis natoque [penatibus][3] et [magnis][5] dis parturient montes, Execute (Two links): let expected = [ \ { \ 'full_link': '[penatibus][3]', \ 'link_text': 'penatibus', \ 'destination': '3', \ 'length': 14, \ 'col_start': 20, \ }, \ { \ 'full_link': '[magnis][5]', \ 'link_text': 'magnis', \ 'destination': '5', \ 'length': 11, \ 'col_start': 38, \ } \ ] let actual = link#body#ParseLineFor('reference', 1) AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown; [penatibus][3] et magnis dis parturient montes Execute (Link at start of line): let expected = [ \ { \ 'full_link': '[penatibus][3]', \ 'link_text': 'penatibus', \ 'destination': '3', \ 'length': 14, \ 'col_start': 1, \ } \ ] let actual = link#body#ParseLineFor('reference', 1) AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown; Cum sociis natoque [penatibus][3] Execute (Link at end of line): let expected = [ \ { \ 'full_link': '[penatibus][3]', \ 'link_text': 'penatibus', \ 'destination': '3', \ 'length': 14, \ 'col_start': 20, \ } \ ] let actual = link#body#ParseLineFor('reference', 1) AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown; [penatibus][3] et [magnis][5] Execute (Two links, one at start of line, one at end of line): let expected = [ \ { \ 'full_link': '[penatibus][3]', \ 'link_text': 'penatibus', \ 'destination': '3', \ 'length': 14, \ 'col_start': 1, \ }, \ { \ 'full_link': '[magnis][5]', \ 'link_text': 'magnis', \ 'destination': '5', \ 'length': 11, \ 'col_start': 19, \ } \ ] let actual = link#body#ParseLineFor('reference', 1) AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown; Cum sociis natoque [penatibus][0] et [magnis][1] dis [parturient][2] montes, Execute (Three links): let expected = [ \ { \ 'full_link': '[penatibus][0]', \ 'link_text': 'penatibus', \ 'destination': '0', \ 'length': 14, \ 'col_start': 20, \ }, \ { \ 'full_link': '[magnis][1]', \ 'link_text': 'magnis', \ 'destination': '1', \ 'length': 11, \ 'col_start': 38, \ }, \ { \ 'full_link': '[parturient][2]', \ 'link_text': 'parturient', \ 'destination': '2', \ 'length': 15, \ 'col_start': 54, \ } \ ] let actual = link#body#ParseLineFor('reference', 1) AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown; Ultrices posuere cubilia Curae; Curabitur consequat leo et dui. Aenean ligula mi, interdum a, dolor. volutpat. [Donec][0] odio. Quisque nunc. [Integer][1] cursus [feugiat][2] magna Execute (Long line): let expected = [ \ { \ 'full_link': '[Donec][0]', \ 'link_text': 'Donec', \ 'destination': '0', \ 'length': 10, \ 'col_start': 112, \ }, \ { \ 'full_link': '[Integer][1]', \ 'link_text': 'Integer', \ 'destination': '1', \ 'length': 12, \ 'col_start': 143, \ }, \ { \ 'full_link': '[feugiat][2]', \ 'link_text': 'feugiat', \ 'destination': '2', \ 'length': 12, \ 'col_start': 163, \ } \ ] let actual = link#body#ParseLineFor('reference', 1) AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown; volutpat. [Donec](www.donec.org) odio. Quisque nunc. [Integer][0] cursus [feugiat](www.feugi.at) magna Execute (Mix of inline and reference links): let expected = [ \ { \ 'full_link': '[Integer][0]', \ 'link_text': 'Integer', \ 'destination': '0', \ 'length': 12, \ 'col_start': 54, \ }, \ ] let actual = link#body#ParseLineFor('reference', 1) AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link.vim-1.4.0/test/markdown_ft/peek.vader000066400000000000000000000017351472625555500205320ustar00rootroot00000000000000Before: find **/lorem-converted.md normal! gg Execute (Valid peek, from single reference link on line, [2]): call cursor(6, 1) LinkPeek let expected = '[2]: www.magna.com' let messages = execute('messages') let actual = split(messages, "\n")[-1] " Last message AssertEqual expected, actual Execute (Valid peek, from multiple reference links on line, [5]): call cursor(9, 15) LinkPeek let expected = '[5]: nunc.com' let actual = split( execute('messages'), '\n')[-1] AssertEqual expected, actual Execute (Invalid peek, from below heading): call cursor(23, 1) LinkPeek let expected = link#globals#errors['not_from_ref'] let actual = split( execute('messages'), '\n')[-1] AssertEqual expected, actual Execute (Invalid peek, label [9] not found in reference section): call cursor(16, 1) LinkPeek let expected = link#globals#errors['no_label_ref_section'] .. ' 9' let actual = split( execute('messages'), '\n')[-1] AssertEqual expected, actual link.vim-1.4.0/test/markdown_ft/pick_closest_link.vader000066400000000000000000000144061472625555500233040ustar00rootroot00000000000000~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: [Penatibus](http://www.loremipsum.com) et [magnis](http://www.dolorsitamet.com) dis [parturient](http://www.adipiscingelitipsum.com) montes, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (First out of three links, cursor on first char): LinkConvertSingle ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expect markdown: [Penatibus][0] et [magnis](http://www.dolorsitamet.com) dis [parturient](http://www.adipiscingelitipsum.com) montes, ## Links [0]: http://www.loremipsum.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: [Penatibus](http://www.loremipsum.com) et [magnis](http://www.dolorsitamet.com) dis [parturient](http://www.adipiscingelitipsum.com) montes, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (Second out of three links, cursor on first char): normal! f[ LinkConvertSingle ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expect markdown: [Penatibus](http://www.loremipsum.com) et [magnis][0] dis [parturient](http://www.adipiscingelitipsum.com) montes, ## Links [0]: http://www.dolorsitamet.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: [Penatibus](http://www.loremipsum.com) et [magnis](http://www.dolorsitamet.com) dis [parturient](http://www.adipiscingelitipsum.com) montes, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (Third out of three links, cursor on first char): normal! f[f[ LinkConvertSingle ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expect markdown: [Penatibus](http://www.loremipsum.com) et [magnis](http://www.dolorsitamet.com) dis [parturient][0] montes, ## Links [0]: http://www.adipiscingelitipsum.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: [Penatibus](http://www.loremipsum.com) et [magnis](http://www.dolorsitamet.com) dis [parturient](http://www.adipiscingelitipsum.com) montes, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (First out of three links, cursor on last char): normal! f) LinkConvertSingle ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expect markdown: [Penatibus][0] et [magnis](http://www.dolorsitamet.com) dis [parturient](http://www.adipiscingelitipsum.com) montes, ## Links [0]: http://www.loremipsum.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: [Penatibus](http://www.loremipsum.com) et [magnis](http://www.dolorsitamet.com) dis [parturient](http://www.adipiscingelitipsum.com) montes, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (Second out of three links, cursor on last char): normal! 2f) LinkConvertSingle ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expect markdown: [Penatibus](http://www.loremipsum.com) et [magnis][0] dis [parturient](http://www.adipiscingelitipsum.com) montes, ## Links [0]: http://www.dolorsitamet.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: [Penatibus](http://www.loremipsum.com) et [magnis](http://www.dolorsitamet.com) dis [parturient](http://www.adipiscingelitipsum.com) montes, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (Third out of three links, cursor on last char): normal! 3f) LinkConvertSingle ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expect markdown: [Penatibus](http://www.loremipsum.com) et [magnis](http://www.dolorsitamet.com) dis [parturient][0] montes, ## Links [0]: http://www.adipiscingelitipsum.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: [Penatibus](http://www.loremipsum.com) et [magnis](http://www.dolorsitamet.com) dis [parturient](http://www.adipiscingelitipsum.com) montes, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (Cursor between first and second link): normal! f)W LinkConvertSingle ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expect markdown: [Penatibus](http://www.loremipsum.com) et [magnis][0] dis [parturient](http://www.adipiscingelitipsum.com) montes, ## Links [0]: http://www.dolorsitamet.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: [Penatibus](http://www.loremipsum.com) et [magnis](http://www.dolorsitamet.com) dis [parturient](http://www.adipiscingelitipsum.com) montes, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (Cursor inside second link): normal! f)f)3b LinkConvertSingle ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expect markdown: [Penatibus](http://www.loremipsum.com) et [magnis][0] dis [parturient](http://www.adipiscingelitipsum.com) montes, ## Links [0]: http://www.dolorsitamet.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: [Penatibus](http://www.loremipsum.com) et [magnis](http://www.dolorsitamet.com) dis [parturient](http://www.adipiscingelitipsum.com) montes, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (Cursor just before second link): normal! f[h LinkConvertSingle ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expect markdown: [Penatibus](http://www.loremipsum.com) et [magnis][0] dis [parturient](http://www.adipiscingelitipsum.com) montes, ## Links [0]: http://www.dolorsitamet.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: [Penatibus](http://www.loremipsum.com) et [magnis](http://www.dolorsitamet.com) dis [parturient](http://www.adipiscingelitipsum.com) montes, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (Cursor just after second link): normal! 2f)l LinkConvertSingle ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expect markdown: [Penatibus](http://www.loremipsum.com) et [magnis](http://www.dolorsitamet.com) dis [parturient][0] montes, ## Links [0]: http://www.adipiscingelitipsum.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: [Penatibus](http://www.loremipsum.com) et [magnis](http://www.dolorsitamet.com) dis [parturient](http://www.adipiscingelitipsum.com) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (Cursor on last char of last link, no trailing chars): normal! 3f) LinkConvertSingle ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expect markdown: [Penatibus](http://www.loremipsum.com) et [magnis](http://www.dolorsitamet.com) dis [parturient][0] ## Links [0]: http://www.adipiscingelitipsum.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link.vim-1.4.0/test/markdown_ft/reformat.vader000066400000000000000000000172671472625555500214340ustar00rootroot00000000000000~~~ 1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: # Yar Pirate Ipsum ## Fluke furl Fluke furl [cutlass][0] scuttle coffer [topmast][1] hang the jib spyglass driver crack Jennys tea cup. Quarterdeck run a rig Jolly Roger gangway no prey, no pay pirate quarter log schooner draft. Sink me wherry [tackle][3] matey ballast mizzen pinnace bucko bowsprit Cat o'nine tails. Nipperkin chase guns topgallant Nelsons folly Jolly Roger matey hulk aye overhaul rum. Black jack fathom booty provost killick bounty Yellow Jack bucko [sloop topgallant][4]. Scurvy Admiral of the Black spirits clipper belaying pin lanyard gally barque keel gaff. ## Transom no Transom no prey, no pay haul wind galleon log smartly quarterdeck interloper Nelsons folly dead men tell no tales. [Topgallant](www.gallant.top) plunder maroon hempen halter pink hang the jib [crimp][6] squiffy clap of [thunder][7] fathom. Spanish [Main][8] killick case shot Shiver me timbers wench red ensign smartly chase guns pillage boom. ## Links [0]: http://cutlass.com [1]: www.topmast.org [2]: www.sink.com [3]: https://tackle.net [4]: www.sloop.com [5]: www.gallant.top [6]: crimp.com [7]: www.thunder.com [8]: http://main.es ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (Delete two links, [2] and [5]): call link#Reformat() ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expect markdown: # Yar Pirate Ipsum ## Fluke furl Fluke furl [cutlass][0] scuttle coffer [topmast][1] hang the jib spyglass driver crack Jennys tea cup. Quarterdeck run a rig Jolly Roger gangway no prey, no pay pirate quarter log schooner draft. Sink me wherry [tackle][2] matey ballast mizzen pinnace bucko bowsprit Cat o'nine tails. Nipperkin chase guns topgallant Nelsons folly Jolly Roger matey hulk aye overhaul rum. Black jack fathom booty provost killick bounty Yellow Jack bucko [sloop topgallant][3]. Scurvy Admiral of the Black spirits clipper belaying pin lanyard gally barque keel gaff. ## Transom no Transom no prey, no pay haul wind galleon log smartly quarterdeck interloper Nelsons folly dead men tell no tales. [Topgallant](www.gallant.top) plunder maroon hempen halter pink hang the jib [crimp][4] squiffy clap of [thunder][5] fathom. Spanish [Main][6] killick case shot Shiver me timbers wench red ensign smartly chase guns pillage boom. ## Links [0]: http://cutlass.com [1]: www.topmast.org [2]: https://tackle.net [3]: www.sloop.com [4]: crimp.com [5]: www.thunder.com [6]: http://main.es ~~~ 2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: # Yar Pirate Ipsum ## Fluke furl Fluke furl [cutlass][0] scuttle coffer [topmast][1] hang the jib spyglass driver crack [Jennys][19] tea cup. Quarterdeck run a rig Jolly Roger gangway no prey, no pay pirate quarter log schooner draft. Sink me wherry [tackle][3] matey ballast mizzen pinnace bucko bowsprit Cat o'nine tails. Nipperkin [chase][23] guns topgallant Nelsons folly Jolly Roger matey hulk aye overhaul rum. Black jack fathom booty provost killick bounty Yellow Jack bucko [sloop topgallant][4]. Scurvy Admiral of the Black [spirits][15] clipper belaying pin lanyard gally barque keel gaff. ## Transom no Transom no prey, no pay haul wind galleon log smartly quarterdeck interloper Nelsons folly dead men tell no tales. [Topgallant](www.gallant.top) plunder maroon hempen halter pink hang the jib [crimp][6] squiffy clap of [thunder][7] fathom. Spanish [Main][8] killick case shot Shiver me timbers wench red ensign smartly chase guns pillage boom. ## Links [1]: www.topmast.org [2]: www.sink.com [6]: crimp.com [3]: https://tackle.net [19]: www.thunder.com [4]: www.sloop.com [5]: www.gallant.top [23]: www.topmast.org [7]: www.thunder.com [0]: http://cutlass.com [15]: www.thunder.com [4]: www.sloop.com [8]: http://main.es ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (Merge links): call link#Reformat() ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expect markdown: # Yar Pirate Ipsum ## Fluke furl Fluke furl [cutlass][0] scuttle coffer [topmast][1] hang the jib spyglass driver crack [Jennys][2] tea cup. Quarterdeck run a rig Jolly Roger gangway no prey, no pay pirate quarter log schooner draft. Sink me wherry [tackle][3] matey ballast mizzen pinnace bucko bowsprit Cat o'nine tails. Nipperkin [chase][1] guns topgallant Nelsons folly Jolly Roger matey hulk aye overhaul rum. Black jack fathom booty provost killick bounty Yellow Jack bucko [sloop topgallant][4]. Scurvy Admiral of the Black [spirits][2] clipper belaying pin lanyard gally barque keel gaff. ## Transom no Transom no prey, no pay haul wind galleon log smartly quarterdeck interloper Nelsons folly dead men tell no tales. [Topgallant](www.gallant.top) plunder maroon hempen halter pink hang the jib [crimp][5] squiffy clap of [thunder][2] fathom. Spanish [Main][6] killick case shot Shiver me timbers wench red ensign smartly chase guns pillage boom. ## Links [0]: http://cutlass.com [1]: www.topmast.org [2]: www.thunder.com [3]: https://tackle.net [4]: www.sloop.com [5]: crimp.com [6]: http://main.es ~~~ 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: Sapien ac iaculis feugiat, [lacus][9] lacus accumsan lorem, quis volutpat justo turpis ac mauris. Duis velit [magna][1], scelerisque [vitae][2], varius ut, aliquam vel, justo. Proin ac augue. Nullam auctor lectus vitae arcu. Vestibulum porta justo placerat purus. Ut [sem][5] [nunc][4], vestibulum [nec][3], sodales vitae, vehicula eget, ipsum. Sed nec tortor. Aenean malesuada. Nunc convallis, massa eu [vestibulum][10] commodo, quam mauris interdum arcu, [pellentesque][6] diam metus ut nulla. Vestibulum eu dolor sit amet lacus varius fermentum. Morbi dolor enim, pulvinar eget, lobortis ac, [fringilla][17] ac, [turpis][8]. Duis ac erat. Etiam consequat. Integer sed est eu elit pellentesque dapibus. Duis venenatis magna feugiat. ## Links [2]: https://vitae.net/index.html [1]: www.magna.com [4]: ftp://nunc.com [3]: www.nec.com [5]: www.sem.com [9]: http://lacus.org/lacus [12]: http://no-exist.com [6]: https://pellentesque.com [17]: www.fringilla.com [8]: http://turpis.net ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute ([10] has no corresponding label in the references section, [12] has no corresponding label in the document body; do not move cursor): call cursor(5, 6) LinkReformat let [line_nr, col_nr] = getcurpos()[1:2] AssertEqual line_nr, 5 AssertEqual col_nr, 6 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expect markdown: Sapien ac iaculis feugiat, [lacus][0] lacus accumsan lorem, quis volutpat justo turpis ac mauris. Duis velit [magna][1], scelerisque [vitae][2], varius ut, aliquam vel, justo. Proin ac augue. Nullam auctor lectus vitae arcu. Vestibulum porta justo placerat purus. Ut [sem][3] [nunc][4], vestibulum [nec][5], sodales vitae, vehicula eget, ipsum. Sed nec tortor. Aenean malesuada. Nunc convallis, massa eu [vestibulum][???] commodo, quam mauris interdum arcu, [pellentesque][6] diam metus ut nulla. Vestibulum eu dolor sit amet lacus varius fermentum. Morbi dolor enim, pulvinar eget, lobortis ac, [fringilla][7] ac, [turpis][8]. Duis ac erat. Etiam consequat. Integer sed est eu elit pellentesque dapibus. Duis venenatis magna feugiat. ## Links [0]: http://lacus.org/lacus [1]: www.magna.com [2]: https://vitae.net/index.html [3]: www.sem.com [4]: ftp://nunc.com [5]: www.nec.com [6]: https://pellentesque.com [7]: www.fringilla.com [8]: http://turpis.net ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link.vim-1.4.0/test/markdown_ft/skip_line.vader000066400000000000000000000027011472625555500215550ustar00rootroot00000000000000Before: unlet! b:link_skip_line After: unlet! b:link_skip_line ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: Filler Not a comment: [magna](www.magna.com) Continued > Blockquote: [lacus](http://lacus.org/lacus) End ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (Use default (commentstring) to skip lines): LinkConvertAll ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expect markdown: Filler Not a comment: [magna][0] Continued > Blockquote: [lacus](http://lacus.org/lacus) End ## Links [0]: www.magna.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: Filler Not a comment: [magna](www.magna.com) Continued > Blockquote: [lacus](http://lacus.org/lacus) End ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (Use custom pattern to skip lines): let b:link_skip_line = '^>' LinkConvertAll ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expect markdown: Filler Not a comment: [magna][0] Continued > Blockquote: [lacus](http://lacus.org/lacus) End ## Links [0]: www.magna.com [1]: https://vitae.net/index.html ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link.vim-1.4.0/test/markdown_ft/urls.vader000066400000000000000000000067111472625555500205720ustar00rootroot00000000000000Before: unlet! b:link_disable_internal_links unlet! g:link_disable_internal_links After: unlet! b:link_disable_internal_links unlet! g:link_disable_internal_links ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: [foo](www.bar.com) [foo](ftp://ftp.bar.net) [foo](file://path/to/file.txt) [foo](http://www.bar.com) [foo](https://bar.org) [foo](http://192.0.2.1) [foo](http://subdomain.bar.com) [foo](https://bar.travel) [foo](http://bar.very123longtld) [foo](http://www.ba-r.com) [foo](http://bar.com:8080) [foo](http://bar.com/baz) [foo](http://bar.com/index.html) [foo](http://www.parameters.org/page2014.html?utm_source=facebook&utm_medium=eventlinkonwall&utm_term=trapshoot&utm_content=calendar_event_on_wall&utm_campaign=trapshoot2014) [foo](bar) [foo](bar.com) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (URLs in varying formats; internal links not disabled): LinkConvertAll ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expect markdown: [foo][0] [foo][1] [foo][2] [foo][3] [foo][4] [foo][5] [foo][6] [foo][7] [foo][8] [foo][9] [foo][10] [foo][11] [foo][12] [foo][13] [foo][14] [foo][15] ## Links [0]: www.bar.com [1]: ftp://ftp.bar.net [2]: file://path/to/file.txt [3]: http://www.bar.com [4]: https://bar.org [5]: http://192.0.2.1 [6]: http://subdomain.bar.com [7]: https://bar.travel [8]: http://bar.very123longtld [9]: http://www.ba-r.com [10]: http://bar.com:8080 [11]: http://bar.com/baz [12]: http://bar.com/index.html [13]: http://www.parameters.org/page2014.html?utm_source=facebook&utm_medium=eventlinkonwall&utm_term=trapshoot&utm_content=calendar_event_on_wall&utm_campaign=trapshoot2014 [14]: bar [15]: bar.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given markdown: [foo](www.bar.com) [foo](ftp://ftp.bar.net) [foo](file://path/to/file.txt) [foo](http://www.bar.com) [foo](https://bar.org) [foo](http://192.0.2.1) [foo](http://subdomain.bar.com) [foo](https://bar.travel) [foo](http://bar.very123longtld) [foo](http://www.ba-r.com) [foo](http://bar.com:8080) [foo](http://bar.com/baz) [foo](http://bar.com/index.html) [foo](http://www.parameters.org/page2014.html?utm_source=facebook&utm_medium=eventlinkonwall&utm_term=trapshoot&utm_content=calendar_event_on_wall&utm_campaign=trapshoot2014) [foo](bar) [foo](bar.com) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (URLs in varying formats; internal links disabled): let g:link_disable_internal_links = 1 LinkConvertAll ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expect markdown: [foo][0] [foo][1] [foo][2] [foo][3] [foo][4] [foo][5] [foo][6] [foo][7] [foo][8] [foo][9] [foo][10] [foo][11] [foo][12] [foo][13] [foo](bar) [foo](bar.com) ## Links [0]: www.bar.com [1]: ftp://ftp.bar.net [2]: file://path/to/file.txt [3]: http://www.bar.com [4]: https://bar.org [5]: http://192.0.2.1 [6]: http://subdomain.bar.com [7]: https://bar.travel [8]: http://bar.very123longtld [9]: http://www.ba-r.com [10]: http://bar.com:8080 [11]: http://bar.com/baz [12]: http://bar.com/index.html [13]: http://www.parameters.org/page2014.html?utm_source=facebook&utm_medium=eventlinkonwall&utm_term=trapshoot&utm_content=calendar_event_on_wall&utm_campaign=trapshoot2014 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link.vim-1.4.0/test/other_ft/000077500000000000000000000000001472625555500160545ustar00rootroot00000000000000link.vim-1.4.0/test/other_ft/convert_all.vader000066400000000000000000000311631472625555500214130ustar00rootroot00000000000000Before: unlet! g:link_heading unlet! b:link_heading unlet! b:link_heading_before unlet! b:link_skip_line After: unlet! g:link_heading unlet! b:link_heading unlet! b:link_heading_before unlet! b:link_skip_line ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: www.bar.com Fluke furl ftp://ftp.bar.net scuttle coffer file://path/to/file.txt hang the jib spyglass driver crack Jennys tea cup. Quarterdeck run a http://www.bar.com rig Jolly Roger https://bar.org gangway http://192.0.2.1 no prey, no pay pirate quarter log http://subdomain.bar.com schooner draft https://bar.travel http://bar.very123longtld Scurvy Admiral of the Black spirits clipper http://www.ba-r.com Nipperkin http://bar.com:8080 Jolly Roger matey hulk aye http://bar.com/baz booty provost killick bounty http://bar.com/index.html http://www.parameters.org/page2014.html?utm_source=facebook&utm_medium=eventlinkonwall&utm_term=trapshoot&utm_content=calendar_event_on_wall&utm_campaign=trapshoot2014 bar bar.com Line containing something resembling an inline link: command! -buffer -range=% -bar TagLinks silent keeppatterns ,substitute#\v%(\[[^\]]+\]\(\s*)@,substitute#\v%(\[[^\]]+\]\(\s*)@ Quarterdeck run a http://www.bar.com > rig Jolly Roger https://bar.org gangway http://192.0.2.1 no prey, > no pay pirate quarter log http://subdomain.bar.com schooner draft https://bar.travel ~~~~~ Execute (Skip some lines in a mail buffer): let b:link_skip_line = '^>' let b:link_heading = 'Links:' LinkConvertAll ~~~~~ Expect mail: [0] Fluke furl [1] scuttle coffer [2] hang the jib spyglass driver crack Jennys tea cup. > Quarterdeck run a http://www.bar.com > rig Jolly Roger https://bar.org gangway http://192.0.2.1 no prey, > no pay pirate quarter log http://subdomain.bar.com schooner draft [3] Links: [0]: www.bar.com [1]: ftp://ftp.bar.net [2]: file://path/to/file.txt [3]: https://bar.travel ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given gitcommit: Git commit title Git https://comm.it body Body continued # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # # On branch main # Changes to be committed: # modified: foo.txt # ~~~~~ Execute (Gitcommit buffer, custom heading, repositioned reference section): let b:link_heading = 'Links:' let b:link_heading_before = '^# Please enter' LinkConvertAll ~~~~~ Expect gitcommit: Git commit title Git [0] body Body continued Links: [0]: https://comm.it # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # # On branch main # Changes to be committed: # modified: foo.txt # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: Hi Recipient, I hope this email https://email.com finds you well. Best regards, Your Name -- Your Job Title Your Company Name Your Contact Information ~~~~~ Execute (Mail buffer): let b:link_heading = 'Links:' let b:link_heading_before = '^--' LinkConvertAll ~~~~~ Expect mail: Hi Recipient, I hope this email [0] finds you well. Best regards, Your Name Links: [0]: https://email.com -- Your Job Title Your Company Name Your Contact Information ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: Subject: Join Our Webinar Series! Hi John, Exciting news! We're hosting a series of webinars on Vim and Neovim. Here's the schedule: Intro to Vim: Join here: https://vim.com/webinar1 or https://vimbackup.com/webinar1 Advanced Vim Techniques: Join here: www.vim.com/webinar2 Q&A with Experts: Join here: http://vim.com/webinar3 Intro to Neovim: Join here: https://neovim.com/webinar1 or https://neovimbackup.com/webinar1 > Advanced Neovim Techniques: Join here: www.neovim.com/webinar2 Q&A with Experts: Join here: http://neovim.com/webinar3 Don't miss out — register now! Let us know if you have any questions. Cheers, Jane ~~~~~ Execute (Mail buffer): let b:link_heading = 'Full Links:' let b:link_heading_before = '^Cheers' let b:link_skip_line = '^>' LinkConvertAll ~~~~~ Expect mail: Subject: Join Our Webinar Series! Hi John, Exciting news! We're hosting a series of webinars on Vim and Neovim. Here's the schedule: Intro to Vim: Join here: [0] or [1] Advanced Vim Techniques: Join here: [2] Q&A with Experts: Join here: [3] Intro to Neovim: Join here: [4] or [5] > Advanced Neovim Techniques: Join here: www.neovim.com/webinar2 Q&A with Experts: Join here: [6] Don't miss out — register now! Let us know if you have any questions. Full Links: [0]: https://vim.com/webinar1 [1]: https://vimbackup.com/webinar1 [2]: www.vim.com/webinar2 [3]: http://vim.com/webinar3 [4]: https://neovim.com/webinar1 [5]: https://neovimbackup.com/webinar1 [6]: http://neovim.com/webinar3 Cheers, Jane ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: foo https://www.vim.org bar https://www.vim.org baz Execute (Two identical links on the same line): let b:link_heading = 'Links:' LinkConvertAll Expect mail: foo [0] bar [1] baz Links: [0]: https://www.vim.org [1]: https://www.vim.org ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: foo https://www.vim.org, bar baz https://neovim.io. qux Execute (URLs with trailing punctuation characters): LinkConvertAll Expect mail: foo [0], bar baz [1]. qux Links: [0]: https://www.vim.org [1]: https://neovim.io ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: foo (https://www.vim.org) bar Execute (URL within parentheses): LinkConvertAll Expect mail: foo ([0]) bar Links: [0]: https://www.vim.org ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given gitcommit: Update README.md with project documentation links This commit updates the README.md file to include links to various project documentation resources. The documentation includes: 1. Project Wiki: https://github.com/example/project/wiki 2. API Documentation: https://api.example.com/docs 3. User Guide: https://docs.example.com/user-guide 4. Developer Documentation: https://docs.example.com/developer-guide # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # # On branch main # Changes to be committed: # modified: README.md # Execute (Gitcommit buffer, reposition reference section, empty heading): let b:link_heading = '' let b:link_heading_before = '^# Please enter' LinkConvertAll Expect gitcommit: Update README.md with project documentation links This commit updates the README.md file to include links to various project documentation resources. The documentation includes: 1. Project Wiki: [0] 2. API Documentation: [1] 3. User Guide: [2] 4. Developer Documentation: [3] [0]: https://github.com/example/project/wiki [1]: https://api.example.com/docs [2]: https://docs.example.com/user-guide [3]: https://docs.example.com/developer-guide # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # # On branch main # Changes to be committed: # modified: README.md # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: Subject: Join Our Webinar Series! Hi John, Exciting news! We're hosting a series of webinars on Vim and Neovim. Here's the schedule: Intro to Vim: Join here: https://vim.com/webinar1 or https://vimbackup.com/webinar1 Advanced Vim Techniques: Join here: www.vim.com/webinar2 Q&A with Experts: Join here: http://vim.com/webinar3 Intro to Neovim: Join here: https://neovim.com/webinar1 or https://neovimbackup.com/webinar1 > Advanced Neovim Techniques: Join here: www.neovim.com/webinar2 Q&A with Experts: Join here: http://neovim.com/webinar3 Cheers, Jane ~~~~~ Execute (Empty heading, reposition): let b:link_heading = '' let b:link_heading_before = '^Cheers' let b:link_skip_line = '^>' LinkConvertAll ~~~~~ Expect mail: Subject: Join Our Webinar Series! Hi John, Exciting news! We're hosting a series of webinars on Vim and Neovim. Here's the schedule: Intro to Vim: Join here: [0] or [1] Advanced Vim Techniques: Join here: [2] Q&A with Experts: Join here: [3] Intro to Neovim: Join here: [4] or [5] > Advanced Neovim Techniques: Join here: www.neovim.com/webinar2 Q&A with Experts: Join here: [6] [0]: https://vim.com/webinar1 [1]: https://vimbackup.com/webinar1 [2]: www.vim.com/webinar2 [3]: http://vim.com/webinar3 [4]: https://neovim.com/webinar1 [5]: https://neovimbackup.com/webinar1 [6]: http://neovim.com/webinar3 Cheers, Jane ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link.vim-1.4.0/test/other_ft/convert_range.vader000066400000000000000000000100331472625555500217300ustar00rootroot00000000000000Before: unlet! g:link_heading unlet! b:link_heading unlet! b:link_heading_before unlet! b:link_skip_line After: unlet! g:link_heading unlet! b:link_heading unlet! b:link_heading_before unlet! b:link_skip_line ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: www.bar.com Fluke furl ftp://ftp.bar.net scuttle coffer file://path/to/file.txt hang the jib spyglass driver crack Jennys tea cup. Quarterdeck run a http://www.bar.com rig Jolly Roger https://bar.org gangway http://192.0.2.1 no prey, no pay pirate quarter log http://subdomain.bar.com schooner draft https://bar.travel http://bar.very123longtld Scurvy Admiral of the Black spirits clipper http://www.ba-r.com Nipperkin http://bar.com:8080 Jolly Roger matey hulk aye http://bar.com/baz booty provost killick bounty http://bar.com/index.html http://www.parameters.org/page2014.html?utm_source=facebook&utm_medium=eventlinkonwall&utm_term=trapshoot&utm_content=calendar_event_on_wall&utm_campaign=trapshoot2014 bar bar.com Line containing something resembling an inline link: command! -buffer -range=% -bar TagLinks silent keeppatterns ,substitute#\v%(\[[^\]]+\]\(\s*)@,substitute#\v%(\[[^\]]+\]\(\s*)@ Advanced Neovim Techniques: Join here: www.neovim.com/webinar2 Q&A with Experts: Join here: http://neovim.com/webinar3 Don't miss out — register now! Let us know if you have any questions. Cheers, Jane ~~~~~ Execute (Mail buffer): let b:link_heading = 'Full Links:' let b:link_heading_before = '^Cheers' let b:link_skip_line = '^>' 10,13 LinkConvertRange ~~~~~ Expect mail: Subject: Join Our Webinar Series! Hi John, Exciting news! We're hosting a series of webinars on Vim and Neovim. Here's the schedule: Intro to Vim: Join here: https://vim.com/webinar1 or https://vimbackup.com/webinar1 Advanced Vim Techniques: Join here: www.vim.com/webinar2 Q&A with Experts: Join here: [0] Intro to Neovim: Join here: [1] or [2] > Advanced Neovim Techniques: Join here: www.neovim.com/webinar2 Q&A with Experts: Join here: http://neovim.com/webinar3 Don't miss out — register now! Let us know if you have any questions. Full Links: [0]: http://vim.com/webinar3 [1]: https://neovim.com/webinar1 [2]: https://neovimbackup.com/webinar1 Cheers, Jane ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link.vim-1.4.0/test/other_ft/convert_single.vader000066400000000000000000000064031472625555500221230ustar00rootroot00000000000000~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: Cum sociis natoque penatibus et magnis dis parturient montes, ~~~~~~~~~~~~~~ Execute (No link): LinkConvertSingle ~~~~~~~~~~~~~~ Expect mail: Cum sociis natoque penatibus et magnis dis parturient montes, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: Cum sociis natoque penatibus http://www.loremipsum.com et magnis dis parturient montes, ~~~~~~~~~~~~~~ Execute (Single link): LinkConvertSingle ~~~~~~~~~~~~~~ Expect mail: Cum sociis natoque penatibus [0] et magnis dis parturient montes, Links: [0]: http://www.loremipsum.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: Cum sociis natoque penatibus http://www.loremipsum.com et magnis http://www.dolorsitamet.com dis parturient montes, ~~~~~~~~~~~~~~ Execute (Two links): LinkConvertSingle LinkConvertSingle ~~~~~~~~~~~~~~ Expect mail: Cum sociis natoque penatibus [0] et magnis [1] dis parturient montes, Links: [0]: http://www.loremipsum.com [1]: http://www.dolorsitamet.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: http://www.loremipsum.com et magnis dis parturient montes ~~~~~~~~~~~~~~ Execute (Link at start of line): LinkConvertSingle ~~~~~~~~~~~~~~ Expect mail: [0] et magnis dis parturient montes Links: [0]: http://www.loremipsum.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: Cum sociis natoque penatibus http://www.loremipsum.com ~~~~~~~~~~~~~~ Execute (Link at end of line): LinkConvertSingle ~~~~~~~~~~~~~~ Expect mail: Cum sociis natoque penatibus [0] Links: [0]: http://www.loremipsum.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: http://www.loremipsum.com et magnis http://www.dolorsitamet.com ~~~~~~~~~~~~~~ Execute (Two links, one at start of line, one at end of line): LinkConvertSingle LinkConvertSingle ~~~~~~~~~~~~~~ Expect mail: [0] et magnis [1] Links: [0]: http://www.loremipsum.com [1]: http://www.dolorsitamet.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: Cum sociis natoque http://www.loremipsum.com et http://www.dolorsitamet.com dis http://www.adipiscingelitipsum.com montes, ~~~~~~~~~~~~~~ Execute (Three links): LinkConvertSingle LinkConvertSingle LinkConvertSingle ~~~~~~~~~~~~~~ Expect mail: Cum sociis natoque [0] et [1] dis [2] montes, Links: [0]: http://www.loremipsum.com [1]: http://www.dolorsitamet.com [2]: http://www.adipiscingelitipsum.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ " NOTE the * character causes issues, so is not included here Given mail: Cum sociis natoque http://www.lorem-ipsum.com/foo_bar.html?bar=baz+alpha$bravo!charlie'delta,echo%foxtrot et magnis ~~~~~~~~~~~~~~ Execute (Link containing special characters): LinkConvertSingle ~~~~~~~~~~~~~~ Expect mail: Cum sociis natoque [0] et magnis Links: [0]: http://www.lorem-ipsum.com/foo_bar.html?bar=baz+alpha$bravo!charlie'delta,echo%foxtrot ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link.vim-1.4.0/test/other_ft/convert_single_insert.vader000066400000000000000000000037411472625555500235110ustar00rootroot00000000000000~~~ Insert X to mark cursor position ~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Before: unlet! g:link_heading unlet! b:link_heading unlet! b:link_heading_before unlet! b:link_skip_line After: unlet! g:link_heading unlet! b:link_heading unlet! b:link_heading_before unlet! b:link_skip_line ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: http://www.loremipsum.com et magnis http://www.dolorsitamet.com dis parturient http://www.adipiscingelitipsum.com montes, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (Link at start of line): LinkConvertSingleInsert normal! iX ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expect mail: [0]X et magnis http://www.dolorsitamet.com dis parturient http://www.adipiscingelitipsum.com montes, Links: [0]: http://www.loremipsum.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: Penatibus http://www.loremipsum.com dis parturient http://www.adipiscingelitipsum.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (Link at end of line): normal! $ LinkConvertSingleInsert " Use a instead of i because we are at the end of the line normal! aX ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expect mail: Penatibus http://www.loremipsum.com dis parturient [0]X Links: [0]: http://www.adipiscingelitipsum.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: http://www.loremipsum.com et magnis http://www.dolorsitamet.com dis http://www.adipiscingelitipsum.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (Cursor in middle of second link): normal! 2f: LinkConvertSingleInsert normal! iX ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expect mail: http://www.loremipsum.com et magnis [0]X dis http://www.adipiscingelitipsum.com Links: [0]: http://www.dolorsitamet.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link.vim-1.4.0/test/other_ft/jump.vader000066400000000000000000000052701472625555500200560ustar00rootroot00000000000000" Calling functions is required here; the commands are unknown because of the " gitcommit resource Before: find **/gitcommit_converted.gitcommit normal! gg unlet! g:link_heading unlet! b:link_heading unlet! b:link_heading_before unlet! b:link_skip_line After: unlet! g:link_heading unlet! b:link_heading unlet! b:link_heading_before unlet! b:link_skip_line ============================================== Execute (): Log 'From document body to reference section' ============================================== Execute (Valid jump, from single reference link on line, [0]): let b:link_heading = 'Links:' let b:link_heading_before = '^# Please enter' call cursor(6, 1) call link#Connect('jump') let [line_nr, col_nr] = getcurpos()[1:2] AssertEqual line_nr, 17 AssertEqual col_nr, 6 Execute (Valid jump, from second reference link on line, [5]): let b:link_heading = 'Links:' let b:link_heading_before = '^# Please enter' call cursor(8, 24) call link#Connect('jump') let [line_nr, col_nr] = getcurpos()[1:2] AssertEqual line_nr, 20 AssertEqual col_nr, 6 Execute (Invalid jump, no reference link on line): let b:link_heading = 'Links:' let b:link_heading_before = '^# Please enter' call cursor(3, 5) call link#Connect('jump') let [line_nr, col_nr] = getcurpos()[1:2] AssertEqual line_nr, 3 AssertEqual col_nr, 5 Execute (Invalid jump, single reference link on line with no corresponding link reference definition, [1]): let b:link_heading = 'Links:' let b:link_heading_before = '^# Please enter' 18 delete call cursor(7, 1) call link#Connect('jump') let [line_nr, col_nr] = getcurpos()[1:2] AssertEqual line_nr, 7 AssertEqual col_nr, 1 undo ============================================== Execute (): Log 'From reference section to document body' ============================================== Execute (Valid jump, to a line with a single link, [0]): let b:link_heading = 'Links:' let b:link_heading_before = '^# Please enter' call cursor(17, 1) call link#Connect('jump') let [line_nr, col_nr] = getcurpos()[1:2] AssertEqual line_nr, 6 AssertEqual col_nr, 20 Execute (Valid jump, to a line with multiple links, [3]): let b:link_heading = 'Links:' let b:link_heading_before = '^# Please enter' call cursor(20, 25) call link#Connect('jump') let [line_nr, col_nr] = getcurpos()[1:2] AssertEqual line_nr, 8 AssertEqual col_nr, 51 Execute (Invalid jump, no corresponding reference link, [1]): let b:link_heading = 'Links:' let b:link_heading_before = '^# Please enter' 7 delete call cursor(17, 1) call link#Connect('jump') let [line_nr, col_nr] = getcurpos()[1:2] AssertEqual line_nr, 17 AssertEqual col_nr, 1 undo link.vim-1.4.0/test/other_ft/open.vader000066400000000000000000000032221472625555500200370ustar00rootroot00000000000000Before: messages clear ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail; Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. [0] Links: [0]: http://www.loremipsumdolorsitamet.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (From reference section): call cursor('$', 1) LinkOpen let expected = g:link#globals#errors['not_from_ref'] let actual = split( execute('messages'), '\n')[-1] AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail; Nam vitae purus Cum sociis natoque [0] penatibus et magnis dis parturient montes, nascetur ridiculus mus. Praesent semper magna. In eu justo. Nunc vitae risus nec sem scelerisque consequat. In hac habitasse platea dictumst. Nam posuere Links: [0]: loremipsumdolorsitamet.com ~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (No reference link on line): LinkOpen let expected = g:link#globals#errors['no_reference_link'] let actual = split( execute('messages'), '\n')[-1] AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail; Cum sociis natoque [0] penatibus et magnis dis parturient montes, nascetur ridiculus mus. Links: [0]: loremipsum.com ~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (No valid URL: does not start with a protocol like 'http' or with 'www'): call cursor(1, 1) LinkOpen let expected = g:link#globals#errors['no_valid_url'] .. ' loremipsum.com' let actual = split( execute('messages'), '\n')[-1] AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link.vim-1.4.0/test/other_ft/parse_inline_links.vader000066400000000000000000000136011472625555500227500ustar00rootroot00000000000000Given mail: Cum sociis natoque penatibus et magnis dis parturient montes, Execute (No link): let expected = [] let actual = link#body#ParseLineFor('inline', 1) AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: Cum sociis natoque http://www.loremipsum.com et magnis dis parturient montes, Execute (Single link): let expected = [ \ { \ 'full_link': 'http://www.loremipsum.com', \ 'link_text': '', \ 'destination': 'http://www.loremipsum.com', \ 'length': 25, \ 'col_start': 20, \ } \ ] let actual = link#body#ParseLineFor('inline', 1) AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: Cum sociis natoque http://www.loremipsum.com et http://www.dolorsitamet.com dis parturient montes, Execute (Two links): let expected = [ \ { \ 'full_link': 'http://www.loremipsum.com', \ 'link_text': '', \ 'destination': 'http://www.loremipsum.com', \ 'length': 25, \ 'col_start': 20, \ }, \ { \ 'full_link': 'http://www.dolorsitamet.com', \ 'link_text': '', \ 'destination': 'http://www.dolorsitamet.com', \ 'length': 27, \ 'col_start': 49, \ } \ ] let actual = link#body#ParseLineFor('inline', 1) AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: http://www.loremipsum.com et magnis dis parturient montes Execute (Link at start of line): let expected = [ \ { \ 'full_link': 'http://www.loremipsum.com', \ 'link_text': '', \ 'destination': 'http://www.loremipsum.com', \ 'length': 25, \ 'col_start': 1, \ } \ ] let actual = link#body#ParseLineFor('inline', 1) AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: Cum sociis natoque http://www.loremipsum.com Execute (Link at end of line): let expected = [ \ { \ 'full_link': 'http://www.loremipsum.com', \ 'link_text': '', \ 'destination': 'http://www.loremipsum.com', \ 'length': 25, \ 'col_start': 20, \ } \ ] let actual = link#body#ParseLineFor('inline', 1) AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: http://www.loremipsum.com et http://www.dolorsitamet.com Execute (Two links, one at start of line, one at end of line): let expected = [ \ { \ 'full_link': 'http://www.loremipsum.com', \ 'link_text': '', \ 'destination': 'http://www.loremipsum.com', \ 'length': 25, \ 'col_start': 1, \ }, \ { \ 'full_link': 'http://www.dolorsitamet.com', \ 'link_text': '', \ 'destination': 'http://www.dolorsitamet.com', \ 'length': 27, \ 'col_start': 30, \ } \ ] let actual = link#body#ParseLineFor('inline', 1) AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: Cum sociis natoque http://www.loremipsum.com et http://www.dolorsitamet.com dis http://www.adipiscingelitipsum.com montes, Execute (Three links): let expected = [ \ { \ 'full_link': 'http://www.loremipsum.com', \ 'link_text': '', \ 'destination': 'http://www.loremipsum.com', \ 'length': 25, \ 'col_start': 20, \ }, \ { \ 'full_link': 'http://www.dolorsitamet.com', \ 'link_text': '', \ 'destination': 'http://www.dolorsitamet.com', \ 'length': 27, \ 'col_start': 49, \ }, \ { \ 'full_link': 'http://www.adipiscingelitipsum.com', \ 'link_text': '', \ 'destination': 'http://www.adipiscingelitipsum.com', \ 'length': 34, \ 'col_start': 81, \ } \ ] let actual = link#body#ParseLineFor('inline', 1) AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: Cum sociis natoque http://www.loremipsum.com/foo.html?bar=baz#alfa et magnis Execute (Link containing special characters): let expected = [ \ { \ 'full_link': 'http://www.loremipsum.com/foo.html?bar=baz#alfa', \ 'link_text': '', \ 'destination': 'http://www.loremipsum.com/foo.html?bar=baz#alfa', \ 'length': 47, \ 'col_start': 20, \ } \ ] let actual = link#body#ParseLineFor('inline', 1) AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: Cum sociis natoque http://www.lorem-ipsum.com/foo_bar.html?bar=baz+alpha$bravo!charlie*delta,echo'foxtrot et magnis Execute (Link containing more special characters): let expected = [ \ { \ 'full_link': "http://www.lorem-ipsum.com/foo_bar.html?bar=baz+alpha$bravo!charlie*delta,echo'foxtrot", \ 'link_text': '', \ 'destination': "http://www.lorem-ipsum.com/foo_bar.html?bar=baz+alpha$bravo!charlie*delta,echo'foxtrot", \ 'length': 86, \ 'col_start': 20, \ } \ ] let actual = link#body#ParseLineFor('inline', 1) AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: loremipsum volutpat. www.donec.org odio. Quisque nunc. http://integ.er cursus www.feugi.at magna Execute (Long line): let expected = [ \ { \ 'full_link': 'www.donec.org', \ 'link_text': '', \ 'destination': 'www.donec.org', \ 'length': 13, \ 'col_start': 22, \ }, \ { \ 'full_link': 'http://integ.er', \ 'link_text': '', \ 'destination': 'http://integ.er', \ 'length': 15, \ 'col_start': 56, \ }, \ { \ 'full_link': 'www.feugi.at', \ 'link_text': '', \ 'destination': 'www.feugi.at', \ 'length': 12, \ 'col_start': 79, \ } \ ] let actual = link#body#ParseLineFor('inline', 1) AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link.vim-1.4.0/test/other_ft/parse_reference_links.vader000066400000000000000000000110221472625555500234230ustar00rootroot00000000000000Given mail: Cum sociis natoque penatibus et magnis dis parturient montes, Execute (No link): let expected = [] let actual = link#body#ParseLineFor('reference', 1) AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: Cum sociis natoque penatibus [3] et magnis dis parturient montes, Execute (Single link): let expected = [ \ { \ 'full_link': '[3]', \ 'link_text': '', \ 'destination': '3', \ 'length': 3, \ 'col_start': 30, \ } \ ] let actual = link#body#ParseLineFor('reference', 1) AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: Cum sociis natoque penatibus [3] et magnis [5] dis parturient montes, Execute (Two links): let expected = [ \ { \ 'full_link': '[3]', \ 'link_text': '', \ 'destination': '3', \ 'length': 3, \ 'col_start': 30, \ }, \ { \ 'full_link': '[5]', \ 'link_text': '', \ 'destination': '5', \ 'length': 3, \ 'col_start': 44, \ } \ ] let actual = link#body#ParseLineFor('reference', 1) AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: [3] et magnis dis parturient montes Execute (Link at start of line): let expected = [ \ { \ 'full_link': '[3]', \ 'link_text': '', \ 'destination': '3', \ 'length': 3, \ 'col_start': 1, \ } \ ] let actual = link#body#ParseLineFor('reference', 1) AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: Cum sociis natoque penatibus [3] Execute (Link at end of line): let expected = [ \ { \ 'full_link': '[3]', \ 'link_text': '', \ 'destination': '3', \ 'length': 3, \ 'col_start': 30, \ } \ ] let actual = link#body#ParseLineFor('reference', 1) AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: [3] et [5] Execute (Two links, one at start of line, one at end of line): let expected = [ \ { \ 'full_link': '[3]', \ 'link_text': '', \ 'destination': '3', \ 'length': 3, \ 'col_start': 1, \ }, \ { \ 'full_link': '[5]', \ 'link_text': '', \ 'destination': '5', \ 'length': 3, \ 'col_start': 8, \ } \ ] let actual = link#body#ParseLineFor('reference', 1) AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: Cum sociis natoque penatibus [0] et magnis [1] dis parturient [2] montes, Execute (Three links): let expected = [ \ { \ 'full_link': '[0]', \ 'link_text': '', \ 'destination': '0', \ 'length': 3, \ 'col_start': 30, \ }, \ { \ 'full_link': '[1]', \ 'link_text': '', \ 'destination': '1', \ 'length': 3, \ 'col_start': 44, \ }, \ { \ 'full_link': '[2]', \ 'link_text': '', \ 'destination': '2', \ 'length': 3, \ 'col_start': 63, \ } \ ] let actual = link#body#ParseLineFor('reference', 1) AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: Ultrices posuere cubilia Curae; Curabitur consequat leo et dui. Aenean ligula mi, interdum a, dolor. volutpat. Donec [0] odio. Quisque nunc. Integer [1] cursus feugiat [2] magna Execute (Long line): let expected = [ \ { \ 'full_link': '[0]', \ 'link_text': '', \ 'destination': '0', \ 'length': 3, \ 'col_start': 118, \ }, \ { \ 'full_link': '[1]', \ 'link_text': '', \ 'destination': '1', \ 'length': 3, \ 'col_start': 150, \ }, \ { \ 'full_link': '[2]', \ 'link_text': '', \ 'destination': '2', \ 'length': 3, \ 'col_start': 169, \ } \ ] let actual = link#body#ParseLineFor('reference', 1) AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: volutpat. www.donec.org odio. Quisque nunc. Integer [0] cursus www.feugi.at magna Execute (Mix of inline and reference links): let expected = [ \ { \ 'full_link': '[0]', \ 'link_text': '', \ 'destination': '0', \ 'length': 3, \ 'col_start': 53, \ }, \ ] let actual = link#body#ParseLineFor('reference', 1) AssertEqual expected, actual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link.vim-1.4.0/test/other_ft/peek.vader000066400000000000000000000034231472625555500200250ustar00rootroot00000000000000" Calling functions is required here; the commands are unknown because of the " gitcommit resource Before: find **/gitcommit_converted.gitcommit normal! gg unlet! g:link_heading unlet! b:link_heading unlet! b:link_heading_before unlet! b:link_skip_line After: unlet! g:link_heading unlet! b:link_heading unlet! b:link_heading_before unlet! b:link_skip_line Execute (Valid peek, from single reference link on line, [0]): let b:link_heading = 'Links:' let b:link_heading_before = '^# Please enter' call cursor(6, 1) call link#Connect('peek') let expected = '[0]: https://github.com/example/project/wiki' let messages = execute('messages') let actual = split(messages, "\n")[-1] " Last message AssertEqual expected, actual Execute (Valid peek, from multiple reference links on line, [3]): let b:link_heading = 'Links:' let b:link_heading_before = '^# Please enter' call cursor(8, 24) call link#Connect('peek') let expected = '[3]: https://docs.example.com/developer-guide' let messages = execute('messages') let actual = split( execute('messages'), '\n')[-1] AssertEqual expected, actual Execute (Invalid peek, from below heading): let b:link_heading = 'Links:' let b:link_heading_before = '^# Please enter' call cursor(16, 1) call link#Connect('peek') let expected = link#globals#errors['not_from_ref'] let actual = split( execute('messages'), '\n')[-1] AssertEqual expected, actual Execute (Invalid peek, label [1] not found in reference section): let b:link_heading = 'Links:' let b:link_heading_before = '^# Please enter' 18 delete call cursor(7, 1) call link#Connect('peek') let expected = link#globals#errors['no_label_ref_section'] .. ' 1' let actual = split( execute('messages'), '\n')[-1] AssertEqual expected, actual link.vim-1.4.0/test/other_ft/pick_closest_link.vader000066400000000000000000000131041472625555500225750ustar00rootroot00000000000000" Calling functions is required here; can't use the commands because of " b:init_view Given mail: http://www.loremipsum.com et http://www.dolorsitamet.com dis http://www.adipiscingelitipsum.com montes, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (First out of three links, cursor on first char): normal! 0 call link#Convert('single-link') ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expect mail: [0] et http://www.dolorsitamet.com dis http://www.adipiscingelitipsum.com montes, Links: [0]: http://www.loremipsum.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: http://www.loremipsum.com et magnis http://www.dolorsitamet.com dis parturient http://www.adipiscingelitipsum.com montes, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (Second out of three links, cursor on first char): normal! 2f:B call link#Convert('single-link') ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expect mail: http://www.loremipsum.com et magnis [0] dis parturient http://www.adipiscingelitipsum.com montes, Links: [0]: http://www.dolorsitamet.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: http://www.loremipsum.com et http://www.dolorsitamet.com dis http://www.adipiscingelitipsum.com montes, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (Third out of three links, cursor on first char): normal! 3f:B call link#Convert('single-link') ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expect mail: http://www.loremipsum.com et http://www.dolorsitamet.com dis [0] montes, Links: [0]: http://www.adipiscingelitipsum.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: http://www.loremipsum.com et http://www.dolorsitamet.com dis http://www.adipiscingelitipsum.com montes, Execute (First out of three links, cursor on last char): normal! 1f:E call link#Convert('single-link') ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expect mail: [0] et http://www.dolorsitamet.com dis http://www.adipiscingelitipsum.com montes, Links: [0]: http://www.loremipsum.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: http://www.loremipsum.com et http://www.dolorsitamet.com dis http://www.adipiscingelitipsum.com montes, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (Second out of three links, cursor on last char): normal! 2f:E call link#Convert('single-link') ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expect mail: http://www.loremipsum.com et [0] dis http://www.adipiscingelitipsum.com montes, Links: [0]: http://www.dolorsitamet.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: http://www.loremipsum.com et http://www.dolorsitamet.com dis http://www.adipiscingelitipsum.com montes, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (Third out of three links, cursor on last char): normal! 3f:E call link#Convert('single-link') ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expect mail: http://www.loremipsum.com et http://www.dolorsitamet.com dis [0] montes, Links: [0]: http://www.adipiscingelitipsum.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: http://www.loremipsum.com et http://www.dolorsitamet.com dis http://www.adipiscingelitipsum.com montes, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (Cursor between first and second link): normal! 1f:Ew call link#Convert('single-link') ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expect mail: http://www.loremipsum.com et [0] dis http://www.adipiscingelitipsum.com montes, Links: [0]: http://www.dolorsitamet.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: http://www.loremipsum.com et http://www.dolorsitamet.com dis http://www.adipiscingelitipsum.com montes, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (Cursor inside second link): normal! 2f:8l call link#Convert('single-link') ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expect mail: http://www.loremipsum.com et [0] dis http://www.adipiscingelitipsum.com montes, Links: [0]: http://www.dolorsitamet.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: http://www.loremipsum.com et http://www.dolorsitamet.com dis http://www.adipiscingelitipsum.com montes, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (Cursor just before second link): normal! 2f:bh call link#Convert('single-link') ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expect mail: http://www.loremipsum.com et [0] dis http://www.adipiscingelitipsum.com montes, Links: [0]: http://www.dolorsitamet.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: http://www.loremipsum.com et http://www.dolorsitamet.com dis http://www.adipiscingelitipsum.com montes, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (Cursor just after second link): normal! 2f:El call link#Convert('single-link') ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expect mail: http://www.loremipsum.com et http://www.dolorsitamet.com dis [0] montes, Links: [0]: http://www.adipiscingelitipsum.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: http://www.loremipsum.com et http://www.dolorsitamet.com dis http://www.adipiscingelitipsum.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (Cursor on last char of last link, no trailing chars): normal! 3f:E call link#Convert('single-link') ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expect mail: http://www.loremipsum.com et http://www.dolorsitamet.com dis [0] Links: [0]: http://www.adipiscingelitipsum.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link.vim-1.4.0/test/other_ft/reformat.vader000066400000000000000000000122211472625555500207140ustar00rootroot00000000000000" Calling functions is required here; the commands are unknown because of the " gitcommit resource Before: unlet! g:link_start_index unlet! g:link_heading unlet! b:link_heading unlet! b:link_heading_before unlet! b:link_skip_line After: unlet! g:link_start_index unlet! g:link_heading unlet! b:link_heading unlet! b:link_heading_before unlet! b:link_skip_line ~~~ 1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given gitcommit: Update README.md with project documentation links This commit updates the README.md file to include links to various project documentation resources. The documentation includes: 2. API Documentation: [1] 3. User Guide: [2] and Developer Documentation Each link provides access to specific documentation sections relevant to different stakeholders involved in the project. This update ensures that stakeholders can easily access the necessary documentation directly from the project's README file. Links: [0]: https://github.com/example/project/wiki [1]: https://api.example.com/docs [2]: https://docs.example.com/user-guide [3]: https://docs.example.com/developer-guide # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # # On branch main # Changes to be committed: # modified: README.md # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (Delete two links, [0] and [3]): let g:link_start_index = 10 let b:link_heading = 'Links:' let b:link_heading_before = '^# Please enter the commit message' let b:link_skip_line = '^>' call link#Reformat() ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expect gitcommit: Update README.md with project documentation links This commit updates the README.md file to include links to various project documentation resources. The documentation includes: 2. API Documentation: [10] 3. User Guide: [11] and Developer Documentation Each link provides access to specific documentation sections relevant to different stakeholders involved in the project. This update ensures that stakeholders can easily access the necessary documentation directly from the project's README file. Links: [10]: https://api.example.com/docs [11]: https://docs.example.com/user-guide # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # # On branch main # Changes to be committed: # modified: README.md # ~~~ 2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given gitcommit: Update README.md with project documentation links > This line should remain untouched: [3] This commit updates the README.md file [7] to include links to various project documentation resources. The documentation includes: 2. API Documentation: [1] Make sure to consult the documentation [55]! 3. User Guide: [2] and Developer Documentation Each link provides access to specific documentation sections relevant to different stakeholders involved in the project. This update ensures that stakeholders can easily access the necessary documentation [5] directly from the project's README file [8]. Links: [5]: https://api.example.com/docs [0]: https://github.com/example/project/wiki [7]: https://github.com/help/readme [1]: https://api.example.com/docs [2]: https://docs.example.com/user-guide [8]: https://github.com/help/readme [3]: https://docs.example.com/developer-guide [55]: https://api.example.com/docs # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # # On branch main # Changes to be committed: # modified: README.md # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Execute (Merge links; do not move cursor): call cursor(5, 6) let b:link_heading = 'Links:' let b:link_heading_before = '^# Please enter the commit message' let b:link_skip_line = '^>' call link#Reformat() let [line_nr, col_nr] = getcurpos()[1:2] AssertEqual line_nr, 5 AssertEqual col_nr, 6 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Expect gitcommit: Update README.md with project documentation links > This line should remain untouched: [3] This commit updates the README.md file [0] to include links to various project documentation resources. The documentation includes: 2. API Documentation: [1] Make sure to consult the documentation [1]! 3. User Guide: [2] and Developer Documentation Each link provides access to specific documentation sections relevant to different stakeholders involved in the project. This update ensures that stakeholders can easily access the necessary documentation [1] directly from the project's README file [0]. Links: [0]: https://github.com/help/readme [1]: https://api.example.com/docs [2]: https://docs.example.com/user-guide # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # # On branch main # Changes to be committed: # modified: README.md # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link.vim-1.4.0/test/other_ft/skip_line.vader000066400000000000000000000033001472625555500210500ustar00rootroot00000000000000Before: unlet! b:link_heading unlet! b:link_skip_line After: unlet! b:link_heading unlet! b:link_skip_line ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given javascript: // filler const url = ' www.magna.com ' // this is a comment: https://vitae.net/index.html ~~~~~ Execute (Use default (commentstring) to skip lines; JavaScript): let b:link_heading = 'Links:' % call link#Convert() ~~~~~ Expect javascript: // filler const url = ' [0] ' // this is a comment: https://vitae.net/index.html Links: [0]: www.magna.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given html: Filler Not a comment: www.magna.com Continued > Blockquote: http://lacus.org/lacus End ~~~~~ Execute (Use default (commentstring) to skip lines; HTML): % call link#Convert() ~~~~~ Expect html: Filler Not a comment: [0] Continued > Blockquote: [1] End Links: [0]: www.magna.com [1]: http://lacus.org/lacus ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given html: Not a comment: www.magna.com Continued > Blockquote: http://lacus.org/lacus End ~~~~~ Execute (Use custom pattern to skip lines; HTML): let b:link_skip_line = '^>' % call link#Convert() ~~~~~ Expect html: Not a comment: [0] Continued > Blockquote: http://lacus.org/lacus End Links: [0]: www.magna.com [1]: https://vitae.net/index.html ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link.vim-1.4.0/test/other_ft/urls.vader000066400000000000000000000043051472625555500200660ustar00rootroot00000000000000Before: unlet! g:link_heading unlet! b:link_heading unlet! b:link_heading_before unlet! b:link_skip_line After: unlet! g:link_heading unlet! b:link_heading unlet! b:link_heading_before unlet! b:link_skip_line ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Given mail: foo www.bar.com foo ftp://ftp.bar.net foo file://path/to/file.txt foo http://www.bar.com foo https://bar.org foo http://192.0.2.1 foo http://subdomain.bar.com foo https://bar.travel foo http://bar.very123longtld foo http://www.ba-r.com foo http://bar.com:8080 foo http://bar.com/baz foo http://bar.com/index.html foo http://www.parameters.org/page2014.html?utm_source=facebook&utm_medium=eventlinkonwall&utm_term=trapshoot&utm_content=calendar_event_on_wall&utm_campaign=trapshoot2014 foo bar foo bar.com Line containing something resembling an inline link: command! -buffer -range=% -bar TagLinks silent keeppatterns ,substitute#\v%(\[[^\]]+\]\(\s*)@,substitute#\v%(\[[^\]]+\]\(\s*)@&2 Usage: $(basename "$0") -e [-w ] [-b] [-o output.txt] [-f file.vader] -e: editor to be used for the tests ('vim' or 'nvim') -w: watch modus (run tests continuously; exit if a test fails) -b: prevent opening of links in browser -o: write output to file; optional; by default, output will be shown inside Vim/Neovim -f: test file(s) to be run; optional; default is all *.vader files; if used, must be last flag EOF exit 1 } while getopts ':e:wbo:f' OPTION; do case "$OPTION" in e) editor_name="$OPTARG" if [[ "$editor_name" != "vim" && "$editor_name" != "nvim" ]]; then show_help_and_exit fi printf "Running tests in: %s\n" "$editor_name" editor=$(command -v "$editor_name") ;; w) watch_modus=true export VADER_OUTPUT_FILE=/dev/null ;; b) export VADER_OPEN_IN_BROWSER=false ;; o) output_to_file=true export VADER_OUTPUT_FILE="$OPTARG" ;; f) all_tests=false ;; *) show_help_and_exit ;; esac done shift "$((OPTIND - 1))" # -e flag is required [[ -z "$editor_name" ]] && show_help_and_exit # Decide if all tests should be run or only one or more particular test(s) if [[ "$all_tests" != false ]]; then test_files='**/*' printf "Running tests in all: *.vader files\n" else test_files="$*" # -f requires an argument [[ -z "$test_files" ]] && show_help_and_exit printf "Running tests in specified files: %s\n" "$test_files" fi if [[ "$output_to_file" == true ]] || [[ "$watch_modus" == true ]]; then vader_cmd="Vader!" else vader_cmd="Vader" fi if [[ "$watch_modus" == true ]]; then printf '\nRunning tests in background...\n' printf 'Script will exit in case a test fails\n' sleep 1 while true; do clear if "$editor" -N -u workstation.vimrc +"${vader_cmd} ${test_files}"; then sleep 1 else printf "\e[31mFailure\e[0m\n\a" break fi done else # -N No-compatible mode # -u {vimrc} Use the commands in the file {vimrc} for initializations "$editor" -N -u workstation.vimrc +"${vader_cmd} ${test_files}" fi link.vim-1.4.0/test/workstation.vimrc000066400000000000000000000023401472625555500176670ustar00rootroot00000000000000" Create a testing environment isolated from existing plugins and settings on " your workstation " Settings --------------------------------------------------------- {{{1 filetype plugin indent on syntax enable " Disable the pager prompt `-- More --`; see `:help pager` and `:help more` set nomore " Key bindings ----------------------------------------------------- {{{1 " Exit tests nnoremap Q :qa! inoremap Q :qa! " Load plugins ----------------------------------------------------- {{{1 " Location where plugins are installed, depends on Vim/Neovim/plugin manager " E.g. when using regular Vim and Vundle: ~/.vim/bundle/ let s:vim_plugins_dir = '~/.vim/plugged/' let s:neovim_plugins_dir = '~/.local/share/nvim/plugged/' " Add plugin to runtimepath function! LoadPlugin(name) if has('nvim') let s:plugin_path = s:neovim_plugins_dir .. a:name else let s:plugin_path = s:vim_plugins_dir .. a:name endif if isdirectory( expand(s:plugin_path) ) let &runtimepath ..= ',' .. expand(s:plugin_path) else throw 'Could not find the ' .. a:name .. ' plugin. Is it installed?' endif endfunction " Load Vader test framework call LoadPlugin('vader.vim') " Load this plugin call LoadPlugin('link.vim')