mirror of
https://github.com/gryf/.vim.git
synced 2025-12-17 11:30:29 +01:00
Update of plugins vimwiki, mark and pydoc
This commit is contained in:
@@ -7,22 +7,22 @@ ScriptID SourceID Filename
|
||||
3304 18081 gundo.vim
|
||||
2727 11120 jsbeautify.vim
|
||||
2289 8922 loremipsum
|
||||
2666 17810 Mark
|
||||
2666 18218 Mark
|
||||
1218 14455 nerdcommenter
|
||||
2262 8944 occur.vim
|
||||
2136 8206 repeat.vim
|
||||
152 3342 showmarks.vim
|
||||
2540 11006 snipMate.vim
|
||||
1697 12566 surround.vim
|
||||
3465 18143 Tagbar
|
||||
3465 18273 Tagbar
|
||||
90 17031 vcscommand.vim
|
||||
2226 18100 vimwiki.vim
|
||||
2226 18232 vimwiki.vim
|
||||
1334 6377 vst.vim
|
||||
2321 9055 zoom.vim
|
||||
52 14880 calendar.vim
|
||||
### ftplugin
|
||||
3818 16921 MatchTag
|
||||
910 14691 pydoc.vim
|
||||
910 18164 pydoc.vim
|
||||
2441 14403 pyflakes.vim
|
||||
30 9196 python_fn.vim
|
||||
435 12010 pythonhelper.vim
|
||||
|
||||
@@ -1,111 +1,196 @@
|
||||
"pydoc.vim: pydoc integration for vim
|
||||
"performs searches and can display the documentation of python modules
|
||||
"Author: Andr<EFBFBD> Kelpe <efeshundertelf at googlemail dot com>
|
||||
"Author: Romain Chossart <romainchossat at gmail dot com>
|
||||
"Author: Matthias Vogelgesang
|
||||
"http://www.vim.org/scripts/script.php?script_id=910
|
||||
"This plugin integrates the pydoc into vim. You can view the
|
||||
"documentation of a module by using :Pydoc foo.bar.baz or search
|
||||
"a word (uses pydoc -k) in the documentation by typing PydocSearch
|
||||
"foobar. You can also view the documentation of the word under the
|
||||
"cursor by pressing <leader>pw or the WORD (see :help WORD) by pressing
|
||||
"<leader>pW. "This is very useful if you want to jump to a module which was found by
|
||||
"PydocSearch. To have a browser like feeling you can use u and CTRL-R to
|
||||
"go back and forward, just like editing normal text.
|
||||
" Vim ftplugin file
|
||||
" Language: Python
|
||||
" Authors: André Kelpe <efeshundertelf at googlemail dot com>
|
||||
" Romain Chossart <romainchossat at gmail dot com>
|
||||
" Matthias Vogelgesang
|
||||
" Ricardo Catalinas Jiménez <jimenezrick at gmail dot com>
|
||||
" Patches and suggestions from all sorts of fine people
|
||||
"
|
||||
" More info and updates at:
|
||||
"
|
||||
" http://www.vim.org/scripts/script.php?script_id=910
|
||||
"
|
||||
"
|
||||
" This plugin integrates the Python documentation view and search tool pydoc
|
||||
" into Vim. It allows you to view the documentation of a Python module or class
|
||||
" by typing:
|
||||
"
|
||||
" :Pydoc foo.bar.baz (e.g. :Pydoc re.compile)
|
||||
"
|
||||
" Or search a word (uses pydoc -k) in the documentation by typing:
|
||||
"
|
||||
" :PydocSearch foobar (e.g. :PydocSearch socket)
|
||||
"
|
||||
" Vim will split the current window to show the Python documentation found by
|
||||
" pydoc (the buffer will be called '__doc__', Pythonic, isn't it ;-) ). The
|
||||
" name may cause problems if you have a file with the same name, but usually
|
||||
" this should not happen.
|
||||
"
|
||||
" pydoc.vim also allows you to view the documentation of the 'word' (see :help
|
||||
" word) under the cursor by pressing <Leader>pw or the 'WORD' (see :help WORD)
|
||||
" under the cursor by pressing <Leader>pW. This is very useful if you want to
|
||||
" jump to the docs of a module or class found by 'PydocSearch' or if you want
|
||||
" to see the docs of a module/class in your source code. Additionally K is
|
||||
" mapped to show invoke pydoc as well, when you are editing python files.
|
||||
"
|
||||
" The script is developed in GitHub at:
|
||||
"
|
||||
" http://github.com/fs111/pydoc.vim
|
||||
"
|
||||
"
|
||||
" If you want to use the script and pydoc is not in your PATH, just put a
|
||||
" line like this in your .vimrc:
|
||||
"
|
||||
" let g:pydoc_cmd = '/usr/bin/pydoc'
|
||||
"
|
||||
" or more portable
|
||||
"
|
||||
" let g:pydoc_cmd = 'python -m pydoc'
|
||||
"
|
||||
" If you want to open pydoc files in vertical splits or tabs, give the
|
||||
" appropriate command in your .vimrc with:
|
||||
"
|
||||
" let g:pydoc_open_cmd = 'vsplit'
|
||||
"
|
||||
" or
|
||||
"
|
||||
" let g:pydoc_open_cmd = 'tabnew'
|
||||
"
|
||||
" The script will highlight the search term by default. To disable this behaviour
|
||||
" put in your .vimrc:
|
||||
"
|
||||
" let g:pydoc_highlight=0
|
||||
"
|
||||
"
|
||||
" In order to install pydoc.vim download it from vim.org or clone the repository
|
||||
" on githubi and put it in your .vim/ftplugin directory. pydoc.vim is also fully
|
||||
" compatible with pathogen, so cloning the repository into your bundle directory
|
||||
" is also a valid way to install it. (I do this myself. see
|
||||
" https://github.com/fs111/dotvim).
|
||||
"
|
||||
" pydoc.vim is free software; you can redistribute it and/or
|
||||
" modify it under the terms of the GNU General Public License
|
||||
" as published by the Free Software Foundation; either version 2
|
||||
" of the License, or (at your option) any later version.
|
||||
"
|
||||
" Please feel free to contact me and follow me on twitter (@fs111).
|
||||
|
||||
"If you want to use the script and pydoc is not in your PATH, just put a
|
||||
"line like
|
||||
" IMPORTANT: We don't use here the `exists("b:did_ftplugin")' guard becase we
|
||||
" want to let the Python filetype script that comes with Vim to execute as
|
||||
" normal.
|
||||
|
||||
" let g:pydoc_cmd = \"/usr/bin/pydoc" (without the backslash!!)
|
||||
" Don't redefine the functions if this ftplugin has been executed previously
|
||||
" and before finish create the local mappings in the current buffer
|
||||
if exists('*s:ShowPyDoc') && g:pydoc_perform_mappings
|
||||
call s:PerformMappings()
|
||||
finish
|
||||
endif
|
||||
|
||||
"in your .vimrc
|
||||
if !exists('g:pydoc_perform_mappings')
|
||||
let g:pydoc_perform_mappings = 1
|
||||
endif
|
||||
|
||||
if !exists('g:pydoc_highlight')
|
||||
let g:pydoc_highlight = 1
|
||||
endif
|
||||
|
||||
"pydoc.vim is free software, you can redistribute or modify
|
||||
"it under the terms of the GNU General Public License Version 2 or any
|
||||
"later Version (see http://www.gnu.org/copyleft/gpl.html for details).
|
||||
if !exists('g:pydoc_cmd')
|
||||
let g:pydoc_cmd = 'pydoc'
|
||||
endif
|
||||
|
||||
"Please feel free to contact me.
|
||||
if !exists('g:pydoc_open_cmd')
|
||||
let g:pydoc_open_cmd = 'split'
|
||||
endif
|
||||
|
||||
setlocal switchbuf=useopen
|
||||
highlight pydoc cterm=reverse gui=reverse
|
||||
|
||||
set switchbuf=useopen
|
||||
function! ShowPyDoc(name, type)
|
||||
if !exists('g:pydoc_cmd')
|
||||
let g:pydoc_cmd = 'pydoc'
|
||||
function s:ShowPyDoc(name, type)
|
||||
if a:name == ''
|
||||
return
|
||||
endif
|
||||
|
||||
if bufloaded("__doc__") >0
|
||||
if g:pydoc_open_cmd == 'split'
|
||||
let l:pydoc_wh = 10
|
||||
endif
|
||||
|
||||
if bufloaded("__doc__")
|
||||
let l:buf_is_new = 0
|
||||
if bufname("%") == "__doc__"
|
||||
" The current buffer is __doc__, thus do not
|
||||
" recreate nor resize it
|
||||
let l:pydoc_wh = -1
|
||||
else
|
||||
" If the __doc__ buffer is open, jump to it
|
||||
silent execute "sbuffer" bufnr("__doc__")
|
||||
let l:pydoc_wh = -1
|
||||
endif
|
||||
else
|
||||
let l:buf_is_new = 1
|
||||
silent execute g:pydoc_open_cmd '__doc__'
|
||||
if g:pydoc_perform_mappings
|
||||
call s:PerformMappings()
|
||||
endif
|
||||
endif
|
||||
|
||||
if bufnr("__doc__") >0
|
||||
execute "sb __doc__"
|
||||
else
|
||||
execute 'split __doc__'
|
||||
endif
|
||||
setlocal noswapfile
|
||||
set buftype=nofile
|
||||
setlocal modifiable
|
||||
normal ggdG
|
||||
" remove function/method arguments
|
||||
setlocal noswapfile
|
||||
setlocal buftype=nofile
|
||||
setlocal bufhidden=delete
|
||||
setlocal syntax=man
|
||||
|
||||
silent normal ggdG
|
||||
" Remove function/method arguments
|
||||
let s:name2 = substitute(a:name, '(.*', '', 'g' )
|
||||
" remove all colons
|
||||
" Remove all colons
|
||||
let s:name2 = substitute(s:name2, ':', '', 'g' )
|
||||
if a:type==1
|
||||
execute "silent read ! " . g:pydoc_cmd . " " . s:name2
|
||||
else
|
||||
execute "silent read ! " . g:pydoc_cmd . " -k " . s:name2
|
||||
endif
|
||||
setlocal nomodified
|
||||
set filetype=man
|
||||
if a:type == 1
|
||||
execute "silent read !" g:pydoc_cmd s:name2
|
||||
else
|
||||
execute "silent read !" g:pydoc_cmd "-k" s:name2
|
||||
endif
|
||||
normal 1G
|
||||
|
||||
if !exists('g:pydoc_wh')
|
||||
let g:pydoc_wh = 10
|
||||
if exists('l:pydoc_wh') && l:pydoc_wh != -1
|
||||
execute "silent resize" l:pydoc_wh
|
||||
end
|
||||
resize -999
|
||||
execute "silent resize +" . g:pydoc_wh
|
||||
|
||||
if !exists('g:pydoc_highlight')
|
||||
let g:pydoc_highlight = 1
|
||||
endif
|
||||
if g:pydoc_highlight == 1
|
||||
call Highlight(s:name2)
|
||||
endif
|
||||
execute 'syntax match pydoc' "'" . s:name2 . "'"
|
||||
endif
|
||||
|
||||
let l:line = getline(2)
|
||||
if l:line =~ "^no Python documentation found for.*$"
|
||||
if l:line =~ "^no Python documentation found for.*$"
|
||||
if l:buf_is_new
|
||||
execute "bd!"
|
||||
execute "bdelete!"
|
||||
else
|
||||
normal u
|
||||
setlocal nomodified
|
||||
setlocal nomodifiable
|
||||
endif
|
||||
redraw
|
||||
echohl WarningMsg | echo l:line | echohl None
|
||||
else
|
||||
setlocal nomodified
|
||||
setlocal nomodifiable
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"highlighting
|
||||
function! Highlight(name)
|
||||
execute "sb __doc__"
|
||||
set filetype=man
|
||||
"syn on
|
||||
execute 'syntax keyword pydoc '.a:name
|
||||
hi pydoc gui=reverse
|
||||
" Mappings
|
||||
function s:PerformMappings()
|
||||
nnoremap <silent> <buffer> <Leader>pw :call <SID>ShowPyDoc('<C-R><C-W>', 1)<CR>
|
||||
nnoremap <silent> <buffer> <Leader>pW :call <SID>ShowPyDoc('<C-R><C-A>', 1)<CR>
|
||||
nnoremap <silent> <buffer> <Leader>pk :call <SID>ShowPyDoc('<C-R><C-W>', 0)<CR>
|
||||
nnoremap <silent> <buffer> <Leader>pK :call <SID>ShowPyDoc('<C-R><C-A>', 0)<CR>
|
||||
|
||||
" remap the K (or 'help') key
|
||||
nnoremap <silent> <buffer> K :call <SID>ShowPyDoc(expand("<cword>"), 1)<CR>
|
||||
endfunction
|
||||
|
||||
"mappings
|
||||
au FileType python,man map <buffer> <leader>pw :call ShowPyDoc('<C-R><C-W>', 1)<CR>
|
||||
au FileType python,man map <buffer> <leader>pW :call ShowPyDoc('<C-R><C-A>', 1)<CR>
|
||||
au FileType python,man map <buffer> <leader>pk :call ShowPyDoc('<C-R><C-W>', 0)<CR>
|
||||
au FileType python,man map <buffer> <leader>pK :call ShowPyDoc('<C-R><C-A>', 0)<CR>
|
||||
if g:pydoc_perform_mappings
|
||||
call s:PerformMappings()
|
||||
endif
|
||||
|
||||
" remap the K (or 'help') key
|
||||
nnoremap <silent> <buffer> K :call ShowPyDoc(expand("<cword>"), 1)<CR>
|
||||
|
||||
|
||||
"commands
|
||||
command! -nargs=1 Pydoc :call ShowPyDoc('<args>', 1)
|
||||
command! -nargs=* PydocSearch :call ShowPyDoc('<args>', 0)
|
||||
" Commands
|
||||
command -nargs=1 Pydoc :call s:ShowPyDoc('<args>', 1)
|
||||
command -nargs=* PydocSearch :call s:ShowPyDoc('<args>', 0)
|
||||
|
||||
@@ -1,112 +0,0 @@
|
||||
This is a mirror of http://www.vim.org/scripts/script.php?script_id=2226
|
||||
|
||||
A Personal Wiki For Vim Plugin
|
||||
==============================================================================
|
||||
Screenshots are available on http://code.google.com/p/vimwiki/
|
||||
There are also zipped vimwiki files there in case you do not like vimball archives.
|
||||
|
||||
|
||||
Prerequisites
|
||||
==============================================================================
|
||||
Make sure you have these settings in your vimrc file:
|
||||
|
||||
set nocompatible
|
||||
filetype plugin on
|
||||
syntax on
|
||||
|
||||
Without them Vimwiki will not work properly.
|
||||
|
||||
|
||||
Intro
|
||||
==============================================================================
|
||||
Vimwiki is a personal wiki for Vim -- a number of linked text files that have
|
||||
their own syntax highlighting.
|
||||
|
||||
With vimwiki you can:
|
||||
- organize notes and ideas;
|
||||
- manage todo-lists;
|
||||
- write documentation.
|
||||
|
||||
To do a quick start press <Leader>ww (this is usually \ww) to go to your index
|
||||
wiki file. By default it is located in:
|
||||
~/vimwiki/index.wiki
|
||||
|
||||
Feed it with the following example:
|
||||
|
||||
= My knowledge base =
|
||||
* Tasks -- things to be done _yesterday_!!!
|
||||
* Project Gutenberg -- good books are power.
|
||||
* Scratchpad -- various temporary stuff.
|
||||
|
||||
Place your cursor on 'Tasks' and press Enter to create a link. Once pressed,
|
||||
'Tasks' will become '[[Tasks]]' -- a vimwiki link. Press Enter again to
|
||||
open it. Edit the file, save it, and then press Backspace to jump back to your
|
||||
index.
|
||||
|
||||
A vimwiki link can be constructed from more than one word. Just visually
|
||||
select the words to be linked and press Enter. Try it with 'Project
|
||||
Gutenberg'. The result should look something like:
|
||||
|
||||
= My knowledge base =
|
||||
* [[Tasks]] -- things to be done _yesterday_!!!
|
||||
* [[Project Gutenberg]] -- good books are power.
|
||||
* Scratchpad -- various temporary stuff.
|
||||
|
||||
|
||||
For the various options see :h vimwiki-options.
|
||||
|
||||
|
||||
Basic Markup
|
||||
==============================================================================
|
||||
see :h vimwiki-syntax
|
||||
|
||||
*bold* -- bold
|
||||
_italic_ -- italic
|
||||
|
||||
[[wiki link]] -- link with spaces
|
||||
[[wiki link|description]] -- link with description
|
||||
|
||||
Lists:
|
||||
* bullet list item 1
|
||||
- bullet list item 2
|
||||
- bullet list item 3
|
||||
* bullet list item 4
|
||||
* bullet list item 5
|
||||
* bullet list item 6
|
||||
* bullet list item 7
|
||||
- bullet list item 8
|
||||
- bullet list item 9
|
||||
|
||||
# numbered list item 1
|
||||
# numbered list item 2
|
||||
# numbered list item 3
|
||||
# numbered list item 4
|
||||
|
||||
= Header1 =
|
||||
== Header2 ==
|
||||
=== Header3 ===
|
||||
|
||||
|
||||
Key bindings
|
||||
==============================================================================
|
||||
see :h vimwiki-mappings
|
||||
|
||||
normal mode:
|
||||
<Leader>ww -- Open default wiki index file.
|
||||
<Leader>wt -- Open default wiki index file in a new tab.
|
||||
<Leader>ws -- Select and open wiki index file.
|
||||
<Leader>wd -- Delete wiki file you are in.
|
||||
<Leader>wr -- Rename wiki file you are in.
|
||||
<Enter> -- Folow/Create wiki link
|
||||
<Shift-Enter> -- Split and folow/create wiki link
|
||||
<Ctrl-Enter> -- Vertical split and folow/create wiki link
|
||||
<Backspace> -- Go back to parent(previous) wiki link
|
||||
<Tab> -- Find next wiki link
|
||||
<Shift-Tab> -- Find previous wiki link
|
||||
|
||||
|
||||
Commands
|
||||
==============================================================================
|
||||
:Vimwiki2HTML -- Convert current wiki link to HTML
|
||||
:VimwikiAll2HTML -- Convert all your wiki links to HTML
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
|
||||
" Vimwiki autoload plugin file
|
||||
" Desc: Link functions for markdown syntax
|
||||
" Author: Maxim Kim <habamax@gmail.com>
|
||||
" Home: http://code.google.com/p/vimwiki/
|
||||
|
||||
|
||||
function! s:normalize_link_syntax_n() " {{{
|
||||
let lnum = line('.')
|
||||
|
||||
" try WikiIncl
|
||||
let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiIncl)
|
||||
if !empty(lnk)
|
||||
" NO-OP !!
|
||||
if g:vimwiki_debug > 1
|
||||
echomsg "WikiIncl: ".lnk." Sub: ".lnk
|
||||
endif
|
||||
return
|
||||
endif
|
||||
|
||||
" try WikiLink0: replace with WikiLink1
|
||||
let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiLink0)
|
||||
if !empty(lnk)
|
||||
let sub = vimwiki#base#normalize_link_helper(lnk,
|
||||
\ g:vimwiki_rxWikiLinkMatchUrl, g:vimwiki_rxWikiLinkMatchDescr,
|
||||
\ g:vimwiki_WikiLink1Template2)
|
||||
call vimwiki#base#replacestr_at_cursor(g:vimwiki_rxWikiLink0, sub)
|
||||
if g:vimwiki_debug > 1
|
||||
echomsg "WikiLink: ".lnk." Sub: ".sub
|
||||
endif
|
||||
return
|
||||
endif
|
||||
|
||||
" try WikiLink1: replace with WikiLink0
|
||||
let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiLink1)
|
||||
if !empty(lnk)
|
||||
let sub = vimwiki#base#normalize_link_helper(lnk,
|
||||
\ g:vimwiki_rxWikiLinkMatchUrl, g:vimwiki_rxWikiLinkMatchDescr,
|
||||
\ g:vimwiki_WikiLinkTemplate2)
|
||||
call vimwiki#base#replacestr_at_cursor(g:vimwiki_rxWikiLink1, sub)
|
||||
if g:vimwiki_debug > 1
|
||||
echomsg "WikiLink: ".lnk." Sub: ".sub
|
||||
endif
|
||||
return
|
||||
endif
|
||||
|
||||
" try Weblink
|
||||
let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWeblink)
|
||||
if !empty(lnk)
|
||||
let sub = vimwiki#base#normalize_link_helper(lnk,
|
||||
\ g:vimwiki_rxWeblinkMatchUrl, g:vimwiki_rxWeblinkMatchDescr,
|
||||
\ g:vimwiki_Weblink1Template)
|
||||
call vimwiki#base#replacestr_at_cursor(g:vimwiki_rxWeblink, sub)
|
||||
if g:vimwiki_debug > 1
|
||||
echomsg "WebLink: ".lnk." Sub: ".sub
|
||||
endif
|
||||
return
|
||||
endif
|
||||
|
||||
" try Word (any characters except separators)
|
||||
" rxWord is less permissive than rxWikiLinkUrl which is used in
|
||||
" normalize_link_syntax_v
|
||||
let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWord)
|
||||
if !empty(lnk)
|
||||
let sub = vimwiki#base#normalize_link_helper(lnk,
|
||||
\ g:vimwiki_rxWord, '',
|
||||
\ g:vimwiki_WikiLinkTemplate1)
|
||||
call vimwiki#base#replacestr_at_cursor('\V'.lnk, sub)
|
||||
if g:vimwiki_debug > 1
|
||||
echomsg "Word: ".lnk." Sub: ".sub
|
||||
endif
|
||||
return
|
||||
endif
|
||||
|
||||
endfunction " }}}
|
||||
|
||||
function! s:normalize_link_syntax_v() " {{{
|
||||
let lnum = line('.')
|
||||
let sel_save = &selection
|
||||
let &selection = "old"
|
||||
let rv = @"
|
||||
let rt = getregtype('"')
|
||||
let done = 0
|
||||
|
||||
try
|
||||
norm! gvy
|
||||
let visual_selection = @"
|
||||
let visual_selection = substitute(g:vimwiki_WikiLinkTemplate1, '__LinkUrl__', '\='."'".visual_selection."'", '')
|
||||
|
||||
call setreg('"', visual_selection, 'v')
|
||||
|
||||
" paste result
|
||||
norm! `>pgvd
|
||||
|
||||
finally
|
||||
call setreg('"', rv, rt)
|
||||
let &selection = sel_save
|
||||
endtry
|
||||
|
||||
endfunction " }}}
|
||||
|
||||
" normalize_link
|
||||
function! vimwiki#markdown_base#normalize_link(is_visual_mode) "{{{
|
||||
if !a:is_visual_mode
|
||||
call s:normalize_link_syntax_n()
|
||||
elseif visualmode() ==# 'v' && line("'<") == line("'>")
|
||||
" action undefined for 'line-wise' or 'multi-line' visual mode selections
|
||||
call s:normalize_link_syntax_v()
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
@@ -10,8 +10,13 @@
|
||||
" Dependencies:
|
||||
" - SearchSpecial.vim autoload script (optional, for improved search messages).
|
||||
"
|
||||
" Version: 2.6.4
|
||||
" Version: 2.7.0
|
||||
" Changes:
|
||||
" 04-Jul-2012, Ingo Karkat
|
||||
" - ENH: Handle on-the-fly change of mark highlighting via mark#ReInit(), which
|
||||
" truncates / expands s:pattern and corrects the indices. Also, w:mwMatch List
|
||||
" size mismatches must be handled in s:MarkMatch().
|
||||
"
|
||||
" 23-Apr-2012, Ingo Karkat + fanhe
|
||||
" - Force case via \c / \C instead of temporarily unsetting 'smartcase'.
|
||||
" - Allow to override 'ignorecase' setting via g:mwIgnoreCase. Thanks to fanhe
|
||||
@@ -292,6 +297,18 @@ endfunction
|
||||
function! s:MarkMatch( indices, expr )
|
||||
if ! exists('w:mwMatch')
|
||||
let w:mwMatch = repeat([0], s:markNum)
|
||||
elseif len(w:mwMatch) != s:markNum
|
||||
" The number of marks has changed.
|
||||
if len(w:mwMatch) > s:markNum
|
||||
" Truncate the matches.
|
||||
for l:match in filter(w:mwMatch[s:markNum : ], 'v:val > 0')
|
||||
silent! call matchdelete(l:match)
|
||||
endfor
|
||||
let w:mwMatch = w:mwMatch[0 : (s:markNum - 1)]
|
||||
else
|
||||
" Expand the matches.
|
||||
let w:mwMatch += repeat([0], (s:markNum - len(w:mwMatch)))
|
||||
endif
|
||||
endif
|
||||
|
||||
for l:index in a:indices
|
||||
@@ -953,6 +970,26 @@ function! mark#Init()
|
||||
let s:lastSearch = -1
|
||||
let s:enabled = 1
|
||||
endfunction
|
||||
function! mark#ReInit( newMarkNum )
|
||||
if a:newMarkNum < s:markNum " There are less marks than before.
|
||||
" Clear the additional highlight groups.
|
||||
for i in range(a:newMarkNum + 1, s:markNum)
|
||||
execute 'highlight clear MarkWord' . (i + 1)
|
||||
endfor
|
||||
|
||||
" Truncate the mark patterns.
|
||||
let s:pattern = s:pattern[0 : (a:newMarkNum - 1)]
|
||||
|
||||
" Correct any indices.
|
||||
let s:cycle = min([s:cycle, (a:newMarkNum - 1)])
|
||||
let s:lastSearch = (s:lastSearch < a:newMarkNum ? s:lastSearch : -1)
|
||||
elseif a:newMarkNum > s:markNum " There are more marks than before.
|
||||
" Expand the mark patterns.
|
||||
let s:pattern += repeat([''], (a:newMarkNum - s:markNum))
|
||||
endif
|
||||
|
||||
let s:markNum = a:newMarkNum
|
||||
endfunction
|
||||
|
||||
call mark#Init()
|
||||
if exists('g:mwDoDeferredLoad') && g:mwDoDeferredLoad
|
||||
|
||||
136
bundle/mark/autoload/mark/palettes.vim
Normal file
136
bundle/mark/autoload/mark/palettes.vim
Normal file
@@ -0,0 +1,136 @@
|
||||
" mark/palettes.vim: Additional palettes for mark highlighting.
|
||||
"
|
||||
" DEPENDENCIES:
|
||||
"
|
||||
" Copyright: (C) 2012 Ingo Karkat
|
||||
" The VIM LICENSE applies to this script; see ':help copyright'.
|
||||
"
|
||||
" Maintainer: Ingo Karkat <ingo@karkat.de>
|
||||
" Contributors: rockybalboa4
|
||||
"
|
||||
" Version: 2.7.0
|
||||
" Changes:
|
||||
" 04-Jul-2012, Ingo Karkat
|
||||
" - Add "maximum" palette contributed by rockybalboa4 and move it and the
|
||||
" "extended" palette to a separate mark/palettes.vim autoload script.
|
||||
|
||||
function! mark#palettes#Extended()
|
||||
return [
|
||||
\ { 'ctermbg':'Blue', 'ctermfg':'Black', 'guibg':'#A1B7FF', 'guifg':'#001E80' },
|
||||
\ { 'ctermbg':'Magenta', 'ctermfg':'Black', 'guibg':'#FFA1C6', 'guifg':'#80005D' },
|
||||
\ { 'ctermbg':'Green', 'ctermfg':'Black', 'guibg':'#ACFFA1', 'guifg':'#0F8000' },
|
||||
\ { 'ctermbg':'Yellow', 'ctermfg':'Black', 'guibg':'#FFE8A1', 'guifg':'#806000' },
|
||||
\ { 'ctermbg':'DarkCyan', 'ctermfg':'Black', 'guibg':'#D2A1FF', 'guifg':'#420080' },
|
||||
\ { 'ctermbg':'Cyan', 'ctermfg':'Black', 'guibg':'#A1FEFF', 'guifg':'#007F80' },
|
||||
\ { 'ctermbg':'DarkBlue', 'ctermfg':'Black', 'guibg':'#A1DBFF', 'guifg':'#004E80' },
|
||||
\ { 'ctermbg':'DarkMagenta','ctermfg':'Black', 'guibg':'#A29CCF', 'guifg':'#120080' },
|
||||
\ { 'ctermbg':'DarkRed', 'ctermfg':'Black', 'guibg':'#F5A1FF', 'guifg':'#720080' },
|
||||
\ { 'ctermbg':'Brown', 'ctermfg':'Black', 'guibg':'#FFC4A1', 'guifg':'#803000' },
|
||||
\ { 'ctermbg':'DarkGreen', 'ctermfg':'Black', 'guibg':'#D0FFA1', 'guifg':'#3F8000' },
|
||||
\ { 'ctermbg':'Red', 'ctermfg':'Black', 'guibg':'#F3FFA1', 'guifg':'#6F8000' },
|
||||
\ { 'ctermbg':'White', 'ctermfg':'Gray', 'guibg':'#E3E3D2', 'guifg':'#999999' },
|
||||
\ { 'ctermbg':'LightGray', 'ctermfg':'White', 'guibg':'#D3D3C3', 'guifg':'#666666' },
|
||||
\ { 'ctermbg':'Gray', 'ctermfg':'Black', 'guibg':'#A3A396', 'guifg':'#222222' },
|
||||
\ { 'ctermbg':'Black', 'ctermfg':'White', 'guibg':'#53534C', 'guifg':'#DDDDDD' },
|
||||
\ { 'ctermbg':'Black', 'ctermfg':'Gray', 'guibg':'#131311', 'guifg':'#AAAAAA' },
|
||||
\ { 'ctermbg':'Blue', 'ctermfg':'White', 'guibg':'#0000FF', 'guifg':'#F0F0FF' },
|
||||
\ { 'ctermbg':'DarkRed', 'ctermfg':'White', 'guibg':'#FF0000', 'guifg':'#FFFFFF' },
|
||||
\]
|
||||
endfunction
|
||||
|
||||
function! mark#palettes#Maximum()
|
||||
let l:palette = [
|
||||
\ { 'ctermbg':'Cyan', 'ctermfg':'Black', 'guibg':'#8CCBEA', 'guifg':'Black' },
|
||||
\ { 'ctermbg':'Green', 'ctermfg':'Black', 'guibg':'#A4E57E', 'guifg':'Black' },
|
||||
\ { 'ctermbg':'Yellow', 'ctermfg':'Black', 'guibg':'#FFDB72', 'guifg':'Black' },
|
||||
\ { 'ctermbg':'Red', 'ctermfg':'Black', 'guibg':'#FF7272', 'guifg':'Black' },
|
||||
\ { 'ctermbg':'Magenta', 'ctermfg':'Black', 'guibg':'#FFB3FF', 'guifg':'Black' },
|
||||
\ { 'ctermbg':'Blue', 'ctermfg':'Black', 'guibg':'#9999FF', 'guifg':'Black' },
|
||||
\]
|
||||
if has('gui_running') || &t_Co >= 88
|
||||
let l:palette += [
|
||||
\ { 'ctermfg':'White', 'ctermbg':'17', 'guifg':'White', 'guibg':'#00005f' },
|
||||
\ { 'ctermfg':'White', 'ctermbg':'22', 'guifg':'White', 'guibg':'#005f00' },
|
||||
\ { 'ctermfg':'White', 'ctermbg':'23', 'guifg':'White', 'guibg':'#005f5f' },
|
||||
\ { 'ctermfg':'White', 'ctermbg':'27', 'guifg':'White', 'guibg':'#005fff' },
|
||||
\ { 'ctermfg':'White', 'ctermbg':'29', 'guifg':'White', 'guibg':'#00875f' },
|
||||
\ { 'ctermfg':'White', 'ctermbg':'34', 'guifg':'White', 'guibg':'#00af00' },
|
||||
\ { 'ctermfg':'Black', 'ctermbg':'37', 'guifg':'Black', 'guibg':'#00afaf' },
|
||||
\ { 'ctermfg':'Black', 'ctermbg':'43', 'guifg':'Black', 'guibg':'#00d7af' },
|
||||
\ { 'ctermfg':'Black', 'ctermbg':'47', 'guifg':'Black', 'guibg':'#00ff5f' },
|
||||
\ { 'ctermfg':'White', 'ctermbg':'52', 'guifg':'White', 'guibg':'#5f0000' },
|
||||
\ { 'ctermfg':'White', 'ctermbg':'53', 'guifg':'White', 'guibg':'#5f005f' },
|
||||
\ { 'ctermfg':'White', 'ctermbg':'58', 'guifg':'White', 'guibg':'#5f5f00' },
|
||||
\ { 'ctermfg':'White', 'ctermbg':'60', 'guifg':'White', 'guibg':'#5f5f87' },
|
||||
\ { 'ctermfg':'White', 'ctermbg':'64', 'guifg':'White', 'guibg':'#5f8700' },
|
||||
\ { 'ctermfg':'White', 'ctermbg':'65', 'guifg':'White', 'guibg':'#5f875f' },
|
||||
\ { 'ctermfg':'Black', 'ctermbg':'66', 'guifg':'Black', 'guibg':'#5f8787' },
|
||||
\ { 'ctermfg':'Black', 'ctermbg':'72', 'guifg':'Black', 'guibg':'#5faf87' },
|
||||
\ { 'ctermfg':'Black', 'ctermbg':'74', 'guifg':'Black', 'guibg':'#5fafd7' },
|
||||
\ { 'ctermfg':'Black', 'ctermbg':'78', 'guifg':'Black', 'guibg':'#5fd787' },
|
||||
\ { 'ctermfg':'Black', 'ctermbg':'79', 'guifg':'Black', 'guibg':'#5fd7af' },
|
||||
\ { 'ctermfg':'Black', 'ctermbg':'85', 'guifg':'Black', 'guibg':'#5fffaf' },
|
||||
\]
|
||||
endif
|
||||
if has('gui_running') || &t_Co >= 256
|
||||
let l:palette += [
|
||||
\ { 'ctermfg':'White', 'ctermbg':'90', 'guifg':'White', 'guibg':'#870087' },
|
||||
\ { 'ctermfg':'White', 'ctermbg':'95', 'guifg':'White', 'guibg':'#875f5f' },
|
||||
\ { 'ctermfg':'White', 'ctermbg':'96', 'guifg':'White', 'guibg':'#875f87' },
|
||||
\ { 'ctermfg':'Black', 'ctermbg':'101', 'guifg':'Black', 'guibg':'#87875f' },
|
||||
\ { 'ctermfg':'Black', 'ctermbg':'107', 'guifg':'Black', 'guibg':'#87af5f' },
|
||||
\ { 'ctermfg':'Black', 'ctermbg':'114', 'guifg':'Black', 'guibg':'#87d787' },
|
||||
\ { 'ctermfg':'Black', 'ctermbg':'117', 'guifg':'Black', 'guibg':'#87d7ff' },
|
||||
\ { 'ctermfg':'Black', 'ctermbg':'118', 'guifg':'Black', 'guibg':'#87ff00' },
|
||||
\ { 'ctermfg':'Black', 'ctermbg':'122', 'guifg':'Black', 'guibg':'#87ffd7' },
|
||||
\ { 'ctermfg':'White', 'ctermbg':'130', 'guifg':'White', 'guibg':'#af5f00' },
|
||||
\ { 'ctermfg':'White', 'ctermbg':'131', 'guifg':'White', 'guibg':'#af5f5f' },
|
||||
\ { 'ctermfg':'Black', 'ctermbg':'133', 'guifg':'Black', 'guibg':'#af5faf' },
|
||||
\ { 'ctermfg':'Black', 'ctermbg':'138', 'guifg':'Black', 'guibg':'#af8787' },
|
||||
\ { 'ctermfg':'Black', 'ctermbg':'142', 'guifg':'Black', 'guibg':'#afaf00' },
|
||||
\ { 'ctermfg':'Black', 'ctermbg':'152', 'guifg':'Black', 'guibg':'#afd7d7' },
|
||||
\ { 'ctermfg':'White', 'ctermbg':'160', 'guifg':'White', 'guibg':'#d70000' },
|
||||
\ { 'ctermfg':'Black', 'ctermbg':'166', 'guifg':'Black', 'guibg':'#d75f00' },
|
||||
\ { 'ctermfg':'Black', 'ctermbg':'169', 'guifg':'Black', 'guibg':'#d75faf' },
|
||||
\ { 'ctermfg':'Black', 'ctermbg':'174', 'guifg':'Black', 'guibg':'#d78787' },
|
||||
\ { 'ctermfg':'Black', 'ctermbg':'175', 'guifg':'Black', 'guibg':'#d787af' },
|
||||
\ { 'ctermfg':'Black', 'ctermbg':'186', 'guifg':'Black', 'guibg':'#d7d787' },
|
||||
\ { 'ctermfg':'Black', 'ctermbg':'190', 'guifg':'Black', 'guibg':'#d7ff00' },
|
||||
\ { 'ctermfg':'White', 'ctermbg':'198', 'guifg':'White', 'guibg':'#ff0087' },
|
||||
\ { 'ctermfg':'Black', 'ctermbg':'202', 'guifg':'Black', 'guibg':'#ff5f00' },
|
||||
\ { 'ctermfg':'Black', 'ctermbg':'204', 'guifg':'Black', 'guibg':'#ff5f87' },
|
||||
\ { 'ctermfg':'Black', 'ctermbg':'209', 'guifg':'Black', 'guibg':'#ff875f' },
|
||||
\ { 'ctermfg':'Black', 'ctermbg':'212', 'guifg':'Black', 'guibg':'#ff87d7' },
|
||||
\ { 'ctermfg':'Black', 'ctermbg':'215', 'guifg':'Black', 'guibg':'#ffaf5f' },
|
||||
\ { 'ctermfg':'Black', 'ctermbg':'220', 'guifg':'Black', 'guibg':'#ffd700' },
|
||||
\ { 'ctermfg':'Black', 'ctermbg':'224', 'guifg':'Black', 'guibg':'#ffd7d7' },
|
||||
\ { 'ctermfg':'Black', 'ctermbg':'228', 'guifg':'Black', 'guibg':'#ffff87' },
|
||||
\]
|
||||
endif
|
||||
if has('gui_running')
|
||||
let l:palette += [
|
||||
\ { 'guifg':'Black', 'guibg':'#b3dcff' },
|
||||
\ { 'guifg':'Black', 'guibg':'#99cbd6' },
|
||||
\ { 'guifg':'Black', 'guibg':'#7afff0' },
|
||||
\ { 'guifg':'Black', 'guibg':'#a6ffd2' },
|
||||
\ { 'guifg':'Black', 'guibg':'#a2de9e' },
|
||||
\ { 'guifg':'Black', 'guibg':'#bcff80' },
|
||||
\ { 'guifg':'Black', 'guibg':'#e7ff8c' },
|
||||
\ { 'guifg':'Black', 'guibg':'#f2e19d' },
|
||||
\ { 'guifg':'Black', 'guibg':'#ffcc73' },
|
||||
\ { 'guifg':'Black', 'guibg':'#f7af83' },
|
||||
\ { 'guifg':'Black', 'guibg':'#fcb9b1' },
|
||||
\ { 'guifg':'Black', 'guibg':'#ff8092' },
|
||||
\ { 'guifg':'Black', 'guibg':'#ff73bb' },
|
||||
\ { 'guifg':'Black', 'guibg':'#fc97ef' },
|
||||
\ { 'guifg':'Black', 'guibg':'#c8a3d9' },
|
||||
\ { 'guifg':'Black', 'guibg':'#ac98eb' },
|
||||
\ { 'guifg':'Black', 'guibg':'#6a6feb' },
|
||||
\ { 'guifg':'Black', 'guibg':'#8caeff' },
|
||||
\ { 'guifg':'Black', 'guibg':'#70b9fa' },
|
||||
\]
|
||||
endif
|
||||
return l:palette
|
||||
endfunction
|
||||
|
||||
" vim: ts=4 sts=0 sw=4 noet
|
||||
@@ -198,6 +198,21 @@ highlight group via [N].
|
||||
The last mark used for a search (via |<Leader>*|) is
|
||||
shown with a "/".
|
||||
|
||||
MARK HIGHLIGHTING PALETTES *mark-palette*
|
||||
|
||||
The plugin comes with three predefined palettes: original, extended, and
|
||||
maximum. You can dynamically toggle between them, e.g. when you need more
|
||||
marks or a different set of colors.
|
||||
*:MarkPalette*
|
||||
:MarkPalette {palette} Highlight existing and future marks with the colors
|
||||
defined in {palette}. If the new palette contains less
|
||||
mark groups than the current one, the additional marks
|
||||
are lost.
|
||||
You can use |:command-completion| for {palette}.
|
||||
|
||||
See |g:mwDefaultHighlightingPalette| for how to change the default palette,
|
||||
and |mark-palette-define| for how to add your own custom palettes.
|
||||
|
||||
==============================================================================
|
||||
INSTALLATION *mark-installation*
|
||||
|
||||
@@ -227,6 +242,9 @@ Higher numbers always take precedence and are displayed above lower ones.
|
||||
Especially if you use GVIM, you can switch to a richer palette of up to 18
|
||||
colors: >
|
||||
let g:mwDefaultHighlightingPalette = 'extended'
|
||||
Or, if you have both good eyes and display, you can try a palette that defines
|
||||
27, 58, or even 77 colors, depending on the number of available colors: >
|
||||
let g:mwDefaultHighlightingPalette = 'maximum'
|
||||
<
|
||||
If you like the additional colors, but don't need that many of them, restrict
|
||||
their number via: >
|
||||
@@ -246,7 +264,19 @@ use the plugin's infrastructure: >
|
||||
\ { 'ctermbg':'Cyan', 'ctermfg':'Black', 'guibg':'#8CCBEA', 'guifg':'Black' },
|
||||
\ ...
|
||||
\]
|
||||
<
|
||||
< *mark-palette-define*
|
||||
If you want to switch multiple palettes during runtime, you need to define
|
||||
them as proper palettes: >
|
||||
let g:mwPalettes['mypalette'] = [
|
||||
\ { 'ctermbg':'Cyan', 'ctermfg':'Black', 'guibg':'#8CCBEA', 'guifg':'Black' },
|
||||
\ ...
|
||||
\]
|
||||
let g:mwPalettes['other'] = [ ... ]
|
||||
let g:mwDefaultHighlightingPalette = 'mypalette'
|
||||
To add your palette to the existing ones, do this after the default palette
|
||||
has been defined, e.g. in .vim/after/plugin/mark.vim). Alternatively, you can
|
||||
also completely redefine all available palettes in .vimrc.
|
||||
|
||||
The search type highlighting (in the search message) can be changed via: >
|
||||
highlight link SearchSpecialSearchType MoreMsg
|
||||
<
|
||||
@@ -293,7 +323,7 @@ You can achieve the same with the Mark plugin through the following scriptlet: >
|
||||
function! s:GetVisualSelectionAsLiteralWhitespaceIndifferentPattern()
|
||||
return substitute(escape(mark#GetVisualSelection(), '\' . '^$.*[~'), '\_s\+', '\\_s\\+', 'g')
|
||||
endfunction
|
||||
vnoremap <silent> <Plug>MarkWhitespaceIndifferent <C-\><C-n>:call mark#DoMark(<SID>GetVisualSelectionAsLiteralWhitespaceIndifferentPattern())<CR>
|
||||
vnoremap <silent> <Plug>MarkWhitespaceIndifferent :<C-u>if !mark#DoMark(v:count, <SID>GetVisualSelectionAsLiteralWhitespaceIndifferentPattern())<Bar>execute "normal! \<lt>C-\>\<lt>C-n>\<lt>Esc>"<Bar>endif<CR>
|
||||
Using this, you can assign a new visual mode mapping <Leader>* >
|
||||
vmap <Leader>* <Plug>MarkWhitespaceIndifferent
|
||||
or override the default |v_<Leader>m| mapping, in case you always want this
|
||||
@@ -324,6 +354,15 @@ http://vim.wikia.com/wiki/Highlight_multiple_words:
|
||||
==============================================================================
|
||||
HISTORY *mark-history*
|
||||
|
||||
2.7.0 04-Jul-2012
|
||||
- ENH: Implement :MarkPalette command to switch mark highlighting on-the-fly
|
||||
during runtime.
|
||||
- Add "maximum" palette contributed by rockybalboa4.
|
||||
|
||||
2.6.5 24-Jun-2012
|
||||
- Don't define the default <Leader>m and <Leader>r mappings in select mode,
|
||||
just visual mode. Thanks to rockybalboa4 for pointing this out.
|
||||
|
||||
2.6.4 23-Apr-2012
|
||||
- Allow to override 'ignorecase' setting via g:mwIgnoreCase. Thanks to fanhe
|
||||
for the idea and sending a patch.
|
||||
@@ -339,6 +378,8 @@ HISTORY *mark-history*
|
||||
- ENH: When a [count] exceeding the number of available mark groups is given,
|
||||
a summary of marks is given and the user is asked to select a mark group.
|
||||
This allows to interactively choose a color via 99<Leader>m.
|
||||
If you use the |mark-whitespace-indifferent| mappings, *** PLEASE UPDATE THE
|
||||
vnoremap <Plug>MarkWhitespaceIndifferent DEFINITION ***
|
||||
- ENH: Include count of alternative patterns in :Marks list.
|
||||
- CHG: Use ">" for next mark and "/" for last search in :Marks.
|
||||
|
||||
|
||||
@@ -11,10 +11,26 @@
|
||||
"
|
||||
" Dependencies:
|
||||
" - Requires Vim 7.1 with "matchadd()", or Vim 7.2 or higher.
|
||||
" - mark.vim autoload script.
|
||||
" - mark.vim autoload script
|
||||
" - mark/palettes.vim autoload script for additional palettes
|
||||
"
|
||||
" Version: 2.6.3
|
||||
" Version: 2.7.0
|
||||
" Changes:
|
||||
" 04-Jul-2012, Ingo Karkat
|
||||
" - Introduce g:mwPalettes instead of hard-coding them in
|
||||
" s:DefaultHighlightings(), which got s:DefineHighlightings() extracted and
|
||||
" the rest renamed to s:GetPalette().
|
||||
" - Allow overriding of existing mark highlighting via a:isOverride argument to
|
||||
" s:DefineHighlightings().
|
||||
" - Add "maximum" palette contributed by rockybalboa4 and move it and the
|
||||
" "extended" palette to a separate mark/palettes.vim autoload script.
|
||||
" - ENH: Implement :MarkPalette command to switch mark highlighting on-the-fly
|
||||
" during runtime.
|
||||
"
|
||||
" 24-Jun-2012, Ingo Karkat
|
||||
" - Don't define the default <Leader>m and <Leader>r mappings in select mode,
|
||||
" just visual mode. Thanks to rockybalboa4 for pointing this out.
|
||||
"
|
||||
" 27-Mar-2012, Ingo Karkat
|
||||
" - ENH: Allow choosing of palette and limiting of default mark highlight groups
|
||||
" via g:mwDefaultHighlightingPalette and g:mwDefaultHighlightingNum.
|
||||
@@ -183,6 +199,7 @@ let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
"- configuration --------------------------------------------------------------
|
||||
|
||||
if ! exists('g:mwHistAdd')
|
||||
let g:mwHistAdd = '/@'
|
||||
endif
|
||||
@@ -201,60 +218,64 @@ endif
|
||||
if ! exists('g:mwDefaultHighlightingPalette')
|
||||
let g:mwDefaultHighlightingPalette = 'original'
|
||||
endif
|
||||
|
||||
|
||||
"- default highlightings ------------------------------------------------------
|
||||
function! s:DefaultHighlightings()
|
||||
let l:palette = []
|
||||
if type(g:mwDefaultHighlightingPalette) == type([])
|
||||
" There are custom color definitions, not a named built-in palette.
|
||||
let l:palette = g:mwDefaultHighlightingPalette
|
||||
elseif g:mwDefaultHighlightingPalette ==# 'original'
|
||||
let l:palette = [
|
||||
if ! exists('g:mwPalettes')
|
||||
let g:mwPalettes = {
|
||||
\ 'original': [
|
||||
\ { 'ctermbg':'Cyan', 'ctermfg':'Black', 'guibg':'#8CCBEA', 'guifg':'Black' },
|
||||
\ { 'ctermbg':'Green', 'ctermfg':'Black', 'guibg':'#A4E57E', 'guifg':'Black' },
|
||||
\ { 'ctermbg':'Yellow', 'ctermfg':'Black', 'guibg':'#FFDB72', 'guifg':'Black' },
|
||||
\ { 'ctermbg':'Red', 'ctermfg':'Black', 'guibg':'#FF7272', 'guifg':'Black' },
|
||||
\ { 'ctermbg':'Magenta', 'ctermfg':'Black', 'guibg':'#FFB3FF', 'guifg':'Black' },
|
||||
\ { 'ctermbg':'Blue', 'ctermfg':'Black', 'guibg':'#9999FF', 'guifg':'Black' },
|
||||
\]
|
||||
elseif g:mwDefaultHighlightingPalette ==# 'extended'
|
||||
let l:palette = [
|
||||
\ { 'ctermbg':'Blue', 'ctermfg':'Black', 'guibg':'#A1B7FF', 'guifg':'#001E80' },
|
||||
\ { 'ctermbg':'Magenta', 'ctermfg':'Black', 'guibg':'#FFA1C6', 'guifg':'#80005D' },
|
||||
\ { 'ctermbg':'Green', 'ctermfg':'Black', 'guibg':'#ACFFA1', 'guifg':'#0F8000' },
|
||||
\ { 'ctermbg':'Yellow', 'ctermfg':'Black', 'guibg':'#FFE8A1', 'guifg':'#806000' },
|
||||
\ { 'ctermbg':'DarkCyan', 'ctermfg':'Black', 'guibg':'#D2A1FF', 'guifg':'#420080' },
|
||||
\ { 'ctermbg':'Cyan', 'ctermfg':'Black', 'guibg':'#A1FEFF', 'guifg':'#007F80' },
|
||||
\ { 'ctermbg':'DarkBlue', 'ctermfg':'Black', 'guibg':'#A1DBFF', 'guifg':'#004E80' },
|
||||
\ { 'ctermbg':'DarkMagenta','ctermfg':'Black', 'guibg':'#A29CCF', 'guifg':'#120080' },
|
||||
\ { 'ctermbg':'DarkRed', 'ctermfg':'Black', 'guibg':'#F5A1FF', 'guifg':'#720080' },
|
||||
\ { 'ctermbg':'Brown', 'ctermfg':'Black', 'guibg':'#FFC4A1', 'guifg':'#803000' },
|
||||
\ { 'ctermbg':'DarkGreen', 'ctermfg':'Black', 'guibg':'#D0FFA1', 'guifg':'#3F8000' },
|
||||
\ { 'ctermbg':'Red', 'ctermfg':'Black', 'guibg':'#F3FFA1', 'guifg':'#6F8000' },
|
||||
\ { 'ctermbg':'White', 'ctermfg':'Gray', 'guibg':'#E3E3D2', 'guifg':'#999999' },
|
||||
\ { 'ctermbg':'LightGray', 'ctermfg':'White', 'guibg':'#D3D3C3', 'guifg':'#666666' },
|
||||
\ { 'ctermbg':'Gray', 'ctermfg':'Black', 'guibg':'#A3A396', 'guifg':'#222222' },
|
||||
\ { 'ctermbg':'Black', 'ctermfg':'White', 'guibg':'#53534C', 'guifg':'#DDDDDD' },
|
||||
\ { 'ctermbg':'Black', 'ctermfg':'Gray', 'guibg':'#131311', 'guifg':'#AAAAAA' },
|
||||
\ { 'ctermbg':'Blue', 'ctermfg':'White', 'guibg':'#0000FF', 'guifg':'#F0F0FF' },
|
||||
\ { 'ctermbg':'DarkRed', 'ctermfg':'White', 'guibg':'#FF0000', 'guifg':'#FFFFFF' },
|
||||
\]
|
||||
elseif ! empty(g:mwDefaultHighlightingPalette)
|
||||
let v:warningmsg = 'Mark: Unknown value for g:mwDefaultHighlightingPalette: ' . g:mwDefaultHighlightingPalette
|
||||
echohl WarningMsg
|
||||
echomsg v:warningmsg
|
||||
echohl None
|
||||
\],
|
||||
\ 'extended': function('mark#palettes#Extended'),
|
||||
\ 'maximum': function('mark#palettes#Maximum')
|
||||
\}
|
||||
endif
|
||||
|
||||
return
|
||||
|
||||
|
||||
"- default highlightings ------------------------------------------------------
|
||||
|
||||
function! s:GetPalette()
|
||||
let l:palette = []
|
||||
if type(g:mwDefaultHighlightingPalette) == type([])
|
||||
" There are custom color definitions, not a named built-in palette.
|
||||
return g:mwDefaultHighlightingPalette
|
||||
endif
|
||||
if ! has_key(g:mwPalettes, g:mwDefaultHighlightingPalette)
|
||||
if ! empty(g:mwDefaultHighlightingPalette)
|
||||
let v:warningmsg = 'Mark: Unknown value for g:mwDefaultHighlightingPalette: ' . g:mwDefaultHighlightingPalette
|
||||
echohl WarningMsg
|
||||
echomsg v:warningmsg
|
||||
echohl None
|
||||
endif
|
||||
|
||||
return []
|
||||
endif
|
||||
|
||||
for i in range(1, (g:mwDefaultHighlightingNum == -1 ? len(l:palette) : g:mwDefaultHighlightingNum))
|
||||
execute 'highlight def MarkWord' . i join(map(items(l:palette[i - 1]), 'join(v:val, "=")'))
|
||||
endfor
|
||||
if type(g:mwPalettes[g:mwDefaultHighlightingPalette]) == type([])
|
||||
return g:mwPalettes[g:mwDefaultHighlightingPalette]
|
||||
elseif type(g:mwPalettes[g:mwDefaultHighlightingPalette]) == type(function('tr'))
|
||||
return call(g:mwPalettes[g:mwDefaultHighlightingPalette], [])
|
||||
else
|
||||
let v:errmsg = printf('Mark: Invalid value type for g:mwPalettes[%s]', g:mwDefaultHighlightingPalette)
|
||||
echohl ErrorMsg
|
||||
echomsg v:errmsg
|
||||
echohl None
|
||||
return []
|
||||
endif
|
||||
endfunction
|
||||
call s:DefaultHighlightings()
|
||||
autocmd ColorScheme * call <SID>DefaultHighlightings()
|
||||
function! s:DefineHighlightings( palette, isOverride )
|
||||
let l:command = (a:isOverride ? 'highlight' : 'highlight def')
|
||||
let l:highlightingNum = (g:mwDefaultHighlightingNum == -1 ? len(a:palette) : g:mwDefaultHighlightingNum)
|
||||
for i in range(1, l:highlightingNum)
|
||||
execute l:command 'MarkWord' . i join(map(items(a:palette[i - 1]), 'join(v:val, "=")'))
|
||||
endfor
|
||||
return l:highlightingNum
|
||||
endfunction
|
||||
call s:DefineHighlightings(s:GetPalette(), 0)
|
||||
autocmd ColorScheme * call <SID>DefineHighlightings(<SID>GetPalette(), 0)
|
||||
|
||||
" Default highlighting for the special search type.
|
||||
" You can override this by defining / linking the 'SearchSpecialSearchType'
|
||||
@@ -262,7 +283,9 @@ autocmd ColorScheme * call <SID>DefaultHighlightings()
|
||||
highlight def link SearchSpecialSearchType MoreMsg
|
||||
|
||||
|
||||
|
||||
"- mappings -------------------------------------------------------------------
|
||||
|
||||
nnoremap <silent> <Plug>MarkSet :<C-u>if !mark#MarkCurrentWord(v:count)<Bar>execute "normal! \<lt>C-\>\<lt>C-n>\<lt>Esc>"<Bar>endif<CR>
|
||||
vnoremap <silent> <Plug>MarkSet :<C-u>if !mark#DoMark(v:count, mark#GetVisualSelectionAsLiteralPattern())<Bar>execute "normal! \<lt>C-\>\<lt>C-n>\<lt>Esc>"<Bar>endif<CR>
|
||||
nnoremap <silent> <Plug>MarkRegex :<C-u>call mark#MarkRegex('')<CR>
|
||||
@@ -285,13 +308,13 @@ if !hasmapto('<Plug>MarkSet', 'n')
|
||||
nmap <unique> <silent> <Leader>m <Plug>MarkSet
|
||||
endif
|
||||
if !hasmapto('<Plug>MarkSet', 'v')
|
||||
vmap <unique> <silent> <Leader>m <Plug>MarkSet
|
||||
xmap <unique> <silent> <Leader>m <Plug>MarkSet
|
||||
endif
|
||||
if !hasmapto('<Plug>MarkRegex', 'n')
|
||||
nmap <unique> <silent> <Leader>r <Plug>MarkRegex
|
||||
endif
|
||||
if !hasmapto('<Plug>MarkRegex', 'v')
|
||||
vmap <unique> <silent> <Leader>r <Plug>MarkRegex
|
||||
xmap <unique> <silent> <Leader>r <Plug>MarkRegex
|
||||
endif
|
||||
if !hasmapto('<Plug>MarkClear', 'n')
|
||||
nmap <unique> <silent> <Leader>n <Plug>MarkClear
|
||||
@@ -319,16 +342,40 @@ if !hasmapto('<Plug>MarkSearchPrev', 'n')
|
||||
endif
|
||||
|
||||
|
||||
|
||||
"- commands -------------------------------------------------------------------
|
||||
|
||||
command! -count -nargs=? Mark if !mark#DoMark(<count>, <f-args>) | echoerr printf('Only %d mark highlight groups', mark#GetGroupNum()) | endif
|
||||
command! -bar MarkClear call mark#ClearAll()
|
||||
command! -bar Marks call mark#List()
|
||||
|
||||
command! -bar MarkLoad call mark#LoadCommand(1)
|
||||
command! -bar MarkSave call mark#SaveCommand()
|
||||
function! s:SetPalette( paletteName )
|
||||
if type(g:mwDefaultHighlightingPalette) == type([])
|
||||
" Convert the directly defined list to a palette named "default".
|
||||
let g:mwPalettes['default'] = g:mwDefaultHighlightingPalette
|
||||
unlet! g:mwDefaultHighlightingPalette " Avoid E706.
|
||||
endif
|
||||
let g:mwDefaultHighlightingPalette = a:paletteName
|
||||
|
||||
let l:palette = s:GetPalette()
|
||||
if empty(l:palette)
|
||||
return
|
||||
endif
|
||||
|
||||
call mark#ReInit(s:DefineHighlightings(l:palette, 1))
|
||||
call mark#UpdateScope()
|
||||
endfunction
|
||||
function! s:MarkPaletteComplete( ArgLead, CmdLine, CursorPos )
|
||||
return sort(filter(keys(g:mwPalettes), 'v:val =~ ''\V\^'' . escape(a:ArgLead, "\\")'))
|
||||
endfunction
|
||||
command! -bar -nargs=1 -complete=customlist,<SID>MarkPaletteComplete MarkPalette call <SID>SetPalette(<q-args>)
|
||||
|
||||
|
||||
|
||||
"- marks persistence ----------------------------------------------------------
|
||||
|
||||
if g:mwAutoLoadMarks
|
||||
" As the viminfo is only processed after sourcing of the runtime files, the
|
||||
" persistent global variables are not yet available here. Defer this until Vim
|
||||
|
||||
@@ -8,19 +8,16 @@ if exists("g:loaded_vimwiki_auto") || &cp
|
||||
endif
|
||||
let g:loaded_vimwiki_auto = 1
|
||||
|
||||
" -------------------------------------------------------------------------
|
||||
" Load syntax-specific Wiki functionality
|
||||
execute 'runtime! autoload/vimwiki/'.VimwikiGet('syntax').'_base.vim'
|
||||
" -------------------------------------------------------------------------
|
||||
|
||||
" MISC helper functions {{{
|
||||
|
||||
" s:normalize_path
|
||||
function! s:normalize_path(path) "{{{
|
||||
let g:VimwikiLog.normalize_path += 1 "XXX
|
||||
" resolve doesn't work quite right with symlinks ended with / or \
|
||||
return resolve(expand(substitute(a:path, '[/\\]\+$', '', ''))).'/'
|
||||
endfunction "}}}
|
||||
|
||||
" s:path_html
|
||||
function! s:path_html(idx) "{{{
|
||||
let path_html = VimwikiGet('path_html', a:idx)
|
||||
if !empty(path_html)
|
||||
@@ -32,8 +29,41 @@ function! s:path_html(idx) "{{{
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki#base#get_known_extensions() " {{{
|
||||
" Getting all extensions that different wikis could have
|
||||
let extensions = {}
|
||||
for wiki in g:vimwiki_list
|
||||
if has_key(wiki, 'ext')
|
||||
let extensions[wiki.ext] = 1
|
||||
else
|
||||
let extensions['.wiki'] = 1
|
||||
endif
|
||||
endfor
|
||||
" append map g:vimwiki_ext2syntax
|
||||
for ext in keys(g:vimwiki_ext2syntax)
|
||||
let extensions[ext] = 1
|
||||
endfor
|
||||
return keys(extensions)
|
||||
endfunction " }}}
|
||||
|
||||
function! vimwiki#base#get_known_syntaxes() " {{{
|
||||
" Getting all syntaxes that different wikis could have
|
||||
let syntaxes = {}
|
||||
let syntaxes['default'] = 1
|
||||
for wiki in g:vimwiki_list
|
||||
if has_key(wiki, 'syntax')
|
||||
let syntaxes[wiki.syntax] = 1
|
||||
endif
|
||||
endfor
|
||||
" append map g:vimwiki_ext2syntax
|
||||
for syn in values(g:vimwiki_ext2syntax)
|
||||
let syntaxes[syn] = 1
|
||||
endfor
|
||||
return keys(syntaxes)
|
||||
endfunction " }}}
|
||||
" }}}
|
||||
|
||||
" vimwiki#base#apply_wiki_options
|
||||
function! vimwiki#base#apply_wiki_options(options) " {{{ Update the current
|
||||
" wiki using the options dictionary
|
||||
for kk in keys(a:options)
|
||||
@@ -43,6 +73,7 @@ function! vimwiki#base#apply_wiki_options(options) " {{{ Update the current
|
||||
call vimwiki#base#setup_buffer_state(g:vimwiki_current_idx)
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#read_wiki_options
|
||||
function! vimwiki#base#read_wiki_options(check) " {{{ Attempt to read wiki
|
||||
" options from the current page's directory, or its ancesters. If a file
|
||||
" named vimwiki.vimrc is found, which declares a wiki-options dictionary
|
||||
@@ -55,7 +86,7 @@ function! vimwiki#base#read_wiki_options(check) " {{{ Attempt to read wiki
|
||||
" overwrite !! (not to mention all the other globals ...)
|
||||
let l:vimwiki_list = deepcopy(g:vimwiki_list, 1)
|
||||
"
|
||||
if a:check
|
||||
if a:check > 1
|
||||
call vimwiki#base#print_wiki_state()
|
||||
echo " \n"
|
||||
endif
|
||||
@@ -67,7 +98,7 @@ function! vimwiki#base#read_wiki_options(check) " {{{ Attempt to read wiki
|
||||
" other names are possible, but most vimrc files will cause grief!
|
||||
for nm in ['vimwiki.vimrc']
|
||||
" TODO: use an alternate strategy, instead of source, to read options
|
||||
if done |
|
||||
if done
|
||||
continue
|
||||
endif
|
||||
"
|
||||
@@ -78,7 +109,7 @@ function! vimwiki#base#read_wiki_options(check) " {{{ Attempt to read wiki
|
||||
"
|
||||
echo "\nFound file : ".local_wiki_options_filename
|
||||
let query = "Vimwiki: Check for options in this file [Y]es/[n]o? "
|
||||
if a:check && (tolower(input(query)) !~ "y")
|
||||
if a:check > 0 && (tolower(input(query)) !~ "y")
|
||||
continue
|
||||
endif
|
||||
"
|
||||
@@ -90,7 +121,7 @@ function! vimwiki#base#read_wiki_options(check) " {{{ Attempt to read wiki
|
||||
continue
|
||||
endif
|
||||
"
|
||||
if a:check
|
||||
if a:check > 0
|
||||
echo "\n\nFound wiki options\n g:local_wiki = ".string(g:local_wiki)
|
||||
let query = "Vimwiki: Apply these options [Y]es/[n]o? "
|
||||
if tolower(input(query)) !~ "y"
|
||||
@@ -114,7 +145,7 @@ function! vimwiki#base#read_wiki_options(check) " {{{ Attempt to read wiki
|
||||
let g:vimwiki_list = deepcopy(l:vimwiki_list, 1)
|
||||
"
|
||||
endif
|
||||
if a:check
|
||||
if a:check > 1
|
||||
echo " \n "
|
||||
if done
|
||||
call vimwiki#base#print_wiki_state()
|
||||
@@ -124,6 +155,7 @@ function! vimwiki#base#read_wiki_options(check) " {{{ Attempt to read wiki
|
||||
endif
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#validate_wiki_options
|
||||
function! vimwiki#base#validate_wiki_options(idx) " {{{ Validate wiki options
|
||||
" Only call this function *before* opening a wiki page.
|
||||
"
|
||||
@@ -144,6 +176,7 @@ function! vimwiki#base#validate_wiki_options(idx) " {{{ Validate wiki options
|
||||
"" call vimwiki#base#cache_buffer_state()
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#setup_buffer_state
|
||||
function! vimwiki#base#setup_buffer_state(idx) " {{{ Init page-specific variables
|
||||
" Only call this function *after* opening a wiki page.
|
||||
if a:idx < 0
|
||||
@@ -162,6 +195,7 @@ function! vimwiki#base#setup_buffer_state(idx) " {{{ Init page-specific variable
|
||||
call vimwiki#base#cache_buffer_state()
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#cache_buffer_state
|
||||
function! vimwiki#base#cache_buffer_state() "{{{
|
||||
if !exists('g:vimwiki_current_idx') && g:vimwiki_debug
|
||||
echo "[Vimwiki Internal Error]: Missing global state variable: 'g:vimwiki_current_idx'"
|
||||
@@ -169,6 +203,7 @@ function! vimwiki#base#cache_buffer_state() "{{{
|
||||
let b:vimwiki_idx = g:vimwiki_current_idx
|
||||
endfunction "}}}
|
||||
|
||||
" vimwiki#base#recall_buffer_state
|
||||
function! vimwiki#base#recall_buffer_state() "{{{
|
||||
if !exists('b:vimwiki_idx')
|
||||
if g:vimwiki_debug
|
||||
@@ -181,6 +216,7 @@ function! vimwiki#base#recall_buffer_state() "{{{
|
||||
endif
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#print_wiki_state
|
||||
function! vimwiki#base#print_wiki_state() "{{{ print wiki options
|
||||
" and buffer state variables
|
||||
let g_width = 18
|
||||
@@ -198,6 +234,7 @@ function! vimwiki#base#print_wiki_state() "{{{ print wiki options
|
||||
endfor
|
||||
endfunction "}}}
|
||||
|
||||
" vimwiki#base#mkdir
|
||||
" If the optional argument 'confirm' == 1 is provided,
|
||||
" vimwiki#base#mkdir will ask before creating a directory
|
||||
function! vimwiki#base#mkdir(path, ...) "{{{
|
||||
@@ -213,9 +250,9 @@ function! vimwiki#base#mkdir(path, ...) "{{{
|
||||
call mkdir(path, "p")
|
||||
endif
|
||||
return 1
|
||||
endfunction
|
||||
" }}}
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#file_pattern
|
||||
function! vimwiki#base#file_pattern(files) "{{{ Get search regex from glob()
|
||||
" string. Aim to support *all* special characters, forcing the user to choose
|
||||
" names that are compatible with any external restrictions that they
|
||||
@@ -231,18 +268,18 @@ function! vimwiki#base#file_pattern(files) "{{{ Get search regex from glob()
|
||||
"
|
||||
let pattern = vimwiki#base#branched_pattern(a:files,"\n")
|
||||
return '\V'.pattern.'\m'
|
||||
endfunction
|
||||
"}}}
|
||||
endfunction "}}}
|
||||
|
||||
" vimwiki#base#branched_pattern
|
||||
function! vimwiki#base#branched_pattern(string,separator) "{{{ get search regex
|
||||
" from a string-list; separators assumed at start and end as well
|
||||
let pattern = substitute(a:string, a:separator, '\\|','g')
|
||||
let pattern = substitute(pattern, '\%^\\|', '\\%(','')
|
||||
let pattern = substitute(pattern,'\\|\%$', '\\)','')
|
||||
return pattern
|
||||
endfunction
|
||||
"}}}
|
||||
endfunction "}}}
|
||||
|
||||
" vimwiki#base#subdir
|
||||
"FIXME TODO slow and faulty
|
||||
function! vimwiki#base#subdir(path, filename)"{{{
|
||||
let g:VimwikiLog.subdir += 1 "XXX
|
||||
@@ -264,17 +301,18 @@ function! vimwiki#base#subdir(path, filename)"{{{
|
||||
return res
|
||||
endfunction "}}}
|
||||
|
||||
" vimwiki#base#current_subdir
|
||||
function! vimwiki#base#current_subdir(idx)"{{{
|
||||
return vimwiki#base#subdir(VimwikiGet('path', a:idx), expand('%:p'))
|
||||
endfunction"}}}
|
||||
|
||||
" vimwiki#base#invsubdir
|
||||
function! vimwiki#base#invsubdir(subdir) " {{{
|
||||
return substitute(a:subdir, '[^/\.]\+/', '../', 'g')
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#resolve_scheme
|
||||
function! vimwiki#base#resolve_scheme(lnk, as_html) " {{{ Resolve scheme
|
||||
" - Only return non-negative index when valid wiki link found
|
||||
"
|
||||
" if link is schemeless add wikiN: scheme
|
||||
let lnk = a:lnk
|
||||
let is_schemeless = lnk !~ g:vimwiki_rxSchemeUrl
|
||||
@@ -392,6 +430,7 @@ function! vimwiki#base#resolve_scheme(lnk, as_html) " {{{ Resolve scheme
|
||||
return [idx, scheme, path, subdir, lnk, ext, url]
|
||||
endfunction "}}}
|
||||
|
||||
" vimwiki#base#system_open_link
|
||||
function! vimwiki#base#system_open_link(url) "{{{
|
||||
" handlers
|
||||
function! s:win32_handler(url)
|
||||
@@ -420,6 +459,7 @@ function! vimwiki#base#system_open_link(url) "{{{
|
||||
echomsg 'Default Vimwiki link handler was unable to open the HTML file!'
|
||||
endfunction "}}}
|
||||
|
||||
" vimwiki#base#open_link
|
||||
function! vimwiki#base#open_link(cmd, link, ...) "{{{
|
||||
let [idx, scheme, path, subdir, lnk, ext, url] =
|
||||
\ vimwiki#base#resolve_scheme(a:link, 0)
|
||||
@@ -467,9 +507,9 @@ function! vimwiki#base#open_link(cmd, link, ...) "{{{
|
||||
call vimwiki#base#setup_buffer_state(idx)
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
" }}}
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#generate_links
|
||||
function! vimwiki#base#generate_links() "{{{only get links from the current dir
|
||||
" change to the directory of the current file
|
||||
let orig_pwd = getcwd()
|
||||
@@ -497,6 +537,7 @@ function! vimwiki#base#generate_links() "{{{only get links from the current dir
|
||||
endfor
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#goto
|
||||
function! vimwiki#base#goto(key) "{{{
|
||||
call vimwiki#base#edit_file(':e',
|
||||
\ VimwikiGet('path').
|
||||
@@ -504,6 +545,7 @@ function! vimwiki#base#goto(key) "{{{
|
||||
\ VimwikiGet('ext'))
|
||||
endfunction "}}}
|
||||
|
||||
" vimwiki#base#backlinks
|
||||
function! vimwiki#base#backlinks() "{{{
|
||||
execute 'lvimgrep "\%(^\|[[:blank:][:punct:]]\)'.
|
||||
\ expand("%:t:r").
|
||||
@@ -511,11 +553,12 @@ function! vimwiki#base#backlinks() "{{{
|
||||
\ escape(VimwikiGet('path').'**/*'.VimwikiGet('ext'), ' ')
|
||||
endfunction "}}}
|
||||
|
||||
" vimwiki#base#get_links
|
||||
function! vimwiki#base#get_links(pat) "{{{ return string-list for files
|
||||
" in the current wiki matching the pattern "pat"
|
||||
" search all wiki files (or directories) in wiki 'path' and its subdirs.
|
||||
|
||||
let time1 = reltime() " start the clock XXX
|
||||
let time1 = reltime() " start the clock
|
||||
|
||||
" XXX:
|
||||
" if maxhi = 1 and <leader>w<leader>w before loading any vimwiki file
|
||||
@@ -586,6 +629,7 @@ function! vimwiki#base#get_links(pat) "{{{ return string-list for files
|
||||
return globlinks
|
||||
endfunction "}}}
|
||||
|
||||
" vimwiki#base#edit_file
|
||||
function! vimwiki#base#edit_file(command, filename, ...) "{{{
|
||||
" XXX: Should we allow * in filenames!?
|
||||
" Maxim: It is allowed, escaping here is for vim to be able to open files
|
||||
@@ -610,17 +654,17 @@ function! vimwiki#base#edit_file(command, filename, ...) "{{{
|
||||
if a:0 && a:2 && len(a:1) > 0
|
||||
let b:vimwiki_prev_link = a:1
|
||||
endif
|
||||
endfunction
|
||||
" }}}
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#search_word
|
||||
function! vimwiki#base#search_word(wikiRx, cmd) "{{{
|
||||
let match_line = search(a:wikiRx, 's'.a:cmd)
|
||||
if match_line == 0
|
||||
echomsg 'vimwiki: Wiki link not found.'
|
||||
endif
|
||||
endfunction
|
||||
" }}}
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#matchstr_at_cursor
|
||||
" Returns part of the line that matches wikiRX at cursor
|
||||
function! vimwiki#base#matchstr_at_cursor(wikiRX) "{{{
|
||||
let col = col('.') - 1
|
||||
@@ -644,6 +688,7 @@ function! vimwiki#base#matchstr_at_cursor(wikiRX) "{{{
|
||||
endif
|
||||
endf "}}}
|
||||
|
||||
" vimwiki#base#replacestr_at_cursor
|
||||
function! vimwiki#base#replacestr_at_cursor(wikiRX, sub) "{{{
|
||||
let col = col('.') - 1
|
||||
let line = getline('.')
|
||||
@@ -666,6 +711,7 @@ function! vimwiki#base#replacestr_at_cursor(wikiRX, sub) "{{{
|
||||
endif
|
||||
endf "}}}
|
||||
|
||||
" s:print_wiki_list
|
||||
function! s:print_wiki_list() "{{{
|
||||
let idx = 0
|
||||
while idx < len(g:vimwiki_list)
|
||||
@@ -680,9 +726,9 @@ function! s:print_wiki_list() "{{{
|
||||
let idx += 1
|
||||
endwhile
|
||||
echohl None
|
||||
endfunction
|
||||
" }}}
|
||||
endfunction " }}}
|
||||
|
||||
" s:update_wiki_link
|
||||
function! s:update_wiki_link(fname, old, new) " {{{
|
||||
echo "Updating links in ".a:fname
|
||||
let has_updates = 0
|
||||
@@ -700,9 +746,9 @@ function! s:update_wiki_link(fname, old, new) " {{{
|
||||
call writefile(dest, a:fname)
|
||||
call delete(a:fname.'#vimwiki_upd#')
|
||||
endif
|
||||
endfunction
|
||||
" }}}
|
||||
endfunction " }}}
|
||||
|
||||
" s:update_wiki_links_dir
|
||||
function! s:update_wiki_links_dir(dir, old_fname, new_fname) " {{{
|
||||
let old_fname = substitute(a:old_fname, '[/\\]', '[/\\\\]', 'g')
|
||||
let new_fname = a:new_fname
|
||||
@@ -718,9 +764,9 @@ function! s:update_wiki_links_dir(dir, old_fname, new_fname) " {{{
|
||||
for fname in files
|
||||
call s:update_wiki_link(fname, old_fname_r, new_fname_r)
|
||||
endfor
|
||||
endfunction
|
||||
" }}}
|
||||
endfunction " }}}
|
||||
|
||||
" s:tail_name
|
||||
function! s:tail_name(fname) "{{{
|
||||
let result = substitute(a:fname, ":", "__colon__", "g")
|
||||
let result = fnamemodify(result, ":t:r")
|
||||
@@ -728,6 +774,7 @@ function! s:tail_name(fname) "{{{
|
||||
return result
|
||||
endfunction "}}}
|
||||
|
||||
" s:update_wiki_links
|
||||
function! s:update_wiki_links(old_fname, new_fname) " {{{
|
||||
let old_fname = s:tail_name(a:old_fname)
|
||||
let new_fname = s:tail_name(a:new_fname)
|
||||
@@ -760,6 +807,7 @@ function! s:update_wiki_links(old_fname, new_fname) " {{{
|
||||
endwhile
|
||||
endfunction " }}}
|
||||
|
||||
" s:get_wiki_buffers
|
||||
function! s:get_wiki_buffers() "{{{
|
||||
let blist = []
|
||||
let bcount = 1
|
||||
@@ -776,6 +824,7 @@ function! s:get_wiki_buffers() "{{{
|
||||
return blist
|
||||
endfunction " }}}
|
||||
|
||||
" s:open_wiki_buffer
|
||||
function! s:open_wiki_buffer(item) "{{{
|
||||
call vimwiki#base#edit_file(':e', a:item[0])
|
||||
if !empty(a:item[1])
|
||||
@@ -783,6 +832,7 @@ function! s:open_wiki_buffer(item) "{{{
|
||||
endif
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#nested_syntax
|
||||
function! vimwiki#base#nested_syntax(filetype, start, end, textSnipHl) abort "{{{
|
||||
" From http://vim.wikia.com/wiki/VimTip857
|
||||
let ft=toupper(a:filetype)
|
||||
@@ -799,8 +849,9 @@ function! vimwiki#base#nested_syntax(filetype, start, end, textSnipHl) abort "{{
|
||||
" let b:skip_set_iskeyword = 1
|
||||
let is_keyword = &iskeyword
|
||||
|
||||
execute 'syntax include @'.group.' syntax/'.a:filetype.'.vim'
|
||||
try
|
||||
" keep going even if syntax file is not found
|
||||
execute 'syntax include @'.group.' syntax/'.a:filetype.'.vim'
|
||||
execute 'syntax include @'.group.' after/syntax/'.a:filetype.'.vim'
|
||||
catch
|
||||
endtry
|
||||
@@ -833,28 +884,28 @@ endfunction "}}}
|
||||
" }}}
|
||||
|
||||
" WIKI link following functions {{{
|
||||
" vimwiki#base#find_next_link
|
||||
function! vimwiki#base#find_next_link() "{{{
|
||||
call vimwiki#base#search_word(g:vimwiki_rxAnyLink, '')
|
||||
endfunction
|
||||
" }}}
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#find_prev_link
|
||||
function! vimwiki#base#find_prev_link() "{{{
|
||||
call vimwiki#base#search_word(g:vimwiki_rxAnyLink, 'b')
|
||||
endfunction
|
||||
" }}}
|
||||
endfunction " }}}
|
||||
|
||||
" follow_link
|
||||
" vimwiki#base#follow_link
|
||||
function! vimwiki#base#follow_link(split, ...) "{{{ Parse link at cursor and pass
|
||||
" to VimwikiLinkHandler, or failing that, the default open_link handler
|
||||
if exists('*vimwiki#base_'.VimwikiGet('syntax').'#follow_link')
|
||||
if exists('*vimwiki#'.VimwikiGet('syntax').'_base#follow_link')
|
||||
" Syntax-specific links
|
||||
" XXX: @Stuart: do we still need it?
|
||||
" XXX: @Maxim: most likely! I am still working on a seemless way to
|
||||
" integrate regexp's without complicating syntax/vimwiki.vim
|
||||
if a:0
|
||||
call vimwiki#base_{VimwikiGet('syntax')}#follow_link(a:split, a:1)
|
||||
call vimwiki#{VimwikiGet('syntax')}_base#follow_link(a:split, a:1)
|
||||
else
|
||||
call vimwiki#base_{VimwikiGet('syntax')}#follow_link(a:split)
|
||||
call vimwiki#{VimwikiGet('syntax')}_base#follow_link(a:split)
|
||||
endif
|
||||
else
|
||||
if a:split == "split"
|
||||
@@ -897,6 +948,7 @@ function! vimwiki#base#follow_link(split, ...) "{{{ Parse link at cursor and pas
|
||||
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#go_back_link
|
||||
function! vimwiki#base#go_back_link() "{{{
|
||||
if exists("b:vimwiki_prev_link")
|
||||
" go back to saved wiki link
|
||||
@@ -906,6 +958,7 @@ function! vimwiki#base#go_back_link() "{{{
|
||||
endif
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#goto_index
|
||||
function! vimwiki#base#goto_index(wnum, ...) "{{{
|
||||
if a:wnum > len(g:vimwiki_list)
|
||||
echom "vimwiki: Wiki ".a:wnum." is not registered in g:vimwiki_list!"
|
||||
@@ -937,6 +990,7 @@ function! vimwiki#base#goto_index(wnum, ...) "{{{
|
||||
call vimwiki#base#setup_buffer_state(idx)
|
||||
endfunction "}}}
|
||||
|
||||
" vimwiki#base#delete_link
|
||||
function! vimwiki#base#delete_link() "{{{
|
||||
"" file system funcs
|
||||
"" Delete wiki link you are in from filesystem
|
||||
@@ -961,6 +1015,7 @@ function! vimwiki#base#delete_link() "{{{
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
" vimwiki#base#rename_link
|
||||
function! vimwiki#base#rename_link() "{{{
|
||||
"" Rename wiki link, update all links to renamed WikiWord
|
||||
let subdir = VimwikiGet('subdir')
|
||||
@@ -1061,6 +1116,7 @@ function! vimwiki#base#rename_link() "{{{
|
||||
let &more = setting_more
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#ui_select
|
||||
function! vimwiki#base#ui_select() "{{{
|
||||
call s:print_wiki_list()
|
||||
let idx = input("Select Wiki (specify number): ")
|
||||
@@ -1068,12 +1124,12 @@ function! vimwiki#base#ui_select() "{{{
|
||||
return
|
||||
endif
|
||||
call vimwiki#base#goto_index(idx)
|
||||
endfunction
|
||||
"}}}
|
||||
endfunction "}}}
|
||||
" }}}
|
||||
|
||||
" TEXT OBJECTS functions {{{
|
||||
|
||||
" vimwiki#base#TO_header
|
||||
function! vimwiki#base#TO_header(inner, visual) "{{{
|
||||
if !search('^\(=\+\).\+\1\s*$', 'bcW')
|
||||
return
|
||||
@@ -1114,9 +1170,9 @@ function! vimwiki#base#TO_header(inner, visual) "{{{
|
||||
let lnum = prevnonblank(line('.') - 1)
|
||||
call cursor(lnum, 0)
|
||||
endif
|
||||
endfunction
|
||||
"}}}
|
||||
endfunction "}}}
|
||||
|
||||
" vimwiki#base#TO_table_cell
|
||||
function! vimwiki#base#TO_table_cell(inner, visual) "{{{
|
||||
if col('.') == col('$')-1
|
||||
return
|
||||
@@ -1181,6 +1237,7 @@ function! vimwiki#base#TO_table_cell(inner, visual) "{{{
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
" vimwiki#base#TO_table_col
|
||||
function! vimwiki#base#TO_table_col(inner, visual) "{{{
|
||||
let t_rows = vimwiki#tbl#get_rows(line('.'))
|
||||
if empty(t_rows)
|
||||
@@ -1297,6 +1354,7 @@ endfunction "}}}
|
||||
" }}}
|
||||
|
||||
" HEADER functions {{{
|
||||
" vimwiki#base#AddHeaderLevel
|
||||
function! vimwiki#base#AddHeaderLevel() "{{{
|
||||
let lnum = line('.')
|
||||
let line = getline(lnum)
|
||||
@@ -1322,9 +1380,9 @@ function! vimwiki#base#AddHeaderLevel() "{{{
|
||||
endif
|
||||
call setline(lnum, line)
|
||||
endif
|
||||
endfunction
|
||||
"}}}
|
||||
endfunction "}}}
|
||||
|
||||
" vimwiki#base#RemoveHeaderLevel
|
||||
function! vimwiki#base#RemoveHeaderLevel() "{{{
|
||||
let lnum = line('.')
|
||||
let line = getline(lnum)
|
||||
@@ -1355,12 +1413,12 @@ function! vimwiki#base#RemoveHeaderLevel() "{{{
|
||||
|
||||
call setline(lnum, line)
|
||||
endif
|
||||
endfunction
|
||||
" }}}
|
||||
endfunction " }}}
|
||||
"}}}
|
||||
|
||||
" LINK functions {{{
|
||||
" Construct a regular expression matching from template (with special
|
||||
" vimwiki#base#apply_template
|
||||
" Construct a regular expression matching from template (with special
|
||||
" characters properly escaped), by substituting rxUrl for __LinkUrl__, rxDesc
|
||||
" for __LinkDescription__, and rxStyle for __LinkStyle__. The three
|
||||
" arguments rxUrl, rxDesc, and rxStyle are copied verbatim, without any
|
||||
@@ -1378,9 +1436,9 @@ function! vimwiki#base#apply_template(template, rxUrl, rxDesc, rxStyle) "{{{
|
||||
let lnk = substitute(lnk, '__LinkStyle__', '\='."'".a:rxStyle."'", '')
|
||||
endif
|
||||
return lnk
|
||||
endfunction
|
||||
" }}}
|
||||
endfunction " }}}
|
||||
|
||||
" s:clean_url
|
||||
function! s:clean_url(url) " {{{
|
||||
let url = split(a:url, '/\|=\|-\|&\|?\|\.')
|
||||
let url = filter(url, 'v:val != ""')
|
||||
@@ -1396,6 +1454,7 @@ function! s:clean_url(url) " {{{
|
||||
return join(url, " ")
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#normalize_link_helper
|
||||
function! vimwiki#base#normalize_link_helper(str, rxUrl, rxDesc, template) " {{{
|
||||
let str = a:str
|
||||
let url = matchstr(str, a:rxUrl)
|
||||
@@ -1409,6 +1468,7 @@ function! vimwiki#base#normalize_link_helper(str, rxUrl, rxDesc, template) " {{{
|
||||
return lnk
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#normalize_imagelink_helper
|
||||
function! vimwiki#base#normalize_imagelink_helper(str, rxUrl, rxDesc, rxStyle, template) "{{{
|
||||
let lnk = vimwiki#base#normalize_link_helper(a:str, a:rxUrl, a:rxDesc, a:template)
|
||||
let style = matchstr(str, a:rxStyle)
|
||||
@@ -1416,6 +1476,7 @@ function! vimwiki#base#normalize_imagelink_helper(str, rxUrl, rxDesc, rxStyle, t
|
||||
return lnk
|
||||
endfunction " }}}
|
||||
|
||||
" s:normalize_link_syntax_n
|
||||
function! s:normalize_link_syntax_n() " {{{
|
||||
let lnum = line('.')
|
||||
|
||||
@@ -1459,6 +1520,7 @@ function! s:normalize_link_syntax_n() " {{{
|
||||
|
||||
endfunction " }}}
|
||||
|
||||
" s:normalize_link_syntax_v
|
||||
function! s:normalize_link_syntax_v() " {{{
|
||||
let lnum = line('.')
|
||||
let sel_save = &selection
|
||||
@@ -1484,7 +1546,7 @@ function! s:normalize_link_syntax_v() " {{{
|
||||
|
||||
endfunction " }}}
|
||||
|
||||
" normalize_link
|
||||
" vimwiki#base#normalize_link
|
||||
function! vimwiki#base#normalize_link(is_visual_mode) "{{{
|
||||
if exists('*vimwiki#'.VimwikiGet('syntax').'_base#normalize_link')
|
||||
" Syntax-specific links
|
||||
@@ -1500,3 +1562,12 @@ function! vimwiki#base#normalize_link(is_visual_mode) "{{{
|
||||
endfunction "}}}
|
||||
|
||||
" }}}
|
||||
|
||||
" -------------------------------------------------------------------------
|
||||
" Load syntax-specific Wiki functionality
|
||||
for syn in vimwiki#base#get_known_syntaxes()
|
||||
execute 'runtime! autoload/vimwiki/'.syn.'_base.vim'
|
||||
endfor
|
||||
" -------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -237,12 +237,12 @@ function! vimwiki#diary#make_note(wnum, ...) "{{{
|
||||
call vimwiki#base#validate_wiki_options(idx)
|
||||
call vimwiki#base#mkdir(VimwikiGet('path', idx).VimwikiGet('diary_rel_path', idx))
|
||||
|
||||
if a:0
|
||||
if a:0 && a:1 == 1
|
||||
let cmd = 'tabedit'
|
||||
else
|
||||
let cmd = 'edit'
|
||||
endif
|
||||
if len(a:0)>1
|
||||
if a:0>1
|
||||
let link = 'diary:'.a:2
|
||||
else
|
||||
let link = 'diary:'.s:diary_date_link(idx)
|
||||
@@ -422,6 +422,13 @@ function! s:tag_wikiincl(value) "{{{
|
||||
if g:vimwiki_debug > 1
|
||||
echom '{{idx='.idx.', scheme='.scheme.', path='.path.', subdir='.subdir.', lnk='.lnk.', ext='.ext.'}}'
|
||||
endif
|
||||
|
||||
" Issue 343: Image transclusions: schemeless links have .html appended.
|
||||
" If link is schemeless pass it as it is
|
||||
if scheme == ''
|
||||
let url = lnk
|
||||
endif
|
||||
|
||||
let url = escape(url, '#')
|
||||
let line = vimwiki#html#linkify_image(url, descr, verbatim_str)
|
||||
return line
|
||||
302
bundle/vimwiki/autoload/vimwiki/markdown_base.vim
Normal file
302
bundle/vimwiki/autoload/vimwiki/markdown_base.vim
Normal file
@@ -0,0 +1,302 @@
|
||||
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79
|
||||
" Vimwiki autoload plugin file
|
||||
" Desc: Link functions for markdown syntax
|
||||
" Author: Stuart Andrews <stu.andrews@gmail.com> (.. i.e. don't blame Maxim!)
|
||||
" Home: http://code.google.com/p/vimwiki/
|
||||
|
||||
|
||||
" MISC helper functions {{{
|
||||
|
||||
" vimwiki#markdown_base#reset_mkd_refs
|
||||
function! vimwiki#markdown_base#reset_mkd_refs() "{{{
|
||||
call VimwikiClear('markdown_refs')
|
||||
endfunction "}}}
|
||||
|
||||
" vimwiki#markdown_base#scan_reflinks
|
||||
function! vimwiki#markdown_base#scan_reflinks() " {{{
|
||||
let mkd_refs = {}
|
||||
" construct list of references using vimgrep
|
||||
try
|
||||
execute 'vimgrep #'.g:vimwiki_rxMkdRef.'#j %'
|
||||
catch /^Vim\%((\a\+)\)\=:E480/ " No Match
|
||||
"Ignore it, and move on to the next file
|
||||
endtry
|
||||
"
|
||||
for d in getqflist()
|
||||
let matchline = join(getline(d.lnum, min([d.lnum+1, line('$')])), ' ')
|
||||
let descr = matchstr(matchline, g:vimwiki_rxMkdRefMatchDescr)
|
||||
let url = matchstr(matchline, g:vimwiki_rxMkdRefMatchUrl)
|
||||
if descr != '' && url != ''
|
||||
let mkd_refs[descr] = url
|
||||
endif
|
||||
endfor
|
||||
call VimwikiSet('markdown_refs', mkd_refs)
|
||||
return mkd_refs
|
||||
endfunction "}}}
|
||||
|
||||
|
||||
" vimwiki#markdown_base#get_reflinks
|
||||
function! vimwiki#markdown_base#get_reflinks() " {{{
|
||||
let done = 1
|
||||
try
|
||||
let mkd_refs = VimwikiGet('markdown_refs')
|
||||
catch
|
||||
" work-around hack
|
||||
let done = 0
|
||||
" ... the following command does not work inside catch block !?
|
||||
" > let mkd_refs = vimwiki#markdown_base#scan_reflinks()
|
||||
endtry
|
||||
if !done
|
||||
let mkd_refs = vimwiki#markdown_base#scan_reflinks()
|
||||
endif
|
||||
return mkd_refs
|
||||
endfunction "}}}
|
||||
|
||||
" vimwiki#markdown_base#open_reflink
|
||||
" try markdown reference links
|
||||
function! vimwiki#markdown_base#open_reflink(link) " {{{
|
||||
" echom "vimwiki#markdown_base#open_reflink"
|
||||
let link = a:link
|
||||
let mkd_refs = vimwiki#markdown_base#get_reflinks()
|
||||
if has_key(mkd_refs, link)
|
||||
let url = mkd_refs[link]
|
||||
call vimwiki#base#system_open_link(url)
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
endif
|
||||
endfunction " }}}
|
||||
|
||||
" s:normalize_path
|
||||
" s:path_html
|
||||
" vimwiki#base#apply_wiki_options
|
||||
" vimwiki#base#read_wiki_options
|
||||
" vimwiki#base#validate_wiki_options
|
||||
" vimwiki#base#setup_buffer_state
|
||||
" vimwiki#base#cache_buffer_state
|
||||
" vimwiki#base#recall_buffer_state
|
||||
" vimwiki#base#print_wiki_state
|
||||
" vimwiki#base#mkdir
|
||||
" vimwiki#base#file_pattern
|
||||
" vimwiki#base#branched_pattern
|
||||
" vimwiki#base#subdir
|
||||
" vimwiki#base#current_subdir
|
||||
" vimwiki#base#invsubdir
|
||||
" vimwiki#base#resolve_scheme
|
||||
" vimwiki#base#system_open_link
|
||||
" vimwiki#base#open_link
|
||||
" vimwiki#base#generate_links
|
||||
" vimwiki#base#goto
|
||||
" vimwiki#base#backlinks
|
||||
" vimwiki#base#get_links
|
||||
" vimwiki#base#edit_file
|
||||
" vimwiki#base#search_word
|
||||
" vimwiki#base#matchstr_at_cursor
|
||||
" vimwiki#base#replacestr_at_cursor
|
||||
" s:print_wiki_list
|
||||
" s:update_wiki_link
|
||||
" s:update_wiki_links_dir
|
||||
" s:tail_name
|
||||
" s:update_wiki_links
|
||||
" s:get_wiki_buffers
|
||||
" s:open_wiki_buffer
|
||||
" vimwiki#base#nested_syntax
|
||||
" }}}
|
||||
|
||||
" WIKI link following functions {{{
|
||||
" vimwiki#base#find_next_link
|
||||
" vimwiki#base#find_prev_link
|
||||
|
||||
" vimwiki#base#follow_link
|
||||
function! vimwiki#markdown_base#follow_link(split, ...) "{{{ Parse link at cursor and pass
|
||||
" to VimwikiLinkHandler, or failing that, the default open_link handler
|
||||
" echom "markdown_base#follow_link"
|
||||
|
||||
if 0
|
||||
" Syntax-specific links
|
||||
" XXX: @Stuart: do we still need it?
|
||||
" XXX: @Maxim: most likely! I am still working on a seemless way to
|
||||
" integrate regexp's without complicating syntax/vimwiki.vim
|
||||
else
|
||||
if a:split == "split"
|
||||
let cmd = ":split "
|
||||
elseif a:split == "vsplit"
|
||||
let cmd = ":vsplit "
|
||||
elseif a:split == "tabnew"
|
||||
let cmd = ":tabnew "
|
||||
else
|
||||
let cmd = ":e "
|
||||
endif
|
||||
|
||||
" try WikiLink
|
||||
let lnk = matchstr(vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiLink),
|
||||
\ g:vimwiki_rxWikiLinkMatchUrl)
|
||||
" try WikiIncl
|
||||
if lnk == ""
|
||||
let lnk = matchstr(vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiIncl),
|
||||
\ g:vimwiki_rxWikiInclMatchUrl)
|
||||
endif
|
||||
" try Weblink
|
||||
if lnk == ""
|
||||
let lnk = matchstr(vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWeblink),
|
||||
\ g:vimwiki_rxWeblinkMatchUrl)
|
||||
endif
|
||||
|
||||
if lnk != ""
|
||||
if !VimwikiLinkHandler(lnk)
|
||||
if !vimwiki#markdown_base#open_reflink(lnk)
|
||||
call vimwiki#base#open_link(cmd, lnk)
|
||||
endif
|
||||
endif
|
||||
return
|
||||
endif
|
||||
|
||||
if a:0 > 0
|
||||
execute "normal! ".a:1
|
||||
else
|
||||
call vimwiki#base#normalize_link(0)
|
||||
endif
|
||||
endif
|
||||
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#go_back_link
|
||||
" vimwiki#base#goto_index
|
||||
" vimwiki#base#delete_link
|
||||
" vimwiki#base#rename_link
|
||||
" vimwiki#base#ui_select
|
||||
|
||||
" TEXT OBJECTS functions {{{
|
||||
" vimwiki#base#TO_header
|
||||
" vimwiki#base#TO_table_cell
|
||||
" vimwiki#base#TO_table_col
|
||||
" }}}
|
||||
|
||||
" HEADER functions {{{
|
||||
" vimwiki#base#AddHeaderLevel
|
||||
" vimwiki#base#RemoveHeaderLevel
|
||||
"}}}
|
||||
|
||||
" LINK functions {{{
|
||||
" vimwiki#base#apply_template
|
||||
|
||||
" s:clean_url
|
||||
" vimwiki#base#normalize_link_helper
|
||||
" vimwiki#base#normalize_imagelink_helper
|
||||
|
||||
" s:normalize_link_syntax_n
|
||||
function! s:normalize_link_syntax_n() " {{{
|
||||
let lnum = line('.')
|
||||
|
||||
" try WikiIncl
|
||||
let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiIncl)
|
||||
if !empty(lnk)
|
||||
" NO-OP !!
|
||||
if g:vimwiki_debug > 1
|
||||
echomsg "WikiIncl: ".lnk." Sub: ".lnk
|
||||
endif
|
||||
return
|
||||
endif
|
||||
|
||||
" try WikiLink0: replace with WikiLink1
|
||||
let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiLink0)
|
||||
if !empty(lnk)
|
||||
let sub = vimwiki#base#normalize_link_helper(lnk,
|
||||
\ g:vimwiki_rxWikiLinkMatchUrl, g:vimwiki_rxWikiLinkMatchDescr,
|
||||
\ g:vimwiki_WikiLink1Template2)
|
||||
call vimwiki#base#replacestr_at_cursor(g:vimwiki_rxWikiLink0, sub)
|
||||
if g:vimwiki_debug > 1
|
||||
echomsg "WikiLink: ".lnk." Sub: ".sub
|
||||
endif
|
||||
return
|
||||
endif
|
||||
|
||||
" try WikiLink1: replace with WikiLink0
|
||||
let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiLink1)
|
||||
if !empty(lnk)
|
||||
let sub = vimwiki#base#normalize_link_helper(lnk,
|
||||
\ g:vimwiki_rxWikiLinkMatchUrl, g:vimwiki_rxWikiLinkMatchDescr,
|
||||
\ g:vimwiki_WikiLinkTemplate2)
|
||||
call vimwiki#base#replacestr_at_cursor(g:vimwiki_rxWikiLink1, sub)
|
||||
if g:vimwiki_debug > 1
|
||||
echomsg "WikiLink: ".lnk." Sub: ".sub
|
||||
endif
|
||||
return
|
||||
endif
|
||||
|
||||
" try Weblink
|
||||
let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWeblink)
|
||||
if !empty(lnk)
|
||||
let sub = vimwiki#base#normalize_link_helper(lnk,
|
||||
\ g:vimwiki_rxWeblinkMatchUrl, g:vimwiki_rxWeblinkMatchDescr,
|
||||
\ g:vimwiki_Weblink1Template)
|
||||
call vimwiki#base#replacestr_at_cursor(g:vimwiki_rxWeblink, sub)
|
||||
if g:vimwiki_debug > 1
|
||||
echomsg "WebLink: ".lnk." Sub: ".sub
|
||||
endif
|
||||
return
|
||||
endif
|
||||
|
||||
" try Word (any characters except separators)
|
||||
" rxWord is less permissive than rxWikiLinkUrl which is used in
|
||||
" normalize_link_syntax_v
|
||||
let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWord)
|
||||
if !empty(lnk)
|
||||
let sub = vimwiki#base#normalize_link_helper(lnk,
|
||||
\ g:vimwiki_rxWord, '',
|
||||
\ g:vimwiki_WikiLinkTemplate1)
|
||||
call vimwiki#base#replacestr_at_cursor('\V'.lnk, sub)
|
||||
if g:vimwiki_debug > 1
|
||||
echomsg "Word: ".lnk." Sub: ".sub
|
||||
endif
|
||||
return
|
||||
endif
|
||||
|
||||
endfunction " }}}
|
||||
|
||||
" s:normalize_link_syntax_v
|
||||
function! s:normalize_link_syntax_v() " {{{
|
||||
let lnum = line('.')
|
||||
let sel_save = &selection
|
||||
let &selection = "old"
|
||||
let rv = @"
|
||||
let rt = getregtype('"')
|
||||
let done = 0
|
||||
|
||||
try
|
||||
norm! gvy
|
||||
let visual_selection = @"
|
||||
let visual_selection = substitute(g:vimwiki_WikiLinkTemplate1, '__LinkUrl__', '\='."'".visual_selection."'", '')
|
||||
|
||||
call setreg('"', visual_selection, 'v')
|
||||
|
||||
" paste result
|
||||
norm! `>pgvd
|
||||
|
||||
finally
|
||||
call setreg('"', rv, rt)
|
||||
let &selection = sel_save
|
||||
endtry
|
||||
|
||||
endfunction " }}}
|
||||
|
||||
" vimwiki#base#normalize_link
|
||||
function! vimwiki#markdown_base#normalize_link(is_visual_mode) "{{{
|
||||
if 0
|
||||
" Syntax-specific links
|
||||
else
|
||||
if !a:is_visual_mode
|
||||
call s:normalize_link_syntax_n()
|
||||
elseif visualmode() ==# 'v' && line("'<") == line("'>")
|
||||
" action undefined for 'line-wise' or 'multi-line' visual mode selections
|
||||
call s:normalize_link_syntax_v()
|
||||
endif
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
" }}}
|
||||
|
||||
" -------------------------------------------------------------------------
|
||||
" Load syntax-specific Wiki functionality
|
||||
" -------------------------------------------------------------------------
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|___| |___| |_| |_||__| |__||___| |___| |_||___| ~
|
||||
|
||||
|
||||
Version: 2.0 'stu'
|
||||
Version: 2.0.1 'stu'
|
||||
|
||||
==============================================================================
|
||||
CONTENTS *vimwiki-contents*
|
||||
@@ -610,10 +610,10 @@ Markdown Links~
|
||||
These links are only available for Markdown syntax. See
|
||||
http://daringfireball.net/projects/markdown/syntax#link.
|
||||
|
||||
Inline links: >
|
||||
Inline link: >
|
||||
[Looks like this](URL)
|
||||
|
||||
Image links: >
|
||||
Image link: >
|
||||

|
||||
|
||||
The URL can be anything recognized by vimwiki as a raw URL.
|
||||
@@ -623,10 +623,26 @@ Reference-style links: >
|
||||
a) [Link Name][Id]
|
||||
b) [Id][], using the "implicit link name" shortcut
|
||||
|
||||
Vimwiki treats reference style links just like default "Wikilinks". In the
|
||||
current implementation: the Id field must be a valid wiki page name,
|
||||
reference style links must always include *two* consecutive pairs of
|
||||
[-brackets, and entries can not use "[" or "]".
|
||||
Reference style links must always include *two* consecutive pairs of
|
||||
[-brackets, and field entries can not use "[" or "]".
|
||||
|
||||
|
||||
NOTE: (in Vimwiki's current implementation) Reference-style links are a hybrid
|
||||
of Vimwiki's default "Wikilink" and the tradition reference-style link.
|
||||
|
||||
If the Id is defined elsewhere in the source, as per the Markdown standard: >
|
||||
[Id]: URL
|
||||
|
||||
then the URL is opened with the system default handler. Otherwise, Vimwiki
|
||||
treats the reference-sytle link as a Wikilink, interpreting the Id field as a
|
||||
wiki page name.
|
||||
|
||||
Highlighting of existing links when |vimwiki-option-maxhi| is activated
|
||||
identifies links whose Id field is not defined, either as a reference-link or
|
||||
as a wiki page.
|
||||
|
||||
To scan the page for new or changed definitions for reference-links, simply
|
||||
re-open the page ":e<CR>".
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
@@ -1193,21 +1209,21 @@ Use the :VimwikiTable command to create a default table with 5 columns and 2
|
||||
rows: >
|
||||
|
||||
| | | | | |
|
||||
|---+---+---+---+---|
|
||||
|---|---|---|---|---|
|
||||
| | | | | |
|
||||
<
|
||||
|
||||
Tables are auto-formattable. Let's add some text into first cell: >
|
||||
|
||||
| First Name | | | | |
|
||||
|---+---+---+---+---|
|
||||
|---|---|---|---|---|
|
||||
| | | | | |
|
||||
<
|
||||
|
||||
Whenever you press <TAB>, <CR> or leave Insert mode, the table is formatted: >
|
||||
|
||||
| First Name | | | | |
|
||||
|------------+---+---+---+---|
|
||||
|------------|---|---|---|---|
|
||||
| | | | | |
|
||||
<
|
||||
|
||||
@@ -1215,7 +1231,7 @@ You can easily create nice-looking text tables, just press <TAB> and enter new
|
||||
values: >
|
||||
|
||||
| First Name | Last Name | Age | City | e-mail |
|
||||
|------------+------------+-----+----------+----------------------|
|
||||
|------------|------------|-----|----------|----------------------|
|
||||
| Vladislav | Pokrishkin | 31 | Moscow | vlad_pok@smail.com |
|
||||
| James | Esfandiary | 27 | Istanbul | esfandiary@tmail.com |
|
||||
<
|
||||
@@ -2170,10 +2186,16 @@ Vim plugins: http://www.vim.org/scripts/script.php?script_id=2226
|
||||
==============================================================================
|
||||
14. Changelog *vimwiki-changelog*
|
||||
|
||||
2.0.1 'stu'~
|
||||
|
||||
* Follow (i.e. open target of) markdown reference-style links.
|
||||
* Bug fixes.
|
||||
|
||||
|
||||
2.0 'stu'~
|
||||
|
||||
This release is partly incompatible with previous.
|
||||
|
||||
*
|
||||
Summary ~
|
||||
|
||||
* Quick page-link creation.
|
||||
@@ -195,7 +195,10 @@ function! s:setup_buffer_enter() "{{{
|
||||
" Settings foldmethod, foldexpr and foldtext are local to window. Thus in a
|
||||
" new tab with the same buffer folding is reset to vim defaults. So we
|
||||
" insist vimwiki folding here.
|
||||
if g:vimwiki_folding == 1 && &fdm != 'expr'
|
||||
if g:vimwiki_folding == 2 && &fdm != 'expr'
|
||||
" User-defined fold-expression, and fold-text
|
||||
endif
|
||||
if g:vimwiki_folding == 1
|
||||
setlocal fdm=expr
|
||||
setlocal foldexpr=VimwikiFoldLevel(v:lnum)
|
||||
setlocal foldtext=VimwikiFoldText()
|
||||
@@ -295,6 +298,19 @@ function! VimwikiSet(option, value, ...) "{{{
|
||||
let b:vimwiki_list[a:option] = a:value
|
||||
endif
|
||||
|
||||
endfunction "}}}
|
||||
|
||||
" Clear option for current wiki or if third parameter exists for
|
||||
" wiki with a given index.
|
||||
" Currently, only works if option was previously saved in the buffer local
|
||||
" dictionary, that acts as a cache.
|
||||
function! VimwikiClear(option, ...) "{{{
|
||||
let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1
|
||||
|
||||
if exists('b:vimwiki_list') && has_key(b:vimwiki_list, a:option)
|
||||
call remove(b:vimwiki_list, a:option)
|
||||
endif
|
||||
|
||||
endfunction "}}}
|
||||
" }}}
|
||||
|
||||
@@ -415,19 +431,7 @@ call s:default('rxSchemeUrlMatchUrl', rxSchemes.':\zs.*\ze')
|
||||
"}}}
|
||||
|
||||
" AUTOCOMMANDS for all known wiki extensions {{{
|
||||
" Getting all extensions that different wikis could have
|
||||
let extensions = {}
|
||||
for wiki in g:vimwiki_list
|
||||
if has_key(wiki, 'ext')
|
||||
let extensions[wiki.ext] = 1
|
||||
else
|
||||
let extensions['.wiki'] = 1
|
||||
endif
|
||||
endfor
|
||||
" append map g:vimwiki_ext2syntax
|
||||
for ext in keys(g:vimwiki_ext2syntax)
|
||||
let extensions[ext] = 1
|
||||
endfor
|
||||
let extensions = vimwiki#base#get_known_extensions()
|
||||
|
||||
augroup filetypedetect
|
||||
" clear FlexWiki's stuff
|
||||
@@ -436,7 +440,7 @@ augroup end
|
||||
|
||||
augroup vimwiki
|
||||
autocmd!
|
||||
for ext in keys(extensions)
|
||||
for ext in extensions
|
||||
exe 'autocmd BufEnter *'.ext.' call s:setup_buffer_reenter()'
|
||||
exe 'autocmd BufWinEnter *'.ext.' call s:setup_buffer_enter()'
|
||||
exe 'autocmd BufLeave,BufHidden *'.ext.' call s:setup_buffer_leave()'
|
||||
@@ -300,8 +300,10 @@ endfor
|
||||
" }}}
|
||||
|
||||
" concealed chars " {{{
|
||||
let cchar = ''
|
||||
if exists("+conceallevel")
|
||||
syntax conceal on
|
||||
let cchar = ' cchar=~ '
|
||||
endif
|
||||
|
||||
syntax spell toplevel
|
||||
@@ -329,9 +331,9 @@ execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiInclPrefix1.'/'.options
|
||||
execute 'syn match VimwikiLinkChar /'.g:vimwiki_rxWikiInclSuffix1.'/'.options
|
||||
|
||||
" A shortener for long URLs: LinkRest (a middle part of the URL) is concealed
|
||||
execute 'syn match VimwikiLinkRest contained `\%(///\=[^/ \t]\+/\)\zs\S\{'
|
||||
execute 'syn match VimwikiLinkRest `\%(///\=[^/ \t]\+/\)\zs\S\{'
|
||||
\.g:vimwiki_url_mingain.',}\ze\%([/#?]\w\|\S\{'
|
||||
\.g:vimwiki_url_maxsave.'}\)` cchar=~ '.options
|
||||
\.g:vimwiki_url_maxsave.'}\)`'.cchar.options
|
||||
|
||||
execute 'syn match VimwikiEqInChar contained /'.g:vimwiki_char_eqin.'/'
|
||||
execute 'syn match VimwikiBoldChar contained /'.g:vimwiki_char_bold.'/'
|
||||
@@ -586,12 +588,13 @@ if !empty(nested)
|
||||
\ '^\s*'.g:vimwiki_rxPreStart.'\%(.*[[:blank:][:punct:]]\)\?'.
|
||||
\ hl_syntax.'\%([[:blank:][:punct:]].*\)\?',
|
||||
\ '^\s*'.g:vimwiki_rxPreEnd, 'VimwikiPre')
|
||||
" call vimwiki#base#nested_syntax(vim_syntax,
|
||||
" \ '^\s*{{\$\%(.*[[:blank:][:punct:]]\)\?'.
|
||||
" \ hl_syntax.'\%([[:blank:][:punct:]].*\)\?',
|
||||
" \ '^\s*}}\$', 'VimwikiMath')
|
||||
endfor
|
||||
endif
|
||||
" LaTeX
|
||||
call vimwiki#base#nested_syntax('tex',
|
||||
\ '^\s*'.g:vimwiki_rxMathStart.'\%(.*[[:blank:][:punct:]]\)\?'.
|
||||
\ '\%([[:blank:][:punct:]].*\)\?',
|
||||
\ '^\s*'.g:vimwiki_rxMathEnd, 'VimwikiMath')
|
||||
"}}}
|
||||
|
||||
let timeend = vimwiki#u#time(starttime) "XXX
|
||||
@@ -83,7 +83,7 @@ let g:vimwiki_rxPreStart = '```'
|
||||
let g:vimwiki_rxPreEnd = '```'
|
||||
|
||||
" Math block
|
||||
let g:vimwiki_rxMathStart = '{{\$'
|
||||
let g:vimwiki_rxMathEnd = '}}\$'
|
||||
let g:vimwiki_rxMathStart = '\$\$'
|
||||
let g:vimwiki_rxMathEnd = '\$\$'
|
||||
|
||||
let g:vimwiki_rxComment = '^\s*%%.*$'
|
||||
@@ -101,7 +101,6 @@ let g:vimwiki_rxWikiLinkMatchDescr = ''.
|
||||
\ g:vimwiki_rxWikiLink1MatchDescr
|
||||
" }}}
|
||||
|
||||
|
||||
" LINKS: setup of wikiincl regexps {{{
|
||||
" }}}
|
||||
|
||||
@@ -182,6 +181,15 @@ let g:vimwiki_rxAnyLink = g:vimwiki_rxWikiLink.'\|'.
|
||||
" }}}
|
||||
|
||||
|
||||
" LINKS: setup wikilink1 reference link definitions {{{
|
||||
let g:vimwiki_rxMkdRef = '\['.g:vimwiki_rxWikiLinkDescr.']:\%(\s\+\|\n\)'.
|
||||
\ g:vimwiki_rxWeblink0
|
||||
let g:vimwiki_rxMkdRefMatchDescr = '\[\zs'.g:vimwiki_rxWikiLinkDescr.'\ze]:\%(\s\+\|\n\)'.
|
||||
\ g:vimwiki_rxWeblink0
|
||||
let g:vimwiki_rxMkdRefMatchUrl = '\['.g:vimwiki_rxWikiLinkDescr.']:\%(\s\+\|\n\)\zs'.
|
||||
\ g:vimwiki_rxWeblink0.'\ze'
|
||||
" }}}
|
||||
|
||||
" }}} end of Links
|
||||
|
||||
" LINKS: highlighting is complicated due to "nonexistent" links feature {{{
|
||||
@@ -214,6 +222,11 @@ function! s:wrap_wikilink1_rx(target) "{{{
|
||||
\ g:vimwiki_rxWikiLink1InvalidSuffix
|
||||
endfunction "}}}
|
||||
|
||||
function! s:existing_mkd_refs() "{{{
|
||||
call vimwiki#markdown_base#reset_mkd_refs()
|
||||
return "\n".join(keys(vimwiki#markdown_base#get_reflinks()), "\n")."\n"
|
||||
endfunction "}}}
|
||||
|
||||
function! s:highlight_existing_links() "{{{
|
||||
" Wikilink1
|
||||
" Conditional highlighting that depends on the existence of a wiki file or
|
||||
@@ -222,8 +235,11 @@ function! s:highlight_existing_links() "{{{
|
||||
let safe_links = vimwiki#base#file_pattern(b:existing_wikifiles)
|
||||
" Wikilink1 Dirs set up upon BufEnter (see plugin/...)
|
||||
let safe_dirs = vimwiki#base#file_pattern(b:existing_wikidirs)
|
||||
" Ref links are cached
|
||||
let safe_reflinks = vimwiki#base#file_pattern(s:existing_mkd_refs())
|
||||
|
||||
" match [URL]
|
||||
|
||||
" match [URL][]
|
||||
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template1,
|
||||
\ safe_links, g:vimwiki_rxWikiLink1Descr, '')
|
||||
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
|
||||
@@ -232,7 +248,7 @@ function! s:highlight_existing_links() "{{{
|
||||
\ safe_links, g:vimwiki_rxWikiLink1Descr, '')
|
||||
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
|
||||
|
||||
" match [DIRURL]
|
||||
" match [DIRURL][]
|
||||
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template1,
|
||||
\ safe_dirs, g:vimwiki_rxWikiLink1Descr, '')
|
||||
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
|
||||
@@ -240,6 +256,15 @@ function! s:highlight_existing_links() "{{{
|
||||
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template2,
|
||||
\ safe_dirs, g:vimwiki_rxWikiLink1Descr, '')
|
||||
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
|
||||
|
||||
" match [MKDREF][]
|
||||
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template1,
|
||||
\ safe_reflinks, g:vimwiki_rxWikiLink1Descr, '')
|
||||
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
|
||||
" match [DESCRIPTION][MKDREF]
|
||||
let target = vimwiki#base#apply_template(g:vimwiki_WikiLink1Template2,
|
||||
\ safe_reflinks, g:vimwiki_rxWikiLink1Descr, '')
|
||||
call s:add_target_syntax_ON(s:wrap_wikilink1_rx(target), 'VimwikiWikiLink1')
|
||||
endfunction "}}}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user