Add new stuff
This commit is contained in:
parent
69661de82f
commit
07744f6823
333 changed files with 1989 additions and 6 deletions
|
|
@ -1,101 +0,0 @@
|
|||
This is a mirror of http://www.vim.org/scripts/script.php?script_id=1879
|
||||
|
||||
Repository:
|
||||
https://bitbucket.org/ns9tks/vim-autocomplpop/
|
||||
|
||||
Issues:
|
||||
http://bitbucket.org/ns9tks/vim-autocomplpop/issues/
|
||||
|
||||
Download latest(development) version
|
||||
https://bitbucket.org/ns9tks/vim-autocomplpop/get/tip.zip
|
||||
|
||||
==============================================================================
|
||||
INTRODUCTION *acp-introduction*
|
||||
|
||||
With this plugin, your vim comes to automatically opens popup menu for
|
||||
completions when you enter characters or move the cursor in Insert mode. It
|
||||
won't prevent you continuing entering characters.
|
||||
|
||||
|
||||
==============================================================================
|
||||
INSTALLATION *acp-installation*
|
||||
|
||||
Put all files into your runtime directory. If you have the zip file, extract
|
||||
it to your runtime directory.
|
||||
|
||||
You should place the files as follows:
|
||||
>
|
||||
<your runtime directory>/plugin/acp.vim
|
||||
<your runtime directory>/doc/acp.txt
|
||||
...
|
||||
<
|
||||
If you disgust to jumble up this plugin and other plugins in your runtime
|
||||
directory, put the files into new directory and just add the directory path to
|
||||
'runtimepath'. It's easy to uninstall the plugin.
|
||||
|
||||
And then update your help tags files to enable fuzzyfinder help. See
|
||||
|add-local-help| for details.
|
||||
|
||||
|
||||
==============================================================================
|
||||
USAGE *acp-usage*
|
||||
|
||||
Once this plugin is installed, auto-popup is enabled at startup by default.
|
||||
|
||||
Which completion method is used depends on the text before the cursor. The
|
||||
default behavior is as follows:
|
||||
|
||||
kind filetype text before the cursor ~
|
||||
Keyword * two keyword characters
|
||||
Filename * a filename character + a path separator
|
||||
+ 0 or more filename character
|
||||
Omni ruby ".", "::" or non-word character + ":"
|
||||
(|+ruby| required.)
|
||||
Omni python "." (|+python| required.)
|
||||
Omni xml "<", "</" or ("<" + non-">" characters + " ")
|
||||
Omni html/xhtml "<", "</" or ("<" + non-">" characters + " ")
|
||||
Omni css (":", ";", "{", "^", "@", or "!")
|
||||
+ 0 or 1 space
|
||||
|
||||
Also, you can make user-defined completion and snipMate's trigger completion
|
||||
(|acp-snipMate|) auto-popup if the options are set.
|
||||
|
||||
These behavior are customizable.
|
||||
|
||||
*acp-snipMate*
|
||||
snipMate's Trigger Completion ~
|
||||
|
||||
snipMate's trigger completion enables you to complete a snippet trigger
|
||||
provided by snipMate plugin
|
||||
(http://www.vim.org/scripts/script.php?script_id=2540) and expand it.
|
||||
|
||||
|
||||
To enable auto-popup for this completion, add following function to
|
||||
plugin/snipMate.vim:
|
||||
>
|
||||
fun! GetSnipsInCurrentScope()
|
||||
let snips = {}
|
||||
for scope in [bufnr('%')] + split(&ft, '\.') + ['_']
|
||||
call extend(snips, get(s:snippets, scope, {}), 'keep')
|
||||
call extend(snips, get(s:multi_snips, scope, {}), 'keep')
|
||||
endfor
|
||||
return snips
|
||||
endf
|
||||
<
|
||||
And set |g:acp_behaviorSnipmateLength| option to 1.
|
||||
|
||||
There is the restriction on this auto-popup, that the word before cursor must
|
||||
consist only of uppercase characters.
|
||||
|
||||
*acp-perl-omni*
|
||||
Perl Omni-Completion ~
|
||||
|
||||
AutoComplPop supports perl-completion.vim
|
||||
(http://www.vim.org/scripts/script.php?script_id=2852).
|
||||
|
||||
To enable auto-popup for this completion, set |g:acp_behaviorPerlOmniLength|
|
||||
option to 0 or more.
|
||||
|
||||
|
||||
==============================================================================
|
||||
|
||||
|
|
@ -1,431 +0,0 @@
|
|||
"=============================================================================
|
||||
" Copyright (c) 2007-2009 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if exists('g:loaded_autoload_acp') || v:version < 702
|
||||
finish
|
||||
endif
|
||||
let g:loaded_autoload_acp = 1
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" GLOBAL FUNCTIONS: {{{1
|
||||
|
||||
"
|
||||
function acp#enable()
|
||||
call acp#disable()
|
||||
|
||||
augroup AcpGlobalAutoCommand
|
||||
autocmd!
|
||||
autocmd InsertEnter * unlet! s:posLast s:lastUncompletable
|
||||
autocmd InsertLeave * call s:finishPopup(1)
|
||||
augroup END
|
||||
|
||||
if g:acp_mappingDriven
|
||||
call s:mapForMappingDriven()
|
||||
else
|
||||
autocmd AcpGlobalAutoCommand CursorMovedI * call s:feedPopup()
|
||||
endif
|
||||
|
||||
nnoremap <silent> i i<C-r>=<SID>feedPopup()<CR>
|
||||
nnoremap <silent> a a<C-r>=<SID>feedPopup()<CR>
|
||||
nnoremap <silent> R R<C-r>=<SID>feedPopup()<CR>
|
||||
endfunction
|
||||
|
||||
"
|
||||
function acp#disable()
|
||||
call s:unmapForMappingDriven()
|
||||
augroup AcpGlobalAutoCommand
|
||||
autocmd!
|
||||
augroup END
|
||||
nnoremap i <Nop> | nunmap i
|
||||
nnoremap a <Nop> | nunmap a
|
||||
nnoremap R <Nop> | nunmap R
|
||||
endfunction
|
||||
|
||||
"
|
||||
function acp#lock()
|
||||
let s:lockCount += 1
|
||||
endfunction
|
||||
|
||||
"
|
||||
function acp#unlock()
|
||||
let s:lockCount -= 1
|
||||
if s:lockCount < 0
|
||||
let s:lockCount = 0
|
||||
throw "AutoComplPop: not locked"
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"
|
||||
function acp#meetsForSnipmate(context)
|
||||
if g:acp_behaviorSnipmateLength < 0
|
||||
return 0
|
||||
endif
|
||||
let matches = matchlist(a:context, '\(^\|\s\|\<\)\(\u\{' .
|
||||
\ g:acp_behaviorSnipmateLength . ',}\)$')
|
||||
return !empty(matches) && !empty(s:getMatchingSnipItems(matches[2]))
|
||||
endfunction
|
||||
|
||||
"
|
||||
function acp#meetsForKeyword(context)
|
||||
if g:acp_behaviorKeywordLength < 0
|
||||
return 0
|
||||
endif
|
||||
let matches = matchlist(a:context, '\(\k\{' . g:acp_behaviorKeywordLength . ',}\)$')
|
||||
if empty(matches)
|
||||
return 0
|
||||
endif
|
||||
for ignore in g:acp_behaviorKeywordIgnores
|
||||
if stridx(ignore, matches[1]) == 0
|
||||
return 0
|
||||
endif
|
||||
endfor
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
"
|
||||
function acp#meetsForFile(context)
|
||||
if g:acp_behaviorFileLength < 0
|
||||
return 0
|
||||
endif
|
||||
if has('win32') || has('win64')
|
||||
let separator = '[/\\]'
|
||||
else
|
||||
let separator = '\/'
|
||||
endif
|
||||
if a:context !~ '\f' . separator . '\f\{' . g:acp_behaviorFileLength . ',}$'
|
||||
return 0
|
||||
endif
|
||||
return a:context !~ '[*/\\][/\\]\f*$\|[^[:print:]]\f*$'
|
||||
endfunction
|
||||
|
||||
"
|
||||
function acp#meetsForRubyOmni(context)
|
||||
if !has('ruby')
|
||||
return 0
|
||||
endif
|
||||
if g:acp_behaviorRubyOmniMethodLength >= 0 &&
|
||||
\ a:context =~ '[^. \t]\(\.\|::\)\k\{' .
|
||||
\ g:acp_behaviorRubyOmniMethodLength . ',}$'
|
||||
return 1
|
||||
endif
|
||||
if g:acp_behaviorRubyOmniSymbolLength >= 0 &&
|
||||
\ a:context =~ '\(^\|[^:]\):\k\{' .
|
||||
\ g:acp_behaviorRubyOmniSymbolLength . ',}$'
|
||||
return 1
|
||||
endif
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
"
|
||||
function acp#meetsForPythonOmni(context)
|
||||
return has('python') && g:acp_behaviorPythonOmniLength >= 0 &&
|
||||
\ a:context =~ '\k\.\k\{' . g:acp_behaviorPythonOmniLength . ',}$'
|
||||
endfunction
|
||||
|
||||
"
|
||||
function acp#meetsForPerlOmni(context)
|
||||
return g:acp_behaviorPerlOmniLength >= 0 &&
|
||||
\ a:context =~ '\w->\k\{' . g:acp_behaviorPerlOmniLength . ',}$'
|
||||
endfunction
|
||||
|
||||
"
|
||||
function acp#meetsForXmlOmni(context)
|
||||
return g:acp_behaviorXmlOmniLength >= 0 &&
|
||||
\ a:context =~ '\(<\|<\/\|<[^>]\+ \|<[^>]\+=\"\)\k\{' .
|
||||
\ g:acp_behaviorXmlOmniLength . ',}$'
|
||||
endfunction
|
||||
|
||||
"
|
||||
function acp#meetsForHtmlOmni(context)
|
||||
return g:acp_behaviorHtmlOmniLength >= 0 &&
|
||||
\ a:context =~ '\(<\|<\/\|<[^>]\+ \|<[^>]\+=\"\)\k\{' .
|
||||
\ g:acp_behaviorHtmlOmniLength . ',}$'
|
||||
endfunction
|
||||
|
||||
"
|
||||
function acp#meetsForCssOmni(context)
|
||||
if g:acp_behaviorCssOmniPropertyLength >= 0 &&
|
||||
\ a:context =~ '\(^\s\|[;{]\)\s*\k\{' .
|
||||
\ g:acp_behaviorCssOmniPropertyLength . ',}$'
|
||||
return 1
|
||||
endif
|
||||
if g:acp_behaviorCssOmniValueLength >= 0 &&
|
||||
\ a:context =~ '[:@!]\s*\k\{' .
|
||||
\ g:acp_behaviorCssOmniValueLength . ',}$'
|
||||
return 1
|
||||
endif
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
"
|
||||
function acp#completeSnipmate(findstart, base)
|
||||
if a:findstart
|
||||
let s:posSnipmateCompletion = len(matchstr(s:getCurrentText(), '.*\U'))
|
||||
return s:posSnipmateCompletion
|
||||
endif
|
||||
let lenBase = len(a:base)
|
||||
let items = filter(GetSnipsInCurrentScope(),
|
||||
\ 'strpart(v:key, 0, lenBase) ==? a:base')
|
||||
return map(sort(items(items)), 's:makeSnipmateItem(v:val[0], v:val[1])')
|
||||
endfunction
|
||||
|
||||
"
|
||||
function acp#onPopupCloseSnipmate()
|
||||
let word = s:getCurrentText()[s:posSnipmateCompletion :]
|
||||
for trigger in keys(GetSnipsInCurrentScope())
|
||||
if word ==# trigger
|
||||
call feedkeys("\<C-r>=TriggerSnippet()\<CR>", "n")
|
||||
return 0
|
||||
endif
|
||||
endfor
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
"
|
||||
function acp#onPopupPost()
|
||||
" to clear <C-r>= expression on command-line
|
||||
echo ''
|
||||
if pumvisible()
|
||||
inoremap <silent> <expr> <C-h> acp#onBs()
|
||||
inoremap <silent> <expr> <BS> acp#onBs()
|
||||
" a command to restore to original text and select the first match
|
||||
return (s:behavsCurrent[s:iBehavs].command =~# "\<C-p>" ? "\<C-n>\<Up>"
|
||||
\ : "\<C-p>\<Down>")
|
||||
endif
|
||||
let s:iBehavs += 1
|
||||
if len(s:behavsCurrent) > s:iBehavs
|
||||
call s:setCompletefunc()
|
||||
return printf("\<C-e>%s\<C-r>=acp#onPopupPost()\<CR>",
|
||||
\ s:behavsCurrent[s:iBehavs].command)
|
||||
else
|
||||
let s:lastUncompletable = {
|
||||
\ 'word': s:getCurrentWord(),
|
||||
\ 'commands': map(copy(s:behavsCurrent), 'v:val.command')[1:],
|
||||
\ }
|
||||
call s:finishPopup(0)
|
||||
return "\<C-e>"
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"
|
||||
function acp#onBs()
|
||||
" using "matchstr" and not "strpart" in order to handle multi-byte
|
||||
" characters
|
||||
if call(s:behavsCurrent[s:iBehavs].meets,
|
||||
\ [matchstr(s:getCurrentText(), '.*\ze.')])
|
||||
return "\<BS>"
|
||||
endif
|
||||
return "\<C-e>\<BS>"
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" LOCAL FUNCTIONS: {{{1
|
||||
|
||||
"
|
||||
function s:mapForMappingDriven()
|
||||
call s:unmapForMappingDriven()
|
||||
let s:keysMappingDriven = [
|
||||
\ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
|
||||
\ 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
|
||||
\ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
|
||||
\ 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
|
||||
\ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
\ '-', '_', '~', '^', '.', ',', ':', '!', '#', '=', '%', '$', '@', '<', '>', '/', '\',
|
||||
\ '<Space>', '<C-h>', '<BS>', ]
|
||||
for key in s:keysMappingDriven
|
||||
execute printf('inoremap <silent> %s %s<C-r>=<SID>feedPopup()<CR>',
|
||||
\ key, key)
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:unmapForMappingDriven()
|
||||
if !exists('s:keysMappingDriven')
|
||||
return
|
||||
endif
|
||||
for key in s:keysMappingDriven
|
||||
execute 'iunmap ' . key
|
||||
endfor
|
||||
let s:keysMappingDriven = []
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:setTempOption(group, name, value)
|
||||
call extend(s:tempOptionSet[a:group], { a:name : eval('&' . a:name) }, 'keep')
|
||||
execute printf('let &%s = a:value', a:name)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:restoreTempOptions(group)
|
||||
for [name, value] in items(s:tempOptionSet[a:group])
|
||||
execute printf('let &%s = value', name)
|
||||
endfor
|
||||
let s:tempOptionSet[a:group] = {}
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:getCurrentWord()
|
||||
return matchstr(s:getCurrentText(), '\k*$')
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:getCurrentText()
|
||||
return strpart(getline('.'), 0, col('.') - 1)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:getPostText()
|
||||
return strpart(getline('.'), col('.') - 1)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:isModifiedSinceLastCall()
|
||||
if exists('s:posLast')
|
||||
let posPrev = s:posLast
|
||||
let nLinesPrev = s:nLinesLast
|
||||
let textPrev = s:textLast
|
||||
endif
|
||||
let s:posLast = getpos('.')
|
||||
let s:nLinesLast = line('$')
|
||||
let s:textLast = getline('.')
|
||||
if !exists('posPrev')
|
||||
return 1
|
||||
elseif posPrev[1] != s:posLast[1] || nLinesPrev != s:nLinesLast
|
||||
return (posPrev[1] - s:posLast[1] == nLinesPrev - s:nLinesLast)
|
||||
elseif textPrev ==# s:textLast
|
||||
return 0
|
||||
elseif posPrev[2] > s:posLast[2]
|
||||
return 1
|
||||
elseif has('gui_running') && has('multi_byte')
|
||||
" NOTE: auto-popup causes a strange behavior when IME/XIM is working
|
||||
return posPrev[2] + 1 == s:posLast[2]
|
||||
endif
|
||||
return posPrev[2] != s:posLast[2]
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:makeCurrentBehaviorSet()
|
||||
let modified = s:isModifiedSinceLastCall()
|
||||
if exists('s:behavsCurrent[s:iBehavs].repeat') && s:behavsCurrent[s:iBehavs].repeat
|
||||
let behavs = [ s:behavsCurrent[s:iBehavs] ]
|
||||
elseif exists('s:behavsCurrent[s:iBehavs]')
|
||||
return []
|
||||
elseif modified
|
||||
let behavs = copy(exists('g:acp_behavior[&filetype]')
|
||||
\ ? g:acp_behavior[&filetype]
|
||||
\ : g:acp_behavior['*'])
|
||||
else
|
||||
return []
|
||||
endif
|
||||
let text = s:getCurrentText()
|
||||
call filter(behavs, 'call(v:val.meets, [text])')
|
||||
let s:iBehavs = 0
|
||||
if exists('s:lastUncompletable') &&
|
||||
\ stridx(s:getCurrentWord(), s:lastUncompletable.word) == 0 &&
|
||||
\ map(copy(behavs), 'v:val.command') ==# s:lastUncompletable.commands
|
||||
let behavs = []
|
||||
else
|
||||
unlet! s:lastUncompletable
|
||||
endif
|
||||
return behavs
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:feedPopup()
|
||||
" NOTE: CursorMovedI is not triggered while the popup menu is visible. And
|
||||
" it will be triggered when popup menu is disappeared.
|
||||
if s:lockCount > 0 || pumvisible() || &paste
|
||||
return ''
|
||||
endif
|
||||
if exists('s:behavsCurrent[s:iBehavs].onPopupClose')
|
||||
if !call(s:behavsCurrent[s:iBehavs].onPopupClose, [])
|
||||
call s:finishPopup(1)
|
||||
return ''
|
||||
endif
|
||||
endif
|
||||
let s:behavsCurrent = s:makeCurrentBehaviorSet()
|
||||
if empty(s:behavsCurrent)
|
||||
call s:finishPopup(1)
|
||||
return ''
|
||||
endif
|
||||
" In case of dividing words by symbols (e.g. "for(int", "ab==cd") while a
|
||||
" popup menu is visible, another popup is not available unless input <C-e>
|
||||
" or try popup once. So first completion is duplicated.
|
||||
call insert(s:behavsCurrent, s:behavsCurrent[s:iBehavs])
|
||||
call s:setTempOption(s:GROUP0, 'spell', 0)
|
||||
call s:setTempOption(s:GROUP0, 'completeopt', 'menuone' . (g:acp_completeoptPreview ? ',preview' : ''))
|
||||
call s:setTempOption(s:GROUP0, 'complete', g:acp_completeOption)
|
||||
call s:setTempOption(s:GROUP0, 'ignorecase', g:acp_ignorecaseOption)
|
||||
" NOTE: With CursorMovedI driven, Set 'lazyredraw' to avoid flickering.
|
||||
" With Mapping driven, set 'nolazyredraw' to make a popup menu visible.
|
||||
call s:setTempOption(s:GROUP0, 'lazyredraw', !g:acp_mappingDriven)
|
||||
" NOTE: 'textwidth' must be restored after <C-e>.
|
||||
call s:setTempOption(s:GROUP1, 'textwidth', 0)
|
||||
call s:setCompletefunc()
|
||||
call feedkeys(s:behavsCurrent[s:iBehavs].command . "\<C-r>=acp#onPopupPost()\<CR>", 'n')
|
||||
return '' " this function is called by <C-r>=
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:finishPopup(fGroup1)
|
||||
inoremap <C-h> <Nop> | iunmap <C-h>
|
||||
inoremap <BS> <Nop> | iunmap <BS>
|
||||
let s:behavsCurrent = []
|
||||
call s:restoreTempOptions(s:GROUP0)
|
||||
if a:fGroup1
|
||||
call s:restoreTempOptions(s:GROUP1)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:setCompletefunc()
|
||||
if exists('s:behavsCurrent[s:iBehavs].completefunc')
|
||||
call s:setTempOption(0, 'completefunc', s:behavsCurrent[s:iBehavs].completefunc)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:makeSnipmateItem(key, snip)
|
||||
if type(a:snip) == type([])
|
||||
let descriptions = map(copy(a:snip), 'v:val[0]')
|
||||
let snipFormatted = '[MULTI] ' . join(descriptions, ', ')
|
||||
else
|
||||
let snipFormatted = substitute(a:snip, '\(\n\|\s\)\+', ' ', 'g')
|
||||
endif
|
||||
return {
|
||||
\ 'word': a:key,
|
||||
\ 'menu': strpart(snipFormatted, 0, 80),
|
||||
\ }
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:getMatchingSnipItems(base)
|
||||
let key = a:base . "\n"
|
||||
if !exists('s:snipItems[key]')
|
||||
let s:snipItems[key] = items(GetSnipsInCurrentScope())
|
||||
call filter(s:snipItems[key], 'strpart(v:val[0], 0, len(a:base)) ==? a:base')
|
||||
call map(s:snipItems[key], 's:makeSnipmateItem(v:val[0], v:val[1])')
|
||||
endif
|
||||
return s:snipItems[key]
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" INITIALIZATION {{{1
|
||||
|
||||
let s:GROUP0 = 0
|
||||
let s:GROUP1 = 1
|
||||
let s:lockCount = 0
|
||||
let s:behavsCurrent = []
|
||||
let s:iBehavs = 0
|
||||
let s:tempOptionSet = [{}, {}]
|
||||
let s:snipItems = {}
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" vim: set fdm=marker:
|
||||
|
|
@ -1,298 +0,0 @@
|
|||
*acp.txt* 補完メニューの自動ポップアップ
|
||||
|
||||
Copyright (c) 2007-2009 Takeshi NISHIDA
|
||||
|
||||
AutoComplPop *autocomplpop* *acp*
|
||||
|
||||
概要 |acp-introduction|
|
||||
インストール |acp-installation|
|
||||
使い方 |acp-usage|
|
||||
コマンド |acp-commands|
|
||||
オプション |acp-options|
|
||||
SPECIAL THANKS |acp-thanks|
|
||||
CHANGELOG |acp-changelog|
|
||||
あばうと |acp-about|
|
||||
|
||||
|
||||
==============================================================================
|
||||
概要 *acp-introduction*
|
||||
|
||||
このプラグインは、インサートモードで文字を入力したりカーソルを動かしたときに補
|
||||
完メニューを自動的に開くようにします。しかし、続けて文字を入力するのを妨げたり
|
||||
はしません。
|
||||
|
||||
|
||||
==============================================================================
|
||||
インストール *acp-installation*
|
||||
|
||||
ZIPファイルをランタイムディレクトリに展開します。
|
||||
|
||||
以下のようにファイルが配置されるはずです。
|
||||
>
|
||||
<your runtime directory>/plugin/acp.vim
|
||||
<your runtime directory>/doc/acp.txt
|
||||
...
|
||||
<
|
||||
もしランタイムディレクトリが他のプラグインとごた混ぜになるのが嫌なら、ファイル
|
||||
を新規ディレクトリに配置し、そのディレクトリのパスを 'runtimepath' に追加して
|
||||
ください。アンインストールも楽になります。
|
||||
|
||||
その後 FuzzyFinder のヘルプを有効にするためにタグファイルを更新してください。
|
||||
詳しくは|add-local-help|を参照してください。
|
||||
|
||||
|
||||
==============================================================================
|
||||
使い方 *acp-usage*
|
||||
|
||||
このプラグインがインストールされていれば、自動ポップアップは vim の開始時から
|
||||
有効になります。
|
||||
|
||||
カーソル直前のテキストに応じて、利用する補完の種類を切り替えます。デフォルトの
|
||||
補完動作は次の通りです:
|
||||
|
||||
補完モード filetype カーソル直前のテキスト ~
|
||||
キーワード補完 * 2文字のキーワード文字
|
||||
ファイル名補完 * ファイル名文字 + パスセパレータ
|
||||
+ 0文字以上のファイル名文字
|
||||
オムニ補完 ruby ".", "::" or 単語を構成する文字以外 + ":"
|
||||
オムニ補完 python "."
|
||||
オムニ補完 xml "<", "</" or ("<" + ">"以外の文字列 + " ")
|
||||
オムニ補完 html/xhtml "<", "</" or ("<" + ">"以外の文字列 + " ")
|
||||
オムニ補完 css (":", ";", "{", "^", "@", or "!")
|
||||
+ 0個または1個のスペース
|
||||
|
||||
さらに、設定を行うことで、ユーザー定義補完と snipMate トリガー補完
|
||||
(|acp-snipMate|) を自動ポップアップさせることができます。
|
||||
|
||||
これらの補完動作はカスタマイズ可能です。
|
||||
|
||||
*acp-snipMate*
|
||||
snipMate トリガー補完 ~
|
||||
|
||||
snipMate トリガー補完では、snipMate プラグイン
|
||||
(http://www.vim.org/scripts/script.php?script_id=2540) が提供するスニペットの
|
||||
トリガーを補完してそれを展開することができます。
|
||||
|
||||
この自動ポップアップを有効にするには、次の関数を plugin/snipMate.vim に追加す
|
||||
る必要があります:
|
||||
>
|
||||
fun! GetSnipsInCurrentScope()
|
||||
let snips = {}
|
||||
for scope in [bufnr('%')] + split(&ft, '\.') + ['_']
|
||||
call extend(snips, get(s:snippets, scope, {}), 'keep')
|
||||
call extend(snips, get(s:multi_snips, scope, {}), 'keep')
|
||||
endfor
|
||||
return snips
|
||||
endf
|
||||
<
|
||||
そして|g:acp_behaviorSnipmateLength|オプションを 1 にしてください。
|
||||
|
||||
この自動ポップアップには制限があり、カーソル直前の単語は大文字英字だけで構成さ
|
||||
れていなければなりません。
|
||||
|
||||
*acp-perl-omni*
|
||||
Perl オムニ補完 ~
|
||||
|
||||
AutoComplPop は perl-completion.vim
|
||||
(http://www.vim.org/scripts/script.php?script_id=2852) をサポートしています。
|
||||
|
||||
この自動ポップアップを有効にするには、|g:acp_behaviorPerlOmniLength|オプション
|
||||
を 0 以上にしてください。
|
||||
|
||||
|
||||
==============================================================================
|
||||
コマンド *acp-commands*
|
||||
|
||||
*:AcpEnable*
|
||||
:AcpEnable
|
||||
自動ポップアップを有効にします。
|
||||
|
||||
*:AcpDisable*
|
||||
:AcpDisable
|
||||
自動ポップアップを無効にします。
|
||||
|
||||
*:AcpLock*
|
||||
:AcpLock
|
||||
自動ポップアップを一時的に停止します。
|
||||
|
||||
別のスクリプトへの干渉を回避する目的なら、このコマンドと|:AcpUnlock|
|
||||
を利用することを、|:AcpDisable|と|:AcpEnable| を利用するよりも推奨しま
|
||||
す。
|
||||
|
||||
*:AcpUnlock*
|
||||
:AcpUnlock
|
||||
|:AcpLock| で停止された自動ポップアップを再開します。
|
||||
|
||||
|
||||
==============================================================================
|
||||
オプション *acp-options*
|
||||
|
||||
*g:acp_enableAtStartup* >
|
||||
let g:acp_enableAtStartup = 1
|
||||
<
|
||||
真なら vim 開始時から自動ポップアップが有効になります。
|
||||
|
||||
*g:acp_mappingDriven* >
|
||||
let g:acp_mappingDriven = 0
|
||||
<
|
||||
真なら|CursorMovedI|イベントではなくキーマッピングで自動ポップアップを
|
||||
行うようにします。カーソルを移動するたびに補完が行われることで重いなど
|
||||
の不都合がある場合に利用してください。ただし他のプラグインとの相性問題
|
||||
や日本語入力での不具合が発生する可能性があります。(逆も然り。)
|
||||
|
||||
*g:acp_ignorecaseOption* >
|
||||
let g:acp_ignorecaseOption = 1
|
||||
<
|
||||
自動ポップアップ時に、'ignorecase' に一時的に設定する値
|
||||
|
||||
*g:acp_completeOption* >
|
||||
let g:acp_completeOption = '.,w,b,k'
|
||||
<
|
||||
自動ポップアップ時に、'complete' に一時的に設定する値
|
||||
|
||||
*g:acp_completeoptPreview* >
|
||||
let g:acp_completeoptPreview = 0
|
||||
<
|
||||
真なら自動ポップアップ時に、 'completeopt' へ "preview" を追加します。
|
||||
|
||||
*g:acp_behaviorUserDefinedFunction* >
|
||||
let g:acp_behaviorUserDefinedFunction = ''
|
||||
<
|
||||
ユーザー定義補完の|g:acp_behavior-completefunc|。空ならこの補完は行わ
|
||||
れません。。
|
||||
|
||||
*g:acp_behaviorUserDefinedMeets* >
|
||||
let g:acp_behaviorUserDefinedMeets = ''
|
||||
<
|
||||
ユーザー定義補完の|g:acp_behavior-meets|。空ならこの補完は行われません
|
||||
。
|
||||
|
||||
*g:acp_behaviorSnipmateLength* >
|
||||
let g:acp_behaviorSnipmateLength = -1
|
||||
<
|
||||
snipMate トリガー補完の自動ポップアップを行うのに必要なカーソルの直前
|
||||
のパターン。
|
||||
|
||||
*g:acp_behaviorKeywordCommand* >
|
||||
let g:acp_behaviorKeywordCommand = "\<C-n>"
|
||||
<
|
||||
キーワード補完のコマンド。このオプションには普通 "\<C-n>" か "\<C-p>"
|
||||
を設定します。
|
||||
|
||||
*g:acp_behaviorKeywordLength* >
|
||||
let g:acp_behaviorKeywordLength = 2
|
||||
<
|
||||
キーワード補完の自動ポップアップを行うのに必要なカーソルの直前のキーワ
|
||||
ード文字数。負数ならこの補完は行われません。
|
||||
|
||||
*g:acp_behaviorKeywordIgnores* >
|
||||
let g:acp_behaviorKeywordIgnores = []
|
||||
<
|
||||
文字列のリスト。カーソル直前の単語がこれらの内いずれかの先頭部分にマッ
|
||||
チする場合、この補完は行われません。
|
||||
|
||||
例えば、 "get" で始まる補完キーワードが多過ぎて、"g", "ge", "get" を入
|
||||
力したときの自動ポップアップがレスポンスの低下を引き起こしている場合、
|
||||
このオプションに ["get"] を設定することでそれを回避することができます。
|
||||
|
||||
*g:acp_behaviorFileLength* >
|
||||
let g:acp_behaviorFileLength = 0
|
||||
<
|
||||
ファイル名補完の自動ポップアップを行うのに必要なカーソルの直前のキーワ
|
||||
ード文字数。負数ならこの補完は行われません。
|
||||
|
||||
*g:acp_behaviorRubyOmniMethodLength* >
|
||||
let g:acp_behaviorRubyOmniMethodLength = 0
|
||||
<
|
||||
メソッド補完のための、Ruby オムニ補完の自動ポップアップを行うのに必要
|
||||
なカーソルの直前のキーワード文字数。負数ならこの補完は行われません。
|
||||
|
||||
*g:acp_behaviorRubyOmniSymbolLength* >
|
||||
let g:acp_behaviorRubyOmniSymbolLength = 1
|
||||
<
|
||||
シンボル補完のための、Ruby オムニ補完の自動ポップアップを行うのに必要
|
||||
なカーソルの直前のキーワード文字数。負数ならこの補完は行われません。
|
||||
|
||||
*g:acp_behaviorPythonOmniLength* >
|
||||
let g:acp_behaviorPythonOmniLength = 0
|
||||
<
|
||||
Python オムニ補完の自動ポップアップを行うのに必要なカーソルの直前のキ
|
||||
ーワード文字数。負数ならこの補完は行われません。
|
||||
|
||||
*g:acp_behaviorPerlOmniLength* >
|
||||
let g:acp_behaviorPerlOmniLength = -1
|
||||
<
|
||||
Perl オムニ補完の自動ポップアップを行うのに必要なカーソルの直前のキー
|
||||
ワード文字数。負数ならこの補完は行われません。
|
||||
|
||||
See also: |acp-perl-omni|
|
||||
|
||||
*g:acp_behaviorXmlOmniLength* >
|
||||
let g:acp_behaviorXmlOmniLength = 0
|
||||
<
|
||||
XML オムニ補完の自動ポップアップを行うのに必要なカーソルの直前のキーワ
|
||||
ード文字数。負数ならこの補完は行われません。
|
||||
|
||||
*g:acp_behaviorHtmlOmniLength* >
|
||||
let g:acp_behaviorHtmlOmniLength = 0
|
||||
<
|
||||
HTML オムニ補完の自動ポップアップを行うのに必要なカーソルの直前のキー
|
||||
ワード文字数。負数ならこの補完は行われません。
|
||||
|
||||
*g:acp_behaviorCssOmniPropertyLength* >
|
||||
let g:acp_behaviorCssOmniPropertyLength = 1
|
||||
<
|
||||
プロパティ補完のための、CSS オムニ補完の自動ポップアップを行うのに必要
|
||||
なカーソルの直前のキーワード文字数。負数ならこの補完は行われません。
|
||||
|
||||
*g:acp_behaviorCssOmniValueLength* >
|
||||
let g:acp_behaviorCssOmniValueLength = 0
|
||||
<
|
||||
値補完のための、CSS オムニ補完の自動ポップアップを行うのに必要なカーソ
|
||||
ルの直前のキーワード文字数。負数ならこの補完は行われません。
|
||||
|
||||
*g:acp_behavior* >
|
||||
let g:acp_behavior = {}
|
||||
<
|
||||
|
||||
これは内部仕様がわかっている人向けのオプションで、他のオプションでの設
|
||||
定より優先されます。
|
||||
|
||||
|Dictionary|型で、キーはファイルタイプに対応します。 '*' はデフォルト
|
||||
を表します。値はリスト型です。補完候補が得られるまでリストの先頭アイテ
|
||||
ムから順に評価します。各要素は|Dictionary|で詳細は次の通り:
|
||||
|
||||
"command": *g:acp_behavior-command*
|
||||
補完メニューをポップアップするためのコマンド。
|
||||
|
||||
"completefunc": *g:acp_behavior-completefunc*
|
||||
'completefunc' に設定する関数。 "command" が "<C-x><C-u>" のときだけ
|
||||
意味があります。
|
||||
|
||||
"meets": *g:acp_behavior-meets*
|
||||
この補完を行うかどうかを判断する関数の名前。この関数はカーソル直前の
|
||||
テキストを引数に取り、補完を行うなら非 0 の値を返します。
|
||||
|
||||
"onPopupClose": *g:acp_behavior-onPopupClose*
|
||||
この補完のポップアップメニューが閉じられたときに呼ばれる関数の名前。
|
||||
この関数が 0 を返した場合、続いて行われる予定の補完は抑制されます。
|
||||
|
||||
"repeat": *g:acp_behavior-repeat*
|
||||
真なら最後の補完が自動的に繰り返されます。
|
||||
|
||||
|
||||
==============================================================================
|
||||
あばうと *acp-about* *acp-contact* *acp-author*
|
||||
|
||||
作者: Takeshi NISHIDA <ns9tks@DELETE-ME.gmail.com>
|
||||
ライセンス: MIT Licence
|
||||
URL: http://www.vim.org/scripts/script.php?script_id=1879
|
||||
http://bitbucket.org/ns9tks/vim-autocomplpop/
|
||||
|
||||
バグや要望など ~
|
||||
|
||||
こちらへどうぞ: http://bitbucket.org/ns9tks/vim-autocomplpop/issues/
|
||||
|
||||
==============================================================================
|
||||
vim:tw=78:ts=8:ft=help:norl:
|
||||
|
||||
|
|
@ -1,512 +0,0 @@
|
|||
*acp.txt* Automatically opens popup menu for completions.
|
||||
|
||||
Copyright (c) 2007-2009 Takeshi NISHIDA
|
||||
|
||||
AutoComplPop *autocomplpop* *acp*
|
||||
|
||||
INTRODUCTION |acp-introduction|
|
||||
INSTALLATION |acp-installation|
|
||||
USAGE |acp-usage|
|
||||
COMMANDS |acp-commands|
|
||||
OPTIONS |acp-options|
|
||||
SPECIAL THANKS |acp-thanks|
|
||||
CHANGELOG |acp-changelog|
|
||||
ABOUT |acp-about|
|
||||
|
||||
|
||||
==============================================================================
|
||||
INTRODUCTION *acp-introduction*
|
||||
|
||||
With this plugin, your vim comes to automatically opens popup menu for
|
||||
completions when you enter characters or move the cursor in Insert mode. It
|
||||
won't prevent you continuing entering characters.
|
||||
|
||||
|
||||
==============================================================================
|
||||
INSTALLATION *acp-installation*
|
||||
|
||||
Put all files into your runtime directory. If you have the zip file, extract
|
||||
it to your runtime directory.
|
||||
|
||||
You should place the files as follows:
|
||||
>
|
||||
<your runtime directory>/plugin/acp.vim
|
||||
<your runtime directory>/doc/acp.txt
|
||||
...
|
||||
<
|
||||
If you disgust to jumble up this plugin and other plugins in your runtime
|
||||
directory, put the files into new directory and just add the directory path to
|
||||
'runtimepath'. It's easy to uninstall the plugin.
|
||||
|
||||
And then update your help tags files to enable fuzzyfinder help. See
|
||||
|add-local-help| for details.
|
||||
|
||||
|
||||
==============================================================================
|
||||
USAGE *acp-usage*
|
||||
|
||||
Once this plugin is installed, auto-popup is enabled at startup by default.
|
||||
|
||||
Which completion method is used depends on the text before the cursor. The
|
||||
default behavior is as follows:
|
||||
|
||||
kind filetype text before the cursor ~
|
||||
Keyword * two keyword characters
|
||||
Filename * a filename character + a path separator
|
||||
+ 0 or more filename character
|
||||
Omni ruby ".", "::" or non-word character + ":"
|
||||
(|+ruby| required.)
|
||||
Omni python "." (|+python| required.)
|
||||
Omni xml "<", "</" or ("<" + non-">" characters + " ")
|
||||
Omni html/xhtml "<", "</" or ("<" + non-">" characters + " ")
|
||||
Omni css (":", ";", "{", "^", "@", or "!")
|
||||
+ 0 or 1 space
|
||||
|
||||
Also, you can make user-defined completion and snipMate's trigger completion
|
||||
(|acp-snipMate|) auto-popup if the options are set.
|
||||
|
||||
These behavior are customizable.
|
||||
|
||||
*acp-snipMate*
|
||||
snipMate's Trigger Completion ~
|
||||
|
||||
snipMate's trigger completion enables you to complete a snippet trigger
|
||||
provided by snipMate plugin
|
||||
(http://www.vim.org/scripts/script.php?script_id=2540) and expand it.
|
||||
|
||||
|
||||
To enable auto-popup for this completion, add following function to
|
||||
plugin/snipMate.vim:
|
||||
>
|
||||
fun! GetSnipsInCurrentScope()
|
||||
let snips = {}
|
||||
for scope in [bufnr('%')] + split(&ft, '\.') + ['_']
|
||||
call extend(snips, get(s:snippets, scope, {}), 'keep')
|
||||
call extend(snips, get(s:multi_snips, scope, {}), 'keep')
|
||||
endfor
|
||||
return snips
|
||||
endf
|
||||
<
|
||||
And set |g:acp_behaviorSnipmateLength| option to 1.
|
||||
|
||||
There is the restriction on this auto-popup, that the word before cursor must
|
||||
consist only of uppercase characters.
|
||||
|
||||
*acp-perl-omni*
|
||||
Perl Omni-Completion ~
|
||||
|
||||
AutoComplPop supports perl-completion.vim
|
||||
(http://www.vim.org/scripts/script.php?script_id=2852).
|
||||
|
||||
To enable auto-popup for this completion, set |g:acp_behaviorPerlOmniLength|
|
||||
option to 0 or more.
|
||||
|
||||
|
||||
==============================================================================
|
||||
COMMANDS *acp-commands*
|
||||
|
||||
*:AcpEnable*
|
||||
:AcpEnable
|
||||
enables auto-popup.
|
||||
|
||||
*:AcpDisable*
|
||||
:AcpDisable
|
||||
disables auto-popup.
|
||||
|
||||
*:AcpLock*
|
||||
:AcpLock
|
||||
suspends auto-popup temporarily.
|
||||
|
||||
For the purpose of avoiding interruption to another script, it is
|
||||
recommended to insert this command and |:AcpUnlock| than |:AcpDisable|
|
||||
and |:AcpEnable| .
|
||||
|
||||
*:AcpUnlock*
|
||||
:AcpUnlock
|
||||
resumes auto-popup suspended by |:AcpLock| .
|
||||
|
||||
|
||||
==============================================================================
|
||||
OPTIONS *acp-options*
|
||||
|
||||
*g:acp_enableAtStartup* >
|
||||
let g:acp_enableAtStartup = 1
|
||||
<
|
||||
If non-zero, auto-popup is enabled at startup.
|
||||
|
||||
*g:acp_mappingDriven* >
|
||||
let g:acp_mappingDriven = 0
|
||||
<
|
||||
If non-zero, auto-popup is triggered by key mappings instead of
|
||||
|CursorMovedI| event. This is useful to avoid auto-popup by moving
|
||||
cursor in Insert mode.
|
||||
|
||||
*g:acp_ignorecaseOption* >
|
||||
let g:acp_ignorecaseOption = 1
|
||||
<
|
||||
Value set to 'ignorecase' temporarily when auto-popup.
|
||||
|
||||
*g:acp_completeOption* >
|
||||
let g:acp_completeOption = '.,w,b,k'
|
||||
<
|
||||
Value set to 'complete' temporarily when auto-popup.
|
||||
|
||||
*g:acp_completeoptPreview* >
|
||||
let g:acp_completeoptPreview = 0
|
||||
<
|
||||
If non-zero, "preview" is added to 'completeopt' when auto-popup.
|
||||
|
||||
*g:acp_behaviorUserDefinedFunction* >
|
||||
let g:acp_behaviorUserDefinedFunction = ''
|
||||
<
|
||||
|g:acp_behavior-completefunc| for user-defined completion. If empty,
|
||||
this completion will be never attempted.
|
||||
|
||||
*g:acp_behaviorUserDefinedMeets* >
|
||||
let g:acp_behaviorUserDefinedMeets = ''
|
||||
<
|
||||
|g:acp_behavior-meets| for user-defined completion. If empty, this
|
||||
completion will be never attempted.
|
||||
|
||||
*g:acp_behaviorSnipmateLength* >
|
||||
let g:acp_behaviorSnipmateLength = -1
|
||||
<
|
||||
Pattern before the cursor, which are needed to attempt
|
||||
snipMate-trigger completion.
|
||||
|
||||
*g:acp_behaviorKeywordCommand* >
|
||||
let g:acp_behaviorKeywordCommand = "\<C-n>"
|
||||
<
|
||||
Command for keyword completion. This option is usually set "\<C-n>" or
|
||||
"\<C-p>".
|
||||
|
||||
*g:acp_behaviorKeywordLength* >
|
||||
let g:acp_behaviorKeywordLength = 2
|
||||
<
|
||||
Length of keyword characters before the cursor, which are needed to
|
||||
attempt keyword completion. If negative value, this completion will be
|
||||
never attempted.
|
||||
|
||||
*g:acp_behaviorKeywordIgnores* >
|
||||
let g:acp_behaviorKeywordIgnores = []
|
||||
<
|
||||
List of string. If a word before the cursor matches to the front part
|
||||
of one of them, keyword completion won't be attempted.
|
||||
|
||||
E.g., when there are too many keywords beginning with "get" for the
|
||||
completion and auto-popup by entering "g", "ge", or "get" causes
|
||||
response degradation, set ["get"] to this option and avoid it.
|
||||
|
||||
*g:acp_behaviorFileLength* >
|
||||
let g:acp_behaviorFileLength = 0
|
||||
<
|
||||
Length of filename characters before the cursor, which are needed to
|
||||
attempt filename completion. If negative value, this completion will
|
||||
be never attempted.
|
||||
|
||||
*g:acp_behaviorRubyOmniMethodLength* >
|
||||
let g:acp_behaviorRubyOmniMethodLength = 0
|
||||
<
|
||||
Length of keyword characters before the cursor, which are needed to
|
||||
attempt ruby omni-completion for methods. If negative value, this
|
||||
completion will be never attempted.
|
||||
|
||||
*g:acp_behaviorRubyOmniSymbolLength* >
|
||||
let g:acp_behaviorRubyOmniSymbolLength = 1
|
||||
<
|
||||
Length of keyword characters before the cursor, which are needed to
|
||||
attempt ruby omni-completion for symbols. If negative value, this
|
||||
completion will be never attempted.
|
||||
|
||||
*g:acp_behaviorPythonOmniLength* >
|
||||
let g:acp_behaviorPythonOmniLength = 0
|
||||
<
|
||||
Length of keyword characters before the cursor, which are needed to
|
||||
attempt python omni-completion. If negative value, this completion
|
||||
will be never attempted.
|
||||
|
||||
*g:acp_behaviorPerlOmniLength* >
|
||||
let g:acp_behaviorPerlOmniLength = -1
|
||||
<
|
||||
Length of keyword characters before the cursor, which are needed to
|
||||
attempt perl omni-completion. If negative value, this completion will
|
||||
be never attempted.
|
||||
|
||||
See also: |acp-perl-omni|
|
||||
|
||||
*g:acp_behaviorXmlOmniLength* >
|
||||
let g:acp_behaviorXmlOmniLength = 0
|
||||
<
|
||||
Length of keyword characters before the cursor, which are needed to
|
||||
attempt XML omni-completion. If negative value, this completion will
|
||||
be never attempted.
|
||||
|
||||
*g:acp_behaviorHtmlOmniLength* >
|
||||
let g:acp_behaviorHtmlOmniLength = 0
|
||||
<
|
||||
Length of keyword characters before the cursor, which are needed to
|
||||
attempt HTML omni-completion. If negative value, this completion will
|
||||
be never attempted.
|
||||
|
||||
*g:acp_behaviorCssOmniPropertyLength* >
|
||||
let g:acp_behaviorCssOmniPropertyLength = 1
|
||||
<
|
||||
Length of keyword characters before the cursor, which are needed to
|
||||
attempt CSS omni-completion for properties. If negative value, this
|
||||
completion will be never attempted.
|
||||
|
||||
*g:acp_behaviorCssOmniValueLength* >
|
||||
let g:acp_behaviorCssOmniValueLength = 0
|
||||
<
|
||||
Length of keyword characters before the cursor, which are needed to
|
||||
attempt CSS omni-completion for values. If negative value, this
|
||||
completion will be never attempted.
|
||||
|
||||
*g:acp_behavior* >
|
||||
let g:acp_behavior = {}
|
||||
<
|
||||
This option is for advanced users. This setting overrides other
|
||||
behavior options. This is a |Dictionary|. Each key corresponds to a
|
||||
filetype. '*' is default. Each value is a list. These are attempted in
|
||||
sequence until completion item is found. Each element is a
|
||||
|Dictionary| which has following items:
|
||||
|
||||
"command": *g:acp_behavior-command*
|
||||
Command to be fed to open popup menu for completions.
|
||||
|
||||
"completefunc": *g:acp_behavior-completefunc*
|
||||
'completefunc' will be set to this user-provided function during the
|
||||
completion. Only makes sense when "command" is "<C-x><C-u>".
|
||||
|
||||
"meets": *g:acp_behavior-meets*
|
||||
Name of the function which dicides whether or not to attempt this
|
||||
completion. It will be attempted if this function returns non-zero.
|
||||
This function takes a text before the cursor.
|
||||
|
||||
"onPopupClose": *g:acp_behavior-onPopupClose*
|
||||
Name of the function which is called when popup menu for this
|
||||
completion is closed. Following completions will be suppressed if
|
||||
this function returns zero.
|
||||
|
||||
"repeat": *g:acp_behavior-repeat*
|
||||
If non-zero, the last completion is automatically repeated.
|
||||
|
||||
|
||||
==============================================================================
|
||||
SPECIAL THANKS *acp-thanks*
|
||||
|
||||
- Daniel Schierbeck
|
||||
- Ingo Karkat
|
||||
|
||||
|
||||
==============================================================================
|
||||
CHANGELOG *acp-changelog*
|
||||
|
||||
2.14.1
|
||||
- Changed the way of auto-popup for avoiding an issue about filename
|
||||
completion.
|
||||
- Fixed a bug that popup menu was opened twice when auto-popup was done.
|
||||
|
||||
2.14
|
||||
- Added the support for perl-completion.vim.
|
||||
|
||||
2.13
|
||||
- Changed to sort snipMate's triggers.
|
||||
- Fixed a bug that a wasted character was inserted after snipMate's trigger
|
||||
completion.
|
||||
|
||||
2.12.1
|
||||
- Changed to avoid a strange behavior with Microsoft IME.
|
||||
|
||||
2.12
|
||||
- Added g:acp_behaviorKeywordIgnores option.
|
||||
- Added g:acp_behaviorUserDefinedMeets option and removed
|
||||
g:acp_behaviorUserDefinedPattern.
|
||||
- Changed to do auto-popup only when a buffer is modified.
|
||||
- Changed the structure of g:acp_behavior option.
|
||||
- Changed to reflect a change of behavior options (named g:acp_behavior*)
|
||||
any time it is done.
|
||||
- Fixed a bug that completions after omni completions or snipMate's trigger
|
||||
completion were never attempted when no candidate for the former
|
||||
completions was found.
|
||||
|
||||
2.11.1
|
||||
- Fixed a bug that a snipMate's trigger could not be expanded when it was
|
||||
completed.
|
||||
|
||||
2.11
|
||||
- Implemented experimental feature which is snipMate's trigger completion.
|
||||
|
||||
2.10
|
||||
- Improved the response by changing not to attempt any completion when
|
||||
keyword characters are entered after a word which has been found that it
|
||||
has no completion candidate at the last attempt of completions.
|
||||
- Improved the response by changing to close popup menu when <BS> was
|
||||
pressed and the text before the cursor would not match with the pattern of
|
||||
current behavior.
|
||||
|
||||
2.9
|
||||
- Changed default behavior to support XML omni completion.
|
||||
- Changed default value of g:acp_behaviorKeywordCommand option.
|
||||
The option with "\<C-p>" cause a problem which inserts a match without
|
||||
<CR> when 'dictionary' has been set and keyword completion is done.
|
||||
- Changed to show error message when incompatible with a installed vim.
|
||||
|
||||
2.8.1
|
||||
- Fixed a bug which inserted a selected match to the next line when
|
||||
auto-wrapping (enabled with 'formatoptions') was performed.
|
||||
|
||||
2.8
|
||||
- Added g:acp_behaviorUserDefinedFunction option and
|
||||
g:acp_behaviorUserDefinedPattern option for users who want to make custom
|
||||
completion auto-popup.
|
||||
- Fixed a bug that setting 'spell' on a new buffer made typing go crazy.
|
||||
|
||||
2.7
|
||||
- Changed naming conventions for filenames, functions, commands, and options
|
||||
and thus renamed them.
|
||||
- Added g:acp_behaviorKeywordCommand option. If you prefer the previous
|
||||
behavior for keyword completion, set this option "\<C-n>".
|
||||
- Changed default value of g:acp_ignorecaseOption option.
|
||||
|
||||
The following were done by Ingo Karkat:
|
||||
|
||||
- ENH: Added support for setting a user-provided 'completefunc' during the
|
||||
completion, configurable via g:acp_behavior.
|
||||
- BUG: When the configured completion is <C-p> or <C-x><C-p>, the command to
|
||||
restore the original text (in on_popup_post()) must be reverted, too.
|
||||
- BUG: When using a custom completion function (<C-x><C-u>) that also uses
|
||||
an s:...() function name, the s:GetSidPrefix() function dynamically
|
||||
determines the wrong SID. Now calling s:DetermineSidPrefix() once during
|
||||
sourcing and caching the value in s:SID.
|
||||
- BUG: Should not use custom defined <C-X><C-...> completion mappings. Now
|
||||
consistently using unmapped completion commands everywhere. (Beforehand,
|
||||
s:PopupFeeder.feed() used mappings via feedkeys(..., 'm'), but
|
||||
s:PopupFeeder.on_popup_post() did not due to its invocation via
|
||||
:map-expr.)
|
||||
|
||||
2.6:
|
||||
- Improved the behavior of omni completion for HTML/XHTML.
|
||||
|
||||
2.5:
|
||||
- Added some options to customize behavior easily:
|
||||
g:AutoComplPop_BehaviorKeywordLength
|
||||
g:AutoComplPop_BehaviorFileLength
|
||||
g:AutoComplPop_BehaviorRubyOmniMethodLength
|
||||
g:AutoComplPop_BehaviorRubyOmniSymbolLength
|
||||
g:AutoComplPop_BehaviorPythonOmniLength
|
||||
g:AutoComplPop_BehaviorHtmlOmniLength
|
||||
g:AutoComplPop_BehaviorCssOmniPropertyLength
|
||||
g:AutoComplPop_BehaviorCssOmniValueLength
|
||||
|
||||
2.4:
|
||||
- Added g:AutoComplPop_MappingDriven option.
|
||||
|
||||
2.3.1:
|
||||
- Changed to set 'lazyredraw' while a popup menu is visible to avoid
|
||||
flickering.
|
||||
- Changed a behavior for CSS.
|
||||
- Added support for GetLatestVimScripts.
|
||||
|
||||
2.3:
|
||||
- Added a behavior for Python to support omni completion.
|
||||
- Added a behavior for CSS to support omni completion.
|
||||
|
||||
2.2:
|
||||
- Changed not to work when 'paste' option is set.
|
||||
- Fixed AutoComplPopEnable command and AutoComplPopDisable command to
|
||||
map/unmap "i" and "R".
|
||||
|
||||
2.1:
|
||||
- Fixed the problem caused by "." command in Normal mode.
|
||||
- Changed to map "i" and "R" to feed completion command after starting
|
||||
Insert mode.
|
||||
- Avoided the problem caused by Windows IME.
|
||||
|
||||
2.0:
|
||||
- Changed to use CursorMovedI event to feed a completion command instead of
|
||||
key mapping. Now the auto-popup is triggered by moving the cursor.
|
||||
- Changed to feed completion command after starting Insert mode.
|
||||
- Removed g:AutoComplPop_MapList option.
|
||||
|
||||
1.7:
|
||||
- Added behaviors for HTML/XHTML. Now supports the omni completion for
|
||||
HTML/XHTML.
|
||||
- Changed not to show expressions for CTRL-R =.
|
||||
- Changed not to set 'nolazyredraw' while a popup menu is visible.
|
||||
|
||||
1.6.1:
|
||||
- Changed not to trigger the filename completion by a text which has
|
||||
multi-byte characters.
|
||||
|
||||
1.6:
|
||||
- Redesigned g:AutoComplPop_Behavior option.
|
||||
- Changed default value of g:AutoComplPop_CompleteOption option.
|
||||
- Changed default value of g:AutoComplPop_MapList option.
|
||||
|
||||
1.5:
|
||||
- Implemented continuous-completion for the filename completion. And added
|
||||
new option to g:AutoComplPop_Behavior.
|
||||
|
||||
1.4:
|
||||
- Fixed the bug that the auto-popup was not suspended in fuzzyfinder.
|
||||
- Fixed the bug that an error has occurred with Ruby-omni-completion unless
|
||||
Ruby interface.
|
||||
|
||||
1.3:
|
||||
- Supported Ruby-omni-completion by default.
|
||||
- Supported filename completion by default.
|
||||
- Added g:AutoComplPop_Behavior option.
|
||||
- Added g:AutoComplPop_CompleteoptPreview option.
|
||||
- Removed g:AutoComplPop_MinLength option.
|
||||
- Removed g:AutoComplPop_MaxLength option.
|
||||
- Removed g:AutoComplPop_PopupCmd option.
|
||||
|
||||
1.2:
|
||||
- Fixed bugs related to 'completeopt'.
|
||||
|
||||
1.1:
|
||||
- Added g:AutoComplPop_IgnoreCaseOption option.
|
||||
- Added g:AutoComplPop_NotEnableAtStartup option.
|
||||
- Removed g:AutoComplPop_LoadAndEnable option.
|
||||
1.0:
|
||||
- g:AutoComplPop_LoadAndEnable option for a startup activation is added.
|
||||
- AutoComplPopLock command and AutoComplPopUnlock command are added to
|
||||
suspend and resume.
|
||||
- 'completeopt' and 'complete' options are changed temporarily while
|
||||
completing by this script.
|
||||
|
||||
0.4:
|
||||
- The first match are selected when the popup menu is Opened. You can insert
|
||||
the first match with CTRL-Y.
|
||||
|
||||
0.3:
|
||||
- Fixed the problem that the original text is not restored if 'longest' is
|
||||
not set in 'completeopt'. Now the plugin works whether or not 'longest' is
|
||||
set in 'completeopt', and also 'menuone'.
|
||||
|
||||
0.2:
|
||||
- When completion matches are not found, insert CTRL-E to stop completion.
|
||||
- Clear the echo area.
|
||||
- Fixed the problem in case of dividing words by symbols, popup menu is
|
||||
not opened.
|
||||
|
||||
0.1:
|
||||
- First release.
|
||||
|
||||
|
||||
==============================================================================
|
||||
ABOUT *acp-about* *acp-contact* *acp-author*
|
||||
|
||||
Author: Takeshi NISHIDA <ns9tks@DELETE-ME.gmail.com>
|
||||
Licence: MIT Licence
|
||||
URL: http://www.vim.org/scripts/script.php?script_id=1879
|
||||
http://bitbucket.org/ns9tks/vim-autocomplpop/
|
||||
|
||||
Bugs/Issues/Suggestions/Improvements ~
|
||||
|
||||
Please submit to http://bitbucket.org/ns9tks/vim-autocomplpop/issues/ .
|
||||
|
||||
==============================================================================
|
||||
vim:tw=78:ts=8:ft=help:norl:
|
||||
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
:AcpDisable acp.txt /*:AcpDisable*
|
||||
:AcpEnable acp.txt /*:AcpEnable*
|
||||
:AcpLock acp.txt /*:AcpLock*
|
||||
:AcpUnlock acp.txt /*:AcpUnlock*
|
||||
acp acp.txt /*acp*
|
||||
acp-about acp.txt /*acp-about*
|
||||
acp-author acp.txt /*acp-author*
|
||||
acp-changelog acp.txt /*acp-changelog*
|
||||
acp-commands acp.txt /*acp-commands*
|
||||
acp-contact acp.txt /*acp-contact*
|
||||
acp-installation acp.txt /*acp-installation*
|
||||
acp-introduction acp.txt /*acp-introduction*
|
||||
acp-options acp.txt /*acp-options*
|
||||
acp-perl-omni acp.txt /*acp-perl-omni*
|
||||
acp-snipMate acp.txt /*acp-snipMate*
|
||||
acp-thanks acp.txt /*acp-thanks*
|
||||
acp-usage acp.txt /*acp-usage*
|
||||
acp.txt acp.txt /*acp.txt*
|
||||
autocomplpop acp.txt /*autocomplpop*
|
||||
g:acp_behavior acp.txt /*g:acp_behavior*
|
||||
g:acp_behavior-command acp.txt /*g:acp_behavior-command*
|
||||
g:acp_behavior-completefunc acp.txt /*g:acp_behavior-completefunc*
|
||||
g:acp_behavior-meets acp.txt /*g:acp_behavior-meets*
|
||||
g:acp_behavior-onPopupClose acp.txt /*g:acp_behavior-onPopupClose*
|
||||
g:acp_behavior-repeat acp.txt /*g:acp_behavior-repeat*
|
||||
g:acp_behaviorCssOmniPropertyLength acp.txt /*g:acp_behaviorCssOmniPropertyLength*
|
||||
g:acp_behaviorCssOmniValueLength acp.txt /*g:acp_behaviorCssOmniValueLength*
|
||||
g:acp_behaviorFileLength acp.txt /*g:acp_behaviorFileLength*
|
||||
g:acp_behaviorHtmlOmniLength acp.txt /*g:acp_behaviorHtmlOmniLength*
|
||||
g:acp_behaviorKeywordCommand acp.txt /*g:acp_behaviorKeywordCommand*
|
||||
g:acp_behaviorKeywordIgnores acp.txt /*g:acp_behaviorKeywordIgnores*
|
||||
g:acp_behaviorKeywordLength acp.txt /*g:acp_behaviorKeywordLength*
|
||||
g:acp_behaviorPerlOmniLength acp.txt /*g:acp_behaviorPerlOmniLength*
|
||||
g:acp_behaviorPythonOmniLength acp.txt /*g:acp_behaviorPythonOmniLength*
|
||||
g:acp_behaviorRubyOmniMethodLength acp.txt /*g:acp_behaviorRubyOmniMethodLength*
|
||||
g:acp_behaviorRubyOmniSymbolLength acp.txt /*g:acp_behaviorRubyOmniSymbolLength*
|
||||
g:acp_behaviorSnipmateLength acp.txt /*g:acp_behaviorSnipmateLength*
|
||||
g:acp_behaviorUserDefinedFunction acp.txt /*g:acp_behaviorUserDefinedFunction*
|
||||
g:acp_behaviorUserDefinedMeets acp.txt /*g:acp_behaviorUserDefinedMeets*
|
||||
g:acp_behaviorXmlOmniLength acp.txt /*g:acp_behaviorXmlOmniLength*
|
||||
g:acp_completeOption acp.txt /*g:acp_completeOption*
|
||||
g:acp_completeoptPreview acp.txt /*g:acp_completeoptPreview*
|
||||
g:acp_enableAtStartup acp.txt /*g:acp_enableAtStartup*
|
||||
g:acp_ignorecaseOption acp.txt /*g:acp_ignorecaseOption*
|
||||
g:acp_mappingDriven acp.txt /*g:acp_mappingDriven*
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
!_TAG_FILE_ENCODING utf-8 //
|
||||
:AcpDisable acp.jax /*:AcpDisable*
|
||||
:AcpEnable acp.jax /*:AcpEnable*
|
||||
:AcpLock acp.jax /*:AcpLock*
|
||||
:AcpUnlock acp.jax /*:AcpUnlock*
|
||||
acp acp.jax /*acp*
|
||||
acp-about acp.jax /*acp-about*
|
||||
acp-author acp.jax /*acp-author*
|
||||
acp-commands acp.jax /*acp-commands*
|
||||
acp-contact acp.jax /*acp-contact*
|
||||
acp-installation acp.jax /*acp-installation*
|
||||
acp-introduction acp.jax /*acp-introduction*
|
||||
acp-options acp.jax /*acp-options*
|
||||
acp-perl-omni acp.jax /*acp-perl-omni*
|
||||
acp-snipMate acp.jax /*acp-snipMate*
|
||||
acp-usage acp.jax /*acp-usage*
|
||||
acp.txt acp.jax /*acp.txt*
|
||||
autocomplpop acp.jax /*autocomplpop*
|
||||
g:acp_behavior acp.jax /*g:acp_behavior*
|
||||
g:acp_behavior-command acp.jax /*g:acp_behavior-command*
|
||||
g:acp_behavior-completefunc acp.jax /*g:acp_behavior-completefunc*
|
||||
g:acp_behavior-meets acp.jax /*g:acp_behavior-meets*
|
||||
g:acp_behavior-onPopupClose acp.jax /*g:acp_behavior-onPopupClose*
|
||||
g:acp_behavior-repeat acp.jax /*g:acp_behavior-repeat*
|
||||
g:acp_behaviorCssOmniPropertyLength acp.jax /*g:acp_behaviorCssOmniPropertyLength*
|
||||
g:acp_behaviorCssOmniValueLength acp.jax /*g:acp_behaviorCssOmniValueLength*
|
||||
g:acp_behaviorFileLength acp.jax /*g:acp_behaviorFileLength*
|
||||
g:acp_behaviorHtmlOmniLength acp.jax /*g:acp_behaviorHtmlOmniLength*
|
||||
g:acp_behaviorKeywordCommand acp.jax /*g:acp_behaviorKeywordCommand*
|
||||
g:acp_behaviorKeywordIgnores acp.jax /*g:acp_behaviorKeywordIgnores*
|
||||
g:acp_behaviorKeywordLength acp.jax /*g:acp_behaviorKeywordLength*
|
||||
g:acp_behaviorPerlOmniLength acp.jax /*g:acp_behaviorPerlOmniLength*
|
||||
g:acp_behaviorPythonOmniLength acp.jax /*g:acp_behaviorPythonOmniLength*
|
||||
g:acp_behaviorRubyOmniMethodLength acp.jax /*g:acp_behaviorRubyOmniMethodLength*
|
||||
g:acp_behaviorRubyOmniSymbolLength acp.jax /*g:acp_behaviorRubyOmniSymbolLength*
|
||||
g:acp_behaviorSnipmateLength acp.jax /*g:acp_behaviorSnipmateLength*
|
||||
g:acp_behaviorUserDefinedFunction acp.jax /*g:acp_behaviorUserDefinedFunction*
|
||||
g:acp_behaviorUserDefinedMeets acp.jax /*g:acp_behaviorUserDefinedMeets*
|
||||
g:acp_behaviorXmlOmniLength acp.jax /*g:acp_behaviorXmlOmniLength*
|
||||
g:acp_completeOption acp.jax /*g:acp_completeOption*
|
||||
g:acp_completeoptPreview acp.jax /*g:acp_completeoptPreview*
|
||||
g:acp_enableAtStartup acp.jax /*g:acp_enableAtStartup*
|
||||
g:acp_ignorecaseOption acp.jax /*g:acp_ignorecaseOption*
|
||||
g:acp_mappingDriven acp.jax /*g:acp_mappingDriven*
|
||||
|
|
@ -1,170 +0,0 @@
|
|||
"=============================================================================
|
||||
" Copyright (c) 2007-2009 Takeshi NISHIDA
|
||||
"
|
||||
" GetLatestVimScripts: 1879 1 :AutoInstall: AutoComplPop
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if exists('g:loaded_acp')
|
||||
finish
|
||||
elseif v:version < 702
|
||||
echoerr 'AutoComplPop does not support this version of vim (' . v:version . ').'
|
||||
finish
|
||||
endif
|
||||
let g:loaded_acp = 1
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" FUNCTION: {{{1
|
||||
|
||||
"
|
||||
function s:defineOption(name, default)
|
||||
if !exists(a:name)
|
||||
let {a:name} = a:default
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:makeDefaultBehavior()
|
||||
let behavs = {
|
||||
\ '*' : [],
|
||||
\ 'ruby' : [],
|
||||
\ 'python' : [],
|
||||
\ 'perl' : [],
|
||||
\ 'xml' : [],
|
||||
\ 'html' : [],
|
||||
\ 'xhtml' : [],
|
||||
\ 'css' : [],
|
||||
\ }
|
||||
"---------------------------------------------------------------------------
|
||||
if !empty(g:acp_behaviorUserDefinedFunction) &&
|
||||
\ !empty(g:acp_behaviorUserDefinedMeets)
|
||||
for key in keys(behavs)
|
||||
call add(behavs[key], {
|
||||
\ 'command' : "\<C-x>\<C-u>",
|
||||
\ 'completefunc' : g:acp_behaviorUserDefinedFunction,
|
||||
\ 'meets' : g:acp_behaviorUserDefinedMeets,
|
||||
\ 'repeat' : 0,
|
||||
\ })
|
||||
endfor
|
||||
endif
|
||||
"---------------------------------------------------------------------------
|
||||
for key in keys(behavs)
|
||||
call add(behavs[key], {
|
||||
\ 'command' : "\<C-x>\<C-u>",
|
||||
\ 'completefunc' : 'acp#completeSnipmate',
|
||||
\ 'meets' : 'acp#meetsForSnipmate',
|
||||
\ 'onPopupClose' : 'acp#onPopupCloseSnipmate',
|
||||
\ 'repeat' : 0,
|
||||
\ })
|
||||
endfor
|
||||
"---------------------------------------------------------------------------
|
||||
for key in keys(behavs)
|
||||
call add(behavs[key], {
|
||||
\ 'command' : g:acp_behaviorKeywordCommand,
|
||||
\ 'meets' : 'acp#meetsForKeyword',
|
||||
\ 'repeat' : 0,
|
||||
\ })
|
||||
endfor
|
||||
"---------------------------------------------------------------------------
|
||||
for key in keys(behavs)
|
||||
call add(behavs[key], {
|
||||
\ 'command' : "\<C-x>\<C-f>",
|
||||
\ 'meets' : 'acp#meetsForFile',
|
||||
\ 'repeat' : 1,
|
||||
\ })
|
||||
endfor
|
||||
"---------------------------------------------------------------------------
|
||||
call add(behavs.ruby, {
|
||||
\ 'command' : "\<C-x>\<C-o>",
|
||||
\ 'meets' : 'acp#meetsForRubyOmni',
|
||||
\ 'repeat' : 0,
|
||||
\ })
|
||||
"---------------------------------------------------------------------------
|
||||
call add(behavs.python, {
|
||||
\ 'command' : "\<C-x>\<C-o>",
|
||||
\ 'meets' : 'acp#meetsForPythonOmni',
|
||||
\ 'repeat' : 0,
|
||||
\ })
|
||||
"---------------------------------------------------------------------------
|
||||
call add(behavs.perl, {
|
||||
\ 'command' : "\<C-x>\<C-o>",
|
||||
\ 'meets' : 'acp#meetsForPerlOmni',
|
||||
\ 'repeat' : 0,
|
||||
\ })
|
||||
"---------------------------------------------------------------------------
|
||||
call add(behavs.xml, {
|
||||
\ 'command' : "\<C-x>\<C-o>",
|
||||
\ 'meets' : 'acp#meetsForXmlOmni',
|
||||
\ 'repeat' : 1,
|
||||
\ })
|
||||
"---------------------------------------------------------------------------
|
||||
call add(behavs.html, {
|
||||
\ 'command' : "\<C-x>\<C-o>",
|
||||
\ 'meets' : 'acp#meetsForHtmlOmni',
|
||||
\ 'repeat' : 1,
|
||||
\ })
|
||||
"---------------------------------------------------------------------------
|
||||
call add(behavs.xhtml, {
|
||||
\ 'command' : "\<C-x>\<C-o>",
|
||||
\ 'meets' : 'acp#meetsForHtmlOmni',
|
||||
\ 'repeat' : 1,
|
||||
\ })
|
||||
"---------------------------------------------------------------------------
|
||||
call add(behavs.css, {
|
||||
\ 'command' : "\<C-x>\<C-o>",
|
||||
\ 'meets' : 'acp#meetsForCssOmni',
|
||||
\ 'repeat' : 0,
|
||||
\ })
|
||||
"---------------------------------------------------------------------------
|
||||
return behavs
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" INITIALIZATION {{{1
|
||||
|
||||
"-----------------------------------------------------------------------------
|
||||
call s:defineOption('g:acp_enableAtStartup', 1)
|
||||
call s:defineOption('g:acp_mappingDriven', 0)
|
||||
call s:defineOption('g:acp_ignorecaseOption', 1)
|
||||
call s:defineOption('g:acp_completeOption', '.,w,b,k')
|
||||
call s:defineOption('g:acp_completeoptPreview', 0)
|
||||
call s:defineOption('g:acp_behaviorUserDefinedFunction', '')
|
||||
call s:defineOption('g:acp_behaviorUserDefinedMeets', '')
|
||||
call s:defineOption('g:acp_behaviorSnipmateLength', -1)
|
||||
call s:defineOption('g:acp_behaviorKeywordCommand', "\<C-n>")
|
||||
call s:defineOption('g:acp_behaviorKeywordLength', 2)
|
||||
call s:defineOption('g:acp_behaviorKeywordIgnores', [])
|
||||
call s:defineOption('g:acp_behaviorFileLength', 0)
|
||||
call s:defineOption('g:acp_behaviorRubyOmniMethodLength', 0)
|
||||
call s:defineOption('g:acp_behaviorRubyOmniSymbolLength', 1)
|
||||
call s:defineOption('g:acp_behaviorPythonOmniLength', 0)
|
||||
call s:defineOption('g:acp_behaviorPerlOmniLength', -1)
|
||||
call s:defineOption('g:acp_behaviorXmlOmniLength', 0)
|
||||
call s:defineOption('g:acp_behaviorHtmlOmniLength', 0)
|
||||
call s:defineOption('g:acp_behaviorCssOmniPropertyLength', 1)
|
||||
call s:defineOption('g:acp_behaviorCssOmniValueLength', 0)
|
||||
call s:defineOption('g:acp_behavior', {})
|
||||
"-----------------------------------------------------------------------------
|
||||
call extend(g:acp_behavior, s:makeDefaultBehavior(), 'keep')
|
||||
"-----------------------------------------------------------------------------
|
||||
command! -bar -narg=0 AcpEnable call acp#enable()
|
||||
command! -bar -narg=0 AcpDisable call acp#disable()
|
||||
command! -bar -narg=0 AcpLock call acp#lock()
|
||||
command! -bar -narg=0 AcpUnlock call acp#unlock()
|
||||
"-----------------------------------------------------------------------------
|
||||
" legacy commands
|
||||
command! -bar -narg=0 AutoComplPopEnable AcpEnable
|
||||
command! -bar -narg=0 AutoComplPopDisable AcpDisable
|
||||
command! -bar -narg=0 AutoComplPopLock AcpLock
|
||||
command! -bar -narg=0 AutoComplPopUnlock AcpUnlock
|
||||
"-----------------------------------------------------------------------------
|
||||
if g:acp_enableAtStartup
|
||||
AcpEnable
|
||||
endif
|
||||
"-----------------------------------------------------------------------------
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" vim: set fdm=marker:
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
all : emmet-vim.zip
|
||||
|
||||
remove-zip:
|
||||
-rm doc/tags
|
||||
-rm emmet-vim.zip
|
||||
|
||||
emmet-vim.zip: remove-zip
|
||||
zip -r emmet-vim.zip autoload plugin doc
|
||||
|
||||
release: emmet-vim.zip
|
||||
vimup update-script emmet.vim
|
||||
|
|
@ -1,149 +0,0 @@
|
|||
# Emmet-vim
|
||||
|
||||
[emmet-vim](http://mattn.github.com/emmet-vim) is a vim plug-in
|
||||
which provides support for expanding abbreviations similar to
|
||||
[emmet](http://emmet.io/).
|
||||
|
||||
[](https://bitdeli.com/free "Bitdeli Badge")
|
||||
|
||||

|
||||
|
||||
## Installation
|
||||
|
||||
[Download zip file](http://www.vim.org/scripts/script.php?script_id=2981):
|
||||
|
||||
cd ~/.vim
|
||||
unzip emmet-vim.zip
|
||||
|
||||
To install using pathogen.vim:
|
||||
|
||||
cd ~/.vim/bundle
|
||||
git clone https://github.com/mattn/emmet-vim.git
|
||||
|
||||
To install using [Vundle](https://github.com/gmarik/vundle):
|
||||
|
||||
" add this line to your .vimrc file
|
||||
Plugin 'mattn/emmet-vim'
|
||||
|
||||
To checkout the source from repository:
|
||||
|
||||
cd ~/.vim/bundle
|
||||
git clone https://github.com/mattn/emmet-vim.git
|
||||
|
||||
or:
|
||||
|
||||
git clone https://github.com/mattn/emmet-vim.git
|
||||
cd emmet-vim
|
||||
cp plugin/emmet.vim ~/.vim/plugin/
|
||||
cp autoload/emmet.vim ~/.vim/autoload/
|
||||
cp -a autoload/emmet ~/.vim/autoload/
|
||||
|
||||
|
||||
## Quick Tutorial
|
||||
|
||||
Open or create a New File:
|
||||
|
||||
vim index.html
|
||||
|
||||
Type ("\_" is the cursor position):
|
||||
|
||||
html:5_
|
||||
|
||||
Then type `<c-y>,` (<kbd>Ctrl</kbd><kbd>y</kbd><kbd>,</kbd>), and you should see:
|
||||
|
||||
```html
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title></title>
|
||||
</head>
|
||||
<body>
|
||||
_
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
[More Tutorials](https://raw.github.com/mattn/emmet-vim/master/TUTORIAL)
|
||||
|
||||
|
||||
## Enable in different mode
|
||||
|
||||
If you don't want to enable emmet in all modes,
|
||||
you can use set these options in `vimrc`:
|
||||
|
||||
```vim
|
||||
let g:user_emmet_mode='n' "only enable normal mode functions.
|
||||
let g:user_emmet_mode='inv' "enable all functions, which is equal to
|
||||
let g:user_emmet_mode='a' "enable all function in all mode.
|
||||
```
|
||||
|
||||
## Enable just for html/css
|
||||
|
||||
```vim
|
||||
let g:user_emmet_install_global = 0
|
||||
autocmd FileType html,css EmmetInstall
|
||||
```
|
||||
|
||||
## Redefine trigger key
|
||||
To remap the default `<C-Y>` leader:
|
||||
|
||||
```vim
|
||||
let g:user_emmet_leader_key='<C-Z>'
|
||||
```
|
||||
|
||||
Note that the trailing `,` still needs to be entered, so the new keymap would be `<C-Z>,`.
|
||||
|
||||
## Adding custom snippets
|
||||
If you have installed the [web-api](https://github.com/mattn/webapi-vim) for **emmet-vim** you can also add your own snippets using a custom **snippets.json** file.
|
||||
|
||||
Once you have installed the [web-api](https://github.com/mattn/webapi-vim) add this line to your **.vimrc**:
|
||||
```
|
||||
let g:user_emmet_settings = webapi#json#decode(join(readfile(expand('~/.snippets_custom.json')), "\n"))
|
||||
```
|
||||
You can change the **path** to your **snippets_custom.json** according to your preferences.
|
||||
|
||||
[Here](http://docs.emmet.io/customization/snippets/) you can find instructions about creating your customized **snippets.json** file.
|
||||
|
||||
## Project Authors
|
||||
|
||||
[Yasuhiro Matsumoto](http://mattn.kaoriya.net/)
|
||||
|
||||
## Links
|
||||
|
||||
### Emmet official site:
|
||||
|
||||
* <http://emmet.io/>
|
||||
|
||||
### zen-coding official site:
|
||||
|
||||
* <http://code.google.com/p/zen-coding/>
|
||||
|
||||
### emmet.vim:
|
||||
|
||||
* <http://mattn.github.com/emmet-vim>
|
||||
|
||||
### development repository:
|
||||
|
||||
* <https://github.com/mattn/emmet-vim>
|
||||
|
||||
### my blog posts about zencoding-vim:
|
||||
|
||||
* <http://mattn.kaoriya.net/software/vim/20100222103327.htm>
|
||||
|
||||
* <http://mattn.kaoriya.net/software/vim/20100306021632.htm>
|
||||
|
||||
### Japanese blog posts about zencoding-vim:
|
||||
|
||||
* <http://d.hatena.ne.jp/idesaku/20100424/1272092255>
|
||||
|
||||
* <http://d.hatena.ne.jp/griefworker/20110118/vim_zen_coding>
|
||||
|
||||
* <http://d.hatena.ne.jp/sakurako_s/20110126/1295988873>
|
||||
|
||||
* <http://looxu.blogspot.jp/2010/02/zencodingvimhtml.html>
|
||||
|
||||
### A Chinese translation of the tutorial:
|
||||
|
||||
* <http://www.zfanw.com/blog/zencoding-vim-tutorial-chinese.html>
|
||||
|
||||
|
|
@ -1,212 +0,0 @@
|
|||
Tutorial for Emmet.vim
|
||||
|
||||
mattn <mattn.jp@gmail.com>
|
||||
|
||||
1. Expand an Abbreviation
|
||||
|
||||
Type the abbreviation as 'div>p#foo$*3>a' and type '<c-y>,'.
|
||||
---------------------
|
||||
<div>
|
||||
<p id="foo1">
|
||||
<a href=""></a>
|
||||
</p>
|
||||
<p id="foo2">
|
||||
<a href=""></a>
|
||||
</p>
|
||||
<p id="foo3">
|
||||
<a href=""></a>
|
||||
</p>
|
||||
</div>
|
||||
---------------------
|
||||
|
||||
2. Wrap with an Abbreviation
|
||||
|
||||
Write as below.
|
||||
---------------------
|
||||
test1
|
||||
test2
|
||||
test3
|
||||
---------------------
|
||||
Then do visual select(line wise) and type '<c-y>,'.
|
||||
Once you get to the 'Tag:' prompt, type 'ul>li*'.
|
||||
---------------------
|
||||
<ul>
|
||||
<li>test1</li>
|
||||
<li>test2</li>
|
||||
<li>test3</li>
|
||||
</ul>
|
||||
---------------------
|
||||
|
||||
If you type a tag, such as 'blockquote', then you'll see the following:
|
||||
---------------------
|
||||
<blockquote>
|
||||
test1
|
||||
test2
|
||||
test3
|
||||
</blockquote>
|
||||
---------------------
|
||||
|
||||
3. Balance a Tag Inward
|
||||
|
||||
type '<c-y>d' in insert mode.
|
||||
|
||||
4. Balance a Tag Outward
|
||||
|
||||
type '<c-y>D' in insert mode.
|
||||
|
||||
5. Go to the Next Edit Point
|
||||
|
||||
type '<c-y>n' in insert mode.
|
||||
|
||||
6. Go to the Previous Edit Point
|
||||
|
||||
type '<c-y>N' in insert mode.
|
||||
|
||||
7. Update an <img>’s Size
|
||||
|
||||
Move cursor to the img tag.
|
||||
---------------------
|
||||
<img src="foo.png" />
|
||||
---------------------
|
||||
Type '<c-y>i' on img tag
|
||||
---------------------
|
||||
<img src="foo.png" width="32" height="48" />
|
||||
---------------------
|
||||
|
||||
8. Merge Lines
|
||||
|
||||
select the lines, which include '<li>'
|
||||
---------------------
|
||||
<ul>
|
||||
<li class="list1"></li>
|
||||
<li class="list2"></li>
|
||||
<li class="list3"></li>
|
||||
</ul>
|
||||
---------------------
|
||||
and then type '<c-y>m'
|
||||
---------------------
|
||||
<ul>
|
||||
<li class="list1"></li><li class="list2"></li><li class="list3"></li>
|
||||
</ul>
|
||||
---------------------
|
||||
|
||||
9. Remove a Tag
|
||||
|
||||
Move cursor in block
|
||||
---------------------
|
||||
<div class="foo">
|
||||
<a>cursor is here</a>
|
||||
</div>
|
||||
---------------------
|
||||
Type '<c-y>k' in insert mode.
|
||||
---------------------
|
||||
<div class="foo">
|
||||
|
||||
</div>
|
||||
---------------------
|
||||
|
||||
And type '<c-y>k' in there again.
|
||||
---------------------
|
||||
|
||||
---------------------
|
||||
|
||||
10. Split/Join Tag
|
||||
|
||||
Move the cursor inside block
|
||||
---------------------
|
||||
<div class="foo">
|
||||
cursor is here
|
||||
</div>
|
||||
---------------------
|
||||
Type '<c-y>j' in insert mode.
|
||||
---------------------
|
||||
<div class="foo"/>
|
||||
---------------------
|
||||
|
||||
And then type '<c-y>j' in there again.
|
||||
---------------------
|
||||
<div class="foo">
|
||||
</div>
|
||||
---------------------
|
||||
|
||||
11. Toggle Comment
|
||||
|
||||
Move cursor inside the block
|
||||
---------------------
|
||||
<div>
|
||||
hello world
|
||||
</div>
|
||||
---------------------
|
||||
Type '<c-y>/' in insert mode.
|
||||
---------------------
|
||||
<!-- <div>
|
||||
hello world
|
||||
</div> -->
|
||||
---------------------
|
||||
Type '<c-y>/' in there again.
|
||||
---------------------
|
||||
<div>
|
||||
hello world
|
||||
</div>
|
||||
---------------------
|
||||
|
||||
12. Make an anchor from a URL
|
||||
|
||||
Move cursor to URL
|
||||
---------------------
|
||||
http://www.google.com/
|
||||
---------------------
|
||||
Type '<c-y>a'
|
||||
---------------------
|
||||
<a href="http://www.google.com/">Google</a>
|
||||
---------------------
|
||||
|
||||
13. Make some quoted text from a URL
|
||||
|
||||
Move cursor to the URL
|
||||
---------------------
|
||||
http://github.com/
|
||||
---------------------
|
||||
Type '<c-y>A'
|
||||
---------------------
|
||||
<blockquote class="quote">
|
||||
<a href="http://github.com/">Secure source code hosting and collaborative development - GitHub</a><br />
|
||||
<p>How does it work? Get up and running in seconds by forking a project, pushing an existing repository...</p>
|
||||
<cite>http://github.com/</cite>
|
||||
</blockquote>
|
||||
---------------------
|
||||
|
||||
14. Installing emmet.vim for the language you are using:
|
||||
|
||||
# cd ~/.vim
|
||||
# unzip emmet-vim.zip
|
||||
|
||||
Or if you are using pathogen.vim:
|
||||
|
||||
# cd ~/.vim/bundle # or make directory
|
||||
# unzip /path/to/emmet-vim.zip
|
||||
|
||||
Or if you get the sources from the repository:
|
||||
|
||||
# cd ~/.vim/bundle # or make directory
|
||||
# git clone http://github.com/mattn/emmet-vim.git
|
||||
|
||||
15. Enable emmet.vim for the language you using.
|
||||
|
||||
You can customize the behavior of the languages you are using.
|
||||
|
||||
---------------------
|
||||
# cat >> ~/.vimrc
|
||||
let g:user_emmet_settings = {
|
||||
\ 'php' : {
|
||||
\ 'extends' : 'html',
|
||||
\ 'filters' : 'c',
|
||||
\ },
|
||||
\ 'xml' : {
|
||||
\ 'extends' : 'html',
|
||||
\ },
|
||||
\ 'haml' : {
|
||||
\ 'extends' : 'html',
|
||||
\ },
|
||||
\}
|
||||
---------------------
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,30 +0,0 @@
|
|||
let s:exists = {}
|
||||
function! emmet#lang#exists(type) abort
|
||||
if len(a:type) == 0
|
||||
return 0
|
||||
elseif has_key(s:exists, a:type)
|
||||
return s:exists[a:type]
|
||||
endif
|
||||
let s:exists[a:type] = len(globpath(&rtp, 'autoload/emmet/lang/'.a:type.'.vim')) > 0
|
||||
return s:exists[a:type]
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#type(type) abort
|
||||
let type = a:type
|
||||
let base = type
|
||||
let settings = emmet#getSettings()
|
||||
while base != ''
|
||||
for b in split(base, '\.')
|
||||
if emmet#lang#exists(b)
|
||||
return b
|
||||
endif
|
||||
if has_key(settings, b) && has_key(settings[b], 'extends')
|
||||
let base = settings[b].extends
|
||||
break
|
||||
else
|
||||
let base = ''
|
||||
endif
|
||||
endfor
|
||||
endwhile
|
||||
return 'html'
|
||||
endfunction
|
||||
|
|
@ -1,350 +0,0 @@
|
|||
function! emmet#lang#css#findTokens(str) abort
|
||||
let tmp = substitute(substitute(a:str, '^.*[;{]\s*', '', ''), '}\s*$', '', '')
|
||||
if tmp =~ '/' && tmp =~ '^[a-zA-Z0-9/_.]\+$'
|
||||
" maybe path or something
|
||||
return ''
|
||||
endif
|
||||
return substitute(substitute(a:str, '^.*[;{]\s*', '', ''), '}\s*$', '', '')
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#css#parseIntoTree(abbr, type) abort
|
||||
let abbr = a:abbr
|
||||
let type = a:type
|
||||
let prefix = 0
|
||||
let value = ''
|
||||
|
||||
let indent = emmet#getIndentation(type)
|
||||
let aliases = emmet#getResource(type, 'aliases', {})
|
||||
let snippets = emmet#getResource(type, 'snippets', {})
|
||||
let use_pipe_for_cursor = emmet#getResource(type, 'use_pipe_for_cursor', 1)
|
||||
|
||||
let root = emmet#newNode()
|
||||
|
||||
" emmet
|
||||
let tokens = split(abbr, '+\ze[^+)!]')
|
||||
let block = emmet#util#searchRegion('{', '}')
|
||||
if abbr !~# '^@' && emmet#getBaseType(type) ==# 'css' && type !=# 'sass' && block[0] ==# [0,0] && block[1] ==# [0,0]
|
||||
let current = emmet#newNode()
|
||||
let current.snippet = substitute(abbr, '\s\+$', '', '') . " {\n" . indent . "${cursor}\n}"
|
||||
let current.name = ''
|
||||
call add(root.child, deepcopy(current))
|
||||
else
|
||||
for n in range(len(tokens))
|
||||
let token = tokens[n]
|
||||
let prop = matchlist(token, '^\(-\{0,1}[a-zA-Z]\+\|[a-zA-Z0-9]\++\{0,1}\|([a-zA-Z0-9]\++\{0,1})\)\(\%([0-9.-]\+\%(p\|e\|em\|re\|rem\|%\)\{0,1}-\{0,1}\|-auto\)*\)$')
|
||||
if len(prop)
|
||||
let token = substitute(prop[1], '^(\(.*\))', '\1', '')
|
||||
if token =~# '^-'
|
||||
let prefix = 1
|
||||
let token = token[1:]
|
||||
endif
|
||||
let value = ''
|
||||
for v in split(prop[2], '\d\zs-')
|
||||
if len(value) > 0
|
||||
let value .= ' '
|
||||
endif
|
||||
if token =~# '^[z]'
|
||||
" TODO
|
||||
let value .= substitute(v, '[^0-9.]*$', '', '')
|
||||
elseif v =~# 'p$'
|
||||
let value .= substitute(v, 'p$', '%', '')
|
||||
elseif v =~# '%$'
|
||||
let value .= v
|
||||
elseif v =~# 'e$'
|
||||
let value .= substitute(v, 'e$', 'em', '')
|
||||
elseif v =~# 'em$'
|
||||
let value .= v
|
||||
elseif v =~# 're$'
|
||||
let value .= substitute(v, 're$', 'rem', '')
|
||||
elseif v =~# 'rem$'
|
||||
let value .= v
|
||||
elseif v =~# '\.'
|
||||
let value .= v . 'em'
|
||||
elseif v ==# 'auto'
|
||||
let value .= v
|
||||
elseif v ==# '0'
|
||||
let value .= '0'
|
||||
else
|
||||
let value .= v . 'px'
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
|
||||
let tag_name = token
|
||||
if tag_name =~# '.!$'
|
||||
let tag_name = tag_name[:-2]
|
||||
let important = 1
|
||||
else
|
||||
let important = 0
|
||||
endif
|
||||
" make default node
|
||||
let current = emmet#newNode()
|
||||
let current.important = important
|
||||
let current.name = tag_name
|
||||
|
||||
" aliases
|
||||
if has_key(aliases, tag_name)
|
||||
let current.name = aliases[tag_name]
|
||||
endif
|
||||
|
||||
" snippets
|
||||
if !empty(snippets)
|
||||
let snippet_name = tag_name
|
||||
if !has_key(snippets, snippet_name)
|
||||
let pat = '^' . join(split(tag_name, '\zs'), '\%(\|[^:-]\+-\)')
|
||||
let vv = filter(sort(keys(snippets)), 'snippets[v:val] =~ pat')
|
||||
if len(vv) > 0
|
||||
let snippet_name = vv[0]
|
||||
else
|
||||
let pat = '^' . join(split(tag_name, '\zs'), '\%(\|[^:-]\+-*\)')
|
||||
let vv = filter(sort(keys(snippets)), 'snippets[v:val] =~ pat')
|
||||
if len(vv) == 0
|
||||
let pat = '^' . join(split(tag_name, '\zs'), '[^:]\{-}')
|
||||
let vv = filter(sort(keys(snippets)), 'snippets[v:val] =~ pat')
|
||||
if len(vv) == 0
|
||||
let pat = '^' . join(split(tag_name, '\zs'), '.\{-}')
|
||||
let vv = filter(sort(keys(snippets)), 'snippets[v:val] =~ pat')
|
||||
endif
|
||||
endif
|
||||
let minl = -1
|
||||
for vk in vv
|
||||
let vvs = snippets[vk]
|
||||
if minl == -1 || len(vvs) < minl
|
||||
let snippet_name = vk
|
||||
let minl = len(vvs)
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
endif
|
||||
if has_key(snippets, snippet_name)
|
||||
let snippet = snippets[snippet_name]
|
||||
if use_pipe_for_cursor
|
||||
let snippet = substitute(snippet, '|', '${cursor}', 'g')
|
||||
endif
|
||||
let lines = split(snippet, "\n")
|
||||
call map(lines, 'substitute(v:val, "\\( \\|\\t\\)", escape(indent, "\\\\"), "g")')
|
||||
let current.snippet = join(lines, "\n")
|
||||
let current.name = ''
|
||||
let current.snippet = substitute(current.snippet, ';', value . ';', '')
|
||||
if use_pipe_for_cursor && len(value) > 0
|
||||
let current.snippet = substitute(current.snippet, '\${cursor}', '', 'g')
|
||||
endif
|
||||
if n < len(tokens) - 1
|
||||
let current.snippet .= "\n"
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
let current.pos = 0
|
||||
let lg = matchlist(token, '^\%(linear-gradient\|lg\)(\s*\(\S\+\)\s*,\s*\([^,]\+\)\s*,\s*\([^)]\+\)\s*)$')
|
||||
if len(lg) == 0
|
||||
let lg = matchlist(token, '^\%(linear-gradient\|lg\)(\s*\(\S\+\)\s*,\s*\([^,]\+\)\s*)$')
|
||||
if len(lg)
|
||||
let [lg[1], lg[2], lg[3]] = ['linear', lg[1], lg[2]]
|
||||
endif
|
||||
endif
|
||||
if len(lg)
|
||||
let current.name = ''
|
||||
let current.snippet = printf("background-image:-webkit-gradient(%s, 0 0, 0 100%, from(%s), to(%s));\n", lg[1], lg[2], lg[3])
|
||||
call add(root.child, deepcopy(current))
|
||||
let current.snippet = printf("background-image:-webkit-linear-gradient(%s, %s);\n", lg[2], lg[3])
|
||||
call add(root.child, deepcopy(current))
|
||||
let current.snippet = printf("background-image:-moz-linear-gradient(%s, %s);\n", lg[2], lg[3])
|
||||
call add(root.child, deepcopy(current))
|
||||
let current.snippet = printf("background-image:-o-linear-gradient(%s, %s);\n", lg[2], lg[3])
|
||||
call add(root.child, deepcopy(current))
|
||||
let current.snippet = printf("background-image:linear-gradient(%s, %s);\n", lg[2], lg[3])
|
||||
call add(root.child, deepcopy(current))
|
||||
elseif prefix
|
||||
let snippet = current.snippet
|
||||
let current.snippet = '-webkit-' . snippet . "\n"
|
||||
call add(root.child, deepcopy(current))
|
||||
let current.snippet = '-moz-' . snippet . "\n"
|
||||
call add(root.child, deepcopy(current))
|
||||
let current.snippet = '-o-' . snippet . "\n"
|
||||
call add(root.child, deepcopy(current))
|
||||
let current.snippet = '-ms-' . snippet . "\n"
|
||||
call add(root.child, deepcopy(current))
|
||||
let current.snippet = snippet
|
||||
call add(root.child, current)
|
||||
elseif token =~# '^c#\([0-9a-fA-F]\{3}\|[0-9a-fA-F]\{6}\)\(\.[0-9]\+\)\?'
|
||||
let cs = split(token, '\.')
|
||||
let current.name = ''
|
||||
let [r,g,b] = [0,0,0]
|
||||
if len(cs[0]) == 5
|
||||
let rgb = matchlist(cs[0], 'c#\(.\)\(.\)\(.\)')
|
||||
let r = eval('0x'.rgb[1].rgb[1])
|
||||
let g = eval('0x'.rgb[2].rgb[2])
|
||||
let b = eval('0x'.rgb[3].rgb[3])
|
||||
elseif len(cs[0]) == 8
|
||||
let rgb = matchlist(cs[0], 'c#\(..\)\(..\)\(..\)')
|
||||
let r = eval('0x'.rgb[1])
|
||||
let g = eval('0x'.rgb[2])
|
||||
let b = eval('0x'.rgb[3])
|
||||
endif
|
||||
if len(cs) == 1
|
||||
let current.snippet = printf('color:rgb(%d, %d, %d);', r, g, b)
|
||||
else
|
||||
let current.snippet = printf('color:rgb(%d, %d, %d, %s);', r, g, b, string(str2float('0.'.cs[1])))
|
||||
endif
|
||||
call add(root.child, current)
|
||||
elseif token =~# '^c#'
|
||||
let current.name = ''
|
||||
let current.snippet = 'color:\${cursor};'
|
||||
call add(root.child, current)
|
||||
else
|
||||
call add(root.child, current)
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
return root
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#css#toString(settings, current, type, inline, filters, itemno, indent) abort
|
||||
let current = a:current
|
||||
let value = current.value[1:-2]
|
||||
let tmp = substitute(value, '\${cursor}', '', 'g')
|
||||
if tmp !~ '.*{[ \t\r\n]*}$'
|
||||
if emmet#useFilter(a:filters, 'fc')
|
||||
let value = substitute(value, '\([^:]\+\):\([^;]*\)', '\1: \2', 'g')
|
||||
else
|
||||
let value = substitute(value, '\([^:]\+\):\([^;]*\)', '\1:\2', 'g')
|
||||
endif
|
||||
if current.important
|
||||
let value = substitute(value, ';', ' !important;', '')
|
||||
endif
|
||||
endif
|
||||
return value
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#css#imageSize() abort
|
||||
let img_region = emmet#util#searchRegion('{', '}')
|
||||
if !emmet#util#regionIsValid(img_region) || !emmet#util#cursorInRegion(img_region)
|
||||
return
|
||||
endif
|
||||
let content = emmet#util#getContent(img_region)
|
||||
let fn = matchstr(content, '\<url(\zs[^)]\+\ze)')
|
||||
let fn = substitute(fn, '[''" \t]', '', 'g')
|
||||
if fn =~# '^\s*$'
|
||||
return
|
||||
elseif fn !~# '^\(/\|http\)'
|
||||
let fn = simplify(expand('%:h') . '/' . fn)
|
||||
endif
|
||||
let [width, height] = emmet#util#getImageSize(fn)
|
||||
if width == -1 && height == -1
|
||||
return
|
||||
endif
|
||||
let indent = emmet#getIndentation('css')
|
||||
if content =~# '.*\<width\s*:[^;]*;.*'
|
||||
let content = substitute(content, '\<width\s*:[^;]*;', 'width: ' . width . 'px;', '')
|
||||
else
|
||||
let content = substitute(content, '}', indent . 'width: ' . width . "px;\n}", '')
|
||||
endif
|
||||
if content =~# '.*\<height\s*:[^;]*;.*'
|
||||
let content = substitute(content, '\<height\s*:[^;]*;', 'height: ' . height . 'px;', '')
|
||||
else
|
||||
let content = substitute(content, '}', indent . 'height: ' . height . "px;\n}", '')
|
||||
endif
|
||||
call emmet#util#setContent(img_region, content)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#css#encodeImage() abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#css#parseTag(tag) abort
|
||||
return {}
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#css#toggleComment() abort
|
||||
let line = getline('.')
|
||||
let mx = '^\(\s*\)/\*\s*\(.*\)\s*\*/\s*$'
|
||||
if line =~# '{\s*$'
|
||||
let block = emmet#util#searchRegion('/\*', '\*/\zs')
|
||||
if emmet#util#regionIsValid(block)
|
||||
let content = emmet#util#getContent(block)
|
||||
let content = substitute(content, '/\*\s\(.*\)\s\*/', '\1', '')
|
||||
call emmet#util#setContent(block, content)
|
||||
else
|
||||
let node = expand('<cword>')
|
||||
if len(node)
|
||||
exe "normal ciw\<c-r>='/* '.node.' */'\<cr>"
|
||||
endif
|
||||
endif
|
||||
else
|
||||
if line =~# mx
|
||||
let space = substitute(matchstr(line, mx), mx, '\1', '')
|
||||
let line = substitute(matchstr(line, mx), mx, '\2', '')
|
||||
let line = space . substitute(line, '^\s*\|\s*$', '\1', 'g')
|
||||
else
|
||||
let mx = '^\(\s*\)\(.*\)\s*$'
|
||||
let line = substitute(line, mx, '\1/* \2 */', '')
|
||||
endif
|
||||
call setline('.', line)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#css#balanceTag(flag) range abort
|
||||
if a:flag == -2 || a:flag == 2
|
||||
let curpos = [0, line("'<"), col("'<"), 0]
|
||||
else
|
||||
let curpos = emmet#util#getcurpos()
|
||||
endif
|
||||
let block = emmet#util#getVisualBlock()
|
||||
if !emmet#util#regionIsValid(block)
|
||||
if a:flag > 0
|
||||
let block = emmet#util#searchRegion('^', ';')
|
||||
if emmet#util#regionIsValid(block)
|
||||
call emmet#util#selectRegion(block)
|
||||
return
|
||||
endif
|
||||
endif
|
||||
else
|
||||
if a:flag > 0
|
||||
let content = emmet#util#getContent(block)
|
||||
if content !~# '^{.*}$'
|
||||
let block = emmet#util#searchRegion('{', '}')
|
||||
if emmet#util#regionIsValid(block)
|
||||
call emmet#util#selectRegion(block)
|
||||
return
|
||||
endif
|
||||
endif
|
||||
else
|
||||
let pos = searchpos('.*;', 'nW')
|
||||
if pos[0] != 0
|
||||
call setpos('.', [0, pos[0], pos[1], 0])
|
||||
let block = emmet#util#searchRegion('^', ';')
|
||||
if emmet#util#regionIsValid(block)
|
||||
call emmet#util#selectRegion(block)
|
||||
return
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
if a:flag == -2 || a:flag == 2
|
||||
silent! exe 'normal! gv'
|
||||
else
|
||||
call setpos('.', curpos)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#css#moveNextPrevItem(flag) abort
|
||||
return emmet#lang#css#moveNextPrev(a:flag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#css#moveNextPrev(flag) abort
|
||||
let pos = search('""\|()\|\(:\s*\zs$\)', a:flag ? 'Wbp' : 'Wp')
|
||||
if pos == 2
|
||||
startinsert!
|
||||
else
|
||||
silent! normal! l
|
||||
startinsert
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#css#splitJoinTag() abort
|
||||
" nothing to do
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#css#removeTag() abort
|
||||
" nothing to do
|
||||
endfunction
|
||||
|
|
@ -1,214 +0,0 @@
|
|||
function! emmet#lang#elm#findTokens(str) abort
|
||||
return emmet#lang#html#findTokens(a:str)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#elm#parseIntoTree(abbr, type) abort
|
||||
let tree = emmet#lang#html#parseIntoTree(a:abbr, a:type)
|
||||
if len(tree.child) < 2 | return tree | endif
|
||||
|
||||
" Add ',' nodes between root elements.
|
||||
let new_children = []
|
||||
for child in tree.child[0:-2]
|
||||
let comma = emmet#newNode()
|
||||
let comma.name = ','
|
||||
call add(new_children, child)
|
||||
call add(new_children, comma)
|
||||
endfor
|
||||
call add(new_children, tree.child[-1])
|
||||
let tree.child = new_children
|
||||
return tree
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#elm#renderNode(node)
|
||||
let elm_nodes = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'
|
||||
\, 'div', 'p', 'hr', 'pre', 'blockquote'
|
||||
\, 'span', 'a', 'code', 'em', 'strong', 'i', 'b', 'u', 'sub', 'sup', 'br'
|
||||
\, 'ol', 'ul', 'li', 'dl', 'dt', 'dd'
|
||||
\, 'img', 'iframe', 'canvas', 'math'
|
||||
\, 'form', 'input', 'textarea', 'button', 'select', 'option'
|
||||
\, 'section', 'nav', 'article', 'aside', 'header', 'footer', 'address', 'main_', 'body'
|
||||
\, 'figure', 'figcaption'
|
||||
\, 'table', 'caption', 'colgroup', 'col', 'tbody', 'thead', 'tfoot', 'tr', 'td', 'th'
|
||||
\, 'fieldset', 'legend', 'label', 'datalist', 'optgroup', 'keygen', 'output', 'progress', 'meter'
|
||||
\, 'audio', 'video', 'source', 'track'
|
||||
\, 'embed', 'object', 'param'
|
||||
\, 'ins', 'del'
|
||||
\, 'small', 'cite', 'dfn', 'abbr', 'time', 'var', 'samp', 'kbd', 's', 'q'
|
||||
\, 'mark', 'ruby', 'rt', 'rp', 'bdi', 'bdo', 'wbr'
|
||||
\, 'details', 'summary', 'menuitem', 'menu']
|
||||
|
||||
if index(elm_nodes, a:node) >= 0
|
||||
return a:node
|
||||
endif
|
||||
return 'node "' . a:node . '"'
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#elm#renderParam(param)
|
||||
let elm_events = ["onClick", "onDoubleClick"
|
||||
\, "onMouseDown", "onMouseUp"
|
||||
\, "onMouseEnter", "onMouseLeave"
|
||||
\, "onMouseOver", "onMouseOut"
|
||||
\, "onInput", "onCheck", "onSubmit"
|
||||
\, "onBlur", "onFocus"
|
||||
\, "on", "onWithOptions", "Options", "defaultOptions"
|
||||
\, "targetValue", "targetChecked", "keyCode"]
|
||||
if index(elm_events, a:param) >= 0
|
||||
return a:param
|
||||
endif
|
||||
let elm_attributes = ["style", "map" , "class", "id", "title", "hidden"
|
||||
\, "type", "type_", "value", "defaultValue", "checked", "placeholder", "selected"
|
||||
\, "accept", "acceptCharset", "action", "autocomplete", "autofocus"
|
||||
\, "disabled", "enctype", "formaction", "list", "maxlength", "minlength", "method", "multiple"
|
||||
\, "name", "novalidate", "pattern", "readonly", "required", "size", "for", "form"
|
||||
\, "max", "min", "step"
|
||||
\, "cols", "rows", "wrap"
|
||||
\, "href", "target", "download", "downloadAs", "hreflang", "media", "ping", "rel"
|
||||
\, "ismap", "usemap", "shape", "coords"
|
||||
\, "src", "height", "width", "alt"
|
||||
\, "autoplay", "controls", "loop", "preload", "poster", "default", "kind", "srclang"
|
||||
\, "sandbox", "seamless", "srcdoc"
|
||||
\, "reversed", "start"
|
||||
\, "align", "colspan", "rowspan", "headers", "scope"
|
||||
\, "async", "charset", "content", "defer", "httpEquiv", "language", "scoped"
|
||||
\, "accesskey", "contenteditable", "contextmenu", "dir", "draggable", "dropzone"
|
||||
\, "itemprop", "lang", "spellcheck", "tabindex"
|
||||
\, "challenge", "keytype"
|
||||
\, "cite", "datetime", "pubdate", "manifest"]
|
||||
|
||||
if index(elm_attributes, a:param) >= 0
|
||||
if a:param == 'type'
|
||||
return 'type_'
|
||||
endif
|
||||
return a:param
|
||||
endif
|
||||
return 'attribute "' . a:param . '"'
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#elm#toString(settings, current, type, inline, filters, itemno, indent) abort
|
||||
let settings = a:settings
|
||||
let current = a:current
|
||||
let type = a:type
|
||||
let inline = a:inline
|
||||
let filters = a:filters
|
||||
let itemno = a:itemno
|
||||
let indent = emmet#getIndentation(type)
|
||||
let dollar_expr = emmet#getResource(type, 'dollar_expr', 1)
|
||||
let str = ''
|
||||
|
||||
" comma between items with *, eg. li*3
|
||||
if itemno > 0
|
||||
let str = ", "
|
||||
endif
|
||||
|
||||
let current_name = current.name
|
||||
if dollar_expr
|
||||
let current_name = substitute(current.name, '\$$', itemno+1, '')
|
||||
endif
|
||||
|
||||
if len(current.name) > 0
|
||||
" inserted root comma nodes
|
||||
if current_name == ','
|
||||
return "\n, "
|
||||
endif
|
||||
let str .= emmet#lang#elm#renderNode(current_name)
|
||||
let tmp = ''
|
||||
for attr in emmet#util#unique(current.attrs_order + keys(current.attr))
|
||||
if !has_key(current.attr, attr)
|
||||
continue
|
||||
endif
|
||||
let Val = current.attr[attr]
|
||||
|
||||
let attr = emmet#lang#elm#renderParam(attr)
|
||||
|
||||
if type(Val) == 2 && Val == function('emmet#types#true')
|
||||
let tmp .= ', ' . attr . ' True'
|
||||
else
|
||||
if dollar_expr
|
||||
while Val =~# '\$\([^#{]\|$\)'
|
||||
let Val = substitute(Val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
endwhile
|
||||
let attr = substitute(attr, '\$$', itemno+1, '')
|
||||
endif
|
||||
let valtmp = substitute(Val, '\${cursor}', '', '')
|
||||
if attr ==# 'id' && len(valtmp) > 0
|
||||
let tmp .=', id "' . Val . '"'
|
||||
elseif attr ==# 'class' && len(valtmp) > 0
|
||||
let tmp .= ', class "' . substitute(Val, ' ', '.', 'g') . '"'
|
||||
else
|
||||
let tmp .= ', ' . attr . ' "' . Val . '"'
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
|
||||
if ! len(tmp)
|
||||
let str .= ' []'
|
||||
else
|
||||
let tmp = strpart(tmp, 2)
|
||||
let str .= ' [ ' . tmp . ' ]'
|
||||
endif
|
||||
|
||||
" No children quit early
|
||||
if len(current.child) == 0 && len(current.value) == 0
|
||||
"Place cursor in node with no value or children
|
||||
let str .= ' [${cursor}]'
|
||||
return str
|
||||
endif
|
||||
|
||||
let inner = ''
|
||||
|
||||
" Parent contex text
|
||||
if len(current.value) > 0
|
||||
let text = current.value[1:-2]
|
||||
if dollar_expr
|
||||
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
let text = substitute(text, '\${nr}', "\n", 'g')
|
||||
let text = substitute(text, '\\\$', '$', 'g')
|
||||
" let str = substitute(str, '\$#', text, 'g')
|
||||
let inner .= ', text "' . text . '"'
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
" Has children
|
||||
for child in current.child
|
||||
if len(child.name) == 0 && len(child.value) > 0
|
||||
" Text node
|
||||
let text = child.value[1:-2]
|
||||
if dollar_expr
|
||||
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
let text = substitute(text, '\${nr}', "\n", 'g')
|
||||
let text = substitute(text, '\\\$', '$', 'g')
|
||||
endif
|
||||
let inner .= ', text "' . text . '"'
|
||||
else
|
||||
" Other nodes
|
||||
let inner .= ', ' . emmet#toString(child, type, inline, filters, 0, indent)
|
||||
endif
|
||||
endfor
|
||||
|
||||
let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g')
|
||||
let inner = substitute(inner, "\n" . escape(indent, '\') . '$', '', 'g')
|
||||
let inner = strpart(inner, 2)
|
||||
|
||||
let inner = substitute(inner, ' ', '', 'g')
|
||||
|
||||
if ! len(inner)
|
||||
let str .= ' []'
|
||||
else
|
||||
let str .= ' [ ' . inner . ' ]'
|
||||
endif
|
||||
|
||||
else
|
||||
let str = current.value[1:-2]
|
||||
if dollar_expr
|
||||
let str = substitute(str, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
let str = substitute(str, '\${nr}', "\n", 'g')
|
||||
let str = substitute(str, '\\\$', '$', 'g')
|
||||
endif
|
||||
endif
|
||||
|
||||
let str .= "\n"
|
||||
|
||||
return str
|
||||
|
||||
endfunction
|
||||
|
|
@ -1,334 +0,0 @@
|
|||
function! emmet#lang#haml#findTokens(str) abort
|
||||
return emmet#lang#html#findTokens(a:str)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#haml#parseIntoTree(abbr, type) abort
|
||||
return emmet#lang#html#parseIntoTree(a:abbr, a:type)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#haml#toString(settings, current, type, inline, filters, itemno, indent) abort
|
||||
let settings = a:settings
|
||||
let current = a:current
|
||||
let type = a:type
|
||||
let inline = a:inline
|
||||
let filters = a:filters
|
||||
let itemno = a:itemno
|
||||
let indent = emmet#getIndentation(type)
|
||||
let dollar_expr = emmet#getResource(type, 'dollar_expr', 1)
|
||||
let attribute_style = emmet#getResource('haml', 'attribute_style', 'hash')
|
||||
let str = ''
|
||||
|
||||
let current_name = current.name
|
||||
if dollar_expr
|
||||
let current_name = substitute(current.name, '\$$', itemno+1, '')
|
||||
endif
|
||||
if len(current.name) > 0
|
||||
let str .= '%' . current_name
|
||||
let tmp = ''
|
||||
for attr in emmet#util#unique(current.attrs_order + keys(current.attr))
|
||||
if !has_key(current.attr, attr)
|
||||
continue
|
||||
endif
|
||||
let Val = current.attr[attr]
|
||||
if type(Val) == 2 && Val == function('emmet#types#true')
|
||||
if attribute_style ==# 'hash'
|
||||
let tmp .= ' :' . attr . ' => true'
|
||||
elseif attribute_style ==# 'html'
|
||||
let tmp .= attr . '=true'
|
||||
end
|
||||
else
|
||||
if dollar_expr
|
||||
while Val =~# '\$\([^#{]\|$\)'
|
||||
let Val = substitute(Val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
endwhile
|
||||
let attr = substitute(attr, '\$$', itemno+1, '')
|
||||
endif
|
||||
let valtmp = substitute(Val, '\${cursor}', '', '')
|
||||
if attr ==# 'id' && len(valtmp) > 0
|
||||
let str .= '#' . Val
|
||||
elseif attr ==# 'class' && len(valtmp) > 0
|
||||
let str .= '.' . substitute(Val, ' ', '.', 'g')
|
||||
else
|
||||
if len(tmp) > 0
|
||||
if attribute_style ==# 'hash'
|
||||
let tmp .= ','
|
||||
elseif attribute_style ==# 'html'
|
||||
let tmp .= ' '
|
||||
endif
|
||||
endif
|
||||
if attribute_style ==# 'hash'
|
||||
let tmp .= ' :' . attr . ' => "' . Val . '"'
|
||||
elseif attribute_style ==# 'html'
|
||||
let tmp .= attr . '="' . Val . '"'
|
||||
end
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
if len(tmp)
|
||||
if attribute_style ==# 'hash'
|
||||
let str .= '{' . tmp . ' }'
|
||||
elseif attribute_style ==# 'html'
|
||||
let str .= '(' . tmp . ')'
|
||||
end
|
||||
endif
|
||||
if stridx(','.settings.html.empty_elements.',', ','.current_name.',') != -1 && len(current.value) == 0
|
||||
let str .= '/'
|
||||
endif
|
||||
|
||||
let inner = ''
|
||||
if len(current.value) > 0
|
||||
let text = current.value[1:-2]
|
||||
if dollar_expr
|
||||
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
let text = substitute(text, '\${nr}', "\n", 'g')
|
||||
let text = substitute(text, '\\\$', '$', 'g')
|
||||
let str = substitute(str, '\$#', text, 'g')
|
||||
endif
|
||||
let lines = split(text, "\n")
|
||||
if len(lines) == 1
|
||||
let str .= ' ' . text
|
||||
else
|
||||
for line in lines
|
||||
let str .= "\n" . indent . line . ' |'
|
||||
endfor
|
||||
endif
|
||||
elseif len(current.child) == 0
|
||||
let str .= '${cursor}'
|
||||
endif
|
||||
if len(current.child) == 1 && len(current.child[0].name) == 0
|
||||
let text = current.child[0].value[1:-2]
|
||||
if dollar_expr
|
||||
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
let text = substitute(text, '\${nr}', "\n", 'g')
|
||||
let text = substitute(text, '\\\$', '$', 'g')
|
||||
endif
|
||||
let lines = split(text, "\n")
|
||||
if len(lines) == 1
|
||||
let str .= ' ' . text
|
||||
else
|
||||
for line in lines
|
||||
let str .= "\n" . indent . line . ' |'
|
||||
endfor
|
||||
endif
|
||||
elseif len(current.child) > 0
|
||||
for child in current.child
|
||||
let inner .= emmet#toString(child, type, inline, filters, itemno, indent)
|
||||
endfor
|
||||
let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g')
|
||||
let inner = substitute(inner, "\n" . escape(indent, '\') . '$', '', 'g')
|
||||
let str .= "\n" . indent . inner
|
||||
endif
|
||||
else
|
||||
let str = current.value[1:-2]
|
||||
if dollar_expr
|
||||
let str = substitute(str, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
let str = substitute(str, '\${nr}', "\n", 'g')
|
||||
let str = substitute(str, '\\\$', '$', 'g')
|
||||
endif
|
||||
endif
|
||||
let str .= "\n"
|
||||
return str
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#haml#imageSize() abort
|
||||
let line = getline('.')
|
||||
let current = emmet#lang#haml#parseTag(line)
|
||||
if empty(current) || !has_key(current.attr, 'src')
|
||||
return
|
||||
endif
|
||||
let fn = current.attr.src
|
||||
if fn =~# '^\s*$'
|
||||
return
|
||||
elseif fn !~# '^\(/\|http\)'
|
||||
let fn = simplify(expand('%:h') . '/' . fn)
|
||||
endif
|
||||
|
||||
let [width, height] = emmet#util#getImageSize(fn)
|
||||
if width == -1 && height == -1
|
||||
return
|
||||
endif
|
||||
let current.attr.width = width
|
||||
let current.attr.height = height
|
||||
let current.attrs_order += ['width', 'height']
|
||||
let haml = emmet#toString(current, 'haml', 1)
|
||||
let haml = substitute(haml, '\${cursor}', '', '')
|
||||
call setline('.', substitute(matchstr(line, '^\s*') . haml, "\n", '', 'g'))
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#haml#encodeImage() abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#haml#parseTag(tag) abort
|
||||
let current = emmet#newNode()
|
||||
let mx = '%\([a-zA-Z][a-zA-Z0-9]*\)\s*\%({\(.*\)}\)'
|
||||
let match = matchstr(a:tag, mx)
|
||||
let current.name = substitute(match, mx, '\1', '')
|
||||
let attrs = substitute(match, mx, '\2', '')
|
||||
let mx = '\([a-zA-Z0-9]\+\)\s*=>\s*\%(\([^"'' \t]\+\)\|"\([^"]\{-}\)"\|''\([^'']\{-}\)''\)'
|
||||
while len(attrs) > 0
|
||||
let match = matchstr(attrs, mx)
|
||||
if len(match) ==# 0
|
||||
break
|
||||
endif
|
||||
let attr_match = matchlist(match, mx)
|
||||
let name = attr_match[1]
|
||||
let value = len(attr_match[2]) ? attr_match[2] : attr_match[3]
|
||||
let current.attr[name] = value
|
||||
let current.attrs_order += [name]
|
||||
let attrs = attrs[stridx(attrs, match) + len(match):]
|
||||
endwhile
|
||||
return current
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#haml#toggleComment() abort
|
||||
let line = getline('.')
|
||||
let space = matchstr(line, '^\s*')
|
||||
if line =~# '^\s*-#'
|
||||
call setline('.', space . matchstr(line[len(space)+2:], '^\s*\zs.*'))
|
||||
elseif line =~# '^\s*%[a-z]'
|
||||
call setline('.', space . '-# ' . line[len(space):])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#haml#balanceTag(flag) range abort
|
||||
let block = emmet#util#getVisualBlock()
|
||||
if a:flag == -2 || a:flag == 2
|
||||
let curpos = [0, line("'<"), col("'<"), 0]
|
||||
else
|
||||
let curpos = emmet#util#getcurpos()
|
||||
endif
|
||||
let n = curpos[1]
|
||||
let ml = len(matchstr(getline(n), '^\s*'))
|
||||
|
||||
if a:flag > 0
|
||||
if a:flag == 1 || !emmet#util#regionIsValid(block)
|
||||
let n = line('.')
|
||||
else
|
||||
while n > 0
|
||||
let l = len(matchstr(getline(n), '^\s*\ze%[a-z]'))
|
||||
if l > 0 && l < ml
|
||||
let ml = l
|
||||
break
|
||||
endif
|
||||
let n -= 1
|
||||
endwhile
|
||||
endif
|
||||
let sn = n
|
||||
if n == 0
|
||||
let ml = 0
|
||||
endif
|
||||
while n < line('$')
|
||||
let l = len(matchstr(getline(n), '^\s*%[a-z]'))
|
||||
if l > 0 && l <= ml
|
||||
let n -= 1
|
||||
break
|
||||
endif
|
||||
let n += 1
|
||||
endwhile
|
||||
call setpos('.', [0, n, 1, 0])
|
||||
normal! V
|
||||
call setpos('.', [0, sn, 1, 0])
|
||||
else
|
||||
while n > 0
|
||||
let l = len(matchstr(getline(n), '^\s*\ze[a-z]'))
|
||||
if l > 0 && l > ml
|
||||
let ml = l
|
||||
break
|
||||
endif
|
||||
let n += 1
|
||||
endwhile
|
||||
let sn = n
|
||||
if n == 0
|
||||
let ml = 0
|
||||
endif
|
||||
while n < line('$')
|
||||
let l = len(matchstr(getline(n), '^\s*%[a-z]'))
|
||||
if l > 0 && l <= ml
|
||||
let n -= 1
|
||||
break
|
||||
endif
|
||||
let n += 1
|
||||
endwhile
|
||||
call setpos('.', [0, n, 1, 0])
|
||||
normal! V
|
||||
call setpos('.', [0, sn, 1, 0])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#haml#moveNextPrevItem(flag) abort
|
||||
return emmet#lang#haml#moveNextPrev(a:flag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#haml#moveNextPrev(flag) abort
|
||||
let pos = search('""', a:flag ? 'Wb' : 'W')
|
||||
if pos != 0
|
||||
silent! normal! l
|
||||
startinsert
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#haml#splitJoinTag() abort
|
||||
let n = line('.')
|
||||
let sml = len(matchstr(getline(n), '^\s*%[a-z]'))
|
||||
while n > 0
|
||||
if getline(n) =~# '^\s*\ze%[a-z]'
|
||||
if len(matchstr(getline(n), '^\s*%[a-z]')) < sml
|
||||
break
|
||||
endif
|
||||
let line = getline(n)
|
||||
call setline(n, substitute(line, '^\s*%\w\+\%(\s*{[^}]*}\|\s\)\zs.*', '', ''))
|
||||
let sn = n
|
||||
let n += 1
|
||||
let ml = len(matchstr(getline(n), '^\s*%[a-z]'))
|
||||
if len(matchstr(getline(n), '^\s*')) > ml
|
||||
while n <= line('$')
|
||||
let l = len(matchstr(getline(n), '^\s*'))
|
||||
if l <= ml
|
||||
break
|
||||
endif
|
||||
exe n 'delete'
|
||||
endwhile
|
||||
call setpos('.', [0, sn, 1, 0])
|
||||
else
|
||||
let tag = matchstr(getline(sn), '^\s*%\zs\(\w\+\)')
|
||||
let spaces = matchstr(getline(sn), '^\s*')
|
||||
let settings = emmet#getSettings()
|
||||
if stridx(','.settings.html.inline_elements.',', ','.tag.',') == -1
|
||||
call append(sn, spaces . ' ')
|
||||
call setpos('.', [0, sn+1, 1, 0])
|
||||
else
|
||||
call setpos('.', [0, sn, 1, 0])
|
||||
endif
|
||||
startinsert!
|
||||
endif
|
||||
break
|
||||
endif
|
||||
let n -= 1
|
||||
endwhile
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#haml#removeTag() abort
|
||||
let n = line('.')
|
||||
let ml = 0
|
||||
while n > 0
|
||||
if getline(n) =~# '^\s*\ze[a-z]'
|
||||
let ml = len(matchstr(getline(n), '^\s*%[a-z]'))
|
||||
break
|
||||
endif
|
||||
let n -= 1
|
||||
endwhile
|
||||
let sn = n
|
||||
while n < line('$')
|
||||
let l = len(matchstr(getline(n), '^\s*%[a-z]'))
|
||||
if l > 0 && l <= ml
|
||||
let n -= 1
|
||||
break
|
||||
endif
|
||||
let n += 1
|
||||
endwhile
|
||||
if sn == n
|
||||
exe 'delete'
|
||||
else
|
||||
exe sn ',' (n-1) 'delete'
|
||||
endif
|
||||
endfunction
|
||||
|
|
@ -1,954 +0,0 @@
|
|||
let s:bx = '{\%("[^"]*"\|''[^'']*''\|\$#\|\${\w\+}\|\$\+\|{[^{]\+\|[^{}]\)\{-}}'
|
||||
let s:mx = '\([+>]\|[<^]\+\)\{-}\s*'
|
||||
\ .'\((*\)\{-}\s*'
|
||||
\ .'\([@#.]\{-}[a-zA-Z_\!][a-zA-Z0-9:_\!\-$]*\|' . s:bx . '\|\[[^\]]\+\]\)'
|
||||
\ .'\('
|
||||
\ .'\%('
|
||||
\ .'\%(#{[{}a-zA-Z0-9_\-\$]\+\|#[a-zA-Z0-9_\-\$]\+\)'
|
||||
\ .'\|\%(\[\%("[^"]*"\|[^"\]]*\)\+\]\)'
|
||||
\ .'\|\%(\.{[{}a-zA-Z0-9_\-\$]\+\|\.[a-zA-Z0-9_\-\$]\+\)'
|
||||
\ .'\)*'
|
||||
\ .'\)'
|
||||
\ .'\%(\(' . s:bx . '\+\)\)\{0,1}'
|
||||
\ .'\%(\(@-\{0,1}[0-9]*\)\{0,1}\*\([0-9]\+\)\)\{0,1}'
|
||||
\ .'\(\%()\%(\(@-\{0,1}[0-9]*\)\{0,1}\*[0-9]\+\)\{0,1}\)*\)'
|
||||
|
||||
function! emmet#lang#html#findTokens(str) abort
|
||||
let str = a:str
|
||||
let [pos, last_pos] = [0, 0]
|
||||
while 1
|
||||
let tag = matchstr(str, '<[a-zA-Z].\{-}>', pos)
|
||||
if len(tag) == 0
|
||||
break
|
||||
endif
|
||||
let pos = stridx(str, tag, pos) + len(tag)
|
||||
endwhile
|
||||
while 1
|
||||
let tag = matchstr(str, '{%[^%]\{-}%}', pos)
|
||||
if len(tag) == 0
|
||||
break
|
||||
endif
|
||||
let pos = stridx(str, tag, pos) + len(tag)
|
||||
endwhile
|
||||
let last_pos = pos
|
||||
while len(str) > 0
|
||||
let token = matchstr(str, s:mx, pos)
|
||||
if token ==# ''
|
||||
break
|
||||
endif
|
||||
if token =~# '^\s'
|
||||
let token = matchstr(token, '^\s*\zs.*')
|
||||
let last_pos = stridx(str, token, pos)
|
||||
endif
|
||||
let pos = stridx(str, token, pos) + len(token)
|
||||
endwhile
|
||||
let str = a:str[last_pos :-1]
|
||||
if str =~# '^\w\+="[^"]*$'
|
||||
return ''
|
||||
endif
|
||||
return str
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#html#parseIntoTree(abbr, type) abort
|
||||
let abbr = a:abbr
|
||||
let type = a:type
|
||||
|
||||
let settings = emmet#getSettings()
|
||||
if !has_key(settings, type)
|
||||
let type = 'html'
|
||||
endif
|
||||
if len(type) == 0 | let type = 'html' | endif
|
||||
|
||||
let indent = emmet#getIndentation(type)
|
||||
let pmap = {
|
||||
\'p': 'span',
|
||||
\'ul': 'li',
|
||||
\'ol': 'li',
|
||||
\'table': 'tr',
|
||||
\'tr': 'td',
|
||||
\'tbody': 'tr',
|
||||
\'thead': 'tr',
|
||||
\'tfoot': 'tr',
|
||||
\'colgroup': 'col',
|
||||
\'select': 'option',
|
||||
\'optgroup': 'option',
|
||||
\'audio': 'source',
|
||||
\'video': 'source',
|
||||
\'object': 'param',
|
||||
\'map': 'area'
|
||||
\}
|
||||
|
||||
let inlineLevel = split('a,abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,select,small,span,strike,strong,sub,sup,textarea,tt,u,var',',')
|
||||
|
||||
let custom_expands = emmet#getResource(type, 'custom_expands', {})
|
||||
if empty(custom_expands) && has_key(settings, 'custom_expands')
|
||||
let custom_expands = settings['custom_expands']
|
||||
endif
|
||||
|
||||
" try 'foo' to (foo-x)
|
||||
let rabbr = emmet#getExpandos(type, abbr)
|
||||
if rabbr == abbr
|
||||
" try 'foo+(' to (foo-x)
|
||||
let rabbr = substitute(abbr, '\%(+\|^\)\([a-zA-Z][a-zA-Z0-9+]\+\)+\([(){}>]\|$\)', '\="(".emmet#getExpandos(type, submatch(1)).")".submatch(2)', 'i')
|
||||
endif
|
||||
let abbr = rabbr
|
||||
|
||||
let root = emmet#newNode()
|
||||
let parent = root
|
||||
let last = root
|
||||
let pos = []
|
||||
while len(abbr)
|
||||
" parse line
|
||||
let match = matchstr(abbr, s:mx)
|
||||
let str = substitute(match, s:mx, '\0', 'ig')
|
||||
let operator = substitute(match, s:mx, '\1', 'ig')
|
||||
let block_start = substitute(match, s:mx, '\2', 'ig')
|
||||
let tag_name = substitute(match, s:mx, '\3', 'ig')
|
||||
let attributes = substitute(match, s:mx, '\4', 'ig')
|
||||
let value = substitute(match, s:mx, '\5', 'ig')
|
||||
let basevalue = substitute(match, s:mx, '\6', 'ig')
|
||||
let multiplier = 0 + substitute(match, s:mx, '\7', 'ig')
|
||||
let block_end = substitute(match, s:mx, '\8', 'ig')
|
||||
let custom = ''
|
||||
let important = 0
|
||||
if len(str) == 0
|
||||
break
|
||||
endif
|
||||
if tag_name =~# '^#'
|
||||
let attributes = tag_name . attributes
|
||||
let tag_name = ''
|
||||
endif
|
||||
if tag_name =~# '[^!]!$'
|
||||
let tag_name = tag_name[:-2]
|
||||
let important = 1
|
||||
endif
|
||||
if tag_name =~# '^\.'
|
||||
let attributes = tag_name . attributes
|
||||
let tag_name = ''
|
||||
endif
|
||||
if tag_name =~# '^\[.*\]$'
|
||||
let attributes = tag_name . attributes
|
||||
let tag_name = ''
|
||||
endif
|
||||
|
||||
for k in keys(custom_expands)
|
||||
if tag_name =~ k
|
||||
let custom = tag_name
|
||||
let tag_name = ''
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
|
||||
if empty(tag_name)
|
||||
let pname = len(parent.child) > 0 ? parent.child[0].name : ''
|
||||
if !empty(pname) && has_key(pmap, pname)
|
||||
let tag_name = pmap[pname]
|
||||
elseif !empty(pname) && index(inlineLevel, pname) > -1
|
||||
let tag_name = 'span'
|
||||
elseif len(parent.child) == 0 || len(custom) == 0
|
||||
let tag_name = 'div'
|
||||
else
|
||||
let tag_name = custom
|
||||
endif
|
||||
endif
|
||||
|
||||
let basedirect = basevalue[1] ==# '-' ? -1 : 1
|
||||
let basevalue = 0 + abs(basevalue[1:])
|
||||
if multiplier <= 0 | let multiplier = 1 | endif
|
||||
|
||||
" make default node
|
||||
let current = emmet#newNode()
|
||||
|
||||
let current.name = tag_name
|
||||
let current.important = important
|
||||
|
||||
" aliases
|
||||
let aliases = emmet#getResource(type, 'aliases', {})
|
||||
if has_key(aliases, tag_name)
|
||||
let current.name = aliases[tag_name]
|
||||
endif
|
||||
|
||||
let use_pipe_for_cursor = emmet#getResource(type, 'use_pipe_for_cursor', 1)
|
||||
|
||||
" snippets
|
||||
let snippets = emmet#getResource(type, 'snippets', {})
|
||||
if !empty(snippets)
|
||||
let snippet_name = tag_name
|
||||
if has_key(snippets, snippet_name)
|
||||
let snippet = snippet_name
|
||||
while has_key(snippets, snippet)
|
||||
let snippet = snippets[snippet]
|
||||
endwhile
|
||||
if use_pipe_for_cursor
|
||||
let snippet = substitute(snippet, '|', '${cursor}', 'g')
|
||||
endif
|
||||
" just redirect to expanding
|
||||
if type == 'html' && snippet !~ '^\s*[{\[<]'
|
||||
return emmet#lang#html#parseIntoTree(snippet, a:type)
|
||||
endif
|
||||
let lines = split(snippet, "\n", 1)
|
||||
call map(lines, 'substitute(v:val, "\\( \\|\\t\\)", escape(indent, "\\\\"), "g")')
|
||||
let current.snippet = join(lines, "\n")
|
||||
let current.name = ''
|
||||
endif
|
||||
endif
|
||||
|
||||
for k in keys(custom_expands)
|
||||
if tag_name =~# k
|
||||
let current.snippet = '${' . (empty(custom) ? tag_name : custom) . '}'
|
||||
let current.name = ''
|
||||
break
|
||||
elseif custom =~# k
|
||||
let current.snippet = '${' . custom . '}'
|
||||
let current.name = ''
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
|
||||
" default_attributes
|
||||
let default_attributes = emmet#getResource(type, 'default_attributes', {})
|
||||
if !empty(default_attributes)
|
||||
for pat in [current.name, tag_name]
|
||||
if has_key(default_attributes, pat)
|
||||
if type(default_attributes[pat]) == 4
|
||||
let a = default_attributes[pat]
|
||||
let current.attrs_order += keys(a)
|
||||
if use_pipe_for_cursor
|
||||
for k in keys(a)
|
||||
let current.attr[k] = len(a[k]) ? substitute(a[k], '|', '${cursor}', 'g') : '${cursor}'
|
||||
endfor
|
||||
else
|
||||
for k in keys(a)
|
||||
let current.attr[k] = a[k]
|
||||
endfor
|
||||
endif
|
||||
else
|
||||
for a in default_attributes[pat]
|
||||
let current.attrs_order += keys(a)
|
||||
if use_pipe_for_cursor
|
||||
for k in keys(a)
|
||||
let current.attr[k] = len(a[k]) ? substitute(a[k], '|', '${cursor}', 'g') : '${cursor}'
|
||||
endfor
|
||||
else
|
||||
for k in keys(a)
|
||||
let current.attr[k] = a[k]
|
||||
endfor
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
if has_key(settings.html.default_attributes, current.name)
|
||||
let current.name = substitute(current.name, ':.*$', '', '')
|
||||
endif
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
|
||||
" parse attributes
|
||||
if len(attributes)
|
||||
let attr = attributes
|
||||
while len(attr)
|
||||
let item = matchstr(attr, '\(\%(\%(#[{}a-zA-Z0-9_\-\$]\+\)\|\%(\[\%("[^"]*"\|[^"\]]*\)\+\]\)\|\%(\.[{}a-zA-Z0-9_\-\$]\+\)*\)\)')
|
||||
if g:emmet_debug > 1
|
||||
echomsg 'attr=' . item
|
||||
endif
|
||||
if len(item) == 0
|
||||
break
|
||||
endif
|
||||
if item[0] ==# '#'
|
||||
let current.attr.id = item[1:]
|
||||
endif
|
||||
if item[0] ==# '.'
|
||||
let current.attr.class = substitute(item[1:], '\.', ' ', 'g')
|
||||
endif
|
||||
if item[0] ==# '['
|
||||
let atts = item[1:-2]
|
||||
if matchstr(atts, '^\s*\zs[0-9a-zA-Z_\-:]\+\(="[^"]*"\|=''[^'']*''\|=[^ ''"]\+\)') ==# ''
|
||||
let ks = []
|
||||
if has_key(default_attributes, current.name)
|
||||
let dfa = default_attributes[current.name]
|
||||
let ks = type(dfa) == 3 ? keys(dfa[0]) : keys(dfa)
|
||||
endif
|
||||
if len(ks) == 0 && has_key(default_attributes, current.name . ':src')
|
||||
let ks = keys(default_attributes[current.name . ':src'])
|
||||
endif
|
||||
if len(ks) > 0
|
||||
let current.attr[ks[0]] = atts
|
||||
else
|
||||
let current.attr[atts] = ''
|
||||
endif
|
||||
else
|
||||
while len(atts)
|
||||
let amat = matchstr(atts, '^\s*\zs\([0-9a-zA-Z-:]\+\%(="[^"]*"\|=''[^'']*''\|=[^ ''"]\+\|[^ ''"\]]*\)\{0,1}\)')
|
||||
if len(amat) == 0
|
||||
break
|
||||
endif
|
||||
let key = split(amat, '=')[0]
|
||||
let Val = amat[len(key)+1:]
|
||||
if key =~# '\.$' && Val ==# ''
|
||||
let key = key[:-2]
|
||||
unlet Val
|
||||
let Val = function('emmet#types#true')
|
||||
elseif Val =~# '^["'']'
|
||||
let Val = Val[1:-2]
|
||||
endif
|
||||
let current.attr[key] = Val
|
||||
if index(current.attrs_order, key) == -1
|
||||
let current.attrs_order += [key]
|
||||
endif
|
||||
let atts = atts[stridx(atts, amat) + len(amat):]
|
||||
unlet Val
|
||||
endwhile
|
||||
endif
|
||||
endif
|
||||
let attr = substitute(strpart(attr, len(item)), '^\s*', '', '')
|
||||
endwhile
|
||||
endif
|
||||
|
||||
" parse text
|
||||
if tag_name =~# '^{.*}$'
|
||||
let current.name = ''
|
||||
let current.value = tag_name
|
||||
else
|
||||
let current.value = value
|
||||
endif
|
||||
let current.basedirect = basedirect
|
||||
let current.basevalue = basevalue
|
||||
let current.multiplier = multiplier
|
||||
|
||||
" parse step inside/outside
|
||||
if !empty(last)
|
||||
if operator =~# '>'
|
||||
unlet! parent
|
||||
let parent = last
|
||||
let current.parent = last
|
||||
let current.pos = last.pos + 1
|
||||
else
|
||||
let current.parent = parent
|
||||
let current.pos = last.pos
|
||||
endif
|
||||
else
|
||||
let current.parent = parent
|
||||
let current.pos = 1
|
||||
endif
|
||||
if operator =~# '[<^]'
|
||||
for c in range(len(operator))
|
||||
let tmp = parent.parent
|
||||
if empty(tmp)
|
||||
break
|
||||
endif
|
||||
let parent = tmp
|
||||
let current.parent = tmp
|
||||
endfor
|
||||
endif
|
||||
|
||||
call add(parent.child, current)
|
||||
let last = current
|
||||
|
||||
" parse block
|
||||
if block_start =~# '('
|
||||
if operator =~# '>'
|
||||
let last.pos += 1
|
||||
endif
|
||||
let last.block = 1
|
||||
for n in range(len(block_start))
|
||||
let pos += [last.pos]
|
||||
endfor
|
||||
endif
|
||||
if block_end =~# ')'
|
||||
for n in split(substitute(substitute(block_end, ' ', '', 'g'), ')', ',),', 'g'), ',')
|
||||
if n ==# ')'
|
||||
if len(pos) > 0 && last.pos >= pos[-1]
|
||||
for c in range(last.pos - pos[-1])
|
||||
let tmp = parent.parent
|
||||
if !has_key(tmp, 'parent')
|
||||
break
|
||||
endif
|
||||
let parent = tmp
|
||||
endfor
|
||||
if len(pos) > 0
|
||||
call remove(pos, -1)
|
||||
endif
|
||||
let last = parent
|
||||
let last.pos += 1
|
||||
endif
|
||||
elseif len(n)
|
||||
let st = 0
|
||||
for nc in range(len(last.child))
|
||||
if last.child[nc].block
|
||||
let st = nc
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
let cl = last.child[st :]
|
||||
let cls = []
|
||||
for c in range(n[1:])
|
||||
for cc in cl
|
||||
if cc.multiplier > 1
|
||||
let cc.basedirect = c + 1
|
||||
else
|
||||
let cc.basevalue = c + 1
|
||||
endif
|
||||
endfor
|
||||
let cls += deepcopy(cl)
|
||||
endfor
|
||||
if st > 0
|
||||
let last.child = last.child[:st-1] + cls
|
||||
else
|
||||
let last.child = cls
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
let abbr = abbr[stridx(abbr, match) + len(match):]
|
||||
if abbr == '/'
|
||||
let g:hoge = 1
|
||||
let current.empty = 1
|
||||
endif
|
||||
|
||||
if g:emmet_debug > 1
|
||||
echomsg 'str='.str
|
||||
echomsg 'block_start='.block_start
|
||||
echomsg 'tag_name='.tag_name
|
||||
echomsg 'operator='.operator
|
||||
echomsg 'attributes='.attributes
|
||||
echomsg 'value='.value
|
||||
echomsg 'basevalue='.basevalue
|
||||
echomsg 'multiplier='.multiplier
|
||||
echomsg 'block_end='.block_end
|
||||
echomsg 'abbr='.abbr
|
||||
echomsg 'pos='.string(pos)
|
||||
echomsg '---'
|
||||
endif
|
||||
endwhile
|
||||
return root
|
||||
endfunction
|
||||
|
||||
function! s:dollar_add(base,no) abort
|
||||
if a:base > 0
|
||||
return a:base + a:no - 1
|
||||
elseif a:base < 0
|
||||
return a:base - a:no + 1
|
||||
else
|
||||
return a:no
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#html#toString(settings, current, type, inline, filters, itemno, indent) abort
|
||||
let settings = a:settings
|
||||
let current = a:current
|
||||
let type = a:type
|
||||
let inline = a:inline
|
||||
let filters = a:filters
|
||||
let itemno = a:itemno
|
||||
let indent = a:indent
|
||||
let dollar_expr = emmet#getResource(type, 'dollar_expr', 1)
|
||||
let q = emmet#getResource(type, 'quote_char', '"')
|
||||
let ct = emmet#getResource(type, 'comment_type', 'both')
|
||||
let an = emmet#getResource(type, 'attribute_name', {})
|
||||
let empty_element_suffix = emmet#getResource(type, 'empty_element_suffix', settings.html.empty_element_suffix)
|
||||
|
||||
if emmet#useFilter(filters, 'haml')
|
||||
return emmet#lang#haml#toString(settings, current, type, inline, filters, itemno, indent)
|
||||
endif
|
||||
if emmet#useFilter(filters, 'slim')
|
||||
return emmet#lang#slim#toString(settings, current, type, inline, filters, itemno, indent)
|
||||
endif
|
||||
|
||||
let comment = ''
|
||||
let current_name = current.name
|
||||
if dollar_expr
|
||||
let current_name = substitute(current_name, '\$$', itemno+1, '')
|
||||
endif
|
||||
|
||||
let str = ''
|
||||
if len(current_name) == 0
|
||||
let text = current.value[1:-2]
|
||||
if dollar_expr
|
||||
" TODO: regexp engine specified
|
||||
let nr = itemno + 1
|
||||
if exists('®expengine')
|
||||
let text = substitute(text, '\%#=1\%(\\\)\@\<!\(\$\+\)\(@-\?[0-9]\+\)\{0,1}\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d",s:dollar_add(submatch(2)[1:],nr)).submatch(3)', 'g')
|
||||
else
|
||||
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\(@-\?[0-9]\+\)\{0,1}\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d",s:dollar_add(submatch(2)[1:],nr).submatch(3)', 'g')
|
||||
endif
|
||||
let text = substitute(text, '\${nr}', "\n", 'g')
|
||||
let text = substitute(text, '\\\$', '$', 'g')
|
||||
endif
|
||||
return text
|
||||
endif
|
||||
if len(current_name) > 0
|
||||
let str .= '<' . current_name
|
||||
endif
|
||||
for attr in emmet#util#unique(current.attrs_order + keys(current.attr))
|
||||
if !has_key(current.attr, attr)
|
||||
continue
|
||||
endif
|
||||
let Val = current.attr[attr]
|
||||
if type(Val) == 2 && Val == function('emmet#types#true')
|
||||
unlet Val
|
||||
let Val = 'true'
|
||||
if g:emmet_html5
|
||||
let str .= ' ' . attr
|
||||
else
|
||||
let str .= ' ' . attr . '=' . q . attr . q
|
||||
endif
|
||||
if emmet#useFilter(filters, 'c')
|
||||
if attr ==# 'id' | let comment .= '#' . Val | endif
|
||||
if attr ==# 'class' | let comment .= '.' . Val | endif
|
||||
endif
|
||||
else
|
||||
if dollar_expr
|
||||
while Val =~# '\$\([^#{]\|$\)'
|
||||
" TODO: regexp engine specified
|
||||
if exists('®expengine')
|
||||
let Val = substitute(Val, '\%#=1\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
else
|
||||
let Val = substitute(Val, '\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
endif
|
||||
endwhile
|
||||
let attr = substitute(attr, '\$$', itemno+1, '')
|
||||
endif
|
||||
if attr ==# 'class' && emmet#useFilter(filters, 'bem')
|
||||
let vals = split(Val, '\s\+')
|
||||
let Val = ''
|
||||
let lead = ''
|
||||
for _val in vals
|
||||
if len(Val) > 0
|
||||
let Val .= ' '
|
||||
endif
|
||||
if _val =~# '^_'
|
||||
if has_key(current.parent.attr, 'class')
|
||||
let lead = current.parent.attr["class"]
|
||||
if _val =~# '^__'
|
||||
let Val .= lead . _val
|
||||
else
|
||||
let Val .= lead . ' ' . lead . _val
|
||||
endif
|
||||
else
|
||||
let lead = split(vals[0], '_')[0]
|
||||
let Val .= lead . _val
|
||||
endif
|
||||
elseif _val =~# '^-'
|
||||
for l in split(_val, '_')
|
||||
if len(Val) > 0
|
||||
let Val .= ' '
|
||||
endif
|
||||
let l = substitute(l, '^-', '__', '')
|
||||
if len(lead) == 0
|
||||
let pattr = current.parent.attr
|
||||
if has_key(pattr, 'class')
|
||||
let lead = split(pattr['class'], '\s\+')[0]
|
||||
endif
|
||||
endif
|
||||
let Val .= lead . l
|
||||
let lead .= l . '_'
|
||||
endfor
|
||||
else
|
||||
let Val .= _val
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
if has_key(an, attr)
|
||||
let attr = an[attr]
|
||||
endif
|
||||
if emmet#isExtends(type, 'jsx') && Val =~ '^{.*}$'
|
||||
let str .= ' ' . attr . '=' . Val
|
||||
else
|
||||
let str .= ' ' . attr . '=' . q . Val . q
|
||||
endif
|
||||
if emmet#useFilter(filters, 'c')
|
||||
if attr ==# 'id' | let comment .= '#' . Val | endif
|
||||
if attr ==# 'class' | let comment .= '.' . Val | endif
|
||||
endif
|
||||
endif
|
||||
unlet Val
|
||||
endfor
|
||||
if len(comment) > 0 && ct ==# 'both'
|
||||
let str = '<!-- ' . comment . " -->\n" . str
|
||||
endif
|
||||
if current.empty
|
||||
let str .= ' />'
|
||||
elseif stridx(','.settings.html.empty_elements.',', ','.current_name.',') != -1
|
||||
let str .= empty_element_suffix
|
||||
else
|
||||
let str .= '>'
|
||||
let text = current.value[1:-2]
|
||||
if dollar_expr
|
||||
" TODO: regexp engine specified
|
||||
let nr = itemno + 1
|
||||
if exists('®expengine')
|
||||
let text = substitute(text, '\%#=1\%(\\\)\@\<!\(\$\+\)\(@-\?[0-9]\+\)\{0,1}\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d",s:dollar_add(submatch(2)[1:],nr)).submatch(3)', 'g')
|
||||
else
|
||||
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\(@-\?[0-9]\+\)\{0,1}\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d",s:dollar_add(submatch(2)[1:],nr)).submatch(3)', 'g')
|
||||
endif
|
||||
let text = substitute(text, '\${nr}', "\n", 'g')
|
||||
let text = substitute(text, '\\\$', '$', 'g')
|
||||
if text != ''
|
||||
let str = substitute(str, '\("\zs$#\ze"\|\s\zs\$#"\|"\$#\ze\s\)', text, 'g')
|
||||
endif
|
||||
endif
|
||||
let str .= text
|
||||
let nc = len(current.child)
|
||||
let dr = 0
|
||||
if nc > 0
|
||||
for n in range(nc)
|
||||
let child = current.child[n]
|
||||
if child.multiplier > 1
|
||||
let str .= "\n" . indent
|
||||
let dr = 1
|
||||
elseif len(current_name) > 0 && stridx(','.settings.html.inline_elements.',', ','.current_name.',') == -1
|
||||
if nc > 1 || (len(child.name) > 0 && stridx(','.settings.html.inline_elements.',', ','.child.name.',') == -1)
|
||||
let str .= "\n" . indent
|
||||
let dr = 1
|
||||
elseif current.multiplier == 1 && nc == 1 && len(child.name) == 0
|
||||
let str .= "\n" . indent
|
||||
let dr = 1
|
||||
endif
|
||||
endif
|
||||
let inner = emmet#toString(child, type, 0, filters, itemno, indent)
|
||||
let inner = substitute(inner, "^\n", '', 'g')
|
||||
let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g')
|
||||
let inner = substitute(inner, "\n" . escape(indent, '\') . '$', '', 'g')
|
||||
let str .= inner
|
||||
endfor
|
||||
else
|
||||
if settings.html.indent_blockelement && len(current_name) > 0 && stridx(','.settings.html.inline_elements.',', ','.current_name.',') == -1
|
||||
let str .= "\n" . indent . '${cursor}' . "\n"
|
||||
else
|
||||
let str .= '${cursor}'
|
||||
endif
|
||||
endif
|
||||
if dr
|
||||
let str .= "\n"
|
||||
endif
|
||||
let str .= '</' . current_name . '>'
|
||||
endif
|
||||
if len(comment) > 0
|
||||
if ct ==# 'lastonly'
|
||||
let str .= '<!-- ' . comment . ' -->'
|
||||
else
|
||||
let str .= "\n<!-- /" . comment . ' -->'
|
||||
endif
|
||||
endif
|
||||
if len(current_name) > 0 && current.multiplier > 0 || stridx(','.settings.html.block_elements.',', ','.current_name.',') != -1
|
||||
let str .= "\n"
|
||||
endif
|
||||
return str
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#html#imageSize() abort
|
||||
let img_region = emmet#util#searchRegion('<img\s', '>')
|
||||
if !emmet#util#regionIsValid(img_region) || !emmet#util#cursorInRegion(img_region)
|
||||
return
|
||||
endif
|
||||
let content = emmet#util#getContent(img_region)
|
||||
if content !~# '^<img[^><]\+>$'
|
||||
return
|
||||
endif
|
||||
let current = emmet#lang#html#parseTag(content)
|
||||
if empty(current) || !has_key(current.attr, 'src')
|
||||
return
|
||||
endif
|
||||
let fn = current.attr.src
|
||||
if fn =~# '^\s*$'
|
||||
return
|
||||
elseif fn !~# '^\(/\|http\)'
|
||||
let fn = simplify(expand('%:h') . '/' . fn)
|
||||
endif
|
||||
|
||||
let [width, height] = emmet#util#getImageSize(fn)
|
||||
if width == -1 && height == -1
|
||||
return
|
||||
endif
|
||||
let current.attr.width = width
|
||||
let current.attr.height = height
|
||||
let current.attrs_order += ['width', 'height']
|
||||
let html = substitute(emmet#toString(current, 'html', 1), '\n', '', '')
|
||||
let html = substitute(html, '\${cursor}', '', '')
|
||||
call emmet#util#setContent(img_region, html)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#html#encodeImage() abort
|
||||
let img_region = emmet#util#searchRegion('<img\s', '>')
|
||||
if !emmet#util#regionIsValid(img_region) || !emmet#util#cursorInRegion(img_region)
|
||||
return
|
||||
endif
|
||||
let content = emmet#util#getContent(img_region)
|
||||
if content !~# '^<img[^><]\+>$'
|
||||
return
|
||||
endif
|
||||
let current = emmet#lang#html#parseTag(content)
|
||||
if empty(current) || !has_key(current.attr, 'src')
|
||||
return
|
||||
endif
|
||||
let fn = current.attr.src
|
||||
if fn !~# '^\(/\|http\)'
|
||||
let fn = simplify(expand('%:h') . '/' . fn)
|
||||
endif
|
||||
|
||||
let [width, height] = emmet#util#getImageSize(fn)
|
||||
if width == -1 && height == -1
|
||||
return
|
||||
endif
|
||||
let current.attr.width = width
|
||||
let current.attr.height = height
|
||||
let html = emmet#toString(current, 'html', 1)
|
||||
call emmet#util#setContent(img_region, html)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#html#parseTag(tag) abort
|
||||
let current = emmet#newNode()
|
||||
let mx = '<\([a-zA-Z][a-zA-Z0-9]*\)\(\%(\s[a-zA-Z][a-zA-Z0-9]\+=\%([^"'' \t]\+\|"[^"]\{-}"\|''[^'']\{-}''\)\s*\)*\)\(/\{0,1}\)>'
|
||||
let match = matchstr(a:tag, mx)
|
||||
let current.name = substitute(match, mx, '\1', 'i')
|
||||
let attrs = substitute(match, mx, '\2', 'i')
|
||||
let mx = '\([a-zA-Z0-9]\+\)=\%(\([^"'' \t]\+\)\|"\([^"]\{-}\)"\|''\([^'']\{-}\)''\)'
|
||||
while len(attrs) > 0
|
||||
let match = matchstr(attrs, mx)
|
||||
if len(match) == 0
|
||||
break
|
||||
endif
|
||||
let attr_match = matchlist(match, mx)
|
||||
let name = attr_match[1]
|
||||
let value = len(attr_match[2]) ? attr_match[2] : attr_match[3]
|
||||
let current.attr[name] = value
|
||||
let current.attrs_order += [name]
|
||||
let attrs = attrs[stridx(attrs, match) + len(match):]
|
||||
endwhile
|
||||
return current
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#html#toggleComment() abort
|
||||
let orgpos = getpos('.')
|
||||
let curpos = getpos('.')
|
||||
let mx = '<\%#[^>]*>'
|
||||
while 1
|
||||
let block = emmet#util#searchRegion('<!--', '-->')
|
||||
if emmet#util#regionIsValid(block)
|
||||
let block[1][1] += 2
|
||||
let content = emmet#util#getContent(block)
|
||||
let content = substitute(content, '^<!--\s\(.*\)\s-->$', '\1', '')
|
||||
call emmet#util#setContent(block, content)
|
||||
silent! call setpos('.', orgpos)
|
||||
return
|
||||
endif
|
||||
let block = emmet#util#searchRegion('<[^>]', '>')
|
||||
if !emmet#util#regionIsValid(block)
|
||||
let pos1 = searchpos('<', 'bcW')
|
||||
if pos1[0] == 0 && pos1[1] == 0
|
||||
return
|
||||
endif
|
||||
let curpos = getpos('.')
|
||||
continue
|
||||
endif
|
||||
let pos1 = block[0]
|
||||
let pos2 = block[1]
|
||||
let content = emmet#util#getContent(block)
|
||||
let tag_name = matchstr(content, '^<\zs/\{0,1}[^ \r\n>]\+')
|
||||
if tag_name[0] ==# '/'
|
||||
call setpos('.', [0, pos1[0], pos1[1], 0])
|
||||
let pos2 = searchpairpos('<'. tag_name[1:] . '\>[^>]*>', '', '</' . tag_name[1:] . '>', 'bnW')
|
||||
let pos1 = searchpos('>', 'cneW')
|
||||
let block = [pos2, pos1]
|
||||
elseif tag_name =~# '/$'
|
||||
if !emmet#util#pointInRegion(orgpos[1:2], block)
|
||||
" it's broken tree
|
||||
call setpos('.', orgpos)
|
||||
let block = emmet#util#searchRegion('>', '<')
|
||||
let content = '><!-- ' . emmet#util#getContent(block)[1:-2] . ' --><'
|
||||
call emmet#util#setContent(block, content)
|
||||
silent! call setpos('.', orgpos)
|
||||
return
|
||||
endif
|
||||
else
|
||||
call setpos('.', [0, pos2[0], pos2[1], 0])
|
||||
let pos3 = searchpairpos('<'. tag_name . '\>[^>]*>', '', '</' . tag_name . '>', 'nW')
|
||||
if pos3 == [0, 0]
|
||||
let block = [pos1, pos2]
|
||||
else
|
||||
call setpos('.', [0, pos3[0], pos3[1], 0])
|
||||
let pos2 = searchpos('>', 'neW')
|
||||
let block = [pos1, pos2]
|
||||
endif
|
||||
endif
|
||||
if !emmet#util#regionIsValid(block)
|
||||
silent! call setpos('.', orgpos)
|
||||
return
|
||||
endif
|
||||
if emmet#util#pointInRegion(curpos[1:2], block)
|
||||
let content = '<!-- ' . emmet#util#getContent(block) . ' -->'
|
||||
call emmet#util#setContent(block, content)
|
||||
silent! call setpos('.', orgpos)
|
||||
return
|
||||
endif
|
||||
endwhile
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#html#balanceTag(flag) range abort
|
||||
let vblock = emmet#util#getVisualBlock()
|
||||
if a:flag == -2 || a:flag == 2
|
||||
let curpos = [0, line("'<"), col("'<"), 0]
|
||||
else
|
||||
let curpos = emmet#util#getcurpos()
|
||||
endif
|
||||
let settings = emmet#getSettings()
|
||||
|
||||
if a:flag > 0
|
||||
let mx = '<\([a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*'
|
||||
let last = curpos[1:2]
|
||||
while 1
|
||||
let pos1 = searchpos(mx, 'bW')
|
||||
let content = matchstr(getline(pos1[0])[pos1[1]-1:], mx)
|
||||
let tag_name = matchstr(content, '^<\zs[a-zA-Z0-9:_\-]*\ze')
|
||||
if stridx(','.settings.html.empty_elements.',', ','.tag_name.',') != -1
|
||||
let pos2 = searchpos('>', 'nW')
|
||||
else
|
||||
let pos2 = searchpairpos('<' . tag_name . '[^>]*>', '', '</'. tag_name . '\zs>', 'nW')
|
||||
endif
|
||||
let block = [pos1, pos2]
|
||||
if pos1[0] == 0 && pos1[1] == 0
|
||||
break
|
||||
endif
|
||||
if emmet#util#pointInRegion(last, block) && emmet#util#regionIsValid(block)
|
||||
call emmet#util#selectRegion(block)
|
||||
return
|
||||
endif
|
||||
if pos1 == last
|
||||
break
|
||||
endif
|
||||
let last = pos1
|
||||
endwhile
|
||||
else
|
||||
let mx = '<\([a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*>'
|
||||
while 1
|
||||
let pos1 = searchpos(mx, 'W')
|
||||
if pos1 == curpos[1:2]
|
||||
let pos1 = searchpos(mx . '\zs', 'W')
|
||||
let pos2 = searchpos('.\ze<', 'W')
|
||||
let block = [pos1, pos2]
|
||||
if emmet#util#regionIsValid(block)
|
||||
call emmet#util#selectRegion(block)
|
||||
return
|
||||
endif
|
||||
endif
|
||||
let content = matchstr(getline(pos1[0])[pos1[1]-1:], mx)
|
||||
let tag_name = matchstr(content, '^<\zs[a-zA-Z0-9:_\-]*\ze')
|
||||
if stridx(','.settings.html.empty_elements.',', ','.tag_name.',') != -1
|
||||
let pos2 = searchpos('>', 'nW')
|
||||
else
|
||||
let pos2 = searchpairpos('<' . tag_name . '[^>]*>', '', '</'. tag_name . '\zs>', 'nW')
|
||||
endif
|
||||
let block = [pos1, pos2]
|
||||
if pos1[0] == 0 && pos1[1] == 0
|
||||
break
|
||||
endif
|
||||
if emmet#util#regionIsValid(block)
|
||||
call emmet#util#selectRegion(block)
|
||||
return
|
||||
endif
|
||||
endwhile
|
||||
endif
|
||||
if a:flag == -2 || a:flag == 2
|
||||
silent! exe 'normal! gv'
|
||||
else
|
||||
call setpos('.', curpos)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#html#moveNextPrevItem(flag) abort
|
||||
silent! exe "normal \<esc>"
|
||||
let mx = '\%([0-9a-zA-Z-:]\+\%(="[^"]*"\|=''[^'']*''\|[^ ''">\]]*\)\{0,1}\)'
|
||||
let pos = searchpos('\s'.mx.'\zs', '')
|
||||
if pos != [0,0]
|
||||
call feedkeys('v?\s\zs'.mx."\<cr>", '')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#html#moveNextPrev(flag) abort
|
||||
let pos = search('\%(</\w\+\)\@<!\zs><\/\|\(""\)\|^\(\s*\)$', a:flag ? 'Wpb' : 'Wp')
|
||||
if pos == 3
|
||||
startinsert!
|
||||
elseif pos != 0
|
||||
silent! normal! l
|
||||
startinsert
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#html#splitJoinTag() abort
|
||||
let curpos = emmet#util#getcurpos()
|
||||
while 1
|
||||
let mx = '<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*>'
|
||||
let pos1 = searchpos(mx, 'bcnW')
|
||||
let content = matchstr(getline(pos1[0])[pos1[1]-1:], mx)
|
||||
let tag_name = substitute(content, '^<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:_\-]*\).*$', '\1', '')
|
||||
let block = [pos1, [pos1[0], pos1[1] + len(content) - 1]]
|
||||
if content[-2:] ==# '/>' && emmet#util#cursorInRegion(block)
|
||||
let content = substitute(content[:-3], '\s*$', '', '') . '></' . tag_name . '>'
|
||||
call emmet#util#setContent(block, content)
|
||||
call setpos('.', [0, block[0][0], block[0][1], 0])
|
||||
return
|
||||
else
|
||||
if tag_name[0] ==# '/'
|
||||
let pos1 = searchpos('<' . tag_name[1:] . '[^a-zA-Z0-9]', 'bcnW')
|
||||
call setpos('.', [0, pos1[0], pos1[1], 0])
|
||||
let pos2 = searchpos('</' . tag_name[1:] . '>', 'cneW')
|
||||
else
|
||||
let pos2 = searchpos('</' . tag_name . '>', 'cneW')
|
||||
endif
|
||||
let block = [pos1, pos2]
|
||||
let content = emmet#util#getContent(block)
|
||||
if emmet#util#pointInRegion(curpos[1:2], block) && content[1:] !~# '<' . tag_name . '[^a-zA-Z0-9]*[^>]*>'
|
||||
let content = matchstr(content, mx)[:-2] . ' />'
|
||||
call emmet#util#setContent(block, content)
|
||||
call setpos('.', [0, block[0][0], block[0][1], 0])
|
||||
return
|
||||
else
|
||||
if block[0][0] > 0
|
||||
call setpos('.', [0, block[0][0]-1, block[0][1], 0])
|
||||
else
|
||||
call setpos('.', curpos)
|
||||
return
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endwhile
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#html#removeTag() abort
|
||||
let curpos = emmet#util#getcurpos()
|
||||
while 1
|
||||
let mx = '<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*'
|
||||
let pos1 = searchpos(mx, 'bcnW')
|
||||
let content = matchstr(getline(pos1[0])[pos1[1]-1:], mx)
|
||||
let tag_name = matchstr(content, '^<\zs/\{0,1}[a-zA-Z0-9:_\-]*')
|
||||
let block = [pos1, [pos1[0], pos1[1] + len(content) - 1]]
|
||||
if content[-2:] ==# '/>' && emmet#util#cursorInRegion(block)
|
||||
call emmet#util#setContent(block, '')
|
||||
call setpos('.', [0, block[0][0], block[0][1], 0])
|
||||
return
|
||||
else
|
||||
if tag_name[0] ==# '/'
|
||||
let pos1 = searchpos('<' . tag_name[1:] . '[^a-zA-Z0-9]', 'bcnW')
|
||||
call setpos('.', [0, pos1[0], pos1[1], 0])
|
||||
let pos2 = searchpos('</' . tag_name[1:] . '>', 'cneW')
|
||||
else
|
||||
let pos2 = searchpos('</' . tag_name . '>', 'cneW')
|
||||
endif
|
||||
let block = [pos1, pos2]
|
||||
let content = emmet#util#getContent(block)
|
||||
if emmet#util#pointInRegion(curpos[1:2], block) && content[1:] !~# '^<' . tag_name . '[^a-zA-Z0-9]'
|
||||
call emmet#util#setContent(block, '')
|
||||
call setpos('.', [0, block[0][0], block[0][1], 0])
|
||||
return
|
||||
else
|
||||
if block[0][0] > 0
|
||||
call setpos('.', [0, block[0][0]-1, block[0][1], 0])
|
||||
else
|
||||
call setpos('.', curpos)
|
||||
return
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endwhile
|
||||
endfunction
|
||||
|
|
@ -1,331 +0,0 @@
|
|||
function! emmet#lang#jade#findTokens(str) abort
|
||||
return emmet#lang#html#findTokens(a:str)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#jade#parseIntoTree(abbr, type) abort
|
||||
return emmet#lang#html#parseIntoTree(a:abbr, a:type)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#jade#toString(settings, current, type, inline, filters, itemno, indent) abort
|
||||
let settings = a:settings
|
||||
let current = a:current
|
||||
let type = a:type
|
||||
let inline = a:inline
|
||||
let filters = a:filters
|
||||
let itemno = a:itemno
|
||||
let indent = emmet#getIndentation(type)
|
||||
let dollar_expr = emmet#getResource(type, 'dollar_expr', 1)
|
||||
let attribute_style = emmet#getResource('jade', 'attribute_style', 'hash')
|
||||
let str = ''
|
||||
|
||||
let current_name = current.name
|
||||
if dollar_expr
|
||||
let current_name = substitute(current.name, '\$$', itemno+1, '')
|
||||
endif
|
||||
if len(current.name) > 0
|
||||
let str .= '' . current_name
|
||||
let tmp = ''
|
||||
for attr in emmet#util#unique(current.attrs_order + keys(current.attr))
|
||||
if !has_key(current.attr, attr)
|
||||
continue
|
||||
endif
|
||||
let Val = current.attr[attr]
|
||||
if type(Val) == 2 && Val == function('emmet#types#true')
|
||||
if attribute_style ==# 'hash'
|
||||
let tmp .= ' ' . attr . ' = true'
|
||||
elseif attribute_style ==# 'html'
|
||||
let tmp .= attr . '=true'
|
||||
end
|
||||
else
|
||||
if dollar_expr
|
||||
while Val =~# '\$\([^#{]\|$\)'
|
||||
let Val = substitute(Val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
endwhile
|
||||
let attr = substitute(attr, '\$$', itemno+1, '')
|
||||
endif
|
||||
let valtmp = substitute(Val, '\${cursor}', '', '')
|
||||
if attr ==# 'id' && len(valtmp) > 0
|
||||
let str .= '#' . Val
|
||||
elseif attr ==# 'class' && len(valtmp) > 0
|
||||
let str .= '.' . substitute(Val, ' ', '.', 'g')
|
||||
else
|
||||
if len(tmp) > 0
|
||||
if attribute_style ==# 'hash'
|
||||
let tmp .= ', '
|
||||
elseif attribute_style ==# 'html'
|
||||
let tmp .= ' '
|
||||
endif
|
||||
endif
|
||||
if attribute_style ==# 'hash'
|
||||
let tmp .= '' . attr . '="' . Val . '"'
|
||||
elseif attribute_style ==# 'html'
|
||||
let tmp .= attr . '="' . Val . '"'
|
||||
end
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
if len(tmp)
|
||||
if attribute_style ==# 'hash'
|
||||
let str .= '(' . tmp . ')'
|
||||
elseif attribute_style ==# 'html'
|
||||
let str .= '(' . tmp . ')'
|
||||
end
|
||||
endif
|
||||
|
||||
let inner = ''
|
||||
if len(current.value) > 0
|
||||
let text = current.value[1:-2]
|
||||
if dollar_expr
|
||||
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
let text = substitute(text, '\${nr}', "\n", 'g')
|
||||
let text = substitute(text, '\\\$', '$', 'g')
|
||||
let str = substitute(str, '\$#', text, 'g')
|
||||
endif
|
||||
let lines = split(text, "\n")
|
||||
if len(lines) == 1
|
||||
let str .= ' ' . text
|
||||
else
|
||||
for line in lines
|
||||
let str .= "\n" . indent . line . ' |'
|
||||
endfor
|
||||
endif
|
||||
elseif len(current.child) == 0
|
||||
let str .= '${cursor}'
|
||||
endif
|
||||
if len(current.child) == 1 && len(current.child[0].name) == 0
|
||||
let text = current.child[0].value[1:-2]
|
||||
if dollar_expr
|
||||
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
let text = substitute(text, '\${nr}', "\n", 'g')
|
||||
let text = substitute(text, '\\\$', '$', 'g')
|
||||
endif
|
||||
let lines = split(text, "\n")
|
||||
if len(lines) == 1
|
||||
let str .= ' ' . text
|
||||
else
|
||||
for line in lines
|
||||
let str .= "\n" . indent . line . ' |'
|
||||
endfor
|
||||
endif
|
||||
elseif len(current.child) > 0
|
||||
for child in current.child
|
||||
let inner .= emmet#toString(child, type, inline, filters, itemno, indent)
|
||||
endfor
|
||||
let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g')
|
||||
let inner = substitute(inner, "\n" . escape(indent, '\') . '$', '', 'g')
|
||||
let str .= "\n" . indent . inner
|
||||
endif
|
||||
else
|
||||
let str = current.value[1:-2]
|
||||
if dollar_expr
|
||||
let str = substitute(str, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
let str = substitute(str, '\${nr}', "\n", 'g')
|
||||
let str = substitute(str, '\\\$', '$', 'g')
|
||||
endif
|
||||
endif
|
||||
let str .= "\n"
|
||||
return str
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#jade#imageSize() abort
|
||||
let line = getline('.')
|
||||
let current = emmet#lang#jade#parseTag(line)
|
||||
if empty(current) || !has_key(current.attr, 'src')
|
||||
return
|
||||
endif
|
||||
let fn = current.attr.src
|
||||
if fn =~# '^\s*$'
|
||||
return
|
||||
elseif fn !~# '^\(/\|http\)'
|
||||
let fn = simplify(expand('%:h') . '/' . fn)
|
||||
endif
|
||||
|
||||
let [width, height] = emmet#util#getImageSize(fn)
|
||||
if width == -1 && height == -1
|
||||
return
|
||||
endif
|
||||
let current.attr.width = width
|
||||
let current.attr.height = height
|
||||
let current.attrs_order += ['width', 'height']
|
||||
let jade = emmet#toString(current, 'jade', 1)
|
||||
let jade = substitute(jade, '\${cursor}', '', '')
|
||||
call setline('.', substitute(matchstr(line, '^\s*') . jade, "\n", '', 'g'))
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#jade#encodeImage() abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#jade#parseTag(tag) abort
|
||||
let current = emmet#newNode()
|
||||
let mx = '%\([a-zA-Z][a-zA-Z0-9]*\)\s*\%({\(.*\)}\)'
|
||||
let match = matchstr(a:tag, mx)
|
||||
let current.name = substitute(match, mx, '\1', '')
|
||||
let attrs = substitute(match, mx, '\2', '')
|
||||
let mx = '\([a-zA-Z0-9]\+\)\s*=>\s*\%(\([^"'' \t]\+\)\|"\([^"]\{-}\)"\|''\([^'']\{-}\)''\)'
|
||||
while len(attrs) > 0
|
||||
let match = matchstr(attrs, mx)
|
||||
if len(match) ==# 0
|
||||
break
|
||||
endif
|
||||
let attr_match = matchlist(match, mx)
|
||||
let name = attr_match[1]
|
||||
let value = len(attr_match[2]) ? attr_match[2] : attr_match[3]
|
||||
let current.attr[name] = value
|
||||
let current.attrs_order += [name]
|
||||
let attrs = attrs[stridx(attrs, match) + len(match):]
|
||||
endwhile
|
||||
return current
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#jade#toggleComment() abort
|
||||
let line = getline('.')
|
||||
let space = matchstr(line, '^\s*')
|
||||
if line =~# '^\s*-#'
|
||||
call setline('.', space . matchstr(line[len(space)+2:], '^\s*\zs.*'))
|
||||
elseif line =~# '^\s*%[a-z]'
|
||||
call setline('.', space . '-# ' . line[len(space):])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#jade#balanceTag(flag) range abort
|
||||
let block = emmet#util#getVisualBlock()
|
||||
if a:flag == -2 || a:flag == 2
|
||||
let curpos = [0, line("'<"), col("'<"), 0]
|
||||
else
|
||||
let curpos = emmet#util#getcurpos()
|
||||
endif
|
||||
let n = curpos[1]
|
||||
let ml = len(matchstr(getline(n), '^\s*'))
|
||||
|
||||
if a:flag > 0
|
||||
if a:flag == 1 || !emmet#util#regionIsValid(block)
|
||||
let n = line('.')
|
||||
else
|
||||
while n > 0
|
||||
let l = len(matchstr(getline(n), '^\s*\ze%[a-z]'))
|
||||
if l > 0 && l < ml
|
||||
let ml = l
|
||||
break
|
||||
endif
|
||||
let n -= 1
|
||||
endwhile
|
||||
endif
|
||||
let sn = n
|
||||
if n == 0
|
||||
let ml = 0
|
||||
endif
|
||||
while n < line('$')
|
||||
let l = len(matchstr(getline(n), '^\s*%[a-z]'))
|
||||
if l > 0 && l <= ml
|
||||
let n -= 1
|
||||
break
|
||||
endif
|
||||
let n += 1
|
||||
endwhile
|
||||
call setpos('.', [0, n, 1, 0])
|
||||
normal! V
|
||||
call setpos('.', [0, sn, 1, 0])
|
||||
else
|
||||
while n > 0
|
||||
let l = len(matchstr(getline(n), '^\s*\ze[a-z]'))
|
||||
if l > 0 && l > ml
|
||||
let ml = l
|
||||
break
|
||||
endif
|
||||
let n += 1
|
||||
endwhile
|
||||
let sn = n
|
||||
if n == 0
|
||||
let ml = 0
|
||||
endif
|
||||
while n < line('$')
|
||||
let l = len(matchstr(getline(n), '^\s*%[a-z]'))
|
||||
if l > 0 && l <= ml
|
||||
let n -= 1
|
||||
break
|
||||
endif
|
||||
let n += 1
|
||||
endwhile
|
||||
call setpos('.', [0, n, 1, 0])
|
||||
normal! V
|
||||
call setpos('.', [0, sn, 1, 0])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#jade#moveNextPrevItem(flag) abort
|
||||
return emmet#lang#jade#moveNextPrev(a:flag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#jade#moveNextPrev(flag) abort
|
||||
let pos = search('""', a:flag ? 'Wb' : 'W')
|
||||
if pos != 0
|
||||
silent! normal! l
|
||||
startinsert
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#jade#splitJoinTag() abort
|
||||
let n = line('.')
|
||||
let sml = len(matchstr(getline(n), '^\s*%[a-z]'))
|
||||
while n > 0
|
||||
if getline(n) =~# '^\s*\ze%[a-z]'
|
||||
if len(matchstr(getline(n), '^\s*%[a-z]')) < sml
|
||||
break
|
||||
endif
|
||||
let line = getline(n)
|
||||
call setline(n, substitute(line, '^\s*%\w\+\%(\s*{[^}]*}\|\s\)\zs.*', '', ''))
|
||||
let sn = n
|
||||
let n += 1
|
||||
let ml = len(matchstr(getline(n), '^\s*%[a-z]'))
|
||||
if len(matchstr(getline(n), '^\s*')) > ml
|
||||
while n <= line('$')
|
||||
let l = len(matchstr(getline(n), '^\s*'))
|
||||
if l <= ml
|
||||
break
|
||||
endif
|
||||
exe n 'delete'
|
||||
endwhile
|
||||
call setpos('.', [0, sn, 1, 0])
|
||||
else
|
||||
let tag = matchstr(getline(sn), '^\s*%\zs\(\w\+\)')
|
||||
let spaces = matchstr(getline(sn), '^\s*')
|
||||
let settings = emmet#getSettings()
|
||||
if stridx(','.settings.html.inline_elements.',', ','.tag.',') == -1
|
||||
call append(sn, spaces . ' ')
|
||||
call setpos('.', [0, sn+1, 1, 0])
|
||||
else
|
||||
call setpos('.', [0, sn, 1, 0])
|
||||
endif
|
||||
startinsert!
|
||||
endif
|
||||
break
|
||||
endif
|
||||
let n -= 1
|
||||
endwhile
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#jade#removeTag() abort
|
||||
let n = line('.')
|
||||
let ml = 0
|
||||
while n > 0
|
||||
if getline(n) =~# '^\s*\ze[a-z]'
|
||||
let ml = len(matchstr(getline(n), '^\s*%[a-z]'))
|
||||
break
|
||||
endif
|
||||
let n -= 1
|
||||
endwhile
|
||||
let sn = n
|
||||
while n < line('$')
|
||||
let l = len(matchstr(getline(n), '^\s*%[a-z]'))
|
||||
if l > 0 && l <= ml
|
||||
let n -= 1
|
||||
break
|
||||
endif
|
||||
let n += 1
|
||||
endwhile
|
||||
if sn == n
|
||||
exe 'delete'
|
||||
else
|
||||
exe sn ',' (n-1) 'delete'
|
||||
endif
|
||||
endfunction
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
function! emmet#lang#less#findTokens(str) abort
|
||||
return emmet#lang#html#findTokens(a:str)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#parseIntoTree(abbr, type) abort
|
||||
return emmet#lang#scss#parseIntoTree(a:abbr, a:type)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#toString(settings, current, type, inline, filters, itemno, indent) abort
|
||||
return emmet#lang#scss#toString(a:settings, a:current, a:type, a:inline, a:filters, a:itemno, a:indent)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#imageSize() abort
|
||||
call emmet#lang#css#imageSize()
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#encodeImage() abort
|
||||
return emmet#lang#css#encodeImage()
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#parseTag(tag) abort
|
||||
return emmet#lang#css#parseTag(a:tag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#toggleComment() abort
|
||||
call emmet#lang#css#toggleComment()
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#balanceTag(flag) range abort
|
||||
call emmet#lang#scss#balanceTag(a:flag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#moveNextPrevItem(flag) abort
|
||||
return emmet#lang#less#moveNextPrev(a:flag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#moveNextPrev(flag) abort
|
||||
call emmet#lang#scss#moveNextPrev(a:flag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#splitJoinTag() abort
|
||||
call emmet#lang#css#splitJoinTag()
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#less#removeTag() abort
|
||||
call emmet#lang#css#removeTag()
|
||||
endfunction
|
||||
|
|
@ -1,160 +0,0 @@
|
|||
function! emmet#lang#sass#findTokens(str) abort
|
||||
return emmet#lang#css#findTokens(a:str)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#sass#parseIntoTree(abbr, type) abort
|
||||
return emmet#lang#css#parseIntoTree(a:abbr, a:type)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#sass#toString(settings, current, type, inline, filters, itemno, indent) abort
|
||||
let settings = a:settings
|
||||
let current = a:current
|
||||
let type = a:type
|
||||
let inline = a:inline
|
||||
let filters = a:filters
|
||||
let itemno = a:itemno
|
||||
let indent = a:indent
|
||||
let str = ''
|
||||
|
||||
let current_name = current.name
|
||||
let current_name = substitute(current.name, '\$$', itemno+1, '')
|
||||
if len(current.name) > 0
|
||||
let str .= current_name
|
||||
let tmp = ''
|
||||
for attr in keys(current.attr)
|
||||
let val = current.attr[attr]
|
||||
while val =~# '\$\([^#{]\|$\)'
|
||||
let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
endwhile
|
||||
let attr = substitute(attr, '\$$', itemno+1, '')
|
||||
if attr ==# 'id'
|
||||
let str .= '#' . val
|
||||
elseif attr ==# 'class'
|
||||
let str .= '.' . val
|
||||
else
|
||||
let tmp .= attr . ': ' . val
|
||||
endif
|
||||
endfor
|
||||
if len(tmp) > 0
|
||||
let str .= "\n"
|
||||
for line in split(tmp, "\n")
|
||||
let str .= indent . line . "\n"
|
||||
endfor
|
||||
else
|
||||
let str .= "\n"
|
||||
endif
|
||||
|
||||
let inner = ''
|
||||
for child in current.child
|
||||
let tmp = emmet#toString(child, type, inline, filters, itemno, indent)
|
||||
let tmp = substitute(tmp, "\n", "\n" . escape(indent, '\'), 'g')
|
||||
let tmp = substitute(tmp, "\n" . escape(indent, '\') . '$', '${cursor}\n', 'g')
|
||||
let inner .= tmp
|
||||
endfor
|
||||
if len(inner) > 0
|
||||
let str .= indent . inner
|
||||
endif
|
||||
else
|
||||
let text = emmet#lang#css#toString(settings, current, type, inline, filters, itemno, indent)
|
||||
let text = substitute(text, '\s*;\ze\(\${[^}]\+}\)\?\(\n\|$\)', '', 'g')
|
||||
return text
|
||||
endif
|
||||
return str
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#sass#imageSize() abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#sass#encodeImage() abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#sass#parseTag(tag) abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#sass#toggleComment() abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#sass#balanceTag(flag) range abort
|
||||
let block = emmet#util#getVisualBlock()
|
||||
if a:flag == -2 || a:flag == 2
|
||||
let curpos = [0, line("'<"), col("'<"), 0]
|
||||
else
|
||||
let curpos = emmet#util#getcurpos()
|
||||
endif
|
||||
let n = curpos[1]
|
||||
let ml = len(matchstr(getline(n), '^\s*'))
|
||||
|
||||
if a:flag > 0
|
||||
if a:flag == 1 || !emmet#util#regionIsValid(block)
|
||||
let n = line('.')
|
||||
else
|
||||
while n > 0
|
||||
let l = len(matchstr(getline(n), '^\s*\ze[a-z]'))
|
||||
if l > 0 && l < ml
|
||||
let ml = l
|
||||
break
|
||||
endif
|
||||
let n -= 1
|
||||
endwhile
|
||||
endif
|
||||
let sn = n
|
||||
if n == 0
|
||||
let ml = 0
|
||||
endif
|
||||
while n < line('$')
|
||||
let l = len(matchstr(getline(n), '^\s*[a-z]'))
|
||||
if l > 0 && l <= ml
|
||||
let n -= 1
|
||||
break
|
||||
endif
|
||||
let n += 1
|
||||
endwhile
|
||||
call setpos('.', [0, n, 1, 0])
|
||||
normal! V
|
||||
call setpos('.', [0, sn, 1, 0])
|
||||
else
|
||||
while n > 0
|
||||
let l = len(matchstr(getline(n), '^\s*\ze[a-z]'))
|
||||
if l > 0 && l > ml
|
||||
let ml = l
|
||||
break
|
||||
endif
|
||||
let n += 1
|
||||
endwhile
|
||||
let sn = n
|
||||
if n == 0
|
||||
let ml = 0
|
||||
endif
|
||||
while n < line('$')
|
||||
let l = len(matchstr(getline(n), '^\s*[a-z]'))
|
||||
if l > 0 && l <= ml
|
||||
let n -= 1
|
||||
break
|
||||
endif
|
||||
let n += 1
|
||||
endwhile
|
||||
call setpos('.', [0, n, 1, 0])
|
||||
normal! V
|
||||
call setpos('.', [0, sn, 1, 0])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#sass#moveNextPrevItem(flag) abort
|
||||
return emmet#lang#sass#moveNextPrev(a:flag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#sass#moveNextPrev(flag) abort
|
||||
let pos = search('""\|\(^\s*|\s*\zs\)', a:flag ? 'Wpb' : 'Wp')
|
||||
if pos == 2
|
||||
startinsert!
|
||||
elseif pos != 0
|
||||
silent! normal! l
|
||||
startinsert
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#sass#splitJoinTag() abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#sass#removeTag() abort
|
||||
endfunction
|
||||
|
|
@ -1,125 +0,0 @@
|
|||
function! emmet#lang#scss#findTokens(str) abort
|
||||
return emmet#lang#css#findTokens(a:str)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#parseIntoTree(abbr, type) abort
|
||||
if a:abbr =~# '>'
|
||||
return emmet#lang#html#parseIntoTree(a:abbr, a:type)
|
||||
else
|
||||
return emmet#lang#css#parseIntoTree(a:abbr, a:type)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#toString(settings, current, type, inline, filters, itemno, indent) abort
|
||||
let settings = a:settings
|
||||
let current = a:current
|
||||
let type = a:type
|
||||
let inline = a:inline
|
||||
let filters = a:filters
|
||||
let itemno = a:itemno
|
||||
let indent = a:indent
|
||||
let str = ''
|
||||
|
||||
let current_name = substitute(current.name, '\$$', itemno+1, '')
|
||||
if len(current.name) > 0
|
||||
let str .= current_name
|
||||
let tmp = ''
|
||||
for attr in keys(current.attr)
|
||||
let val = current.attr[attr]
|
||||
while val =~# '\$\([^#{]\|$\)'
|
||||
let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
endwhile
|
||||
let attr = substitute(attr, '\$$', itemno+1, '')
|
||||
if attr ==# 'id'
|
||||
let str .= '#' . val
|
||||
elseif attr ==# 'class'
|
||||
let str .= '.' . val
|
||||
else
|
||||
let tmp .= attr . ': ' . val . ';'
|
||||
endif
|
||||
endfor
|
||||
if len(tmp) > 0
|
||||
let str .= " {\n"
|
||||
for line in split(tmp, "\n")
|
||||
let str .= indent . line . "\n"
|
||||
endfor
|
||||
else
|
||||
let str .= " {\n"
|
||||
endif
|
||||
|
||||
let inner = ''
|
||||
for child in current.child
|
||||
let inner .= emmet#toString(child, type, inline, filters, itemno)
|
||||
endfor
|
||||
let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g')
|
||||
let inner = substitute(inner, "\n" . escape(indent, '\') . '$', '', 'g')
|
||||
let str .= indent . inner . "${cursor}\n}\n"
|
||||
else
|
||||
return emmet#lang#css#toString(settings, current, type, inline, filters, itemno, indent)
|
||||
endif
|
||||
return str
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#imageSize() abort
|
||||
call emmet#lang#css#imageSize()
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#encodeImage() abort
|
||||
return emmet#lang#css#encodeImage()
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#parseTag(tag) abort
|
||||
return emmet#lang#css#parseTag(a:tag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#toggleComment() abort
|
||||
call emmet#lang#css#toggleComment()
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#balanceTag(flag) range abort
|
||||
if a:flag == -2 || a:flag == 2
|
||||
let curpos = [0, line("'<"), col("'<"), 0]
|
||||
call setpos('.', curpos)
|
||||
else
|
||||
let curpos = emmet#util#getcurpos()
|
||||
endif
|
||||
if a:flag < 0
|
||||
let ret = searchpair('}', '', '.\zs{')
|
||||
else
|
||||
let ret = searchpair('{', '', '}', 'bW')
|
||||
endif
|
||||
if ret > 0
|
||||
let pos1 = emmet#util#getcurpos()[1:2]
|
||||
if a:flag < 0
|
||||
let pos2 = searchpairpos('{', '', '}')
|
||||
else
|
||||
let pos2 = searchpairpos('{', '', '}')
|
||||
endif
|
||||
let block = [pos1, pos2]
|
||||
if emmet#util#regionIsValid(block)
|
||||
call emmet#util#selectRegion(block)
|
||||
return
|
||||
endif
|
||||
endif
|
||||
if a:flag == -2 || a:flag == 2
|
||||
silent! exe 'normal! gv'
|
||||
else
|
||||
call setpos('.', curpos)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#moveNextPrevItem(flag) abort
|
||||
return emmet#lang#scss#moveNextPrev(a:flag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#moveNextPrev(flag) abort
|
||||
call emmet#lang#css#moveNextPrev(a:flag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#splitJoinTag() abort
|
||||
call emmet#lang#css#splitJoinTag()
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#scss#removeTag() abort
|
||||
call emmet#lang#css#removeTag()
|
||||
endfunction
|
||||
|
|
@ -1,281 +0,0 @@
|
|||
function! emmet#lang#slim#findTokens(str) abort
|
||||
return emmet#lang#html#findTokens(a:str)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#slim#parseIntoTree(abbr, type) abort
|
||||
return emmet#lang#html#parseIntoTree(a:abbr, a:type)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#slim#toString(settings, current, type, inline, filters, itemno, indent) abort
|
||||
let current = a:current
|
||||
let type = a:type
|
||||
let inline = a:inline
|
||||
let filters = a:filters
|
||||
let itemno = a:itemno
|
||||
let indent = emmet#getIndentation(type)
|
||||
let dollar_expr = emmet#getResource(type, 'dollar_expr', 1)
|
||||
let str = ''
|
||||
|
||||
let current_name = current.name
|
||||
if dollar_expr
|
||||
let current_name = substitute(current.name, '\$$', itemno+1, '')
|
||||
endif
|
||||
if len(current.name) > 0
|
||||
let str .= current_name
|
||||
for attr in emmet#util#unique(current.attrs_order + keys(current.attr))
|
||||
if !has_key(current.attr, attr)
|
||||
continue
|
||||
endif
|
||||
let Val = current.attr[attr]
|
||||
if type(Val) == 2 && Val == function('emmet#types#true')
|
||||
let str .= ' ' . attr . '=true'
|
||||
else
|
||||
if dollar_expr
|
||||
while Val =~# '\$\([^#{]\|$\)'
|
||||
let Val = substitute(Val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
endwhile
|
||||
endif
|
||||
let attr = substitute(attr, '\$$', itemno+1, '')
|
||||
let str .= ' ' . attr . '="' . Val . '"'
|
||||
endif
|
||||
endfor
|
||||
|
||||
let inner = ''
|
||||
if len(current.value) > 0
|
||||
let str .= "\n"
|
||||
let text = current.value[1:-2]
|
||||
if dollar_expr
|
||||
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
let text = substitute(text, '\${nr}', "\n", 'g')
|
||||
let text = substitute(text, '\\\$', '$', 'g')
|
||||
let str = substitute(str, '\$#', text, 'g')
|
||||
endif
|
||||
for line in split(text, "\n")
|
||||
let str .= indent . '| ' . line . "\n"
|
||||
endfor
|
||||
elseif len(current.child) == 0
|
||||
let str .= '${cursor}'
|
||||
endif
|
||||
if len(current.child) == 1 && len(current.child[0].name) == 0
|
||||
let str .= "\n"
|
||||
let text = current.child[0].value[1:-2]
|
||||
if dollar_expr
|
||||
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
let text = substitute(text, '\${nr}', "\n", 'g')
|
||||
let text = substitute(text, '\\\$', '$', 'g')
|
||||
endif
|
||||
for line in split(text, "\n")
|
||||
let str .= indent . '| ' . line . "\n"
|
||||
endfor
|
||||
elseif len(current.child) > 0
|
||||
for child in current.child
|
||||
let inner .= emmet#toString(child, type, inline, filters, itemno, indent)
|
||||
endfor
|
||||
let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g')
|
||||
let inner = substitute(inner, "\n" . escape(indent, '\') . '$', '', 'g')
|
||||
let str .= "\n" . indent . inner
|
||||
endif
|
||||
else
|
||||
let str = current.value[1:-2]
|
||||
if dollar_expr
|
||||
let str = substitute(str, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
let str = substitute(str, '\${nr}', "\n", 'g')
|
||||
let str = substitute(str, '\\\$', '$', 'g')
|
||||
endif
|
||||
endif
|
||||
if str !~# "\n$"
|
||||
let str .= "\n"
|
||||
endif
|
||||
return str
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#slim#imageSize() abort
|
||||
let line = getline('.')
|
||||
let current = emmet#lang#slim#parseTag(line)
|
||||
if empty(current) || !has_key(current.attr, 'src')
|
||||
return
|
||||
endif
|
||||
let fn = current.attr.src
|
||||
if fn =~# '^\s*$'
|
||||
return
|
||||
elseif fn !~# '^\(/\|http\)'
|
||||
let fn = simplify(expand('%:h') . '/' . fn)
|
||||
endif
|
||||
|
||||
let [width, height] = emmet#util#getImageSize(fn)
|
||||
if width == -1 && height == -1
|
||||
return
|
||||
endif
|
||||
let current.attr.width = width
|
||||
let current.attr.height = height
|
||||
let current.attrs_order += ['width', 'height']
|
||||
let slim = emmet#toString(current, 'slim', 1)
|
||||
let slim = substitute(slim, '\${cursor}', '', '')
|
||||
call setline('.', substitute(matchstr(line, '^\s*') . slim, "\n", '', 'g'))
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#slim#encodeImage() abort
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#slim#parseTag(tag) abort
|
||||
let current = emmet#newNode()
|
||||
let mx = '\([a-zA-Z][a-zA-Z0-9]*\)\s\+\(.*\)'
|
||||
let match = matchstr(a:tag, mx)
|
||||
let current.name = substitute(match, mx, '\1', '')
|
||||
let attrs = substitute(match, mx, '\2', '')
|
||||
let mx = '\([a-zA-Z0-9]\+\)=\%(\([^"'' \t]\+\)\|"\([^"]\{-}\)"\|''\([^'']\{-}\)''\)'
|
||||
while len(attrs) > 0
|
||||
let match = matchstr(attrs, mx)
|
||||
if len(match) == 0
|
||||
break
|
||||
endif
|
||||
let attr_match = matchlist(match, mx)
|
||||
let name = attr_match[1]
|
||||
let value = len(attr_match[2]) ? attr_match[2] : attr_match[3]
|
||||
let current.attr[name] = value
|
||||
let current.attrs_order += [name]
|
||||
let attrs = attrs[stridx(attrs, match) + len(match):]
|
||||
endwhile
|
||||
return current
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#slim#toggleComment() abort
|
||||
let line = getline('.')
|
||||
let space = matchstr(line, '^\s*')
|
||||
if line =~# '^\s*/'
|
||||
call setline('.', space . line[len(space)+1:])
|
||||
elseif line =~# '^\s*[a-z]'
|
||||
call setline('.', space . '/' . line[len(space):])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#slim#balanceTag(flag) range abort
|
||||
let block = emmet#util#getVisualBlock()
|
||||
if a:flag == -2 || a:flag == 2
|
||||
let curpos = [0, line("'<"), col("'<"), 0]
|
||||
else
|
||||
let curpos = emmet#util#getcurpos()
|
||||
endif
|
||||
let n = curpos[1]
|
||||
let ml = len(matchstr(getline(n), '^\s*'))
|
||||
|
||||
if a:flag > 0
|
||||
if a:flag == 1 || !emmet#util#regionIsValid(block)
|
||||
let n = line('.')
|
||||
else
|
||||
while n > 0
|
||||
let l = len(matchstr(getline(n), '^\s*\ze[a-z]'))
|
||||
if l > 0 && l < ml
|
||||
let ml = l
|
||||
break
|
||||
endif
|
||||
let n -= 1
|
||||
endwhile
|
||||
endif
|
||||
let sn = n
|
||||
if n == 0
|
||||
let ml = 0
|
||||
endif
|
||||
while n < line('$')
|
||||
let l = len(matchstr(getline(n), '^\s*[a-z]'))
|
||||
if l > 0 && l <= ml
|
||||
let n -= 1
|
||||
break
|
||||
endif
|
||||
let n += 1
|
||||
endwhile
|
||||
call setpos('.', [0, n, 1, 0])
|
||||
normal! V
|
||||
call setpos('.', [0, sn, 1, 0])
|
||||
else
|
||||
while n > 0
|
||||
let l = len(matchstr(getline(n), '^\s*\ze[a-z]'))
|
||||
if l > 0 && l > ml
|
||||
let ml = l
|
||||
break
|
||||
endif
|
||||
let n += 1
|
||||
endwhile
|
||||
let sn = n
|
||||
if n == 0
|
||||
let ml = 0
|
||||
endif
|
||||
while n < line('$')
|
||||
let l = len(matchstr(getline(n), '^\s*[a-z]'))
|
||||
if l > 0 && l <= ml
|
||||
let n -= 1
|
||||
break
|
||||
endif
|
||||
let n += 1
|
||||
endwhile
|
||||
call setpos('.', [0, n, 1, 0])
|
||||
normal! V
|
||||
call setpos('.', [0, sn, 1, 0])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#slim#moveNextPrevItem(flag) abort
|
||||
return emmet#lang#slim#moveNextPrev(a:flag)
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#slim#moveNextPrev(flag) abort
|
||||
let pos = search('""\|\(^\s*|\s*\zs\)', a:flag ? 'Wpb' : 'Wp')
|
||||
if pos == 2
|
||||
startinsert!
|
||||
elseif pos != 0
|
||||
silent! normal! l
|
||||
startinsert
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#slim#splitJoinTag() abort
|
||||
let n = line('.')
|
||||
while n > 0
|
||||
if getline(n) =~# '^\s*\ze[a-z]'
|
||||
let sn = n
|
||||
let n += 1
|
||||
if getline(n) =~# '^\s*|'
|
||||
while n <= line('$')
|
||||
if getline(n) !~# '^\s*|'
|
||||
break
|
||||
endif
|
||||
exe n 'delete'
|
||||
endwhile
|
||||
call setpos('.', [0, sn, 1, 0])
|
||||
else
|
||||
let spaces = matchstr(getline(sn), '^\s*')
|
||||
call append(sn, spaces . ' | ')
|
||||
call setpos('.', [0, sn+1, 1, 0])
|
||||
startinsert!
|
||||
endif
|
||||
break
|
||||
endif
|
||||
let n -= 1
|
||||
endwhile
|
||||
endfunction
|
||||
|
||||
function! emmet#lang#slim#removeTag() abort
|
||||
let n = line('.')
|
||||
let ml = 0
|
||||
while n > 0
|
||||
if getline(n) =~# '^\s*\ze[a-z]'
|
||||
let ml = len(matchstr(getline(n), '^\s*[a-z]'))
|
||||
break
|
||||
endif
|
||||
let n -= 1
|
||||
endwhile
|
||||
let sn = n
|
||||
while n < line('$')
|
||||
let l = len(matchstr(getline(n), '^\s*[a-z]'))
|
||||
if l > 0 && l <= ml
|
||||
let n -= 1
|
||||
break
|
||||
endif
|
||||
let n += 1
|
||||
endwhile
|
||||
if sn == n
|
||||
exe 'delete'
|
||||
else
|
||||
exe sn ',' (n-1) 'delete'
|
||||
endif
|
||||
endfunction
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
function! emmet#lorem#en#expand(command) abort
|
||||
let wcount = matchstr(a:command, '\(\d*\)$')
|
||||
let wcount = wcount > 0 ? wcount : 30
|
||||
|
||||
let common = ['lorem', 'ipsum', 'dolor', 'sit', 'amet', 'consectetur', 'adipisicing', 'elit']
|
||||
let words = ['exercitationem', 'perferendis', 'perspiciatis', 'laborum', 'eveniet',
|
||||
\ 'sunt', 'iure', 'nam', 'nobis', 'eum', 'cum', 'officiis', 'excepturi',
|
||||
\ 'odio', 'consectetur', 'quasi', 'aut', 'quisquam', 'vel', 'eligendi',
|
||||
\ 'itaque', 'non', 'odit', 'tempore', 'quaerat', 'dignissimos',
|
||||
\ 'facilis', 'neque', 'nihil', 'expedita', 'vitae', 'vero', 'ipsum',
|
||||
\ 'nisi', 'animi', 'cumque', 'pariatur', 'velit', 'modi', 'natus',
|
||||
\ 'iusto', 'eaque', 'sequi', 'illo', 'sed', 'ex', 'et', 'voluptatibus',
|
||||
\ 'tempora', 'veritatis', 'ratione', 'assumenda', 'incidunt', 'nostrum',
|
||||
\ 'placeat', 'aliquid', 'fuga', 'provident', 'praesentium', 'rem',
|
||||
\ 'necessitatibus', 'suscipit', 'adipisci', 'quidem', 'possimus',
|
||||
\ 'voluptas', 'debitis', 'sint', 'accusantium', 'unde', 'sapiente',
|
||||
\ 'voluptate', 'qui', 'aspernatur', 'laudantium', 'soluta', 'amet',
|
||||
\ 'quo', 'aliquam', 'saepe', 'culpa', 'libero', 'ipsa', 'dicta',
|
||||
\ 'reiciendis', 'nesciunt', 'doloribus', 'autem', 'impedit', 'minima',
|
||||
\ 'maiores', 'repudiandae', 'ipsam', 'obcaecati', 'ullam', 'enim',
|
||||
\ 'totam', 'delectus', 'ducimus', 'quis', 'voluptates', 'dolores',
|
||||
\ 'molestiae', 'harum', 'dolorem', 'quia', 'voluptatem', 'molestias',
|
||||
\ 'magni', 'distinctio', 'omnis', 'illum', 'dolorum', 'voluptatum', 'ea',
|
||||
\ 'quas', 'quam', 'corporis', 'quae', 'blanditiis', 'atque', 'deserunt',
|
||||
\ 'laboriosam', 'earum', 'consequuntur', 'hic', 'cupiditate',
|
||||
\ 'quibusdam', 'accusamus', 'ut', 'rerum', 'error', 'minus', 'eius',
|
||||
\ 'ab', 'ad', 'nemo', 'fugit', 'officia', 'at', 'in', 'id', 'quos',
|
||||
\ 'reprehenderit', 'numquam', 'iste', 'fugiat', 'sit', 'inventore',
|
||||
\ 'beatae', 'repellendus', 'magnam', 'recusandae', 'quod', 'explicabo',
|
||||
\ 'doloremque', 'aperiam', 'consequatur', 'asperiores', 'commodi',
|
||||
\ 'optio', 'dolor', 'labore', 'temporibus', 'repellat', 'veniam',
|
||||
\ 'architecto', 'est', 'esse', 'mollitia', 'nulla', 'a', 'similique',
|
||||
\ 'eos', 'alias', 'dolore', 'tenetur', 'deleniti', 'porro', 'facere',
|
||||
\ 'maxime', 'corrupti']
|
||||
let ret = []
|
||||
let sentence = 0
|
||||
for i in range(wcount)
|
||||
let arr = common
|
||||
if sentence > 0
|
||||
let arr += words
|
||||
endif
|
||||
let r = emmet#util#rand()
|
||||
let word = arr[r % len(arr)]
|
||||
if sentence == 0
|
||||
let word = substitute(word, '^.', '\U&', '')
|
||||
endif
|
||||
let sentence += 1
|
||||
call add(ret, word)
|
||||
if (sentence > 5 && emmet#util#rand() < 10000) || i == wcount - 1
|
||||
if i == wcount - 1
|
||||
let endc = '?!...'[emmet#util#rand() % 5]
|
||||
call add(ret, endc)
|
||||
else
|
||||
let endc = '?!,...'[emmet#util#rand() % 6]
|
||||
call add(ret, endc . ' ')
|
||||
endif
|
||||
if endc !=# ','
|
||||
let sentence = 0
|
||||
endif
|
||||
else
|
||||
call add(ret, ' ')
|
||||
endif
|
||||
endfor
|
||||
return join(ret, '')
|
||||
endfunction
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
scriptencoding utf-8
|
||||
|
||||
function! emmet#lorem#ja#expand(command) abort
|
||||
let wcount = matchstr(a:command, '^\%(lorem\|lipsum\)\(\d*\)}$', '\1', '')
|
||||
let wcount = wcount > 0 ? wcount : 30
|
||||
|
||||
let url = "http://www.aozora.gr.jp/cards/000081/files/470_15407.html"
|
||||
let content = emmet#util#cache(url)
|
||||
if len(content) == 0
|
||||
let content = emmet#util#getContentFromURL(url)
|
||||
let content = matchstr(content, '<div[^>]*>\zs.\{-}</div>')
|
||||
let content = substitute(content, '[ \r]', '', 'g')
|
||||
let content = substitute(content, '<br[^>]*>', "\n", 'g')
|
||||
let content = substitute(content, '<[^>]\+>', '', 'g')
|
||||
let content = join(filter(split(content, "\n"), 'len(v:val)>0'), "\n")
|
||||
call emmet#util#cache(url, content)
|
||||
endif
|
||||
|
||||
let content = substitute(content, "、\n", "、", "g")
|
||||
let clines = split(content, '\n')
|
||||
let lines = filter(clines, 'len(substitute(v:val,".",".","g"))<=wcount')
|
||||
if len(lines) == 0
|
||||
let lines = clines
|
||||
endif
|
||||
let r = emmet#util#rand()
|
||||
return lines[r % len(lines)]
|
||||
endfunction
|
||||
|
|
@ -1,349 +0,0 @@
|
|||
"==============================================================================
|
||||
" region utils
|
||||
"==============================================================================
|
||||
" deleteContent : delete content in region
|
||||
" if region make from between '<foo>' and '</foo>'
|
||||
" --------------------
|
||||
" begin:<foo>
|
||||
" </foo>:end
|
||||
" --------------------
|
||||
" this function make the content as following
|
||||
" --------------------
|
||||
" begin::end
|
||||
" --------------------
|
||||
function! emmet#util#deleteContent(region) abort
|
||||
let lines = getline(a:region[0][0], a:region[1][0])
|
||||
call setpos('.', [0, a:region[0][0], a:region[0][1], 0])
|
||||
silent! exe 'delete '.(a:region[1][0] - a:region[0][0])
|
||||
call setline(line('.'), lines[0][:a:region[0][1]-2] . lines[-1][a:region[1][1]])
|
||||
endfunction
|
||||
|
||||
" change_content : change content in region
|
||||
" if region make from between '<foo>' and '</foo>'
|
||||
" --------------------
|
||||
" begin:<foo>
|
||||
" </foo>:end
|
||||
" --------------------
|
||||
" and content is
|
||||
" --------------------
|
||||
" foo
|
||||
" bar
|
||||
" baz
|
||||
" --------------------
|
||||
" this function make the content as following
|
||||
" --------------------
|
||||
" begin:foo
|
||||
" bar
|
||||
" baz:end
|
||||
" --------------------
|
||||
function! emmet#util#setContent(region, content) abort
|
||||
let newlines = split(a:content, '\n', 1)
|
||||
let oldlines = getline(a:region[0][0], a:region[1][0])
|
||||
call setpos('.', [0, a:region[0][0], a:region[0][1], 0])
|
||||
silent! exe 'delete '.(a:region[1][0] - a:region[0][0])
|
||||
if len(newlines) == 0
|
||||
let tmp = ''
|
||||
if a:region[0][1] > 1
|
||||
let tmp = oldlines[0][:a:region[0][1]-2]
|
||||
endif
|
||||
if a:region[1][1] >= 1
|
||||
let tmp .= oldlines[-1][a:region[1][1]:]
|
||||
endif
|
||||
call setline(line('.'), tmp)
|
||||
elseif len(newlines) == 1
|
||||
if a:region[0][1] > 1
|
||||
let newlines[0] = oldlines[0][:a:region[0][1]-2] . newlines[0]
|
||||
endif
|
||||
if a:region[1][1] >= 1
|
||||
let newlines[0] .= oldlines[-1][a:region[1][1]:]
|
||||
endif
|
||||
call setline(line('.'), newlines[0])
|
||||
else
|
||||
if a:region[0][1] > 1
|
||||
let newlines[0] = oldlines[0][:a:region[0][1]-2] . newlines[0]
|
||||
endif
|
||||
if a:region[1][1] >= 1
|
||||
let newlines[-1] .= oldlines[-1][a:region[1][1]:]
|
||||
endif
|
||||
call setline(line('.'), newlines[0])
|
||||
call append(line('.'), newlines[1:])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" select_region : select region
|
||||
" this function make a selection of region
|
||||
function! emmet#util#selectRegion(region) abort
|
||||
call setpos('.', [0, a:region[1][0], a:region[1][1], 0])
|
||||
normal! v
|
||||
call setpos('.', [0, a:region[0][0], a:region[0][1], 0])
|
||||
endfunction
|
||||
|
||||
" point_in_region : check point is in the region
|
||||
" this function return 0 or 1
|
||||
function! emmet#util#pointInRegion(point, region) abort
|
||||
if !emmet#util#regionIsValid(a:region) | return 0 | endif
|
||||
if a:region[0][0] > a:point[0] | return 0 | endif
|
||||
if a:region[1][0] < a:point[0] | return 0 | endif
|
||||
if a:region[0][0] == a:point[0] && a:region[0][1] > a:point[1] | return 0 | endif
|
||||
if a:region[1][0] == a:point[0] && a:region[1][1] < a:point[1] | return 0 | endif
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
" cursor_in_region : check cursor is in the region
|
||||
" this function return 0 or 1
|
||||
function! emmet#util#cursorInRegion(region) abort
|
||||
if !emmet#util#regionIsValid(a:region) | return 0 | endif
|
||||
let cur = emmet#util#getcurpos()[1:2]
|
||||
return emmet#util#pointInRegion(cur, a:region)
|
||||
endfunction
|
||||
|
||||
" region_is_valid : check region is valid
|
||||
" this function return 0 or 1
|
||||
function! emmet#util#regionIsValid(region) abort
|
||||
if a:region[0][0] == 0 || a:region[1][0] == 0 | return 0 | endif
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
" search_region : make region from pattern which is composing start/end
|
||||
" this function return array of position
|
||||
function! emmet#util#searchRegion(start, end) abort
|
||||
let b = searchpairpos(a:start, '', a:end, 'bcnW')
|
||||
if b == [0, 0]
|
||||
return [searchpairpos(a:start, '', a:end, 'bnW'), searchpairpos(a:start, '\%#', a:end, 'nW')]
|
||||
else
|
||||
return [b, searchpairpos(a:start, '', a:end. '', 'nW')]
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" get_content : get content in region
|
||||
" this function return string in region
|
||||
function! emmet#util#getContent(region) abort
|
||||
if !emmet#util#regionIsValid(a:region)
|
||||
return ''
|
||||
endif
|
||||
let lines = getline(a:region[0][0], a:region[1][0])
|
||||
if a:region[0][0] == a:region[1][0]
|
||||
let lines[0] = lines[0][a:region[0][1]-1:a:region[1][1]-1]
|
||||
else
|
||||
let lines[0] = lines[0][a:region[0][1]-1:]
|
||||
let lines[-1] = lines[-1][:a:region[1][1]-1]
|
||||
endif
|
||||
return join(lines, "\n")
|
||||
endfunction
|
||||
|
||||
" region_in_region : check region is in the region
|
||||
" this function return 0 or 1
|
||||
function! emmet#util#regionInRegion(outer, inner) abort
|
||||
if !emmet#util#regionIsValid(a:inner) || !emmet#util#regionIsValid(a:outer)
|
||||
return 0
|
||||
endif
|
||||
return emmet#util#pointInRegion(a:inner[0], a:outer) && emmet#util#pointInRegion(a:inner[1], a:outer)
|
||||
endfunction
|
||||
|
||||
" get_visualblock : get region of visual block
|
||||
" this function return region of visual block
|
||||
function! emmet#util#getVisualBlock() abort
|
||||
return [[line("'<"), col("'<")], [line("'>"), col("'>")]]
|
||||
endfunction
|
||||
|
||||
"==============================================================================
|
||||
" html utils
|
||||
"==============================================================================
|
||||
function! emmet#util#getContentFromURL(url) abort
|
||||
let res = system(printf('%s -i %s', g:emmet_curl_command, shellescape(substitute(a:url, '#.*', '', ''))))
|
||||
while res =~# '^HTTP/1.\d 3' || res =~# '^HTTP/1\.\d 200 Connection established' || res =~# '^HTTP/1\.\d 100 Continue'
|
||||
let pos = stridx(res, "\r\n\r\n")
|
||||
if pos != -1
|
||||
let res = strpart(res, pos+4)
|
||||
else
|
||||
let pos = stridx(res, "\n\n")
|
||||
let res = strpart(res, pos+2)
|
||||
endif
|
||||
endwhile
|
||||
let pos = stridx(res, "\r\n\r\n")
|
||||
if pos != -1
|
||||
let content = strpart(res, pos+4)
|
||||
else
|
||||
let pos = stridx(res, "\n\n")
|
||||
let content = strpart(res, pos+2)
|
||||
endif
|
||||
let header = res[:pos-1]
|
||||
let charset = matchstr(content, '<meta[^>]\+content=["''][^;"'']\+;\s*charset=\zs[^;"'']\+\ze["''][^>]*>')
|
||||
if len(charset) == 0
|
||||
let charset = matchstr(content, '<meta\s\+charset=["'']\?\zs[^"'']\+\ze["'']\?[^>]*>')
|
||||
endif
|
||||
if len(charset) == 0
|
||||
let charset = matchstr(header, '\nContent-Type:.* charset=[''"]\?\zs[^''";\n]\+\ze')
|
||||
endif
|
||||
if len(charset) == 0
|
||||
let s1 = len(split(content, '?'))
|
||||
let utf8 = iconv(content, 'utf-8', &encoding)
|
||||
let s2 = len(split(utf8, '?'))
|
||||
return (s2 == s1 || s2 >= s1 * 2) ? utf8 : content
|
||||
endif
|
||||
return iconv(content, charset, &encoding)
|
||||
endfunction
|
||||
|
||||
function! emmet#util#getTextFromHTML(buf) abort
|
||||
let threshold_len = 100
|
||||
let threshold_per = 0.1
|
||||
let buf = a:buf
|
||||
|
||||
let buf = strpart(buf, stridx(buf, '</head>'))
|
||||
let buf = substitute(buf, '<style[^>]*>.\{-}</style>', '', 'g')
|
||||
let buf = substitute(buf, '<script[^>]*>.\{-}</script>', '', 'g')
|
||||
let res = ''
|
||||
let max = 0
|
||||
let mx = '\(<td[^>]\{-}>\)\|\(<\/td>\)\|\(<div[^>]\{-}>\)\|\(<\/div>\)'
|
||||
let m = split(buf, mx)
|
||||
for str in m
|
||||
let c = split(str, '<[^>]*?>')
|
||||
let str = substitute(str, '<[^>]\{-}>', ' ', 'g')
|
||||
let str = substitute(str, '>', '>', 'g')
|
||||
let str = substitute(str, '<', '<', 'g')
|
||||
let str = substitute(str, '"', '"', 'g')
|
||||
let str = substitute(str, ''', '''', 'g')
|
||||
let str = substitute(str, ' ', ' ', 'g')
|
||||
let str = substitute(str, '¥', '\¥', 'g')
|
||||
let str = substitute(str, '&', '\&', 'g')
|
||||
let str = substitute(str, '^\s*\(.*\)\s*$', '\1', '')
|
||||
let str = substitute(str, '\s\+', ' ', 'g')
|
||||
let l = len(str)
|
||||
if l > threshold_len
|
||||
let per = (l+0.0) / len(c)
|
||||
if max < l && per > threshold_per
|
||||
let max = l
|
||||
let res = str
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
let res = substitute(res, '^\s*\(.*\)\s*$', '\1', 'g')
|
||||
return res
|
||||
endfunction
|
||||
|
||||
function! emmet#util#getImageSize(fn) abort
|
||||
let fn = a:fn
|
||||
|
||||
if emmet#util#isImageMagickInstalled()
|
||||
return emmet#util#imageSizeWithImageMagick(fn)
|
||||
endif
|
||||
|
||||
if filereadable(fn)
|
||||
let hex = substitute(system('xxd -p "'.fn.'"'), '\n', '', 'g')
|
||||
else
|
||||
if fn !~# '^\w\+://'
|
||||
let path = fnamemodify(expand('%'), ':p:gs?\\?/?')
|
||||
if has('win32') || has('win64') |
|
||||
let path = tolower(path)
|
||||
endif
|
||||
for k in keys(g:emmet_docroot)
|
||||
let root = fnamemodify(k, ':p:gs?\\?/?')
|
||||
if has('win32') || has('win64') |
|
||||
let root = tolower(root)
|
||||
endif
|
||||
if stridx(path, root) == 0
|
||||
let v = g:emmet_docroot[k]
|
||||
let fn = (len(v) == 0 ? k : v) . fn
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
let hex = substitute(system(g:emmet_curl_command.' "'.fn.'" | xxd -p'), '\n', '', 'g')
|
||||
endif
|
||||
|
||||
let [width, height] = [-1, -1]
|
||||
if hex =~# '^89504e470d0a1a0a'
|
||||
let width = eval('0x'.hex[32:39])
|
||||
let height = eval('0x'.hex[40:47])
|
||||
endif
|
||||
if hex =~# '^ffd8'
|
||||
let pos = 4
|
||||
while pos < len(hex)
|
||||
let bs = hex[pos+0:pos+3]
|
||||
let pos += 4
|
||||
if bs ==# 'ffc0' || bs ==# 'ffc2'
|
||||
let pos += 6
|
||||
let height = eval('0x'.hex[pos+0:pos+1])*256 + eval('0x'.hex[pos+2:pos+3])
|
||||
let pos += 4
|
||||
let width = eval('0x'.hex[pos+0:pos+1])*256 + eval('0x'.hex[pos+2:pos+3])
|
||||
break
|
||||
elseif bs =~# 'ffd[9a]'
|
||||
break
|
||||
elseif bs =~# 'ff\(e[0-9a-e]\|fe\|db\|dd\|c4\)'
|
||||
let pos += (eval('0x'.hex[pos+0:pos+1])*256 + eval('0x'.hex[pos+2:pos+3])) * 2
|
||||
endif
|
||||
endwhile
|
||||
endif
|
||||
if hex =~# '^47494638'
|
||||
let width = eval('0x'.hex[14:15].hex[12:13])
|
||||
let height = eval('0x'.hex[18:19].hex[16:17])
|
||||
endif
|
||||
|
||||
return [width, height]
|
||||
endfunction
|
||||
|
||||
function! emmet#util#imageSizeWithImageMagick(fn) abort
|
||||
let img_info = system('identify -format "%wx%h" "'.a:fn.'"')
|
||||
let img_size = split(substitute(img_info, '\n', '', ''), 'x')
|
||||
if len(img_size) != 2
|
||||
return [-1, -1]
|
||||
endif
|
||||
return img_size
|
||||
endfunction
|
||||
|
||||
function! emmet#util#isImageMagickInstalled() abort
|
||||
if !get(g:, 'emmet_use_identify', 1)
|
||||
return 0
|
||||
endif
|
||||
return executable('identify')
|
||||
endfunction
|
||||
|
||||
function! emmet#util#unique(arr) abort
|
||||
let m = {}
|
||||
let r = []
|
||||
for i in a:arr
|
||||
if !has_key(m, i)
|
||||
let m[i] = 1
|
||||
call add(r, i)
|
||||
endif
|
||||
endfor
|
||||
return r
|
||||
endfunction
|
||||
|
||||
let s:seed = localtime()
|
||||
function! emmet#util#srand(seed) abort
|
||||
let s:seed = a:seed
|
||||
endfunction
|
||||
|
||||
function! emmet#util#rand() abort
|
||||
let s:seed = s:seed * 214013 + 2531011
|
||||
return (s:seed < 0 ? s:seed - 0x80000000 : s:seed) / 0x10000 % 0x8000
|
||||
endfunction
|
||||
|
||||
function! emmet#util#cache(name, ...) abort
|
||||
let content = get(a:000, 0, '')
|
||||
let dir = expand('~/.emmet/cache')
|
||||
if !isdirectory(dir)
|
||||
call mkdir(dir, 'p', 0700)
|
||||
endif
|
||||
let file = dir . '/' . substitute(a:name, '\W', '_', 'g')
|
||||
if len(content) == 0
|
||||
if !filereadable(file)
|
||||
return ''
|
||||
endif
|
||||
return join(readfile(file), "\n")
|
||||
endif
|
||||
call writefile(split(content, "\n"), file)
|
||||
endfunction
|
||||
|
||||
function! emmet#util#getcurpos() abort
|
||||
let pos = getpos('.')
|
||||
if mode(0) ==# 'i' && pos[2] > 0
|
||||
let pos[2] -=1
|
||||
endif
|
||||
return pos
|
||||
endfunction
|
||||
|
||||
function! emmet#util#closePopup() abort
|
||||
return pumvisible() ? "\<c-e>" : ''
|
||||
endfunction
|
||||
File diff suppressed because it is too large
Load diff
Binary file not shown.
|
Before Width: | Height: | Size: 32 KiB |
|
|
@ -1,93 +0,0 @@
|
|||
:Emmet emmet.txt /*:Emmet*
|
||||
:EmmetInstall emmet.txt /*:EmmetInstall*
|
||||
<C-y>, emmet.txt /*<C-y>,*
|
||||
<C-y>/ emmet.txt /*<C-y>\/*
|
||||
<C-y>; emmet.txt /*<C-y>;*
|
||||
<C-y>A emmet.txt /*<C-y>A*
|
||||
<C-y>D emmet.txt /*<C-y>D*
|
||||
<C-y>N emmet.txt /*<C-y>N*
|
||||
<C-y>a emmet.txt /*<C-y>a*
|
||||
<C-y>c emmet.txt /*<C-y>c*
|
||||
<C-y>d emmet.txt /*<C-y>d*
|
||||
<C-y>i emmet.txt /*<C-y>i*
|
||||
<C-y>j emmet.txt /*<C-y>j*
|
||||
<C-y>k emmet.txt /*<C-y>k*
|
||||
<C-y>m emmet.txt /*<C-y>m*
|
||||
<C-y>n emmet.txt /*<C-y>n*
|
||||
<C-y>u emmet.txt /*<C-y>u*
|
||||
Emmet emmet.txt /*Emmet*
|
||||
emmet emmet.txt /*emmet*
|
||||
emmet-# emmet.txt /*emmet-#*
|
||||
emmet-$ emmet.txt /*emmet-$*
|
||||
emmet-$# emmet.txt /*emmet-$#*
|
||||
emmet-() emmet.txt /*emmet-()*
|
||||
emmet-+ emmet.txt /*emmet-+*
|
||||
emmet-. emmet.txt /*emmet-.*
|
||||
emmet-> emmet.txt /*emmet->*
|
||||
emmet-@ emmet.txt /*emmet-@*
|
||||
emmet-[] emmet.txt /*emmet-[]*
|
||||
emmet-^ emmet.txt /*emmet-^*
|
||||
emmet-abbreviation emmet.txt /*emmet-abbreviation*
|
||||
emmet-alias emmet.txt /*emmet-alias*
|
||||
emmet-balance-tag-inward emmet.txt /*emmet-balance-tag-inward*
|
||||
emmet-balance-tag-outward emmet.txt /*emmet-balance-tag-outward*
|
||||
emmet-code-pretty emmet.txt /*emmet-code-pretty*
|
||||
emmet-commands emmet.txt /*emmet-commands*
|
||||
emmet-contents emmet.txt /*emmet-contents*
|
||||
emmet-css-expression-syntax emmet.txt /*emmet-css-expression-syntax*
|
||||
emmet-css-properties emmet.txt /*emmet-css-properties*
|
||||
emmet-css-units emmet.txt /*emmet-css-units*
|
||||
emmet-css-values emmet.txt /*emmet-css-values*
|
||||
emmet-css-vendor-prefixes emmet.txt /*emmet-css-vendor-prefixes*
|
||||
emmet-custom-snippets emmet.txt /*emmet-custom-snippets*
|
||||
emmet-customize emmet.txt /*emmet-customize*
|
||||
emmet-customize-key-mappings emmet.txt /*emmet-customize-key-mappings*
|
||||
emmet-define-tags-behavior emmet.txt /*emmet-define-tags-behavior*
|
||||
emmet-expand-abbr emmet.txt /*emmet-expand-abbr*
|
||||
emmet-expand-word emmet.txt /*emmet-expand-word*
|
||||
emmet-filter emmet.txt /*emmet-filter*
|
||||
emmet-filter-c emmet.txt /*emmet-filter-c*
|
||||
emmet-filter-e emmet.txt /*emmet-filter-e*
|
||||
emmet-filter-s emmet.txt /*emmet-filter-s*
|
||||
emmet-filter-t emmet.txt /*emmet-filter-t*
|
||||
emmet-filters-list emmet.txt /*emmet-filters-list*
|
||||
emmet-goto-next-point emmet.txt /*emmet-goto-next-point*
|
||||
emmet-goto-previous-point emmet.txt /*emmet-goto-previous-point*
|
||||
emmet-html-attr-quote-char emmet.txt /*emmet-html-attr-quote-char*
|
||||
emmet-html-expression-syntax emmet.txt /*emmet-html-expression-syntax*
|
||||
emmet-html-implicit-tag-names emmet.txt /*emmet-html-implicit-tag-names*
|
||||
emmet-html-syntax-attribute-operators emmet.txt /*emmet-html-syntax-attribute-operators*
|
||||
emmet-html-syntax-elements emmet.txt /*emmet-html-syntax-elements*
|
||||
emmet-html-syntax-nesting-operators emmet.txt /*emmet-html-syntax-nesting-operators*
|
||||
emmet-html-syntax-notes emmet.txt /*emmet-html-syntax-notes*
|
||||
emmet-indent-size emmet.txt /*emmet-indent-size*
|
||||
emmet-install emmet.txt /*emmet-install*
|
||||
emmet-introduction emmet.txt /*emmet-introduction*
|
||||
emmet-links emmet.txt /*emmet-links*
|
||||
emmet-lorem-ipsum emmet.txt /*emmet-lorem-ipsum*
|
||||
emmet-make-anchor-url emmet.txt /*emmet-make-anchor-url*
|
||||
emmet-merge-lines emmet.txt /*emmet-merge-lines*
|
||||
emmet-quoted-text-url emmet.txt /*emmet-quoted-text-url*
|
||||
emmet-remove-tag emmet.txt /*emmet-remove-tag*
|
||||
emmet-snippet emmet.txt /*emmet-snippet*
|
||||
emmet-split-join-tag emmet.txt /*emmet-split-join-tag*
|
||||
emmet-star emmet.txt /*emmet-star*
|
||||
emmet-todo emmet.txt /*emmet-todo*
|
||||
emmet-toggle-comment emmet.txt /*emmet-toggle-comment*
|
||||
emmet-tutorial emmet.txt /*emmet-tutorial*
|
||||
emmet-update-image-size emmet.txt /*emmet-update-image-size*
|
||||
emmet-update-tag emmet.txt /*emmet-update-tag*
|
||||
emmet-variables emmet.txt /*emmet-variables*
|
||||
emmet-wrap-with-abbreviation emmet.txt /*emmet-wrap-with-abbreviation*
|
||||
emmet-{} emmet.txt /*emmet-{}*
|
||||
emmet.txt emmet.txt /*emmet.txt*
|
||||
g:emmet_curl_command emmet.txt /*g:emmet_curl_command*
|
||||
g:emmet_docroot emmet.txt /*g:emmet_docroot*
|
||||
g:emmet_html5 emmet.txt /*g:emmet_html5*
|
||||
g:user_emmet_complete_tag emmet.txt /*g:user_emmet_complete_tag*
|
||||
g:user_emmet_install_command emmet.txt /*g:user_emmet_install_command*
|
||||
g:user_emmet_install_global emmet.txt /*g:user_emmet_install_global*
|
||||
g:user_emmet_leader_key emmet.txt /*g:user_emmet_leader_key*
|
||||
g:user_emmet_mode emmet.txt /*g:user_emmet_mode*
|
||||
g:user_emmet_settings emmet.txt /*g:user_emmet_settings*
|
||||
v_<C-y>, emmet.txt /*v_<C-y>,*
|
||||
|
|
@ -1,277 +0,0 @@
|
|||
script_name: Emmet.vim
|
||||
script_id: '2981'
|
||||
script_type: utility
|
||||
script_package: emmet-vim.zip
|
||||
script_version: '0.86'
|
||||
required_vim_version: '7.0'
|
||||
summary: vim plugins for HTML and CSS hi-speed coding.
|
||||
|
||||
detailed_description: |
|
||||
|
||||
This is vim script support expanding abbreviation like emmet.
|
||||
ref: http://emmet.io/
|
||||
|
||||
There is a movie using emmet.vim
|
||||
ref: http://mattn.github.com/emmet-vim
|
||||
|
||||
Source Repository.
|
||||
ref: http://github.com/mattn/emmet-vim
|
||||
|
||||
Type abbreviation
|
||||
+-------------------------------------
|
||||
| html:5_
|
||||
+-------------------------------------
|
||||
"_" is a cursor position. and type "<c-y>," (Ctrl + y and Comma)
|
||||
NOTE: Don't worry about key map. you can change it easily.
|
||||
+-------------------------------------
|
||||
| <!DOCTYPE HTML>
|
||||
| <html lang="en">
|
||||
| <head>
|
||||
| <title></title>
|
||||
| <meta charset="UTF-8">
|
||||
| </head>
|
||||
| <body>
|
||||
| _
|
||||
| </body>
|
||||
| </html>
|
||||
+-------------------------------------
|
||||
Type following
|
||||
+-------------------------------------
|
||||
| div#foo$*2>div.bar
|
||||
+-------------------------------------
|
||||
And type "<c-y>,"
|
||||
+-------------------------------------
|
||||
|<div id="foo1">
|
||||
| <div class="bar">_</div>
|
||||
|</div>
|
||||
|<div id="foo2">
|
||||
| <div class="bar"></div>
|
||||
|</div>
|
||||
| _
|
||||
+-------------------------------------
|
||||
|
||||
Tutorial:
|
||||
|
||||
http://github.com/mattn/emmet-vim/raw/master/TUTORIAL
|
||||
|
||||
How work this:
|
||||
|
||||
http://mattn.github.com/emmet-vim
|
||||
|
||||
Tips:
|
||||
|
||||
You can customize behavior of expanding with overriding config.
|
||||
This configuration will be merged at loading plugin.
|
||||
|
||||
let g:user_emmet_settings = {
|
||||
\ 'indentation' : ' ',
|
||||
\ 'perl' : {
|
||||
\ 'aliases' : {
|
||||
\ 'req' : 'require '
|
||||
\ },
|
||||
\ 'snippets' : {
|
||||
\ 'use' : "use strict\nuse warnings\n\n",
|
||||
\ 'warn' : "warn \"|\";",
|
||||
\ }
|
||||
\ }
|
||||
\}
|
||||
|
||||
let g:user_emmet_expandabbr_key = '<c-e>'
|
||||
|
||||
let g:use_emmet_complete_tag = 1
|
||||
|
||||
You can set language attribute in html using emmet_settings['lang'].
|
||||
|
||||
install_details: |
|
||||
|
||||
# cd ~/.vim
|
||||
# unzip emmet-vim.zip
|
||||
|
||||
or if you install pathogen.vim:
|
||||
|
||||
# cd ~/.vim/bundle # or make directory
|
||||
# unzip /path/to/emmet-vim.zip
|
||||
|
||||
if you get sources from repository:
|
||||
|
||||
# cd ~/.vim/bundle # or make directory
|
||||
# git clone http://github.com/mattn/emmet-vim.git
|
||||
|
||||
versions:
|
||||
- '0.86': |
|
||||
This is an upgrade for Emmet.vim: lot of bug fixes.
|
||||
- '0.85': |
|
||||
This is an upgrade for Emmet.vim: lot of bug fixes.
|
||||
- '0.84': |
|
||||
This is an upgrade for Emmet.vim: lot of bug fixes. fix bug that interpose insert completion plugins.
|
||||
- '0.83': |
|
||||
This is an upgrade for Emmet.vim: lot of bug fixes.
|
||||
- '0.82': |
|
||||
This is an upgrade for Emmet.vim: many bug fixes.
|
||||
- '0.81': |
|
||||
Release of Emmet.vim: renamed from ZenCoding.vim.
|
||||
- '0.80': |
|
||||
This is an upgrade for ZenCoding.vim: add emmet features.
|
||||
- '0.74': |
|
||||
This is an upgrade for ZenCoding.vim: many bug fixes.
|
||||
- '0.73': |
|
||||
This is an upgrade for ZenCoding.vim: many bug fixes. and support slim format (experimental).
|
||||
- '0.72': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
[fix] fix finding tokens.
|
||||
- '0.71': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
[fix] fix finding begin of tokens.
|
||||
- '0.70': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
[mod] Changed behavior of expanding. "div div>a|" should keep first div element.
|
||||
[add] Supported slim formatter.
|
||||
- '0.60': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
[fix] fixed expanding {{}}.
|
||||
- '0.59': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
[fix] fixed toggleComment and mny bugs.
|
||||
- '0.58': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
[fix] fixed 'foo+' style expandos.
|
||||
- '0.57': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
[fix] fixed expandos that don't work 'choose' in xsl.
|
||||
- '0.56': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
[fix] fixed contents parser.
|
||||
- '0.55': |
|
||||
uploaded again: sorry, files was old.
|
||||
- '0.54': |
|
||||
[add] support sass, xsd.
|
||||
[fix] expanding with html tag.
|
||||
uploaded again: sorry, fileformat was DOS.
|
||||
- '0.53': |
|
||||
[fix] gif width/height was swapped.
|
||||
- '0.52': |
|
||||
[fix] broken wrap expanding.
|
||||
- '0.51': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
[fix] wrap expanding with '&'.
|
||||
[fix] expand .content to class="content".
|
||||
[fix] haml expanding.
|
||||
[fix] bg+ snippet
|
||||
- '0.50': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
[fix] fixed parsing '#{{foo}}' and '.{{bar}}'.
|
||||
- '0.49': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
[doc] add help manual.
|
||||
- '0.48': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
[fix] install mappings to global.
|
||||
- '0.47': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
[drastic changes] enable autoload. you should whole replace older files.
|
||||
package was empty. upload again.
|
||||
- '0.46': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
[drastic changes] enable autoload. you should whole replace older files.
|
||||
- '0.45': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
fixed attribute parsing like: a[href="hello', world" rel].
|
||||
- '0.44': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
fixed checking whether have mapping using maparg() / hasmapto().
|
||||
- '0.43': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
fixed behavior for nested block. like "html:5>#page>(header#globalHeader>(hgroup>h1+h2)+(nav>ul>li*3>a)+(form>p.siteSearch>input+input[type=button]))+(#contents>(#main>(section>h2+p*5)+p.pagetop>a[href=#page])+(#sub>p+(nav>ul>li>a)))+(footer#globalFoooter>(ul>li>a)+(p.copyright>small))"
|
||||
- '0.42': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
fixed select/option indent.
|
||||
- '0.41': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
fixed default filter. when using 'e' filter, output become empty.
|
||||
- '0.40': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
add the pure vimscript code for 'get image size'. you can use it without perl interface just now.
|
||||
change key assign of ZenCodingExpandWord from ',' to ';'. it don't effect to most users.
|
||||
- '0.39': |
|
||||
This is an upgrade for ZenCoding.vim: fixed problem about 'selection'. see http://github.com/mattn/zencoding-vim/issues/#issue/2
|
||||
- '0.38': |
|
||||
This is an upgrade for ZenCoding.vim: use v7h"_s instead of v7hs for backspace.
|
||||
- '0.37': |
|
||||
This is an upgrade for ZenCoding.vim: fixed problem that won't working with some 'backspace' options.
|
||||
- '0.36': |
|
||||
This is an upgrade for ZenCoding.vim: fixed problem that filter does not work.
|
||||
- '0.35': |
|
||||
This is an upgrade for ZenCoding.vim: enable zencoding for other languages. (meaning php also)
|
||||
- '0.34': |
|
||||
This is an upgrade for ZenCoding.vim: enable zencoding for xsl. (you should add ~/.vim/ftplugin/xslt/zencoding.vim)
|
||||
- '0.33': |
|
||||
This is an upgrade for ZenCoding.vim: fixed problem breaking multibyte when cursor is in a part of line. enabled zencoding for javascript in html.
|
||||
- '0.32': |
|
||||
This is an upgrade for ZenCoding.vim: fixed indentation. supported extends so that you can enable zencoding for php/xhtml/haml other's section 14 in http://github.com/mattn/zencoding-vim/raw/master/TUTORIAL
|
||||
- '0.31': |
|
||||
This is an upgrade for ZenCoding.vim: fixed indentation and $$$ problem. fixed about missing support multiple classes.
|
||||
- '0.30': |
|
||||
This is an upgrade for ZenCoding.vim: Fixed key assign.
|
||||
- '0.29': |
|
||||
This is an upgrade for ZenCoding.vim: Changed leading key to '<c-y>' from '<c-z>'.
|
||||
- '0.28': |
|
||||
This is an upgrade for ZenCoding.vim: supported 'Balance Tag Inward/Outward', 'Go to Next/Previous Edit Point', 'Update <img> Size', 'Remove Tag', 'Split/Join Tag', 'Toggle Comment'
|
||||
- '0.27': |
|
||||
This is an upgrade for ZenCoding.vim: fixed problem that can't work on the part of multibyte characters. fixed inline elements behavior.
|
||||
- '0.26': |
|
||||
This is an upgrade for ZenCoding.vim: The count of '(((a#foo + a#bar)*2)*3)' should be 12.
|
||||
- '0.25': |
|
||||
This is an upgrade for ZenCoding.vim: store undo before working. good luck about 'table>(tr>td*3)*4'.
|
||||
- '0.24': |
|
||||
This is an upgrade for ZenCoding.vim: fixed behavior of parsing area of visual selection.
|
||||
- '0.23': |
|
||||
This is an upgrade for ZenCoding.vim: pre-expand '#header>li<#content' to 'div#header>li<div#content'. support () expression.
|
||||
- '0.22': |
|
||||
This is an upgrade for ZenCoding.vim: expand 'ul+' to 'ul>li'. fix undo ring. support visual selection. when type trigger key on visual select, it request you leader like 'ul>li'. if you give 'ul>li*' as leader, you'll get each separate 'ul>li' tags. and when you give 'blockquote' as leader, you'll get blocked text.
|
||||
- '0.21': |
|
||||
This is an upgrade for ZenCoding.vim: treat xhtml as html.
|
||||
- '0.20': |
|
||||
This is an upgrade for ZenCoding.vim: add option use_zen_complete_tag for complete abbr.
|
||||
- '0.19': |
|
||||
This is an upgrade for ZenCoding.vim: fixed problem that couldn't expand 'link:css' correctly.
|
||||
- '0.18': |
|
||||
This is an upgrade for ZenCoding.vim: ignore duplicate key map.
|
||||
- '0.17': |
|
||||
This is an upgrade for ZenCoding.vim: fixed key map.
|
||||
- '0.16': |
|
||||
This is an upgrade for ZenCoding.vim: fixed problem 'endless loop'.
|
||||
- '0.15': |
|
||||
This is an upgrade for ZenCoding.vim: set default filetype to 'html'.
|
||||
- '0.14': |
|
||||
This is an upgrade for ZenCoding.vim: fixed tag name like 'fs:n' in 'css'.
|
||||
- '0.14': |
|
||||
This is an upgrade for ZenCoding.vim: indentation for each languages.
|
||||
- '0.13': |
|
||||
This is an upgrade for ZenCoding.vim: user key map.
|
||||
- '0.12': |
|
||||
This is an upgrade for ZenCoding.vim: few extensive notation.
|
||||
- '0.11': |
|
||||
This is an upgrade for ZenCoding.vim: fixed indent.
|
||||
- '0.10': |
|
||||
This is an upgrade for ZenCoding.vim: fixed behavior of '+' operator
|
||||
- '0.9': |
|
||||
This is an upgrade for ZenCoding.vim: fixed single line behavior
|
||||
- '0.8': |
|
||||
This is an upgrade for ZenCoding.vim: support 'a[href=http://www.google.com]{Google}'
|
||||
- '0.7': |
|
||||
This is an upgrade for ZenCoding.vim: fixed behavior in 'a+b'.
|
||||
- '0.6': |
|
||||
This is an upgrade for ZenCoding.vim: fixed strange behavior about '<a href="">b_</a>'.
|
||||
- '0.5': |
|
||||
This is an upgrade for ZenCoding.vim: recover rest part in line.
|
||||
- '0.4': |
|
||||
This is an upgrade for ZenCoding.vim: fixed cursor position. fixed ${lang} replacement.
|
||||
- '0.3': |
|
||||
This is an upgrade for ZenCoding.vim: fixed line expanding.
|
||||
- '0.2': |
|
||||
This is an upgrade for ZenCoding.vim: fixed problem that moving cursor with expanding.
|
||||
- '0.1': |
|
||||
Initial upload
|
||||
|
||||
# __END__
|
||||
# vim: filetype=yaml
|
||||
|
|
@ -1,177 +0,0 @@
|
|||
"=============================================================================
|
||||
" File: emmet.vim
|
||||
" Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
|
||||
" Last Change: 26-Jul-2015.
|
||||
" Version: 0.86
|
||||
" WebPage: http://github.com/mattn/emmet-vim
|
||||
" Description: vim plugins for HTML and CSS hi-speed coding.
|
||||
" SeeAlso: http://emmet.io/
|
||||
" Usage:
|
||||
"
|
||||
" This is vim script support expanding abbreviation like emmet.
|
||||
" ref: http://emmet.io/
|
||||
"
|
||||
" Type abbreviation
|
||||
" +-------------------------------------
|
||||
" | html:5_
|
||||
" +-------------------------------------
|
||||
" "_" is a cursor position. and type "<c-y>," (Ctrl+y and Comma)
|
||||
" NOTE: Don't worry about key map. you can change it easily.
|
||||
" +-------------------------------------
|
||||
" | <!DOCTYPE HTML>
|
||||
" | <html lang="en">
|
||||
" | <head>
|
||||
" | <title></title>
|
||||
" | <meta charset="UTF-8">
|
||||
" | </head>
|
||||
" | <body>
|
||||
" | _
|
||||
" | </body>
|
||||
" | </html>
|
||||
" +-------------------------------------
|
||||
" Type following
|
||||
" +-------------------------------------
|
||||
" | div#foo$*2>div.bar
|
||||
" +-------------------------------------
|
||||
" And type "<c-y>,"
|
||||
" +-------------------------------------
|
||||
" |<div id="foo1">
|
||||
" | <div class="bar">_</div>
|
||||
" |</div>
|
||||
" |<div id="foo2">
|
||||
" | <div class="bar"></div>
|
||||
" |</div>
|
||||
" +-------------------------------------
|
||||
"
|
||||
" Tips:
|
||||
"
|
||||
" You can customize behavior of expanding with overriding config.
|
||||
" This configuration will be marged at loading plugin.
|
||||
"
|
||||
" let g:user_emmet_settings = {
|
||||
" \ 'indentation' : ' ',
|
||||
" \ 'perl' : {
|
||||
" \ 'aliases' : {
|
||||
" \ 'req' : 'require '
|
||||
" \ },
|
||||
" \ 'snippets' : {
|
||||
" \ 'use' : "use strict\nuse warnings\n\n",
|
||||
" \ 'warn' : "warn \"|\";",
|
||||
" \ }
|
||||
" \ }
|
||||
" \}
|
||||
"
|
||||
" You can set language attribute in html using 'emmet_settings.lang'.
|
||||
"
|
||||
" GetLatestVimScripts: 2981 1 :AutoInstall: emmet.vim
|
||||
" script type: plugin
|
||||
|
||||
if &compatible || v:version < 702 || (exists('g:loaded_emmet_vim') && g:loaded_emmet_vim)
|
||||
finish
|
||||
endif
|
||||
let g:loaded_emmet_vim = 1
|
||||
|
||||
let s:save_cpo = &cpoptions
|
||||
set cpoptions&vim
|
||||
|
||||
if !exists('g:emmet_html5')
|
||||
let g:emmet_html5 = 1
|
||||
endif
|
||||
|
||||
if !exists('g:emmet_docroot')
|
||||
let g:emmet_docroot = {}
|
||||
endif
|
||||
|
||||
if !exists('g:emmet_debug')
|
||||
let g:emmet_debug = 0
|
||||
endif
|
||||
|
||||
if !exists('g:emmet_curl_command')
|
||||
let g:emmet_curl_command = 'curl -s -L -A Mozilla/5.0'
|
||||
endif
|
||||
|
||||
if !exists('g:user_emmet_leader_key')
|
||||
let g:user_emmet_leader_key = '<c-y>'
|
||||
endif
|
||||
|
||||
function! s:install_plugin(mode, buffer)
|
||||
let buffer = a:buffer ? '<buffer>' : ''
|
||||
let items = [
|
||||
\ {'mode': 'i', 'var': 'user_emmet_expandabbr_key', 'key': ',', 'plug': 'emmet-expand-abbr', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#expandAbbr(0,"")<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_expandabbr_key', 'key': ',', 'plug': 'emmet-expand-abbr', 'func': ':call emmet#expandAbbr(3,"")<cr>'},
|
||||
\ {'mode': 'v', 'var': 'user_emmet_expandabbr_key', 'key': ',', 'plug': 'emmet-expand-abbr', 'func': ':call emmet#expandAbbr(2,"")<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_expandword_key', 'key': ';', 'plug': 'emmet-expand-word', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#expandAbbr(1,"")<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_expandword_key', 'key': ';', 'plug': 'emmet-expand-word', 'func': ':call emmet#expandAbbr(1,"")<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_update_tag', 'key': 'u', 'plug': 'emmet-update-tag', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#updateTag()<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_update_tag', 'key': 'u', 'plug': 'emmet-update-tag', 'func': ':call emmet#updateTag()<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_balancetaginward_key', 'key': 'd', 'plug': 'emmet-balance-tag-inward', 'func': '<esc>:call emmet#balanceTag(1)<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_balancetaginward_key', 'key': 'd', 'plug': 'emmet-balance-tag-inward', 'func': ':call emmet#balanceTag(1)<cr>'},
|
||||
\ {'mode': 'v', 'var': 'user_emmet_balancetaginward_key', 'key': 'd', 'plug': 'emmet-balance-tag-inward', 'func': ':call emmet#balanceTag(2)<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_balancetagoutward_key', 'key': 'D', 'plug': 'emmet-balance-tag-outword', 'func': '<esc>:call emmet#balanceTag(-1)<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_balancetagoutward_key', 'key': 'D', 'plug': 'emmet-balance-tag-outword', 'func': ':call emmet#balanceTag(-1)<cr>'},
|
||||
\ {'mode': 'v', 'var': 'user_emmet_balancetagoutward_key', 'key': 'D', 'plug': 'emmet-balance-tag-outword', 'func': ':call emmet#balanceTag(-2)<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_next_key', 'key': 'n', 'plug': 'emmet-move-next', 'func': '<esc>:call emmet#moveNextPrev(0)<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_next_key', 'key': 'n', 'plug': 'emmet-move-next', 'func': ':call emmet#moveNextPrev(0)<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_prev_key', 'key': 'N', 'plug': 'emmet-move-prev', 'func': '<esc>:call emmet#moveNextPrev(1)<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_prev_key', 'key': 'N', 'plug': 'emmet-move-prev', 'func': ':call emmet#moveNextPrev(1)<cr>'},
|
||||
\ {'mode': 'i', 'var': '', 'key': '', 'plug': 'emmet-move-next-item', 'func': '<esc>:call emmet#moveNextPrevItem(0)<cr>'},
|
||||
\ {'mode': 'n', 'var': '', 'key': '', 'plug': 'emmet-move-next-item', 'func': ':call emmet#moveNextPrevItem(0)<cr>'},
|
||||
\ {'mode': 'i', 'var': '', 'key': '', 'plug': 'emmet-move-prev-item', 'func': '<esc>:call emmet#moveNextPrevItem(1)<cr>'},
|
||||
\ {'mode': 'n', 'var': '', 'key': '', 'plug': 'emmet-move-prev-item', 'func': ':call emmet#moveNextPrevItem(1)<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_imagesize_key', 'key': 'i', 'plug': 'emmet-image-size', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#imageSize()<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_imagesize_key', 'key': 'i', 'plug': 'emmet-image-size', 'func': ':call emmet#imageSize()<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_togglecomment_key', 'key': '/', 'plug': 'emmet-toggle-comment', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#toggleComment()<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_togglecomment_key', 'key': '/', 'plug': 'emmet-toggle-comment', 'func': ':call emmet#toggleComment()<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_splitjointag_key', 'key': 'j', 'plug': 'emmet-split-join-tag', 'func': '<esc>:call emmet#splitJoinTag()<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_splitjointag_key', 'key': 'j', 'plug': 'emmet-split-join-tag', 'func': ':call emmet#splitJoinTag()<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_removetag_key', 'key': 'k', 'plug': 'emmet-remove-tag', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#removeTag()<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_removetag_key', 'key': 'k', 'plug': 'emmet-remove-tag', 'func': ':call emmet#removeTag()<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_anchorizeurl_key', 'key': 'a', 'plug': 'emmet-anchorize-url', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#anchorizeURL(0)<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_anchorizeurl_key', 'key': 'a', 'plug': 'emmet-anchorize-url', 'func': ':call emmet#anchorizeURL(0)<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_emmet_anchorizesummary_key', 'key': 'A', 'plug': 'emmet-anchorize-summary', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#anchorizeURL(1)<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_emmet_anchorizesummary_key', 'key': 'A', 'plug': 'emmet-anchorize-summary', 'func': ':call emmet#anchorizeURL(1)<cr>'},
|
||||
\ {'mode': 'v', 'var': 'user_emmet_mergelines_key', 'key': 'm', 'plug': 'emmet-merge-lines', 'func': ':call emmet#mergeLines()<cr>'},
|
||||
\ {'mode': 'v', 'var': 'user_emmet_codepretty_key', 'key': 'c', 'plug': 'emmet-code-pretty', 'func': ':call emmet#codePretty()<cr>'},
|
||||
\]
|
||||
|
||||
let only_plug = get(g:, 'emmet_install_only_plug', 0)
|
||||
for item in items
|
||||
if a:mode !=# 'a' && stridx(a:mode, item.mode) == -1
|
||||
continue
|
||||
endif
|
||||
exe item.mode . 'noremap '. buffer .' <plug>(' . item.plug . ') ' . item.func
|
||||
if item.var != '' && !only_plug
|
||||
if exists('g:' . item.var)
|
||||
let key = eval('g:' . item.var)
|
||||
else
|
||||
let key = g:user_emmet_leader_key . item.key
|
||||
endif
|
||||
if !hasmapto('<plug>(' . item.plug . ')', item.mode) && !len(maparg(key, item.mode))
|
||||
exe item.mode . 'map ' . buffer . ' <unique> ' . key . ' <plug>(' . item.plug . ')'
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
|
||||
if exists('g:user_emmet_complete_tag') && g:user_emmet_complete_tag
|
||||
if get(g:, 'user_emmet_install_global', 1)
|
||||
set omnifunc=emmet#completeTag
|
||||
else
|
||||
setlocal omnifunc=emmet#completeTag
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
command! -nargs=0 -bar EmmetInstall call <SID>install_plugin(get(g:, 'user_emmet_mode', 'a'), 1)
|
||||
|
||||
if get(g:, 'user_emmet_install_global', 1)
|
||||
call s:install_plugin(get(g:, 'user_emmet_mode', 'a'), 0)
|
||||
endif
|
||||
|
||||
if get(g:, 'user_emmet_install_command', 1)
|
||||
command! -nargs=1 Emmet call emmet#expandAbbr(4, <q-args>)
|
||||
endif
|
||||
|
||||
let &cpoptions = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim:set et:
|
||||
File diff suppressed because it is too large
Load diff
Binary file not shown.
|
|
@ -1,17 +0,0 @@
|
|||
SHELL=/bin/bash
|
||||
|
||||
all: dist
|
||||
|
||||
dist:
|
||||
@rm supertab.vmb 2> /dev/null || true
|
||||
@vim -c 'r! git ls-files doc plugin' \
|
||||
-c '$$,$$d _' -c '%MkVimball supertab .' -c 'q!'
|
||||
|
||||
clean:
|
||||
@rm -R build 2> /dev/null || true
|
||||
|
||||
install: supertab.vmb
|
||||
vim $< -c 'so %' -c 'q'
|
||||
|
||||
uninstall:
|
||||
vim -c 'RmVimball supertab.vmb' -c 'q'
|
||||
|
|
@ -1,172 +0,0 @@
|
|||
.. Copyright (c) 2012 - 2014, Eric Van Dewoestine
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this software in source and binary forms, with
|
||||
or without modification, are permitted provided that the following
|
||||
conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
|
||||
* Neither the name of Eric Van Dewoestine nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission of
|
||||
Eric Van Dewoestine.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
.. _overview:
|
||||
|
||||
==================
|
||||
Overview
|
||||
==================
|
||||
|
||||
Supertab is a vim plugin which allows you to use <Tab> for all your insert
|
||||
completion needs (:help ins-completion).
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
- Configurable to suit you needs:
|
||||
|
||||
- Default completion type to use.
|
||||
- Prevent <Tab> from completing after/before defined patterns.
|
||||
- Close vim's completion preview window when code completion is finished.
|
||||
- When using other completion types, you can configure how long to 'remember'
|
||||
the current completion type before returning to the default.
|
||||
- Don't like using <Tab>? You can also configure a different pair of keys to
|
||||
scroll forwards and backwards through completion results.
|
||||
|
||||
- Optional improved 'longest' completion support (after typing some characters,
|
||||
hitting <Tab> will highlight the next longest match).
|
||||
- Built in 'context' completion option which chooses the appropriate completion
|
||||
type based on the text preceding the cursor.
|
||||
|
||||
- You can also plug in your own functions to determine which completion type
|
||||
to use.
|
||||
|
||||
- Support for simple completion chaining (falling back to a different
|
||||
completion type, keyword completion for example, if omni or user completion
|
||||
returns no results).
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
You have a few options when it comes to installing supertab:
|
||||
|
||||
1. Use your linux package manager:
|
||||
|
||||
Some linux distributions include a supertab package so you don't have to
|
||||
manage the install/upgrade of supertab separately from other software on your
|
||||
system.
|
||||
|
||||
2. Use a vim plugin manager:
|
||||
|
||||
There are several plugin managers for vim, which will either allow you to
|
||||
manually clone vim plugin repositories, or will do so for you. Probably the
|
||||
two most popular ones currently are `pathogen
|
||||
<https://github.com/tpope/vim-pathogen>`_ and `vundle
|
||||
<https://github.com/gmarik/Vundle.vim>`_. Please refer to their docs for
|
||||
instructions on how to install plugins.
|
||||
|
||||
3. And lastly you can use the vimball (.vmb) file found on
|
||||
`vim.org <http://www.vim.org/scripts/script.php?script_id=1643>`_:
|
||||
|
||||
Vimball files are installed by simply opening them in vim and then sourcing
|
||||
the file:
|
||||
|
||||
::
|
||||
|
||||
$ vim supertab.vmb
|
||||
:source %
|
||||
|
||||
Frequently Asked Questions
|
||||
--------------------------
|
||||
|
||||
- **Why isn't supertab honoring my configured settings (attempts to complete at the
|
||||
start of a line, always performs keyword completion instead of my configured
|
||||
default, etc.)?**
|
||||
|
||||
Chances are that you have a very old version of `snipmate
|
||||
<https://github.com/msanders/snipmate.vim>`_ installed, or something similar,
|
||||
which will issue a `<c-n>` when no snippet is found. Supertab use to map to
|
||||
`<c-n>`, so this behavior would act as a fallback to supertab, but current
|
||||
versions of supertab no longer do so, resulting in snipmate bypassing supertab
|
||||
entirely.
|
||||
|
||||
You can check if this is the case by running the following in vim to see what
|
||||
is mapped to `<tab>`:
|
||||
|
||||
::
|
||||
|
||||
:verbose imap <tab>
|
||||
|
||||
To resolve the issue you can either:
|
||||
|
||||
#. Install my `fork <https://github.com/ervandew/snipmate.vim>`_ or
|
||||
#. Upgrade to a more recent snipmate fork, like `garbas/vim-snipmate
|
||||
<https://github.com/garbas/vim-snipmate>`_
|
||||
|
||||
See `#74 <https://github.com/ervandew/supertab/issues/74>`_ for additional
|
||||
details.
|
||||
|
||||
- **Why does <tab> navigate the completion menu from bottom to top?**
|
||||
|
||||
First, if after reading the explanation below (or if you don't want to bother
|
||||
reading it), you still want the default to scroll down the list then you can
|
||||
use:
|
||||
|
||||
::
|
||||
|
||||
let g:SuperTabDefaultCompletionType = "<c-n>"
|
||||
|
||||
or if your default completion type is currently `context` then you can use
|
||||
this instead:
|
||||
|
||||
::
|
||||
|
||||
let g:SuperTabContextDefaultCompletionType = "<c-n>"
|
||||
|
||||
Now on to the reasoning behind this. When using `<c-p>` or `<c-n>` to start
|
||||
insert completion, both populate the completion popup with the same list of
|
||||
words in the same order, the only difference is that `<c-p>` highlights the
|
||||
nearest matching word located above the current cursor position, which is the
|
||||
result at the bottom of the completion popup. Without supertab installed,
|
||||
continuing to hit `<c-p>` will walk up the list to next nearest word above the
|
||||
cursor.
|
||||
|
||||
I think Bram chose to display the results like this so that
|
||||
|
||||
#. the completion logic is the same for `<c-n>` and `<c-p>`, only the first
|
||||
entry to highlight differs
|
||||
#. so that the behavior of `<c-p>` mode is consistent, always moving up the
|
||||
list and
|
||||
#. when starting `<c-p>` mode you don't have to switch over to
|
||||
using `<c-n>` to get the next nearest entry, just continue to hit `<c-p>`.
|
||||
|
||||
So, with supertab I wanted to preserve the same behavior. If `<c-p>` is your
|
||||
default completion method (supertab defaults to this being the case), then
|
||||
`<tab>` will start it and additional uses of `<tab>` will move up the list
|
||||
instead of down so that you don't have to suddenly switch to using `<s-tab>`
|
||||
to get the next nearest result.
|
||||
|
||||
Why is `<c-p>` the supertab default? The original supertab author found (and I
|
||||
agree with his finding) that while coding, the keyword match you want is
|
||||
typically the closer of the matches above the cursor, which `<c-p>` naturally
|
||||
provides.
|
||||
|
|
@ -1,473 +0,0 @@
|
|||
*supertab.txt*
|
||||
|
||||
Author: Eric Van Dewoestine <ervandew@gmail.com>
|
||||
Original concept and versions up to 0.32 written by
|
||||
Gergely Kontra <kgergely@mcl.hu>
|
||||
|
||||
This plugin is licensed under the terms of the BSD License. Please see
|
||||
supertab.vim for the license in its entirety.
|
||||
|
||||
==============================================================================
|
||||
Supertab *supertab*
|
||||
|
||||
1. Introduction |supertab-intro|
|
||||
2. Supertab Usage |supertab-usage|
|
||||
3. Supertab Options |supertab-options|
|
||||
Default completion type |supertab-defaultcompletion|
|
||||
Secondary default completion type |supertab-contextdefault|
|
||||
Completion contexts |supertab-completioncontexts|
|
||||
Context text |supertab-contexttext|
|
||||
Context Discover |supertab-contextdiscover|
|
||||
Example |supertab-contextexample|
|
||||
Completion Duration |supertab-duration|
|
||||
Preventing Completion After/Before... |supertab-preventcomplete|
|
||||
Changing default mapping |supertab-forwardbackward|
|
||||
Inserting true tabs |supertab-mappingtabliteral|
|
||||
Enhanced longest match support |supertab-longestenhanced|
|
||||
Preselecting the first entry |supertab-longesthighlight|
|
||||
Mapping <cr> to end completion |supertab-crmapping|
|
||||
Auto close the preview window |supertab-closepreviewonpopupclose|
|
||||
Keyword completion ignore/match case |supertab-completecase|
|
||||
Completion Chaining |supertab-completionchaining|
|
||||
|
||||
==============================================================================
|
||||
1. Introduction *supertab-intro*
|
||||
|
||||
Supertab is a plugin which allows you to perform all your insert completion
|
||||
(|ins-completion|) using the tab key.
|
||||
|
||||
Supertab requires Vim version 7.0 or above.
|
||||
|
||||
==============================================================================
|
||||
2. Supertab usage *supertab-usage*
|
||||
|
||||
Using Supertab is as easy as hitting <Tab> or <S-Tab> (shift+tab) while in
|
||||
insert mode, with at least one non whitespace character before the cursor, to
|
||||
start the completion and then <Tab> or <S-Tab> again to cycle forwards or
|
||||
backwards through the available completions.
|
||||
|
||||
Example ('|' denotes the cursor location):
|
||||
|
||||
bar
|
||||
baz
|
||||
b|<Tab> Hitting <Tab> here will start the completion, allowing you to
|
||||
then cycle through the suggested words ('bar' and 'baz').
|
||||
|
||||
==============================================================================
|
||||
3. Supertab Options *supertab-options*
|
||||
|
||||
Supertab is configured via several global variables that you can set in your
|
||||
|vimrc| file according to your needs. Below is a comprehensive list of
|
||||
the variables available.
|
||||
|
||||
|
||||
Default Completion Type *supertab-defaultcompletion*
|
||||
*g:SuperTabDefaultCompletionType*
|
||||
|
||||
g:SuperTabDefaultCompletionType (default value: "<c-p>")
|
||||
|
||||
Used to set the default completion type. There is no need to escape this
|
||||
value as that will be done for you when the type is set.
|
||||
|
||||
Example: setting the default completion to 'user' completion:
|
||||
|
||||
>
|
||||
let g:SuperTabDefaultCompletionType = "<c-x><c-u>"
|
||||
<
|
||||
|
||||
Note: a special value of 'context' is supported which will result in
|
||||
super tab attempting to use the text preceding the cursor to decide which
|
||||
type of completion to attempt. Currently supertab can recognize method calls
|
||||
or attribute references via '.', '::' or '->', and file path references
|
||||
containing '/'. If the language you are using doesn't use any of the member
|
||||
reference characters listed above, or you'd like to add additional patterns,
|
||||
you can write a custom context function also described in the next section
|
||||
(Completion context).
|
||||
|
||||
Example: setting the default completion to supertab's 'context' completion:
|
||||
>
|
||||
let g:SuperTabDefaultCompletionType = "context"
|
||||
<
|
||||
|
||||
/usr/l<tab> # will use filename completion
|
||||
myvar.t<tab> # will use user completion if completefunc set,
|
||||
# or omni completion if omnifunc set.
|
||||
myvar-><tab> # same as above
|
||||
|
||||
When using context completion, super tab will fall back to a secondary default
|
||||
completion type set by |g:SuperTabContextDefaultCompletionType|.
|
||||
|
||||
Note: once the buffer has been initialized, changing the value of this setting
|
||||
will not change the default complete type used. If you want to change the
|
||||
default completion type for the current buffer after it has been set, perhaps
|
||||
in an ftplugin, you'll need to call *SuperTabSetDefaultCompletionType* like so,
|
||||
supplying the completion type you wish to switch to:
|
||||
|
||||
>
|
||||
call SuperTabSetDefaultCompletionType("<c-x><c-u>")
|
||||
<
|
||||
|
||||
|
||||
Secondary default completion type *supertab-contextdefault*
|
||||
*g:SuperTabContextDefaultCompletionType*
|
||||
|
||||
g:SuperTabContextDefaultCompletionType (default value: "<c-p>")
|
||||
|
||||
Sets the default completion type used when g:SuperTabDefaultCompletionType is
|
||||
set to 'context' and no completion type is returned by any of the configured
|
||||
contexts.
|
||||
|
||||
Note: supertab also supports the b:SuperTabContextDefaultCompletionType
|
||||
variable allowing you to set the default type separately for the current
|
||||
buffer, like from an ftplugin for example.
|
||||
|
||||
|
||||
Completion contexts *supertab-completioncontexts*
|
||||
*g:SuperTabCompletionContexts*
|
||||
|
||||
g:SuperTabCompletionContexts (default value: ['s:ContextText'])
|
||||
|
||||
Sets the list of contexts used for context completion. This value should
|
||||
be a list of function names which provide the context implementation.
|
||||
|
||||
When supertab starts context completion, each of these contexts will be
|
||||
consulted, in the order they were supplied, to determine the completion type
|
||||
to use. If a context returns a completion type, that type will be used,
|
||||
otherwise the next context in the list will be consulted. If after executing
|
||||
all the context functions, no completion type has been determined, then the
|
||||
value of |g:SuperTabContextDefaultCompletionType| will be used.
|
||||
|
||||
Note: supertab also supports the b:SuperTabCompletionContexts variable
|
||||
allowing you to set the list of contexts separately for the current buffer,
|
||||
like from an ftplugin for example.
|
||||
|
||||
Built in completion contexts:
|
||||
|
||||
s:ContextText *supertab-contexttext*
|
||||
|
||||
The text context will examine the text near the cursor to decide which type
|
||||
of completion to attempt. Currently the text context can recognize method
|
||||
calls or attribute references via '.', '::' or '->', and file path
|
||||
references containing '/'.
|
||||
|
||||
/usr/l<tab> # will use filename completion
|
||||
myvar.t<tab> # will use user completion if completefunc set, or
|
||||
# omni completion if omnifunc set.
|
||||
myvar-><tab> # same as above
|
||||
|
||||
Supported configuration attributes:
|
||||
|
||||
*g:SuperTabContextTextFileTypeExclusions*
|
||||
List of file types for which the text context will be skipped.
|
||||
|
||||
*g:SuperTabContextTextOmniPrecedence* (default: ['&completefunc', '&omnifunc'])
|
||||
*b:SuperTabContextTextOmniPrecedence*
|
||||
List of omni completion option names in the order of precedence that they
|
||||
should be used if available. By default, user completion will be given
|
||||
precedence over omni completion, but you can use this variable to give
|
||||
omni completion higher precedence by placing it first in the list.
|
||||
|
||||
*g:SuperTabContextTextMemberPatterns* (default: ['\.', '>\?::', '->'])
|
||||
*b:SuperTabContextTextMemberPatterns*
|
||||
List of patterns used to determine when omni/user completion should be
|
||||
used. The default list consists of the most common patterns used to access
|
||||
module/class/object members.
|
||||
|
||||
Note: For html and xml based files, the buffer local version of the above
|
||||
two settings are set to trigger omni completion first when encountering a
|
||||
potential end tag pattern of '</'.
|
||||
|
||||
s:ContextDiscover *supertab-contextdiscover*
|
||||
|
||||
This context will use the 'g:SuperTabContextDiscoverDiscovery' variable to
|
||||
determine the completion type to use. It will evaluate each value, in the
|
||||
order they were defined, until a variable evaluates to a non-zero or
|
||||
non-empty value, then the associated completion type is used.
|
||||
|
||||
Supported configuration properties:
|
||||
|
||||
g:SuperTabContextDiscoverDiscovery
|
||||
List of variable:completionType mappings.
|
||||
|
||||
Example context configuration: *supertab-contextexample*
|
||||
|
||||
>
|
||||
let g:SuperTabCompletionContexts = ['s:ContextText', 's:ContextDiscover']
|
||||
let g:SuperTabContextTextOmniPrecedence = ['&omnifunc', '&completefunc']
|
||||
let g:SuperTabContextDiscoverDiscovery =
|
||||
\ ["&completefunc:<c-x><c-u>", "&omnifunc:<c-x><c-o>"]
|
||||
<
|
||||
|
||||
In addition to the default completion contexts, you can plug in your own
|
||||
implementation by creating a globally accessible function that returns
|
||||
the completion type to use (eg. "\<c-x>\<c-u>").
|
||||
|
||||
>
|
||||
function MyTagContext()
|
||||
if filereadable(expand('%:p:h') . '/tags')
|
||||
return "\<c-x>\<c-]>"
|
||||
endif
|
||||
" no return will result in the evaluation of the next
|
||||
" configured context
|
||||
endfunction
|
||||
let g:SuperTabCompletionContexts =
|
||||
\ ['MyTagContext', 's:ContextText', 's:ContextDiscover']
|
||||
<
|
||||
|
||||
Here is another example that could be used to add context support for
|
||||
clojure, and perhaps other lisp variants:
|
||||
|
||||
>
|
||||
let b:SuperTabCompletionContexts =
|
||||
\ ['ClojureContext'] + g:SuperTabCompletionContexts
|
||||
|
||||
function! ClojureContext()
|
||||
let curline = getline('.')
|
||||
let cnum = col('.')
|
||||
let synname = synIDattr(synID(line('.'), cnum - 1, 1), 'name')
|
||||
if curline =~ '(\S\+\%' . cnum . 'c' && synname !~ '\(String\|Comment\)'
|
||||
return "\<c-x>\<c-o>"
|
||||
endif
|
||||
endfunction
|
||||
<
|
||||
|
||||
|
||||
Completion Duration *supertab-duration*
|
||||
*g:SuperTabRetainCompletionDuration*
|
||||
|
||||
g:SuperTabRetainCompletionDuration (default value: 'insert')
|
||||
|
||||
Determines if, and for how long, the current completion type is retained.
|
||||
The possible values include:
|
||||
'completion' - The current completion type is only retained for the
|
||||
current completion. Once you have chosen a completion
|
||||
result or exited the completion mode, the default
|
||||
completion type is restored.
|
||||
'insert' - The current completion type is saved until you exit insert
|
||||
mode (via ESC). Once you exit insert mode the default
|
||||
completion type is restored. (supertab default)
|
||||
'session' - The current completion type is saved for the duration of
|
||||
your vim session or until you enter a different completion
|
||||
mode.
|
||||
|
||||
|
||||
Preventing completion after... *supertab-preventcomplete*
|
||||
*g:SuperTabNoCompleteBefore*
|
||||
*g:SuperTabNoCompleteAfter*
|
||||
|
||||
g:SuperTabNoCompleteBefore (default value: [])
|
||||
g:SuperTabNoCompleteAfter (default value: ['^', '\s'])
|
||||
|
||||
These two variables are used to control when supertab will attempt completion
|
||||
or instead fall back to inserting a literal <tab>. There are two possible ways
|
||||
to define these variables:
|
||||
|
||||
1) by specifying a list of patterns which are tested against the text before
|
||||
and after the current cursor position that when matched, prevent completion.
|
||||
So if you don't want supertab to start completion at the start of a line,
|
||||
after a comma, or after a space, you can set g:SuperTabNoCompleteAfter
|
||||
to ['^', ',', '\s'].
|
||||
|
||||
2) by specifying a funcref to a global accessible function which expects
|
||||
as parameter the text to be inspected (before or after) and, based on that (or
|
||||
other factors), it returns 1 if completion must be prevented, 0 otherwise.
|
||||
|
||||
Note: That a buffer local version of these variables
|
||||
(b:SuperTabNoCompleteBefore, b:SuperTabNoCompleteAfter) are also supported
|
||||
should you wish to have different values depending on the file type for
|
||||
instance.
|
||||
|
||||
Changing the default mapping *supertab-forwardbackward*
|
||||
*g:SuperTabMappingForward*
|
||||
*g:SuperTabMappingBackward*
|
||||
|
||||
g:SuperTabMappingForward (default value: '<tab>')
|
||||
g:SuperTabMappingBackward (default value: '<s-tab>')
|
||||
|
||||
These two variables allow you to set the keys used to kick off the current
|
||||
completion. By default this is <tab> and <s-tab>. To change to something
|
||||
like <c-space> and <s-c-space>, you can add the following to your |vimrc|.
|
||||
|
||||
>
|
||||
let g:SuperTabMappingForward = '<c-space>'
|
||||
let g:SuperTabMappingBackward = '<s-c-space>'
|
||||
>
|
||||
|
||||
Note: if the above does not have the desired effect (which may happen in
|
||||
console version of vim), you can try the following mappings. Although the
|
||||
backwards mapping still doesn't seem to work in the console for me, your
|
||||
milage may vary.
|
||||
|
||||
>
|
||||
let g:SuperTabMappingForward = '<nul>'
|
||||
let g:SuperTabMappingBackward = '<s-nul>'
|
||||
<
|
||||
|
||||
|
||||
Inserting true tabs *supertab-mappingtabliteral*
|
||||
*g:SuperTabMappingTabLiteral*
|
||||
|
||||
g:SuperTabMappingTabLiteral (default value: '<c-tab>')
|
||||
|
||||
Sets the key mapping used to insert a literal tab where supertab would
|
||||
otherwise attempt to kick off insert completion. The default is '<c-tab>'
|
||||
(ctrl-tab) which unfortunately might not work at the console. So if you are
|
||||
using a console vim and want this functionality, you may have to change it to
|
||||
something that is supported. Alternatively, you can escape the <tab> with
|
||||
<c-v> (see |i_CTRL-V| for more infos).
|
||||
|
||||
See also |supertab-preventcomplete|.
|
||||
|
||||
|
||||
Enhanced longest match support *supertab-longestenhanced*
|
||||
*g:SuperTabLongestEnhanced*
|
||||
|
||||
g:SuperTabLongestEnhanced (default value: 0)
|
||||
|
||||
When enabled and 'longest' is in your |completeopt| setting, supertab will
|
||||
provide an enhanced longest match support where typing one or more letters and
|
||||
hitting tab again while in a completion mode will complete the longest common
|
||||
match using the new text in the buffer.
|
||||
|
||||
For example, say you have a buffer with the following contents:
|
||||
FooBarFoo
|
||||
FooBar
|
||||
Foo
|
||||
FooBarBaz
|
||||
And you then type F<tab>. Vim's builtin longest support will complete the
|
||||
longest common text 'Foo' and offer 'FooBarFoo', 'FooBar', 'Foo', and
|
||||
'FooBarBaz' as possible completions. With supertab's longest match
|
||||
enhancement disabled, typing B<tab> while still in the completion mode will
|
||||
end up completing 'FooBarBaz' or 'FooBarFoo' depending your settings, instead
|
||||
of the next longest common match of 'FooBar'. With supertab's enhanced
|
||||
longest match feature enabled, the typing of B<tab> will result in the next
|
||||
longest text being completed.
|
||||
|
||||
|
||||
Preselecting the first entry *supertab-longesthighlight*
|
||||
*g:SuperTabLongestHighlight*
|
||||
|
||||
g:SuperTabLongestHighlight (default value: 0)
|
||||
|
||||
Sets whether or not to pre-highlight the first match when completeopt has the
|
||||
popup menu enabled and the 'longest' option as well. When enabled, <tab> will
|
||||
kick off completion and pre-select the first entry in the popup menu, allowing
|
||||
you to simply hit <enter> to use it.
|
||||
|
||||
|
||||
Mapping <cr> to end completion *supertab-crmapping*
|
||||
*g:SuperTabCrMapping*
|
||||
|
||||
g:SuperTabCrMapping (default value: 0)
|
||||
|
||||
When enabled, <cr> will cancel completion mode preserving the current text.
|
||||
|
||||
Compatibility with other plugins:
|
||||
- endwise: compatible
|
||||
- delimitMate: not compatible (disabled if the delimitMate <cr> mapping is
|
||||
detected.)
|
||||
|
||||
Note: if you have an insert expression mapping with a <cr> in it or an insert
|
||||
abbreviation containing a <cr>, then supertab will not create a <cr> mapping
|
||||
which could potentially cause problems with those.
|
||||
|
||||
|
||||
Auto close the preview window *supertab-closepreviewonpopupclose*
|
||||
*g:SuperTabClosePreviewOnPopupClose*
|
||||
|
||||
g:SuperTabClosePreviewOnPopupClose (default value: 0)
|
||||
|
||||
When enabled, supertab will attempt to close vim's completion preview window
|
||||
when the completion popup closes (completion is finished or canceled).
|
||||
|
||||
|
||||
Completion ignore/match case *supertab-completecase*
|
||||
*g:SuperTabCompleteCase*
|
||||
|
||||
g:SuperTabCompleteCase (default value: 'inherit')
|
||||
|
||||
When issuing completions (keyword and potentially others), the value of your
|
||||
|'ignorecase'| setting will determine what results are returned based on
|
||||
whether or not you've chosen to ignore case or not. However, you may have
|
||||
|'ignorecase'| set or unset for other reasons and don't want that value
|
||||
considered when using insert completion. SuperTab allows you temporarily
|
||||
override |'ignorecase'| by setting g:SuperTabCompleteCase to either 'ignore'
|
||||
or 'match' depending on whether you want to always ignore or match case when
|
||||
using insert completion.
|
||||
|
||||
Note: third party omni/user completion plugins may or may not honor
|
||||
|'ignorecase'|. If they do not, then you can probably contact them to add that
|
||||
support.
|
||||
|
||||
Completion Chaining *supertab-completionchaining*
|
||||
|
||||
SuperTab provides the ability to chain one of the completion functions
|
||||
(|completefunc| or |omnifunc|) together with one of the default vim
|
||||
completion key sequences (|ins-completion|), giving you the ability to attempt
|
||||
completion with the first, and upon no results, fall back to the second.
|
||||
|
||||
To utilize this feature you need to call the *SuperTabChain* function where
|
||||
the first argument is the name of a vim compatible |complete-function| and the
|
||||
second is one of vim's insert completion (|ins-completion|) key bindings
|
||||
(<c-p>, <c-n>, <c-x><c-]>, etc). Calling this function will set the current
|
||||
buffer's |completefunc| option to a supertab provided implementation which
|
||||
utilizes the supplied arguments to perform the completion.
|
||||
|
||||
Here is an example that can be added to your .vimrc which will setup the
|
||||
supertab chaining for any filetype that has a provided |omnifunc| to first
|
||||
try that, then fall back to supertab's default, <c-p>, completion:
|
||||
|
||||
>
|
||||
autocmd FileType *
|
||||
\ if &omnifunc != '' |
|
||||
\ call SuperTabChain(&omnifunc, "<c-p>") |
|
||||
\ endif
|
||||
<
|
||||
|
||||
You can also specify whether or not the 'context' completion method will
|
||||
be used as part of your completion chaining. If you've already set your
|
||||
default completion type to 'context', then no further action is needed. If
|
||||
however you haven't set that or don't want to use 'context' completion in this
|
||||
case, then you can supply a third argument to SuperTabChain which is a boolean
|
||||
(1 or 0) indicationg whether you want to use 'context' completion (1) or not
|
||||
(0).
|
||||
|
||||
Here is an example where 'context' is the global default and completion
|
||||
chaining is enabled for file types that have omni completion support:
|
||||
|
||||
>
|
||||
let g:SuperTabDefaultCompletionType = 'context'
|
||||
autocmd FileType *
|
||||
\ if &omnifunc != '' |
|
||||
\ call SuperTabChain(&omnifunc, "<c-p>") |
|
||||
\ endif
|
||||
<
|
||||
|
||||
This configuration will result in a completion flow like so:
|
||||
|
||||
if text before the cursor looks like a file path:
|
||||
use file completion
|
||||
elif text before the cursor looks like an attempt to access a member
|
||||
(method, field, etc):
|
||||
use user completion
|
||||
where user completion is currently set to supertab's
|
||||
completion chaining, resulting in:
|
||||
if omni completion has results:
|
||||
use omni completion
|
||||
else:
|
||||
use keyword completion
|
||||
else:
|
||||
use keyword completion
|
||||
|
||||
Note: Completion chaining only supports chaining 1 completion function (omni
|
||||
or user) with 1 regular completion keybinding. All other combinations of
|
||||
completions (2 or more completion functions, 2 or more key bindings, etc.) are
|
||||
not supported due to limitations imposed by vim's code completion
|
||||
implementation.
|
||||
|
||||
Note: If the |completefunc| or |omnifunc| use vim's |complete_add()| instead
|
||||
of returning completion results as a list, then Supertab's completion chaining
|
||||
won't work properly with it since Supertab uses the function result to
|
||||
determine if it should fallback to the next completion type.
|
||||
|
||||
vim:tw=78:ts=8:ft=help:norl:
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
SuperTabChain supertab.txt /*SuperTabChain*
|
||||
SuperTabSetDefaultCompletionType supertab.txt /*SuperTabSetDefaultCompletionType*
|
||||
b:SuperTabContextTextMemberPatterns supertab.txt /*b:SuperTabContextTextMemberPatterns*
|
||||
b:SuperTabContextTextOmniPrecedence supertab.txt /*b:SuperTabContextTextOmniPrecedence*
|
||||
g:SuperTabClosePreviewOnPopupClose supertab.txt /*g:SuperTabClosePreviewOnPopupClose*
|
||||
g:SuperTabCompleteCase supertab.txt /*g:SuperTabCompleteCase*
|
||||
g:SuperTabCompletionContexts supertab.txt /*g:SuperTabCompletionContexts*
|
||||
g:SuperTabContextDefaultCompletionType supertab.txt /*g:SuperTabContextDefaultCompletionType*
|
||||
g:SuperTabContextTextFileTypeExclusions supertab.txt /*g:SuperTabContextTextFileTypeExclusions*
|
||||
g:SuperTabContextTextMemberPatterns supertab.txt /*g:SuperTabContextTextMemberPatterns*
|
||||
g:SuperTabContextTextOmniPrecedence supertab.txt /*g:SuperTabContextTextOmniPrecedence*
|
||||
g:SuperTabCrMapping supertab.txt /*g:SuperTabCrMapping*
|
||||
g:SuperTabDefaultCompletionType supertab.txt /*g:SuperTabDefaultCompletionType*
|
||||
g:SuperTabLongestEnhanced supertab.txt /*g:SuperTabLongestEnhanced*
|
||||
g:SuperTabLongestHighlight supertab.txt /*g:SuperTabLongestHighlight*
|
||||
g:SuperTabMappingBackward supertab.txt /*g:SuperTabMappingBackward*
|
||||
g:SuperTabMappingForward supertab.txt /*g:SuperTabMappingForward*
|
||||
g:SuperTabMappingTabLiteral supertab.txt /*g:SuperTabMappingTabLiteral*
|
||||
g:SuperTabNoCompleteAfter supertab.txt /*g:SuperTabNoCompleteAfter*
|
||||
g:SuperTabNoCompleteBefore supertab.txt /*g:SuperTabNoCompleteBefore*
|
||||
g:SuperTabRetainCompletionDuration supertab.txt /*g:SuperTabRetainCompletionDuration*
|
||||
supertab supertab.txt /*supertab*
|
||||
supertab-closepreviewonpopupclose supertab.txt /*supertab-closepreviewonpopupclose*
|
||||
supertab-completecase supertab.txt /*supertab-completecase*
|
||||
supertab-completionchaining supertab.txt /*supertab-completionchaining*
|
||||
supertab-completioncontexts supertab.txt /*supertab-completioncontexts*
|
||||
supertab-contextdefault supertab.txt /*supertab-contextdefault*
|
||||
supertab-contextdiscover supertab.txt /*supertab-contextdiscover*
|
||||
supertab-contextexample supertab.txt /*supertab-contextexample*
|
||||
supertab-contexttext supertab.txt /*supertab-contexttext*
|
||||
supertab-crmapping supertab.txt /*supertab-crmapping*
|
||||
supertab-defaultcompletion supertab.txt /*supertab-defaultcompletion*
|
||||
supertab-duration supertab.txt /*supertab-duration*
|
||||
supertab-forwardbackward supertab.txt /*supertab-forwardbackward*
|
||||
supertab-intro supertab.txt /*supertab-intro*
|
||||
supertab-longestenhanced supertab.txt /*supertab-longestenhanced*
|
||||
supertab-longesthighlight supertab.txt /*supertab-longesthighlight*
|
||||
supertab-mappingtabliteral supertab.txt /*supertab-mappingtabliteral*
|
||||
supertab-options supertab.txt /*supertab-options*
|
||||
supertab-preventcomplete supertab.txt /*supertab-preventcomplete*
|
||||
supertab-usage supertab.txt /*supertab-usage*
|
||||
supertab.txt supertab.txt /*supertab.txt*
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
" Author: Eric Van Dewoestine <ervandew@gmail.com>
|
||||
"
|
||||
" License: {{{
|
||||
" Copyright (c) 2014
|
||||
" All rights reserved.
|
||||
"
|
||||
" Redistribution and use of this software in source and binary forms, with
|
||||
" or without modification, are permitted provided that the following
|
||||
" conditions are met:
|
||||
"
|
||||
" * Redistributions of source code must retain the above
|
||||
" copyright notice, this list of conditions and the
|
||||
" following disclaimer.
|
||||
"
|
||||
" * Redistributions in binary form must reproduce the above
|
||||
" copyright notice, this list of conditions and the
|
||||
" following disclaimer in the documentation and/or other
|
||||
" materials provided with the distribution.
|
||||
"
|
||||
" * Neither the name of Gergely Kontra or Eric Van Dewoestine nor the names
|
||||
" of its contributors may be used to endorse or promote products derived
|
||||
" from this software without specific prior written permission of Gergely
|
||||
" Kontra or Eric Van Dewoestine.
|
||||
"
|
||||
" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
" IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
" THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
" CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
" EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
" PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
" }}}
|
||||
|
||||
if !exists('b:SuperTabContextTextMemberPatterns')
|
||||
let b:SuperTabContextTextMemberPatterns = ['</']
|
||||
endif
|
||||
if !exists('b:SuperTabContextTextOmniPrecedence')
|
||||
let set_precedence = 1
|
||||
|
||||
" don't set omni precedence when user is using eclim + php
|
||||
if &ft == 'php'
|
||||
try
|
||||
let project = eclim#project#util#GetCurrentProjectName()
|
||||
if project != ''
|
||||
let natures = eclim#project#util#GetProjectNatureAliases(project)
|
||||
let set_precedence = !eclim#util#ListContains(natures, 'php')
|
||||
endif
|
||||
catch /E117/
|
||||
endtry
|
||||
endif
|
||||
|
||||
if set_precedence
|
||||
let b:SuperTabContextTextOmniPrecedence = ['&omnifunc', '&completefunc']
|
||||
endif
|
||||
endif
|
||||
|
||||
" vim:ft=vim:fdm=marker
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
" Author: Eric Van Dewoestine <ervandew@gmail.com>
|
||||
"
|
||||
" License: {{{
|
||||
" Copyright (c) 2014
|
||||
" All rights reserved.
|
||||
"
|
||||
" Redistribution and use of this software in source and binary forms, with
|
||||
" or without modification, are permitted provided that the following
|
||||
" conditions are met:
|
||||
"
|
||||
" * Redistributions of source code must retain the above
|
||||
" copyright notice, this list of conditions and the
|
||||
" following disclaimer.
|
||||
"
|
||||
" * Redistributions in binary form must reproduce the above
|
||||
" copyright notice, this list of conditions and the
|
||||
" following disclaimer in the documentation and/or other
|
||||
" materials provided with the distribution.
|
||||
"
|
||||
" * Neither the name of Gergely Kontra or Eric Van Dewoestine nor the names
|
||||
" of its contributors may be used to endorse or promote products derived
|
||||
" from this software without specific prior written permission of Gergely
|
||||
" Kontra or Eric Van Dewoestine.
|
||||
"
|
||||
" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
" IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
" THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
" CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
" EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
" PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
" }}}
|
||||
|
||||
if !exists('b:SuperTabContextTextMemberPatterns')
|
||||
let b:SuperTabContextTextMemberPatterns = ['</']
|
||||
endif
|
||||
if !exists('b:SuperTabContextTextOmniPrecedence')
|
||||
let b:SuperTabContextTextOmniPrecedence = ['&omnifunc', '&completefunc']
|
||||
endif
|
||||
|
||||
" vim:ft=vim:fdm=marker
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,27 +0,0 @@
|
|||
v0.5.1 Mon 23 Apr 2012
|
||||
- compatability fixes for older django versions
|
||||
- fix some edge cases in tag detection
|
||||
|
||||
v0.6 - html omni support / better matching
|
||||
|
||||
v0.7 Thu Apr 26 2012
|
||||
-url matching
|
||||
-inline {% import %} support
|
||||
|
||||
v0.8 Sun 13 May 2012
|
||||
- {% block %} name complete
|
||||
|
||||
v0.8.1 Sun 25 Nov 2012
|
||||
- warning suppression on imports
|
||||
|
||||
v0.9.1 Tue 27 Nov 2012
|
||||
- {% static %}
|
||||
|
||||
v0.9.2 Wed 06 May 2014
|
||||
- TEMPLATE_DIRS bugfix
|
||||
|
||||
v0.9.3 Tue 06 Jan 2015
|
||||
- Django 1.7 support
|
||||
|
||||
v0.9.4 Fri 29 May 2015
|
||||
- Django 1.7 support
|
||||
|
|
@ -1,130 +0,0 @@
|
|||
#Vim htmldjango autocomplete
|
||||
|
||||
[](https://gitter.im/mjbrownie/vim-htmldjango_omnicomplete?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
|
||||
An omnicomplete tailored to django templates "tags/variables/filters/templates"
|
||||
|
||||
Repo: git://github.com/mjbrownie/vim-htmldjango_omnicomplete.git
|
||||
|
||||
##Screenshots:
|
||||
|
||||

|
||||
( Note the screenshot is from the youcompleteme rewrite found here https://github.com/mjbrownie/django_completeme).
|
||||
This plugin is standalone and functionally identical except for the fuzzy ycm completion options. See notes at the bottom.
|
||||
|
||||
##Eg.
|
||||
|
||||
1. Filters
|
||||
|
||||
{{ somevar|a<c-x><c-o>}} should complete 'add' , 'addslashes'
|
||||
|
||||
2. Tags
|
||||
|
||||
{% cy<c-x><x-o> %} should complete 'cycle'
|
||||
|
||||
3. Load statements
|
||||
|
||||
It also should grab any libs you have {% load tag_lib %} in the file.
|
||||
Although it needs them in INSTALLED_APPS.
|
||||
|
||||
{% load <c-x><c-o> %} will complete libraries (eg. 'cache', 'humanize')
|
||||
|
||||
4. template filenames
|
||||
|
||||
{% extends '<c-x><c-o>' %} will list base.html ... etc
|
||||
|
||||
5. url complete
|
||||
|
||||
{% url <c-x><c-o> %} should complete views and named urls
|
||||
|
||||
6. super block complete
|
||||
|
||||
eg {% block c<c-x><c-o> %} to complete 'content' or something defined
|
||||
in an extended template.
|
||||
|
||||
7. static files complete
|
||||
|
||||
eg {% static "r<c-x><c-o>" %}
|
||||
|
||||
<script src="{% static "<c-x><c-o>" %}" /> - completes js files in static
|
||||
<style src="{% static "<c-x><c-o>" %}" /> - completes css files in static
|
||||
<img src="{% static "<c-x><c-o>" %}" /> - completes img files in static
|
||||
|
||||
8. optional variable name completion (placeholder)
|
||||
|
||||
{{ s<c-x><x-o> }}
|
||||
|
||||
will complete any maps defined in the python htmldjango_opts['variable']
|
||||
dict list. See below for info.
|
||||
|
||||
|
||||
Where possible info panels show the functions __doc__. Most of the
|
||||
internal ones are decent.
|
||||
|
||||
##Requires:
|
||||
|
||||
+python
|
||||
|
||||
##SETUP
|
||||
|
||||
1. I like pathogen/Vundle clone into ~/.vim/bundle directory.
|
||||
|
||||
Alternately just stick the vim file in your ~/.vim/autoload/ dir.
|
||||
|
||||
2. in .vimrc set the omnifunc Eg.
|
||||
|
||||
au FileType htmldjango set omnifunc=htmldjangocomplete#CompleteDjango
|
||||
|
||||
3. Optional: At the moment you need to force a html flavour for htmlcompletion
|
||||
|
||||
in .vimrc
|
||||
|
||||
let g:htmldjangocomplete_html_flavour = 'html401s'
|
||||
|
||||
:verbose function htmlcomplete#CheckDoctype for DocType details
|
||||
|
||||
Choices:
|
||||
'html401t' 'xhtml10s' 'html32' 'html40t' 'html40f' 'html40s'
|
||||
'html401t' 'html401f' 'html401s' 'xhtml10t' 'xhtml10f' 'xhtml10s'
|
||||
'xhtml11'
|
||||
|
||||
'html5' if you have html5.vim
|
||||
|
||||
4. matchpair notes
|
||||
|
||||
This plugin uses matchpair and needs to be inside a closed django tag.
|
||||
This is fine if you are using snipmate. Also you might want auto
|
||||
closing maps such as follows.
|
||||
|
||||
au FileType htmldjango inoremap {% {% %}<left><left><left>
|
||||
au FileType htmldjango inoremap {{ {{ }}<left><left><left>
|
||||
|
||||
##TESTING
|
||||
|
||||
django needs to be in sys.path along with DJANGO_SETTINGS_MODULE in your
|
||||
environment.
|
||||
|
||||
To test...
|
||||
|
||||
:python import django
|
||||
|
||||
should not result in an error
|
||||
|
||||
:python from django.conf import settings; print settings.INSTALLED_APPS
|
||||
:python from django.conf import settings; print settings.TEMPLATE_DIRS
|
||||
|
||||
should show the apps template dirs you need
|
||||
|
||||
I've only tested this on a mac with vim 7.3 and django 1.4
|
||||
|
||||
##NOTES
|
||||
|
||||
Note I have started rewriting an editior agnostic version of this plugin.
|
||||
|
||||
https://github.com/mjbrownie/django_completeme
|
||||
|
||||
It can be used with my fork of the youcompleteme daemon.
|
||||
|
||||
https://github.com/mjbrownie/ycmd
|
||||
|
||||
but it is still pre alpha.
|
||||
|
|
@ -1,504 +0,0 @@
|
|||
" Vim completion script
|
||||
" Language: htmldjango
|
||||
" Maintainer: Michael Brown
|
||||
" Last Change: Sun 13 May 2012 16:39:45 EST
|
||||
" Version: 0.9.2
|
||||
" Omnicomplete for django template taga/variables/filters
|
||||
" {{{1 Environment Settings
|
||||
if !exists('g:htmldjangocomplete_html_flavour')
|
||||
" :verbose function htmlcomplete#CheckDoctype for details
|
||||
" No html5!
|
||||
"'html401t' 'xhtml10s' 'html32' 'html40t' 'html40f' 'html40s'
|
||||
"'html401t' 'html401f' 'html401s' 'xhtml10t' 'xhtml10f' 'xhtml10s'
|
||||
"'xhtml11'
|
||||
let g:htmldjangocomplete_html_flavour = 'xhtml11'
|
||||
endif
|
||||
|
||||
"Allow settings of DEBUG
|
||||
if !exists('g:htmldjangocomplete_debug')
|
||||
let g:htmldjangocomplete_debug = 0
|
||||
endif
|
||||
|
||||
"{{{1 The actual omnifunc
|
||||
function! htmldjangocomplete#CompleteDjango(findstart, base)
|
||||
"{{{2 findstart = 1 when we need to get the text length
|
||||
"
|
||||
if a:findstart == 1
|
||||
|
||||
"Fallback to htmlcomplete
|
||||
if searchpair('{{','','}}','nc') == 0 && searchpair('{%',"",'%}','nc') == 0
|
||||
if !exists('b:html_doctype')
|
||||
let b:html_doctype = 1
|
||||
let b:html_omni_flavor = g:htmldjangocomplete_html_flavour
|
||||
endif
|
||||
return htmlcomplete#CompleteTags(a:findstart,a:base)
|
||||
endif
|
||||
|
||||
" locate the start of the word
|
||||
let line = getline('.')
|
||||
let start = col('.') - 1
|
||||
"special case for {% extends %} {% import %} needs to grab /'s
|
||||
"TODO make this match more flexible. It needs to know its in a string
|
||||
"also need to handle inline imports
|
||||
if s:get_context() == 'extends'|| s:get_context() == 'include'
|
||||
while start > 0 && line[start - 1] != '"' && line[start -1] != "'"
|
||||
\ && line[start -1] != ' '
|
||||
let start -= 1
|
||||
endwhile
|
||||
return start
|
||||
endif
|
||||
"
|
||||
"default <word> case
|
||||
while start > 0 && line[start - 1] =~ '\a'
|
||||
let start -= 1
|
||||
endwhile
|
||||
return start
|
||||
"{{{2 findstart = 0 when we need to return the list of completions
|
||||
else
|
||||
"Fallback to htmlcomplete
|
||||
if searchpair('{{','','}}','nc') == 0 && searchpair('{%',"",'%}','nc') == 0
|
||||
let matches = htmlcomplete#CompleteTags(a:findstart,a:base)
|
||||
"suppress all DOCTYPE matches
|
||||
call filter(matches, 'stridx(v:val["word"],"DOCTYPE") == -1')
|
||||
return matches
|
||||
endif
|
||||
|
||||
let context = s:get_context()
|
||||
|
||||
if context == 'extends' || context == 'include'
|
||||
let context = 'template'
|
||||
endif
|
||||
|
||||
"TODO: Reduce load always nature of this plugin
|
||||
call s:load_libs()
|
||||
"get context look for {% {{ and |
|
||||
let line = getline('.')
|
||||
let start = col('.') -1
|
||||
|
||||
" Special case for extends and import
|
||||
" TODO 'filter' should really just be string filters
|
||||
if index(['template','load','url','filter','block', 'static'],context) != -1
|
||||
execute "python htmldjangocomplete('" . context . "', '" . a:base . "')"
|
||||
return g:htmldjangocomplete_completions
|
||||
endif
|
||||
|
||||
while start > 0
|
||||
if line[start] == ':' && s:in_django(line,start) == 1
|
||||
execute "python htmldjangocomplete('variable', '" . a:base . "')"
|
||||
return g:htmldjangocomplete_completions
|
||||
elseif line[start] == '|' && s:in_django(line,start)
|
||||
execute "python htmldjangocomplete('filter', '" . a:base . "')"
|
||||
return g:htmldjangocomplete_completions
|
||||
elseif line[start] == '{' && line[start -1] == '{'
|
||||
execute "python htmldjangocomplete('variable', '" . a:base . "')"
|
||||
return g:htmldjangocomplete_completions
|
||||
elseif line[start] == '%' && line[start -1] == '{'
|
||||
execute "python htmldjangocomplete('tag', '" . a:base . "')"
|
||||
return g:htmldjangocomplete_completions
|
||||
else
|
||||
let start -= 1
|
||||
endif
|
||||
endwhile
|
||||
|
||||
return [ {'word': "nomatch"} ]
|
||||
"fallback to htmlcomplete TODO This doesn't work as expected.
|
||||
"Might need to turn off some doctype setting.
|
||||
"
|
||||
"call htmlcomplete#CompleteTags(1, a:base)
|
||||
"return htmlcomplete#CompleteTags(0, a:base)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"Supporting vim functions {{{1
|
||||
function! s:get_context()
|
||||
let curpos = getpos('.')
|
||||
let line = getline('.')
|
||||
|
||||
"tags
|
||||
let starttag = searchpairpos('{%', '', '%}', 'bn')
|
||||
if starttag != [0,0]
|
||||
let fragment = line[starttag[1]:curpos[2]]
|
||||
return split(fragment,' ')[1]
|
||||
endif
|
||||
|
||||
return "other"
|
||||
endfunction
|
||||
|
||||
"TODO This could probably be neater with an index check. need to get strings
|
||||
"working
|
||||
function! s:in_django(l,s)
|
||||
let line = a:l
|
||||
let start = a:s
|
||||
while start >= 0
|
||||
if line[start] == '}'
|
||||
return 0
|
||||
elseif line[start] == '{'
|
||||
return 1
|
||||
endif
|
||||
let start -= 1
|
||||
endwhile
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
"Python section {{{1
|
||||
"imports {{{2
|
||||
let g:htmldjangocomplete_completions = []
|
||||
function! s:load_libs()
|
||||
if has('python')
|
||||
python << EOF
|
||||
try:
|
||||
HTMLDJANGO_DEBUG = vim.eval("g:htmldjangocomplete_debug") == 0 and True or False
|
||||
except:
|
||||
HTMLDJANGO_DEBUG = False
|
||||
|
||||
TEMPLATE_EXTS = ['.html','.txt','.htm']
|
||||
|
||||
import warnings
|
||||
warnings.sys.warnoptions = ['-W']
|
||||
|
||||
import logging
|
||||
import vim
|
||||
import os
|
||||
|
||||
# Install the django-configurations importer (before Django setup).
|
||||
if os.environ.get('DJANGO_CONFIGURATION'):
|
||||
try:
|
||||
import configurations.importer
|
||||
configurations.importer.install()
|
||||
except:
|
||||
sys.exit()
|
||||
|
||||
# Setup Django (required for >= 1.7).
|
||||
import django
|
||||
if hasattr(django, 'setup'):
|
||||
django.setup()
|
||||
|
||||
try:
|
||||
#for OLD versions od django
|
||||
from django.template import get_library
|
||||
except:
|
||||
#for django 1.8+
|
||||
try:
|
||||
from django.template.base import get_library
|
||||
except:
|
||||
#for django 1.9+
|
||||
from django.template.backends.django import get_installed_libraries
|
||||
def get_library(libname):
|
||||
return get_installed_libraries()[libname]
|
||||
|
||||
|
||||
from django.template.loaders import filesystem, app_directories
|
||||
#Later versions of django seem to be fussy about get_library paths.
|
||||
try:
|
||||
from django.template import import_library
|
||||
except ImportError:
|
||||
try:
|
||||
from django.template.base import import_library
|
||||
except ImportError:
|
||||
import_library = get_library
|
||||
|
||||
|
||||
try:
|
||||
from django.template.loaders.app_directories import app_template_dirs
|
||||
except:
|
||||
from django.template.loaders.app_directories import get_app_template_dirs
|
||||
app_template_dirs = get_app_template_dirs('templates')
|
||||
|
||||
from django.conf import settings as mysettings
|
||||
from django.template.loader import get_template
|
||||
from django.template.loader_tags import ExtendsNode, BlockNode
|
||||
from django.template import Template
|
||||
|
||||
import re
|
||||
from operator import itemgetter
|
||||
import pkgutil
|
||||
import os
|
||||
from glob import glob
|
||||
|
||||
try:
|
||||
from django.template import get_templatetags_modules
|
||||
except ImportError:
|
||||
#I've lifted this version from the django source
|
||||
try:
|
||||
from importlib import import_module
|
||||
except ImportError:
|
||||
from django.utils.importlib import import_module
|
||||
|
||||
def get_templatetags_modules():
|
||||
"""
|
||||
Return the list of all available template tag modules.
|
||||
|
||||
Caches the result for faster access.
|
||||
"""
|
||||
_templatetags_modules = []
|
||||
# Populate list once per process. Mutate the local list first, and
|
||||
# then assign it to the global name to ensure there are no cases where
|
||||
# two threads try to populate it simultaneously.
|
||||
for app_module in ['django'] + list(mysettings.INSTALLED_APPS):
|
||||
try:
|
||||
templatetag_module = '%s.templatetags' % app_module
|
||||
import_module(templatetag_module)
|
||||
_templatetags_modules.append(templatetag_module)
|
||||
except ImportError:
|
||||
continue
|
||||
return _templatetags_modules
|
||||
|
||||
# {{{2 Support functions
|
||||
|
||||
def get_block_tags(start=''):
|
||||
|
||||
#use regexp for extends as get_template will fail on tag errors
|
||||
rexp = re.compile('{%\s*extends\s*[\'"](.*)["\']\s*%}')
|
||||
base = None
|
||||
templates = [] # for cycle detection
|
||||
|
||||
for l in vim.current.buffer[0:10]:
|
||||
match = rexp.match(l)
|
||||
if match:
|
||||
try:
|
||||
base = get_template(match.groups()[0])
|
||||
except:
|
||||
return []
|
||||
|
||||
if not base:
|
||||
return []
|
||||
|
||||
def _get_blocks(tpl, menu_prefix='', add_name = True):
|
||||
"""
|
||||
recursive worker function
|
||||
"""
|
||||
|
||||
# TODO I Think this is a 1.8 compatibility thing sending the wrapper
|
||||
# class
|
||||
tpl = getattr(tpl, 'name', None) and tpl or tpl.template
|
||||
|
||||
if tpl.name in templates and isinstance(tpl, Template):
|
||||
logging.info("cyclic extends detected!")
|
||||
return []
|
||||
else:
|
||||
templates.append(tpl.name)
|
||||
|
||||
if menu_prefix == '' and isinstance(tpl, Template):
|
||||
menu_prefix = "%s > " % tpl.name
|
||||
|
||||
blocks = [(block, block.name, menu_prefix)
|
||||
for block in tpl.nodelist if isinstance(block, BlockNode)]
|
||||
|
||||
for block, name, _ in blocks:
|
||||
if add_name:
|
||||
blocks += _get_blocks(block, '%s%s > ' % (menu_prefix, name))
|
||||
else:
|
||||
blocks += _get_blocks(block, '%s' % (menu_prefix))
|
||||
|
||||
if len(tpl.nodelist) > 0 and isinstance(tpl.nodelist[0], ExtendsNode):
|
||||
logging.debug("parent_name")
|
||||
logging.debug(tpl.nodelist[0].parent_name)
|
||||
parent_template = str(tpl.nodelist[0].parent_name).replace(
|
||||
'"', '').replace("''", '')
|
||||
try:
|
||||
parent_tpl = get_template(parent_template)
|
||||
blocks += _get_blocks(parent_tpl)
|
||||
except TemplateDoesNotExist:
|
||||
logging.info("get_template:TemplateDoesNotExist - '%s'" %
|
||||
parent_template)
|
||||
|
||||
for node in tpl.nodelist:
|
||||
if not isinstance(node, BlockNode) and not isinstance(node,
|
||||
ExtendsNode):
|
||||
try:
|
||||
blocks += _get_blocks(node, menu_prefix, add_name=False)
|
||||
except AttributeError:
|
||||
logging.info("node %s: no nodelist" % node)
|
||||
|
||||
return blocks
|
||||
|
||||
full_matches = _get_blocks(base)
|
||||
|
||||
names = []
|
||||
matches = []
|
||||
# dedup matches TODO might be a better way of picking matches
|
||||
for match in full_matches:
|
||||
if not match[0] in names:
|
||||
matches.append(match)
|
||||
names.append(match[0])
|
||||
|
||||
return [{'word':n,'menu':m} for b, n, m in matches if n.startswith(start)]
|
||||
|
||||
def get_template_names(pattern):
|
||||
|
||||
dirs = getattr(mysettings, "TEMPLATE_DIRS", ()) + app_template_dirs
|
||||
if hasattr(mysettings, "TEMPLATES"):
|
||||
for d in [e["DIRS"] for e in mysettings.TEMPLATES]:
|
||||
dirs += tuple(d)
|
||||
|
||||
matches = []
|
||||
for d in dirs:
|
||||
d = d + (os.path.sep if not d.endswith(os.path.sep) else '')
|
||||
for m in glob(os.path.join(d,pattern + '*')):
|
||||
if os.path.isdir(m):
|
||||
for root,dirnames,filenames in os.walk(m):
|
||||
for f in filenames:
|
||||
fn,ext = os.path.splitext(f)
|
||||
if ext in TEMPLATE_EXTS:
|
||||
matches.append({
|
||||
'word' : os.path.join(root,f).replace(d,''),
|
||||
'info' : 'found in %s' % d
|
||||
}
|
||||
)
|
||||
else:
|
||||
matches.append({
|
||||
'word' : m.replace(d,''),
|
||||
'info' : 'found in %s' % d
|
||||
}
|
||||
)
|
||||
|
||||
return matches
|
||||
|
||||
try:
|
||||
from django.contrib.staticfiles import finders, storage
|
||||
def get_staticfiles(pattern):
|
||||
|
||||
dirs = mysettings.STATICFILES_DIRS
|
||||
|
||||
#TODO crude matching
|
||||
line = vim.current.line
|
||||
if 'script' in line:
|
||||
ext = ".*\.js$"
|
||||
elif 'style' in line:
|
||||
ext = ".*\.css$"
|
||||
elif 'img' in line:
|
||||
ext = ".*\.(gif|jpg|jpeg|png)$"
|
||||
else:
|
||||
ext = '.*'
|
||||
|
||||
matches = []
|
||||
|
||||
for finder in finders.get_finders():
|
||||
for path, storage in finder.list([]):
|
||||
if re.compile(ext,re.IGNORECASE).match(path) \
|
||||
and path.startswith(pattern):
|
||||
matches.append(dict(word=path,info=''))
|
||||
|
||||
return matches
|
||||
except:
|
||||
def get_staticfiles(pattern):
|
||||
return []
|
||||
|
||||
def get_tag_libraries():
|
||||
opts = []
|
||||
for module in get_templatetags_modules():
|
||||
mod = __import__(module,fromlist=['foo'])
|
||||
for l,m,i in pkgutil.iter_modules([os.path.dirname(mod.__file__)]):
|
||||
opts.append({'word':m,'menu':mod.__name__})
|
||||
|
||||
return opts
|
||||
|
||||
|
||||
def _get_doc(doc, name):
|
||||
if doc:
|
||||
return doc.replace('"',' ').replace("'",' ')
|
||||
return '%s: no doc' % name
|
||||
|
||||
def _get_opt_dict(lib,t,libname=''):
|
||||
opts = getattr(lib,t)
|
||||
return [
|
||||
{'word':f, 'info': _get_doc(opts[f].__doc__,f),'menu':libname} \
|
||||
for f in opts.keys()]
|
||||
|
||||
def load_app_tags():
|
||||
cb = vim.current.buffer
|
||||
for line in cb:
|
||||
m = re.compile('{% load (.*)%}').match(line)
|
||||
if m:
|
||||
for lib in m.groups()[0].rstrip().split(' '):
|
||||
try:
|
||||
l = get_library(lib)
|
||||
htmldjango_opts['filter'] += _get_opt_dict(l,'filters',lib)
|
||||
htmldjango_opts['tag'] += _get_opt_dict(l,'tags',lib)
|
||||
except Exception as e:
|
||||
if HTMLDJANGO_DEBUG:
|
||||
print "FAILED TO LOAD: %s" % lib
|
||||
raise e
|
||||
# {{{2 load options
|
||||
# TODO At the moment this is being loaded every match
|
||||
htmldjango_opts = {}
|
||||
|
||||
htmldjango_opts['load'] = get_tag_libraries()
|
||||
def_filters = import_library('django.template.defaultfilters')
|
||||
htmldjango_opts['filter'] = _get_opt_dict(def_filters,'filters','default')
|
||||
def_tags = import_library('django.template.defaulttags')
|
||||
htmldjango_opts['tag'] = _get_opt_dict(def_tags,'tags','default')
|
||||
load_app_tags()
|
||||
|
||||
try:
|
||||
urls = __import__(mysettings.ROOT_URLCONF,fromlist=['foo'])
|
||||
except:
|
||||
urls = None
|
||||
|
||||
def htmldjango_urls(pattern):
|
||||
matches = []
|
||||
def get_urls(urllist,parent=None):
|
||||
for entry in urllist:
|
||||
if hasattr(entry,'name') and entry.name:
|
||||
matches.append(dict(
|
||||
word = entry.name,
|
||||
info = entry.regex.pattern,
|
||||
menu = parent and parent.urlconf_name or '')
|
||||
)
|
||||
if hasattr(entry, 'url_patterns'):
|
||||
get_urls(entry.url_patterns, entry)
|
||||
if urls:
|
||||
get_urls(urls.urlpatterns)
|
||||
return matches
|
||||
|
||||
#TODO I may be able to populate RequestContext via middleware component
|
||||
htmldjango_opts['variable'] = []
|
||||
#TODO Write a function that gets all ancestor template blocks
|
||||
htmldjango_opts['block'] = []
|
||||
|
||||
# Main Python function {{{2
|
||||
def htmldjangocomplete(context,match):
|
||||
if context == 'template':
|
||||
all = get_template_names(match)
|
||||
elif context == 'static':
|
||||
all = get_staticfiles(match)
|
||||
elif context == 'url':
|
||||
all = htmldjango_urls(match)
|
||||
elif context == 'block':
|
||||
all = get_block_tags(match)
|
||||
else:
|
||||
all = htmldjango_opts[context]
|
||||
|
||||
vim.command("silent let g:htmldjangocomplete_completions = []")
|
||||
|
||||
dictstr = '['
|
||||
# have to do this for double quoting
|
||||
|
||||
all = [a for a in all if a['word'].startswith(match)]
|
||||
all = sorted(all, key=itemgetter('word'))
|
||||
|
||||
for cmpl in all:
|
||||
dictstr += '{'
|
||||
for x in cmpl: dictstr += '"%s":"%s",' % (x,cmpl[x].replace("\\", "\\\\")) # Windows slashes must be escaped
|
||||
dictstr += '"icase":0},'
|
||||
if dictstr[-1] == ',': dictstr = dictstr[:-1]
|
||||
dictstr += ']'
|
||||
vim.command("silent let g:htmldjangocomplete_completions = %s" % dictstr)
|
||||
EOF
|
||||
endif
|
||||
endfunction
|
||||
" Test Area {{{1
|
||||
function! TestLoadLibs()
|
||||
call s:load_libs()
|
||||
endfunction
|
||||
|
||||
function! HtmlDjangoDebug(on)
|
||||
if a:on
|
||||
echo "adding Breakpoint"
|
||||
breakadd func htmldjangocomplete#CompleteDjango
|
||||
else
|
||||
echo "remove Breakpoint"
|
||||
breakdel func htmldjangocomplete#CompleteDjango
|
||||
endif
|
||||
endfunction
|
||||
" vim:set foldmethod=marker:
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 17 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 34 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 38 KiB |
|
|
@ -1,31 +0,0 @@
|
|||
language: vim
|
||||
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
|
||||
env:
|
||||
- TEST=package
|
||||
- TEST=latest
|
||||
|
||||
before_script: |
|
||||
if [ "$TEST" = "package" ]; then
|
||||
if [ "$TRAVIS_OS_NAME" = "linux" ]; then
|
||||
sudo apt-get -y update
|
||||
sudo apt-get -y install vim
|
||||
fi
|
||||
else
|
||||
cd ..
|
||||
git clone --depth 1 https://github.com/vim/vim
|
||||
cd vim
|
||||
./configure --with-features=huge
|
||||
make
|
||||
sudo make install
|
||||
export PATH="/usr/local/bin:$PATH"
|
||||
cd "$TRAVIS_BUILD_DIR"
|
||||
fi
|
||||
sudo -H pip install virtualenv
|
||||
|
||||
script:
|
||||
- make test
|
||||
- make doc
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
# CONTRIBUTING
|
||||
|
||||
These contributing guidelines were accepted rather late in the history of this plugin, after much code had already been written.
|
||||
|
||||
If you find any existing behavior which does not conform to these guidelines, please correct it and send a pull request.
|
||||
|
||||
## General Rules
|
||||
|
||||
Every non local identifier must start with `g:vim_markdown_`.
|
||||
|
||||
## Documentation
|
||||
|
||||
Every new feature must be documented under in the [README.md](README.md). Documentation must be written in [GFM](https://help.github.com/articles/github-flavored-markdown) since GitHub itself is the primary to HTML converter used. In particular, remember that GFM adds line breaks at single newlines, so just forget about the 70 characters wide rule.
|
||||
|
||||
Vim help file [doc/vim-markdown.txt](doc/vim-markdown.txt) will be generated from [README.md](README.md) by `make doc` using [vim-tools](https://github.com/xolox/vim-tools).
|
||||
|
||||
## Markdown Flavors
|
||||
|
||||
There are many flavors of markdown, each one with an unique feature set. This plugin uses the following strategy to deal with all those flavors:
|
||||
|
||||
- Features from the [original markdown](http://daringfireball.net/projects/markdown/syntax) are turned on by default. They may not even have an option that turns them off.
|
||||
|
||||
- Features from other markdown flavors *must* have an option that turns them on or off. If the feature is common enough across multiple versions of markdown, it may be turned on by default. This shall be decided by the community when the merge request is done.
|
||||
|
||||
- If possible, cite the exact point in the documentation of the flavor where a feature is specified. If the feature is not documented, you may also reference the source code itself of the implementation. This way, people who do not know that flavor can check if your implementation is correct.
|
||||
|
||||
- Do not use the name of a flavor for a feature that is used across multiple flavors. Instead, create a separate flavor option, that automatically sets each feature.
|
||||
|
||||
For example, fenced code blocks (putting code between pairs of three backticks) is not part of the original markdown, but is supported by [GFM](https://help.github.com/articles/github-flavored-markdown#fenced-code-blocks) and [Jekyll](http://jekyllrb.com/docs/configuration/).
|
||||
|
||||
Therefore, instead of creating an option `g:vim_markdown_gfm_fenced_code_block`, and an option `g:vim_markdown_jekyll_fenced_code_block`, create a single option `g:vim_markdown_fenced_code_block`.
|
||||
|
||||
Next, if there are many more than one Jekyll feature options, create a `g:vim_markdown_jekyll` option that turns them all on at once.
|
||||
|
||||
## Style
|
||||
|
||||
When choosing between multiple valid Markdown syntaxes, the default behavior must be that specified at: <http://www.cirosantilli.com/markdown-styleguide>
|
||||
|
||||
If you wish to have a behavior that differs from that style guide, add an option to turn it on or off, and leave it off by default.
|
||||
|
||||
## Tests
|
||||
|
||||
All new features must have unit tests.
|
||||
|
||||
## Issues
|
||||
|
||||
Issues are tracked within GitHub.
|
||||
|
||||
When reporting issues, your report is more effective if you include a minimal example file that reproduces the problem. Try to trim out as much as possible, until you have the smallest possible file that still reproduces the issue. Paste the example inline into your issue report, quoted using four spaces at the beginning of each line, like this example from issue [#189](https://github.com/plasticboy/vim-markdown/issues/189):
|
||||
|
||||
```
|
||||
Minimal example:
|
||||
|
||||
```
|
||||
=
|
||||
```
|
||||
bad!
|
||||
```
|
||||
|
|
@ -1,82 +0,0 @@
|
|||
VIMDIR=$(DESTDIR)/usr/share/vim
|
||||
ADDONS=${VIMDIR}/addons
|
||||
REGISTRY=${VIMDIR}/registry
|
||||
|
||||
all:
|
||||
|
||||
install:
|
||||
mkdir -pv ${ADDONS}/ftdetect
|
||||
cp -v ftdetect/markdown.vim ${ADDONS}/ftdetect/markdown.vim
|
||||
mkdir -pv ${ADDONS}/ftplugin
|
||||
cp -v ftplugin/markdown.vim ${ADDONS}/ftplugin/markdown.vim
|
||||
mkdir -pv ${ADDONS}/syntax
|
||||
cp -v syntax/markdown.vim ${ADDONS}/syntax/markdown.vim
|
||||
mkdir -pv ${ADDONS}/after/ftplugin
|
||||
cp -v after/ftplugin/markdown.vim ${ADDONS}/after/ftplugin/markdown.vim
|
||||
mkdir -pv ${ADDONS}/indent
|
||||
cp -v indent/markdown.vim ${ADDONS}/indent/markdown.vim
|
||||
mkdir -pv ${ADDONS}/doc
|
||||
cp -v doc/vim-markdown.txt ${ADDONS}/doc/vim-markdown.txt
|
||||
mkdir -pv ${REGISTRY}
|
||||
cp -v registry/markdown.yaml ${REGISTRY}/markdown.yaml
|
||||
|
||||
test: build/tabular build/vim-toml build/vim-json build/vader.vim
|
||||
test/run-tests.sh
|
||||
.PHONY: test
|
||||
|
||||
update: build/tabular build/vim-toml build/vim-json build/vader.vim
|
||||
cd build/tabular && git pull
|
||||
cd build/vim-toml && git pull
|
||||
cd build/vim-json && git pull
|
||||
cd build/vader.vim && git pull
|
||||
.PHONY: update
|
||||
|
||||
build/tabular: | build
|
||||
git clone https://github.com/godlygeek/tabular build/tabular
|
||||
|
||||
build/vim-toml: | build
|
||||
git clone https://github.com/cespare/vim-toml build/vim-toml
|
||||
|
||||
build/vim-json: | build
|
||||
git clone https://github.com/elzr/vim-json build/vim-json
|
||||
|
||||
build/vader.vim: | build
|
||||
git clone https://github.com/junegunn/vader.vim build/vader.vim
|
||||
|
||||
build:
|
||||
mkdir build
|
||||
|
||||
doc: build/html2vimdoc build/vim-tools
|
||||
sed -e '/^\[!\[Build Status\]/d' \
|
||||
-e '/^1\. \[/d' README.md > doc/tmp.md # remove table of contents
|
||||
build/html2vimdoc/bin/python build/vim-tools/html2vimdoc.py -f vim-markdown \
|
||||
doc/tmp.md | \
|
||||
sed -E -e "s/[[:space:]]*$$//" -e "# remove trailing spaces" \
|
||||
-e "/^.{79,}\|$$/ {" -e "# wrap table of contents over 79" \
|
||||
-e "h" -e "# save the matched line to the hold space" \
|
||||
-e "s/^(.*) (\|[^|]*\|)$$/\1/" -e "# make content title" \
|
||||
-e "p" -e "# print title" \
|
||||
-e "g" -e "# restore the matched line" \
|
||||
-e "s/^.* (\|[^|]*\|)$$/ \1/" -e "# make link" \
|
||||
-e ":c" -e "s/^(.{1,78})$$/ \1/" -e "tc" -e "# align right" \
|
||||
-e "}" \
|
||||
-e "/^- '[^']*':( |$$)/ {" \
|
||||
-e "h" -e "# save the matched line to the hold space" \
|
||||
-e "s/^- '([^']{3,})':.*/ \*\1\*/" -e "# make command reference" \
|
||||
-e "s/^- '([^']{1,2})':.*/ \*vim-markdown-\1\*/" -e "# short command" \
|
||||
-e ":a" -e "s/^(.{1,78})$$/ \1/" -e "ta" -e "# align right" \
|
||||
-e "G" -e "# append the matched line after the command reference" \
|
||||
-e "}" > doc/vim-markdown.txt && rm -f doc/tmp.md
|
||||
|
||||
.PHONY: doc
|
||||
|
||||
# Prerequire Python and virtualenv.
|
||||
# $ sudo pip install virtualenv
|
||||
# Create the virtual environment.
|
||||
# Install the dependencies.
|
||||
build/html2vimdoc: | build
|
||||
virtualenv build/html2vimdoc
|
||||
build/html2vimdoc/bin/pip install beautifulsoup coloredlogs==4.0 markdown
|
||||
|
||||
build/vim-tools: | build
|
||||
git clone https://github.com/xolox/vim-tools.git build/vim-tools
|
||||
|
|
@ -1,358 +0,0 @@
|
|||
# Vim Markdown
|
||||
|
||||
[](https://travis-ci.org/plasticboy/vim-markdown)
|
||||
|
||||
Syntax highlighting, matching rules and mappings for [the original Markdown](http://daringfireball.net/projects/markdown/) and extensions.
|
||||
|
||||
1. [Installation](#installation)
|
||||
1. [Options](#options)
|
||||
1. [Mappings](#mappings)
|
||||
1. [Commands](#commands)
|
||||
1. [Credits](#credits)
|
||||
1. [License](#license)
|
||||
|
||||
## Installation
|
||||
|
||||
If you use [Vundle](https://github.com/gmarik/vundle), add the following line to your `~/.vimrc`:
|
||||
|
||||
```vim
|
||||
Plugin 'godlygeek/tabular'
|
||||
Plugin 'plasticboy/vim-markdown'
|
||||
```
|
||||
|
||||
The `tabular` plugin must come *before* `vim-markdown`.
|
||||
|
||||
Then run inside Vim:
|
||||
|
||||
```vim
|
||||
:so ~/.vimrc
|
||||
:PluginInstall
|
||||
```
|
||||
|
||||
If you use [Pathogen](https://github.com/tpope/vim-pathogen), do this:
|
||||
|
||||
```sh
|
||||
cd ~/.vim/bundle
|
||||
git clone https://github.com/plasticboy/vim-markdown.git
|
||||
```
|
||||
|
||||
To install without Pathogen using the Debian [vim-addon-manager](http://packages.qa.debian.org/v/vim-addon-manager.html), do this:
|
||||
|
||||
```sh
|
||||
git clone https://github.com/plasticboy/vim-markdown.git
|
||||
cd vim-markdown
|
||||
sudo make install
|
||||
vim-addon-manager install markdown
|
||||
```
|
||||
|
||||
If you are not using any package manager, download the [tarball](https://github.com/plasticboy/vim-markdown/archive/master.tar.gz) and do this:
|
||||
|
||||
```sh
|
||||
cd ~/.vim
|
||||
tar --strip=1 -zxf vim-markdown-master.tar.gz
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
### Disable Folding
|
||||
|
||||
Add the following line to your `.vimrc` to disable the folding configuration:
|
||||
|
||||
```vim
|
||||
let g:vim_markdown_folding_disabled = 1
|
||||
```
|
||||
|
||||
This option only controls Vim Markdown specific folding configuration.
|
||||
|
||||
To enable/disable folding use Vim's standard folding configuration.
|
||||
|
||||
```vim
|
||||
set [no]foldenable
|
||||
```
|
||||
|
||||
### Change fold style
|
||||
|
||||
To fold in a style like [python-mode](https://github.com/klen/python-mode), add the following to your `.vimrc`:
|
||||
|
||||
```vim
|
||||
let g:vim_markdown_folding_style_pythonic = 1
|
||||
```
|
||||
|
||||
Level 1 heading which is served as a document title is not folded.
|
||||
`g:vim_markdown_folding_level` setting is not active with this fold style.
|
||||
|
||||
To prevent foldtext from being set add the following to your `.vimrc`:
|
||||
|
||||
```vim
|
||||
let g:vim_markdown_override_foldtext = 0
|
||||
```
|
||||
|
||||
### Set header folding level
|
||||
|
||||
Folding level is a number between 1 and 6. By default, if not specified, it is set to 1.
|
||||
|
||||
```vim
|
||||
let g:vim_markdown_folding_level = 6
|
||||
```
|
||||
|
||||
Tip: it can be changed on the fly with:
|
||||
|
||||
```vim
|
||||
:let g:vim_markdown_folding_level = 1
|
||||
:edit
|
||||
```
|
||||
|
||||
### Disable Default Key Mappings
|
||||
|
||||
Add the following line to your `.vimrc` to disable default key mappings:
|
||||
|
||||
```vim
|
||||
let g:vim_markdown_no_default_key_mappings = 1
|
||||
```
|
||||
|
||||
You can also map them by yourself with `<Plug>` mappings.
|
||||
|
||||
### Enable TOC window auto-fit
|
||||
|
||||
Allow for the TOC window to auto-fit when it's possible for it to shrink.
|
||||
It never increases its default size (half screen), it only shrinks.
|
||||
|
||||
```vim
|
||||
let g:vim_markdown_toc_autofit = 1
|
||||
```
|
||||
|
||||
### Text emphasis restriction to single-lines
|
||||
|
||||
By default text emphasis works across multiple lines until a closing token is found. However, it's possible to restrict text emphasis to a single line (ie, for it to be applied a closing token must be found on the same line). To do so:
|
||||
|
||||
```vim
|
||||
let g:vim_markdown_emphasis_multiline = 0
|
||||
```
|
||||
|
||||
### Syntax Concealing
|
||||
|
||||
Concealing is set for some syntax.
|
||||
|
||||
For example, conceal `[link text](link url)` as just `link text`.
|
||||
Also, `_italic_` and `*italic*` will conceal to just _italic_.
|
||||
Similarly `__bold__`, `**bold**`, `___italic bold___`, and `***italic bold***`
|
||||
will conceal to just __bold__, **bold**, ___italic bold___, and ***italic bold*** respectively.
|
||||
|
||||
To enable conceal use Vim's standard conceal configuration.
|
||||
|
||||
```vim
|
||||
set conceallevel=2
|
||||
```
|
||||
|
||||
To disable conceal regardless of `conceallevel` setting, add the following to your `.vimrc`:
|
||||
|
||||
```vim
|
||||
let g:vim_markdown_conceal = 0
|
||||
```
|
||||
|
||||
To disable math conceal with LaTeX math syntax enabled, add the following to your `.vimrc`:
|
||||
|
||||
```vim
|
||||
let g:tex_conceal = ""
|
||||
let g:vim_markdown_math = 1
|
||||
```
|
||||
|
||||
### Fenced code block languages
|
||||
|
||||
You can use filetype name as fenced code block languages for syntax highlighting.
|
||||
If you want to use different name from filetype, you can add it in your `.vimrc` like so:
|
||||
|
||||
```vim
|
||||
let g:vim_markdown_fenced_languages = ['csharp=cs']
|
||||
```
|
||||
|
||||
This will cause the following to be highlighted using the `cs` filetype syntax.
|
||||
|
||||
```csharp
|
||||
...
|
||||
```
|
||||
|
||||
Default is `['c++=cpp', 'viml=vim', 'bash=sh', 'ini=dosini']`.
|
||||
|
||||
### Syntax extensions
|
||||
|
||||
The following options control which syntax extensions will be turned on. They are off by default.
|
||||
|
||||
#### LaTeX math
|
||||
|
||||
Used as `$x^2$`, `$$x^2$$`, escapable as `\$x\$` and `\$\$x\$\$`.
|
||||
|
||||
```vim
|
||||
let g:vim_markdown_math = 1
|
||||
```
|
||||
|
||||
#### YAML Front Matter
|
||||
|
||||
Highlight YAML front matter as used by Jekyll or [Hugo](https://gohugo.io/content/front-matter/).
|
||||
|
||||
```vim
|
||||
let g:vim_markdown_frontmatter = 1
|
||||
```
|
||||
|
||||
#### TOML Front Matter
|
||||
|
||||
Highlight TOML front matter as used by [Hugo](https://gohugo.io/content/front-matter/).
|
||||
|
||||
TOML syntax highlight requires [vim-toml](https://github.com/cespare/vim-toml).
|
||||
|
||||
```vim
|
||||
let g:vim_markdown_toml_frontmatter = 1
|
||||
```
|
||||
|
||||
#### JSON Front Matter
|
||||
|
||||
Highlight JSON front matter as used by [Hugo](https://gohugo.io/content/front-matter/).
|
||||
|
||||
JSON syntax highlight requires [vim-json](https://github.com/elzr/vim-json).
|
||||
|
||||
```vim
|
||||
let g:vim_markdown_json_frontmatter = 1
|
||||
```
|
||||
|
||||
### Adjust new list item indent
|
||||
|
||||
You can adjust a new list indent. For example, you insert a single line like below:
|
||||
|
||||
```
|
||||
* item1
|
||||
```
|
||||
|
||||
Then if you type `o` to insert new line in vim and type `* item2`, the result will be:
|
||||
|
||||
```
|
||||
* item1
|
||||
* item2
|
||||
```
|
||||
|
||||
vim-markdown automatically insert the indent. By default, the number of spaces of indent is 4. If you'd like to change the number as 2, just write:
|
||||
|
||||
```vim
|
||||
let g:vim_markdown_new_list_item_indent = 2
|
||||
```
|
||||
|
||||
### Do not require .md extensions for Markdown links
|
||||
|
||||
If you want to have a link like this `[link text](link-url)` and follow it for editing in vim using the `ge` command, but have it open the file "link-url.md" instead of the file "link-url", then use this option:
|
||||
|
||||
```vim
|
||||
let g:vim_markdown_no_extensions_in_markdown = 1
|
||||
```
|
||||
This is super useful for GitLab and GitHub wiki repositories.
|
||||
|
||||
Normal behaviour would be that vim-markup required you to do this `[link text](link-url.md)`, but this is not how the Gitlab and GitHub wiki repositories work. So this option adds some consistency between the two.
|
||||
|
||||
### Auto-write when following link
|
||||
|
||||
If you follow a link like this `[link text](link-url)` using the `ge` shortcut, this option will automatically save any edits you made before moving you:
|
||||
|
||||
```vim
|
||||
let g:vim_markdown_autowrite = 1
|
||||
```
|
||||
|
||||
## Mappings
|
||||
|
||||
The following work on normal and visual modes:
|
||||
|
||||
- `gx`: open the link under the cursor in the same browser as the standard `gx` command. `<Plug>Markdown_OpenUrlUnderCursor`
|
||||
|
||||
The standard `gx` is extended by allowing you to put your cursor anywhere inside a link.
|
||||
|
||||
For example, all the following cursor positions will work:
|
||||
|
||||
[Example](http://example.com)
|
||||
^ ^ ^^ ^ ^
|
||||
1 2 34 5 6
|
||||
|
||||
<http://example.com>
|
||||
^ ^ ^
|
||||
1 2 3
|
||||
|
||||
Known limitation: does not work for links that span multiple lines.
|
||||
|
||||
- `ge`: open the link under the cursor in Vim for editing. Useful for relative markdown links. `<Plug>Markdown_EditUrlUnderCursor`
|
||||
|
||||
The rules for the cursor position are the same as the `gx` command.
|
||||
|
||||
- `]]`: go to next header. `<Plug>Markdown_MoveToNextHeader`
|
||||
|
||||
- `[[`: go to previous header. Contrast with `]c`. `<Plug>Markdown_MoveToPreviousHeader`
|
||||
|
||||
- `][`: go to next sibling header if any. `<Plug>Markdown_MoveToNextSiblingHeader`
|
||||
|
||||
- `[]`: go to previous sibling header if any. `<Plug>Markdown_MoveToPreviousSiblingHeader`
|
||||
|
||||
- `]c`: go to Current header. `<Plug>Markdown_MoveToCurHeader`
|
||||
|
||||
- `]u`: go to parent header (Up). `<Plug>Markdown_MoveToParentHeader`
|
||||
|
||||
This plugin follows the recommended Vim plugin mapping interface, so to change the map `]u` to `asdf`, add to your `.vimrc`:
|
||||
|
||||
map asdf <Plug>Markdown_MoveToParentHeader
|
||||
|
||||
To disable a map use:
|
||||
|
||||
map <Plug> <Plug>Markdown_MoveToParentHeader
|
||||
|
||||
## Commands
|
||||
|
||||
The following requires `:filetype plugin on`.
|
||||
|
||||
- `:HeaderDecrease`:
|
||||
|
||||
Decrease level of all headers in buffer: `h2` to `h1`, `h3` to `h2`, etc.
|
||||
|
||||
If range is given, only operate in the range.
|
||||
|
||||
If an `h1` would be decreased, abort.
|
||||
|
||||
For simplicity of implementation, Setex headers are converted to Atx.
|
||||
|
||||
- `:HeaderIncrease`: Analogous to `:HeaderDecrease`, but increase levels instead.
|
||||
|
||||
- `:SetexToAtx`:
|
||||
|
||||
Convert all Setex style headers in buffer to Atx.
|
||||
|
||||
If a range is given, e.g. hit `:` from visual mode, only operate on the range.
|
||||
|
||||
- `:TableFormat`: Format the table under the cursor [like this](http://www.cirosantilli.com/markdown-style-guide/#tables).
|
||||
|
||||
Requires [Tabular](https://github.com/godlygeek/tabular).
|
||||
|
||||
The input table *must* already have a separator line as the second line of the table.
|
||||
That line only needs to contain the correct pipes `|`, nothing else is required.
|
||||
|
||||
- `:Toc`: create a quickfix vertical window navigable table of contents with the headers.
|
||||
|
||||
Hit `<Enter>` on a line to jump to the corresponding line of the markdown file.
|
||||
|
||||
- `:Toch`: Same as `:Toc` but in an horizontal window.
|
||||
|
||||
- `:Toct`: Same as `:Toc` but in a new tab.
|
||||
|
||||
- `:Tocv`: Same as `:Toc` for symmetry with `:Toch` and `:Tocv`.
|
||||
|
||||
## Credits
|
||||
|
||||
The main contributors of vim-markdown are:
|
||||
|
||||
- **Ben Williams** (A.K.A. **plasticboy**). The original developer of vim-markdown. [Homepage](http://plasticboy.com/).
|
||||
|
||||
If you feel that your name should be on this list, please make a pull request listing your contributions.
|
||||
|
||||
## License
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2012 Benjamin D. Williams
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
|
@ -1,160 +0,0 @@
|
|||
" folding for Markdown headers, both styles (atx- and setex-)
|
||||
" http://daringfireball.net/projects/markdown/syntax#header
|
||||
"
|
||||
" this code can be placed in file
|
||||
" $HOME/.vim/after/ftplugin/markdown.vim
|
||||
"
|
||||
" original version from Steve Losh's gist: https://gist.github.com/1038710
|
||||
|
||||
function! s:is_mkdCode(lnum)
|
||||
let name = synIDattr(synID(a:lnum, 1, 0), 'name')
|
||||
return (name =~ '^mkd\%(Code$\|Snippet\)' || name != '' && name !~ '^\%(mkd\|html\)')
|
||||
endfunction
|
||||
|
||||
if get(g:, "vim_markdown_folding_style_pythonic", 0)
|
||||
function! Foldexpr_markdown(lnum)
|
||||
let l1 = getline(a:lnum)
|
||||
" keep track of fenced code blocks
|
||||
if l1 =~ '````*' || l1 =~ '\~\~\~\~*'
|
||||
if b:fenced_block == 0
|
||||
let b:fenced_block = 1
|
||||
elseif b:fenced_block == 1
|
||||
let b:fenced_block = 0
|
||||
endif
|
||||
elseif g:vim_markdown_frontmatter == 1
|
||||
if b:front_matter == 1 && a:lnum > 2
|
||||
let l0 = getline(a:lnum-1)
|
||||
if l0 == '---'
|
||||
let b:front_matter = 0
|
||||
endif
|
||||
elseif a:lnum == 1
|
||||
if l1 == '---'
|
||||
let b:front_matter = 1
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
if b:fenced_block == 1 || b:front_matter == 1
|
||||
if a:lnum == 1
|
||||
" fold any 'preamble'
|
||||
return '>1'
|
||||
else
|
||||
" keep previous foldlevel
|
||||
return '='
|
||||
endif
|
||||
endif
|
||||
|
||||
let l2 = getline(a:lnum+1)
|
||||
if l2 =~ '^==\+\s*' && !s:is_mkdCode(a:lnum+1)
|
||||
" next line is underlined (level 1)
|
||||
return '>0'
|
||||
elseif l2 =~ '^--\+\s*' && !s:is_mkdCode(a:lnum+1)
|
||||
" next line is underlined (level 2)
|
||||
return '>1'
|
||||
endif
|
||||
|
||||
if l1 =~ '^#' && !s:is_mkdCode(a:lnum)
|
||||
" current line starts with hashes
|
||||
return '>'.(matchend(l1, '^#\+') - 1)
|
||||
elseif a:lnum == 1
|
||||
" fold any 'preamble'
|
||||
return '>1'
|
||||
else
|
||||
" keep previous foldlevel
|
||||
return '='
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! Foldtext_markdown()
|
||||
let line = getline(v:foldstart)
|
||||
let has_numbers = &number || &relativenumber
|
||||
let nucolwidth = &fdc + has_numbers * &numberwidth
|
||||
let windowwidth = winwidth(0) - nucolwidth - 6
|
||||
let foldedlinecount = v:foldend - v:foldstart
|
||||
let line = strpart(line, 0, windowwidth - 2 -len(foldedlinecount))
|
||||
let line = substitute(line, '\%("""\|''''''\)', '', '')
|
||||
let fillcharcount = windowwidth - len(line) - len(foldedlinecount) + 1
|
||||
return line . ' ' . repeat("-", fillcharcount) . ' ' . foldedlinecount
|
||||
endfunction
|
||||
else
|
||||
function! Foldexpr_markdown(lnum)
|
||||
if (a:lnum == 1)
|
||||
let l0 = ''
|
||||
else
|
||||
let l0 = getline(a:lnum-1)
|
||||
endif
|
||||
|
||||
" keep track of fenced code blocks
|
||||
if l0 =~ '````*' || l0 =~ '\~\~\~\~*'
|
||||
if b:fenced_block == 0
|
||||
let b:fenced_block = 1
|
||||
elseif b:fenced_block == 1
|
||||
let b:fenced_block = 0
|
||||
endif
|
||||
elseif g:vim_markdown_frontmatter == 1
|
||||
if b:front_matter == 1
|
||||
if l0 == '---'
|
||||
let b:front_matter = 0
|
||||
endif
|
||||
elseif a:lnum == 2
|
||||
if l0 == '---'
|
||||
let b:front_matter = 1
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
if b:fenced_block == 1 || b:front_matter == 1
|
||||
" keep previous foldlevel
|
||||
return '='
|
||||
endif
|
||||
|
||||
let l2 = getline(a:lnum+1)
|
||||
if l2 =~ '^==\+\s*' && !s:is_mkdCode(a:lnum+1)
|
||||
" next line is underlined (level 1)
|
||||
return '>1'
|
||||
elseif l2 =~ '^--\+\s*' && !s:is_mkdCode(a:lnum+1)
|
||||
" next line is underlined (level 2)
|
||||
if s:vim_markdown_folding_level >= 2
|
||||
return '>1'
|
||||
else
|
||||
return '>2'
|
||||
endif
|
||||
endif
|
||||
|
||||
let l1 = getline(a:lnum)
|
||||
if l1 =~ '^#' && !s:is_mkdCode(a:lnum)
|
||||
" fold level according to option
|
||||
if s:vim_markdown_folding_level == 1 || matchend(l1, '^#\+') > s:vim_markdown_folding_level
|
||||
if a:lnum == line('$')
|
||||
return matchend(l1, '^#\+') - 1
|
||||
else
|
||||
return -1
|
||||
endif
|
||||
else
|
||||
" headers are not folded
|
||||
return 0
|
||||
endif
|
||||
endif
|
||||
|
||||
if l0 =~ '^#' && !s:is_mkdCode(a:lnum-1)
|
||||
" previous line starts with hashes
|
||||
return '>'.matchend(l0, '^#\+')
|
||||
else
|
||||
" keep previous foldlevel
|
||||
return '='
|
||||
endif
|
||||
endfunction
|
||||
endif
|
||||
|
||||
|
||||
let b:fenced_block = 0
|
||||
let b:front_matter = 0
|
||||
let s:vim_markdown_folding_level = get(g:, "vim_markdown_folding_level", 1)
|
||||
|
||||
if !get(g:, "vim_markdown_folding_disabled", 0)
|
||||
setlocal foldexpr=Foldexpr_markdown(v:lnum)
|
||||
setlocal foldmethod=expr
|
||||
if get(g:, "vim_markdown_folding_style_pythonic", 0) && get(g:, "vim_markdown_override_foldtext", 1)
|
||||
setlocal foldtext=Foldtext_markdown()
|
||||
endif
|
||||
endif
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
:HeaderDecrease vim-markdown.txt /*:HeaderDecrease*
|
||||
:HeaderIncrease vim-markdown.txt /*:HeaderIncrease*
|
||||
:SetexToAtx vim-markdown.txt /*:SetexToAtx*
|
||||
:TableFormat vim-markdown.txt /*:TableFormat*
|
||||
:Toc vim-markdown.txt /*:Toc*
|
||||
:Toch vim-markdown.txt /*:Toch*
|
||||
:Toct vim-markdown.txt /*:Toct*
|
||||
:Tocv vim-markdown.txt /*:Tocv*
|
||||
vim-markdown vim-markdown.txt /*vim-markdown*
|
||||
vim-markdown-[[ vim-markdown.txt /*vim-markdown-[[*
|
||||
vim-markdown-[] vim-markdown.txt /*vim-markdown-[]*
|
||||
vim-markdown-][ vim-markdown.txt /*vim-markdown-][*
|
||||
vim-markdown-]] vim-markdown.txt /*vim-markdown-]]*
|
||||
vim-markdown-]c vim-markdown.txt /*vim-markdown-]c*
|
||||
vim-markdown-]u vim-markdown.txt /*vim-markdown-]u*
|
||||
vim-markdown-adjust-new-list-item-indent vim-markdown.txt /*vim-markdown-adjust-new-list-item-indent*
|
||||
vim-markdown-auto-write-when-following-link vim-markdown.txt /*vim-markdown-auto-write-when-following-link*
|
||||
vim-markdown-change-fold-style vim-markdown.txt /*vim-markdown-change-fold-style*
|
||||
vim-markdown-commands vim-markdown.txt /*vim-markdown-commands*
|
||||
vim-markdown-credits vim-markdown.txt /*vim-markdown-credits*
|
||||
vim-markdown-disable-default-key-mappings vim-markdown.txt /*vim-markdown-disable-default-key-mappings*
|
||||
vim-markdown-disable-folding vim-markdown.txt /*vim-markdown-disable-folding*
|
||||
vim-markdown-do-not-require-.md-extensions-for-markdown-links vim-markdown.txt /*vim-markdown-do-not-require-.md-extensions-for-markdown-links*
|
||||
vim-markdown-enable-toc-window-auto-fit vim-markdown.txt /*vim-markdown-enable-toc-window-auto-fit*
|
||||
vim-markdown-fenced-code-block-languages vim-markdown.txt /*vim-markdown-fenced-code-block-languages*
|
||||
vim-markdown-ge vim-markdown.txt /*vim-markdown-ge*
|
||||
vim-markdown-gx vim-markdown.txt /*vim-markdown-gx*
|
||||
vim-markdown-installation vim-markdown.txt /*vim-markdown-installation*
|
||||
vim-markdown-introduction vim-markdown.txt /*vim-markdown-introduction*
|
||||
vim-markdown-json-front-matter vim-markdown.txt /*vim-markdown-json-front-matter*
|
||||
vim-markdown-latex-math vim-markdown.txt /*vim-markdown-latex-math*
|
||||
vim-markdown-license vim-markdown.txt /*vim-markdown-license*
|
||||
vim-markdown-mappings vim-markdown.txt /*vim-markdown-mappings*
|
||||
vim-markdown-options vim-markdown.txt /*vim-markdown-options*
|
||||
vim-markdown-references vim-markdown.txt /*vim-markdown-references*
|
||||
vim-markdown-set-header-folding-level vim-markdown.txt /*vim-markdown-set-header-folding-level*
|
||||
vim-markdown-syntax-concealing vim-markdown.txt /*vim-markdown-syntax-concealing*
|
||||
vim-markdown-syntax-extensions vim-markdown.txt /*vim-markdown-syntax-extensions*
|
||||
vim-markdown-text-emphasis-restriction-to-single-lines vim-markdown.txt /*vim-markdown-text-emphasis-restriction-to-single-lines*
|
||||
vim-markdown-toml-front-matter vim-markdown.txt /*vim-markdown-toml-front-matter*
|
||||
vim-markdown-yaml-front-matter vim-markdown.txt /*vim-markdown-yaml-front-matter*
|
||||
|
|
@ -1,452 +0,0 @@
|
|||
*vim-markdown* Vim Markdown
|
||||
|
||||
===============================================================================
|
||||
Contents ~
|
||||
|
||||
1. Introduction |vim-markdown-introduction|
|
||||
2. Installation |vim-markdown-installation|
|
||||
3. Options |vim-markdown-options|
|
||||
1. Disable Folding |vim-markdown-disable-folding|
|
||||
2. Change fold style |vim-markdown-change-fold-style|
|
||||
3. Set header folding level |vim-markdown-set-header-folding-level|
|
||||
4. Disable Default Key Mappings |vim-markdown-disable-default-key-mappings|
|
||||
5. Enable TOC window auto-fit |vim-markdown-enable-toc-window-auto-fit|
|
||||
6. Text emphasis restriction to single-lines
|
||||
|vim-markdown-text-emphasis-restriction-to-single-lines|
|
||||
7. Syntax Concealing |vim-markdown-syntax-concealing|
|
||||
8. Fenced code block languages |vim-markdown-fenced-code-block-languages|
|
||||
9. Syntax extensions |vim-markdown-syntax-extensions|
|
||||
1. LaTeX math |vim-markdown-latex-math|
|
||||
2. YAML Front Matter |vim-markdown-yaml-front-matter|
|
||||
3. TOML Front Matter |vim-markdown-toml-front-matter|
|
||||
4. JSON Front Matter |vim-markdown-json-front-matter|
|
||||
10. Adjust new list item indent |vim-markdown-adjust-new-list-item-indent|
|
||||
11. Do not require .md extensions for Markdown links
|
||||
|vim-markdown-do-not-require-.md-extensions-for-markdown-links|
|
||||
12. Auto-write when following link
|
||||
|vim-markdown-auto-write-when-following-link|
|
||||
4. Mappings |vim-markdown-mappings|
|
||||
5. Commands |vim-markdown-commands|
|
||||
6. Credits |vim-markdown-credits|
|
||||
7. License |vim-markdown-license|
|
||||
8. References |vim-markdown-references|
|
||||
|
||||
===============================================================================
|
||||
*vim-markdown-introduction*
|
||||
Introduction ~
|
||||
|
||||
Syntax highlighting, matching rules and mappings for the original Markdown [1]
|
||||
and extensions.
|
||||
|
||||
===============================================================================
|
||||
*vim-markdown-installation*
|
||||
Installation ~
|
||||
|
||||
If you use Vundle [2], add the following line to your '~/.vimrc':
|
||||
>
|
||||
Plugin 'godlygeek/tabular'
|
||||
Plugin 'plasticboy/vim-markdown'
|
||||
<
|
||||
The 'tabular' plugin must come _before_ 'vim-markdown'.
|
||||
|
||||
Then run inside Vim:
|
||||
>
|
||||
:so ~/.vimrc
|
||||
:PluginInstall
|
||||
<
|
||||
If you use Pathogen [3], do this:
|
||||
>
|
||||
cd ~/.vim/bundle
|
||||
git clone https://github.com/plasticboy/vim-markdown.git
|
||||
<
|
||||
To install without Pathogen using the Debian vim-addon-manager [4], do this:
|
||||
>
|
||||
git clone https://github.com/plasticboy/vim-markdown.git
|
||||
cd vim-markdown
|
||||
sudo make install
|
||||
vim-addon-manager install markdown
|
||||
<
|
||||
If you are not using any package manager, download the tarball [5] and do this:
|
||||
>
|
||||
cd ~/.vim
|
||||
tar --strip=1 -zxf vim-markdown-master.tar.gz
|
||||
<
|
||||
===============================================================================
|
||||
*vim-markdown-options*
|
||||
Options ~
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
*vim-markdown-disable-folding*
|
||||
Disable Folding ~
|
||||
|
||||
Add the following line to your '.vimrc' to disable the folding configuration:
|
||||
>
|
||||
let g:vim_markdown_folding_disabled = 1
|
||||
<
|
||||
This option only controls Vim Markdown specific folding configuration.
|
||||
|
||||
To enable/disable folding use Vim's standard folding configuration.
|
||||
>
|
||||
set [no]foldenable
|
||||
<
|
||||
-------------------------------------------------------------------------------
|
||||
*vim-markdown-change-fold-style*
|
||||
Change fold style ~
|
||||
|
||||
To fold in a style like python-mode [6], add the following to your '.vimrc':
|
||||
>
|
||||
let g:vim_markdown_folding_style_pythonic = 1
|
||||
<
|
||||
Level 1 heading which is served as a document title is not folded.
|
||||
'g:vim_markdown_folding_level' setting is not active with this fold style.
|
||||
|
||||
To prevent foldtext from being set add the following to your '.vimrc':
|
||||
>
|
||||
let g:vim_markdown_override_foldtext = 0
|
||||
<
|
||||
-------------------------------------------------------------------------------
|
||||
*vim-markdown-set-header-folding-level*
|
||||
Set header folding level ~
|
||||
|
||||
Folding level is a number between 1 and 6. By default, if not specified, it is
|
||||
set to 1.
|
||||
>
|
||||
let g:vim_markdown_folding_level = 6
|
||||
<
|
||||
Tip: it can be changed on the fly with:
|
||||
>
|
||||
:let g:vim_markdown_folding_level = 1
|
||||
:edit
|
||||
<
|
||||
-------------------------------------------------------------------------------
|
||||
*vim-markdown-disable-default-key-mappings*
|
||||
Disable Default Key Mappings ~
|
||||
|
||||
Add the following line to your '.vimrc' to disable default key mappings:
|
||||
>
|
||||
let g:vim_markdown_no_default_key_mappings = 1
|
||||
<
|
||||
You can also map them by yourself with '<Plug>' mappings.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
*vim-markdown-enable-toc-window-auto-fit*
|
||||
Enable TOC window auto-fit ~
|
||||
|
||||
Allow for the TOC window to auto-fit when it's possible for it to shrink. It
|
||||
never increases its default size (half screen), it only shrinks.
|
||||
>
|
||||
let g:vim_markdown_toc_autofit = 1
|
||||
<
|
||||
-------------------------------------------------------------------------------
|
||||
*vim-markdown-text-emphasis-restriction-to-single-lines*
|
||||
Text emphasis restriction to single-lines ~
|
||||
|
||||
By default text emphasis works across multiple lines until a closing token is
|
||||
found. However, it's possible to restrict text emphasis to a single line (ie,
|
||||
for it to be applied a closing token must be found on the same line). To do so:
|
||||
>
|
||||
let g:vim_markdown_emphasis_multiline = 0
|
||||
<
|
||||
-------------------------------------------------------------------------------
|
||||
*vim-markdown-syntax-concealing*
|
||||
Syntax Concealing ~
|
||||
|
||||
Concealing is set for some syntax.
|
||||
|
||||
For example, conceal '[link text](link url)' as just 'link text'. Also,
|
||||
'_italic_' and '*italic*' will conceal to just _italic_. Similarly '__bold__',
|
||||
'**bold**', '___italic bold___', and '***italic bold***' will conceal to just
|
||||
**bold**, **bold**, **_italic bold_**, and **_italic bold_** respectively.
|
||||
|
||||
To enable conceal use Vim's standard conceal configuration.
|
||||
>
|
||||
set conceallevel=2
|
||||
<
|
||||
To disable conceal regardless of 'conceallevel' setting, add the following to
|
||||
your '.vimrc':
|
||||
>
|
||||
let g:vim_markdown_conceal = 0
|
||||
<
|
||||
To disable math conceal with LaTeX math syntax enabled, add the following to
|
||||
your '.vimrc':
|
||||
>
|
||||
let g:tex_conceal = ""
|
||||
let g:vim_markdown_math = 1
|
||||
<
|
||||
-------------------------------------------------------------------------------
|
||||
*vim-markdown-fenced-code-block-languages*
|
||||
Fenced code block languages ~
|
||||
|
||||
You can use filetype name as fenced code block languages for syntax
|
||||
highlighting. If you want to use different name from filetype, you can add it
|
||||
in your '.vimrc' like so:
|
||||
>
|
||||
let g:vim_markdown_fenced_languages = ['csharp=cs']
|
||||
<
|
||||
This will cause the following to be highlighted using the 'cs' filetype syntax.
|
||||
>
|
||||
```csharp
|
||||
...
|
||||
```
|
||||
<
|
||||
Default is "['c++=cpp', 'viml=vim', 'bash=sh', 'ini=dosini']".
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
*vim-markdown-syntax-extensions*
|
||||
Syntax extensions ~
|
||||
|
||||
The following options control which syntax extensions will be turned on. They
|
||||
are off by default.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
*vim-markdown-latex-math*
|
||||
LaTeX math ~
|
||||
|
||||
Used as '$x^2$', '$$x^2$$', escapable as '\$x\$' and '\$\$x\$\$'.
|
||||
>
|
||||
let g:vim_markdown_math = 1
|
||||
<
|
||||
-------------------------------------------------------------------------------
|
||||
*vim-markdown-yaml-front-matter*
|
||||
YAML Front Matter ~
|
||||
|
||||
Highlight YAML front matter as used by Jekyll or Hugo [7].
|
||||
>
|
||||
let g:vim_markdown_frontmatter = 1
|
||||
<
|
||||
-------------------------------------------------------------------------------
|
||||
*vim-markdown-toml-front-matter*
|
||||
TOML Front Matter ~
|
||||
|
||||
Highlight TOML front matter as used by Hugo [7].
|
||||
|
||||
TOML syntax highlight requires vim-toml [8].
|
||||
>
|
||||
let g:vim_markdown_toml_frontmatter = 1
|
||||
<
|
||||
-------------------------------------------------------------------------------
|
||||
*vim-markdown-json-front-matter*
|
||||
JSON Front Matter ~
|
||||
|
||||
Highlight JSON front matter as used by Hugo [7].
|
||||
|
||||
JSON syntax highlight requires vim-json [9].
|
||||
>
|
||||
let g:vim_markdown_json_frontmatter = 1
|
||||
<
|
||||
-------------------------------------------------------------------------------
|
||||
*vim-markdown-adjust-new-list-item-indent*
|
||||
Adjust new list item indent ~
|
||||
|
||||
You can adjust a new list indent. For example, you insert a single line like
|
||||
below:
|
||||
>
|
||||
* item1
|
||||
<
|
||||
Then if you type 'o' to insert new line in vim and type '* item2', the result
|
||||
will be:
|
||||
>
|
||||
* item1
|
||||
* item2
|
||||
<
|
||||
vim-markdown automatically insert the indent. By default, the number of spaces
|
||||
of indent is 4. If you'd like to change the number as 2, just write:
|
||||
>
|
||||
let g:vim_markdown_new_list_item_indent = 2
|
||||
<
|
||||
-------------------------------------------------------------------------------
|
||||
*vim-markdown-do-not-require-.md-extensions-for-markdown-links*
|
||||
Do not require .md extensions for Markdown links ~
|
||||
|
||||
If you want to have a link like this '[link text](link-url)' and follow it for
|
||||
editing in vim using the 'ge' command, but have it open the file "link-url.md"
|
||||
instead of the file "link-url", then use this option:
|
||||
>
|
||||
let g:vim_markdown_no_extensions_in_markdown = 1
|
||||
<
|
||||
This is super useful for GitLab and GitHub wiki repositories.
|
||||
|
||||
Normal behaviour would be that vim-markup required you to do this '[link text
|
||||
](link-url.md)', but this is not how the Gitlab and GitHub wiki repositories
|
||||
work. So this option adds some consistency between the two.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
*vim-markdown-auto-write-when-following-link*
|
||||
Auto-write when following link ~
|
||||
|
||||
If you follow a link like this '[link text](link-url)' using the 'ge' shortcut,
|
||||
this option will automatically save any edits you made before moving you:
|
||||
>
|
||||
let g:vim_markdown_autowrite = 1
|
||||
<
|
||||
===============================================================================
|
||||
*vim-markdown-mappings*
|
||||
Mappings ~
|
||||
|
||||
The following work on normal and visual modes:
|
||||
|
||||
*vim-markdown-gx*
|
||||
- 'gx': open the link under the cursor in the same browser as the standard
|
||||
'gx' command. '<Plug>Markdown_OpenUrlUnderCursor'
|
||||
|
||||
The standard 'gx' is extended by allowing you to put your cursor anywhere
|
||||
inside a link.
|
||||
|
||||
For example, all the following cursor positions will work:
|
||||
>
|
||||
[Example](http://example.com)
|
||||
^ ^ ^^ ^ ^
|
||||
1 2 34 5 6
|
||||
|
||||
<http://example.com>
|
||||
^ ^ ^
|
||||
1 2 3
|
||||
<
|
||||
Known limitation: does not work for links that span multiple lines.
|
||||
|
||||
*vim-markdown-ge*
|
||||
- 'ge': open the link under the cursor in Vim for editing. Useful for
|
||||
relative markdown links. '<Plug>Markdown_EditUrlUnderCursor'
|
||||
|
||||
The rules for the cursor position are the same as the 'gx' command.
|
||||
|
||||
*vim-markdown-]]*
|
||||
- ']]': go to next header. '<Plug>Markdown_MoveToNextHeader'
|
||||
|
||||
*vim-markdown-[[*
|
||||
- '[[': go to previous header. Contrast with ']c'.
|
||||
'<Plug>Markdown_MoveToPreviousHeader'
|
||||
|
||||
*vim-markdown-][*
|
||||
- '][': go to next sibling header if any.
|
||||
'<Plug>Markdown_MoveToNextSiblingHeader'
|
||||
|
||||
*vim-markdown-[]*
|
||||
- '[]': go to previous sibling header if any.
|
||||
'<Plug>Markdown_MoveToPreviousSiblingHeader'
|
||||
|
||||
*vim-markdown-]c*
|
||||
- ']c': go to Current header. '<Plug>Markdown_MoveToCurHeader'
|
||||
|
||||
*vim-markdown-]u*
|
||||
- ']u': go to parent header (Up). '<Plug>Markdown_MoveToParentHeader'
|
||||
|
||||
This plugin follows the recommended Vim plugin mapping interface, so to change
|
||||
the map ']u' to 'asdf', add to your '.vimrc':
|
||||
>
|
||||
map asdf <Plug>Markdown_MoveToParentHeader
|
||||
<
|
||||
To disable a map use:
|
||||
>
|
||||
map <Plug> <Plug>Markdown_MoveToParentHeader
|
||||
<
|
||||
===============================================================================
|
||||
*vim-markdown-commands*
|
||||
Commands ~
|
||||
|
||||
The following requires ':filetype plugin on'.
|
||||
|
||||
*:HeaderDecrease*
|
||||
- ':HeaderDecrease':
|
||||
|
||||
Decrease level of all headers in buffer: 'h2' to 'h1', 'h3' to 'h2', etc.
|
||||
|
||||
If range is given, only operate in the range.
|
||||
|
||||
If an 'h1' would be decreased, abort.
|
||||
|
||||
For simplicity of implementation, Setex headers are converted to Atx.
|
||||
|
||||
*:HeaderIncrease*
|
||||
- ':HeaderIncrease': Analogous to ':HeaderDecrease', but increase levels
|
||||
instead.
|
||||
|
||||
*:SetexToAtx*
|
||||
- ':SetexToAtx':
|
||||
|
||||
Convert all Setex style headers in buffer to Atx.
|
||||
|
||||
If a range is given, e.g. hit ':' from visual mode, only operate on the
|
||||
range.
|
||||
|
||||
*:TableFormat*
|
||||
- ':TableFormat': Format the table under the cursor like this [10].
|
||||
|
||||
Requires Tabular [11].
|
||||
|
||||
The input table _must_ already have a separator line as the second line of
|
||||
the table. That line only needs to contain the correct pipes '|', nothing
|
||||
else is required.
|
||||
|
||||
*:Toc*
|
||||
- ':Toc': create a quickfix vertical window navigable table of contents with
|
||||
the headers.
|
||||
|
||||
Hit '<Enter>' on a line to jump to the corresponding line of the markdown
|
||||
file.
|
||||
|
||||
*:Toch*
|
||||
- ':Toch': Same as ':Toc' but in an horizontal window.
|
||||
|
||||
*:Toct*
|
||||
- ':Toct': Same as ':Toc' but in a new tab.
|
||||
|
||||
*:Tocv*
|
||||
- ':Tocv': Same as ':Toc' for symmetry with ':Toch' and ':Tocv'.
|
||||
|
||||
===============================================================================
|
||||
*vim-markdown-credits*
|
||||
Credits ~
|
||||
|
||||
The main contributors of vim-markdown are:
|
||||
|
||||
- **Ben Williams** (A.K.A. **plasticboy**). The original developer of vim-
|
||||
markdown. Homepage [12].
|
||||
|
||||
If you feel that your name should be on this list, please make a pull request
|
||||
listing your contributions.
|
||||
|
||||
===============================================================================
|
||||
*vim-markdown-license*
|
||||
License ~
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2012 Benjamin D. Williams
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
===============================================================================
|
||||
*vim-markdown-references*
|
||||
References ~
|
||||
|
||||
[1] http://daringfireball.net/projects/markdown/
|
||||
[2] https://github.com/gmarik/vundle
|
||||
[3] https://github.com/tpope/vim-pathogen
|
||||
[4] http://packages.qa.debian.org/v/vim-addon-manager.html
|
||||
[5] https://github.com/plasticboy/vim-markdown/archive/master.tar.gz
|
||||
[6] https://github.com/klen/python-mode
|
||||
[7] https://gohugo.io/content/front-matter/
|
||||
[8] https://github.com/cespare/vim-toml
|
||||
[9] https://github.com/elzr/vim-json
|
||||
[10] http://www.cirosantilli.com/markdown-style-guide/#tables
|
||||
[11] https://github.com/godlygeek/tabular
|
||||
[12] http://plasticboy.com/
|
||||
|
||||
vim: ft=help
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
" markdown filetype file
|
||||
au BufRead,BufNewFile *.{md,mdown,mkd,mkdn,markdown,mdwn} set filetype=markdown
|
||||
au BufRead,BufNewFile *.{md,mdown,mkd,mkdn,markdown,mdwn}.{des3,des,bf,bfa,aes,idea,cast,rc2,rc4,rc5,desx} set filetype=markdown
|
||||
|
|
@ -1,749 +0,0 @@
|
|||
"TODO print messages when on visual mode. I only see VISUAL, not the messages.
|
||||
|
||||
" Function interface phylosophy:
|
||||
"
|
||||
" - functions take arbitrary line numbers as parameters.
|
||||
" Current cursor line is only a suitable default parameter.
|
||||
"
|
||||
" - only functions that bind directly to user actions:
|
||||
"
|
||||
" - print error messages.
|
||||
" All intermediate functions limit themselves return `0` to indicate an error.
|
||||
"
|
||||
" - move the cursor. All other functions do not move the cursor.
|
||||
"
|
||||
" This is how you should view headers for the header mappings:
|
||||
"
|
||||
" |BUFFER
|
||||
" |
|
||||
" |Outside any header
|
||||
" |
|
||||
" a-+# a
|
||||
" |
|
||||
" |Inside a
|
||||
" |
|
||||
" a-+
|
||||
" b-+## b
|
||||
" |
|
||||
" |inside b
|
||||
" |
|
||||
" b-+
|
||||
" c-+### c
|
||||
" |
|
||||
" |Inside c
|
||||
" |
|
||||
" c-+
|
||||
" d-|# d
|
||||
" |
|
||||
" |Inside d
|
||||
" |
|
||||
" d-+
|
||||
" e-|e
|
||||
" |====
|
||||
" |
|
||||
" |Inside e
|
||||
" |
|
||||
" e-+
|
||||
|
||||
" For each level, contains the regexp that matches at that level only.
|
||||
"
|
||||
let s:levelRegexpDict = {
|
||||
\ 1: '\v^(#[^#]@=|.+\n\=+$)',
|
||||
\ 2: '\v^(##[^#]@=|.+\n-+$)',
|
||||
\ 3: '\v^###[^#]@=',
|
||||
\ 4: '\v^####[^#]@=',
|
||||
\ 5: '\v^#####[^#]@=',
|
||||
\ 6: '\v^######[^#]@='
|
||||
\ }
|
||||
|
||||
" Maches any header level of any type.
|
||||
"
|
||||
" This could be deduced from `s:levelRegexpDict`, but it is more
|
||||
" efficient to have a single regexp for this.
|
||||
"
|
||||
let s:headersRegexp = '\v^(#|.+\n(\=+|-+)$)'
|
||||
|
||||
" Returns the line number of the first header before `line`, called the
|
||||
" current header.
|
||||
"
|
||||
" If there is no current header, return `0`.
|
||||
"
|
||||
" @param a:1 The line to look the header of. Default value: `getpos('.')`.
|
||||
"
|
||||
function! s:GetHeaderLineNum(...)
|
||||
if a:0 == 0
|
||||
let l:l = line('.')
|
||||
else
|
||||
let l:l = a:1
|
||||
endif
|
||||
while(l:l > 0)
|
||||
if join(getline(l:l, l:l + 1), "\n") =~ s:headersRegexp
|
||||
return l:l
|
||||
endif
|
||||
let l:l -= 1
|
||||
endwhile
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
" - if inside a header goes to it.
|
||||
" Return its line number.
|
||||
"
|
||||
" - if on top level outside any headers,
|
||||
" print a warning
|
||||
" Return `0`.
|
||||
"
|
||||
function! s:MoveToCurHeader()
|
||||
let l:lineNum = s:GetHeaderLineNum()
|
||||
if l:lineNum != 0
|
||||
call cursor(l:lineNum, 1)
|
||||
else
|
||||
echo 'outside any header'
|
||||
"normal! gg
|
||||
endif
|
||||
return l:lineNum
|
||||
endfunction
|
||||
|
||||
" Move cursor to next header of any level.
|
||||
"
|
||||
" If there are no more headers, print a warning.
|
||||
"
|
||||
function! s:MoveToNextHeader()
|
||||
if search(s:headersRegexp, 'W') == 0
|
||||
"normal! G
|
||||
echo 'no next header'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Move cursor to previous header (before current) of any level.
|
||||
"
|
||||
" If it does not exist, print a warning.
|
||||
"
|
||||
function! s:MoveToPreviousHeader()
|
||||
let l:curHeaderLineNumber = s:GetHeaderLineNum()
|
||||
let l:noPreviousHeader = 0
|
||||
if l:curHeaderLineNumber <= 1
|
||||
let l:noPreviousHeader = 1
|
||||
else
|
||||
let l:previousHeaderLineNumber = s:GetHeaderLineNum(l:curHeaderLineNumber - 1)
|
||||
if l:previousHeaderLineNumber == 0
|
||||
let l:noPreviousHeader = 1
|
||||
else
|
||||
call cursor(l:previousHeaderLineNumber, 1)
|
||||
endif
|
||||
endif
|
||||
if l:noPreviousHeader
|
||||
echo 'no previous header'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" - if line is inside a header, return the header level (h1 -> 1, h2 -> 2, etc.).
|
||||
"
|
||||
" - if line is at top level outside any headers, return `0`.
|
||||
"
|
||||
function! s:GetHeaderLevel(...)
|
||||
if a:0 == 0
|
||||
let l:line = line('.')
|
||||
else
|
||||
let l:line = a:1
|
||||
endif
|
||||
let l:linenum = s:GetHeaderLineNum(l:line)
|
||||
if l:linenum != 0
|
||||
return s:GetLevelOfHeaderAtLine(l:linenum)
|
||||
else
|
||||
return 0
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Returns the level of the header at the given line.
|
||||
"
|
||||
" If there is no header at the given line, returns `0`.
|
||||
"
|
||||
function! s:GetLevelOfHeaderAtLine(linenum)
|
||||
let l:lines = join(getline(a:linenum, a:linenum + 1), "\n")
|
||||
for l:key in keys(s:levelRegexpDict)
|
||||
if l:lines =~ get(s:levelRegexpDict, l:key)
|
||||
return l:key
|
||||
endif
|
||||
endfor
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
" Move cursor to parent header of the current header.
|
||||
"
|
||||
" If it does not exit, print a warning and do nothing.
|
||||
"
|
||||
function! s:MoveToParentHeader()
|
||||
let l:linenum = s:GetParentHeaderLineNumber()
|
||||
if l:linenum != 0
|
||||
call cursor(l:linenum, 1)
|
||||
else
|
||||
echo 'no parent header'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Return the line number of the parent header of line `line`.
|
||||
"
|
||||
" If it has no parent, return `0`.
|
||||
"
|
||||
function! s:GetParentHeaderLineNumber(...)
|
||||
if a:0 == 0
|
||||
let l:line = line('.')
|
||||
else
|
||||
let l:line = a:1
|
||||
endif
|
||||
let l:level = s:GetHeaderLevel(l:line)
|
||||
if l:level > 1
|
||||
let l:linenum = s:GetPreviousHeaderLineNumberAtLevel(l:level - 1, l:line)
|
||||
return l:linenum
|
||||
endif
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
" Return the line number of the previous header of given level.
|
||||
" in relation to line `a:1`. If not given, `a:1 = getline()`
|
||||
"
|
||||
" `a:1` line is included, and this may return the current header.
|
||||
"
|
||||
" If none return 0.
|
||||
"
|
||||
function! s:GetNextHeaderLineNumberAtLevel(level, ...)
|
||||
if a:0 < 1
|
||||
let l:line = line('.')
|
||||
else
|
||||
let l:line = a:1
|
||||
endif
|
||||
let l:l = l:line
|
||||
while(l:l <= line('$'))
|
||||
if join(getline(l:l, l:l + 1), "\n") =~ get(s:levelRegexpDict, a:level)
|
||||
return l:l
|
||||
endif
|
||||
let l:l += 1
|
||||
endwhile
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
" Return the line number of the previous header of given level.
|
||||
" in relation to line `a:1`. If not given, `a:1 = getline()`
|
||||
"
|
||||
" `a:1` line is included, and this may return the current header.
|
||||
"
|
||||
" If none return 0.
|
||||
"
|
||||
function! s:GetPreviousHeaderLineNumberAtLevel(level, ...)
|
||||
if a:0 == 0
|
||||
let l:line = line('.')
|
||||
else
|
||||
let l:line = a:1
|
||||
endif
|
||||
let l:l = l:line
|
||||
while(l:l > 0)
|
||||
if join(getline(l:l, l:l + 1), "\n") =~ get(s:levelRegexpDict, a:level)
|
||||
return l:l
|
||||
endif
|
||||
let l:l -= 1
|
||||
endwhile
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
" Move cursor to next sibling header.
|
||||
"
|
||||
" If there is no next siblings, print a warning and don't move.
|
||||
"
|
||||
function! s:MoveToNextSiblingHeader()
|
||||
let l:curHeaderLineNumber = s:GetHeaderLineNum()
|
||||
let l:curHeaderLevel = s:GetLevelOfHeaderAtLine(l:curHeaderLineNumber)
|
||||
let l:curHeaderParentLineNumber = s:GetParentHeaderLineNumber()
|
||||
let l:nextHeaderSameLevelLineNumber = s:GetNextHeaderLineNumberAtLevel(l:curHeaderLevel, l:curHeaderLineNumber + 1)
|
||||
let l:noNextSibling = 0
|
||||
if l:nextHeaderSameLevelLineNumber == 0
|
||||
let l:noNextSibling = 1
|
||||
else
|
||||
let l:nextHeaderSameLevelParentLineNumber = s:GetParentHeaderLineNumber(l:nextHeaderSameLevelLineNumber)
|
||||
if l:curHeaderParentLineNumber == l:nextHeaderSameLevelParentLineNumber
|
||||
call cursor(l:nextHeaderSameLevelLineNumber, 1)
|
||||
else
|
||||
let l:noNextSibling = 1
|
||||
endif
|
||||
endif
|
||||
if l:noNextSibling
|
||||
echo 'no next sibling header'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Move cursor to previous sibling header.
|
||||
"
|
||||
" If there is no previous siblings, print a warning and do nothing.
|
||||
"
|
||||
function! s:MoveToPreviousSiblingHeader()
|
||||
let l:curHeaderLineNumber = s:GetHeaderLineNum()
|
||||
let l:curHeaderLevel = s:GetLevelOfHeaderAtLine(l:curHeaderLineNumber)
|
||||
let l:curHeaderParentLineNumber = s:GetParentHeaderLineNumber()
|
||||
let l:previousHeaderSameLevelLineNumber = s:GetPreviousHeaderLineNumberAtLevel(l:curHeaderLevel, l:curHeaderLineNumber - 1)
|
||||
let l:noPreviousSibling = 0
|
||||
if l:previousHeaderSameLevelLineNumber == 0
|
||||
let l:noPreviousSibling = 1
|
||||
else
|
||||
let l:previousHeaderSameLevelParentLineNumber = s:GetParentHeaderLineNumber(l:previousHeaderSameLevelLineNumber)
|
||||
if l:curHeaderParentLineNumber == l:previousHeaderSameLevelParentLineNumber
|
||||
call cursor(l:previousHeaderSameLevelLineNumber, 1)
|
||||
else
|
||||
let l:noPreviousSibling = 1
|
||||
endif
|
||||
endif
|
||||
if l:noPreviousSibling
|
||||
echo 'no previous sibling header'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:Toc(...)
|
||||
if a:0 > 0
|
||||
let l:window_type = a:1
|
||||
else
|
||||
let l:window_type = 'vertical'
|
||||
endif
|
||||
|
||||
|
||||
let l:bufnr = bufnr('%')
|
||||
let l:cursor_line = line('.')
|
||||
let l:cursor_header = 0
|
||||
let l:fenced_block = 0
|
||||
let l:front_matter = 0
|
||||
let l:header_list = []
|
||||
let l:header_max_len = 0
|
||||
let l:vim_markdown_toc_autofit = get(g:, "vim_markdown_toc_autofit", 0)
|
||||
let l:vim_markdown_frontmatter = get(g:, "vim_markdown_frontmatter", 0)
|
||||
for i in range(1, line('$'))
|
||||
let l:lineraw = getline(i)
|
||||
let l:l1 = getline(i+1)
|
||||
let l:line = substitute(l:lineraw, "#", "\\\#", "g")
|
||||
if l:line =~ '````*' || l:line =~ '\~\~\~\~*'
|
||||
if l:fenced_block == 0
|
||||
let l:fenced_block = 1
|
||||
elseif l:fenced_block == 1
|
||||
let l:fenced_block = 0
|
||||
endif
|
||||
elseif l:vim_markdown_frontmatter == 1
|
||||
if l:front_matter == 1
|
||||
if l:line == '---'
|
||||
let l:front_matter = 0
|
||||
endif
|
||||
elseif i == 1
|
||||
if l:line == '---'
|
||||
let l:front_matter = 1
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
if l:line =~ '^#\+' || (l:l1 =~ '^=\+\s*$' || l:l1 =~ '^-\+\s*$') && l:line =~ '^\S'
|
||||
let l:is_header = 1
|
||||
else
|
||||
let l:is_header = 0
|
||||
endif
|
||||
if l:is_header == 1 && l:fenced_block == 0 && l:front_matter == 0
|
||||
" append line to location list
|
||||
let l:item = {'lnum': i, 'text': l:line, 'valid': 1, 'bufnr': l:bufnr, 'col': 1}
|
||||
let l:header_list = l:header_list + [l:item]
|
||||
" set header number of the cursor position
|
||||
if l:cursor_header == 0
|
||||
if i == l:cursor_line
|
||||
let l:cursor_header = len(l:header_list)
|
||||
elseif i > l:cursor_line
|
||||
let l:cursor_header = len(l:header_list) - 1
|
||||
endif
|
||||
endif
|
||||
" keep track of the longest header size (heading level + title)
|
||||
let l:total_len = stridx(l:line, ' ') + strdisplaywidth(l:line)
|
||||
if l:total_len > l:header_max_len
|
||||
let l:header_max_len = l:total_len
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
call setloclist(0, l:header_list)
|
||||
if len(l:header_list) == 0
|
||||
echom "Toc: No headers."
|
||||
return
|
||||
endif
|
||||
|
||||
if l:window_type ==# 'horizontal'
|
||||
lopen
|
||||
elseif l:window_type ==# 'vertical'
|
||||
vertical lopen
|
||||
" auto-fit toc window when possible to shrink it
|
||||
if (&columns/2) > l:header_max_len && l:vim_markdown_toc_autofit == 1
|
||||
execute 'vertical resize ' . (l:header_max_len + 1)
|
||||
else
|
||||
execute 'vertical resize ' . (&columns/2)
|
||||
endif
|
||||
elseif l:window_type ==# 'tab'
|
||||
tab lopen
|
||||
else
|
||||
lopen
|
||||
endif
|
||||
setlocal modifiable
|
||||
for i in range(1, line('$'))
|
||||
" this is the location-list data for the current item
|
||||
let d = getloclist(0)[i-1]
|
||||
" atx headers
|
||||
if match(d.text, "^#") > -1
|
||||
let l:level = len(matchstr(d.text, '#*', 'g'))-1
|
||||
let d.text = substitute(d.text, '\v^#*[ ]*', '', '')
|
||||
let d.text = substitute(d.text, '\v[ ]*#*$', '', '')
|
||||
" setex headers
|
||||
else
|
||||
let l:next_line = getbufline(d.bufnr, d.lnum+1)
|
||||
if match(l:next_line, "=") > -1
|
||||
let l:level = 0
|
||||
elseif match(l:next_line, "-") > -1
|
||||
let l:level = 1
|
||||
endif
|
||||
endif
|
||||
call setline(i, repeat(' ', l:level). d.text)
|
||||
endfor
|
||||
setlocal nomodified
|
||||
setlocal nomodifiable
|
||||
execute 'normal! ' . l:cursor_header . 'G'
|
||||
endfunction
|
||||
|
||||
" Convert Setex headers in range `line1 .. line2` to Atx.
|
||||
"
|
||||
" Return the number of conversions.
|
||||
"
|
||||
function! s:SetexToAtx(line1, line2)
|
||||
let l:originalNumLines = line('$')
|
||||
execute 'silent! ' . a:line1 . ',' . a:line2 . 'substitute/\v(.*\S.*)\n\=+$/# \1/'
|
||||
execute 'silent! ' . a:line1 . ',' . a:line2 . 'substitute/\v(.*\S.*)\n-+$/## \1/'
|
||||
return l:originalNumLines - line('$')
|
||||
endfunction
|
||||
|
||||
" If `a:1` is 0, decrease the level of all headers in range `line1 .. line2`.
|
||||
"
|
||||
" Otherwise, increase the level. `a:1` defaults to `0`.
|
||||
"
|
||||
function! s:HeaderDecrease(line1, line2, ...)
|
||||
if a:0 > 0
|
||||
let l:increase = a:1
|
||||
else
|
||||
let l:increase = 0
|
||||
endif
|
||||
if l:increase
|
||||
let l:forbiddenLevel = 6
|
||||
let l:replaceLevels = [5, 1]
|
||||
let l:levelDelta = 1
|
||||
else
|
||||
let l:forbiddenLevel = 1
|
||||
let l:replaceLevels = [2, 6]
|
||||
let l:levelDelta = -1
|
||||
endif
|
||||
for l:line in range(a:line1, a:line2)
|
||||
if join(getline(l:line, l:line + 1), "\n") =~ s:levelRegexpDict[l:forbiddenLevel]
|
||||
echomsg 'There is an h' . l:forbiddenLevel . ' at line ' . l:line . '. Aborting.'
|
||||
return
|
||||
endif
|
||||
endfor
|
||||
let l:numSubstitutions = s:SetexToAtx(a:line1, a:line2)
|
||||
let l:flags = (&gdefault ? '' : 'g')
|
||||
for l:level in range(replaceLevels[0], replaceLevels[1], -l:levelDelta)
|
||||
execute 'silent! ' . a:line1 . ',' . (a:line2 - l:numSubstitutions) . 'substitute/' . s:levelRegexpDict[l:level] . '/' . repeat('#', l:level + l:levelDelta) . '/' . l:flags
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
" Format table under cursor.
|
||||
"
|
||||
" Depends on Tabularize.
|
||||
"
|
||||
function! s:TableFormat()
|
||||
let l:pos = getpos('.')
|
||||
normal! {
|
||||
" Search instead of `normal! j` because of the table at beginning of file edge case.
|
||||
call search('|')
|
||||
normal! j
|
||||
" Remove everything that is not a pipe, colon or hyphen next to a colon othewise
|
||||
" well formated tables would grow because of addition of 2 spaces on the separator
|
||||
" line by Tabularize /|.
|
||||
let l:flags = (&gdefault ? '' : 'g')
|
||||
execute 's/\(:\@<!-:\@!\|[^|:-]\)//e' . l:flags
|
||||
execute 's/--/-/e' . l:flags
|
||||
Tabularize /|
|
||||
" Move colons for alignment to left or right side of the cell.
|
||||
execute 's/:\( \+\)|/\1:|/e' . l:flags
|
||||
execute 's/|\( \+\):/|:\1/e' . l:flags
|
||||
execute 's/ /-/' . l:flags
|
||||
call setpos('.', l:pos)
|
||||
endfunction
|
||||
|
||||
" Wrapper to do move commands in visual mode.
|
||||
"
|
||||
function! s:VisMove(f)
|
||||
norm! gv
|
||||
call function(a:f)()
|
||||
endfunction
|
||||
|
||||
" Map in both normal and visual modes.
|
||||
"
|
||||
function! s:MapNormVis(rhs,lhs)
|
||||
execute 'nn <buffer><silent> ' . a:rhs . ' :call ' . a:lhs . '()<cr>'
|
||||
execute 'vn <buffer><silent> ' . a:rhs . ' <esc>:call <sid>VisMove(''' . a:lhs . ''')<cr>'
|
||||
endfunction
|
||||
|
||||
" Parameters:
|
||||
"
|
||||
" - step +1 for right, -1 for left
|
||||
"
|
||||
" TODO: multiple lines.
|
||||
"
|
||||
function! s:FindCornerOfSyntax(lnum, col, step)
|
||||
let l:col = a:col
|
||||
let l:syn = synIDattr(synID(a:lnum, l:col, 1), 'name')
|
||||
while synIDattr(synID(a:lnum, l:col, 1), 'name') ==# l:syn
|
||||
let l:col += a:step
|
||||
endwhile
|
||||
return l:col - a:step
|
||||
endfunction
|
||||
|
||||
" Return the next position of the given syntax name,
|
||||
" inclusive on the given position.
|
||||
"
|
||||
" TODO: multiple lines
|
||||
"
|
||||
function! s:FindNextSyntax(lnum, col, name)
|
||||
let l:col = a:col
|
||||
let l:step = 1
|
||||
while synIDattr(synID(a:lnum, l:col, 1), 'name') !=# a:name
|
||||
let l:col += l:step
|
||||
endwhile
|
||||
return [a:lnum, l:col]
|
||||
endfunction
|
||||
|
||||
function! s:FindCornersOfSyntax(lnum, col)
|
||||
return [<sid>FindLeftOfSyntax(a:lnum, a:col), <sid>FindRightOfSyntax(a:lnum, a:col)]
|
||||
endfunction
|
||||
|
||||
function! s:FindRightOfSyntax(lnum, col)
|
||||
return <sid>FindCornerOfSyntax(a:lnum, a:col, 1)
|
||||
endfunction
|
||||
|
||||
function! s:FindLeftOfSyntax(lnum, col)
|
||||
return <sid>FindCornerOfSyntax(a:lnum, a:col, -1)
|
||||
endfunction
|
||||
|
||||
" Returns:
|
||||
"
|
||||
" - a string with the the URL for the link under the cursor
|
||||
" - an empty string if the cursor is not on a link
|
||||
"
|
||||
" TODO
|
||||
"
|
||||
" - multiline support
|
||||
" - give an error if the separator does is not on a link
|
||||
"
|
||||
function! s:Markdown_GetUrlForPosition(lnum, col)
|
||||
let l:lnum = a:lnum
|
||||
let l:col = a:col
|
||||
let l:syn = synIDattr(synID(l:lnum, l:col, 1), 'name')
|
||||
|
||||
if l:syn ==# 'mkdInlineURL' || l:syn ==# 'mkdURL' || l:syn ==# 'mkdLinkDefTarget'
|
||||
" Do nothing.
|
||||
elseif l:syn ==# 'mkdLink'
|
||||
let [l:lnum, l:col] = <sid>FindNextSyntax(l:lnum, l:col, 'mkdURL')
|
||||
let l:syn = 'mkdURL'
|
||||
elseif l:syn ==# 'mkdDelimiter'
|
||||
let l:line = getline(l:lnum)
|
||||
let l:char = l:line[col - 1]
|
||||
if l:char ==# '<'
|
||||
let l:col += 1
|
||||
elseif l:char ==# '>' || l:char ==# ')'
|
||||
let l:col -= 1
|
||||
elseif l:char ==# '[' || l:char ==# ']' || l:char ==# '('
|
||||
let [l:lnum, l:col] = <sid>FindNextSyntax(l:lnum, l:col, 'mkdURL')
|
||||
else
|
||||
return ''
|
||||
endif
|
||||
else
|
||||
return ''
|
||||
endif
|
||||
|
||||
let [l:left, l:right] = <sid>FindCornersOfSyntax(l:lnum, l:col)
|
||||
return getline(l:lnum)[l:left - 1 : l:right - 1]
|
||||
endfunction
|
||||
|
||||
" Front end for GetUrlForPosition.
|
||||
"
|
||||
function! s:OpenUrlUnderCursor()
|
||||
let l:url = s:Markdown_GetUrlForPosition(line('.'), col('.'))
|
||||
if l:url != ''
|
||||
call s:VersionAwareNetrwBrowseX(l:url)
|
||||
else
|
||||
echomsg 'The cursor is not on a link.'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" We need a definition guard because we invoke 'edit' which will reload this
|
||||
" script while this function is running. We must not replace it.
|
||||
if !exists("*s:EditUrlUnderCursor")
|
||||
function s:EditUrlUnderCursor()
|
||||
let l:url = s:Markdown_GetUrlForPosition(line('.'), col('.'))
|
||||
if l:url != ''
|
||||
if get(g:, 'vim_markdown_autowrite', 0)
|
||||
write
|
||||
endif
|
||||
if get(g:, 'vim_markdown_no_extensions_in_markdown', 0)
|
||||
execute 'edit' fnamemodify(expand('%:~'), ':p:h').'/'.l:url.'.md'
|
||||
else
|
||||
execute 'edit' l:url
|
||||
endif
|
||||
else
|
||||
echomsg 'The cursor is not on a link.'
|
||||
endif
|
||||
endfunction
|
||||
endif
|
||||
|
||||
function! s:VersionAwareNetrwBrowseX(url)
|
||||
if has('patch-7.4.567')
|
||||
call netrw#BrowseX(a:url, 0)
|
||||
else
|
||||
call netrw#NetrwBrowseX(a:url, 0)
|
||||
endif
|
||||
endf
|
||||
|
||||
function! s:MapNotHasmapto(lhs, rhs)
|
||||
if !hasmapto('<Plug>' . a:rhs)
|
||||
execute 'nmap <buffer>' . a:lhs . ' <Plug>' . a:rhs
|
||||
execute 'vmap <buffer>' . a:lhs . ' <Plug>' . a:rhs
|
||||
endif
|
||||
endfunction
|
||||
|
||||
call <sid>MapNormVis('<Plug>Markdown_MoveToNextHeader', '<sid>MoveToNextHeader')
|
||||
call <sid>MapNormVis('<Plug>Markdown_MoveToPreviousHeader', '<sid>MoveToPreviousHeader')
|
||||
call <sid>MapNormVis('<Plug>Markdown_MoveToNextSiblingHeader', '<sid>MoveToNextSiblingHeader')
|
||||
call <sid>MapNormVis('<Plug>Markdown_MoveToPreviousSiblingHeader', '<sid>MoveToPreviousSiblingHeader')
|
||||
call <sid>MapNormVis('<Plug>Markdown_MoveToParentHeader', '<sid>MoveToParentHeader')
|
||||
call <sid>MapNormVis('<Plug>Markdown_MoveToCurHeader', '<sid>MoveToCurHeader')
|
||||
nnoremap <Plug>Markdown_OpenUrlUnderCursor :call <sid>OpenUrlUnderCursor()<cr>
|
||||
nnoremap <Plug>Markdown_EditUrlUnderCursor :call <sid>EditUrlUnderCursor()<cr>
|
||||
|
||||
if !get(g:, 'vim_markdown_no_default_key_mappings', 0)
|
||||
call <sid>MapNotHasmapto(']]', 'Markdown_MoveToNextHeader')
|
||||
call <sid>MapNotHasmapto('[[', 'Markdown_MoveToPreviousHeader')
|
||||
call <sid>MapNotHasmapto('][', 'Markdown_MoveToNextSiblingHeader')
|
||||
call <sid>MapNotHasmapto('[]', 'Markdown_MoveToPreviousSiblingHeader')
|
||||
call <sid>MapNotHasmapto(']u', 'Markdown_MoveToParentHeader')
|
||||
call <sid>MapNotHasmapto(']c', 'Markdown_MoveToCurHeader')
|
||||
call <sid>MapNotHasmapto('gx', 'Markdown_OpenUrlUnderCursor')
|
||||
call <sid>MapNotHasmapto('ge', 'Markdown_EditUrlUnderCursor')
|
||||
endif
|
||||
|
||||
command! -buffer -range=% HeaderDecrease call s:HeaderDecrease(<line1>, <line2>)
|
||||
command! -buffer -range=% HeaderIncrease call s:HeaderDecrease(<line1>, <line2>, 1)
|
||||
command! -buffer -range=% SetexToAtx call s:SetexToAtx(<line1>, <line2>)
|
||||
command! -buffer TableFormat call s:TableFormat()
|
||||
command! -buffer Toc call s:Toc()
|
||||
command! -buffer Toch call s:Toc('horizontal')
|
||||
command! -buffer Tocv call s:Toc('vertical')
|
||||
command! -buffer Toct call s:Toc('tab')
|
||||
|
||||
" Heavily based on vim-notes - http://peterodding.com/code/vim/notes/
|
||||
if exists('g:vim_markdown_fenced_languages')
|
||||
let s:filetype_dict = {}
|
||||
for s:filetype in g:vim_markdown_fenced_languages
|
||||
let key = matchstr(s:filetype, "[^=]*")
|
||||
let val = matchstr(s:filetype, "[^=]*$")
|
||||
let s:filetype_dict[key] = val
|
||||
endfor
|
||||
else
|
||||
let s:filetype_dict = {
|
||||
\ 'c++': 'cpp',
|
||||
\ 'viml': 'vim',
|
||||
\ 'bash': 'sh',
|
||||
\ 'ini': 'dosini'
|
||||
\ }
|
||||
endif
|
||||
|
||||
function! s:MarkdownHighlightSources(force)
|
||||
" Syntax highlight source code embedded in notes.
|
||||
" Look for code blocks in the current file
|
||||
let filetypes = {}
|
||||
for line in getline(1, '$')
|
||||
let ft = matchstr(line, '```\s*\zs[0-9A-Za-z_+-]*')
|
||||
if !empty(ft) && ft !~ '^\d*$' | let filetypes[ft] = 1 | endif
|
||||
endfor
|
||||
if !exists('b:mkd_known_filetypes')
|
||||
let b:mkd_known_filetypes = {}
|
||||
endif
|
||||
if !exists('b:mkd_included_filetypes')
|
||||
" set syntax file name included
|
||||
let b:mkd_included_filetypes = {}
|
||||
endif
|
||||
if !a:force && (b:mkd_known_filetypes == filetypes || empty(filetypes))
|
||||
return
|
||||
endif
|
||||
|
||||
" Now we're ready to actually highlight the code blocks.
|
||||
let startgroup = 'mkdCodeStart'
|
||||
let endgroup = 'mkdCodeEnd'
|
||||
for ft in keys(filetypes)
|
||||
if a:force || !has_key(b:mkd_known_filetypes, ft)
|
||||
if has_key(s:filetype_dict, ft)
|
||||
let filetype = s:filetype_dict[ft]
|
||||
else
|
||||
let filetype = ft
|
||||
endif
|
||||
let group = 'mkdSnippet' . toupper(substitute(filetype, "[+-]", "_", "g"))
|
||||
if !has_key(b:mkd_included_filetypes, filetype)
|
||||
let include = s:SyntaxInclude(filetype)
|
||||
let b:mkd_included_filetypes[filetype] = 1
|
||||
else
|
||||
let include = '@' . toupper(filetype)
|
||||
endif
|
||||
let command = 'syntax region %s matchgroup=%s start="^\s*```\s*%s$" matchgroup=%s end="\s*```$" keepend contains=%s%s'
|
||||
execute printf(command, group, startgroup, ft, endgroup, include, has('conceal') && get(g:, 'vim_markdown_conceal', 1) ? ' concealends' : '')
|
||||
execute printf('syntax cluster mkdNonListItem add=%s', group)
|
||||
|
||||
let b:mkd_known_filetypes[ft] = 1
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! s:SyntaxInclude(filetype)
|
||||
" Include the syntax highlighting of another {filetype}.
|
||||
let grouplistname = '@' . toupper(a:filetype)
|
||||
" Unset the name of the current syntax while including the other syntax
|
||||
" because some syntax scripts do nothing when "b:current_syntax" is set
|
||||
if exists('b:current_syntax')
|
||||
let syntax_save = b:current_syntax
|
||||
unlet b:current_syntax
|
||||
endif
|
||||
try
|
||||
execute 'syntax include' grouplistname 'syntax/' . a:filetype . '.vim'
|
||||
execute 'syntax include' grouplistname 'after/syntax/' . a:filetype . '.vim'
|
||||
catch /E484/
|
||||
" Ignore missing scripts
|
||||
endtry
|
||||
" Restore the name of the current syntax
|
||||
if exists('syntax_save')
|
||||
let b:current_syntax = syntax_save
|
||||
elseif exists('b:current_syntax')
|
||||
unlet b:current_syntax
|
||||
endif
|
||||
return grouplistname
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:MarkdownRefreshSyntax(force)
|
||||
if &filetype == 'markdown' && line('$') > 1
|
||||
call s:MarkdownHighlightSources(a:force)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:MarkdownClearSyntaxVariables()
|
||||
if &filetype == 'markdown'
|
||||
unlet! b:mkd_included_filetypes
|
||||
endif
|
||||
endfunction
|
||||
|
||||
augroup Mkd
|
||||
autocmd!
|
||||
au BufWinEnter * call s:MarkdownRefreshSyntax(1)
|
||||
au BufUnload * call s:MarkdownClearSyntaxVariables()
|
||||
au BufWritePost * call s:MarkdownRefreshSyntax(0)
|
||||
au InsertEnter,InsertLeave * call s:MarkdownRefreshSyntax(0)
|
||||
au CursorHold,CursorHoldI * call s:MarkdownRefreshSyntax(0)
|
||||
augroup END
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
if exists("b:did_indent") | finish | endif
|
||||
let b:did_indent = 1
|
||||
|
||||
setlocal indentexpr=GetMarkdownIndent()
|
||||
setlocal nolisp
|
||||
setlocal autoindent
|
||||
|
||||
" Automatically insert bullets
|
||||
setlocal formatoptions+=r
|
||||
" Do not automatically insert bullets when auto-wrapping with text-width
|
||||
setlocal formatoptions-=c
|
||||
" Accept various markers as bullets
|
||||
setlocal comments=b:*,b:+,b:-
|
||||
|
||||
" Automatically continue blockquote on line break
|
||||
setlocal comments+=b:>
|
||||
|
||||
" Only define the function once
|
||||
if exists("*GetMarkdownIndent") | finish | endif
|
||||
|
||||
function! s:IsMkdCode(lnum)
|
||||
let name = synIDattr(synID(a:lnum, 1, 0), 'name')
|
||||
return (name =~ '^mkd\%(Code$\|Snippet\)' || name != '' && name !~ '^\%(mkd\|html\)')
|
||||
endfunction
|
||||
|
||||
function! s:IsLiStart(line)
|
||||
return a:line !~ '^ *\([*-]\)\%( *\1\)\{2}\%( \|\1\)*$' &&
|
||||
\ a:line =~ '^\s*[*+-] \+'
|
||||
endfunction
|
||||
|
||||
function! s:IsHeaderLine(line)
|
||||
return a:line =~ '^\s*#'
|
||||
endfunction
|
||||
|
||||
function! s:IsBlankLine(line)
|
||||
return a:line =~ '^$'
|
||||
endfunction
|
||||
|
||||
function! s:PrevNonBlank(lnum)
|
||||
let i = a:lnum
|
||||
while i > 1 && s:IsBlankLine(getline(i))
|
||||
let i -= 1
|
||||
endwhile
|
||||
return i
|
||||
endfunction
|
||||
|
||||
function GetMarkdownIndent()
|
||||
if v:lnum > 2 && s:IsBlankLine(getline(v:lnum - 1)) && s:IsBlankLine(getline(v:lnum - 2))
|
||||
return 0
|
||||
endif
|
||||
let list_ind = get(g:, "vim_markdown_new_list_item_indent", 4)
|
||||
" Find a non-blank line above the current line.
|
||||
let lnum = s:PrevNonBlank(v:lnum - 1)
|
||||
" At the start of the file use zero indent.
|
||||
if lnum == 0 | return 0 | endif
|
||||
let ind = indent(lnum)
|
||||
let line = getline(lnum) " Last line
|
||||
let cline = getline(v:lnum) " Current line
|
||||
if s:IsLiStart(cline)
|
||||
" Current line is the first line of a list item, do not change indent
|
||||
return indent(v:lnum)
|
||||
elseif s:IsHeaderLine(cline) && !s:IsMkdCode(v:lnum)
|
||||
" Current line is the header, do not indent
|
||||
return 0
|
||||
elseif s:IsLiStart(line)
|
||||
if s:IsMkdCode(lnum)
|
||||
return ind
|
||||
else
|
||||
" Last line is the first line of a list item, increase indent
|
||||
return ind + list_ind
|
||||
end
|
||||
else
|
||||
return ind
|
||||
endif
|
||||
endfunction
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
addon: markdown
|
||||
description: "Markdown syntax highlighting"
|
||||
files:
|
||||
- ftdetect/markdown.vim
|
||||
- ftplugin/markdown.vim
|
||||
- syntax/markdown.vim
|
||||
- after/ftplugin/markdown.vim
|
||||
- indent/markdown.vim
|
||||
- doc/vim-markdown.txt
|
||||
|
|
@ -1,175 +0,0 @@
|
|||
" Vim syntax file
|
||||
" Language: Markdown
|
||||
" Maintainer: Ben Williams <benw@plasticboy.com>
|
||||
" URL: http://plasticboy.com/markdown-vim-mode/
|
||||
" Remark: Uses HTML syntax file
|
||||
" TODO: Handle stuff contained within stuff (e.g. headings within blockquotes)
|
||||
|
||||
|
||||
" Read the HTML syntax to start with
|
||||
if version < 600
|
||||
so <sfile>:p:h/html.vim
|
||||
else
|
||||
runtime! syntax/html.vim
|
||||
|
||||
if exists('b:current_syntax')
|
||||
unlet b:current_syntax
|
||||
endif
|
||||
endif
|
||||
|
||||
if version < 600
|
||||
syntax clear
|
||||
elseif exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
" don't use standard HiLink, it will not work with included syntax files
|
||||
if version < 508
|
||||
command! -nargs=+ HtmlHiLink hi link <args>
|
||||
else
|
||||
command! -nargs=+ HtmlHiLink hi def link <args>
|
||||
endif
|
||||
|
||||
syn spell toplevel
|
||||
syn case ignore
|
||||
syn sync linebreaks=1
|
||||
|
||||
let s:conceal = ''
|
||||
let s:concealends = ''
|
||||
if has('conceal') && get(g:, 'vim_markdown_conceal', 1)
|
||||
let s:conceal = ' conceal'
|
||||
let s:concealends = ' concealends'
|
||||
endif
|
||||
|
||||
" additions to HTML groups
|
||||
if get(g:, 'vim_markdown_emphasis_multiline', 1)
|
||||
let s:oneline = ''
|
||||
else
|
||||
let s:oneline = ' oneline'
|
||||
endif
|
||||
syn region mkdItalic matchgroup=mkdItalic start="\%(\*\|_\)" end="\%(\*\|_\)"
|
||||
syn region mkdBold matchgroup=mkdBold start="\%(\*\*\|__\)" end="\%(\*\*\|__\)"
|
||||
syn region mkdBoldItalic matchgroup=mkdBoldItalic start="\%(\*\*\*\|___\)" end="\%(\*\*\*\|___\)"
|
||||
execute 'syn region htmlItalic matchgroup=mkdItalic start="\%(^\|\s\)\zs\*\ze[^\\\*\t ]\%(\%([^*]\|\\\*\|\n\)*[^\\\*\t ]\)\?\*\_W" end="[^\\\*\t ]\zs\*\ze\_W" keepend contains=@Spell' . s:oneline . s:concealends
|
||||
execute 'syn region htmlItalic matchgroup=mkdItalic start="\%(^\|\s\)\zs_\ze[^\\_\t ]" end="[^\\_\t ]\zs_\ze\_W" keepend contains=@Spell' . s:oneline . s:concealends
|
||||
execute 'syn region htmlBold matchgroup=mkdBold start="\%(^\|\s\)\zs\*\*\ze\S" end="\S\zs\*\*" keepend contains=@Spell' . s:oneline . s:concealends
|
||||
execute 'syn region htmlBold matchgroup=mkdBold start="\%(^\|\s\)\zs__\ze\S" end="\S\zs__" keepend contains=@Spell' . s:oneline . s:concealends
|
||||
execute 'syn region htmlBoldItalic matchgroup=mkdBoldItalic start="\%(^\|\s\)\zs\*\*\*\ze\S" end="\S\zs\*\*\*" keepend contains=@Spell' . s:oneline . s:concealends
|
||||
execute 'syn region htmlBoldItalic matchgroup=mkdBoldItalic start="\%(^\|\s\)\zs___\ze\S" end="\S\zs___" keepend contains=@Spell' . s:oneline . s:concealends
|
||||
|
||||
" [link](URL) | [link][id] | [link][] | 
|
||||
syn region mkdFootnotes matchgroup=mkdDelimiter start="\[^" end="\]"
|
||||
execute 'syn region mkdID matchgroup=mkdDelimiter start="\[" end="\]" contained oneline' . s:conceal
|
||||
execute 'syn region mkdURL matchgroup=mkdDelimiter start="(" end=")" contained oneline' . s:conceal
|
||||
execute 'syn region mkdLink matchgroup=mkdDelimiter start="\\\@<!!\?\[\ze[^]\n]*\n\?[^]\n]*\][[(]" end="\]" contains=@mkdNonListItem,@Spell nextgroup=mkdURL,mkdID skipwhite' . s:concealends
|
||||
|
||||
" Autolink without angle brackets.
|
||||
" mkd inline links: protocol optional user:pass@ sub/domain .com, .co.uk, etc optional port path/querystring/hash fragment
|
||||
" ------------ _____________________ ----------------------------- _________________________ ----------------- __
|
||||
syn match mkdInlineURL /https\?:\/\/\(\w\+\(:\w\+\)\?@\)\?\([A-Za-z0-9][-_0-9A-Za-z]*\.\)\{1,}\(\w\{2,}\.\?\)\{1,}\(:[0-9]\{1,5}\)\?\S*/
|
||||
|
||||
" Autolink with parenthesis.
|
||||
syn region mkdInlineURL matchgroup=mkdDelimiter start="(\(https\?:\/\/\(\w\+\(:\w\+\)\?@\)\?\([A-Za-z0-9][-_0-9A-Za-z]*\.\)\{1,}\(\w\{2,}\.\?\)\{1,}\(:[0-9]\{1,5}\)\?\S*)\)\@=" end=")"
|
||||
|
||||
" Autolink with angle brackets.
|
||||
syn region mkdInlineURL matchgroup=mkdDelimiter start="\\\@<!<\ze[a-z][a-z0-9,.-]\{1,22}:\/\/[^> ]*>" end=">"
|
||||
|
||||
" Link definitions: [id]: URL (Optional Title)
|
||||
syn region mkdLinkDef matchgroup=mkdDelimiter start="^ \{,3}\zs\[\^\@!" end="]:" oneline nextgroup=mkdLinkDefTarget skipwhite
|
||||
syn region mkdLinkDefTarget start="<\?\zs\S" excludenl end="\ze[>[:space:]\n]" contained nextgroup=mkdLinkTitle,mkdLinkDef skipwhite skipnl oneline
|
||||
syn region mkdLinkTitle matchgroup=mkdDelimiter start=+"+ end=+"+ contained
|
||||
syn region mkdLinkTitle matchgroup=mkdDelimiter start=+'+ end=+'+ contained
|
||||
syn region mkdLinkTitle matchgroup=mkdDelimiter start=+(+ end=+)+ contained
|
||||
|
||||
"HTML headings
|
||||
syn region htmlH1 start="^\s*#" end="$" contains=mkdLink,mkdInlineURL,@Spell
|
||||
syn region htmlH2 start="^\s*##" end="$" contains=mkdLink,mkdInlineURL,@Spell
|
||||
syn region htmlH3 start="^\s*###" end="$" contains=mkdLink,mkdInlineURL,@Spell
|
||||
syn region htmlH4 start="^\s*####" end="$" contains=mkdLink,mkdInlineURL,@Spell
|
||||
syn region htmlH5 start="^\s*#####" end="$" contains=mkdLink,mkdInlineURL,@Spell
|
||||
syn region htmlH6 start="^\s*######" end="$" contains=mkdLink,mkdInlineURL,@Spell
|
||||
syn match htmlH1 /^.\+\n=\+$/ contains=mkdLink,mkdInlineURL,@Spell
|
||||
syn match htmlH2 /^.\+\n-\+$/ contains=mkdLink,mkdInlineURL,@Spell
|
||||
|
||||
"define Markdown groups
|
||||
syn match mkdLineBreak / \+$/
|
||||
syn region mkdBlockquote start=/^\s*>/ end=/$/ contains=mkdLink,mkdInlineURL,mkdLineBreak,@Spell
|
||||
syn region mkdCode start=/\(\([^\\]\|^\)\\\)\@<!`/ end=/\(\([^\\]\|^\)\\\)\@<!`/
|
||||
syn region mkdCode start=/\s*``[^`]*/ end=/[^`]*``\s*/
|
||||
syn region mkdCode start=/^\s*\z(`\{3,}\)[^`]*$/ end=/^\s*\z1`*\s*$/
|
||||
syn region mkdCode start=/\s*\~\~[^\~]*/ end=/[^\~]*\~\~\s*/
|
||||
syn region mkdCode start=/^\s*\z(\~\{3,}\)\s*[0-9A-Za-z_+-]*\s*$/ end=/^\s*\z1\~*\s*$/
|
||||
syn region mkdCode start="<pre[^>]*\\\@<!>" end="</pre>"
|
||||
syn region mkdCode start="<code[^>]*\\\@<!>" end="</code>"
|
||||
syn region mkdFootnote start="\[^" end="\]"
|
||||
syn match mkdCode /^\s*\n\(\(\s\{8,}[^ ]\|\t\t\+[^\t]\).*\n\)\+/
|
||||
syn match mkdCode /\%^\(\(\s\{4,}[^ ]\|\t\+[^\t]\).*\n\)\+/
|
||||
syn match mkdCode /^\s*\n\(\(\s\{4,}[^ ]\|\t\+[^\t]\).*\n\)\+/ contained
|
||||
syn match mkdListItem /^\s*\%([-*+]\|\d\+\.\)\ze\s\+/ contained
|
||||
syn region mkdListItemLine start="^\s*\%([-*+]\|\d\+\.\)\s\+" end="$" oneline contains=@mkdNonListItem,mkdListItem,@Spell
|
||||
syn region mkdNonListItemBlock start="\(\%^\(\s*\([-*+]\|\d\+\.\)\s\+\)\@!\|\n\(\_^\_$\|\s\{4,}[^ ]\|\t+[^\t]\)\@!\)" end="^\(\s*\([-*+]\|\d\+\.\)\s\+\)\@=" contains=@mkdNonListItem,@Spell
|
||||
syn match mkdRule /^\s*\*\s\{0,1}\*\s\{0,1}\*$/
|
||||
syn match mkdRule /^\s*-\s\{0,1}-\s\{0,1}-$/
|
||||
syn match mkdRule /^\s*_\s\{0,1}_\s\{0,1}_$/
|
||||
syn match mkdRule /^\s*-\{3,}$/
|
||||
syn match mkdRule /^\s*\*\{3,5}$/
|
||||
|
||||
" YAML frontmatter
|
||||
if get(g:, 'vim_markdown_frontmatter', 0)
|
||||
syn include @yamlTop syntax/yaml.vim
|
||||
syn region Comment matchgroup=mkdDelimiter start="\%^---$" end="^---$" contains=@yamlTop keepend
|
||||
unlet! b:current_syntax
|
||||
endif
|
||||
|
||||
if get(g:, 'vim_markdown_toml_frontmatter', 0)
|
||||
try
|
||||
syn include @tomlTop syntax/toml.vim
|
||||
syn region Comment matchgroup=mkdDelimiter start="\%^+++$" end="^+++$" transparent contains=@tomlTop keepend
|
||||
unlet! b:current_syntax
|
||||
catch /E484/
|
||||
syn region Comment matchgroup=mkdDelimiter start="\%^+++$" end="^+++$"
|
||||
endtry
|
||||
endif
|
||||
|
||||
if get(g:, 'vim_markdown_json_frontmatter', 0)
|
||||
try
|
||||
syn include @jsonTop syntax/json.vim
|
||||
syn region Comment matchgroup=mkdDelimiter start="\%^{$" end="^}$" contains=@jsonTop keepend
|
||||
unlet! b:current_syntax
|
||||
catch /E484/
|
||||
syn region Comment matchgroup=mkdDelimiter start="\%^{$" end="^}$"
|
||||
endtry
|
||||
endif
|
||||
|
||||
if get(g:, 'vim_markdown_math', 0)
|
||||
syn include @tex syntax/tex.vim
|
||||
syn region mkdMath start="\\\@<!\$" end="\$" contains=@tex keepend
|
||||
syn region mkdMath start="\\\@<!\$\$" end="\$\$" contains=@tex keepend
|
||||
endif
|
||||
|
||||
syn cluster mkdNonListItem contains=@htmlTop,htmlItalic,htmlBold,htmlBoldItalic,mkdFootnotes,mkdInlineURL,mkdLink,mkdLinkDef,mkdLineBreak,mkdBlockquote,mkdCode,mkdRule,htmlH1,htmlH2,htmlH3,htmlH4,htmlH5,htmlH6,mkdMath
|
||||
|
||||
"highlighting for Markdown groups
|
||||
HtmlHiLink mkdString String
|
||||
HtmlHiLink mkdCode String
|
||||
HtmlHiLink mkdCodeStart String
|
||||
HtmlHiLink mkdCodeEnd String
|
||||
HtmlHiLink mkdFootnote Comment
|
||||
HtmlHiLink mkdBlockquote Comment
|
||||
HtmlHiLink mkdListItem Identifier
|
||||
HtmlHiLink mkdRule Identifier
|
||||
HtmlHiLink mkdLineBreak Visual
|
||||
HtmlHiLink mkdFootnotes htmlLink
|
||||
HtmlHiLink mkdLink htmlLink
|
||||
HtmlHiLink mkdURL htmlString
|
||||
HtmlHiLink mkdInlineURL htmlLink
|
||||
HtmlHiLink mkdID Identifier
|
||||
HtmlHiLink mkdLinkDef mkdID
|
||||
HtmlHiLink mkdLinkDefTarget mkdURL
|
||||
HtmlHiLink mkdLinkTitle htmlString
|
||||
HtmlHiLink mkdDelimiter Delimiter
|
||||
|
||||
let b:current_syntax = "mkd"
|
||||
|
||||
delcommand HtmlHiLink
|
||||
" vim: ts=8
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
You can run the tests using the Makefile from the top directory:
|
||||
|
||||
make test
|
||||
|
||||
To run them manually please refer to the instructions/commands in the Makefile.
|
||||
|
|
@ -1,178 +0,0 @@
|
|||
" Tests atx and setext folding, and :Toc.
|
||||
|
||||
Before:
|
||||
source ../after/ftplugin/markdown.vim
|
||||
|
||||
After:
|
||||
setlocal foldexpr=0
|
||||
setlocal foldmethod=manual
|
||||
|
||||
Given markdown;
|
||||
# chap 1
|
||||
|
||||
hello
|
||||
world
|
||||
|
||||
```bash
|
||||
# some bash scripting
|
||||
pwd
|
||||
|
||||
# this is another comment
|
||||
# other
|
||||
echo "foo"
|
||||
```
|
||||
|
||||
## chap 1.1
|
||||
|
||||
- dog
|
||||
- cat
|
||||
|
||||
~~~~bash
|
||||
mkdir foo
|
||||
# comment in ~
|
||||
~~~~
|
||||
|
||||
### chap 1.1.1
|
||||
|
||||
- dragons
|
||||
- fenixs
|
||||
|
||||
# chap 2
|
||||
|
||||
another
|
||||
|
||||
## chap 2.1
|
||||
|
||||
- uk
|
||||
- japan
|
||||
- china
|
||||
|
||||
|
||||
# chap 3
|
||||
|
||||
nothing here
|
||||
|
||||
chap 4
|
||||
======
|
||||
|
||||
setext are evil
|
||||
|
||||
chap 4.1
|
||||
--------
|
||||
|
||||
evil indeed
|
||||
|
||||
````bash
|
||||
# get system info
|
||||
uname -a
|
||||
````
|
||||
|
||||
Execute (fold level):
|
||||
AssertEqual foldlevel(1), 0, '# chap 1'
|
||||
AssertEqual foldlevel(3), 1, 'hello'
|
||||
AssertEqual foldlevel(6), 1, '```bash'
|
||||
AssertEqual foldlevel(7), 1, '# some bash scripting'
|
||||
AssertEqual foldlevel(15), 1, '## chap 1.1'
|
||||
AssertEqual foldlevel(21), 2, 'mkdir foo'
|
||||
AssertEqual foldlevel(22), 2, 'comment in ~'
|
||||
AssertEqual foldlevel(25), 2, '### chap 1.1.1'
|
||||
AssertEqual foldlevel(27), 3, '- dragons'
|
||||
AssertEqual foldlevel(30), 1, '# chap 2'
|
||||
AssertEqual foldlevel(32), 1, 'another'
|
||||
AssertEqual foldlevel(34), 1, '# chap 2.1'
|
||||
AssertEqual foldlevel(37), 2, '- japan'
|
||||
AssertEqual foldlevel(41), 1, '# chap 3'
|
||||
AssertEqual foldlevel(45), 1, 'chap 4\n======'
|
||||
AssertEqual foldlevel(48), 1, 'setext are evil'
|
||||
AssertEqual foldlevel(50), 2, 'chap 4.1\n------'
|
||||
|
||||
Execute (fold text result):
|
||||
AssertEqual foldtextresult(2), '+-- 28 lines: hello'
|
||||
AssertEqual foldtextresult(31), '+-- 10 lines: another'
|
||||
AssertEqual foldtextresult(42), '+-- 3 lines: nothing here'
|
||||
AssertEqual foldtextresult(45), '+-- 14 lines: chap 4'
|
||||
|
||||
Execute (fold level with setting):
|
||||
let g:vim_markdown_folding_level = 2
|
||||
source ../after/ftplugin/markdown.vim
|
||||
AssertEqual foldlevel(1), 0, '# chap 1'
|
||||
AssertEqual foldlevel(3), 1, 'hello'
|
||||
AssertEqual foldlevel(6), 1, '```bash'
|
||||
AssertEqual foldlevel(7), 1, '# some bash scripting'
|
||||
AssertEqual foldlevel(15), 0, '## chap 1.1'
|
||||
AssertEqual foldlevel(21), 2, 'mkdir foo'
|
||||
AssertEqual foldlevel(22), 2, 'comment in ~'
|
||||
AssertEqual foldlevel(25), 2, '### chap 1.1.1'
|
||||
AssertEqual foldlevel(27), 3, '- dragons'
|
||||
AssertEqual foldlevel(30), 0, '# chap 2'
|
||||
AssertEqual foldlevel(32), 1, 'another'
|
||||
AssertEqual foldlevel(34), 0, '# chap 2.1'
|
||||
AssertEqual foldlevel(37), 2, '- japan'
|
||||
AssertEqual foldlevel(41), 0, '# chap 3'
|
||||
AssertEqual foldlevel(45), 1, 'chap 4\n======'
|
||||
AssertEqual foldlevel(48), 1, 'setext are evil'
|
||||
AssertEqual foldlevel(50), 1, 'chap 4.1\n------'
|
||||
let g:vim_markdown_folding_level = 0
|
||||
|
||||
Execute (check TOC):
|
||||
:Toc
|
||||
:lclose
|
||||
let res = getloclist(0)
|
||||
let elem = res[0]
|
||||
AssertEqual elem.lnum, 1
|
||||
AssertEqual elem.text, '# chap 1'
|
||||
let elem = res[1]
|
||||
AssertEqual elem.lnum, 15
|
||||
AssertEqual elem.text, '## chap 1.1'
|
||||
let elem = res[2]
|
||||
AssertEqual elem.lnum, 25
|
||||
AssertEqual elem.text, '### chap 1.1.1'
|
||||
let elem = res[3]
|
||||
AssertEqual elem.lnum, 30
|
||||
AssertEqual elem.text, '# chap 2'
|
||||
let elem = res[4]
|
||||
AssertEqual elem.lnum, 34
|
||||
AssertEqual elem.text, '## chap 2.1'
|
||||
let elem = res[5]
|
||||
AssertEqual elem.lnum, 41
|
||||
AssertEqual elem.text, '# chap 3'
|
||||
let elem = res[6]
|
||||
AssertEqual elem.lnum, 45
|
||||
AssertEqual elem.text, 'chap 4'
|
||||
let elem = res[7]
|
||||
AssertEqual elem.lnum, 50
|
||||
AssertEqual elem.text, 'chap 4.1'
|
||||
|
||||
Given markdown;
|
||||
---
|
||||
layout: article
|
||||
title: A test of the heading folding when there is YAML frontmatter
|
||||
tags: markdown yaml vim-markdown
|
||||
---
|
||||
body
|
||||
|
||||
heading
|
||||
-------
|
||||
|
||||
Execute (fold level of yaml front matter):
|
||||
let g:vim_markdown_frontmatter = 1
|
||||
source ../after/ftplugin/markdown.vim
|
||||
AssertEqual foldlevel(1), 0, '---'
|
||||
AssertEqual foldlevel(2), 0, 'layout: article'
|
||||
AssertEqual foldlevel(4), 0, 'tags: markdown yaml vim-markdown'
|
||||
AssertEqual foldlevel(5), 0, '---'
|
||||
AssertEqual foldlevel(6), 0, 'body'
|
||||
AssertEqual foldlevel(8), 2, 'heading'
|
||||
AssertEqual foldlevel(9), 2, '-------'
|
||||
unlet g:vim_markdown_frontmatter
|
||||
|
||||
Execute (check Toc of yaml front matter):
|
||||
let g:vim_markdown_frontmatter = 1
|
||||
:Toc
|
||||
:lclose
|
||||
let res = getloclist(0)
|
||||
AssertEqual len(res), 1
|
||||
let elem = res[0]
|
||||
AssertEqual elem.lnum, 8
|
||||
AssertEqual elem.text, 'heading'
|
||||
unlet g:vim_markdown_frontmatter
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
Before:
|
||||
source ../after/ftplugin/markdown.vim
|
||||
|
||||
After:
|
||||
setlocal foldexpr=0
|
||||
setlocal foldmethod=manual
|
||||
|
||||
Given markdown;
|
||||
# Title
|
||||
|
||||
## Chapter 1
|
||||
|
||||
```
|
||||
This is code block
|
||||
# This is just a comment
|
||||
```
|
||||
|
||||
## Capter 2
|
||||
|
||||
foobar
|
||||
|
||||
Execute (fold level # in code block):
|
||||
AssertEqual foldlevel(1), 0, '# Title'
|
||||
AssertEqual foldlevel(3), 1, '## Chapter 1'
|
||||
AssertEqual foldlevel(7), 2, '# This is just a comment'
|
||||
AssertEqual foldlevel(8), 2, '```'
|
||||
AssertEqual foldlevel(10), 1, '## Chapter 2'
|
||||
AssertEqual foldlevel(12), 2, 'foobar'
|
||||
|
||||
Given markdown;
|
||||
Fold Level 1
|
||||
============
|
||||
Fold Level 2
|
||||
------------
|
||||
|
||||
Execute (fold level ==, --):
|
||||
AssertEqual foldlevel(2), 1, '=='
|
||||
AssertEqual foldlevel(4), 2, '--'
|
||||
|
||||
Given markdown;
|
||||
# H1
|
||||
|
||||
## H1.1
|
||||
|
||||
## H1.2
|
||||
|
||||
# H2
|
||||
|
||||
Execute (fold level # in last line):
|
||||
AssertEqual foldlevel(1), 0, '# H1'
|
||||
AssertEqual foldlevel(3), 1, '## H1.1'
|
||||
AssertEqual foldlevel(5), 1, '## H1.2'
|
||||
AssertEqual foldlevel(7), 0, '# H2'
|
||||
|
|
@ -1 +0,0 @@
|
|||
ge test
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
Before:
|
||||
let g:vim_markdown_new_list_item_indent = 2
|
||||
|
||||
After:
|
||||
unlet g:vim_markdown_new_list_item_indent
|
||||
|
||||
Given markdown;
|
||||
* item1
|
||||
|
||||
Do (new line from the first item of the list and add the second item):
|
||||
o* item2
|
||||
|
||||
Expect (insert 2 spaces to the head of second item):
|
||||
* item1
|
||||
* item2
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
1. Confirm indent with new line insert after list items
|
||||
|
||||
'\' is not list item.
|
||||
\ foo
|
||||
|
||||
If only space and three '*' or '-' character are in the line,
|
||||
this line means horizontal item.
|
||||
If current line is below horizontal item, it need not to indent.
|
||||
Following example is horizontal item.
|
||||
|
||||
---
|
||||
***
|
||||
- - -
|
||||
* * *
|
||||
|
||||
And list item must be specified space after [*-+].
|
||||
Following example is list item.
|
||||
|
||||
* foo
|
||||
- bar
|
||||
+ baz
|
||||
|
||||
But following example is not list item.
|
||||
*foo
|
||||
-bar
|
||||
+baz
|
||||
|
|
@ -1,73 +0,0 @@
|
|||
Given markdown;
|
||||
* item1
|
||||
|
||||
Do (insert enter at list end):
|
||||
A\<cr>item2
|
||||
|
||||
Expect (auto insert * and indent level is same):
|
||||
* item1
|
||||
* item2
|
||||
|
||||
Given markdown;
|
||||
|
||||
Execute:
|
||||
syntax off
|
||||
|
||||
Do (insert enter at list end with syntax off):
|
||||
i* item1\<cr>item2
|
||||
|
||||
Expect (auto insert * and indent level is same):
|
||||
* item1
|
||||
* item2
|
||||
|
||||
Execute:
|
||||
syntax on
|
||||
|
||||
Given markdown;
|
||||
```
|
||||
* item1
|
||||
|
||||
Do (insert after list items in code block):
|
||||
jotext
|
||||
|
||||
Expect (no autoindent in code block):
|
||||
```
|
||||
* item1
|
||||
text
|
||||
|
||||
Given markdown;
|
||||
* item1
|
||||
|
||||
a
|
||||
|
||||
Do (insert enter after list):
|
||||
jji\<cr>b
|
||||
|
||||
Expect (no autoindent outside list):
|
||||
* item1
|
||||
|
||||
|
||||
ba
|
||||
|
||||
Given markdown;
|
||||
- a
|
||||
|
||||
# b
|
||||
|
||||
Do (insert header after list):
|
||||
jjwi#
|
||||
|
||||
Expect (no indent header after list):
|
||||
- a
|
||||
|
||||
## b
|
||||
|
||||
Given markdown;
|
||||
* item1
|
||||
|
||||
Do (new line from the first item of the list and add the second item):
|
||||
o* item2
|
||||
|
||||
Expect (insert 4 spaces to the head of second item):
|
||||
* item1
|
||||
* item2
|
||||
|
|
@ -1,153 +0,0 @@
|
|||
Given markdown;
|
||||
a <http://b> c
|
||||
|
||||
Execute (gx autolink):
|
||||
let b:url = 'http://b'
|
||||
let b:line = getline(1)
|
||||
let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'Markdown_GetUrlForPosition')
|
||||
AssertEqual b:func(1, match(b:line, 'a') + 1), ''
|
||||
AssertEqual b:func(1, match(b:line, '<') + 1), b:url
|
||||
AssertEqual b:func(1, match(b:line, 'h') + 1), b:url
|
||||
AssertEqual b:func(1, match(b:line, '>') + 1), b:url
|
||||
AssertEqual b:func(1, match(b:line, 'c') + 1), ''
|
||||
|
||||
Given markdown;
|
||||
a http://b.bb c
|
||||
|
||||
Execute (gx implicit autolink):
|
||||
let b:url = 'http://b.bb'
|
||||
let b:line = getline(1)
|
||||
let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'Markdown_GetUrlForPosition')
|
||||
AssertEqual b:func(1, match(b:line, 'a') + 1), ''
|
||||
AssertEqual b:func(1, match(b:line, 'h') + 1), b:url
|
||||
AssertEqual b:func(1, match(b:line, 'c') + 1), ''
|
||||
|
||||
Given markdown;
|
||||
[a]: http://b "c"
|
||||
|
||||
Execute (gx link reference definition):
|
||||
let b:url = 'http://b'
|
||||
let b:line = getline(1)
|
||||
let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'Markdown_GetUrlForPosition')
|
||||
" TODO would be cool if all of the following gave the link.
|
||||
AssertEqual b:func(1, match(b:line, 'a') + 1), ''
|
||||
AssertEqual b:func(1, match(b:line, 'h') + 1), b:url
|
||||
AssertEqual b:func(1, match(b:line, 'c') + 1), ''
|
||||
|
||||
Given markdown;
|
||||
a [b](c) d
|
||||
|
||||
Execute (gx autolink):
|
||||
let b:url = 'c'
|
||||
let b:line = getline(1)
|
||||
let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'Markdown_GetUrlForPosition')
|
||||
AssertEqual b:func(1, match(b:line, 'a') + 1), ''
|
||||
AssertEqual b:func(1, match(b:line, '[') + 1), b:url
|
||||
AssertEqual b:func(1, match(b:line, 'b') + 1), b:url
|
||||
AssertEqual b:func(1, match(b:line, ']') + 1), b:url
|
||||
AssertEqual b:func(1, match(b:line, '(') + 1), b:url
|
||||
AssertEqual b:func(1, match(b:line, 'c') + 1), b:url
|
||||
AssertEqual b:func(1, match(b:line, ')') + 1), b:url
|
||||
AssertEqual b:func(1, match(b:line, 'd') + 1), ''
|
||||
|
||||
Given markdown;
|
||||
[ge_test.md](ge_test.md)
|
||||
|
||||
Execute (ge opens file):
|
||||
normal ge
|
||||
AssertEqual @%, 'ge_test.md'
|
||||
AssertEqual getline(1), 'ge test'
|
||||
|
||||
Given markdown;
|
||||
[ge_test](ge_test)
|
||||
|
||||
Execute (ge opens file without .md extensions):
|
||||
let g:vim_markdown_no_extensions_in_markdown = 1
|
||||
normal ge
|
||||
AssertEqual @%, 'ge_test.md'
|
||||
AssertEqual getline(1), 'ge test'
|
||||
unlet g:vim_markdown_no_extensions_in_markdown
|
||||
|
||||
Given markdown;
|
||||
[ge_test.md](ge_test.md)
|
||||
|
||||
Execute (ge does not write before opening file):
|
||||
normal ia
|
||||
normal l
|
||||
normal ge
|
||||
AssertEqual @%, 'ge_test.md'
|
||||
AssertEqual getline(1), 'ge test'
|
||||
|
||||
Given markdown;
|
||||
[ge_test.md](ge_test.md)
|
||||
|
||||
Execute (ge auto-write before opening file):
|
||||
let g:vim_markdown_autowrite = 1
|
||||
normal ia
|
||||
normal l
|
||||
AssertThrows normal ge
|
||||
AssertEqual g:vader_exception, 'Vim(write):E382: Cannot write, ''buftype'' option is set'
|
||||
unlet g:vim_markdown_autowrite
|
||||
|
||||
Given markdown;
|
||||
# a
|
||||
|
||||
b
|
||||
|
||||
# c
|
||||
|
||||
d
|
||||
|
||||
Execute (]] same level):
|
||||
AssertEqual line('.'), 1
|
||||
normal ]]
|
||||
AssertEqual line('.'), 5
|
||||
normal [[
|
||||
AssertEqual line('.'), 1
|
||||
|
||||
Given markdown;
|
||||
# a
|
||||
|
||||
b
|
||||
|
||||
## c
|
||||
|
||||
d
|
||||
|
||||
Execute (]] different levels level):
|
||||
AssertEqual line('.'), 1
|
||||
normal ]]
|
||||
AssertEqual line('.'), 5
|
||||
normal [[
|
||||
AssertEqual line('.'), 1
|
||||
|
||||
Given markdown;
|
||||
# a
|
||||
|
||||
b
|
||||
|
||||
## c
|
||||
|
||||
d
|
||||
|
||||
# e
|
||||
|
||||
f
|
||||
|
||||
Execute (][ different levels level):
|
||||
AssertEqual line('.'), 1
|
||||
normal ][
|
||||
AssertEqual line('.'), 9
|
||||
normal []
|
||||
AssertEqual line('.'), 1
|
||||
|
||||
Given markdown;
|
||||
# a
|
||||
|
||||
b
|
||||
|
||||
Execute (]c):
|
||||
normal! 3G
|
||||
AssertEqual line('.'), 3
|
||||
normal ]c
|
||||
AssertEqual line('.'), 1
|
||||
|
|
@ -1,85 +0,0 @@
|
|||
Before:
|
||||
let g:vim_markdown_folding_style_pythonic = 1
|
||||
source ../after/ftplugin/markdown.vim
|
||||
|
||||
After:
|
||||
setlocal foldexpr=0
|
||||
setlocal foldmethod=manual
|
||||
|
||||
Given markdown;
|
||||
# Title
|
||||
|
||||
## Chapter 1
|
||||
|
||||
```
|
||||
This is code block
|
||||
# This is just a comment
|
||||
```
|
||||
|
||||
## Chapter 2
|
||||
|
||||
foobar
|
||||
|
||||
Execute (fold level # in code block):
|
||||
AssertEqual foldlevel(1), 0, '# Title'
|
||||
AssertEqual foldlevel(3), 1, '## Chapter 1'
|
||||
AssertEqual foldlevel(7), 1, '# This is just a comment'
|
||||
AssertEqual foldlevel(8), 1, '```'
|
||||
AssertEqual foldlevel(10), 1, '## Chapter 2'
|
||||
AssertEqual foldlevel(12), 1, 'foobar'
|
||||
|
||||
Execute (fold text of chapters):
|
||||
let b:width = winwidth(0)
|
||||
let b:hyphen = repeat('-', b:width - 18 > 2 ? b:width - 18 : b:width - 9 > 0 ? 3 : 2)
|
||||
AssertEqual foldtextresult(3), strpart('## Chapter 1', 0, b:width - 9) . ' ' . b:hyphen . ' 6'
|
||||
AssertEqual foldtextresult(10), strpart('## Chapter 2', 0, b:width - 9) . ' ' . b:hyphen . ' 2'
|
||||
|
||||
Given markdown;
|
||||
Fold text 1
|
||||
===========
|
||||
Fold text 2
|
||||
-----------
|
||||
|
||||
Execute (fold level ==, --):
|
||||
AssertEqual foldlevel(2), 0, '=='
|
||||
AssertEqual foldlevel(4), 1, '--'
|
||||
|
||||
Execute (fold text of ==, --):
|
||||
let b:width = winwidth(0)
|
||||
let b:hyphen = repeat('-', b:width - 17 > 2 ? b:width - 17 : b:width - 9 > 0 ? 3 : 2)
|
||||
AssertEqual foldtextresult(3), strpart('Fold text 2', 0, b:width - 9) . ' ' . b:hyphen . ' 1'
|
||||
|
||||
Given markdown;
|
||||
Headline
|
||||
|
||||
foobar
|
||||
|
||||
# Title
|
||||
|
||||
Execute (fold any preamble):
|
||||
AssertEqual foldlevel(1), 1, 'Headline'
|
||||
AssertEqual foldlevel(3), 1, 'foobar'
|
||||
AssertEqual foldlevel(5), 0, '# Title'
|
||||
|
||||
Given markdown;
|
||||
---
|
||||
layout: article
|
||||
title: A test of the heading folding when there is YAML frontmatter
|
||||
tags: markdown yaml vim-markdown
|
||||
---
|
||||
body
|
||||
|
||||
heading
|
||||
-------
|
||||
|
||||
Execute (fold level of yaml front matter):
|
||||
let g:vim_markdown_frontmatter = 1
|
||||
source ../after/ftplugin/markdown.vim
|
||||
AssertEqual foldlevel(1), 1, '---'
|
||||
AssertEqual foldlevel(2), 1, 'layout: article'
|
||||
AssertEqual foldlevel(4), 1, 'tags: markdown yaml vim-markdown'
|
||||
AssertEqual foldlevel(5), 1, '---'
|
||||
AssertEqual foldlevel(6), 1, 'body'
|
||||
AssertEqual foldlevel(8), 1, 'heading'
|
||||
AssertEqual foldlevel(9), 1, '-------'
|
||||
unlet g:vim_markdown_frontmatter
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Exit on error.
|
||||
set -e
|
||||
|
||||
cd "$( dirname "${BASH_SOURCE[0]}" )"
|
||||
|
||||
for dep in ../build/tabular ../build/vim-toml ../build/vim-json ../build/vader.vim; do
|
||||
if [[ ! -d $dep ]]; then
|
||||
echo "Missing dependency: $dep"
|
||||
echo "You may just want to use 'make test'."
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
vim -Nu vimrc -c 'Vader! *' > /dev/null
|
||||
|
|
@ -1,158 +0,0 @@
|
|||
Before:
|
||||
let g:vim_markdown_emphasis_multiline = 0
|
||||
syn off | syn on
|
||||
|
||||
After:
|
||||
let g:vim_markdown_emphasis_multiline = 1
|
||||
syn off | syn on
|
||||
|
||||
Given markdown;
|
||||
a **b** c
|
||||
|
||||
Execute (bold):
|
||||
AssertNotEqual SyntaxOf('a'), 'htmlBold'
|
||||
AssertEqual SyntaxOf('b'), 'htmlBold'
|
||||
AssertNotEqual SyntaxOf('c'), 'htmlBold'
|
||||
|
||||
Given markdown;
|
||||
a __b__ c
|
||||
|
||||
Execute (bold):
|
||||
AssertNotEqual SyntaxOf('a'), 'htmlBold'
|
||||
AssertEqual SyntaxOf('b'), 'htmlBold'
|
||||
AssertNotEqual SyntaxOf('c'), 'htmlBold'
|
||||
|
||||
Given markdown;
|
||||
a *b* c
|
||||
|
||||
Execute (italic):
|
||||
AssertNotEqual SyntaxOf('a'), 'htmlItalic'
|
||||
AssertEqual SyntaxOf('b'), 'htmlItalic'
|
||||
AssertNotEqual SyntaxOf('c'), 'htmlItalic'
|
||||
|
||||
Given markdown;
|
||||
a _b_ c
|
||||
|
||||
Execute (italic):
|
||||
AssertNotEqual SyntaxOf('a'), 'htmlItalic'
|
||||
AssertEqual SyntaxOf('b'), 'htmlItalic'
|
||||
AssertNotEqual SyntaxOf('c'), 'htmlItalic'
|
||||
|
||||
Given markdown;
|
||||
_a_b_
|
||||
|
||||
Execute (italic text has underscores):
|
||||
AssertEqual SyntaxOf('a'), 'htmlItalic'
|
||||
AssertEqual SyntaxOf('b'), 'htmlItalic'
|
||||
|
||||
Given markdown;
|
||||
a \*b\* c
|
||||
|
||||
Execute (not italic with escaped asterisks):
|
||||
AssertNotEqual SyntaxOf('a'), 'htmlItalic'
|
||||
AssertNotEqual SyntaxOf('b'), 'htmlItalic'
|
||||
AssertNotEqual SyntaxOf('c'), 'htmlItalic'
|
||||
|
||||
Given markdown;
|
||||
a \_b\_ c
|
||||
|
||||
Execute (not italic with escaped underscores):
|
||||
AssertNotEqual SyntaxOf('a'), 'htmlItalic'
|
||||
AssertNotEqual SyntaxOf('b'), 'htmlItalic'
|
||||
AssertNotEqual SyntaxOf('c'), 'htmlItalic'
|
||||
|
||||
Given markdown;
|
||||
a _b\_c_ d
|
||||
|
||||
Execute (italic with escaped underscores):
|
||||
AssertNotEqual SyntaxOf('a'), 'htmlItalic'
|
||||
AssertEqual SyntaxOf('b'), 'htmlItalic'
|
||||
AssertEqual SyntaxOf('c'), 'htmlItalic'
|
||||
AssertNotEqual SyntaxOf('d'), 'htmlItalic'
|
||||
|
||||
Given markdown;
|
||||
a_b_c
|
||||
|
||||
Execute (not italic underscores within text):
|
||||
AssertNotEqual SyntaxOf('a'), 'htmlItalic'
|
||||
AssertNotEqual SyntaxOf('b'), 'htmlItalic'
|
||||
AssertNotEqual SyntaxOf('c'), 'htmlItalic'
|
||||
|
||||
Given markdown;
|
||||
a *b\*c* d
|
||||
|
||||
Execute (italic with escaped asterisks):
|
||||
AssertNotEqual SyntaxOf('a'), 'htmlItalic'
|
||||
AssertEqual SyntaxOf('b'), 'htmlItalic'
|
||||
AssertEqual SyntaxOf('c'), 'htmlItalic'
|
||||
AssertNotEqual SyntaxOf('d'), 'htmlItalic'
|
||||
|
||||
Given markdown;
|
||||
a __b\_\_c__ d
|
||||
|
||||
Execute (bold with escaped underscores):
|
||||
AssertNotEqual SyntaxOf('a'), 'htmlBold'
|
||||
AssertEqual SyntaxOf('b'), 'htmlBold'
|
||||
AssertEqual SyntaxOf('c'), 'htmlBold'
|
||||
AssertNotEqual SyntaxOf('d'), 'htmlBold'
|
||||
|
||||
Given markdown;
|
||||
_a b
|
||||
c_ d
|
||||
|
||||
Execute (italic with underscores in multiple lines):
|
||||
AssertNotEqual SyntaxOf('a'), 'htmlItalic'
|
||||
AssertNotEqual SyntaxOf('b'), 'htmlItalic'
|
||||
AssertNotEqual SyntaxOf('c'), 'htmlItalic'
|
||||
AssertNotEqual SyntaxOf('d'), 'htmlItalic'
|
||||
|
||||
Given markdown;
|
||||
__a b
|
||||
c__ d
|
||||
|
||||
Execute (bold with underscores in multiple lines):
|
||||
AssertNotEqual SyntaxOf('a'), 'htmlBold'
|
||||
AssertNotEqual SyntaxOf('b'), 'htmlBold'
|
||||
AssertNotEqual SyntaxOf('c'), 'htmlBold'
|
||||
AssertNotEqual SyntaxOf('d'), 'htmlBold'
|
||||
|
||||
Given markdown;
|
||||
___a b
|
||||
c___ d
|
||||
|
||||
Execute (bold italic with underscores in multiple lines):
|
||||
AssertNotEqual SyntaxOf('a'), 'htmlBoldItalic'
|
||||
AssertNotEqual SyntaxOf('b'), 'htmlBoldItalic'
|
||||
AssertNotEqual SyntaxOf('c'), 'htmlBoldItalic'
|
||||
AssertNotEqual SyntaxOf('d'), 'htmlBoldItalic'
|
||||
|
||||
Given markdown;
|
||||
*a b
|
||||
c* d
|
||||
|
||||
Execute (italic with asterisks in multiple lines):
|
||||
AssertNotEqual SyntaxOf('a'), 'htmlItalic'
|
||||
AssertNotEqual SyntaxOf('b'), 'htmlItalic'
|
||||
AssertNotEqual SyntaxOf('c'), 'htmlItalic'
|
||||
AssertNotEqual SyntaxOf('d'), 'htmlItalic'
|
||||
|
||||
Given markdown;
|
||||
**a b
|
||||
c** d
|
||||
|
||||
Execute (bold with asterisks in multiple lines):
|
||||
AssertNotEqual SyntaxOf('a'), 'htmlBold'
|
||||
AssertNotEqual SyntaxOf('b'), 'htmlBold'
|
||||
AssertNotEqual SyntaxOf('c'), 'htmlBold'
|
||||
AssertNotEqual SyntaxOf('d'), 'htmlBold'
|
||||
|
||||
Given markdown;
|
||||
***a b
|
||||
c*** d
|
||||
|
||||
Execute (bold italic with asterisks in multiple lines):
|
||||
AssertNotEqual SyntaxOf('a'), 'htmlBoldItalic'
|
||||
AssertNotEqual SyntaxOf('b'), 'htmlBoldItalic'
|
||||
AssertNotEqual SyntaxOf('c'), 'htmlBoldItalic'
|
||||
AssertNotEqual SyntaxOf('d'), 'htmlBoldItalic'
|
||||
|
||||
|
|
@ -1,89 +0,0 @@
|
|||
# Fenced code living in an indented environment is correctly highlighted
|
||||
|
||||
1. run this command to do this:
|
||||
|
||||
```
|
||||
some command
|
||||
```
|
||||
|
||||
2. Subsequent list items are correctly highlighted.
|
||||
|
||||
Fenced code block with language:
|
||||
|
||||
```ruby
|
||||
def f
|
||||
0
|
||||
end
|
||||
```
|
||||
|
||||
# Links
|
||||
|
||||
[a](b "c")
|
||||
|
||||
[a]()
|
||||
|
||||
[good spell](a)
|
||||
|
||||
[badd spell](a)
|
||||
|
||||
[a](b "c")
|
||||
|
||||
[a]( b
|
||||
"c" )
|
||||
|
||||
a (`a`) b. Fix: <https://github.com/plasticboy/vim-markdown/issues/113>
|
||||
|
||||
Escaped:
|
||||
|
||||
\[a](b)
|
||||
|
||||
[a\]b](c)
|
||||
|
||||
## Known failures
|
||||
|
||||
Escape does not work:
|
||||
|
||||
[a\](b)
|
||||
|
||||
Should not be links because of whitespace:
|
||||
|
||||
[a] (b)
|
||||
|
||||
[a](a
|
||||
b)
|
||||
|
||||
[a](a b)
|
||||
|
||||
# Reference links
|
||||
|
||||
Single links:
|
||||
|
||||
[a][b]
|
||||
|
||||
[good spell][a]
|
||||
|
||||
[badd spell][a]
|
||||
|
||||
[a][]
|
||||
|
||||
[a] []
|
||||
|
||||
[a][b] c [d][e]
|
||||
|
||||
Reference link followed by inline link:
|
||||
|
||||
[a] [b](c)
|
||||
|
||||
## Known failures
|
||||
|
||||
Should be shortcut reference links:
|
||||
|
||||
[a]
|
||||
|
||||
[a] b [c]
|
||||
|
||||
Should be a single link:
|
||||
|
||||
[a] [b]
|
||||
|
||||
[a] b [c](d)
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,44 +0,0 @@
|
|||
Before:
|
||||
let &gdefault = 1
|
||||
|
||||
After:
|
||||
let &gdefault = 0
|
||||
|
||||
Given markdown;
|
||||
| normal |no space| 2 spaces ||
|
||||
| - |-| --- ||
|
||||
| normal |no space| 2 spaces ||
|
||||
|
||||
Execute (format unformatted table):
|
||||
TableFormat
|
||||
|
||||
Expect (table is formatted):
|
||||
| normal | no space | 2 spaces | |
|
||||
|--------|----------|----------|--|
|
||||
| normal | no space | 2 spaces | |
|
||||
|
||||
Given markdown;
|
||||
| a | b |
|
||||
|---|---|
|
||||
| c | d |
|
||||
|
||||
Execute (format well formatted table):
|
||||
TableFormat
|
||||
|
||||
Expect (table is not modified):
|
||||
| a | b |
|
||||
|---|---|
|
||||
| c | d |
|
||||
|
||||
Given markdown;
|
||||
| left |right| center ||
|
||||
| :- | --: |:---:|:|
|
||||
| left |right| center ||
|
||||
|
||||
Execute (format table with colons):
|
||||
TableFormat
|
||||
|
||||
Expect (preserve colons to align text):
|
||||
| left | right | center | |
|
||||
|:-----|------:|:------:|:--|
|
||||
| left | right | center | |
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
" Tests toc window auto-fit to longest header, but without exceeding half screen.
|
||||
|
||||
Given markdown;
|
||||
# chap 1
|
||||
|
||||
# chap 2
|
||||
|
||||
# chap 3
|
||||
|
||||
# chap 4
|
||||
|
||||
# chap 5
|
||||
|
||||
# chap 6
|
||||
|
||||
# chap 7
|
||||
|
||||
# chap 8
|
||||
|
||||
# chap 9
|
||||
|
||||
# chap 10
|
||||
|
||||
# chap 11
|
||||
|
||||
# chap 12
|
||||
|
||||
## chap 12.1
|
||||
|
||||
### chap 12.1.1
|
||||
|
||||
#### chap 12.1.1.1
|
||||
|
||||
##### chap 12.1.1.1.1
|
||||
|
||||
###### chap 12.1.1.1.1.1
|
||||
|
||||
# chap 13
|
||||
|
||||
Execute (toc window autofit width):
|
||||
set number
|
||||
let g:vim_markdown_toc_autofit = 1
|
||||
let line = '###### chap 12.1.1.1.1.1'
|
||||
AssertEqual getline('33'), line
|
||||
:Toc
|
||||
let real_width = winwidth(0)
|
||||
:lclose
|
||||
let expected_width = len(line) + 2*5 + 1 + 3 - 7
|
||||
AssertEqual real_width, expected_width
|
||||
set nonumber
|
||||
" 2 spaces * 5 additional header levels + 1 space for first header +
|
||||
" 3 spaces for line numbers - 7 chars ('###### ') that don't show up on the TOC
|
||||
|
||||
|
|
@ -1,185 +0,0 @@
|
|||
Given markdown;
|
||||
# a
|
||||
|
||||
Execute (Toc does not set nomodifiable on other files):
|
||||
" Sanity check.
|
||||
Assert &modifiable
|
||||
|
||||
:Toc
|
||||
:lclose
|
||||
:edit a
|
||||
|
||||
Assert &modifiable
|
||||
|
||||
Given markdown;
|
||||
header 1
|
||||
========
|
||||
|
||||
test
|
||||
|
||||
header 2
|
||||
--------
|
||||
|
||||
test
|
||||
|
||||
### header 3
|
||||
|
||||
test
|
||||
|
||||
Execute (Toc setex headers):
|
||||
:Toc
|
||||
|
||||
Expect (setex headers):
|
||||
header 1
|
||||
header 2
|
||||
header 3
|
||||
|
||||
Given markdown;
|
||||
# header 1
|
||||
|
||||
test
|
||||
|
||||
## header 2
|
||||
|
||||
test
|
||||
|
||||
### header 3
|
||||
|
||||
test
|
||||
|
||||
Execute (Toc atx headers):
|
||||
:Toc
|
||||
|
||||
Expect (atx headers):
|
||||
header 1
|
||||
header 2
|
||||
header 3
|
||||
|
||||
Given markdown;
|
||||
ATX tests.
|
||||
|
||||
# h1 space
|
||||
|
||||
#h1 nospace
|
||||
|
||||
# h1 2 spaces
|
||||
|
||||
# h1 trailing hash #
|
||||
|
||||
## h2 space
|
||||
|
||||
##h2 nospace
|
||||
|
||||
## h2 trailing hash ##
|
||||
|
||||
### h3 space
|
||||
|
||||
###h3 nospace
|
||||
|
||||
### h3 trailing hash ###
|
||||
|
||||
#### h4
|
||||
|
||||
##### h5
|
||||
|
||||
###### h6
|
||||
|
||||
---
|
||||
|
||||
Relative positions.
|
||||
|
||||
# h1 before h2
|
||||
|
||||
## h2 between h1s
|
||||
|
||||
# h1 after h2
|
||||
|
||||
---
|
||||
|
||||
Setex tests.
|
||||
|
||||
setex h1
|
||||
========
|
||||
|
||||
setex h2
|
||||
--------
|
||||
|
||||
setex h1 single punctuation
|
||||
=
|
||||
|
||||
setex h1 punctuation longer than header
|
||||
================================
|
||||
|
||||
Prevent list vs Setex confusion:
|
||||
|
||||
- not Setex
|
||||
- because list
|
||||
|
||||
---
|
||||
|
||||
Mixed tests.
|
||||
|
||||
setex h1 before atx
|
||||
===================
|
||||
|
||||
## atx h2
|
||||
|
||||
### atx h3
|
||||
|
||||
# atx h1
|
||||
|
||||
setex h2
|
||||
------------------
|
||||
|
||||
### atx h3 2
|
||||
|
||||
Execute (Toc multiple headers):
|
||||
:Toc
|
||||
|
||||
Expect (multiple headers):
|
||||
h1 space
|
||||
h1 nospace
|
||||
h1 2 spaces
|
||||
h1 trailing hash
|
||||
h2 space
|
||||
h2 nospace
|
||||
h2 trailing hash
|
||||
h3 space
|
||||
h3 nospace
|
||||
h3 trailing hash
|
||||
h4
|
||||
h5
|
||||
h6
|
||||
h1 before h2
|
||||
h2 between h1s
|
||||
h1 after h2
|
||||
setex h1
|
||||
setex h2
|
||||
setex h1 single punctuation
|
||||
setex h1 punctuation longer than header
|
||||
setex h1 before atx
|
||||
atx h2
|
||||
atx h3
|
||||
atx h1
|
||||
setex h2
|
||||
atx h3 2
|
||||
|
||||
Execute:
|
||||
:lclose
|
||||
|
||||
Given markdown;
|
||||
# header 1
|
||||
|
||||
## header 2
|
||||
|
||||
### header 3
|
||||
|
||||
Execute (Toc cursor on the current header):
|
||||
normal! 4G
|
||||
:Toc
|
||||
AssertEqual line('.'), 2
|
||||
:lclose
|
||||
normal! G
|
||||
:Toc
|
||||
AssertEqual line('.'), 3
|
||||
:lclose
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
set nocompatible
|
||||
set rtp+=../
|
||||
set rtp+=../build/tabular/
|
||||
set rtp+=../build/vim-toml/
|
||||
set rtp+=../build/vim-json/
|
||||
set rtp+=../build/vader.vim/
|
||||
let $LANG='en_US'
|
||||
filetype on
|
||||
filetype plugin on
|
||||
filetype indent on
|
||||
syntax on
|
||||
|
||||
function! Markdown_GetScriptID(fname) abort
|
||||
let a:snlist = ''
|
||||
redir => a:snlist
|
||||
silent! scriptnames
|
||||
redir END
|
||||
let a:mx = '^\s*\(\d\+\):\s*\(.*\)$'
|
||||
for a:line in split(a:snlist, "\n")
|
||||
if stridx(substitute(a:line, '\\', '/', 'g'), a:fname) >= 0
|
||||
return substitute(a:line, a:mx, '\1', '')
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
function! Markdown_GetFunc(fname, funcname) abort
|
||||
return function('<SNR>' . Markdown_GetScriptID(a:fname) . '_' . a:funcname)
|
||||
endfunction
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
virtualenv.vim
|
||||
==============
|
||||
|
||||
When using :python or :!python, it will only have access to the environment outside of any virtualenvs. If you're working with packages that are only installed in a virtualenv, they will not be available to Vim.
|
||||
|
||||
*__Until now!__* The virtualenv.vim plugin will modify python's sys.path and the $PATH environment variable so that anything done with :python or :!python will behave like you would expect for the chosen virtualenv.
|
||||
|
||||
If compiled with python support, Vim will have a :python command, but this will be tied to whatever version is the default on your system. If this is the version of python that you use, or you're using a Linux distribution with a sensible package manager (like Debian or Ubuntu), you likely will not have to do anything more than install the plugin. If not, then you will likely have to recompile vim with your version of python.
|
||||
|
||||
Usage examples
|
||||
==============
|
||||
|
||||
Deactivate the current virtualenv
|
||||
|
||||
:VirtualEnvDeactivate
|
||||
|
||||
List all virtualenvs
|
||||
|
||||
:VirtualEnvList
|
||||
|
||||
Activate the 'spam' virtualenv
|
||||
|
||||
:VirtualEnvActivate spam
|
||||
|
||||
If you're unsure which one to activate, you could always use tab completion
|
||||
|
||||
:VirtualEnvActivate <tab>
|
||||
|
||||

|
||||
|
||||
If the shell that started vim had $VIRTUAL\_ENV set, omitting the name will
|
||||
imply usage of this value.
|
||||
|
||||
If you're a virtualenvwrapper user and have $PROJECT\_HOME set, omitting the
|
||||
name will try to guess which virtualenv to activate based on the current
|
||||
filename.
|
||||
|
||||
You can even show the current virtualenv in the statusline with the included function
|
||||
|
||||

|
||||
|
||||
Or, for those with a properly configured Powerline (the virtualenv segment is not enabled by default), your virtualenv indicator will toggle on or off accordingly.
|
||||
|
||||

|
||||
|
||||
For more detailed help
|
||||
|
||||
:help virtualenv
|
||||
|
||||
Binary file not shown.
Binary file not shown.
|
|
@ -1,57 +0,0 @@
|
|||
import vim, os, sys
|
||||
|
||||
prev_syspath = None
|
||||
|
||||
activate_content = """
|
||||
try:
|
||||
__file__
|
||||
except NameError:
|
||||
raise AssertionError(
|
||||
"You must run this like execfile('path/to/activate_this.py', dict(__file__='path/to/activate_this.py'))")
|
||||
import sys
|
||||
import os
|
||||
|
||||
old_os_path = os.environ['PATH']
|
||||
os.environ['PATH'] = os.path.dirname(os.path.abspath(__file__)) + os.pathsep + old_os_path
|
||||
base = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
if sys.platform == 'win32':
|
||||
site_packages = os.path.join(base, 'Lib', 'site-packages')
|
||||
else:
|
||||
version = '%s.%s' % (sys.version_info.major, sys.version_info.minor)
|
||||
site_packages = os.path.join(base, 'lib', 'python%s' % version, 'site-packages')
|
||||
prev_sys_path = list(sys.path)
|
||||
import site
|
||||
site.addsitedir(site_packages)
|
||||
sys.real_prefix = sys.prefix
|
||||
sys.prefix = base
|
||||
# Move the added items to the front of the path:
|
||||
new_sys_path = []
|
||||
for item in list(sys.path):
|
||||
if item not in prev_sys_path:
|
||||
new_sys_path.append(item)
|
||||
sys.path.remove(item)
|
||||
sys.path[:0] = new_sys_path
|
||||
"""
|
||||
|
||||
def activate(env):
|
||||
global prev_syspath
|
||||
prev_syspath = list(sys.path)
|
||||
activate = os.path.join(env, (sys.platform == 'win32') and 'Scripts' or 'bin', 'activate_this.py')
|
||||
try:
|
||||
fo = open(activate)
|
||||
f = fo.read()
|
||||
fo.close()
|
||||
except:
|
||||
f = activate_content
|
||||
|
||||
code = compile(f, activate, 'exec')
|
||||
exec(code, dict(__file__=activate))
|
||||
|
||||
|
||||
def deactivate():
|
||||
global prev_syspath
|
||||
try:
|
||||
sys.path[:] = prev_syspath
|
||||
prev_syspath = None
|
||||
except:
|
||||
pass
|
||||
Binary file not shown.
|
|
@ -1,110 +0,0 @@
|
|||
if has('python3')
|
||||
python3 import sys, vim
|
||||
python3 if vim.eval('expand("<sfile>:p:h")') not in sys.path: sys.path.append(vim.eval('expand("<sfile>:p:h")'))
|
||||
python3 import pyvenv
|
||||
endif
|
||||
if has('python')
|
||||
python import sys, vim
|
||||
python if vim.eval('expand("<sfile>:p:h")') not in sys.path: sys.path.append(vim.eval('expand("<sfile>:p:h")'))
|
||||
python import pyvenv
|
||||
endif
|
||||
|
||||
function! virtualenv#activate(...)
|
||||
let name = a:0 > 0 ? a:1 : ''
|
||||
let silent = a:0 > 1 ? a:2 : 0
|
||||
let env_dir = ''
|
||||
if len(name) == 0 "Figure out the name based on current file
|
||||
if isdirectory($VIRTUAL_ENV)
|
||||
let name = fnamemodify($VIRTUAL_ENV, ':t')
|
||||
let env_dir = $VIRTUAL_ENV
|
||||
elseif isdirectory($PROJECT_HOME)
|
||||
let fn = expand('%:p')
|
||||
let pat = '^'.$PROJECT_HOME.'/'
|
||||
if fn =~ pat
|
||||
let name = fnamemodify(substitute(fn, pat, '', ''), ':h')
|
||||
if name != '.' "No project directory
|
||||
let env_dir = g:virtualenv_directory.'/'.name
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
else
|
||||
let env_dir = g:virtualenv_directory.'/'.name
|
||||
endif
|
||||
|
||||
"Couldn't figure it out, so DIE
|
||||
if !isdirectory(env_dir)
|
||||
if !silent
|
||||
echoerr "No virtualenv could be auto-detected and activated."
|
||||
endif
|
||||
return
|
||||
endif
|
||||
|
||||
let bin = env_dir.(has('win32')? '/Scripts': '/bin')
|
||||
call virtualenv#deactivate()
|
||||
|
||||
let s:prev_path = $PATH
|
||||
|
||||
if has('python')
|
||||
python pyvenv.activate(vim.eval('l:env_dir'))
|
||||
endif
|
||||
if has('python3')
|
||||
python3 pyvenv.activate(vim.eval('l:env_dir'))
|
||||
endif
|
||||
|
||||
let g:virtualenv_name = name
|
||||
let $VIRTUAL_ENV = env_dir
|
||||
|
||||
if exists("*airline#extensions#virtualenv#update")
|
||||
call airline#extensions#virtualenv#update()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! virtualenv#deactivate()
|
||||
if has('python')
|
||||
python pyvenv.deactivate()
|
||||
endif
|
||||
if has('python3')
|
||||
python3 pyvenv.deactivate()
|
||||
endif
|
||||
|
||||
unlet! g:virtualenv_name
|
||||
|
||||
let $VIRTUAL_ENV = '' " can't delete parent variables
|
||||
|
||||
if exists('s:prev_path')
|
||||
let $PATH = s:prev_path
|
||||
endif
|
||||
|
||||
if exists("*airline#extensions#virtualenv#update")
|
||||
call airline#extensions#virtualenv#update()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! virtualenv#list()
|
||||
for name in virtualenv#names('')
|
||||
echo name
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! virtualenv#statusline()
|
||||
if exists('g:virtualenv_name')
|
||||
return substitute(g:virtualenv_stl_format, '\C%n', g:virtualenv_name, 'g')
|
||||
else
|
||||
return ''
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! virtualenv#names(prefix)
|
||||
let venvs = []
|
||||
for dir in split(glob(g:virtualenv_directory.'/'.a:prefix.'*'), '\n')
|
||||
if !isdirectory(dir)
|
||||
continue
|
||||
endif
|
||||
let fn = dir.(has('win32')? '/Scripts': '/bin').'/activate'
|
||||
if !filereadable(fn)
|
||||
continue
|
||||
endif
|
||||
call add(venvs, fnamemodify(dir, ':t'))
|
||||
endfor
|
||||
return venvs
|
||||
endfunction
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
:VirtualEnvActivate virtualenv.txt /*:VirtualEnvActivate*
|
||||
:VirtualEnvDeactivate virtualenv.txt /*:VirtualEnvDeactivate*
|
||||
:VirtualEnvList virtualenv.txt /*:VirtualEnvList*
|
||||
g:virtualenv_auto_activate virtualenv.txt /*g:virtualenv_auto_activate*
|
||||
g:virtualenv_directory virtualenv.txt /*g:virtualenv_directory*
|
||||
g:virtualenv_loaded virtualenv.txt /*g:virtualenv_loaded*
|
||||
g:virtualenv_stl_format virtualenv.txt /*g:virtualenv_stl_format*
|
||||
virtualenv virtualenv.txt /*virtualenv*
|
||||
virtualenv-author virtualenv.txt /*virtualenv-author*
|
||||
virtualenv-commands virtualenv.txt /*virtualenv-commands*
|
||||
virtualenv-configuration virtualenv.txt /*virtualenv-configuration*
|
||||
virtualenv.txt virtualenv.txt /*virtualenv.txt*
|
||||
virtualenv.vim virtualenv.txt /*virtualenv.vim*
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
*virtualenv.txt* Activate a python virtualenv within Vim
|
||||
|
||||
Author: Jeremy Cantrell <jmcantrell@gmail.com> *virtualenv-author*
|
||||
License: Same terms as Vim itself (see |license|)
|
||||
|
||||
INTRODUCTION *virtualenv* *virtualenv.vim*
|
||||
|
||||
The virtualenv plugin allows you to activate and deactivate a virtualenv
|
||||
within a live Vim session.
|
||||
|
||||
COMMANDS *virtualenv-commands*
|
||||
|
||||
:VirtualEnvList *:VirtualEnvList*
|
||||
List all available virtualenvs.
|
||||
|
||||
:VirtualEnvDeactivate *:VirtualEnvDeactivate*
|
||||
Deactivate the current virtualenv.
|
||||
|
||||
:VirtualEnvActivate [name] *:VirtualEnvActivate*
|
||||
Activate a virtualenv. The name of the virtualenv can be completed with
|
||||
<tab> at the command line.
|
||||
|
||||
If name is not specified, and you have $PROJECT_HOME set, the name will be
|
||||
guessed based on the current filename.
|
||||
|
||||
CONFIGURATION *virtualenv-configuration*
|
||||
|
||||
g:virtualenv_loaded *g:virtualenv_loaded*
|
||||
If set in your |vimrc|, virtualenv.vim is not loaded.
|
||||
|
||||
g:virtualenv_directory *g:virtualenv_directory*
|
||||
The directory that contains the virtualenvs. If you're a virtualenvwrapper
|
||||
user and you have $WORKON_HOME set, it will default to this. Otherwise it
|
||||
will default to ~/.virtualenvs.
|
||||
|
||||
g:virtualenv_auto_activate *g:virtualenv_auto_activate*
|
||||
If set, an attempt will be made to detect any active virtualenv, and
|
||||
activate it.
|
||||
|
||||
Example: >
|
||||
let g:virtualenv_directory = '/path/to/virtualenvs'
|
||||
<
|
||||
g:virtualenv_stl_format *g:virtualenv_stl_format*
|
||||
Format string for the statusline function.
|
||||
|
||||
Example: >
|
||||
let g:virtualenv_stl_format = '[%n]'
|
||||
<
|
||||
To use the statusline flag, this must appear in your |'statusline'| setting: >
|
||||
%{virtualenv#statusline()}
|
||||
<
|
||||
The content is derived from the |g:virtualenv_stl_format| variable.
|
||||
|
||||
Powerline users can see their statuslines too. After configuring powerline
|
||||
according to its documentation to support a virtualenv segment, Powerline will
|
||||
read the value of $VIRTUAL_ENV and display it.
|
||||
|
||||
vim:tw=78:et:ft=help:norl:
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
if exists("g:virtualenv_loaded")
|
||||
finish
|
||||
endif
|
||||
|
||||
let g:virtualenv_loaded = 1
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
if !has('python3') && !has('python')
|
||||
finish
|
||||
endif
|
||||
|
||||
if !exists("g:virtualenv_auto_activate")
|
||||
let g:virtualenv_auto_activate = 1
|
||||
endif
|
||||
|
||||
if !exists("g:virtualenv_stl_format")
|
||||
let g:virtualenv_stl_format = '%n'
|
||||
endif
|
||||
|
||||
if !exists("g:virtualenv_directory")
|
||||
if isdirectory($WORKON_HOME)
|
||||
let g:virtualenv_directory = $WORKON_HOME
|
||||
else
|
||||
let g:virtualenv_directory = '~/.virtualenvs'
|
||||
endif
|
||||
endif
|
||||
|
||||
let g:virtualenv_directory = expand(g:virtualenv_directory)
|
||||
|
||||
command! -bar VirtualEnvList :call virtualenv#list()
|
||||
command! -bar VirtualEnvDeactivate :call virtualenv#deactivate()
|
||||
command! -bar -nargs=? -complete=customlist,s:CompleteVirtualEnv VirtualEnvActivate :call virtualenv#activate(<q-args>)
|
||||
|
||||
function! s:Error(message)
|
||||
echohl ErrorMsg | echo a:message | echohl None
|
||||
endfunction
|
||||
|
||||
function! s:CompleteVirtualEnv(arg_lead, cmd_line, cursor_pos)
|
||||
return virtualenv#names(a:arg_lead)
|
||||
endfunction
|
||||
|
||||
" DEPRECATED: Leaving in for compatibility
|
||||
function! VirtualEnvStatusline()
|
||||
return virtualenv#statusline()
|
||||
endfunction
|
||||
|
||||
if g:virtualenv_auto_activate == 1
|
||||
call virtualenv#activate('', 1)
|
||||
endif
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
|
|
@ -162,7 +162,7 @@ fun! s:f.python_find_func( default )
|
|||
endif
|
||||
|
||||
return matchstr( getline( defIndent[0] ), '\Vdef\s\+\zs\w\+' )
|
||||
|
||||
|
||||
endfunction
|
||||
|
||||
" ================================= Snippets ===================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue