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
" Check if absolute or relative path
" TODO Clean that => just one call
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 link_text !=# '/'
if link_text !=# '//' && link_text[0:1] ==# '//'
@@ -234,8 +239,9 @@ function! vimwiki#base#resolve_link(link_text, ...) abort
return link_infos
endif
endif
if is_absolute
let root_dir = ''
let root_dir = ''
elseif !is_relative || link_infos.index != source_wiki
let root_dir = vimwiki#vars#get_wikilocal('path', link_infos.index)
endif
@@ -262,8 +268,10 @@ function! vimwiki#base#resolve_link(link_text, ...) abort
\ vimwiki#vars#get_wikilocal('diary_rel_path', link_infos.index) .
\ link_text .
\ vimwiki#vars#get_wikilocal('ext', link_infos.index)
elseif (link_infos.scheme ==# 'file' || link_infos.scheme ==# 'local') && is_relative
let link_infos.filename = simplify(root_dir . link_text)
else " absolute file link
" collapse repeated leading "/"'s within a link
let link_text = substitute(link_text, '\m^/\+', '/', '')
+11 -2
View File
@@ -204,11 +204,20 @@ endfunction
function! vimwiki#path#is_absolute(path) abort
" Check: if path is absolute
let res=0
" Match 'C:' or '/' or '~'
if vimwiki#u#is_windows()
return a:path =~? '\m^\a:'
let res += a:path =~? '\m^\a:'
else
return a:path =~# '\m^/\|\~/'
let res += a:path =~# '\m^/\|\~/'
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
+17 -14
View File
@@ -172,6 +172,13 @@ function! s:get_default_global() abort
\ 'map_prefix': {'type': type(''), 'default': '<Leader>w'},
\ 'markdown_header_style': {'type': type(0), 'default': 1, 'min':0, 'max': 2},
\ '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_reduce_last_col': {'type': type(0), 'default': 0, '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
" 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.web_schemes1 = join(['http', 'https', 'file', 'ftp', 'gopher',
\ 'telnet', 'nntp', 'ldap', 'rsync', 'imap', 'pop', 'irc', 'ircs', 'cvs', 'svn', 'svn+ssh',
\ 'git', 'ssh', 'fish', 'sftp'], '\|')
" Other possible schemes
let web_schemes2 =
\ join(['mailto', 'news', 'xmpp', 'sip', 'sips', 'doi', 'urn', 'tel', 'data'], '\|')
let g:vimwiki_global_vars.schemes_web =
\ join(vimwiki#vars#get_global('schemes_web'), '\|')
let g:vimwiki_global_vars.schemes_any =
\ join(vimwiki#vars#get_global('schemes_any'), '\|')
let g:vimwiki_global_vars.schemes_local = join(['wiki\d\+', 'diary', 'local'], '\|')
" Concatenate known schemes => regex
let g:vimwiki_global_vars.rxSchemes = '\%('.
\ g:vimwiki_global_vars.schemes . '\|'.
\ g:vimwiki_global_vars.web_schemes1 . '\|'.
\ web_schemes2 .
\ g:vimwiki_global_vars.schemes_local . '\|'.
\ g:vimwiki_global_vars.schemes_web . '\|'.
\ g:vimwiki_global_vars.schemes_any .
\ '\)'
" 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 =
\ '\%('.
\ '\%('.
\ '\%('.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()]*)\)\='
+18 -9
View File
@@ -616,7 +616,7 @@ TABLE MAPPINGS, INSERT MODE *vimwiki-table-mappings*
to the largest cell.
Remap command: `<Plug>VimwikiTableNextCell`
*vimwiki_i_<Tab>_table*
*vimwiki_i_<S-Tab>_table*
<S-Tab> Go to the previous table cell. Adjusts the whole
column width according to the largest cell.
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:
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
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
diary entries inside the feed.
------------------------------------------------------------------------------
*g:vimwiki_toc_header*
------------------------------------------------------------------------------
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
@@ -2840,16 +2840,16 @@ appropriate word in your mother tongue like this: >
The default is 'Contents'.
------------------------------------------------------------------------------
*g:vimwiki_toc_header_level*
------------------------------------------------------------------------------
The header level of the Table of Contents (see |vimwiki-toc|). Valid values
are from 1 to 6.
The default is 1.
------------------------------------------------------------------------------
*g:vimwiki_toc_link_format*
------------------------------------------------------------------------------
The format of the links in the Table of Contents (see |vimwiki-toc|).
@@ -2862,8 +2862,8 @@ Value Description~
Default: 0
------------------------------------------------------------------------------
*vimwiki-option-color_dic*
------------------------------------------------------------------------------
Dictionary containing the possible html colors for |:VimwikiColorize| the
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.
------------------------------------------------------------------------------
*g:vimwiki-option-rx_todo*
------------------------------------------------------------------------------
Regular expression used to highlight different TODO words.
Default: `\C\<\%(TODO\|DONE\|STARTED\|FIXME\|FIXED\|XXX\)\>`
------------------------------------------------------------------------------
*vimwiki-option-color_tag_template*
------------------------------------------------------------------------------
Not supposed to be edited already: a regex with __COLORFG__, __COLORBG__ and
__CONTENT__ placeholders to surround the content with a tag to define its
@@ -2915,6 +2915,16 @@ Where:
- `global_ext` is the option name
- `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*
@@ -2927,7 +2937,6 @@ Value Description~
0 Use |hl-Title| color for headers.
Default: 0
------------------------------------------------------------------------------
*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:
" All remaining schemes are highlighted automatically
let s:rxSchemes = '\%('.
\ vimwiki#vars#get_global('schemes') . '\|'.
\ vimwiki#vars#get_global('web_schemes1').
\ vimwiki#vars#get_global('schemes_local') . '\|'.
\ vimwiki#vars#get_global('schemes_web').
\ '\):'
" a) match [[nonwiki-scheme-URL]]
let s:target = vimwiki#base#apply_template(
\ 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
" All remaining schemes are highlighted automatically
let s:rxSchemes = '\%('.
\ vimwiki#vars#get_global('schemes') . '\|'.
\ vimwiki#vars#get_global('web_schemes1').
\ vimwiki#vars#get_global('schemes_local') . '\|'.
\ vimwiki#vars#get_global('schemes_web').
\ '\):'
" a) match [nonwiki-scheme-URL]