From df0d46a56e47b88c1148d2fb6c327f7bef17852f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=98=A5=E5=A5=95?= <373852389@qq.com> Date: Sun, 9 Oct 2016 11:22:35 +0800 Subject: [PATCH 1/7] add the merge_upstream bash script --- merge_upstream.sh | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 merge_upstream.sh diff --git a/merge_upstream.sh b/merge_upstream.sh new file mode 100644 index 00000000..7c3b4390 --- /dev/null +++ b/merge_upstream.sh @@ -0,0 +1,2 @@ +#!/bin/bash +git fetch upstream && git merge upstream/master From 1458911e037b0db120c5077adbf250e2635f8229 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=98=A5=E5=A5=95?= <373852389@qq.com> Date: Sun, 9 Oct 2016 11:24:22 +0800 Subject: [PATCH 2/7] add my personal configuration --- .gitignore | 1 - merge_upstream.sh | 0 my_configs.vim | 13 +++++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) mode change 100644 => 100755 merge_upstream.sh create mode 100644 my_configs.vim diff --git a/.gitignore b/.gitignore index 56dee29f..c40b6f34 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,5 @@ temp_dirs/yankring_history_v2.txt sources_forked/yankring/doc/tags sources_non_forked/tlib/doc/tags sources_non_forked/ctrlp.vim/doc/tags* -my_configs.vim tags .DS_Store diff --git a/merge_upstream.sh b/merge_upstream.sh old mode 100644 new mode 100755 diff --git a/my_configs.vim b/my_configs.vim new file mode 100644 index 00000000..2da1725d --- /dev/null +++ b/my_configs.vim @@ -0,0 +1,13 @@ +" personal themes +set background=dark +colorscheme solarized + +"tabspace = 2 +set ts = 2 +set sw = 2 + +" reload vim environment +nmap r :source $MYVIMRC + + + From f20982b27579b9c36d1521ceb00da76bac073641 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=98=A5=E5=A5=95?= <373852389@qq.com> Date: Sun, 9 Oct 2016 14:10:08 +0800 Subject: [PATCH 3/7] add supertab plugin and vim-system-copy plugin --- sources_forked/supertab/.gitignore | 4 + sources_forked/supertab/Makefile | 17 + sources_forked/supertab/README.rst | 172 +++ sources_forked/supertab/doc/supertab.txt | 473 +++++++ sources_forked/supertab/ftplugin/html.vim | 61 + sources_forked/supertab/ftplugin/xml.vim | 45 + sources_forked/supertab/plugin/supertab.vim | 1144 +++++++++++++++++ sources_forked/vim-system-copy/README.md | 66 + .../vim-system-copy/plugin/system_copy.vim | 111 ++ 9 files changed, 2093 insertions(+) create mode 100755 sources_forked/supertab/.gitignore create mode 100755 sources_forked/supertab/Makefile create mode 100755 sources_forked/supertab/README.rst create mode 100755 sources_forked/supertab/doc/supertab.txt create mode 100755 sources_forked/supertab/ftplugin/html.vim create mode 100755 sources_forked/supertab/ftplugin/xml.vim create mode 100755 sources_forked/supertab/plugin/supertab.vim create mode 100644 sources_forked/vim-system-copy/README.md create mode 100644 sources_forked/vim-system-copy/plugin/system_copy.vim diff --git a/sources_forked/supertab/.gitignore b/sources_forked/supertab/.gitignore new file mode 100755 index 00000000..8d4efa7a --- /dev/null +++ b/sources_forked/supertab/.gitignore @@ -0,0 +1,4 @@ +*.swp +*.vmb +doc/tags +/README.html diff --git a/sources_forked/supertab/Makefile b/sources_forked/supertab/Makefile new file mode 100755 index 00000000..7a3c371a --- /dev/null +++ b/sources_forked/supertab/Makefile @@ -0,0 +1,17 @@ +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' diff --git a/sources_forked/supertab/README.rst b/sources_forked/supertab/README.rst new file mode 100755 index 00000000..89bafdb5 --- /dev/null +++ b/sources_forked/supertab/README.rst @@ -0,0 +1,172 @@ +.. 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 for all your insert +completion needs (:help ins-completion). + +Features +-------- + +- Configurable to suit you needs: + + - Default completion type to use. + - Prevent 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 ? 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 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 + `_ and `vundle + `_. 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 `_: + + 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 + `_ installed, or something similar, + which will issue a `` when no snippet is found. Supertab use to map to + ``, 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 ``: + + :: + + :verbose imap + + To resolve the issue you can either: + + #. Install my `fork `_ or + #. Upgrade to a more recent snipmate fork, like `garbas/vim-snipmate + `_ + + See `#74 `_ for additional + details. + +- **Why does 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 = "" + + or if your default completion type is currently `context` then you can use + this instead: + + :: + + let g:SuperTabContextDefaultCompletionType = "" + + Now on to the reasoning behind this. When using `` or `` to start + insert completion, both populate the completion popup with the same list of + words in the same order, the only difference is that `` 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 `` 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 `` and ``, only the first + entry to highlight differs + #. so that the behavior of `` mode is consistent, always moving up the + list and + #. when starting `` mode you don't have to switch over to + using `` to get the next nearest entry, just continue to hit ``. + + So, with supertab I wanted to preserve the same behavior. If `` is your + default completion method (supertab defaults to this being the case), then + `` will start it and additional uses of `` will move up the list + instead of down so that you don't have to suddenly switch to using `` + to get the next nearest result. + + Why is `` 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 `` naturally + provides. diff --git a/sources_forked/supertab/doc/supertab.txt b/sources_forked/supertab/doc/supertab.txt new file mode 100755 index 00000000..941a9a05 --- /dev/null +++ b/sources_forked/supertab/doc/supertab.txt @@ -0,0 +1,473 @@ +*supertab.txt* + +Author: Eric Van Dewoestine + Original concept and versions up to 0.32 written by + Gergely Kontra + +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 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 or (shift+tab) while in +insert mode, with at least one non whitespace character before the cursor, to +start the completion and then or again to cycle forwards or +backwards through the available completions. + +Example ('|' denotes the cursor location): + +bar +baz +b| Hitting 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: "") + +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 = "" +< + +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 # will use filename completion + myvar.t # will use user completion if completefunc set, + # or omni completion if omnifunc set. + myvar-> # 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("") +< + + +Secondary default completion type *supertab-contextdefault* + *g:SuperTabContextDefaultCompletionType* + +g:SuperTabContextDefaultCompletionType (default value: "") + +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 # will use filename completion + myvar.t # will use user completion if completefunc set, or + # omni completion if omnifunc set. + myvar-> # 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 ' + let g:SuperTabCompletionContexts = ['s:ContextText', 's:ContextDiscover'] + let g:SuperTabContextTextOmniPrecedence = ['&omnifunc', '&completefunc'] + let g:SuperTabContextDiscoverDiscovery = + \ ["&completefunc:", "&omnifunc:"] +< + + 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. "\\"). + +> + function MyTagContext() + if filereadable(expand('%:p:h') . '/tags') + return "\\" + 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 "\\" + 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 . 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: '') +g:SuperTabMappingBackward (default value: '') + +These two variables allow you to set the keys used to kick off the current +completion. By default this is and . To change to something +like and , you can add the following to your |vimrc|. + +> + let g:SuperTabMappingForward = '' + let g:SuperTabMappingBackward = '' +> + +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 = '' + let g:SuperTabMappingBackward = '' +< + + +Inserting true tabs *supertab-mappingtabliteral* + *g:SuperTabMappingTabLiteral* + +g:SuperTabMappingTabLiteral (default value: '') + +Sets the key mapping used to insert a literal tab where supertab would +otherwise attempt to kick off insert completion. The default is '' +(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 with + (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. 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 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 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, will +kick off completion and pre-select the first entry in the popup menu, allowing +you to simply hit to use it. + + +Mapping to end completion *supertab-crmapping* + *g:SuperTabCrMapping* + +g:SuperTabCrMapping (default value: 0) + +When enabled, will cancel completion mode preserving the current text. + +Compatibility with other plugins: + - endwise: compatible + - delimitMate: not compatible (disabled if the delimitMate mapping is + detected.) + +Note: if you have an insert expression mapping with a in it or an insert +abbreviation containing a , then supertab will not create a 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 +(, , , 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, , completion: + +> + autocmd FileType * + \ if &omnifunc != '' | + \ call SuperTabChain(&omnifunc, "") | + \ 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, "") | + \ 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: diff --git a/sources_forked/supertab/ftplugin/html.vim b/sources_forked/supertab/ftplugin/html.vim new file mode 100755 index 00000000..4bd2385d --- /dev/null +++ b/sources_forked/supertab/ftplugin/html.vim @@ -0,0 +1,61 @@ +" Author: Eric Van Dewoestine +" +" 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 = [' +" +" 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 = [' +" Original concept and versions up to 0.32 written by +" Gergely Kontra +" Version: 2.1 +" GetLatestVimScripts: 1643 1 :AutoInstall: supertab.vim +" +" Description: {{{ +" Use your tab key to do all your completion in insert mode! +" You can cycle forward and backward with the and keys +" Note: you must press once to be able to cycle back +" +" http://www.vim.org/scripts/script.php?script_id=1643 +" }}} +" +" License: {{{ +" Copyright (c) 2002 - 2015 +" 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. +" }}} +" +" Testing Info: {{{ +" Running vim + supertab with the absolute bare minimum settings: +" $ vim -u NONE -U NONE -c "set nocp | runtime plugin/supertab.vim" +" }}} + +if v:version < 700 + finish +endif + +if exists('complType') " Integration with other completion functions. + finish +endif + +if exists("loaded_supertab") + finish +endif +let loaded_supertab = 1 + +let s:save_cpo=&cpo +set cpo&vim + +" Global Variables {{{ + + if !exists("g:SuperTabDefaultCompletionType") + let g:SuperTabDefaultCompletionType = "" + endif + + if !exists("g:SuperTabContextDefaultCompletionType") + let g:SuperTabContextDefaultCompletionType = "" + endif + + if !exists("g:SuperTabContextTextMemberPatterns") + let g:SuperTabContextTextMemberPatterns = ['\.', '>\?::', '->'] + endif + + if !exists("g:SuperTabCompletionContexts") + let g:SuperTabCompletionContexts = ['s:ContextText'] + endif + + if !exists("g:SuperTabRetainCompletionDuration") + let g:SuperTabRetainCompletionDuration = 'insert' + endif + + if !exists("g:SuperTabNoCompleteBefore") + " retain backwards compatability + if exists("g:SuperTabMidWordCompletion") && !g:SuperTabMidWordCompletion + let g:SuperTabNoCompleteBefore = ['\k'] + else + let g:SuperTabNoCompleteBefore = [] + endif + endif + + if !exists("g:SuperTabNoCompleteAfter") + " retain backwards compatability + if exists("g:SuperTabLeadingSpaceCompletion") && g:SuperTabLeadingSpaceCompletion + let g:SuperTabNoCompleteAfter = [] + else + let g:SuperTabNoCompleteAfter = ['^', '\s'] + endif + endif + + if !exists("g:SuperTabMappingForward") + let g:SuperTabMappingForward = '' + endif + if !exists("g:SuperTabMappingBackward") + let g:SuperTabMappingBackward = '' + endif + + if !exists("g:SuperTabMappingTabLiteral") + let g:SuperTabMappingTabLiteral = '' + endif + + if !exists("g:SuperTabLongestEnhanced") + let g:SuperTabLongestEnhanced = 0 + endif + + if !exists("g:SuperTabLongestHighlight") + let g:SuperTabLongestHighlight = 0 + endif + + if !exists("g:SuperTabCrMapping") + let g:SuperTabCrMapping = 0 + endif + + if !exists("g:SuperTabClosePreviewOnPopupClose") + let g:SuperTabClosePreviewOnPopupClose = 0 + endif + + if !exists("g:SuperTabUndoBreak") + let g:SuperTabUndoBreak = 0 + endif + + if !exists("g:SuperTabCompleteCase") + let g:SuperTabCompleteCase = 'inherit' + endif + +" }}} + +" Script Variables {{{ + + " construct the help text. + let s:tabHelp = + \ "Hit or CTRL-] on the completion type you wish to switch to.\n" . + \ "Use :help ins-completion for more information.\n" . + \ "\n" . + \ "|| - Keywords in 'complete' searching down.\n" . + \ "|| - Keywords in 'complete' searching up (SuperTab default).\n" . + \ "|| - Whole lines.\n" . + \ "|| - Keywords in current file.\n" . + \ "|| - Keywords in 'dictionary'.\n" . + \ "|| - Keywords in 'thesaurus', thesaurus-style.\n" . + \ "|| - Keywords in the current and included files.\n" . + \ "|| - Tags.\n" . + \ "|| - File names.\n" . + \ "|| - Definitions or macros.\n" . + \ "|| - Vim command-line.\n" . + \ "|| - User defined completion.\n" . + \ "|| - Omni completion.\n" . + \ "|s| - Spelling suggestions." + + " set the available completion types and modes. + let s:types = + \ "\\\\\\\\" . + \ "\\\\\\\\\s" + let s:modes = '/^E/^Y/^L/^N/^K/^T/^I/^]/^F/^D/^V/^P/^U/^O/s' + let s:types = s:types . "np" + let s:modes = s:modes . '/n/p' + +" }}} + +function! SuperTabSetDefaultCompletionType(type) " {{{ + " Globally available function that users can use to set the default + " completion type for the current buffer, like in an ftplugin. + + " don't allow overriding what SuperTabChain has set, otherwise chaining may + " not work. + if exists('b:SuperTabChain') + return + endif + + " init hack for workaround. + let b:complCommandLine = 0 + + let b:SuperTabDefaultCompletionType = a:type + + " set the current completion type to the default + call SuperTabSetCompletionType(b:SuperTabDefaultCompletionType) +endfunction " }}} + +function! SuperTabSetCompletionType(type) " {{{ + " Globally available function that users can use to create mappings to quickly + " switch completion modes. Useful when a user wants to restore the default or + " switch to another mode without having to kick off a completion of that type + " or use SuperTabHelp. Note, this function only changes the current + " completion type, not the default, meaning that the default will still be + " restored once the configured retension duration has been met (see + " g:SuperTabRetainCompletionDuration). To change the default for the current + " buffer, use SuperTabDefaultCompletionType(type) instead. Example mapping to + " restore SuperTab default: + " nmap :call SetSuperTabCompletionType("") + + " don't allow overriding what SuperTabChain has set, otherwise chaining may + " not work. + if exists('b:SuperTabChain') + return + endif + + call s:InitBuffer() + exec "let b:complType = \"" . escape(a:type, '<') . "\"" +endfunction " }}} + +function! SuperTabAlternateCompletion(type) " {{{ + " Function which can be mapped to a key to kick off an alternate completion + " other than the default. For instance, if you have 'context' as the default + " and want to map ctrl+space to issue keyword completion. + " Note: due to the way vim expands ctrl characters in mappings, you cannot + " create the alternate mapping like so: + " imap =SuperTabAlternateCompletion("") + " instead, you have to use \ to prevent vim from expanding the key + " when creating the mapping. + " gvim: + " imap =SuperTabAlternateCompletion("\c-p>") + " console: + " imap =SuperTabAlternateCompletion("\c-p>") + + call SuperTabSetCompletionType(a:type) + " end any current completion before attempting to start the new one. + " use feedkeys to prevent possible remapping of from causing issues. + "call feedkeys("\", 'n') + " ^ since we can't detect completion mode vs regular insert mode, we force + " vim into keyword completion mode and end that mode to prevent the regular + " insert behavior of from occurring. + call feedkeys("\\\", 'n') + call feedkeys(b:complType, 'n') + return '' +endfunction " }}} + +function! SuperTabLongestHighlight(dir) " {{{ + " When longest highlight is enabled, this function is used to do the actual + " selection of the completion popup entry. + + if !s:CompletionMode() + return '' + endif + return a:dir == -1 ? "\" : "\" +endfunction " }}} + +function! s:Init() " {{{ + " Setup mechanism to restore original completion type upon leaving insert + " mode if configured to do so + if g:SuperTabRetainCompletionDuration == 'insert' + augroup supertab_retain + autocmd! + autocmd InsertLeave * call s:SetDefaultCompletionType() + augroup END + endif +endfunction " }}} + +function! s:InitBuffer() " {{{ + if exists('b:SuperTabNoCompleteBefore') + return + endif + + let b:complReset = 0 + let b:complTypeManual = !exists('b:complTypeManual') ? '' : b:complTypeManual + let b:complTypeContext = '' + + " init hack for workaround. + let b:complCommandLine = 0 + + if !exists('b:SuperTabNoCompleteBefore') + let b:SuperTabNoCompleteBefore = g:SuperTabNoCompleteBefore + endif + if !exists('b:SuperTabNoCompleteAfter') + let b:SuperTabNoCompleteAfter = g:SuperTabNoCompleteAfter + endif + + if !exists('b:SuperTabDefaultCompletionType') + let b:SuperTabDefaultCompletionType = g:SuperTabDefaultCompletionType + endif + + if !exists('b:SuperTabContextDefaultCompletionType') + let b:SuperTabContextDefaultCompletionType = + \ g:SuperTabContextDefaultCompletionType + endif + + " set the current completion type to the default + call SuperTabSetCompletionType(b:SuperTabDefaultCompletionType) + + " hack to programatically revert a change to snipmate that breaks supertab + " but which the new maintainers don't care about: + " http://github.com/garbas/vim-snipmate/issues/37 + let snipmate = maparg('', 'i') + if snipmate =~ 'u' && g:SuperTabMappingForward =~? '' + let snipmate = substitute(snipmate, 'u', '', '') + iunmap + exec "inoremap " . snipmate + endif +endfunction " }}} + +function! s:ManualCompletionEnter() " {{{ + " Handles manual entrance into completion mode. + + if &smd + echo '' | echohl ModeMsg | echo '-- ^X++ mode (' . s:modes . ')' | echohl None + endif + let complType = nr2char(getchar()) + if stridx(s:types, complType) != -1 + if !exists('b:supertab_close_preview') + let b:supertab_close_preview = !s:IsPreviewOpen() + endif + + if stridx("\\", complType) != -1 " no memory, just scroll... + return "\" . complType + elseif stridx('np', complType) != -1 + let complType = nr2char(char2nr(complType) - 96) + else + let complType = "\" . complType + endif + + let b:complTypeManual = complType + + if index(['insert', 'session'], g:SuperTabRetainCompletionDuration) != -1 + let b:complType = complType + endif + + " Hack to workaround bug when invoking command line completion via = + if complType == "\\" + return s:CommandLineCompletion() + endif + + call s:InitBuffer() + + " optionally enable enhanced longest completion + if g:SuperTabLongestEnhanced && &completeopt =~ 'longest' + call s:EnableLongestEnhancement() + " handle backspacing which triggers g:SuperTabNoCompleteAfter match + elseif s:IsNoCompleteAfterReset() + call s:EnableNoCompleteAfterReset() + endif + + if g:SuperTabLongestHighlight && + \ &completeopt =~ 'longest' && + \ &completeopt =~ 'menu' && + \ !s:CompletionMode() + let dir = (complType == "\\") ? -1 : 1 + call feedkeys("\=SuperTabLongestHighlight(" . dir . ")\", 'n') + endif + + call s:StartCompletionMode() + return complType + endif + + echohl "Unknown mode" + return complType +endfunction " }}} + +function! s:SetCompletionType() " {{{ + " Sets the completion type based on what the user has chosen from the help + " buffer. + + let chosen = substitute(getline('.'), '.*|\(.*\)|.*', '\1', '') + if chosen != getline('.') + let winnr = b:winnr + close + exec winnr . 'winc w' + call SuperTabSetCompletionType(chosen) + endif +endfunction " }}} + +function! s:SetDefaultCompletionType() " {{{ + if exists('b:SuperTabDefaultCompletionType') && + \ (!exists('b:complCommandLine') || !b:complCommandLine) + call SuperTabSetCompletionType(b:SuperTabDefaultCompletionType) + endif +endfunction " }}} + +function! SuperTab(command) " {{{ + " Used to perform proper cycle navigation as the user requests the next or + " previous entry in a completion list, and determines whether or not to simply + " retain the normal usage of based on the cursor position. + + if exists('b:SuperTabDisabled') && b:SuperTabDisabled + if exists('s:Tab') + return s:Tab() + endif + return ( + \ g:SuperTabMappingForward ==? '' || + \ g:SuperTabMappingBackward ==? '' + \ ) ? "\" : '' + endif + + call s:InitBuffer() + + if s:WillComplete() + if !exists('b:supertab_close_preview') + let b:supertab_close_preview = !s:IsPreviewOpen() + endif + + " optionally enable enhanced longest completion + if g:SuperTabLongestEnhanced && &completeopt =~ 'longest' + call s:EnableLongestEnhancement() + " handle backspacing which triggers g:SuperTabNoCompleteAfter match + elseif s:IsNoCompleteAfterReset() + call s:EnableNoCompleteAfterReset() + endif + + if !s:CompletionMode() + let b:complTypeManual = '' + endif + + " exception: if in mode, then should move up the list, and + " down the list. + if a:command == 'p' && !b:complReset && + \ (b:complType == "\" || + \ (b:complType == 'context' && + \ b:complTypeManual == '' && + \ b:complTypeContext == "\")) + return "\" + + elseif a:command == 'p' && !b:complReset && + \ (b:complType == "\" || + \ (b:complType == 'context' && + \ b:complTypeManual == '' && + \ b:complTypeContext == "\")) + return "\" + + " already in completion mode and not resetting for longest enhancement, so + " just scroll to next/previous + elseif s:CompletionMode() && !b:complReset + let type = b:complType == 'context' ? b:complTypeContext : b:complType + if a:command == 'n' + return type == "\" || type == "\\" ? "\" : "\" + endif + return type == "\" || type == "\\" ? "\" : "\" + endif + + " handle 'context' completion. + if b:complType == 'context' + let complType = s:ContextCompletion() + if complType == '' + exec "let complType = \"" . + \ escape(b:SuperTabContextDefaultCompletionType, '<') . "\"" + endif + let b:complTypeContext = complType + + " Hack to workaround bug when invoking command line completion via = + elseif b:complType == "\\" + let complType = s:CommandLineCompletion() + else + let complType = b:complType + endif + + " switch / completion in mode + if a:command == 'p' + if complType == "\\" + let complType = "\\" + elseif complType == "\\" + let complType = "\\" + endif + endif + + " highlight first result if longest enabled + if g:SuperTabLongestHighlight && + \ &completeopt =~ 'longest' && + \ &completeopt =~ 'menu' && + \ (!s:CompletionMode() || b:complReset) + let dir = (complType == "\") ? -1 : 1 + call feedkeys("\=SuperTabLongestHighlight(" . dir . ")\", 'n') + endif + + if b:complReset + let b:complReset = 0 + " not an accurate condition for everyone, but better than sending + " at the wrong time. + if s:CompletionMode() + return "\" . complType + endif + endif + + if g:SuperTabUndoBreak && !s:CompletionMode() + call s:StartCompletionMode() + return "\u" . complType + endif + + if g:SuperTabCompleteCase == 'ignore' || + \ g:SuperTabCompleteCase == 'match' + if exists('##CompleteDone') + let ignorecase = g:SuperTabCompleteCase == 'ignore' ? 1 : 0 + if &ignorecase != ignorecase + let b:supertab_ignorecase_save = &ignorecase + let &ignorecase = ignorecase + augroup supertab_ignorecase + autocmd CompleteDone + \ let &ignorecase = b:supertab_ignorecase_save | + \ unlet b:supertab_ignorecase_save | + \ autocmd! supertab_ignorecase + augroup END + endif + endif + endif + + call s:StartCompletionMode() + return complType + endif + + if (a:command == 'n' && g:SuperTabMappingForward ==? '') || + \ (a:command == 'p' && g:SuperTabMappingBackward ==? '') + + " trigger our func ref to the smart tabs plugin if present. + if exists('s:Tab') + return s:Tab() + endif + + return "\" + endif + + if (a:command == 'n' && g:SuperTabMappingForward ==? '') || + \ (a:command == 'p' && g:SuperTabMappingBackward ==? '') + " support triggering mappings users might have. + if exists('s:ShiftTab') + if type(s:ShiftTab) == 2 + return s:ShiftTab() + else + call feedkeys(s:ShiftTab, 'n') + endif + endif + endif + + return '' +endfunction " }}} + +function! s:SuperTabHelp() " {{{ + " Opens a help window where the user can choose a completion type to enter. + + let winnr = winnr() + if bufwinnr("SuperTabHelp") == -1 + keepalt botright split SuperTabHelp + + setlocal noswapfile + setlocal buftype=nowrite + setlocal bufhidden=wipe + + silent put =s:tabHelp + call cursor(1, 1) + silent 1,delete _ + call cursor(4, 1) + exec "resize " . line('$') + + syntax match Special "|.\{-}|" + + setlocal readonly + setlocal nomodifiable + + nmap :call SetCompletionType() + nmap :call SetCompletionType() + else + exec bufwinnr("SuperTabHelp") . "winc w" + endif + let b:winnr = winnr +endfunction " }}} + +function! s:CompletionMode() " {{{ + return pumvisible() || exists('b:supertab_completion_mode') +endfunction " }}} + +function! s:StartCompletionMode() " {{{ + if exists('##CompleteDone') + let b:supertab_completion_mode = 1 + augroup supertab_completion_mode + autocmd CompleteDone + \ if exists('b:supertab_completion_mode') | + \ unlet b:supertab_completion_mode | + \ endif | + \ autocmd! supertab_completion_mode + augroup END + endif +endfunction " }}} + +function! s:WillComplete(...) " {{{ + " Determines if completion should be kicked off at the current location. + " Optional arg: + " col: The column to check at, otherwise use the current column. + + " if an arg was supplied, then we will re-check even if already in + " completion mode. + if s:CompletionMode() && !a:0 + return 1 + endif + + let line = getline('.') + let cnum = a:0 ? a:1 : col('.') + + " honor SuperTabNoCompleteAfter + let pre = cnum >= 2 ? line[:cnum - 2] : '' + let complAfterType = type(b:SuperTabNoCompleteAfter) + if complAfterType == 3 + " the option was provided as a list of patterns + for pattern in b:SuperTabNoCompleteAfter + if pre =~ pattern . '$' + return 0 + endif + endfor + elseif complAfterType == 2 + " the option was provided as a funcref + return !b:SuperTabNoCompleteAfter(pre) + endif + + " honor SuperTabNoCompleteBefore + " Within a word, but user does not have mid word completion enabled. + let post = line[cnum - 1:] + let complBeforeType = type(b:SuperTabNoCompleteBefore) + if complBeforeType == 3 + " a list of patterns + for pattern in b:SuperTabNoCompleteBefore + if post =~ '^' . pattern + return 0 + endif + endfor + elseif complBeforeType == 2 + " the option was provided as a funcref + return !b:SuperTabNoCompleteBefore(post) + endif + + return 1 +endfunction " }}} + +function! s:EnableLongestEnhancement() " {{{ + augroup supertab_reset + autocmd! + autocmd InsertLeave,CursorMovedI + \ call s:ReleaseKeyPresses() | autocmd! supertab_reset + augroup END + call s:CaptureKeyPresses() +endfunction " }}} + +function! s:IsNoCompleteAfterReset() " {{{ + " if the user has g:SuperTabNoCompleteAfter set, then re-map so that + " backspacing to a point where one of the g:SuperTabNoCompleteAfter + " entries matches will cause completion mode to exit. + let complAfterType = type(b:SuperTabNoCompleteAfter) + if complAfterType == 2 + return 1 + endif + return len(g:SuperTabNoCompleteAfter) && g:SuperTabNoCompleteAfter != ['^', '\s'] +endfunction " }}} + +function! s:EnableNoCompleteAfterReset() " {{{ + augroup supertab_reset + autocmd! + autocmd InsertLeave,CursorMovedI + \ call s:ReleaseKeyPresses() | autocmd! supertab_reset + augroup END + + " short version of s:CaptureKeyPresses + if !exists('b:capturing') || !b:capturing + let b:capturing = 1 + let b:capturing_start = col('.') + let b:captured = { + \ '': s:CaptureKeyMap(''), + \ '': s:CaptureKeyMap(''), + \ } + imap =CompletionReset("\bs>") + imap =CompletionReset("\c-h>") + endif +endfunction " }}} + +function! s:CompletionReset(char) " {{{ + let b:complReset = 1 + + " handle exiting completion mode if user has g:SuperTabNoCompleteAfter set + " and they are about to backspace to a point where that maches one of the + " entries in that var. + if (a:char == "\" || a:char == "\") && s:IsNoCompleteAfterReset() + if !s:WillComplete(col('.') - 1) + " Exit from completion mode then issue the currently requested + " backspace (mapped). + call feedkeys("\\", 'n') + call s:ReleaseKeyPresses() + call feedkeys("\", 'mt') + return '' + endif + endif + + return a:char +endfunction " }}} + +function! s:CaptureKeyPresses() " {{{ + if !exists('b:capturing') || !b:capturing + let b:capturing = 1 + let b:capturing_start = col('.') + " save any previous mappings + let b:captured = { + \ '': s:CaptureKeyMap(''), + \ '': s:CaptureKeyMap(''), + \ } + " TODO: use &keyword to get an accurate list of chars to map + for c in split('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_', '.\zs') + let existing = s:CaptureKeyMap(c) + let b:captured[c] = existing + exec 'imap ' . c . ' =CompletionReset("' . c . '")' + endfor + imap =CompletionReset("\bs>") + imap =CompletionReset("\c-h>") + endif +endfunction " }}} + +function! s:CaptureKeyMap(key) " {{{ + " as of 7.3.032 maparg supports obtaining extended information about the + " mapping. + if s:has_dict_maparg + return maparg(a:key, 'i', 0, 1) + endif + return maparg(a:key, 'i') +endfunction " }}} + +function! s:IsPreviewOpen() " {{{ + let wins = tabpagewinnr(tabpagenr(), '$') + let winnr = 1 + while winnr <= wins + if getwinvar(winnr, '&previewwindow') == 1 + return 1 + endif + let winnr += 1 + endwhile + return 0 +endfunction " }}} + +function! s:ClosePreview() " {{{ + if exists('b:supertab_close_preview') && b:supertab_close_preview + let preview = 0 + for bufnum in tabpagebuflist() + if getwinvar(bufwinnr(bufnum), '&previewwindow') + let preview = 1 + break + endif + endfor + if preview + pclose + try + doautocmd supertab_preview_closed User + catch /E216/ + " ignore: no autocmds defined + endtry + endif + endif + silent! unlet b:supertab_close_preview +endfunction " }}} + +function! s:ReleaseKeyPresses() " {{{ + if exists('b:capturing') && b:capturing + let b:capturing = 0 + for c in keys(b:captured) + exec 'iunmap ' . c + endfor + + " restore any previous mappings + for [key, mapping] in items(b:captured) + if !len(mapping) + continue + endif + + if type(mapping) == 4 + let restore = mapping.noremap ? "inoremap" : "imap" + let restore .= " " + if mapping.silent + let restore .= " " + endif + if mapping.expr + let restore .= " " + endif + let rhs = substitute(mapping.rhs, '\c', '' . mapping.sid . '_', 'g') + let restore .= ' ' . key . ' ' . rhs + exec restore + elseif type(c) == 1 + let args = substitute(mapping, '.*\(".\{-}"\).*', '\1', '') + if args != mapping + let args = substitute(args, '<', '', 'g') + let expr = substitute(mapping, '\(.*\)".\{-}"\(.*\)', '\1%s\2', '') + let mapping = printf(expr, args) + endif + exec printf("imap %s %s", key, mapping) + endif + endfor + unlet b:captured + + if mode() == 'i' && &completeopt =~ 'menu' && b:capturing_start != col('.') + " force full exit from completion mode (don't exit insert mode since + " that will break repeating with '.') + call feedkeys("\\", 'n') + endif + unlet b:capturing_start + endif +endfunction " }}} + +function! s:CommandLineCompletion() " {{{ + " Hack needed to account for apparent bug in vim command line mode completion + " when invoked via = + + " This hack will trigger InsertLeave which will then invoke + " s:SetDefaultCompletionType. To prevent default completion from being + " restored prematurely, set an internal flag for s:SetDefaultCompletionType + " to check for. + let b:complCommandLine = 1 + return "\\:call feedkeys('\\\', 'n') | " . + \ "let b:complCommandLine = 0\" +endfunction " }}} + +function! s:ContextCompletion() " {{{ + let contexts = exists('b:SuperTabCompletionContexts') ? + \ b:SuperTabCompletionContexts : g:SuperTabCompletionContexts + + for context in contexts + try + let Context = function(context) + let complType = Context() + unlet Context + if type(complType) == 1 && complType != '' + return complType + endif + catch /E700/ + echohl Error + echom 'supertab: no context function "' . context . '" found.' + echohl None + endtry + endfor + return '' +endfunction " }}} + +function! s:ContextDiscover() " {{{ + let discovery = exists('g:SuperTabContextDiscoverDiscovery') ? + \ g:SuperTabContextDiscoverDiscovery : [] + + " loop through discovery list to find the default + if !empty(discovery) + for pair in discovery + let var = substitute(pair, '\(.*\):.*', '\1', '') + let type = substitute(pair, '.*:\(.*\)', '\1', '') + exec 'let value = ' . var + if value !~ '^\s*$' && value != '0' + exec "let complType = \"" . escape(type, '<') . "\"" + return complType + endif + endfor + endif +endfunction " }}} + +function! s:ContextText() " {{{ + let exclusions = exists('g:SuperTabContextTextFileTypeExclusions') ? + \ g:SuperTabContextTextFileTypeExclusions : [] + + if index(exclusions, &ft) == -1 + let curline = getline('.') + let cnum = col('.') + let synname = synIDattr(synID(line('.'), cnum - 1, 1), 'name') + + let member_patterns = exists('b:SuperTabContextTextMemberPatterns') ? + \ b:SuperTabContextTextMemberPatterns : g:SuperTabContextTextMemberPatterns + let member_pattern = join(member_patterns, '\|') + + " don't kick off file completion if the pattern is '\" + + elseif curline =~ '\(' . member_pattern . '\)\w*\%' . cnum . 'c' && + \ synname !~ '\(String\|Comment\)' + let omniPrecedence = exists('g:SuperTabContextTextOmniPrecedence') ? + \ g:SuperTabContextTextOmniPrecedence : ['&completefunc', '&omnifunc'] + let omniPrecedence = exists('b:SuperTabContextTextOmniPrecedence') ? + \ b:SuperTabContextTextOmniPrecedence : omniPrecedence + + for omniFunc in omniPrecedence + if omniFunc !~ '^&' + let omniFunc = '&' . omniFunc + endif + if getbufvar(bufnr('%'), omniFunc) != '' + return omniFunc == '&omnifunc' ? "\\" : "\\" + endif + endfor + endif + endif +endfunction " }}} + +function! s:ExpandMap(map) " {{{ + let map = a:map + if map =~ '' + let plug = substitute(map, '.\{-}\(\w\+\).*', '\1', '') + let plug_map = maparg(plug, 'i') + let map = substitute(map, '.\{-}\(\w\+\).*', plug_map, '') + endif + return map +endfunction " }}} + +function! SuperTabChain(completefunc, completekeys, ...) " {{{ + if a:completefunc != 'SuperTabCodeComplete' + call s:InitBuffer() + if (a:0 && a:1) || (!a:0 && b:SuperTabDefaultCompletionType == 'context') + let b:SuperTabContextTextOmniPrecedence = ['&completefunc', '&omnifunc'] + call SuperTabSetDefaultCompletionType("context") + else + call SuperTabSetDefaultCompletionType("") + endif + + let b:SuperTabChain = [a:completefunc, a:completekeys] + setlocal completefunc=SuperTabCodeComplete + endif +endfunction " }}} + +function! SuperTabCodeComplete(findstart, base) " {{{ + if !exists('b:SuperTabChain') + echoe 'No completion chain has been set.' + return -2 + endif + + if len(b:SuperTabChain) != 2 + echoe 'Completion chain can only be used with 1 completion function ' . + \ 'and 1 fallback completion key binding.' + return -2 + endif + + let Func = function(b:SuperTabChain[0]) + + if a:findstart + let start = Func(a:findstart, a:base) + if start >= 0 + return start + endif + + return col('.') - 1 + endif + + let results = Func(a:findstart, a:base) + " Handle dict case, with 'words' and 'refresh' (optional). + " This is used by YouCompleteMe. (See complete-functions). + if type(results) == type({}) && has_key(results, 'words') + if len(results.words) + return results + endif + elseif len(results) + return results + endif + + exec 'let keys = "' . escape(b:SuperTabChain[1], '<') . '"' + " : stop completion and go back to the originally typed text. + call feedkeys("\" . keys, 'nt') + return [] +endfunction " }}} + +" Autocmds {{{ + if g:SuperTabClosePreviewOnPopupClose + augroup supertab_close_preview + autocmd! + autocmd InsertLeave,CursorMovedI * call s:ClosePreview() + augroup END + endif +" }}} + +" Key Mappings {{{ + " map a regular tab to ctrl-tab (note: doesn't work in console vim) + exec 'inoremap ' . g:SuperTabMappingTabLiteral . ' ' + + inoremap =ManualCompletionEnter() + + imap ', '', 'g') + let res = '' + let max = 0 + let mx = '\(]\{-}>\)\|\(<\/td>\)\|\(]\{-}>\)\|\(<\/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() ? "\" : '' +endfunction diff --git a/sources_forked/emmet-vim/doc/emmet.txt b/sources_forked/emmet-vim/doc/emmet.txt new file mode 100755 index 00000000..ffa5e0a9 --- /dev/null +++ b/sources_forked/emmet-vim/doc/emmet.txt @@ -0,0 +1,1773 @@ +*emmet.txt* *Emmet* for Vim + + ------------------------------------------------------- + Emmet: vim plugins for HTML and CSS hi-speed coding + ------------------------------------------------------- + +Author: Yasuhiro Matsumoto +WebSite: http://mattn.kaoriya.net/ +Repository: https://github.com/mattn/emmet-vim +Site: https://mattn.github.com/emmet-vim +License: BSD style license + +============================================================================== +CONTENTS *emmet-contents* + +Introduction |emmet-introduction| +Install |emmet-install| +Tutorial |emmet-tutorial| + 1. Expand abbreviation |emmet-expand-abbr| |,| + 2. Expand word |emmet-expand-word| |;| + 3. Update tag |emmet-update-tag| |u| + 4. Wrap with abbreviation |emmet-wrap-with-abbreviation| |v_,| + 5. Balance tag inward |emmet-balance-tag-inward| |d| + 6. Balance tag outward |emmet-balance-tag-outward| |D| + 7. Go to next edit point |emmet-goto-next-point| |n| + 8. Go to previous edit point |emmet-goto-previous-point| |N| + 9. Add and update size |emmet-update-image-size| |i| + 10. Merge lines |emmet-merge-lines| |m| + 11. Remove tag |emmet-remove-tag| |k| + 12. Split/join tag |emmet-split-join-tag| |j| + 13. Toggle comment |emmet-toggle-comment| |/| + 14. Make anchor from URL |emmet-make-anchor-url| |a| + 15. Make quoted text from URL |emmet-quoted-text-url| |A| + 16. Code pretty |emmet-code-pretty| |c| + 17. Lorem ipsum |emmet-lorem-ipsum| +HTML expression syntax |emmet-html-expression-syntax| + 1. Elements |emmet-html-syntax-elements| + 2. Nesting operators |emmet-html-syntax-nesting-operators| + 2.1. Child |emmet->| + 2.2. Sibling |emmet-+| + 2.3. Climb-up |emmet-^| + 2.4. Multiplication |emmet-star| + 2.5. Grouping |emmet-()| + 3. Attribute operators |emmet-html-syntax-attribute-operators| + 3.1. ID and CLASS |emmet-.| |emmet-#| + 3.2. Custom attributes |emmet-[]| + 3.3. Item numbering |emmet-$| + 3.3.1. Changing numbering origin and direction |emmet-@| + 3.4. Quote character |emmet-html-attr-quote-char| + 4. Text |emmet-{}| + 5. Implicit tag names |emmet-html-implicit-tag-names| + 6. Notes on abbreviation formatting |emmet-html-syntax-notes| + 7. Choose position to insert text when wrap abbreviation |emmet-$#| +CSS expression syntax |emmet-css-expression-syntax| + 1. Properties |emmet-css-properties| + 2. Values |emmet-css-values| + 3. Units |emmet-css-units| + 4. Vendor prefixes |emmet-css-vendor-prefixes| +Commands |emmet-commands| + :Emmet |:Emmet| + :EmmetInstall |:EmmetInstall| +Variables |emmet-variables| + g:emmet_html5 |g:emmet_html5| + g:emmet_docroot |g:emmet_docroot| + g:emmet_curl_command |g:emmet_curl_command| + g:user_emmet_complete_tag |g:user_emmet_complete_tag| + g:user_emmet_leader_key |g:user_emmet_leader_key| + g:user_emmet_install_global |g:user_emmet_install_global| + g:user_emmet_install_command |g:user_emmet_install_command| + g:user_emmet_settings |g:user_emmet_settings| + g:user_emmet_mode |g:user_emmet_mode| +Customize |emmet-customize| + 1. Key mappings |emmet-customize-key-mappings| + 2. Indent size |emmet-indent-size| + 3. Define tag's behavior |emmet-define-tags-behavior| + 4. Adding custom snippets |emmet-custom-snippets| +Filters |emmet-filters-list| + Escapes XML-unsafe characters |emmet-filter-e| + Add comments around 'important tags' |emmet-filter-c| + Outputs as a single line |emmet-filter-s| + Trim list markers |emmet-filter-t| +Links |emmet-links| +ToDo |emmet-todo| + +============================================================================== +INTRODUCTION *emmet-introduction* *emmet* + +Emmet is an editor plugin for high-speed HTML, XML, XSL (or any other +structured code format) coding and editing. The core of this plugin is a +powerful abbreviation engine which allows you to expand expressions, +similar to CSS selectors, into HTML code: +> + div#page>div.logo+ul#navigation>li*5>a +< +can be expanded into: +> +
+ + +
+< +Read more about current Emmet syntax + |emmet-html-expression-syntax| + |emmet-css-expression-syntax| + http://docs.emmet.io/abbreviations/ + +Abbreviation engine has a modular structure which allows you +to expand abbreviations into different languages. +Emmet currently supports CSS, HTML, XML/XSL and HAML, Slim languages +via filters (see |emmet-filter|). + +============================================================================== +INSTALL *emmet-install* + +Install the distributed files into Vim runtime directory which is usually +'~/.vim/', or '$HOME/vimfiles' on Windows. + +If you install pathogen (https://github.com/tpope/vim-pathogen) +that provided by Tim Pope, you should extract the +file into 'bundle' directory. + +============================================================================== +TUTORIAL *emmet-tutorial* + +If you are seeing this file as :help, then you can't edit this file. +You should copy this section and create new buffer, paste and write as +'emmet-tutor.txt'. Formally, open the file to start tutorial. + +1. Expand abbreviation *emmet-expand-abbr* *,* + + Type abbreviation as 'div>p#foo$*3>a' and type ','. +> +
+

+ +

+

+ +

+

+ +

+
+< +2. Expand abbreviation *emmet-expand-word* *;* + + When you want to expand word except html tokens like below, use this. +> + foo +< + This will be expanded like: +> + + +3. Update tag *emmet-update-tag* *u* + + The begining of tags '
' on below +> +
foo
+< + Type 'u' request 'Enter Abbreviation:'. Then type +> + .global +< + This will be expanded like: +> +
foo
+< +4. Wrap with abbreviation *emmet-wrap-with-abbreviation* *v_,* + + Write as below. +> + test1 + test2 + test3 +< + Then do visual select (line wise) and type ','. + If you request 'Tag:', then type +> + ul>li* +< + Result: +> +
    +
  • test1
  • +
  • test2
  • +
  • test3
  • +
+< + If you type tag name, for example +> + blockquote +< + then you'll see as following: +> +
+ test1 + test2 + test3 +
+< + See also: |emmet-filter-t|, |emmet-$#| + +5. Balance tag inward *emmet-balance-tag-inward* *d* + + To select inward of '
    ' tag, type 'd' in insert mode. +> +
      + *
    • +
    • +
    • +
    +< + If cursor is at '*', 'd' select from begin of '
      ' to end of '
    '. + If cursor is at first of '
  • ', it select '
  • '. + +6. Balance tag outward *emmet-balance-tag-outward* *D* + + To select outward of '
      ' tag type 'D' in insert mode. +> +
        + *
      • +
      • +
      • +
      +< + If cursor is at '*', 'D' select from next letter of '
        ' + to previous letter of '
      '. + If cursor is at first of '
    • ', it select '
    • '. + +7. Go to next edit point *emmet-goto-next-point* *n* + + To jump next point that need to edit, type 'n' in insert mode. +> + *
      foo
      +
      +< + If cursor is at '*', type 'n' to move a cursor + into attribute value of '
      ' specified id as 'foo'. + And type again 'n' to move a cursor + into inner of '
      ' specified id as 'bar'. + +8. Go to previous edit point *emmet-goto-previous-point* *N* + + To jump previous point that need to edit, type 'N' in insert mode. +> +
      foo
      +
      * +< + If cursor is at '*', type 'N' to move a cursor + into '
      ' specified id as 'bar'. + And type again 'N' to move a cursor + into attribute value of 'foo'. + +9. Add and update size *emmet-update-image-size* *i* + + To add or update 'width' and 'height' attributes of image, + type 'i' on '' tag +> + +< + Type 'i' on '' tag +> + +< + If you change image, then type it again. it will be following. +> + +< + Image size retrieved using 'identify' (ImageMagick.org) (if available) + or |xxd|. + +10. Merge lines *emmet-merge-lines* *m* + + To join multi line text like following, type |J|. +> +
        +
      • +
      • +
      • +
      +< + If you select part of line include '
    • ' and type |m|, + it will be following. +> +
        +
      • +
      +< +11. Remove tag *emmet-remove-tag* *k* + + To remove tag in the block, type 'k'. +> + +< + Type 'k' in insert mode, then +> +
      + +
      +< + And type 'k' in there again, then '
      ' will be removed. + +12. Split/join tag *emmet-split-join-tag* *j* + + To join block, type 'j'. +> +
      + cursor is here +
      +< + Type 'j' in insert mode. Then, +> +
      +< + And type 'j' in there again. +> +
      +
      +< +13. Toggle comment *emmet-toggle-comment* */* + + Move cursor to block +> +
      + hello world +
      +< + Type '/' in insert mode. +> + +< + Type '/' in there again. +> +
      + hello world +
      +< +14. Make anchor from URL *emmet-make-anchor-url* *a* + + Move cursor to URL +> + http://www.google.com/ +< + Type 'a' +> + Google +< + Text retrieved using command, specified by |g:emmet_curl_command|. + +15. Make quoted text from URL *emmet-quoted-text-url* *A* + + Move cursor to URL +> + https://github.com/ +< + Type 'A' +> +
      + Secure source code hosting and collaborative development - GitHub
      +

      How does it work? Get up and running in seconds by forking a project, pushing an existing repository...

      + https://github.com/ +
      +< + Text retrieved using command, specified by |g:emmet_curl_command|. + +16. Code pretty *emmet-code-pretty* *c* + + Select code block, for example select following code from 'int main()'. +> +

      Writing in C language

      + + int main() { + puts("hello world"); + } +< + Type 'c' +> + int main() {
      +   puts("hello world");
      + }
      +< + To convert text into html used command |:TOhtml|. + +17. Lorem ipsum *emmet-lorem-ipsum* + + To insert dummy text (30 words by default). +> + div>lorem +< + Type |,| +> +
      Adipisicing asperiores deleniti ipsum fuga deserunt perferendis + molestiae sunt excepturi aut quo nihil! Optio accusantium corporis molestiae + deserunt ab, veritatis commodi. Eius nobis ab deserunt magni iure quo + laboriosam laboriosam.
      +< + For japanese user, put like follow into your |g:user_emmet_settings|: +> + let g:user_emmet_settings = { + ... + + \ 'custom_expands1' : { + \ '^\%(lorem\|lipsum\)\(\d*\)$' : function('emmet#lorem#ja#expand'), + \ }, + + ... +< + You will get japanese dummy text. Text retrieved from url + 'http://www.aozora.gr.jp/cards/000081/files/470_15407.html' + using command, specified by |g:emmet_curl_command|. + + To insert 3 words of dummy text. +> + div>lorem3 +< + Type |,| +> +
      + Elit libero id. +
      +< +============================================================================== +HTML EXPRESSION SYNTAX *emmet-html-expression-syntax* + +Emmet uses syntax similar to CSS selectors for describing elements' positions +inside generated tree and elements' attributes. + +1. Elements *emmet-html-syntax-elements* + + You can use elements' names like 'div' or 'p' to generate HTML tags. +> + p ->

      + div ->
      +< + You can write any word and transform it into a tag: +> + foo -> + bar -> +< + Emmet knowns set of empty elements: +> + br ->
      or
      + meta -> or +< + To choose between HTML '>' and XHTML ' />' use |g:emmet_html5| or + |g:user_emmet_settings|: +> + let g:user_emmet_settings = { + \ ... + \ 'html': { + \ ... + \ 'empty_element_suffix': ' />', + \ ... + \ }, + \ ... + \} +< + Emmet will automatically insert some attributes: +> + a -> + link -> +< + Set of inserted attributes can be changed using |g:user_emmet_settings|: +> + let s:emmet_settings = { + \ ... + \ 'html': { + \ ... + \ 'default_attributes': { + \ ... + \ 'a': {'href': ''}, + \ 'ins': {'datetime': '${datetime}'}, + \ 'iframe': [{'src': ''}, {'frameborder': '0'}], + \ 'textarea': [{'name': ''}, {'id': ''}, {'cols': '30'}, {'rows': '10'}], + \ ... + \ }, + \ ... + \ }, + \ ... + \} +< +2. Nesting operators *emmet-html-syntax-nesting-operators* + + Nesting operators are used to position abbreviation elements + inside generated tree: whether it should be placed + inside or near the context element. + + Operator Description Link ~ + > Child |emmet->| + + Sibling |emmet-+| + ^ Climb-up |emmet-^| + * Multiplication |emmet-star| + () Grouping |emmet-()| + +2.1. Child *emmet->* + + You can use '>' operator to nest elements inside each other: +> + div>ul>li +< + will produce +> +
      +
        +
      • +
      +
      +< +2.2. Sibling *emmet-+* + + Use '+' operator to place elements near each other, on the same level: +> + div+p+bq +< + will output +> +
      +

      +
      +< +2.3. Climb-up *emmet-^* + + With '>' operator you're descending down the generated tree and + positions of all sibling elements will be resolved + against the most deepest element: +> + div+div>p>span+em +< + will be expanded to +> +
      +
      +

      + + +

      +
      +< + With '^' operator, you can climb one level up the tree and change context + where following elements should appear: +> + div+div>p>span+em^bq +< + outputs to +> +
      +
      +

      + + +

      +
      +
      +< + You can use as many '^' operators as you like, + each operator will move one level up: +> + div+div>p>span+em^^^bq +< + will output to +> +
      +
      +

      + + +

      +
      +
      +< +2.4. Multiplication *emmet-star* + + With '*' operator you can define how many times element should be outputted: +> + ul>li*5 +< + outputs to +> +
        +
      • +
      • +
      • +
      • +
      • +
      +< + Expression may contain several '*' operators: +> + tr*2>td*3 +< + become +> + + + + + + + + + + +< +2.5. Grouping *emmet-()* + + Parentheses '()' are used by Emmets' power users for grouping subtrees + in complex abbreviations: +> + div>(header>ul>li*2>a)+footer>p +< + expands to +> +
      +
      +
        +
      • +
      • +
      +
      +
      +

      +
      +
      +< + If you're working with browser's DOM, you may think of groups + as Document Fragments: each group contains abbreviation subtree and + all the following elements are inserted at the same level + as the first element of group. + + You can nest groups inside each other and + combine them with multiplication '*' operator: +> + (div>dl>(dt+dd)*3)+footer>p +< + produces +> +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +

      +
      +< + With groups, you can literally write full page mark-up + with a single abbreviation, but please don't do that. + +3. Attribute operators *emmet-html-syntax-attribute-operators* + + Attribute operators are used to modify attributes of outputted elements. + For example, in HTML and XML you can quickly add 'class' attribute + to generated element. + + Operator Description Link ~ + . Attribute 'class' |emmet-.| + # Attribute 'id' |emmet-#| + [] Custom attributes |emmet-[]| + $ Number |emmet-$| + @ Number origin and direction |emmet-@| + +3.1. ID and CLASS *emmet-.* *emmet-#* + + In CSS, you use 'elem#id' and 'elem.class' notation to reach the elements + with specified 'id' or 'class' attributes. + In Emmet, you can use the very same syntax to add these attributes + to specified element: +> + span.class1 -> + span.class1.class2 -> + div#wrapper ->
      + div#wrapper.content ->
      +< + More complex expression: +> + div#header+div.page+div#footer.class1.class2.class3 +< + will output +> + +
      + +< +3.2. Custom attributes *emmet-[]* + + You can use '[attr]' notation (as in CSS) + to add custom attributes to your element: +> + td[title="Hello world!" colspan=3] +< + outputs +> + +< + You can place as many attributes as you like inside square brackets. + + Attribute values may be omitted: +> + td[colspan title] +< + will produce +> + +< + You can use single or double quotes for quoting attribute values. +> + div[a='value1' b="value2"] +< + become +> +
      +< + You don't need to quote values if they don't contain spaces: +> + td[title=hello colspan=3] +< + will output +> + +< +3.3. Item numbering *emmet-$* + + With multiplication '*' operator you can repeat elements, + but with '$' you can number them. + Place '$' operator inside element's name, attribute's name or + attribute's value to output current number of repeated element: +> + ul>li.item_$*5 +< + outputs to +> +
        +
      • +
      • +
      • +
      • +
      • +
      +< + You can use multiple '$' in a row to pad number with zeroes: +> + ul>li.item_$$$*5 +< + outputs to +> +
        +
      • +
      • +
      • +
      • +
      • +
      +< + Also '$' can be used in element name and in text (|emmet-{}|): +> + h$[title=item$]{Header $}*3 +< + transformed to +> +

      Header 1

      +

      Header 2

      +

      Header 3

      +< +3.3.1. Changing numbering origin and direction *emmet-@* + + With '@' modifier, you can change + - numbering direction (ascending or descending) and + - origin (i. e. start value). + + For example, to change direction, add '@-' after '$': +> + ul>li.item_$@-*5 +< + outputs to +> +
        +
      • +
      • +
      • +
      • +
      • +
      +< + To change counter origin value, add '@N' modifier to '$': +> + ul>li.item_$@3*5 +< + transforms to +> +
        +
      • +
      • +
      • +
      • +
      • +
      +< + You can use these modifiers together: +> + ul>li.item_$@-3*5 +< + is transformed to +> +
        +
      • +
      • +
      • +
      • +
      • +
      +> +3.4. Quote character *emmet-html-attr-quote-char* + + |g:user_emmet_settings| may be used to change attribute quote character: +> + let g:user_emmet_settings = { + ... + \ 'html' : { + ... + \ 'quote_char': "'", + ... + \ }, + ... + \} +< + Then abbreviation +> + a[target=_blank] +< + will expand to +> + +< + instead of +> + +< + Default quote is '"'. + +4. Text *emmet-{}* + + You can use curly braces to add text to element: +> + a{Click me} +< + will produce +> + Click me +< + Note that '{text}' is used and parsed as a separate element + (like, 'div', 'p' etc), but has a special meaning + when written right after element. For example, +> + a{click} +< + and +> + a>{click} +< + will produce the same output, but +> + a{click}+b{here} +< + and +> + a>{click}+b{here} +< + won't: +> + + clickhere + + + clickhere +< + In second example the '' element is placed inside '' element. + And that's the difference: when '{text}' is written right after element, + it doesn't change parent context. + Here's more complex example showing why it is important: +> + p>{Click }+a{here}+{ to continue} +< + produces +> +

      Click here to continue

      +< + In this example, to write 'Click here to continue' inside '

      ' element + we have explicitly move down the tree with '>' operator after 'p', + but in case of 'a' element we don't have to, since we need '' element + with here word only, without changing parent context. + + For comparison, here's the same abbreviation + written without child '>' operator: +> + p{Click }+a{here}+{ to continue} +< + produces +> +

      Click

      + here to continue +< +5. Implicit tag names *emmet-html-implicit-tag-names* + + Even with such a powerful abbreviation engine, + which can expand large HTML structures from short abbreviation, + writing tag names may be very tedious. + + In many cases you can skip typing tag names and + Emmet will substitute it for you. + For example, instead of > + div.content +< you can simply write > + .content +< and expand it into > +
      +< + Other examples: +> + .wrapper ->
      + #popup -> +< + When you expand abbreviation, Emmet tries to grab parent context, + e. g. the HTML element, inside which you're expanding the abbreviation. + If the context was grabbed successfully, + Emmet uses its name to resolve implicit names. + Emmet looks at the parent tag name every time + you're expanding the abbreviation with an implicit name. + Here's how it resolves the names for some parent elements: + + Inserted element Parent elements ~ + li ul, ol + tr table, tbody, thead, tfoot + td tr + option select, optgroup + span Inline elements + div Block elements + + Take a look at some abbreviations equivalents + with implicit and explicit tag names: +> + .wrap>.content -> div.wrap>div.content + em>.info -> em>span.info + ul>.item*3 -> ul>li.item*3 + table>.row>.col -> table>tr.row>td.col + table>#row$*4>[colspan=2] -> table>tr#row$*4>td[colspan=2] +< +6. Notes on abbreviation formatting *emmet-html-syntax-notes* + + When you get familiar with Emmet's abbreviations syntax, + you may want to use some formatting to make your abbreviations more readable. + For example, use spaces between elements and operators, like this: +> + (header > ul.nav > li*5) + footer +< + But it won't work, because space is a stop symbol + where Emmet stops abbreviation parsing. + + Many users mistakenly think that each abbreviation + should be written in a new line, but they are wrong: + you can type and expand abbreviation anywhere in the text: + + This is why Emmet needs some indicators (like spaces) + where it should stop parsing to not expand anything that you don't need. + If you're still thinking that such formatting is required + for complex abbreviations to make them more readable: + - abbreviations are not a template language, + they don't have to be "readable", + they have to be "quickly expandable and removable"; + - you don't really need to write complex abbreviations. + Stop thinking that "typing" is the slowest process in web-development. + You'll quickly find out that constructing a single complex abbreviation + is much slower and error-prone than constructing and typing + a few short ones. + +7. Choose position to insert text when wrap abbreviation *emmet-$#* + + When wrap abbreviation (|emmet-wrap-with-abbreviation|) you can choose + position to insert text using '$#' operator. + Operator '$#' may be used only inside |emmet-[]| and/or |emmet-{}|. + + For example, do visual select (line wise) following text: +> + First + Second + Third +< + Then press ',' and type +> + ul>li[ title="[$#]" ]* +< + Result: +> +
        +
      • First
      • +
      • Second
      • +
      • Third
      • +
      +< + You may type +> + input[ type=input value=$# ] +< + to get +> + + + +< + Using '$#' you can type text (|emmet-{}|) only once: +> + a[title=$#]{foo} +< + will be expanded to +> + foo +< +============================================================================== +CSS EXPRESSION SYNTAX *emmet-css-expression-syntax* + +1. Properties *emmet-css-properties* + + Emmet has a lot of predefined snippets for CSS properties. +> + +< + become +> + +< + In above example '|' denotes a cursor (caret) position. + + Other examples: +> + t -> top: ; + d -> display: ; + o -> outline: ; + ov -> overflow: ; + cu -> cursor: ; + bdrs -> border-radius: ; +< + '+' operator may be used to insert number of properties: +> + m1+p2 +< + become +> + margin: 1px; + padding: 2px; +< +2. Values *emmet-css-values* + + Some properties have default values: +> + c -> color: #000; + bgc -> background-color: #FFF; + zoo -> zoom: 1; +< + To insert predefined property value after abbreviation + type colon ':' and first character of predefined keyword: +> + d:n -> display: none; + d:b -> display: block; + d:i -> display: inline; +< + Numerical value can be typed directly after abbreviation: +> + m10 -> margin: 10px; + m2e -> margin: 2em; +< + Use a hyphen '-' to separate some numerical values: +> + m10-20 -> margin: 10px 20px; + p1-2-3 -> padding: 1px 2px 3px; +< + To negative values + precede the first value with hyphen and all the rest with double hyphens: +> + m-10 -> margin: -10px; + m-1--2 -> margin: -1px -2px; + p-2--1-0-1 -> padding: -2px -1px 0 1px; +< + To insert '!important' append '!' to property abbreviation: +> + m! -> margin: !important; + bac! -> background: !important; +< + You can use special abbreviation 'lg(...)' + to insert definition of linear gradient. Example: +> + lg(left, #fc0 30%, red) +< + will expand to +> + background-image: -webkit-gradient(left, 0 0, 0 100, from(#fc0 30%), to(red)); + background-image: -webkit-linear-gradient(#fc0 30%, red); + background-image: -moz-linear-gradient(#fc0 30%, red); + background-image: -o-linear-gradient(#fc0 30%, red); + background-image: linear-gradient(#fc0 30%, red); +< +3. Units *emmet-css-units* + + By default, when you expand an abbreviation with integer value, + Emmet outputs it with a 'px' unit: +> + bor2 -> border: 2px; + fs100 -> font-size: 100px; + miw20 -> min-width: 20px; +< + By default, if you're expanding an abbreviation with a float value, + it is outputted with an 'em' unit: +> + fs1.5 -> font-style: 1.5em; +< + But you can explicitly provide the unit name + by putting one of characters right after value: + + Character Unit ~ + p % + e em + + Examples: +> + fs2e -> font-style: 2em; + w100p -> width: 100%; +< +4. Vendor prefixes *emmet-css-vendor-prefixes* + + To automatically create vendor-prefixed copies of property, + precede abbreviation with a hyphen '-'. For example, abbreviation +> + -bdrs +< + will be expanded into +> + -webkit-border-radius: ; + -moz-border-radius: ; + border-radius: ; +< +============================================================================== +COMMANDS *emmet-commands* + +:Emmet {expression} *:Emmet* + Expand {expression} and insert result under cursor. + {expression} is |emmet-html-expression|. + Also see |g:user_emmet_install_command|. + +:EmmetInstall *:EmmetInstall* + Create Emmet mappings to current buffer + (|mapping|, |:map-|) and, + if set |g:user_emmet_complete_tag|, + change |'omnifunc'| option to emmet#completeTag() + +============================================================================== +VARIABLES *emmet-variables* + +g:emmet_html5 *g:emmet_html5* + If set to 1, enable HTML 5 support: + - use ">" instead of "/>": > + + +< - omit some HTML 4 attributes: > +