Conf: #1060 Get configurable schemes_web

Permit opening file with name "ssh: name with spaces.md"
This commit is contained in:
Tinmarino
2021-01-10 13:00:54 -03:00
parent e7124290a2
commit 850aace465
6 changed files with 60 additions and 30 deletions
+9 -1
View File
@@ -182,7 +182,12 @@ function! vimwiki#base#resolve_link(link_text, ...) abort
endif endif
" Check if absolute or relative path " Check if absolute or relative path
" TODO Clean that => just one call
let is_absolute = 0 let is_absolute = 0
if vimwiki#path#is_absolute(link_text)
let is_absolute = 1
let link_text = expand(link_text)
endif
if is_wiki_link && link_text[0] ==# '/' if is_wiki_link && link_text[0] ==# '/'
if link_text !=# '/' if link_text !=# '/'
if link_text !=# '//' && link_text[0:1] ==# '//' if link_text !=# '//' && link_text[0:1] ==# '//'
@@ -234,8 +239,9 @@ function! vimwiki#base#resolve_link(link_text, ...) abort
return link_infos return link_infos
endif endif
endif endif
if is_absolute if is_absolute
let root_dir = '' let root_dir = ''
elseif !is_relative || link_infos.index != source_wiki elseif !is_relative || link_infos.index != source_wiki
let root_dir = vimwiki#vars#get_wikilocal('path', link_infos.index) let root_dir = vimwiki#vars#get_wikilocal('path', link_infos.index)
endif endif
@@ -262,8 +268,10 @@ function! vimwiki#base#resolve_link(link_text, ...) abort
\ vimwiki#vars#get_wikilocal('diary_rel_path', link_infos.index) . \ vimwiki#vars#get_wikilocal('diary_rel_path', link_infos.index) .
\ link_text . \ link_text .
\ vimwiki#vars#get_wikilocal('ext', link_infos.index) \ vimwiki#vars#get_wikilocal('ext', link_infos.index)
elseif (link_infos.scheme ==# 'file' || link_infos.scheme ==# 'local') && is_relative elseif (link_infos.scheme ==# 'file' || link_infos.scheme ==# 'local') && is_relative
let link_infos.filename = simplify(root_dir . link_text) let link_infos.filename = simplify(root_dir . link_text)
else " absolute file link else " absolute file link
" collapse repeated leading "/"'s within a link " collapse repeated leading "/"'s within a link
let link_text = substitute(link_text, '\m^/\+', '/', '') let link_text = substitute(link_text, '\m^/\+', '/', '')
+11 -2
View File
@@ -204,11 +204,20 @@ endfunction
function! vimwiki#path#is_absolute(path) abort function! vimwiki#path#is_absolute(path) abort
" Check: if path is absolute " Check: if path is absolute
let res=0
" Match 'C:' or '/' or '~'
if vimwiki#u#is_windows() if vimwiki#u#is_windows()
return a:path =~? '\m^\a:' let res += a:path =~? '\m^\a:'
else else
return a:path =~# '\m^/\|\~/' let res += a:path =~# '\m^/\|\~/'
endif endif
" Do not prepent root_path to scp files
" See: https://vim.fandom.com/wiki/Editing_remote_files_via_scp_in_vim
let res += a:path =~# '\m^scp:'
return res
endfunction endfunction
+17 -14
View File
@@ -172,6 +172,13 @@ function! s:get_default_global() abort
\ 'map_prefix': {'type': type(''), 'default': '<Leader>w'}, \ 'map_prefix': {'type': type(''), 'default': '<Leader>w'},
\ 'markdown_header_style': {'type': type(0), 'default': 1, 'min':0, 'max': 2}, \ 'markdown_header_style': {'type': type(0), 'default': 1, 'min':0, 'max': 2},
\ 'menu': {'type': type(''), 'default': 'Vimwiki'}, \ 'menu': {'type': type(''), 'default': 'Vimwiki'},
\ 'schemes_web': {'type': type([]), 'default':
\ [
\ 'http', 'https', 'file', 'ftp', 'gopher', 'telnet', 'nntp', 'ldap',
\ 'rsync', 'imap', 'pop', 'irc', 'ircs', 'cvs', 'svn', 'svn+ssh',
\ 'git', 'ssh', 'fish', 'sftp',
\ ]},
\ 'schemes_any': {'type': type([]), 'default': ['mailto', 'news', 'xmpp', 'sip', 'sips', 'doi', 'urn', 'tel', 'data']},
\ 'table_auto_fmt': {'type': type(0), 'default': 1, 'min': 0, 'max': 1}, \ 'table_auto_fmt': {'type': type(0), 'default': 1, 'min': 0, 'max': 1},
\ 'table_reduce_last_col': {'type': type(0), 'default': 0, 'min': 0, 'max': 1}, \ 'table_reduce_last_col': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
\ 'table_mappings': {'type': type(0), 'default': 1, 'min': 0, 'max': 1}, \ 'table_mappings': {'type': type(0), 'default': 1, 'min': 0, 'max': 1},
@@ -205,22 +212,18 @@ function! s:internal_global_settings() abort
" able to <leader>w<leader>w without opening any vimwiki file first " able to <leader>w<leader>w without opening any vimwiki file first
" Know internal schemes " Know internal schemes
let g:vimwiki_global_vars.schemes = join(['wiki\d\+', 'diary', 'local'], '\|')
" Are used in markdown for image links let g:vimwiki_global_vars.schemes_web =
let g:vimwiki_global_vars.web_schemes1 = join(['http', 'https', 'file', 'ftp', 'gopher', \ join(vimwiki#vars#get_global('schemes_web'), '\|')
\ 'telnet', 'nntp', 'ldap', 'rsync', 'imap', 'pop', 'irc', 'ircs', 'cvs', 'svn', 'svn+ssh', let g:vimwiki_global_vars.schemes_any =
\ 'git', 'ssh', 'fish', 'sftp'], '\|') \ join(vimwiki#vars#get_global('schemes_any'), '\|')
let g:vimwiki_global_vars.schemes_local = join(['wiki\d\+', 'diary', 'local'], '\|')
" Other possible schemes
let web_schemes2 =
\ join(['mailto', 'news', 'xmpp', 'sip', 'sips', 'doi', 'urn', 'tel', 'data'], '\|')
" Concatenate known schemes => regex " Concatenate known schemes => regex
let g:vimwiki_global_vars.rxSchemes = '\%('. let g:vimwiki_global_vars.rxSchemes = '\%('.
\ g:vimwiki_global_vars.schemes . '\|'. \ g:vimwiki_global_vars.schemes_local . '\|'.
\ g:vimwiki_global_vars.web_schemes1 . '\|'. \ g:vimwiki_global_vars.schemes_web . '\|'.
\ web_schemes2 . \ g:vimwiki_global_vars.schemes_any .
\ '\)' \ '\)'
" Match URL for common protocols; see http://en.wikipedia.org/wiki/URI_scheme " Match URL for common protocols; see http://en.wikipedia.org/wiki/URI_scheme
@@ -228,11 +231,11 @@ function! s:internal_global_settings() abort
let rxWebProtocols = let rxWebProtocols =
\ '\%('. \ '\%('.
\ '\%('. \ '\%('.
\ '\%('.g:vimwiki_global_vars.web_schemes1 . '\):'. \ '\%('. g:vimwiki_global_vars.schemes_web . '\):'.
\ '\%(//\)'. \ '\%(//\)'.
\ '\)'. \ '\)'.
\ '\|'. \ '\|'.
\ '\%('.web_schemes2.'\):'. \ '\%('. g:vimwiki_global_vars.schemes_any .'\):'.
\ '\)' \ '\)'
let g:vimwiki_global_vars.rxWeblinkUrl = rxWebProtocols . '\S\{-1,}'. '\%(([^ \t()]*)\)\=' let g:vimwiki_global_vars.rxWeblinkUrl = rxWebProtocols . '\S\{-1,}'. '\%(([^ \t()]*)\)\='
+18 -9
View File
@@ -616,7 +616,7 @@ TABLE MAPPINGS, INSERT MODE *vimwiki-table-mappings*
to the largest cell. to the largest cell.
Remap command: `<Plug>VimwikiTableNextCell` Remap command: `<Plug>VimwikiTableNextCell`
*vimwiki_i_<Tab>_table* *vimwiki_i_<S-Tab>_table*
<S-Tab> Go to the previous table cell. Adjusts the whole <S-Tab> Go to the previous table cell. Adjusts the whole
column width according to the largest cell. column width according to the largest cell.
Remap command: `<Plug>VimwikiTablePrevCell` Remap command: `<Plug>VimwikiTablePrevCell`
@@ -1023,7 +1023,7 @@ For Markdown syntax these variations are used: >
Furthermore, there are a number of words which are highlighted extra flashy: Furthermore, there are a number of words which are highlighted extra flashy:
TODO, DONE, STARTED, FIXME, FIXED, XXX (customisable, see TODO, DONE, STARTED, FIXME, FIXED, XXX (customisable, see
vimwiki-option-rx_todo). |g:vimwiki-option-rx_todo|).
When rendered as HTML, code blocks containing only a hash prefixed 6 digit hex When rendered as HTML, code blocks containing only a hash prefixed 6 digit hex
number will be colored as themselves. For example > number will be colored as themselves. For example >
@@ -2830,8 +2830,8 @@ This setting specifies the URL where the generated VimWiki HTML pages can
be reached. It is used for the link to the RSS feed and for links to the be reached. It is used for the link to the RSS feed and for links to the
diary entries inside the feed. diary entries inside the feed.
------------------------------------------------------------------------------
*g:vimwiki_toc_header* *g:vimwiki_toc_header*
------------------------------------------------------------------------------
A string with the magic header that tells Vimwiki where the Table of Contents A string with the magic header that tells Vimwiki where the Table of Contents
(see |vimwiki-toc|) is located in a file. You can change it to the (see |vimwiki-toc|) is located in a file. You can change it to the
@@ -2840,16 +2840,16 @@ appropriate word in your mother tongue like this: >
The default is 'Contents'. The default is 'Contents'.
------------------------------------------------------------------------------
*g:vimwiki_toc_header_level* *g:vimwiki_toc_header_level*
------------------------------------------------------------------------------
The header level of the Table of Contents (see |vimwiki-toc|). Valid values The header level of the Table of Contents (see |vimwiki-toc|). Valid values
are from 1 to 6. are from 1 to 6.
The default is 1. The default is 1.
------------------------------------------------------------------------------
*g:vimwiki_toc_link_format* *g:vimwiki_toc_link_format*
------------------------------------------------------------------------------
The format of the links in the Table of Contents (see |vimwiki-toc|). The format of the links in the Table of Contents (see |vimwiki-toc|).
@@ -2862,8 +2862,8 @@ Value Description~
Default: 0 Default: 0
------------------------------------------------------------------------------
*vimwiki-option-color_dic* *vimwiki-option-color_dic*
------------------------------------------------------------------------------
Dictionary containing the possible html colors for |:VimwikiColorize| the Dictionary containing the possible html colors for |:VimwikiColorize| the
keys are the color names used as argument, the values are a list [foreground, keys are the color names used as argument, the values are a list [foreground,
@@ -2875,16 +2875,16 @@ Provides two colors to |:VimwikiColorize|: 'red' => red foreground and 'bred'
=> red background. => red background.
------------------------------------------------------------------------------
*g:vimwiki-option-rx_todo* *g:vimwiki-option-rx_todo*
------------------------------------------------------------------------------
Regular expression used to highlight different TODO words. Regular expression used to highlight different TODO words.
Default: `\C\<\%(TODO\|DONE\|STARTED\|FIXME\|FIXED\|XXX\)\>` Default: `\C\<\%(TODO\|DONE\|STARTED\|FIXME\|FIXED\|XXX\)\>`
------------------------------------------------------------------------------
*vimwiki-option-color_tag_template* *vimwiki-option-color_tag_template*
------------------------------------------------------------------------------
Not supposed to be edited already: a regex with __COLORFG__, __COLORBG__ and Not supposed to be edited already: a regex with __COLORFG__, __COLORBG__ and
__CONTENT__ placeholders to surround the content with a tag to define its __CONTENT__ placeholders to surround the content with a tag to define its
@@ -2915,6 +2915,16 @@ Where:
- `global_ext` is the option name - `global_ext` is the option name
- `1` is the option value - `1` is the option value
------------------------------------------------------------------------------
*g:vimwiki_schemes_web* *g:vimwiki_schemes_any*
List of know schemes. shemes_web will match if there is a "//" like in
https://github.com
Example: ~
let g:vimwiki_schemes_web = ['http', 'https']
Default:~
['http', 'https', 'file', ... , 'git', 'ssh', 'fish', 'sftp']
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
*g:vimwiki_hl_headers* *g:vimwiki_hl_headers*
@@ -2927,7 +2937,6 @@ Value Description~
0 Use |hl-Title| color for headers. 0 Use |hl-Title| color for headers.
Default: 0 Default: 0
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
*g:vimwiki_hl_cb_checked* *g:vimwiki_hl_cb_checked*
+3 -2
View File
@@ -118,10 +118,11 @@ call s:add_target_syntax_ON(vimwiki#vars#get_syntaxlocal('rxWeblink'), 'VimwikiL
" WikiLink: " WikiLink:
" All remaining schemes are highlighted automatically " All remaining schemes are highlighted automatically
let s:rxSchemes = '\%('. let s:rxSchemes = '\%('.
\ vimwiki#vars#get_global('schemes') . '\|'. \ vimwiki#vars#get_global('schemes_local') . '\|'.
\ vimwiki#vars#get_global('web_schemes1'). \ vimwiki#vars#get_global('schemes_web').
\ '\):' \ '\):'
" a) match [[nonwiki-scheme-URL]] " a) match [[nonwiki-scheme-URL]]
let s:target = vimwiki#base#apply_template( let s:target = vimwiki#base#apply_template(
\ vimwiki#u#escape(vimwiki#vars#get_global('WikiLinkTemplate1')), \ vimwiki#u#escape(vimwiki#vars#get_global('WikiLinkTemplate1')),
+2 -2
View File
@@ -105,8 +105,8 @@ call s:add_target_syntax_ON(vimwiki#vars#get_syntaxlocal('rxImage'), 'VimwikiIma
" WikiLink " WikiLink
" All remaining schemes are highlighted automatically " All remaining schemes are highlighted automatically
let s:rxSchemes = '\%('. let s:rxSchemes = '\%('.
\ vimwiki#vars#get_global('schemes') . '\|'. \ vimwiki#vars#get_global('schemes_local') . '\|'.
\ vimwiki#vars#get_global('web_schemes1'). \ vimwiki#vars#get_global('schemes_web').
\ '\):' \ '\):'
" a) match [nonwiki-scheme-URL] " a) match [nonwiki-scheme-URL]