Configuration refactored
This commit is contained in:
parent
3d0baee9e8
commit
65ebd36472
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
vim/bundle/*
|
|
@ -1 +0,0 @@
|
|||
12
|
|
@ -1 +0,0 @@
|
|||
12
|
|
@ -1,3 +0,0 @@
|
|||
snippet ! "!important"
|
||||
!important
|
||||
endsnippet
|
|
@ -1,39 +0,0 @@
|
|||
snippet for "Boucle for"
|
||||
{% for item in $1 %}
|
||||
|
||||
{% endfor %}
|
||||
endsnippet
|
||||
|
||||
snippet if "If cond"
|
||||
{% if $1 %}
|
||||
|
||||
{% else %}
|
||||
|
||||
{% endif %}
|
||||
endsnippet
|
||||
|
||||
snippet dump "Dump function"
|
||||
{{ dump($1) }}
|
||||
endsnippet
|
||||
|
||||
snippet trans "Trans function"
|
||||
{{ '$1'|trans }}
|
||||
endsnippet
|
||||
|
||||
snippet macro "Macro function"
|
||||
{% import _self as macros %}
|
||||
|
||||
{% macro $1() %}
|
||||
|
||||
{% endmacro %}
|
||||
|
||||
{{ macros.$1() }}
|
||||
endsnippet
|
||||
|
||||
snippet {{ "Print"
|
||||
{{ $1 }}
|
||||
endsnippet
|
||||
|
||||
snippet {% "Function"
|
||||
{% $1 %}
|
||||
endsnippet
|
|
@ -1,77 +0,0 @@
|
|||
snippet pf "Create a public function" b
|
||||
public function $1()
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet ppf "Create a private function" b
|
||||
public function $1()
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet ptf "Create a protected function" b
|
||||
public function $1()
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet sf2:c "Create a symfony2 controller function" b
|
||||
/**
|
||||
* @param $request
|
||||
* @return \Symfony\Bundle\FrameworkBundle\Controller\Response
|
||||
*/
|
||||
public function $1Action(Request $request)
|
||||
{
|
||||
return $this->defaultRender();
|
||||
}
|
||||
endsnippet
|
||||
|
||||
snippet page "Create trinity page"
|
||||
<?php
|
||||
|
||||
`!p snip.rv = os.popen('/home/simon/bin/namespace ' + path).readline().strip()`
|
||||
|
||||
use Trinity\Bundle\ContentManagerBundle\Model\Page;
|
||||
use Trinity\Bundle\ContentManagerBundle\Model\Block;
|
||||
|
||||
class `!p snip.rv = snip.basename` extends Page
|
||||
{
|
||||
public function __construct($template = '$1')
|
||||
{
|
||||
parent::__construct($template);
|
||||
}
|
||||
|
||||
public function getConfiguration()
|
||||
{
|
||||
return $this->configuration
|
||||
->setDefaultController('FooBarBundle:MyController:bob')
|
||||
->setDefaultControllerClass('Foo\Bundle\BarBundle::bobAction')
|
||||
->setBlock('title', 'Trinity\Bundle\ContentManagerBundle\Form\Type\BlockType')
|
||||
->setBlock('content', 'Trinity\Bundle\ContentManagerBundle\Form\Type\TinymceAdvancedBlockType')
|
||||
}
|
||||
|
||||
public function getBlockTitle()
|
||||
{
|
||||
return $this->getBlock('title');
|
||||
}
|
||||
|
||||
public function getBlockTitle(Block $block)
|
||||
{
|
||||
return $this->setBlock($block);
|
||||
}
|
||||
|
||||
public function getBlockContent()
|
||||
{
|
||||
return $this->getBlock('content');
|
||||
}
|
||||
|
||||
public function setBlockContent(Block $block)
|
||||
{
|
||||
return $this->setBlock($block);
|
||||
}
|
||||
}
|
||||
endsnippet
|
Binary file not shown.
|
@ -1,34 +0,0 @@
|
|||
snippet trans "trans"
|
||||
<trans-unit id="$1">
|
||||
<source><![CDATA[$2]]></source>
|
||||
<target><![CDATA[$3]]></target>
|
||||
</trans-unit>
|
||||
endsnippet
|
||||
|
||||
snippet schema "schema"
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<database defaultIdMethod="native" name="default" namespace="$1">
|
||||
$2
|
||||
</database>
|
||||
endsnippet
|
||||
|
||||
|
||||
snippet table "table"
|
||||
<table name="$1" isCrossRef="$2">
|
||||
<column name="id" type="INTEGER" primaryKey="true" required="true" autoIncrement="true"/>
|
||||
|
||||
<behavior name="timestampable"/>
|
||||
|
||||
<!--
|
||||
<foreign-key foreignTable="foo" onDelete="none" onUpdate="cascade">
|
||||
<reference local="foo_id" foreign="id"/>
|
||||
</foreign-key>
|
||||
|
||||
<behavior name="sortable"/>
|
||||
<behavior name="uploadable">
|
||||
<parameter name="fields" value="picture"/>
|
||||
<parameter name="paths" value="uploads/post/"/>
|
||||
</behavior>
|
||||
-->
|
||||
</table>
|
||||
endsnippet
|
|
@ -1,20 +0,0 @@
|
|||
# vim-twig
|
||||
|
||||
## About
|
||||
Supports Twig PHP templates [http://www.twig-project.org/][1]
|
||||
|
||||
Based on Jinja2 syntax highlighting by [Armin Ronacher][2]
|
||||
|
||||
-----
|
||||
## Installation
|
||||
|
||||
This scripts bundles is compatible with [vim-addon-manager][3]
|
||||
|
||||
## Changes
|
||||
### 2011-07-29
|
||||
- Re-based the syntax highlighting to properly support all tags
|
||||
- Added support for .html.twig files
|
||||
|
||||
[1]: http://www.twig-project.org/
|
||||
[2]: http://www.vim.org/scripts/script.php?script_id=1856
|
||||
[3]: https://github.com/MarcWeber/vim-addon-manager
|
|
@ -1,5 +0,0 @@
|
|||
" Twig
|
||||
autocmd BufNewFile,BufRead *.twig set filetype=twig
|
||||
|
||||
" HTML Twig
|
||||
autocmd BufNewFile,BufRead *.html.twig set filetype=html.twig
|
|
@ -1,18 +0,0 @@
|
|||
" Vim filetype plugin
|
||||
" Language: Twig
|
||||
" Maintainer: F. Gabriel Gosselin <gabrielNOSPAM@evidens.ca>
|
||||
|
||||
if exists("b:did_ftplugin")
|
||||
finish
|
||||
endif
|
||||
|
||||
runtime! ftplugin/html.vim ftplugin/html*.vim ftplugin/html/*.vim
|
||||
unlet! b:did_ftplugin
|
||||
|
||||
setlocal comments=s:{#,ex:#}
|
||||
setlocal formatoptions+=tcqln
|
||||
" setlocal formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\|^[-*+]\\s\\+
|
||||
|
||||
let b:undo_ftplugin .= "|setl cms< com< fo<"
|
||||
|
||||
" vim:set sw=2:
|
|
@ -1,46 +0,0 @@
|
|||
# Basic Twig snippets
|
||||
# Maintainer: F. Gabriel Gosselin <gabrielNOSPAM@evidens.ca>
|
||||
|
||||
# include
|
||||
snippet inc
|
||||
{% include '${1}' %}
|
||||
# extend
|
||||
snippet ext
|
||||
{% extends '${1:template.html.twig}' %}
|
||||
# extends
|
||||
snippet extends
|
||||
{% extends '${1:template}' %}${2}
|
||||
# if
|
||||
snippet if
|
||||
{% if ${1} %}
|
||||
${2}
|
||||
{% endif %}
|
||||
# else
|
||||
snippet else
|
||||
{% else %}
|
||||
${1}
|
||||
# for
|
||||
snippet for
|
||||
{% for ${2:} in ${1} %}
|
||||
${3}{{ $2 }}
|
||||
{% endfor %}
|
||||
# Set
|
||||
snippet set
|
||||
{% set ${1:var} = ${2:value} %}${3}
|
||||
# Print variable
|
||||
snippet }}
|
||||
{{ ${1} }}${2}
|
||||
# Single Regular execution block
|
||||
snippet %%
|
||||
{% ${1} %}${2}
|
||||
# Comment block
|
||||
snippet ##
|
||||
{# ${1} #}${2}
|
||||
# Open/close block
|
||||
snippet %end
|
||||
{% ${1:block} %}${2}{% end$1 %}
|
||||
# Named block
|
||||
snippet block
|
||||
{% block ${1:name} %}${2}{% endblock %}
|
||||
snippet f_date
|
||||
{{ ${1:a_date}|date("${2:m/d/Y}") }}
|
|
@ -1,109 +0,0 @@
|
|||
" Vim syntax file
|
||||
" Language: Twig template
|
||||
" Maintainer: Gabriel Gosselin <gabrielNOSPAM@evidens.ca>
|
||||
" Last Change: 2011 July 27
|
||||
" Version: 1.0
|
||||
"
|
||||
" Based Jinja syntax by: Armin Ronacher <armin.ronacher@active-4.com>
|
||||
"
|
||||
" Known Bugs:
|
||||
" because of odd limitations dicts and the modulo operator
|
||||
" appear wrong in the template.
|
||||
"
|
||||
" Changes:
|
||||
"
|
||||
" 2008 May 9: Added support for Jinja2 changes (new keyword rules)
|
||||
" 2011 July 27: Changed all references of jinja tp twig
|
||||
|
||||
syntax case match
|
||||
|
||||
" Jinja template built-in tags and parameters (without filter, macro, is and raw, they
|
||||
" have special threatment)
|
||||
syn keyword twigStatement containedin=twigVarBlock,twigTagBlock,twigNested contained and if else in not or recursive as import
|
||||
|
||||
syn keyword twigStatement containedin=twigVarBlock,twigTagBlock,twigNested contained is filter skipwhite nextgroup=twigFilter
|
||||
syn keyword twigStatement containedin=twigTagBlock contained macro skipwhite nextgroup=twigFunction
|
||||
syn keyword twigStatement containedin=twigTagBlock contained block skipwhite nextgroup=twigBlockName
|
||||
|
||||
" Variable Names
|
||||
syn match twigVariable containedin=twigVarBlock,twigTagBlock,twigNested contained skipwhite /[a-zA-Z_][a-zA-Z0-9_]*/
|
||||
syn keyword twigSpecial containedin=twigVarBlock,twigTagBlock,twigNested contained false true none loop super caller varargs kwargs
|
||||
|
||||
" Filters
|
||||
syn match twigOperator "|" containedin=twigVarBlock,twigTagBlock,twigNested contained nextgroup=twigFilter
|
||||
syn match twigFilter contained skipwhite /[a-zA-Z_][a-zA-Z0-9_]*/
|
||||
syn match twigFunction contained skipwhite /[a-zA-Z_][a-zA-Z0-9_]*/
|
||||
syn match twigBlockName contained skipwhite /[a-zA-Z_][a-zA-Z0-9_]*/
|
||||
|
||||
" Jinja template constants
|
||||
syn region twigString containedin=twigVarBlock,twigTagBlock,twigNested contained start=/"/ skip=/\\"/ end=/"/
|
||||
syn region twigString containedin=twigVarBlock,twigTagBlock,twigNested contained start=/'/ skip=/\\'/ end=/'/
|
||||
syn match twigNumber containedin=twigVarBlock,twigTagBlock,twigNested contained /[0-9]\+\(\.[0-9]\+\)\?/
|
||||
|
||||
" Operators
|
||||
syn match twigOperator containedin=twigVarBlock,twigTagBlock,twigNested contained /[+\-*\/<>=!,:]/
|
||||
syn match twigPunctuation containedin=twigVarBlock,twigTagBlock,twigNested contained /[()\[\]]/
|
||||
syn match twigOperator containedin=twigVarBlock,twigTagBlock,twigNested contained /\./ nextgroup=twigAttribute
|
||||
syn match twigAttribute contained /[a-zA-Z_][a-zA-Z0-9_]*/
|
||||
|
||||
" Jinja template tag and variable blocks
|
||||
syn region twigNested matchgroup=twigOperator start="(" end=")" transparent display containedin=twigVarBlock,twigTagBlock,twigNested contained
|
||||
syn region twigNested matchgroup=twigOperator start="\[" end="\]" transparent display containedin=twigVarBlock,twigTagBlock,twigNested contained
|
||||
syn region twigNested matchgroup=twigOperator start="{" end="}" transparent display containedin=twigVarBlock,twigTagBlock,twigNested contained
|
||||
syn region twigTagBlock matchgroup=twigTagDelim start=/{%-\?/ end=/-\?%}/ skipwhite containedin=ALLBUT,twigTagBlock,twigVarBlock,twigRaw,twigString,twigNested,twigComment
|
||||
|
||||
syn region twigVarBlock matchgroup=twigVarDelim start=/{{-\?/ end=/-\?}}/ containedin=ALLBUT,twigTagBlock,twigVarBlock,twigRaw,twigString,twigNested,twigComment
|
||||
|
||||
" Jinja template 'raw' tag
|
||||
syn region twigRaw matchgroup=twigRawDelim start="{%\s*raw\s*%}" end="{%\s*endraw\s*%}" containedin=ALLBUT,twigTagBlock,twigVarBlock,twigString,twigComment
|
||||
|
||||
" Jinja comments
|
||||
syn region twigComment matchgroup=twigCommentDelim start="{#" end="#}" containedin=ALLBUT,twigTagBlock,twigVarBlock,twigString
|
||||
|
||||
" Block start keywords. A bit tricker. We only highlight at the start of a
|
||||
" tag block and only if the name is not followed by a comma or equals sign
|
||||
" which usually means that we have to deal with an assignment.
|
||||
syn match twigStatement containedin=twigTagBlock contained skipwhite /\({%-\?\s*\)\@<=\<[a-zA-Z_][a-zA-Z0-9_]*\>\(\s*[,=]\)\@!/
|
||||
|
||||
" and context modifiers
|
||||
syn match twigStatement containedin=twigTagBlock contained /\<with\(out\)\?\s\+context\>/ skipwhite
|
||||
|
||||
|
||||
" Define the default highlighting.
|
||||
" For version 5.7 and earlier: only when not done already
|
||||
" For version 5.8 and later: only when an item doesn't have highlighting yet
|
||||
if version >= 508 || !exists("did_twig_syn_inits")
|
||||
if version < 508
|
||||
let did_twig_syn_inits = 1
|
||||
command -nargs=+ HiLink hi link <args>
|
||||
else
|
||||
command -nargs=+ HiLink hi def link <args>
|
||||
endif
|
||||
|
||||
HiLink twigPunctuation twigOperator
|
||||
HiLink twigAttribute twigVariable
|
||||
HiLink twigFunction twigFilter
|
||||
|
||||
HiLink twigTagDelim twigTagBlock
|
||||
HiLink twigVarDelim twigVarBlock
|
||||
HiLink twigCommentDelim twigComment
|
||||
HiLink twigRawDelim twig
|
||||
|
||||
HiLink twigSpecial Special
|
||||
HiLink twigOperator Normal
|
||||
HiLink twigRaw Normal
|
||||
HiLink twigTagBlock PreProc
|
||||
HiLink twigVarBlock PreProc
|
||||
HiLink twigStatement Statement
|
||||
HiLink twigFilter Function
|
||||
HiLink twigBlockName Function
|
||||
HiLink twigVariable Identifier
|
||||
HiLink twigString Constant
|
||||
HiLink twigNumber Constant
|
||||
HiLink twigComment Comment
|
||||
|
||||
delcommand HiLink
|
||||
endif
|
||||
|
||||
let b:current_syntax = "twig"
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
{
|
||||
"name" : "vim-twig",
|
||||
"version" : "0.1",
|
||||
"author" : "F. Gabriel Gosselin <gabriel@evidens.ca>",
|
||||
"maintainer" : "F. Gabriel Gosselin <gabriel@evidens.ca>",
|
||||
"repository": { "type" : "git", "url" : "git://github.com/beyondwords/vim-twig.git"},
|
||||
"dependencies" : {},
|
||||
"description" : "Support Twig template language"
|
||||
}
|
|
@ -1,377 +0,0 @@
|
|||
" colorizer.vim Colorize all text in the form #rrggbb or #rgb; autoload functions
|
||||
" Maintainer: lilydjwg <lilydjwg@gmail.com>
|
||||
" Version: 1.4.1
|
||||
" License: Vim License (see vim's :help license)
|
||||
"
|
||||
" See plugin/colorizer.vim for more info.
|
||||
|
||||
let s:keepcpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
function! s:FGforBG(bg) "{{{1
|
||||
" takes a 6hex color code and returns a matching color that is visible
|
||||
let pure = substitute(a:bg,'^#','','')
|
||||
let r = eval('0x'.pure[0].pure[1])
|
||||
let g = eval('0x'.pure[2].pure[3])
|
||||
let b = eval('0x'.pure[4].pure[5])
|
||||
let fgc = g:colorizer_fgcontrast
|
||||
if r*30 + g*59 + b*11 > 12000
|
||||
return s:predefined_fgcolors['dark'][fgc]
|
||||
else
|
||||
return s:predefined_fgcolors['light'][fgc]
|
||||
end
|
||||
endfunction
|
||||
|
||||
function! s:Rgb2xterm(color) "{{{1
|
||||
" selects the nearest xterm color for a rgb value like #FF0000
|
||||
let best_match=0
|
||||
let smallest_distance = 10000000000
|
||||
let r = eval('0x'.a:color[1].a:color[2])
|
||||
let g = eval('0x'.a:color[3].a:color[4])
|
||||
let b = eval('0x'.a:color[5].a:color[6])
|
||||
let colortable = s:GetXterm2rgbTable()
|
||||
for c in range(0,254)
|
||||
let d = pow(colortable[c][0]-r,2) + pow(colortable[c][1]-g,2) + pow(colortable[c][2]-b,2)
|
||||
if d<smallest_distance
|
||||
let smallest_distance = d
|
||||
let best_match = c
|
||||
endif
|
||||
endfor
|
||||
return best_match
|
||||
endfunction
|
||||
|
||||
"" the 6 value iterations in the xterm color cube {{{1
|
||||
let s:valuerange = [0x00, 0x5F, 0x87, 0xAF, 0xD7, 0xFF]
|
||||
|
||||
"" 16 basic colors {{{1
|
||||
let s:basic16 = [
|
||||
\ [0x00, 0x00, 0x00], [0xCD, 0x00, 0x00],
|
||||
\ [0x00, 0xCD, 0x00], [0xCD, 0xCD, 0x00],
|
||||
\ [0x00, 0x00, 0xEE], [0xCD, 0x00, 0xCD],
|
||||
\ [0x00, 0xCD, 0xCD], [0xE5, 0xE5, 0xE5],
|
||||
\ [0x7F, 0x7F, 0x7F], [0xFF, 0x00, 0x00],
|
||||
\ [0x00, 0xFF, 0x00], [0xFF, 0xFF, 0x00],
|
||||
\ [0x5C, 0x5C, 0xFF], [0xFF, 0x00, 0xFF],
|
||||
\ [0x00, 0xFF, 0xFF], [0xFF, 0xFF, 0xFF]]
|
||||
|
||||
function! s:Xterm2rgb(color) "{{{1
|
||||
" 16 basic colors
|
||||
let r = 0
|
||||
let g = 0
|
||||
let b = 0
|
||||
if a:color<16
|
||||
let r = s:basic16[a:color][0]
|
||||
let g = s:basic16[a:color][1]
|
||||
let b = s:basic16[a:color][2]
|
||||
endif
|
||||
|
||||
" color cube color
|
||||
if a:color>=16 && a:color<=232
|
||||
let l:color=a:color-16
|
||||
let r = s:valuerange[(l:color/36)%6]
|
||||
let g = s:valuerange[(l:color/6)%6]
|
||||
let b = s:valuerange[l:color%6]
|
||||
endif
|
||||
|
||||
" gray tone
|
||||
if a:color>=233 && a:color<=253
|
||||
let r=8+(a:color-232)*0x0a
|
||||
let g=r
|
||||
let b=r
|
||||
endif
|
||||
let rgb=[r,g,b]
|
||||
return rgb
|
||||
endfunction
|
||||
|
||||
function! s:SetMatcher(color, pat) "{{{1
|
||||
" "color" is the converted color and "pat" is what to highlight
|
||||
let group = 'Color' . strpart(a:color, 1)
|
||||
if !hlexists(group) || s:force_group_update
|
||||
let fg = g:colorizer_fgcontrast < 0 ? a:color : s:FGforBG(a:color)
|
||||
if &t_Co == 256
|
||||
exe 'hi '.group.' ctermfg='.s:Rgb2xterm(fg).' ctermbg='.s:Rgb2xterm(a:color)
|
||||
endif
|
||||
" Always set gui* as user may switch to GUI version and it's cheap
|
||||
exe 'hi '.group.' guifg='.fg.' guibg='.a:color
|
||||
endif
|
||||
if !exists("w:colormatches[a:pat]")
|
||||
let w:colormatches[a:pat] = matchadd(group, a:pat)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"ColorFinders {{{1
|
||||
function! s:HexCode(str, lineno) "{{{2
|
||||
let ret = []
|
||||
let place = 0
|
||||
let colorpat = '#[0-9A-Fa-f]\{3\}\>\|#[0-9A-Fa-f]\{6\}\>'
|
||||
while 1
|
||||
let foundcolor = matchstr(a:str, colorpat, place)
|
||||
if foundcolor == ''
|
||||
break
|
||||
endif
|
||||
let place = matchend(a:str, colorpat, place)
|
||||
let pat = foundcolor . '\>'
|
||||
if len(foundcolor) == 4
|
||||
let foundcolor = substitute(foundcolor, '[[:xdigit:]]', '&&', 'g')
|
||||
endif
|
||||
call add(ret, [foundcolor, pat])
|
||||
endwhile
|
||||
return ret
|
||||
endfunction
|
||||
|
||||
function! s:RgbColor(str, lineno) "{{{2
|
||||
let ret = []
|
||||
let place = 0
|
||||
let colorpat = '\<rgb(\v\s*(\d+(\%)?)\s*,\s*(\d+%(\2))\s*,\s*(\d+%(\2))\s*\)'
|
||||
while 1
|
||||
let foundcolor = matchlist(a:str, colorpat, place)
|
||||
if empty(foundcolor)
|
||||
break
|
||||
endif
|
||||
let place = matchend(a:str, colorpat, place)
|
||||
if foundcolor[2] == '%'
|
||||
let r = foundcolor[1] * 255 / 100
|
||||
let g = foundcolor[3] * 255 / 100
|
||||
let b = foundcolor[4] * 255 / 100
|
||||
else
|
||||
let r = foundcolor[1]
|
||||
let g = foundcolor[3]
|
||||
let b = foundcolor[4]
|
||||
endif
|
||||
if r > 255 || g > 255 || b > 255
|
||||
break
|
||||
endif
|
||||
let pat = printf('\<rgb(\v\s*%s\s*,\s*%s\s*,\s*%s\s*\)', foundcolor[1], foundcolor[3], foundcolor[4])
|
||||
if foundcolor[2] == '%'
|
||||
let pat = substitute(pat, '%', '\\%', 'g')
|
||||
endif
|
||||
let l:color = printf('#%02x%02x%02x', r, g, b)
|
||||
call add(ret, [l:color, pat])
|
||||
endwhile
|
||||
return ret
|
||||
endfunction
|
||||
|
||||
function! s:RgbaColor(str, lineno) "{{{2
|
||||
if has("gui_running")
|
||||
let bg = synIDattr(synIDtrans(hlID("Normal")), "bg")
|
||||
let bg_r = str2nr(bg[1].bg[2], 16)
|
||||
let bg_g = str2nr(bg[3].bg[4], 16)
|
||||
let bg_b = str2nr(bg[5].bg[6], 16)
|
||||
else
|
||||
" translucent colors would display incorrectly, so ignore the alpha value
|
||||
return s:RgbaColorForTerm(a:str, a:lineno)
|
||||
endif
|
||||
let ret = []
|
||||
let place = 0
|
||||
let colorpat = '\<rgba(\v\s*(\d+(\%)?)\s*,\s*(\d+%(\2))\s*,\s*(\d+%(\2))\s*,\s*(-?[.[:digit:]]+)\s*\)'
|
||||
while 1
|
||||
let foundcolor = matchlist(a:str, colorpat, place)
|
||||
if empty(foundcolor)
|
||||
break
|
||||
endif
|
||||
let place = matchend(a:str, colorpat, place)
|
||||
if foundcolor[2] == '%'
|
||||
let ar = foundcolor[1] * 255 / 100
|
||||
let ag = foundcolor[3] * 255 / 100
|
||||
let ab = foundcolor[4] * 255 / 100
|
||||
else
|
||||
let ar = foundcolor[1]
|
||||
let ag = foundcolor[3]
|
||||
let ab = foundcolor[4]
|
||||
endif
|
||||
if ar > 255 || ag > 255 || ab > 255
|
||||
break
|
||||
endif
|
||||
let alpha = str2float(foundcolor[5])
|
||||
if alpha < 0
|
||||
let alpha = 0.0
|
||||
elseif alpha > 1
|
||||
let alpha = 1.0
|
||||
endif
|
||||
let pat = printf('\<rgba(\v\s*%s\s*,\s*%s\s*,\s*%s\s*,\s*%s0*\s*\)', foundcolor[1], foundcolor[3], foundcolor[4], foundcolor[5])
|
||||
if foundcolor[2] == '%'
|
||||
let pat = substitute(pat, '%', '\\%', 'g')
|
||||
endif
|
||||
let r = float2nr(ceil(ar * alpha) + ceil(bg_r * (1 - alpha)))
|
||||
let g = float2nr(ceil(ag * alpha) + ceil(bg_g * (1 - alpha)))
|
||||
let b = float2nr(ceil(ab * alpha) + ceil(bg_b * (1 - alpha)))
|
||||
if r > 255
|
||||
let r = 255
|
||||
endif
|
||||
if g > 255
|
||||
let g = 255
|
||||
endif
|
||||
if b > 255
|
||||
let b = 255
|
||||
endif
|
||||
let l:color = printf('#%02x%02x%02x', r, g, b)
|
||||
call add(ret, [l:color, pat])
|
||||
endwhile
|
||||
return ret
|
||||
endfunction
|
||||
|
||||
function! s:RgbaColorForTerm(str, lineno) "{{{2
|
||||
let ret = []
|
||||
let place = 0
|
||||
let colorpat = '\<rgba(\v\s*(\d+(\%)?)\s*,\s*(\d+%(\2))\s*,\s*(\d+%(\2))\s*,\s*(-?[.[:digit:]]+)\s*\)'
|
||||
while 1
|
||||
let foundcolor = matchlist(a:str, colorpat, place)
|
||||
if empty(foundcolor)
|
||||
break
|
||||
endif
|
||||
let place = matchend(a:str, colorpat, place)
|
||||
if foundcolor[2] == '%'
|
||||
let ar = foundcolor[1] * 255 / 100
|
||||
let ag = foundcolor[3] * 255 / 100
|
||||
let ab = foundcolor[4] * 255 / 100
|
||||
else
|
||||
let ar = foundcolor[1]
|
||||
let ag = foundcolor[3]
|
||||
let ab = foundcolor[4]
|
||||
endif
|
||||
if ar > 255 || ag > 255 || ab > 255
|
||||
break
|
||||
endif
|
||||
let pat = printf('\<rgba(\v\s*%s\s*,\s*%s\s*,\s*%s\s*,\ze\s*(-?[.[:digit:]]+)\s*\)', foundcolor[1], foundcolor[3], foundcolor[4])
|
||||
if foundcolor[2] == '%'
|
||||
let pat = substitute(pat, '%', '\\%', 'g')
|
||||
endif
|
||||
let l:color = printf('#%02x%02x%02x', ar, ag, ab)
|
||||
call add(ret, [l:color, pat])
|
||||
endwhile
|
||||
return ret
|
||||
endfunction
|
||||
|
||||
function! s:PreviewColorInLine(where) "{{{1
|
||||
let line = getline(a:where)
|
||||
for Func in s:ColorFinder
|
||||
let ret = Func(line, a:where)
|
||||
" returned a list of a list: color as #rrggbb, text pattern to highlight
|
||||
for r in ret
|
||||
call s:SetMatcher(r[0], r[1])
|
||||
endfor
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! s:CursorMoved() "{{{1
|
||||
if !exists('w:colormatches')
|
||||
return
|
||||
endif
|
||||
if exists('b:colorizer_last_update')
|
||||
if b:colorizer_last_update == b:changedtick
|
||||
" Nothing changed
|
||||
return
|
||||
endif
|
||||
endif
|
||||
call s:PreviewColorInLine('.')
|
||||
let b:colorizer_last_update = b:changedtick
|
||||
endfunction
|
||||
|
||||
function! s:TextChanged() "{{{1
|
||||
if !exists('w:colormatches')
|
||||
return
|
||||
endif
|
||||
echomsg "TextChanged"
|
||||
call s:PreviewColorInLine('.')
|
||||
endfunction
|
||||
|
||||
function! colorizer#ColorHighlight(update, ...) "{{{1
|
||||
if exists('w:colormatches')
|
||||
if !a:update
|
||||
return
|
||||
endif
|
||||
call s:ClearMatches()
|
||||
endif
|
||||
let w:colormatches = {}
|
||||
if g:colorizer_fgcontrast != s:saved_fgcontrast || (exists("a:1") && a:1 == '!')
|
||||
let s:force_group_update = 1
|
||||
endif
|
||||
for i in range(1, line("$"))
|
||||
call s:PreviewColorInLine(i)
|
||||
endfor
|
||||
let s:force_group_update = 0
|
||||
let s:saved_fgcontrast = g:colorizer_fgcontrast
|
||||
augroup Colorizer
|
||||
au!
|
||||
if exists('##TextChanged')
|
||||
autocmd TextChanged * silent call s:TextChanged()
|
||||
if v:version > 704 || v:version == 704 && has('patch143')
|
||||
autocmd TextChangedI * silent call s:TextChanged()
|
||||
else
|
||||
" TextChangedI does not work as expected
|
||||
autocmd CursorMovedI * silent call s:CursorMoved()
|
||||
endif
|
||||
else
|
||||
autocmd CursorMoved,CursorMovedI * silent call s:CursorMoved()
|
||||
endif
|
||||
" rgba handles differently, so need updating
|
||||
autocmd GUIEnter * silent call colorizer#ColorHighlight(1)
|
||||
autocmd BufRead * silent call colorizer#ColorHighlight(1)
|
||||
autocmd WinEnter * silent call colorizer#ColorHighlight(1)
|
||||
autocmd ColorScheme * let s:force_group_update=1 | silent call colorizer#ColorHighlight(1)
|
||||
augroup END
|
||||
endfunction
|
||||
|
||||
function! colorizer#ColorClear() "{{{1
|
||||
augroup Colorizer
|
||||
au!
|
||||
augroup END
|
||||
let save_tab = tabpagenr()
|
||||
let save_win = winnr()
|
||||
tabdo windo call s:ClearMatches()
|
||||
exe 'tabn '.save_tab
|
||||
exe save_win . 'wincmd w'
|
||||
endfunction
|
||||
|
||||
function! s:ClearMatches() "{{{1
|
||||
if !exists('w:colormatches')
|
||||
return
|
||||
endif
|
||||
for i in values(w:colormatches)
|
||||
call matchdelete(i)
|
||||
endfor
|
||||
unlet w:colormatches
|
||||
endfunction
|
||||
|
||||
function! colorizer#ColorToggle() "{{{1
|
||||
if exists('#Colorizer#BufRead')
|
||||
call colorizer#ColorClear()
|
||||
echomsg 'Disabled color code highlighting.'
|
||||
else
|
||||
call colorizer#ColorHighlight(0)
|
||||
echomsg 'Enabled color code highlighting.'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:GetXterm2rgbTable()
|
||||
if !exists('s:table_xterm2rgb')
|
||||
let s:table_xterm2rgb = []
|
||||
for c in range(0, 254)
|
||||
let s:color = s:Xterm2rgb(c)
|
||||
call add(s:table_xterm2rgb, s:color)
|
||||
endfor
|
||||
endif
|
||||
return s:table_xterm2rgb
|
||||
endfun
|
||||
|
||||
" Setups {{{1
|
||||
let s:ColorFinder = [function('s:HexCode'), function('s:RgbColor'), function('s:RgbaColor')]
|
||||
let s:force_group_update = 0
|
||||
let s:predefined_fgcolors = {}
|
||||
let s:predefined_fgcolors['dark'] = ['#444444', '#222222', '#000000']
|
||||
let s:predefined_fgcolors['light'] = ['#bbbbbb', '#dddddd', '#ffffff']
|
||||
if !exists("g:colorizer_fgcontrast")
|
||||
" Default to black / white
|
||||
let g:colorizer_fgcontrast = len(s:predefined_fgcolors['dark']) - 1
|
||||
elseif g:colorizer_fgcontrast >= len(s:predefined_fgcolors['dark'])
|
||||
echohl WarningMsg
|
||||
echo "g:colorizer_fgcontrast value invalid, using default"
|
||||
echohl None
|
||||
let g:colorizer_fgcontrast = len(s:predefined_fgcolors['dark']) - 1
|
||||
endif
|
||||
let s:saved_fgcontrast = g:colorizer_fgcontrast
|
||||
|
||||
" Restoration and modelines {{{1
|
||||
let &cpo = s:keepcpo
|
||||
unlet s:keepcpo
|
||||
" vim:ft=vim:fdm=marker:fmr={{{,}}}:
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,319 +0,0 @@
|
|||
# FILE: autoload/conque_term/conque_globals.py
|
||||
# AUTHOR: Nico Raffo <nicoraffo@gmail.com>
|
||||
# WEBSITE: http://conque.googlecode.com
|
||||
# MODIFIED: 2011-04-04
|
||||
# VERSION: 2.1, for Vim 7.0
|
||||
# LICENSE:
|
||||
# Conque - Vim terminal/console emulator
|
||||
# Copyright (C) 2009-2011 Nico Raffo
|
||||
#
|
||||
# MIT License
|
||||
#
|
||||
# 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.
|
||||
|
||||
"""Common global constants and functions for Conque."""
|
||||
|
||||
import sys
|
||||
import re
|
||||
|
||||
|
||||
|
||||
|
||||
# PYTHON VERSION
|
||||
CONQUE_PYTHON_VERSION = sys.version_info[0]
|
||||
|
||||
# Encoding
|
||||
|
||||
try:
|
||||
# Vim's character encoding
|
||||
import vim
|
||||
CONQUE_VIM_ENCODING = vim.eval('&encoding')
|
||||
|
||||
except:
|
||||
CONQUE_VIM_ENCODING = 'utf-8'
|
||||
|
||||
|
||||
def u(str_val, str_encoding='utf-8', errors='strict'):
|
||||
""" Foolhardy attempt to make unicode string syntax compatible with both python 2 and 3. """
|
||||
|
||||
if not str_val:
|
||||
str_val = ''
|
||||
|
||||
if CONQUE_PYTHON_VERSION == 3:
|
||||
return str_val
|
||||
|
||||
else:
|
||||
return unicode(str_val, str_encoding, errors)
|
||||
|
||||
def uchr(str):
|
||||
""" Foolhardy attempt to make unicode string syntax compatible with both python 2 and 3. """
|
||||
|
||||
if CONQUE_PYTHON_VERSION == 3:
|
||||
return chr(str)
|
||||
|
||||
else:
|
||||
return unichr(str)
|
||||
|
||||
|
||||
# Logging
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Unix escape sequence settings
|
||||
|
||||
CONQUE_CTL = {
|
||||
1: 'soh', # start of heading
|
||||
2: 'stx', # start of text
|
||||
7: 'bel', # bell
|
||||
8: 'bs', # backspace
|
||||
9: 'tab', # tab
|
||||
10: 'nl', # new line
|
||||
13: 'cr', # carriage return
|
||||
14: 'so', # shift out
|
||||
15: 'si' # shift in
|
||||
}
|
||||
# 11 : 'vt', # vertical tab
|
||||
# 12 : 'ff', # form feed
|
||||
|
||||
# Escape sequences
|
||||
CONQUE_ESCAPE = {
|
||||
'm': 'font',
|
||||
'J': 'clear_screen',
|
||||
'K': 'clear_line',
|
||||
'@': 'add_spaces',
|
||||
'A': 'cursor_up',
|
||||
'B': 'cursor_down',
|
||||
'C': 'cursor_right',
|
||||
'D': 'cursor_left',
|
||||
'G': 'cursor_to_column',
|
||||
'H': 'cursor',
|
||||
'P': 'delete_chars',
|
||||
'f': 'cursor',
|
||||
'g': 'tab_clear',
|
||||
'r': 'set_coords',
|
||||
'h': 'set',
|
||||
'l': 'reset'
|
||||
}
|
||||
# 'L': 'insert_lines',
|
||||
# 'M': 'delete_lines',
|
||||
# 'd': 'cusor_vpos',
|
||||
|
||||
# Alternate escape sequences, no [
|
||||
CONQUE_ESCAPE_PLAIN = {
|
||||
'D': 'scroll_up',
|
||||
'E': 'next_line',
|
||||
'H': 'set_tab',
|
||||
'M': 'scroll_down'
|
||||
}
|
||||
# 'N': 'single_shift_2',
|
||||
# 'O': 'single_shift_3',
|
||||
# '=': 'alternate_keypad',
|
||||
# '>': 'numeric_keypad',
|
||||
# '7': 'save_cursor',
|
||||
# '8': 'restore_cursor',
|
||||
|
||||
# Character set escape sequences, with "("
|
||||
CONQUE_ESCAPE_CHARSET = {
|
||||
'A': 'uk',
|
||||
'B': 'us',
|
||||
'0': 'graphics'
|
||||
}
|
||||
|
||||
# Uber alternate escape sequences, with # or ?
|
||||
CONQUE_ESCAPE_QUESTION = {
|
||||
'1h': 'new_line_mode',
|
||||
'3h': '132_cols',
|
||||
'4h': 'smooth_scrolling',
|
||||
'5h': 'reverse_video',
|
||||
'6h': 'relative_origin',
|
||||
'7h': 'set_auto_wrap',
|
||||
'8h': 'set_auto_repeat',
|
||||
'9h': 'set_interlacing_mode',
|
||||
'1l': 'set_cursor_key',
|
||||
'2l': 'set_vt52',
|
||||
'3l': '80_cols',
|
||||
'4l': 'set_jump_scrolling',
|
||||
'5l': 'normal_video',
|
||||
'6l': 'absolute_origin',
|
||||
'7l': 'reset_auto_wrap',
|
||||
'8l': 'reset_auto_repeat',
|
||||
'9l': 'reset_interlacing_mode'
|
||||
}
|
||||
|
||||
CONQUE_ESCAPE_HASH = {
|
||||
'8': 'screen_alignment_test'
|
||||
}
|
||||
# '3': 'double_height_top',
|
||||
# '4': 'double_height_bottom',
|
||||
# '5': 'single_height_single_width',
|
||||
# '6': 'single_height_double_width',
|
||||
|
||||
CONQUE_GRAPHICS_SET = [
|
||||
0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
|
||||
0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
|
||||
0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
|
||||
0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
|
||||
0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
|
||||
0x0028, 0x0029, 0x002A, 0x2192, 0x2190, 0x2191, 0x2193, 0x002F,
|
||||
0x2588, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
|
||||
0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
|
||||
0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
|
||||
0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
|
||||
0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
|
||||
0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x00A0,
|
||||
0x25C6, 0x2592, 0x2409, 0x240C, 0x240D, 0x240A, 0x00B0, 0x00B1,
|
||||
0x2591, 0x240B, 0x2518, 0x2510, 0x250C, 0x2514, 0x253C, 0xF800,
|
||||
0xF801, 0x2500, 0xF803, 0xF804, 0x251C, 0x2524, 0x2534, 0x252C,
|
||||
0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00B7, 0x007F,
|
||||
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
|
||||
0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F,
|
||||
0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
|
||||
0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F,
|
||||
0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
|
||||
0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
|
||||
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
|
||||
0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF,
|
||||
0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7,
|
||||
0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
|
||||
0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7,
|
||||
0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF,
|
||||
0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7,
|
||||
0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
|
||||
0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7,
|
||||
0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF
|
||||
]
|
||||
|
||||
# Font codes
|
||||
CONQUE_FONT = {
|
||||
0: {'description': 'Normal (default)', 'attributes': {'cterm': 'NONE', 'ctermfg': 'NONE', 'ctermbg': 'NONE', 'gui': 'NONE', 'guifg': 'NONE', 'guibg': 'NONE'}, 'normal': True},
|
||||
1: {'description': 'Bold', 'attributes': {'cterm': 'BOLD', 'gui': 'BOLD'}, 'normal': False},
|
||||
4: {'description': 'Underlined', 'attributes': {'cterm': 'UNDERLINE', 'gui': 'UNDERLINE'}, 'normal': False},
|
||||
5: {'description': 'Blink (appears as Bold)', 'attributes': {'cterm': 'BOLD', 'gui': 'BOLD'}, 'normal': False},
|
||||
7: {'description': 'Inverse', 'attributes': {'cterm': 'REVERSE', 'gui': 'REVERSE'}, 'normal': False},
|
||||
8: {'description': 'Invisible (hidden)', 'attributes': {'ctermfg': '0', 'ctermbg': '0', 'guifg': '#000000', 'guibg': '#000000'}, 'normal': False},
|
||||
22: {'description': 'Normal (neither bold nor faint)', 'attributes': {'cterm': 'NONE', 'gui': 'NONE'}, 'normal': True},
|
||||
24: {'description': 'Not underlined', 'attributes': {'cterm': 'NONE', 'gui': 'NONE'}, 'normal': True},
|
||||
25: {'description': 'Steady (not blinking)', 'attributes': {'cterm': 'NONE', 'gui': 'NONE'}, 'normal': True},
|
||||
27: {'description': 'Positive (not inverse)', 'attributes': {'cterm': 'NONE', 'gui': 'NONE'}, 'normal': True},
|
||||
28: {'description': 'Visible (not hidden)', 'attributes': {'ctermfg': 'NONE', 'ctermbg': 'NONE', 'guifg': 'NONE', 'guibg': 'NONE'}, 'normal': True},
|
||||
30: {'description': 'Set foreground color to Black', 'attributes': {'ctermfg': '16', 'guifg': '#000000'}, 'normal': False},
|
||||
31: {'description': 'Set foreground color to Red', 'attributes': {'ctermfg': '1', 'guifg': '#ff0000'}, 'normal': False},
|
||||
32: {'description': 'Set foreground color to Green', 'attributes': {'ctermfg': '2', 'guifg': '#00ff00'}, 'normal': False},
|
||||
33: {'description': 'Set foreground color to Yellow', 'attributes': {'ctermfg': '3', 'guifg': '#ffff00'}, 'normal': False},
|
||||
34: {'description': 'Set foreground color to Blue', 'attributes': {'ctermfg': '4', 'guifg': '#0000ff'}, 'normal': False},
|
||||
35: {'description': 'Set foreground color to Magenta', 'attributes': {'ctermfg': '5', 'guifg': '#990099'}, 'normal': False},
|
||||
36: {'description': 'Set foreground color to Cyan', 'attributes': {'ctermfg': '6', 'guifg': '#009999'}, 'normal': False},
|
||||
37: {'description': 'Set foreground color to White', 'attributes': {'ctermfg': '7', 'guifg': '#ffffff'}, 'normal': False},
|
||||
39: {'description': 'Set foreground color to default (original)', 'attributes': {'ctermfg': 'NONE', 'guifg': 'NONE'}, 'normal': True},
|
||||
40: {'description': 'Set background color to Black', 'attributes': {'ctermbg': '16', 'guibg': '#000000'}, 'normal': False},
|
||||
41: {'description': 'Set background color to Red', 'attributes': {'ctermbg': '1', 'guibg': '#ff0000'}, 'normal': False},
|
||||
42: {'description': 'Set background color to Green', 'attributes': {'ctermbg': '2', 'guibg': '#00ff00'}, 'normal': False},
|
||||
43: {'description': 'Set background color to Yellow', 'attributes': {'ctermbg': '3', 'guibg': '#ffff00'}, 'normal': False},
|
||||
44: {'description': 'Set background color to Blue', 'attributes': {'ctermbg': '4', 'guibg': '#0000ff'}, 'normal': False},
|
||||
45: {'description': 'Set background color to Magenta', 'attributes': {'ctermbg': '5', 'guibg': '#990099'}, 'normal': False},
|
||||
46: {'description': 'Set background color to Cyan', 'attributes': {'ctermbg': '6', 'guibg': '#009999'}, 'normal': False},
|
||||
47: {'description': 'Set background color to White', 'attributes': {'ctermbg': '7', 'guibg': '#ffffff'}, 'normal': False},
|
||||
49: {'description': 'Set background color to default (original).', 'attributes': {'ctermbg': 'NONE', 'guibg': 'NONE'}, 'normal': True},
|
||||
90: {'description': 'Set foreground color to Black', 'attributes': {'ctermfg': '8', 'guifg': '#000000'}, 'normal': False},
|
||||
91: {'description': 'Set foreground color to Red', 'attributes': {'ctermfg': '9', 'guifg': '#ff0000'}, 'normal': False},
|
||||
92: {'description': 'Set foreground color to Green', 'attributes': {'ctermfg': '10', 'guifg': '#00ff00'}, 'normal': False},
|
||||
93: {'description': 'Set foreground color to Yellow', 'attributes': {'ctermfg': '11', 'guifg': '#ffff00'}, 'normal': False},
|
||||
94: {'description': 'Set foreground color to Blue', 'attributes': {'ctermfg': '12', 'guifg': '#0000ff'}, 'normal': False},
|
||||
95: {'description': 'Set foreground color to Magenta', 'attributes': {'ctermfg': '13', 'guifg': '#990099'}, 'normal': False},
|
||||
96: {'description': 'Set foreground color to Cyan', 'attributes': {'ctermfg': '14', 'guifg': '#009999'}, 'normal': False},
|
||||
97: {'description': 'Set foreground color to White', 'attributes': {'ctermfg': '15', 'guifg': '#ffffff'}, 'normal': False},
|
||||
100: {'description': 'Set background color to Black', 'attributes': {'ctermbg': '8', 'guibg': '#000000'}, 'normal': False},
|
||||
101: {'description': 'Set background color to Red', 'attributes': {'ctermbg': '9', 'guibg': '#ff0000'}, 'normal': False},
|
||||
102: {'description': 'Set background color to Green', 'attributes': {'ctermbg': '10', 'guibg': '#00ff00'}, 'normal': False},
|
||||
103: {'description': 'Set background color to Yellow', 'attributes': {'ctermbg': '11', 'guibg': '#ffff00'}, 'normal': False},
|
||||
104: {'description': 'Set background color to Blue', 'attributes': {'ctermbg': '12', 'guibg': '#0000ff'}, 'normal': False},
|
||||
105: {'description': 'Set background color to Magenta', 'attributes': {'ctermbg': '13', 'guibg': '#990099'}, 'normal': False},
|
||||
106: {'description': 'Set background color to Cyan', 'attributes': {'ctermbg': '14', 'guibg': '#009999'}, 'normal': False},
|
||||
107: {'description': 'Set background color to White', 'attributes': {'ctermbg': '15', 'guibg': '#ffffff'}, 'normal': False}
|
||||
}
|
||||
|
||||
|
||||
# regular expression matching (almost) all control sequences
|
||||
CONQUE_SEQ_REGEX = re.compile("(\x1b\[?\??#?[0-9;]*[a-zA-Z0-9@=>]|\x1b\][0-9];.*?\x07|[\x01-\x0f]|\x1b\([AB0])")
|
||||
CONQUE_SEQ_REGEX_CTL = re.compile("^[\x01-\x0f]$")
|
||||
CONQUE_SEQ_REGEX_CSI = re.compile("^\x1b\[")
|
||||
CONQUE_SEQ_REGEX_TITLE = re.compile("^\x1b\]")
|
||||
CONQUE_SEQ_REGEX_HASH = re.compile("^\x1b#")
|
||||
CONQUE_SEQ_REGEX_ESC = re.compile("^\x1b.$")
|
||||
CONQUE_SEQ_REGEX_CHAR = re.compile("^\x1b[()]")
|
||||
|
||||
# match table output
|
||||
CONQUE_TABLE_OUTPUT = re.compile("^\s*\|\s.*\s\|\s*$|^\s*\+[=+-]+\+\s*$")
|
||||
|
||||
# basic terminal colors
|
||||
CONQUE_COLOR_SEQUENCE = (
|
||||
'000', '009', '090', '099', '900', '909', '990', '999',
|
||||
'000', '00f', '0f0', '0ff', 'f00', 'f0f', 'ff0', 'fff'
|
||||
)
|
||||
|
||||
|
||||
# Windows subprocess constants
|
||||
|
||||
# shared memory size
|
||||
CONQUE_SOLE_BUFFER_LENGTH = 1000
|
||||
CONQUE_SOLE_INPUT_SIZE = 1000
|
||||
CONQUE_SOLE_STATS_SIZE = 1000
|
||||
CONQUE_SOLE_COMMANDS_SIZE = 255
|
||||
CONQUE_SOLE_RESCROLL_SIZE = 255
|
||||
CONQUE_SOLE_RESIZE_SIZE = 255
|
||||
|
||||
# interval of screen redraw
|
||||
# larger number means less frequent
|
||||
CONQUE_SOLE_SCREEN_REDRAW = 50
|
||||
|
||||
# interval of full buffer redraw
|
||||
# larger number means less frequent
|
||||
CONQUE_SOLE_BUFFER_REDRAW = 500
|
||||
|
||||
# interval of full output bucket replacement
|
||||
# larger number means less frequent, 1 = every time
|
||||
CONQUE_SOLE_MEM_REDRAW = 1000
|
||||
|
||||
# maximum number of lines with terminal colors
|
||||
# ignored if g:ConqueTerm_Color = 2
|
||||
CONQUE_MAX_SYNTAX_LINES = 200
|
||||
|
||||
# windows input splitting on special keys
|
||||
CONQUE_WIN32_REGEX_VK = re.compile("(\x1b\[[0-9;]+VK)")
|
||||
|
||||
# windows attribute string splitting
|
||||
CONQUE_WIN32_REGEX_ATTR = re.compile("((.)\\2*)", re.DOTALL)
|
||||
|
||||
# special key attributes
|
||||
CONQUE_VK_ATTR_CTRL_PRESSED = u('1024')
|
||||
|
||||
|
|
@ -1,230 +0,0 @@
|
|||
# FILE: autoload/conque_term/conque_screen.py
|
||||
# AUTHOR: Nico Raffo <nicoraffo@gmail.com>
|
||||
# WEBSITE: http://conque.googlecode.com
|
||||
# MODIFIED: 2011-04-04
|
||||
# VERSION: 2.1, for Vim 7.0
|
||||
# LICENSE:
|
||||
# Conque - Vim terminal/console emulator
|
||||
# Copyright (C) 2009-2011 Nico Raffo
|
||||
#
|
||||
# MIT License
|
||||
#
|
||||
# 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.
|
||||
|
||||
"""
|
||||
ConqueScreen is an extention of the vim.current.buffer object
|
||||
|
||||
Unix terminal escape sequences usually reference line numbers relative to the
|
||||
top of the visible screen. However the visible portion of the Vim buffer
|
||||
representing the terminal probably doesn't start at the first line of the
|
||||
buffer.
|
||||
|
||||
The ConqueScreen class allows access to the Vim buffer with screen-relative
|
||||
line numbering. And handles a few other related tasks, such as setting the
|
||||
correct cursor position.
|
||||
|
||||
E.g.:
|
||||
s = ConqueScreen()
|
||||
...
|
||||
s[5] = 'Set 5th line in terminal to this line'
|
||||
s.append('Add new line to terminal')
|
||||
s[5] = 'Since previous append() command scrolled the terminal down, this is a different line than first cb[5] call'
|
||||
|
||||
"""
|
||||
|
||||
import vim
|
||||
|
||||
|
||||
class ConqueScreen(object):
|
||||
|
||||
# the buffer
|
||||
buffer = None
|
||||
|
||||
# screen and scrolling regions
|
||||
screen_top = 1
|
||||
|
||||
# screen width
|
||||
screen_width = 80
|
||||
screen_height = 80
|
||||
|
||||
# char encoding for vim buffer
|
||||
screen_encoding = 'utf-8'
|
||||
|
||||
|
||||
def __init__(self):
|
||||
""" Initialize screen size and character encoding. """
|
||||
|
||||
self.buffer = vim.current.buffer
|
||||
|
||||
# initialize screen size
|
||||
self.screen_top = 1
|
||||
self.screen_width = vim.current.window.width
|
||||
self.screen_height = vim.current.window.height
|
||||
|
||||
# save screen character encoding type
|
||||
self.screen_encoding = vim.eval('&fileencoding')
|
||||
|
||||
|
||||
def __len__(self):
|
||||
""" Define the len() function for ConqueScreen objects. """
|
||||
return len(self.buffer)
|
||||
|
||||
|
||||
def __getitem__(self, key):
|
||||
""" Define value access for ConqueScreen objects. """
|
||||
buffer_line = self.get_real_idx(key)
|
||||
|
||||
# if line is past buffer end, add lines to buffer
|
||||
if buffer_line >= len(self.buffer):
|
||||
for i in range(len(self.buffer), buffer_line + 1):
|
||||
self.append(' ')
|
||||
|
||||
return u(self.buffer[buffer_line], 'utf-8')
|
||||
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
""" Define value assignments for ConqueScreen objects. """
|
||||
buffer_line = self.get_real_idx(key)
|
||||
|
||||
if CONQUE_PYTHON_VERSION == 2:
|
||||
val = value.encode(self.screen_encoding)
|
||||
else:
|
||||
# XXX / Vim's python3 interface doesn't accept bytes object
|
||||
val = str(value)
|
||||
|
||||
# if line is past end of screen, append
|
||||
if buffer_line == len(self.buffer):
|
||||
self.buffer.append(val)
|
||||
else:
|
||||
self.buffer[buffer_line] = val
|
||||
|
||||
|
||||
def __delitem__(self, key):
|
||||
""" Define value deletion for ConqueScreen objects. """
|
||||
del self.buffer[self.screen_top + key - 2]
|
||||
|
||||
|
||||
def append(self, value):
|
||||
""" Define value appending for ConqueScreen objects. """
|
||||
|
||||
if len(self.buffer) > self.screen_top + self.screen_height - 1:
|
||||
self.buffer[len(self.buffer) - 1] = value
|
||||
else:
|
||||
self.buffer.append(value)
|
||||
|
||||
if len(self.buffer) > self.screen_top + self.screen_height - 1:
|
||||
self.screen_top += 1
|
||||
|
||||
if vim.current.buffer.number == self.buffer.number:
|
||||
vim.command('normal! G')
|
||||
|
||||
|
||||
def insert(self, line, value):
|
||||
""" Define value insertion for ConqueScreen objects. """
|
||||
|
||||
l = self.screen_top + line - 2
|
||||
self.buffer.append(value, l)
|
||||
|
||||
|
||||
def get_top(self):
|
||||
""" Get the Vim line number representing the top of the visible terminal. """
|
||||
return self.screen_top
|
||||
|
||||
|
||||
def get_real_idx(self, line):
|
||||
""" Get the zero index Vim line number corresponding to the provided screen line. """
|
||||
return (self.screen_top + line - 2)
|
||||
|
||||
|
||||
def get_buffer_line(self, line):
|
||||
""" Get the Vim line number corresponding to the provided screen line. """
|
||||
return (self.screen_top + line - 1)
|
||||
|
||||
|
||||
def set_screen_width(self, width):
|
||||
""" Set the screen width. """
|
||||
self.screen_width = width
|
||||
|
||||
|
||||
def clear(self):
|
||||
""" Clear the screen. Does not clear the buffer, just scrolls down past all text. """
|
||||
|
||||
self.screen_width = width
|
||||
self.buffer.append(' ')
|
||||
vim.command('normal! Gzt')
|
||||
self.screen_top = len(self.buffer)
|
||||
|
||||
|
||||
def set_cursor(self, line, column):
|
||||
""" Set cursor position. """
|
||||
|
||||
# figure out line
|
||||
buffer_line = self.screen_top + line - 1
|
||||
if buffer_line > len(self.buffer):
|
||||
for l in range(len(self.buffer) - 1, buffer_line):
|
||||
self.buffer.append('')
|
||||
|
||||
# figure out column
|
||||
real_column = column
|
||||
if len(self.buffer[buffer_line - 1]) < real_column:
|
||||
self.buffer[buffer_line - 1] = self.buffer[buffer_line - 1] + ' ' * (real_column - len(self.buffer[buffer_line - 1]))
|
||||
|
||||
if not CONQUE_FAST_MODE:
|
||||
# set cursor at byte index of real_column'th character
|
||||
vim.command('call cursor(' + str(buffer_line) + ', byteidx(getline(' + str(buffer_line) + '), ' + str(real_column) + '))')
|
||||
|
||||
else:
|
||||
# old version
|
||||
# python version is occasionally grumpy
|
||||
try:
|
||||
vim.current.window.cursor = (buffer_line, real_column - 1)
|
||||
except:
|
||||
vim.command('call cursor(' + str(buffer_line) + ', ' + str(real_column) + ')')
|
||||
|
||||
|
||||
def reset_size(self, line):
|
||||
""" Change screen size """
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# save cursor line number
|
||||
buffer_line = self.screen_top + line
|
||||
|
||||
# reset screen size
|
||||
self.screen_width = vim.current.window.width
|
||||
self.screen_height = vim.current.window.height
|
||||
self.screen_top = len(self.buffer) - vim.current.window.height + 1
|
||||
if self.screen_top < 1:
|
||||
self.screen_top = 1
|
||||
|
||||
|
||||
# align bottom of buffer to bottom of screen
|
||||
vim.command('normal! ' + str(self.screen_height) + 'kG')
|
||||
|
||||
# return new relative line number
|
||||
return (buffer_line - self.screen_top)
|
||||
|
||||
|
||||
def align(self):
|
||||
""" align bottom of buffer to bottom of screen """
|
||||
vim.command('normal! ' + str(self.screen_height) + 'kG')
|
||||
|
||||
|
|
@ -1,458 +0,0 @@
|
|||
# FILE: autoload/conque_term/conque_sole.py
|
||||
# AUTHOR: Nico Raffo <nicoraffo@gmail.com>
|
||||
# WEBSITE: http://conque.googlecode.com
|
||||
# MODIFIED: 2011-04-04
|
||||
# VERSION: 2.1, for Vim 7.0
|
||||
# LICENSE:
|
||||
# Conque - Vim terminal/console emulator
|
||||
# Copyright (C) 2009-2011 Nico Raffo
|
||||
#
|
||||
# MIT License
|
||||
#
|
||||
# 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.
|
||||
|
||||
"""
|
||||
Windows Console Emulator
|
||||
|
||||
This is the main interface to the Windows emulator. It reads new output from the background console
|
||||
and updates the Vim buffer.
|
||||
"""
|
||||
|
||||
import vim
|
||||
|
||||
|
||||
class ConqueSole(Conque):
|
||||
|
||||
window_top = None
|
||||
window_bottom = None
|
||||
|
||||
color_cache = {}
|
||||
attribute_cache = {}
|
||||
color_mode = None
|
||||
color_conceals = {}
|
||||
|
||||
buffer = None
|
||||
encoding = None
|
||||
|
||||
# counters for periodic rendering
|
||||
buffer_redraw_ct = 1
|
||||
screen_redraw_ct = 1
|
||||
|
||||
# line offset, shifts output down
|
||||
offset = 0
|
||||
|
||||
|
||||
def open(self):
|
||||
""" Start command and initialize this instance
|
||||
|
||||
Arguments:
|
||||
command - Command string, e.g. "Powershell.exe"
|
||||
options - Dictionary of config options
|
||||
python_exe - Path to the python.exe executable. Usually C:\PythonXX\python.exe
|
||||
communicator_py - Path to subprocess controller script in user's vimfiles directory
|
||||
|
||||
"""
|
||||
# get arguments
|
||||
command = vim.eval('command')
|
||||
options = vim.eval('options')
|
||||
python_exe = vim.eval('py_exe')
|
||||
communicator_py = vim.eval('py_vim')
|
||||
|
||||
# init size
|
||||
self.columns = vim.current.window.width
|
||||
self.lines = vim.current.window.height
|
||||
self.window_top = 0
|
||||
self.window_bottom = vim.current.window.height - 1
|
||||
|
||||
# color mode
|
||||
self.color_mode = vim.eval('g:ConqueTerm_ColorMode')
|
||||
|
||||
# line offset
|
||||
self.offset = int(options['offset'])
|
||||
|
||||
# init color
|
||||
self.enable_colors = options['color'] and not CONQUE_FAST_MODE
|
||||
|
||||
# open command
|
||||
self.proc = ConqueSoleWrapper()
|
||||
self.proc.open(command, self.lines, self.columns, python_exe, communicator_py, options)
|
||||
|
||||
self.buffer = vim.current.buffer
|
||||
self.screen_encoding = vim.eval('&fileencoding')
|
||||
|
||||
|
||||
def read(self, timeout=1, set_cursor=True, return_output=False, update_buffer=True):
|
||||
""" Read from console and update Vim buffer. """
|
||||
|
||||
try:
|
||||
stats = self.proc.get_stats()
|
||||
|
||||
if not stats:
|
||||
return
|
||||
|
||||
# disable screen and buffer redraws in fast mode
|
||||
if not CONQUE_FAST_MODE:
|
||||
self.buffer_redraw_ct += 1
|
||||
self.screen_redraw_ct += 1
|
||||
|
||||
update_top = 0
|
||||
update_bottom = 0
|
||||
lines = []
|
||||
|
||||
# full buffer redraw, our favorite!
|
||||
#if self.buffer_redraw_ct == CONQUE_SOLE_BUFFER_REDRAW:
|
||||
# self.buffer_redraw_ct = 0
|
||||
# update_top = 0
|
||||
# update_bottom = stats['top_offset'] + self.lines
|
||||
# (lines, attributes) = self.proc.read(update_top, update_bottom)
|
||||
# if return_output:
|
||||
# output = self.get_new_output(lines, update_top, stats)
|
||||
# if update_buffer:
|
||||
# for i in range(update_top, update_bottom + 1):
|
||||
# if CONQUE_FAST_MODE:
|
||||
# self.plain_text(i, lines[i], None, stats)
|
||||
# else:
|
||||
# self.plain_text(i, lines[i], attributes[i], stats)
|
||||
|
||||
# full screen redraw
|
||||
if stats['cursor_y'] + 1 != self.l or stats['top_offset'] != self.window_top or self.screen_redraw_ct >= CONQUE_SOLE_SCREEN_REDRAW:
|
||||
|
||||
self.screen_redraw_ct = 0
|
||||
update_top = self.window_top
|
||||
update_bottom = max([stats['top_offset'] + self.lines + 1, stats['cursor_y']])
|
||||
(lines, attributes) = self.proc.read(update_top, update_bottom - update_top + 1)
|
||||
if return_output:
|
||||
output = self.get_new_output(lines, update_top, stats)
|
||||
if update_buffer:
|
||||
for i in range(update_top, update_bottom + 1):
|
||||
if CONQUE_FAST_MODE:
|
||||
self.plain_text(i, lines[i - update_top], None, stats)
|
||||
else:
|
||||
self.plain_text(i, lines[i - update_top], attributes[i - update_top], stats)
|
||||
|
||||
|
||||
# single line redraw
|
||||
else:
|
||||
update_top = stats['cursor_y']
|
||||
(lines, attributes) = self.proc.read(update_top, 1)
|
||||
if return_output:
|
||||
output = self.get_new_output(lines, update_top, stats)
|
||||
if update_buffer:
|
||||
if lines[0].rstrip() != u(self.buffer[update_top].rstrip()):
|
||||
if CONQUE_FAST_MODE:
|
||||
self.plain_text(update_top, lines[0], None, stats)
|
||||
else:
|
||||
self.plain_text(update_top, lines[0], attributes[0], stats)
|
||||
|
||||
|
||||
# reset current position
|
||||
self.window_top = stats['top_offset']
|
||||
self.l = stats['cursor_y'] + 1
|
||||
self.c = stats['cursor_x'] + 1
|
||||
|
||||
# reposition cursor if this seems plausible
|
||||
if set_cursor:
|
||||
self.set_cursor(self.l, self.c)
|
||||
|
||||
if return_output:
|
||||
return output
|
||||
|
||||
except:
|
||||
|
||||
pass
|
||||
|
||||
|
||||
def get_new_output(self, lines, update_top, stats):
|
||||
""" Calculate the "new" output from this read. Fake but useful """
|
||||
|
||||
if not (stats['cursor_y'] + 1 > self.l or (stats['cursor_y'] + 1 == self.l and stats['cursor_x'] + 1 > self.c)):
|
||||
return ""
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try:
|
||||
num_to_return = stats['cursor_y'] - self.l + 2
|
||||
|
||||
lines = lines[self.l - update_top - 1:]
|
||||
|
||||
|
||||
new_output = []
|
||||
|
||||
# first line
|
||||
new_output.append(lines[0][self.c - 1:].rstrip())
|
||||
|
||||
# the rest
|
||||
for i in range(1, num_to_return):
|
||||
new_output.append(lines[i].rstrip())
|
||||
|
||||
except:
|
||||
|
||||
pass
|
||||
|
||||
|
||||
|
||||
return "\n".join(new_output)
|
||||
|
||||
|
||||
def plain_text(self, line_nr, text, attributes, stats):
|
||||
""" Write plain text to Vim buffer. """
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# handle line offset
|
||||
line_nr += self.offset
|
||||
|
||||
self.l = line_nr + 1
|
||||
|
||||
# remove trailing whitespace
|
||||
text = text.rstrip()
|
||||
|
||||
# if we're using concealed text for color, then s- is weird
|
||||
if self.color_mode == 'conceal':
|
||||
|
||||
text = self.add_conceal_color(text, attributes, stats, line_nr)
|
||||
|
||||
|
||||
# deal with character encoding
|
||||
if CONQUE_PYTHON_VERSION == 2:
|
||||
val = text.encode(self.screen_encoding)
|
||||
else:
|
||||
# XXX / Vim's python3 interface doesn't accept bytes object
|
||||
val = str(text)
|
||||
|
||||
# update vim buffer
|
||||
if len(self.buffer) <= line_nr:
|
||||
self.buffer.append(val)
|
||||
else:
|
||||
self.buffer[line_nr] = val
|
||||
|
||||
if self.enable_colors and not self.color_mode == 'conceal' and line_nr > self.l - CONQUE_MAX_SYNTAX_LINES:
|
||||
relevant = attributes[0:len(text)]
|
||||
if line_nr not in self.attribute_cache or self.attribute_cache[line_nr] != relevant:
|
||||
self.do_color(attributes=relevant, stats=stats)
|
||||
self.attribute_cache[line_nr] = relevant
|
||||
|
||||
|
||||
def add_conceal_color(self, text, attributes, stats, line_nr):
|
||||
""" Add 'conceal' color strings to output text """
|
||||
|
||||
# stop here if coloration is disabled
|
||||
if not self.enable_colors:
|
||||
return text
|
||||
|
||||
# if no colors for this line, clear everything out
|
||||
if len(attributes) == 0 or attributes == u(chr(stats['default_attribute'])) * len(attributes):
|
||||
return text
|
||||
|
||||
new_text = ''
|
||||
self.color_conceals[line_nr] = []
|
||||
|
||||
attribute_chunks = CONQUE_WIN32_REGEX_ATTR.findall(attributes)
|
||||
offset = 0
|
||||
ends = []
|
||||
for attr in attribute_chunks:
|
||||
attr_num = ord(attr[1])
|
||||
ends = []
|
||||
if attr_num != stats['default_attribute']:
|
||||
|
||||
color = self.translate_color(attr_num)
|
||||
|
||||
new_text += chr(27) + 'sf' + color['fg_code'] + ';'
|
||||
ends.append(chr(27) + 'ef' + color['fg_code'] + ';')
|
||||
self.color_conceals[line_nr].append(offset)
|
||||
|
||||
if attr_num > 15:
|
||||
new_text += chr(27) + 'sb' + color['bg_code'] + ';'
|
||||
ends.append(chr(27) + 'eb' + color['bg_code'] + ';')
|
||||
self.color_conceals[line_nr].append(offset)
|
||||
|
||||
new_text += text[offset:offset + len(attr[0])]
|
||||
|
||||
# close color regions
|
||||
ends.reverse()
|
||||
for i in range(0, len(ends)):
|
||||
self.color_conceals[line_nr].append(len(new_text))
|
||||
new_text += ends[i]
|
||||
|
||||
offset += len(attr[0])
|
||||
|
||||
return new_text
|
||||
|
||||
|
||||
def do_color(self, start=0, end=0, attributes='', stats=None):
|
||||
""" Convert Windows console attributes into Vim syntax highlighting """
|
||||
|
||||
# if no colors for this line, clear everything out
|
||||
if len(attributes) == 0 or attributes == u(chr(stats['default_attribute'])) * len(attributes):
|
||||
self.color_changes = {}
|
||||
self.apply_color(1, len(attributes), self.l)
|
||||
return
|
||||
|
||||
attribute_chunks = CONQUE_WIN32_REGEX_ATTR.findall(attributes)
|
||||
offset = 0
|
||||
for attr in attribute_chunks:
|
||||
attr_num = ord(attr[1])
|
||||
if attr_num != stats['default_attribute']:
|
||||
self.color_changes = self.translate_color(attr_num)
|
||||
self.apply_color(offset + 1, offset + len(attr[0]) + 1, self.l)
|
||||
offset += len(attr[0])
|
||||
|
||||
|
||||
def translate_color(self, attr):
|
||||
""" Convert Windows console attributes into RGB colors """
|
||||
|
||||
# check for cached color
|
||||
if attr in self.color_cache:
|
||||
return self.color_cache[attr]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# convert attribute integer to bit string
|
||||
bit_str = bin(attr)
|
||||
bit_str = bit_str.replace('0b', '')
|
||||
|
||||
# slice foreground and background portions of bit string
|
||||
fg = bit_str[-4:].rjust(4, '0')
|
||||
bg = bit_str[-8:-4].rjust(4, '0')
|
||||
|
||||
# ok, first create foreground #rbg
|
||||
red = int(fg[1]) * 204 + int(fg[0]) * int(fg[1]) * 51
|
||||
green = int(fg[2]) * 204 + int(fg[0]) * int(fg[2]) * 51
|
||||
blue = int(fg[3]) * 204 + int(fg[0]) * int(fg[3]) * 51
|
||||
fg_str = "#%02x%02x%02x" % (red, green, blue)
|
||||
fg_code = "%02x%02x%02x" % (red, green, blue)
|
||||
fg_code = fg_code[0] + fg_code[2] + fg_code[4]
|
||||
|
||||
# ok, first create foreground #rbg
|
||||
red = int(bg[1]) * 204 + int(bg[0]) * int(bg[1]) * 51
|
||||
green = int(bg[2]) * 204 + int(bg[0]) * int(bg[2]) * 51
|
||||
blue = int(bg[3]) * 204 + int(bg[0]) * int(bg[3]) * 51
|
||||
bg_str = "#%02x%02x%02x" % (red, green, blue)
|
||||
bg_code = "%02x%02x%02x" % (red, green, blue)
|
||||
bg_code = bg_code[0] + bg_code[2] + bg_code[4]
|
||||
|
||||
# build value for color_changes
|
||||
|
||||
color = {'guifg': fg_str, 'guibg': bg_str}
|
||||
|
||||
if self.color_mode == 'conceal':
|
||||
color['fg_code'] = fg_code
|
||||
color['bg_code'] = bg_code
|
||||
|
||||
self.color_cache[attr] = color
|
||||
|
||||
return color
|
||||
|
||||
|
||||
def write_vk(self, vk_code):
|
||||
""" write virtual key code to shared memory using proprietary escape seq """
|
||||
|
||||
self.proc.write_vk(vk_code)
|
||||
|
||||
|
||||
def update_window_size(self):
|
||||
""" Resize underlying console if Vim buffer size has changed """
|
||||
|
||||
if vim.current.window.width != self.columns or vim.current.window.height != self.lines:
|
||||
|
||||
|
||||
|
||||
# reset all window size attributes to default
|
||||
self.columns = vim.current.window.width
|
||||
self.lines = vim.current.window.height
|
||||
self.working_columns = vim.current.window.width
|
||||
self.working_lines = vim.current.window.height
|
||||
self.bottom = vim.current.window.height
|
||||
|
||||
self.proc.window_resize(vim.current.window.height, vim.current.window.width)
|
||||
|
||||
|
||||
def set_cursor(self, line, column):
|
||||
""" Update cursor position in Vim buffer """
|
||||
|
||||
|
||||
|
||||
# handle offset
|
||||
line += self.offset
|
||||
|
||||
# shift cursor position to handle concealed text
|
||||
if self.enable_colors and self.color_mode == 'conceal':
|
||||
if line - 1 in self.color_conceals:
|
||||
for c in self.color_conceals[line - 1]:
|
||||
if c < column:
|
||||
column += 7
|
||||
else:
|
||||
break
|
||||
|
||||
|
||||
|
||||
# figure out line
|
||||
buffer_line = line
|
||||
if buffer_line > len(self.buffer):
|
||||
for l in range(len(self.buffer) - 1, buffer_line):
|
||||
self.buffer.append('')
|
||||
|
||||
# figure out column
|
||||
real_column = column
|
||||
if len(self.buffer[buffer_line - 1]) < real_column:
|
||||
self.buffer[buffer_line - 1] = self.buffer[buffer_line - 1] + ' ' * (real_column - len(self.buffer[buffer_line - 1]))
|
||||
|
||||
# python version is occasionally grumpy
|
||||
try:
|
||||
vim.current.window.cursor = (buffer_line, real_column - 1)
|
||||
except:
|
||||
vim.command('call cursor(' + str(buffer_line) + ', ' + str(real_column) + ')')
|
||||
|
||||
|
||||
def idle(self):
|
||||
""" go into idle mode """
|
||||
|
||||
self.proc.idle()
|
||||
|
||||
|
||||
def resume(self):
|
||||
""" resume from idle mode """
|
||||
|
||||
self.proc.resume()
|
||||
|
||||
|
||||
def close(self):
|
||||
""" end console subprocess """
|
||||
self.proc.close()
|
||||
|
||||
|
||||
def abort(self):
|
||||
""" end subprocess forcefully """
|
||||
self.proc.close()
|
||||
|
||||
|
||||
def get_buffer_line(self, line):
|
||||
""" get buffer line """
|
||||
return line
|
||||
|
||||
|
||||
# vim:foldmethod=marker
|
|
@ -1,183 +0,0 @@
|
|||
# FILE: autoload/conque_term/conque_sole_communicator.py
|
||||
# AUTHOR: Nico Raffo <nicoraffo@gmail.com>
|
||||
# WEBSITE: http://conque.googlecode.com
|
||||
# MODIFIED: 2011-04-04
|
||||
# VERSION: 2.1, for Vim 7.0
|
||||
# LICENSE:
|
||||
# Conque - Vim terminal/console emulator
|
||||
# Copyright (C) 2009-2011 Nico Raffo
|
||||
#
|
||||
# MIT License
|
||||
#
|
||||
# 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.
|
||||
|
||||
"""
|
||||
|
||||
ConqueSoleCommunicator
|
||||
|
||||
This script will create a new Windows console and start the requested program
|
||||
inside of it. This process is launched independently from the parent Vim
|
||||
program, so it has no access to the vim module.
|
||||
|
||||
The main loop in this script reads data from the console and syncs it onto
|
||||
blocks of memory shared with the Vim process. In this way the Vim process
|
||||
and this script can communicate with each other.
|
||||
|
||||
"""
|
||||
|
||||
import time
|
||||
import sys
|
||||
|
||||
from conque_globals import *
|
||||
from conque_win32_util import *
|
||||
from conque_sole_subprocess import *
|
||||
from conque_sole_shared_memory import *
|
||||
|
||||
##############################################################
|
||||
# only run if this file was run directly
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# attempt to catch ALL exceptions to fend of zombies
|
||||
try:
|
||||
|
||||
# simple arg validation
|
||||
|
||||
if len(sys.argv) < 5:
|
||||
|
||||
exit()
|
||||
|
||||
# maximum time this thing reads. 0 means no limit. Only for testing.
|
||||
max_loops = 0
|
||||
|
||||
# read interval, in seconds
|
||||
sleep_time = 0.01
|
||||
|
||||
# idle read interval, in seconds
|
||||
idle_sleep_time = 0.10
|
||||
|
||||
# are we idled?
|
||||
is_idle = False
|
||||
|
||||
# mem key
|
||||
mem_key = sys.argv[1]
|
||||
|
||||
# console width
|
||||
console_width = int(sys.argv[2])
|
||||
|
||||
# console height
|
||||
console_height = int(sys.argv[3])
|
||||
|
||||
# code page
|
||||
code_page = int(sys.argv[4])
|
||||
|
||||
# code page
|
||||
fast_mode = int(sys.argv[5])
|
||||
|
||||
# the actual subprocess to run
|
||||
cmd_line = " ".join(sys.argv[6:])
|
||||
|
||||
|
||||
# width and height
|
||||
options = {'LINES': console_height, 'COLUMNS': console_width, 'CODE_PAGE': code_page, 'FAST_MODE': fast_mode}
|
||||
|
||||
|
||||
|
||||
# set initial idle status
|
||||
shm_command = ConqueSoleSharedMemory(CONQUE_SOLE_COMMANDS_SIZE, 'command', mem_key, serialize=True)
|
||||
shm_command.create('write')
|
||||
|
||||
cmd = shm_command.read()
|
||||
if cmd:
|
||||
|
||||
if cmd['cmd'] == 'idle':
|
||||
is_idle = True
|
||||
shm_command.clear()
|
||||
|
||||
|
||||
##############################################################
|
||||
# Create the subprocess
|
||||
|
||||
proc = ConqueSoleSubprocess()
|
||||
res = proc.open(cmd_line, mem_key, options)
|
||||
|
||||
if not res:
|
||||
|
||||
exit()
|
||||
|
||||
##############################################################
|
||||
# main loop!
|
||||
|
||||
loops = 0
|
||||
|
||||
while True:
|
||||
|
||||
# check for idle/resume
|
||||
if is_idle or loops % 25 == 0:
|
||||
|
||||
# check process health
|
||||
if not proc.is_alive():
|
||||
|
||||
proc.close()
|
||||
break
|
||||
|
||||
# check for change in buffer focus
|
||||
cmd = shm_command.read()
|
||||
if cmd:
|
||||
|
||||
if cmd['cmd'] == 'idle':
|
||||
is_idle = True
|
||||
shm_command.clear()
|
||||
|
||||
elif cmd['cmd'] == 'resume':
|
||||
is_idle = False
|
||||
shm_command.clear()
|
||||
|
||||
|
||||
# sleep between loops if moderation is requested
|
||||
if sleep_time > 0:
|
||||
if is_idle:
|
||||
time.sleep(idle_sleep_time)
|
||||
else:
|
||||
time.sleep(sleep_time)
|
||||
|
||||
# write, read, etc
|
||||
proc.write()
|
||||
proc.read()
|
||||
|
||||
# increment loops, and exit if max has been reached
|
||||
loops += 1
|
||||
if max_loops and loops >= max_loops:
|
||||
|
||||
break
|
||||
|
||||
##############################################################
|
||||
# all done!
|
||||
|
||||
|
||||
|
||||
proc.close()
|
||||
|
||||
# if an exception was thrown, croak
|
||||
except:
|
||||
|
||||
proc.close()
|
||||
|
||||
|
||||
# vim:foldmethod=marker
|
|
@ -1,210 +0,0 @@
|
|||
# FILE: autoload/conque_term/conque_sole_shared_memory.py
|
||||
# AUTHOR: Nico Raffo <nicoraffo@gmail.com>
|
||||
# WEBSITE: http://conque.googlecode.com
|
||||
# MODIFIED: 2011-04-04
|
||||
# VERSION: 2.1, for Vim 7.0
|
||||
# LICENSE:
|
||||
# Conque - Vim terminal/console emulator
|
||||
# Copyright (C) 2009-2011 Nico Raffo
|
||||
#
|
||||
# MIT License
|
||||
#
|
||||
# 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.
|
||||
|
||||
"""
|
||||
Wrapper class for shared memory between Windows python processes
|
||||
|
||||
Adds a small amount of functionality to the standard mmap module.
|
||||
|
||||
"""
|
||||
|
||||
import mmap
|
||||
import sys
|
||||
|
||||
# PYTHON VERSION
|
||||
CONQUE_PYTHON_VERSION = sys.version_info[0]
|
||||
|
||||
if CONQUE_PYTHON_VERSION == 2:
|
||||
import cPickle as pickle
|
||||
else:
|
||||
import pickle
|
||||
|
||||
|
||||
class ConqueSoleSharedMemory():
|
||||
|
||||
# is the data being stored not fixed length
|
||||
fixed_length = False
|
||||
|
||||
# maximum number of bytes per character, for fixed width blocks
|
||||
char_width = 1
|
||||
|
||||
# fill memory with this character when clearing and fixed_length is true
|
||||
FILL_CHAR = None
|
||||
|
||||
# serialize and unserialize data automatically
|
||||
serialize = False
|
||||
|
||||
# size of shared memory, in bytes / chars
|
||||
mem_size = None
|
||||
|
||||
# size of shared memory, in bytes / chars
|
||||
mem_type = None
|
||||
|
||||
# unique key, so multiple console instances are possible
|
||||
mem_key = None
|
||||
|
||||
# mmap instance
|
||||
shm = None
|
||||
|
||||
# character encoding, dammit
|
||||
encoding = 'utf-8'
|
||||
|
||||
# pickle terminator
|
||||
TERMINATOR = None
|
||||
|
||||
|
||||
def __init__(self, mem_size, mem_type, mem_key, fixed_length=False, fill_char=' ', serialize=False, encoding='utf-8'):
|
||||
""" Initialize new shared memory block instance
|
||||
|
||||
Arguments:
|
||||
mem_size -- Memory size in characters, depends on encoding argument to calcuate byte size
|
||||
mem_type -- Label to identify what will be stored
|
||||
mem_key -- Unique, probably random key to identify this block
|
||||
fixed_length -- If set to true, assume the data stored will always fill the memory size
|
||||
fill_char -- Initialize memory block with this character, only really helpful with fixed_length blocks
|
||||
serialize -- Automatically serialize data passed to write. Allows storing non-byte data
|
||||
encoding -- Character encoding to use when storing character data
|
||||
|
||||
"""
|
||||
self.mem_size = mem_size
|
||||
self.mem_type = mem_type
|
||||
self.mem_key = mem_key
|
||||
self.fixed_length = fixed_length
|
||||
self.fill_char = fill_char
|
||||
self.serialize = serialize
|
||||
self.encoding = encoding
|
||||
self.TERMINATOR = str(chr(0)).encode(self.encoding)
|
||||
|
||||
if CONQUE_PYTHON_VERSION == 3:
|
||||
self.FILL_CHAR = fill_char
|
||||
else:
|
||||
self.FILL_CHAR = unicode(fill_char)
|
||||
|
||||
if fixed_length and encoding == 'utf-8':
|
||||
self.char_width = 4
|
||||
|
||||
|
||||
def create(self, access='write'):
|
||||
""" Create a new block of shared memory using the mmap module. """
|
||||
|
||||
if access == 'write':
|
||||
mmap_access = mmap.ACCESS_WRITE
|
||||
else:
|
||||
mmap_access = mmap.ACCESS_READ
|
||||
|
||||
name = "conque_%s_%s" % (self.mem_type, self.mem_key)
|
||||
|
||||
self.shm = mmap.mmap(0, self.mem_size * self.char_width, name, mmap_access)
|
||||
|
||||
if not self.shm:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
|
||||
def read(self, chars=1, start=0):
|
||||
""" Read data from shared memory.
|
||||
|
||||
If this is a fixed length block, read 'chars' characters from memory.
|
||||
Otherwise read up until the TERMINATOR character (null byte).
|
||||
If this memory is serialized, unserialize it automatically.
|
||||
|
||||
"""
|
||||
# go to start position
|
||||
self.shm.seek(start * self.char_width)
|
||||
|
||||
if self.fixed_length:
|
||||
chars = chars * self.char_width
|
||||
else:
|
||||
chars = self.shm.find(self.TERMINATOR)
|
||||
|
||||
if chars == 0:
|
||||
return ''
|
||||
|
||||
shm_str = self.shm.read(chars)
|
||||
|
||||
# return unpickled byte object
|
||||
if self.serialize:
|
||||
return pickle.loads(shm_str)
|
||||
|
||||
# decode byes in python 3
|
||||
if CONQUE_PYTHON_VERSION == 3:
|
||||
return str(shm_str, self.encoding)
|
||||
|
||||
# encoding
|
||||
if self.encoding != 'ascii':
|
||||
shm_str = unicode(shm_str, self.encoding)
|
||||
|
||||
return shm_str
|
||||
|
||||
|
||||
def write(self, text, start=0):
|
||||
""" Write data to memory.
|
||||
|
||||
If memory is fixed length, simply write the 'text' characters at 'start' position.
|
||||
Otherwise write 'text' characters and append a null character.
|
||||
If memory is serializable, do so first.
|
||||
|
||||
"""
|
||||
# simple scenario, let pickle create bytes
|
||||
if self.serialize:
|
||||
if CONQUE_PYTHON_VERSION == 3:
|
||||
tb = pickle.dumps(text, 0)
|
||||
else:
|
||||
tb = pickle.dumps(text, 0).encode(self.encoding)
|
||||
|
||||
else:
|
||||
tb = text.encode(self.encoding, 'replace')
|
||||
|
||||
# write to memory
|
||||
self.shm.seek(start * self.char_width)
|
||||
|
||||
if self.fixed_length:
|
||||
self.shm.write(tb)
|
||||
else:
|
||||
self.shm.write(tb + self.TERMINATOR)
|
||||
|
||||
|
||||
def clear(self, start=0):
|
||||
""" Clear memory block using self.fill_char. """
|
||||
|
||||
self.shm.seek(start)
|
||||
|
||||
if self.fixed_length:
|
||||
self.shm.write(str(self.fill_char * self.mem_size * self.char_width).encode(self.encoding))
|
||||
else:
|
||||
self.shm.write(self.TERMINATOR)
|
||||
|
||||
|
||||
def close(self):
|
||||
""" Close/destroy memory block. """
|
||||
|
||||
self.shm.close()
|
||||
|
||||
|
|
@ -1,762 +0,0 @@
|
|||
# FILE: autoload/conque_term/conque_sole_subprocess.py
|
||||
# AUTHOR: Nico Raffo <nicoraffo@gmail.com>
|
||||
# WEBSITE: http://conque.googlecode.com
|
||||
# MODIFIED: 2011-04-04
|
||||
# VERSION: 2.1, for Vim 7.0
|
||||
# LICENSE:
|
||||
# Conque - Vim terminal/console emulator
|
||||
# Copyright (C) 2009-2011 Nico Raffo
|
||||
#
|
||||
# MIT License
|
||||
#
|
||||
# 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.
|
||||
|
||||
""" ConqueSoleSubprocess
|
||||
|
||||
Creates a new subprocess with it's own (hidden) console window.
|
||||
|
||||
Mirrors console window text onto a block of shared memory (mmap), along with
|
||||
text attribute data. Also handles translation of text input into the format
|
||||
Windows console expects.
|
||||
|
||||
Sample Usage:
|
||||
|
||||
sh = ConqueSoleSubprocess()
|
||||
sh.open("cmd.exe", "unique_str")
|
||||
|
||||
shm_in = ConqueSoleSharedMemory(mem_key = "unique_str", mem_type = "input", ...)
|
||||
shm_out = ConqueSoleSharedMemory(mem_key = "unique_str", mem_type = "output", ...)
|
||||
|
||||
output = shm_out.read(...)
|
||||
shm_in.write("dir\r")
|
||||
output = shm_out.read(...)
|
||||
|
||||
"""
|
||||
|
||||
import time
|
||||
import re
|
||||
import os
|
||||
import ctypes
|
||||
|
||||
from conque_globals import *
|
||||
from conque_win32_util import *
|
||||
from conque_sole_shared_memory import *
|
||||
|
||||
|
||||
class ConqueSoleSubprocess():
|
||||
|
||||
# subprocess handle and pid
|
||||
handle = None
|
||||
pid = None
|
||||
|
||||
# input / output handles
|
||||
stdin = None
|
||||
stdout = None
|
||||
|
||||
# size of console window
|
||||
window_width = 160
|
||||
window_height = 40
|
||||
|
||||
# max lines for the console buffer
|
||||
buffer_width = 160
|
||||
buffer_height = 100
|
||||
|
||||
# keep track of the buffer number at the top of the window
|
||||
top = 0
|
||||
line_offset = 0
|
||||
|
||||
# buffer height is CONQUE_SOLE_BUFFER_LENGTH * output_blocks
|
||||
output_blocks = 1
|
||||
|
||||
# cursor position
|
||||
cursor_line = 0
|
||||
cursor_col = 0
|
||||
|
||||
# console data, array of lines
|
||||
data = []
|
||||
|
||||
# console attribute data, array of array of int
|
||||
attributes = []
|
||||
attribute_cache = {}
|
||||
|
||||
# default attribute
|
||||
default_attribute = 7
|
||||
|
||||
# shared memory objects
|
||||
shm_input = None
|
||||
shm_output = None
|
||||
shm_attributes = None
|
||||
shm_stats = None
|
||||
shm_command = None
|
||||
shm_rescroll = None
|
||||
shm_resize = None
|
||||
|
||||
# are we still a valid process?
|
||||
is_alive = True
|
||||
|
||||
# running in fast mode
|
||||
fast_mode = 0
|
||||
|
||||
# used for periodic execution of screen and memory redrawing
|
||||
screen_redraw_ct = 0
|
||||
mem_redraw_ct = 0
|
||||
|
||||
|
||||
def open(self, cmd, mem_key, options={}):
|
||||
""" Create subproccess running in hidden console window. """
|
||||
|
||||
|
||||
|
||||
self.reset = True
|
||||
|
||||
try:
|
||||
# if we're already attached to a console, then unattach
|
||||
try:
|
||||
ctypes.windll.kernel32.FreeConsole()
|
||||
except:
|
||||
pass
|
||||
|
||||
# set buffer height
|
||||
self.buffer_height = CONQUE_SOLE_BUFFER_LENGTH
|
||||
|
||||
if 'LINES' in options and 'COLUMNS' in options:
|
||||
self.window_width = options['COLUMNS']
|
||||
self.window_height = options['LINES']
|
||||
self.buffer_width = options['COLUMNS']
|
||||
|
||||
# fast mode
|
||||
self.fast_mode = options['FAST_MODE']
|
||||
|
||||
# console window options
|
||||
si = STARTUPINFO()
|
||||
|
||||
# hide window
|
||||
si.dwFlags |= STARTF_USESHOWWINDOW
|
||||
si.wShowWindow = SW_HIDE
|
||||
#si.wShowWindow = SW_MINIMIZE
|
||||
|
||||
# process options
|
||||
flags = NORMAL_PRIORITY_CLASS | CREATE_NEW_PROCESS_GROUP | CREATE_UNICODE_ENVIRONMENT | CREATE_NEW_CONSOLE
|
||||
|
||||
# created process info
|
||||
pi = PROCESS_INFORMATION()
|
||||
|
||||
|
||||
|
||||
# create the process!
|
||||
res = ctypes.windll.kernel32.CreateProcessW(None, u(cmd), None, None, 0, flags, None, u('.'), ctypes.byref(si), ctypes.byref(pi))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# process info
|
||||
self.pid = pi.dwProcessId
|
||||
self.handle = pi.hProcess
|
||||
|
||||
|
||||
|
||||
|
||||
# attach ourselves to the new console
|
||||
# console is not immediately available
|
||||
for i in range(10):
|
||||
time.sleep(0.25)
|
||||
try:
|
||||
|
||||
res = ctypes.windll.kernel32.AttachConsole(self.pid)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
break
|
||||
except:
|
||||
|
||||
pass
|
||||
|
||||
# get input / output handles
|
||||
self.stdout = ctypes.windll.kernel32.GetStdHandle(STD_OUTPUT_HANDLE)
|
||||
self.stdin = ctypes.windll.kernel32.GetStdHandle(STD_INPUT_HANDLE)
|
||||
|
||||
# set buffer size
|
||||
size = COORD(self.buffer_width, self.buffer_height)
|
||||
res = ctypes.windll.kernel32.SetConsoleScreenBufferSize(self.stdout, size)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# prev set size call needs to process
|
||||
time.sleep(0.2)
|
||||
|
||||
# set window size
|
||||
self.set_window_size(self.window_width, self.window_height)
|
||||
|
||||
# set utf-8 code page
|
||||
if 'CODE_PAGE' in options and options['CODE_PAGE'] > 0:
|
||||
if ctypes.windll.kernel32.IsValidCodePage(ctypes.c_uint(options['CODE_PAGE'])):
|
||||
|
||||
ctypes.windll.kernel32.SetConsoleCP(ctypes.c_uint(options['CODE_PAGE']))
|
||||
ctypes.windll.kernel32.SetConsoleOutputCP(ctypes.c_uint(options['CODE_PAGE']))
|
||||
|
||||
# init shared memory
|
||||
self.init_shared_memory(mem_key)
|
||||
|
||||
# init read buffers
|
||||
self.tc = ctypes.create_unicode_buffer(self.buffer_width)
|
||||
self.ac = ctypes.create_unicode_buffer(self.buffer_width)
|
||||
|
||||
return True
|
||||
|
||||
except:
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def init_shared_memory(self, mem_key):
|
||||
""" Create shared memory objects. """
|
||||
|
||||
self.shm_input = ConqueSoleSharedMemory(CONQUE_SOLE_INPUT_SIZE, 'input', mem_key)
|
||||
self.shm_input.create('write')
|
||||
self.shm_input.clear()
|
||||
|
||||
self.shm_output = ConqueSoleSharedMemory(self.buffer_height * self.buffer_width, 'output', mem_key, True)
|
||||
self.shm_output.create('write')
|
||||
self.shm_output.clear()
|
||||
|
||||
if not self.fast_mode:
|
||||
buf_info = self.get_buffer_info()
|
||||
self.shm_attributes = ConqueSoleSharedMemory(self.buffer_height * self.buffer_width, 'attributes', mem_key, True, chr(buf_info.wAttributes), encoding='latin-1')
|
||||
self.shm_attributes.create('write')
|
||||
self.shm_attributes.clear()
|
||||
|
||||
self.shm_stats = ConqueSoleSharedMemory(CONQUE_SOLE_STATS_SIZE, 'stats', mem_key, serialize=True)
|
||||
self.shm_stats.create('write')
|
||||
self.shm_stats.clear()
|
||||
|
||||
self.shm_command = ConqueSoleSharedMemory(CONQUE_SOLE_COMMANDS_SIZE, 'command', mem_key, serialize=True)
|
||||
self.shm_command.create('write')
|
||||
self.shm_command.clear()
|
||||
|
||||
self.shm_resize = ConqueSoleSharedMemory(CONQUE_SOLE_RESIZE_SIZE, 'resize', mem_key, serialize=True)
|
||||
self.shm_resize.create('write')
|
||||
self.shm_resize.clear()
|
||||
|
||||
self.shm_rescroll = ConqueSoleSharedMemory(CONQUE_SOLE_RESCROLL_SIZE, 'rescroll', mem_key, serialize=True)
|
||||
self.shm_rescroll.create('write')
|
||||
self.shm_rescroll.clear()
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def check_commands(self):
|
||||
""" Check for and process commands from Vim. """
|
||||
|
||||
cmd = self.shm_command.read()
|
||||
|
||||
if cmd:
|
||||
|
||||
# shut it all down
|
||||
if cmd['cmd'] == 'close':
|
||||
|
||||
# clear command
|
||||
self.shm_command.clear()
|
||||
|
||||
self.close()
|
||||
return
|
||||
|
||||
cmd = self.shm_resize.read()
|
||||
|
||||
if cmd:
|
||||
|
||||
# clear command
|
||||
self.shm_resize.clear()
|
||||
|
||||
# resize console
|
||||
if cmd['cmd'] == 'resize':
|
||||
|
||||
|
||||
|
||||
# only change buffer width if it's larger
|
||||
if cmd['data']['width'] > self.buffer_width:
|
||||
self.buffer_width = cmd['data']['width']
|
||||
|
||||
# always change console width and height
|
||||
self.window_width = cmd['data']['width']
|
||||
self.window_height = cmd['data']['height']
|
||||
|
||||
# reset the console
|
||||
buf_info = self.get_buffer_info()
|
||||
self.reset_console(buf_info, add_block=False)
|
||||
|
||||
|
||||
def read(self):
|
||||
""" Read from windows console and update shared memory blocks. """
|
||||
|
||||
# no point really
|
||||
if self.screen_redraw_ct == 0 and not self.is_alive():
|
||||
stats = {'top_offset': 0, 'default_attribute': 0, 'cursor_x': 0, 'cursor_y': self.cursor_line, 'is_alive': 0}
|
||||
|
||||
self.shm_stats.write(stats)
|
||||
return
|
||||
|
||||
# check for commands
|
||||
self.check_commands()
|
||||
|
||||
# get cursor position
|
||||
buf_info = self.get_buffer_info()
|
||||
curs_line = buf_info.dwCursorPosition.Y
|
||||
curs_col = buf_info.dwCursorPosition.X
|
||||
|
||||
# set update range
|
||||
if curs_line != self.cursor_line or self.top != buf_info.srWindow.Top or self.screen_redraw_ct == CONQUE_SOLE_SCREEN_REDRAW:
|
||||
self.screen_redraw_ct = 0
|
||||
|
||||
read_start = self.top
|
||||
read_end = max([buf_info.srWindow.Bottom + 1, curs_line + 1])
|
||||
else:
|
||||
|
||||
read_start = curs_line
|
||||
read_end = curs_line + 1
|
||||
|
||||
|
||||
|
||||
|
||||
# vars used in for loop
|
||||
coord = COORD(0, 0)
|
||||
chars_read = ctypes.c_int(0)
|
||||
|
||||
# read new data
|
||||
for i in range(read_start, read_end):
|
||||
|
||||
coord.Y = i
|
||||
|
||||
res = ctypes.windll.kernel32.ReadConsoleOutputCharacterW(self.stdout, ctypes.byref(self.tc), self.buffer_width, coord, ctypes.byref(chars_read))
|
||||
if not self.fast_mode:
|
||||
ctypes.windll.kernel32.ReadConsoleOutputAttribute(self.stdout, ctypes.byref(self.ac), self.buffer_width, coord, ctypes.byref(chars_read))
|
||||
|
||||
t = self.tc.value
|
||||
if not self.fast_mode:
|
||||
a = self.ac.value
|
||||
|
||||
# add data
|
||||
if i >= len(self.data):
|
||||
for j in range(len(self.data), i + 1):
|
||||
self.data.append('')
|
||||
if not self.fast_mode:
|
||||
self.attributes.append('')
|
||||
|
||||
self.data[i] = t
|
||||
if not self.fast_mode:
|
||||
self.attributes[i] = a
|
||||
|
||||
|
||||
|
||||
|
||||
#for i in range(0, len(t)):
|
||||
|
||||
|
||||
|
||||
|
||||
# write new output to shared memory
|
||||
try:
|
||||
if self.mem_redraw_ct == CONQUE_SOLE_MEM_REDRAW:
|
||||
self.mem_redraw_ct = 0
|
||||
|
||||
for i in range(0, len(self.data)):
|
||||
self.shm_output.write(text=self.data[i], start=self.buffer_width * i)
|
||||
if not self.fast_mode:
|
||||
self.shm_attributes.write(text=self.attributes[i], start=self.buffer_width * i)
|
||||
else:
|
||||
|
||||
for i in range(read_start, read_end):
|
||||
self.shm_output.write(text=self.data[i], start=self.buffer_width * i)
|
||||
if not self.fast_mode:
|
||||
self.shm_attributes.write(text=self.attributes[i], start=self.buffer_width * i)
|
||||
#self.shm_output.write(text=''.join(self.data[read_start:read_end]), start=read_start * self.buffer_width)
|
||||
#self.shm_attributes.write(text=''.join(self.attributes[read_start:read_end]), start=read_start * self.buffer_width)
|
||||
|
||||
# write cursor position to shared memory
|
||||
stats = {'top_offset': buf_info.srWindow.Top, 'default_attribute': buf_info.wAttributes, 'cursor_x': curs_col, 'cursor_y': curs_line, 'is_alive': 1}
|
||||
self.shm_stats.write(stats)
|
||||
|
||||
# adjust screen position
|
||||
self.top = buf_info.srWindow.Top
|
||||
self.cursor_line = curs_line
|
||||
|
||||
# check for reset
|
||||
if curs_line > buf_info.dwSize.Y - 200:
|
||||
self.reset_console(buf_info)
|
||||
|
||||
except:
|
||||
|
||||
|
||||
|
||||
|
||||
pass
|
||||
|
||||
# increment redraw counters
|
||||
self.screen_redraw_ct += 1
|
||||
self.mem_redraw_ct += 1
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def reset_console(self, buf_info, add_block=True):
|
||||
""" Extend the height of the current console if the cursor postion gets within 200 lines of the current size. """
|
||||
|
||||
# sometimes we just want to change the buffer width,
|
||||
# in which case no need to add another block
|
||||
if add_block:
|
||||
self.output_blocks += 1
|
||||
|
||||
# close down old memory
|
||||
self.shm_output.close()
|
||||
self.shm_output = None
|
||||
|
||||
if not self.fast_mode:
|
||||
self.shm_attributes.close()
|
||||
self.shm_attributes = None
|
||||
|
||||
# new shared memory key
|
||||
mem_key = 'mk' + str(time.time())
|
||||
|
||||
# reallocate memory
|
||||
self.shm_output = ConqueSoleSharedMemory(self.buffer_height * self.buffer_width * self.output_blocks, 'output', mem_key, True)
|
||||
self.shm_output.create('write')
|
||||
self.shm_output.clear()
|
||||
|
||||
# backfill data
|
||||
if len(self.data[0]) < self.buffer_width:
|
||||
for i in range(0, len(self.data)):
|
||||
self.data[i] = self.data[i] + ' ' * (self.buffer_width - len(self.data[i]))
|
||||
self.shm_output.write(''.join(self.data))
|
||||
|
||||
if not self.fast_mode:
|
||||
self.shm_attributes = ConqueSoleSharedMemory(self.buffer_height * self.buffer_width * self.output_blocks, 'attributes', mem_key, True, chr(buf_info.wAttributes), encoding='latin-1')
|
||||
self.shm_attributes.create('write')
|
||||
self.shm_attributes.clear()
|
||||
|
||||
# backfill attributes
|
||||
if len(self.attributes[0]) < self.buffer_width:
|
||||
for i in range(0, len(self.attributes)):
|
||||
self.attributes[i] = self.attributes[i] + chr(buf_info.wAttributes) * (self.buffer_width - len(self.attributes[i]))
|
||||
if not self.fast_mode:
|
||||
self.shm_attributes.write(''.join(self.attributes))
|
||||
|
||||
# notify wrapper of new output block
|
||||
self.shm_rescroll.write({'cmd': 'new_output', 'data': {'blocks': self.output_blocks, 'mem_key': mem_key}})
|
||||
|
||||
# set buffer size
|
||||
size = COORD(X=self.buffer_width, Y=self.buffer_height * self.output_blocks)
|
||||
|
||||
res = ctypes.windll.kernel32.SetConsoleScreenBufferSize(self.stdout, size)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# prev set size call needs to process
|
||||
time.sleep(0.2)
|
||||
|
||||
# set window size
|
||||
self.set_window_size(self.window_width, self.window_height)
|
||||
|
||||
# init read buffers
|
||||
self.tc = ctypes.create_unicode_buffer(self.buffer_width)
|
||||
self.ac = ctypes.create_unicode_buffer(self.buffer_width)
|
||||
|
||||
|
||||
|
||||
def write(self):
|
||||
""" Write text to console.
|
||||
|
||||
This function just parses out special sequences for special key events
|
||||
and passes on the text to the plain or virtual key functions.
|
||||
|
||||
"""
|
||||
# get input from shared mem
|
||||
text = self.shm_input.read()
|
||||
|
||||
# nothing to do here
|
||||
if text == u(''):
|
||||
return
|
||||
|
||||
|
||||
|
||||
# clear input queue
|
||||
self.shm_input.clear()
|
||||
|
||||
# split on VK codes
|
||||
chunks = CONQUE_WIN32_REGEX_VK.split(text)
|
||||
|
||||
# if len() is one then no vks
|
||||
if len(chunks) == 1:
|
||||
self.write_plain(text)
|
||||
return
|
||||
|
||||
|
||||
|
||||
# loop over chunks and delegate
|
||||
for t in chunks:
|
||||
|
||||
if t == '':
|
||||
continue
|
||||
|
||||
if CONQUE_WIN32_REGEX_VK.match(t):
|
||||
|
||||
self.write_vk(t[2:-2])
|
||||
else:
|
||||
self.write_plain(t)
|
||||
|
||||
|
||||
def write_plain(self, text):
|
||||
""" Write simple text to subprocess. """
|
||||
|
||||
li = INPUT_RECORD * len(text)
|
||||
list_input = li()
|
||||
|
||||
for i in range(0, len(text)):
|
||||
|
||||
# create keyboard input
|
||||
ke = KEY_EVENT_RECORD()
|
||||
ke.bKeyDown = ctypes.c_byte(1)
|
||||
ke.wRepeatCount = ctypes.c_short(1)
|
||||
|
||||
cnum = ord(text[i])
|
||||
|
||||
ke.wVirtualKeyCode = ctypes.windll.user32.VkKeyScanW(cnum)
|
||||
ke.wVirtualScanCode = ctypes.c_short(ctypes.windll.user32.MapVirtualKeyW(int(cnum), 0))
|
||||
|
||||
if cnum > 31:
|
||||
ke.uChar.UnicodeChar = uchr(cnum)
|
||||
elif cnum == 3:
|
||||
ctypes.windll.kernel32.GenerateConsoleCtrlEvent(0, self.pid)
|
||||
ke.uChar.UnicodeChar = uchr(cnum)
|
||||
ke.wVirtualKeyCode = ctypes.windll.user32.VkKeyScanW(cnum + 96)
|
||||
ke.dwControlKeyState |= LEFT_CTRL_PRESSED
|
||||
else:
|
||||
ke.uChar.UnicodeChar = uchr(cnum)
|
||||
if cnum in CONQUE_WINDOWS_VK_INV:
|
||||
ke.wVirtualKeyCode = cnum
|
||||
else:
|
||||
ke.wVirtualKeyCode = ctypes.windll.user32.VkKeyScanW(cnum + 96)
|
||||
ke.dwControlKeyState |= LEFT_CTRL_PRESSED
|
||||
|
||||
|
||||
|
||||
|
||||
kc = INPUT_RECORD(KEY_EVENT)
|
||||
kc.Event.KeyEvent = ke
|
||||
list_input[i] = kc
|
||||
|
||||
|
||||
|
||||
# write input array
|
||||
events_written = ctypes.c_int()
|
||||
res = ctypes.windll.kernel32.WriteConsoleInputW(self.stdin, list_input, len(text), ctypes.byref(events_written))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def write_vk(self, vk_code):
|
||||
""" Write special characters to console subprocess. """
|
||||
|
||||
|
||||
|
||||
code = None
|
||||
ctrl_pressed = False
|
||||
|
||||
# this could be made more generic when more attributes
|
||||
# other than ctrl_pressed are available
|
||||
vk_attributes = vk_code.split(';')
|
||||
|
||||
for attr in vk_attributes:
|
||||
if attr == CONQUE_VK_ATTR_CTRL_PRESSED:
|
||||
ctrl_pressed = True
|
||||
else:
|
||||
code = attr
|
||||
|
||||
li = INPUT_RECORD * 1
|
||||
|
||||
# create keyboard input
|
||||
ke = KEY_EVENT_RECORD()
|
||||
ke.uChar.UnicodeChar = uchr(0)
|
||||
ke.wVirtualKeyCode = ctypes.c_short(int(code))
|
||||
ke.wVirtualScanCode = ctypes.c_short(ctypes.windll.user32.MapVirtualKeyW(int(code), 0))
|
||||
ke.bKeyDown = ctypes.c_byte(1)
|
||||
ke.wRepeatCount = ctypes.c_short(1)
|
||||
|
||||
# set enhanced key mode for arrow keys
|
||||
if code in CONQUE_WINDOWS_VK_ENHANCED:
|
||||
|
||||
ke.dwControlKeyState |= ENHANCED_KEY
|
||||
|
||||
if ctrl_pressed:
|
||||
ke.dwControlKeyState |= LEFT_CTRL_PRESSED
|
||||
|
||||
kc = INPUT_RECORD(KEY_EVENT)
|
||||
kc.Event.KeyEvent = ke
|
||||
list_input = li(kc)
|
||||
|
||||
# write input array
|
||||
events_written = ctypes.c_int()
|
||||
res = ctypes.windll.kernel32.WriteConsoleInputW(self.stdin, list_input, 1, ctypes.byref(events_written))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def close(self):
|
||||
""" Close all running subproccesses """
|
||||
|
||||
# record status
|
||||
self.is_alive = False
|
||||
try:
|
||||
stats = {'top_offset': 0, 'default_attribute': 0, 'cursor_x': 0, 'cursor_y': self.cursor_line, 'is_alive': 0}
|
||||
self.shm_stats.write(stats)
|
||||
except:
|
||||
pass
|
||||
|
||||
pid_list = (ctypes.c_int * 10)()
|
||||
num = ctypes.windll.kernel32.GetConsoleProcessList(pid_list, 10)
|
||||
|
||||
|
||||
|
||||
current_pid = os.getpid()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# kill subprocess pids
|
||||
for pid in pid_list[0:num]:
|
||||
if not pid:
|
||||
break
|
||||
|
||||
# kill current pid last
|
||||
if pid == current_pid:
|
||||
continue
|
||||
try:
|
||||
self.close_pid(pid)
|
||||
except:
|
||||
|
||||
pass
|
||||
|
||||
# kill this process
|
||||
try:
|
||||
self.close_pid(current_pid)
|
||||
except:
|
||||
|
||||
pass
|
||||
|
||||
|
||||
def close_pid(self, pid):
|
||||
""" Terminate a single process. """
|
||||
|
||||
|
||||
handle = ctypes.windll.kernel32.OpenProcess(PROCESS_TERMINATE, 0, pid)
|
||||
ctypes.windll.kernel32.TerminateProcess(handle, -1)
|
||||
ctypes.windll.kernel32.CloseHandle(handle)
|
||||
|
||||
|
||||
def is_alive(self):
|
||||
""" Check process health. """
|
||||
|
||||
status = ctypes.windll.kernel32.WaitForSingleObject(self.handle, 1)
|
||||
|
||||
if status == 0:
|
||||
|
||||
self.is_alive = False
|
||||
|
||||
return self.is_alive
|
||||
|
||||
|
||||
def get_screen_text(self):
|
||||
""" Return screen data as string. """
|
||||
|
||||
return "\n".join(self.data)
|
||||
|
||||
|
||||
def set_window_size(self, width, height):
|
||||
""" Change Windows console size. """
|
||||
|
||||
|
||||
|
||||
# get current window size object
|
||||
window_size = SMALL_RECT(0, 0, 0, 0)
|
||||
|
||||
# buffer info has maximum window size data
|
||||
buf_info = self.get_buffer_info()
|
||||
|
||||
|
||||
# set top left corner
|
||||
window_size.Top = 0
|
||||
window_size.Left = 0
|
||||
|
||||
# set bottom right corner
|
||||
if buf_info.dwMaximumWindowSize.X < width:
|
||||
|
||||
window_size.Right = buf_info.dwMaximumWindowSize.X - 1
|
||||
else:
|
||||
window_size.Right = width - 1
|
||||
|
||||
if buf_info.dwMaximumWindowSize.Y < height:
|
||||
|
||||
window_size.Bottom = buf_info.dwMaximumWindowSize.Y - 1
|
||||
else:
|
||||
window_size.Bottom = height - 1
|
||||
|
||||
|
||||
|
||||
# set the window size!
|
||||
res = ctypes.windll.kernel32.SetConsoleWindowInfo(self.stdout, ctypes.c_bool(True), ctypes.byref(window_size))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# reread buffer info to get final console max lines
|
||||
buf_info = self.get_buffer_info()
|
||||
|
||||
self.window_width = buf_info.srWindow.Right + 1
|
||||
self.window_height = buf_info.srWindow.Bottom + 1
|
||||
|
||||
|
||||
def get_buffer_info(self):
|
||||
""" Retrieve commonly-used buffer information. """
|
||||
|
||||
buf_info = CONSOLE_SCREEN_BUFFER_INFO()
|
||||
ctypes.windll.kernel32.GetConsoleScreenBufferInfo(self.stdout, ctypes.byref(buf_info))
|
||||
|
||||
return buf_info
|
||||
|
||||
|
||||
|
|
@ -1,278 +0,0 @@
|
|||
# FILE: autoload/conque_term/conque_sole_wrapper.py
|
||||
# AUTHOR: Nico Raffo <nicoraffo@gmail.com>
|
||||
# WEBSITE: http://conque.googlecode.com
|
||||
# MODIFIED: 2011-04-04
|
||||
# VERSION: 2.1, for Vim 7.0
|
||||
# LICENSE:
|
||||
# Conque - Vim terminal/console emulator
|
||||
# Copyright (C) 2009-2011 Nico Raffo
|
||||
#
|
||||
# MIT License
|
||||
#
|
||||
# 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.
|
||||
|
||||
"""
|
||||
|
||||
ConqueSoleSubprocessWrapper
|
||||
|
||||
Subprocess wrapper to deal with Windows insanity. Launches console based python,
|
||||
which in turn launches originally requested command. Communicates with cosole
|
||||
python through shared memory objects.
|
||||
|
||||
"""
|
||||
|
||||
import ctypes
|
||||
import time
|
||||
|
||||
|
||||
class ConqueSoleWrapper():
|
||||
|
||||
# unique key used for shared memory block names
|
||||
shm_key = ''
|
||||
|
||||
# process info
|
||||
handle = None
|
||||
pid = None
|
||||
|
||||
# queue input in this bucket
|
||||
bucket = None
|
||||
|
||||
# console size
|
||||
lines = 24
|
||||
columns = 80
|
||||
|
||||
# shared memory objects
|
||||
shm_input = None
|
||||
shm_output = None
|
||||
shm_attributes = None
|
||||
shm_stats = None
|
||||
shm_command = None
|
||||
shm_rescroll = None
|
||||
shm_resize = None
|
||||
|
||||
# console python process
|
||||
proc = None
|
||||
|
||||
|
||||
def open(self, cmd, lines, columns, python_exe='python.exe', communicator_py='conque_sole_communicator.py', options={}):
|
||||
""" Launch python.exe subprocess which will in turn launch the user's program.
|
||||
|
||||
Arguments:
|
||||
cmd -- The user's command to run. E.g. "Powershell.exe" or "C:\Python27\Scripts\ipython.bat"
|
||||
lines, columns -- The size of the console, also the size of the Vim buffer
|
||||
python.exe -- The path to the python executable, typically C:\PythonXX\python.exe
|
||||
communicator_py -- The path to the subprocess controller script in the user's vimfiles directory
|
||||
options -- optional configuration
|
||||
|
||||
"""
|
||||
self.lines = lines
|
||||
self.columns = columns
|
||||
self.bucket = u('')
|
||||
|
||||
# create a shm key
|
||||
self.shm_key = 'mk' + str(time.time())
|
||||
|
||||
# python command
|
||||
cmd_line = '%s "%s" %s %d %d %d %d %s' % (python_exe, communicator_py, self.shm_key, int(self.columns), int(self.lines), int(options['CODE_PAGE']), int(CONQUE_FAST_MODE), cmd)
|
||||
|
||||
|
||||
# console window attributes
|
||||
flags = NORMAL_PRIORITY_CLASS | DETACHED_PROCESS | CREATE_UNICODE_ENVIRONMENT
|
||||
si = STARTUPINFO()
|
||||
pi = PROCESS_INFORMATION()
|
||||
|
||||
# start the stupid process already
|
||||
try:
|
||||
res = ctypes.windll.kernel32.CreateProcessW(None, u(cmd_line), None, None, 0, flags, None, u('.'), ctypes.byref(si), ctypes.byref(pi))
|
||||
except:
|
||||
|
||||
raise
|
||||
|
||||
# handle
|
||||
self.pid = pi.dwProcessId
|
||||
|
||||
|
||||
|
||||
# init shared memory objects
|
||||
self.init_shared_memory(self.shm_key)
|
||||
|
||||
|
||||
def read(self, start_line, num_lines, timeout=0):
|
||||
""" Read a range of console lines from shared memory.
|
||||
|
||||
Returns a pair of lists containing the console text and console text attributes.
|
||||
|
||||
"""
|
||||
# emulate timeout by sleeping timeout time
|
||||
if timeout > 0:
|
||||
read_timeout = float(timeout) / 1000
|
||||
|
||||
time.sleep(read_timeout)
|
||||
|
||||
output = []
|
||||
attributes = []
|
||||
|
||||
# get output
|
||||
for i in range(start_line, start_line + num_lines + 1):
|
||||
output.append(self.shm_output.read(self.columns, i * self.columns))
|
||||
if not CONQUE_FAST_MODE:
|
||||
attributes.append(self.shm_attributes.read(self.columns, i * self.columns))
|
||||
|
||||
return (output, attributes)
|
||||
|
||||
|
||||
def get_stats(self):
|
||||
""" Return a dictionary with current console cursor and scrolling information. """
|
||||
|
||||
try:
|
||||
rescroll = self.shm_rescroll.read()
|
||||
if rescroll != '' and rescroll != None:
|
||||
|
||||
|
||||
|
||||
self.shm_rescroll.clear()
|
||||
|
||||
# close down old memory
|
||||
self.shm_output.close()
|
||||
self.shm_output = None
|
||||
|
||||
if not CONQUE_FAST_MODE:
|
||||
self.shm_attributes.close()
|
||||
self.shm_attributes = None
|
||||
|
||||
# reallocate memory
|
||||
|
||||
self.shm_output = ConqueSoleSharedMemory(CONQUE_SOLE_BUFFER_LENGTH * self.columns * rescroll['data']['blocks'], 'output', rescroll['data']['mem_key'], True)
|
||||
self.shm_output.create('read')
|
||||
|
||||
if not CONQUE_FAST_MODE:
|
||||
self.shm_attributes = ConqueSoleSharedMemory(CONQUE_SOLE_BUFFER_LENGTH * self.columns * rescroll['data']['blocks'], 'attributes', rescroll['data']['mem_key'], True, encoding='latin-1')
|
||||
self.shm_attributes.create('read')
|
||||
|
||||
stats_str = self.shm_stats.read()
|
||||
if stats_str != '':
|
||||
self.stats = stats_str
|
||||
else:
|
||||
return False
|
||||
except:
|
||||
|
||||
return False
|
||||
|
||||
return self.stats
|
||||
|
||||
|
||||
def is_alive(self):
|
||||
""" Get process status. """
|
||||
|
||||
if not self.shm_stats:
|
||||
return True
|
||||
|
||||
stats_str = self.shm_stats.read()
|
||||
if stats_str:
|
||||
return (stats_str['is_alive'])
|
||||
else:
|
||||
return True
|
||||
|
||||
|
||||
def write(self, text):
|
||||
""" Write input to shared memory. """
|
||||
|
||||
self.bucket += text
|
||||
|
||||
istr = self.shm_input.read()
|
||||
|
||||
if istr == '':
|
||||
|
||||
self.shm_input.write(self.bucket[:500])
|
||||
self.bucket = self.bucket[500:]
|
||||
|
||||
|
||||
def write_vk(self, vk_code):
|
||||
""" Write virtual key code to shared memory using proprietary escape sequences. """
|
||||
|
||||
seq = u("\x1b[") + u(str(vk_code)) + u("VK")
|
||||
self.write(seq)
|
||||
|
||||
|
||||
def idle(self):
|
||||
""" Write idle command to shared memory block, so subprocess controller can hibernate. """
|
||||
|
||||
|
||||
self.shm_command.write({'cmd': 'idle', 'data': {}})
|
||||
|
||||
|
||||
def resume(self):
|
||||
""" Write resume command to shared memory block, so subprocess controller can wake up. """
|
||||
|
||||
self.shm_command.write({'cmd': 'resume', 'data': {}})
|
||||
|
||||
|
||||
def close(self):
|
||||
""" Shut it all down. """
|
||||
|
||||
self.shm_command.write({'cmd': 'close', 'data': {}})
|
||||
time.sleep(0.2)
|
||||
|
||||
|
||||
def window_resize(self, lines, columns):
|
||||
""" Resize console window. """
|
||||
|
||||
self.lines = lines
|
||||
|
||||
# we don't shrink buffer width
|
||||
if columns > self.columns:
|
||||
self.columns = columns
|
||||
|
||||
self.shm_resize.write({'cmd': 'resize', 'data': {'width': columns, 'height': lines}})
|
||||
|
||||
|
||||
def init_shared_memory(self, mem_key):
|
||||
""" Create shared memory objects. """
|
||||
|
||||
self.shm_input = ConqueSoleSharedMemory(CONQUE_SOLE_INPUT_SIZE, 'input', mem_key)
|
||||
self.shm_input.create('write')
|
||||
self.shm_input.clear()
|
||||
|
||||
self.shm_output = ConqueSoleSharedMemory(CONQUE_SOLE_BUFFER_LENGTH * self.columns, 'output', mem_key, True)
|
||||
self.shm_output.create('write')
|
||||
|
||||
if not CONQUE_FAST_MODE:
|
||||
self.shm_attributes = ConqueSoleSharedMemory(CONQUE_SOLE_BUFFER_LENGTH * self.columns, 'attributes', mem_key, True, encoding='latin-1')
|
||||
self.shm_attributes.create('write')
|
||||
|
||||
self.shm_stats = ConqueSoleSharedMemory(CONQUE_SOLE_STATS_SIZE, 'stats', mem_key, serialize=True)
|
||||
self.shm_stats.create('write')
|
||||
self.shm_stats.clear()
|
||||
|
||||
self.shm_command = ConqueSoleSharedMemory(CONQUE_SOLE_COMMANDS_SIZE, 'command', mem_key, serialize=True)
|
||||
self.shm_command.create('write')
|
||||
self.shm_command.clear()
|
||||
|
||||
self.shm_resize = ConqueSoleSharedMemory(CONQUE_SOLE_RESIZE_SIZE, 'resize', mem_key, serialize=True)
|
||||
self.shm_resize.create('write')
|
||||
self.shm_resize.clear()
|
||||
|
||||
self.shm_rescroll = ConqueSoleSharedMemory(CONQUE_SOLE_RESCROLL_SIZE, 'rescroll', mem_key, serialize=True)
|
||||
self.shm_rescroll.create('write')
|
||||
self.shm_rescroll.clear()
|
||||
|
||||
return True
|
||||
|
||||
|
||||
# vim:foldmethod=marker
|
|
@ -1,198 +0,0 @@
|
|||
# FILE: autoload/conque_term/conque_subprocess.py
|
||||
# AUTHOR: Nico Raffo <nicoraffo@gmail.com>
|
||||
# WEBSITE: http://conque.googlecode.com
|
||||
# MODIFIED: 2011-04-04
|
||||
# VERSION: 2.1, for Vim 7.0
|
||||
# LICENSE:
|
||||
# Conque - Vim terminal/console emulator
|
||||
# Copyright (C) 2009-2011 Nico Raffo
|
||||
#
|
||||
# MIT License
|
||||
#
|
||||
# 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.
|
||||
|
||||
"""
|
||||
ConqueSubprocess
|
||||
|
||||
Create and interact with a subprocess through a pty.
|
||||
|
||||
Usage:
|
||||
|
||||
p = ConqueSubprocess()
|
||||
p.open('bash', {'TERM':'vt100'})
|
||||
output = p.read()
|
||||
p.write('cd ~/vim' + "\r")
|
||||
p.write('ls -lha' + "\r")
|
||||
output += p.read(timeout = 500)
|
||||
p.close()
|
||||
"""
|
||||
|
||||
import os
|
||||
import signal
|
||||
import pty
|
||||
import tty
|
||||
import select
|
||||
import fcntl
|
||||
import termios
|
||||
import struct
|
||||
import shlex
|
||||
|
||||
|
||||
class ConqueSubprocess:
|
||||
|
||||
# process id
|
||||
pid = 0
|
||||
|
||||
# stdout+stderr file descriptor
|
||||
fd = None
|
||||
|
||||
|
||||
def open(self, command, env={}):
|
||||
""" Create subprocess using forkpty() """
|
||||
|
||||
# parse command
|
||||
command_arr = shlex.split(command)
|
||||
executable = command_arr[0]
|
||||
args = command_arr
|
||||
|
||||
# try to fork a new pty
|
||||
try:
|
||||
self.pid, self.fd = pty.fork()
|
||||
|
||||
except:
|
||||
|
||||
return False
|
||||
|
||||
# child proc, replace with command after altering terminal attributes
|
||||
if self.pid == 0:
|
||||
|
||||
# set requested environment variables
|
||||
for k in env.keys():
|
||||
os.environ[k] = env[k]
|
||||
|
||||
# set tty attributes
|
||||
try:
|
||||
attrs = tty.tcgetattr(1)
|
||||
attrs[0] = attrs[0] ^ tty.IGNBRK
|
||||
attrs[0] = attrs[0] | tty.BRKINT | tty.IXANY | tty.IMAXBEL
|
||||
attrs[2] = attrs[2] | tty.HUPCL
|
||||
attrs[3] = attrs[3] | tty.ICANON | tty.ECHO | tty.ISIG | tty.ECHOKE
|
||||
attrs[6][tty.VMIN] = 1
|
||||
attrs[6][tty.VTIME] = 0
|
||||
tty.tcsetattr(1, tty.TCSANOW, attrs)
|
||||
except:
|
||||
|
||||
pass
|
||||
|
||||
# replace this process with the subprocess
|
||||
os.execvp(executable, args)
|
||||
|
||||
# else master, do nothing
|
||||
else:
|
||||
pass
|
||||
|
||||
|
||||
def read(self, timeout=1):
|
||||
""" Read from subprocess and return new output """
|
||||
|
||||
output = ''
|
||||
read_timeout = float(timeout) / 1000
|
||||
read_ct = 0
|
||||
|
||||
try:
|
||||
# read from fd until no more output
|
||||
while 1:
|
||||
s_read, s_write, s_error = select.select([self.fd], [], [], read_timeout)
|
||||
|
||||
lines = ''
|
||||
for s_fd in s_read:
|
||||
try:
|
||||
# increase read buffer so huge reads don't slow down
|
||||
if read_ct < 10:
|
||||
lines = os.read(self.fd, 32)
|
||||
elif read_ct < 50:
|
||||
lines = os.read(self.fd, 512)
|
||||
else:
|
||||
lines = os.read(self.fd, 2048)
|
||||
read_ct += 1
|
||||
except:
|
||||
pass
|
||||
output = output + lines.decode('utf-8')
|
||||
|
||||
if lines == '' or read_ct > 100:
|
||||
break
|
||||
except:
|
||||
|
||||
pass
|
||||
|
||||
return output
|
||||
|
||||
|
||||
def write(self, input):
|
||||
""" Write new input to subprocess """
|
||||
|
||||
try:
|
||||
if CONQUE_PYTHON_VERSION == 2:
|
||||
os.write(self.fd, input.encode('utf-8', 'ignore'))
|
||||
else:
|
||||
os.write(self.fd, bytes(input, 'utf-8'))
|
||||
except:
|
||||
|
||||
pass
|
||||
|
||||
|
||||
def signal(self, signum):
|
||||
""" signal process """
|
||||
|
||||
try:
|
||||
os.kill(self.pid, signum)
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
def close(self):
|
||||
""" close process with sigterm signal """
|
||||
|
||||
self.signal(15)
|
||||
|
||||
|
||||
def is_alive(self):
|
||||
""" get process status """
|
||||
|
||||
p_status = True
|
||||
try:
|
||||
if os.waitpid(self.pid, os.WNOHANG)[0]:
|
||||
p_status = False
|
||||
except:
|
||||
p_status = False
|
||||
|
||||
return p_status
|
||||
|
||||
|
||||
def window_resize(self, lines, columns):
|
||||
""" update window size in kernel, then send SIGWINCH to fg process """
|
||||
|
||||
try:
|
||||
fcntl.ioctl(self.fd, termios.TIOCSWINSZ, struct.pack("HHHH", lines, columns, 0, 0))
|
||||
os.kill(self.pid, signal.SIGWINCH)
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
# vim:foldmethod=marker
|
|
@ -1,448 +0,0 @@
|
|||
# FILE: autoload/conque_term/conque_win32_util.py
|
||||
# AUTHOR: Nico Raffo <nicoraffo@gmail.com>
|
||||
# WEBSITE: http://conque.googlecode.com
|
||||
# MODIFIED: 2011-04-04
|
||||
# VERSION: 2.1, for Vim 7.0
|
||||
# LICENSE:
|
||||
# Conque - Vim terminal/console emulator
|
||||
# Copyright (C) 2009-2011 Nico Raffo
|
||||
#
|
||||
# MIT License
|
||||
#
|
||||
# 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.
|
||||
|
||||
""" Python constants and structures used for ctypes interaction. """
|
||||
|
||||
from ctypes import *
|
||||
|
||||
# Constants
|
||||
|
||||
# create process flag constants
|
||||
|
||||
CREATE_BREAKAWAY_FROM_JOB = 0x01000000
|
||||
CREATE_DEFAULT_ERROR_MODE = 0x04000000
|
||||
CREATE_NEW_CONSOLE = 0x00000010
|
||||
CREATE_NEW_PROCESS_GROUP = 0x00000200
|
||||
CREATE_NO_WINDOW = 0x08000000
|
||||
CREATE_PROTECTED_PROCESS = 0x00040000
|
||||
CREATE_PRESERVE_CODE_AUTHZ_LEVEL = 0x02000000
|
||||
CREATE_SEPARATE_WOW_VDM = 0x00000800
|
||||
CREATE_SHARED_WOW_VDM = 0x00001000
|
||||
CREATE_SUSPENDED = 0x00000004
|
||||
CREATE_UNICODE_ENVIRONMENT = 0x00000400
|
||||
|
||||
|
||||
DETACHED_PROCESS = 0x00000008
|
||||
EXTENDED_STARTUPINFO_PRESENT = 0x00080000
|
||||
INHERIT_PARENT_AFFINITY = 0x00010000
|
||||
|
||||
|
||||
# process priority constants
|
||||
|
||||
ABOVE_NORMAL_PRIORITY_CLASS = 0x00008000
|
||||
BELOW_NORMAL_PRIORITY_CLASS = 0x00004000
|
||||
HIGH_PRIORITY_CLASS = 0x00000080
|
||||
IDLE_PRIORITY_CLASS = 0x00000040
|
||||
NORMAL_PRIORITY_CLASS = 0x00000020
|
||||
REALTIME_PRIORITY_CLASS = 0x00000100
|
||||
|
||||
|
||||
# startup info constants
|
||||
|
||||
STARTF_FORCEONFEEDBACK = 0x00000040
|
||||
STARTF_FORCEOFFFEEDBACK = 0x00000080
|
||||
STARTF_PREVENTPINNING = 0x00002000
|
||||
STARTF_RUNFULLSCREEN = 0x00000020
|
||||
STARTF_TITLEISAPPID = 0x00001000
|
||||
STARTF_TITLEISLINKNAME = 0x00000800
|
||||
STARTF_USECOUNTCHARS = 0x00000008
|
||||
STARTF_USEFILLATTRIBUTE = 0x00000010
|
||||
STARTF_USEHOTKEY = 0x00000200
|
||||
STARTF_USEPOSITION = 0x00000004
|
||||
STARTF_USESHOWWINDOW = 0x00000001
|
||||
STARTF_USESIZE = 0x00000002
|
||||
STARTF_USESTDHANDLES = 0x00000100
|
||||
|
||||
|
||||
# show window constants
|
||||
|
||||
SW_FORCEMINIMIZE = 11
|
||||
SW_HIDE = 0
|
||||
SW_MAXIMIZE = 3
|
||||
SW_MINIMIZE = 6
|
||||
SW_RESTORE = 9
|
||||
SW_SHOW = 5
|
||||
SW_SHOWDEFAULT = 10
|
||||
SW_SHOWMAXIMIZED = 3
|
||||
SW_SHOWMINIMIZED = 2
|
||||
SW_SHOWMINNOACTIVE = 7
|
||||
SW_SHOWNA = 8
|
||||
SW_SHOWNOACTIVATE = 4
|
||||
SW_SHOWNORMAL = 1
|
||||
|
||||
|
||||
# input event types
|
||||
|
||||
FOCUS_EVENT = 0x0010
|
||||
KEY_EVENT = 0x0001
|
||||
MENU_EVENT = 0x0008
|
||||
MOUSE_EVENT = 0x0002
|
||||
WINDOW_BUFFER_SIZE_EVENT = 0x0004
|
||||
|
||||
|
||||
# key event modifiers
|
||||
|
||||
CAPSLOCK_ON = 0x0080
|
||||
ENHANCED_KEY = 0x0100
|
||||
LEFT_ALT_PRESSED = 0x0002
|
||||
LEFT_CTRL_PRESSED = 0x0008
|
||||
NUMLOCK_ON = 0x0020
|
||||
RIGHT_ALT_PRESSED = 0x0001
|
||||
RIGHT_CTRL_PRESSED = 0x0004
|
||||
SCROLLLOCK_ON = 0x0040
|
||||
SHIFT_PRESSED = 0x0010
|
||||
|
||||
|
||||
# process access
|
||||
|
||||
PROCESS_CREATE_PROCESS = 0x0080
|
||||
PROCESS_CREATE_THREAD = 0x0002
|
||||
PROCESS_DUP_HANDLE = 0x0040
|
||||
PROCESS_QUERY_INFORMATION = 0x0400
|
||||
PROCESS_QUERY_LIMITED_INFORMATION = 0x1000
|
||||
PROCESS_SET_INFORMATION = 0x0200
|
||||
PROCESS_SET_QUOTA = 0x0100
|
||||
PROCESS_SUSPEND_RESUME = 0x0800
|
||||
PROCESS_TERMINATE = 0x0001
|
||||
PROCESS_VM_OPERATION = 0x0008
|
||||
PROCESS_VM_READ = 0x0010
|
||||
PROCESS_VM_WRITE = 0x0020
|
||||
|
||||
|
||||
# input / output handles
|
||||
|
||||
STD_INPUT_HANDLE = c_ulong(-10)
|
||||
STD_OUTPUT_HANDLE = c_ulong(-11)
|
||||
STD_ERROR_HANDLE = c_ulong(-12)
|
||||
|
||||
|
||||
CONQUE_WINDOWS_VK = {
|
||||
'VK_LBUTTON': 0x0001,
|
||||
'VK_RBUTTON': 0x0002,
|
||||
'VK_CANCEL': 0x0003,
|
||||
'VK_BACK': 0x0008,
|
||||
'VK_TAB': 0x0009,
|
||||
'VK_CLEAR': 0x000C,
|
||||
'VK_RETURN': 0x0D,
|
||||
'VK_SHIFT': 0x10,
|
||||
'VK_CONTROL': 0x11,
|
||||
'VK_MENU': 0x12,
|
||||
'VK_PAUSE': 0x0013,
|
||||
'VK_CAPITAL': 0x0014,
|
||||
'VK_ESCAPE': 0x001B,
|
||||
'VK_SPACE': 0x0020,
|
||||
'VK_PRIOR': 0x0021,
|
||||
'VK_NEXT': 0x0022,
|
||||
'VK_END': 0x0023,
|
||||
'VK_HOME': 0x0024,
|
||||
'VK_LEFT': 0x0025,
|
||||
'VK_UP': 0x0026,
|
||||
'VK_RIGHT': 0x0027,
|
||||
'VK_DOWN': 0x0028,
|
||||
'VK_SELECT': 0x0029,
|
||||
'VK_PRINT': 0x002A,
|
||||
'VK_EXECUTE': 0x002B,
|
||||
'VK_SNAPSHOT': 0x002C,
|
||||
'VK_INSERT': 0x002D,
|
||||
'VK_DELETE': 0x002E,
|
||||
'VK_HELP': 0x002F,
|
||||
'VK_0': 0x0030,
|
||||
'VK_1': 0x0031,
|
||||
'VK_2': 0x0032,
|
||||
'VK_3': 0x0033,
|
||||
'VK_4': 0x0034,
|
||||
'VK_5': 0x0035,
|
||||
'VK_6': 0x0036,
|
||||
'VK_7': 0x0037,
|
||||
'VK_8': 0x0038,
|
||||
'VK_9': 0x0039,
|
||||
'VK_A': 0x0041,
|
||||
'VK_B': 0x0042,
|
||||
'VK_C': 0x0043,
|
||||
'VK_D': 0x0044,
|
||||
'VK_E': 0x0045,
|
||||
'VK_F': 0x0046,
|
||||
'VK_G': 0x0047,
|
||||
'VK_H': 0x0048,
|
||||
'VK_I': 0x0049,
|
||||
'VK_J': 0x004A,
|
||||
'VK_K': 0x004B,
|
||||
'VK_L': 0x004C,
|
||||
'VK_M': 0x004D,
|
||||
'VK_N': 0x004E,
|
||||
'VK_O': 0x004F,
|
||||
'VK_P': 0x0050,
|
||||
'VK_Q': 0x0051,
|
||||
'VK_R': 0x0052,
|
||||
'VK_S': 0x0053,
|
||||
'VK_T': 0x0054,
|
||||
'VK_U': 0x0055,
|
||||
'VK_V': 0x0056,
|
||||
'VK_W': 0x0057,
|
||||
'VK_X': 0x0058,
|
||||
'VK_Y': 0x0059,
|
||||
'VK_Z': 0x005A,
|
||||
'VK_LWIN': 0x005B,
|
||||
'VK_RWIN': 0x005C,
|
||||
'VK_APPS': 0x005D,
|
||||
'VK_SLEEP': 0x005F,
|
||||
'VK_NUMPAD0': 0x0060,
|
||||
'VK_NUMPAD1': 0x0061,
|
||||
'VK_NUMPAD2': 0x0062,
|
||||
'VK_NUMPAD3': 0x0063,
|
||||
'VK_NUMPAD4': 0x0064,
|
||||
'VK_NUMPAD5': 0x0065,
|
||||
'VK_NUMPAD6': 0x0066,
|
||||
'VK_NUMPAD7': 0x0067,
|
||||
'VK_NUMPAD8': 0x0068,
|
||||
'VK_MULTIPLY': 0x006A,
|
||||
'VK_ADD': 0x006B,
|
||||
'VK_SEPARATOR': 0x006C,
|
||||
'VK_SUBTRACT': 0x006D,
|
||||
'VK_DECIMAL': 0x006E,
|
||||
'VK_DIVIDE': 0x006F,
|
||||
'VK_F1': 0x0070,
|
||||
'VK_F2': 0x0071,
|
||||
'VK_F3': 0x0072,
|
||||
'VK_F4': 0x0073,
|
||||
'VK_F5': 0x0074,
|
||||
'VK_F6': 0x0075,
|
||||
'VK_F7': 0x0076,
|
||||
'VK_F8': 0x0077,
|
||||
'VK_F9': 0x0078,
|
||||
'VK_F10': 0x0079,
|
||||
'VK_F11': 0x007A,
|
||||
'VK_F12': 0x007B,
|
||||
'VK_F13': 0x007C,
|
||||
'VK_F14': 0x007D,
|
||||
'VK_F15': 0x007E,
|
||||
'VK_F16': 0x007F,
|
||||
'VK_F17': 0x0080,
|
||||
'VK_F18': 0x0081,
|
||||
'VK_F19': 0x0082,
|
||||
'VK_F20': 0x0083,
|
||||
'VK_F21': 0x0084,
|
||||
'VK_F22': 0x0085,
|
||||
'VK_F23': 0x0086,
|
||||
'VK_F24': 0x0087,
|
||||
'VK_NUMLOCK': 0x0090,
|
||||
'VK_SCROLL': 0x0091,
|
||||
'VK_LSHIFT': 0x00A0,
|
||||
'VK_RSHIFT': 0x00A1,
|
||||
'VK_LCONTROL': 0x00A2,
|
||||
'VK_RCONTROL': 0x00A3,
|
||||
'VK_LMENU': 0x00A4,
|
||||
'VK_RMENU': 0x00A5
|
||||
}
|
||||
|
||||
CONQUE_WINDOWS_VK_INV = dict([v, k] for k, v in CONQUE_WINDOWS_VK.items())
|
||||
|
||||
CONQUE_WINDOWS_VK_ENHANCED = {
|
||||
str(int(CONQUE_WINDOWS_VK['VK_UP'])): 1,
|
||||
str(int(CONQUE_WINDOWS_VK['VK_DOWN'])): 1,
|
||||
str(int(CONQUE_WINDOWS_VK['VK_LEFT'])): 1,
|
||||
str(int(CONQUE_WINDOWS_VK['VK_RIGHT'])): 1,
|
||||
str(int(CONQUE_WINDOWS_VK['VK_HOME'])): 1,
|
||||
str(int(CONQUE_WINDOWS_VK['VK_END'])): 1
|
||||
}
|
||||
|
||||
|
||||
# structures used for CreateProcess
|
||||
|
||||
# Odd types
|
||||
|
||||
LPBYTE = POINTER(c_ubyte)
|
||||
LPTSTR = POINTER(c_char)
|
||||
|
||||
|
||||
class STARTUPINFO(Structure):
|
||||
_fields_ = [("cb", c_ulong),
|
||||
("lpReserved", LPTSTR),
|
||||
("lpDesktop", LPTSTR),
|
||||
("lpTitle", LPTSTR),
|
||||
("dwX", c_ulong),
|
||||
("dwY", c_ulong),
|
||||
("dwXSize", c_ulong),
|
||||
("dwYSize", c_ulong),
|
||||
("dwXCountChars", c_ulong),
|
||||
("dwYCountChars", c_ulong),
|
||||
("dwFillAttribute", c_ulong),
|
||||
("dwFlags", c_ulong),
|
||||
("wShowWindow", c_short),
|
||||
("cbReserved2", c_short),
|
||||
("lpReserved2", LPBYTE),
|
||||
("hStdInput", c_void_p),
|
||||
("hStdOutput", c_void_p),
|
||||
("hStdError", c_void_p),]
|
||||
|
||||
def to_str(self):
|
||||
return ''
|
||||
|
||||
|
||||
class PROCESS_INFORMATION(Structure):
|
||||
_fields_ = [("hProcess", c_void_p),
|
||||
("hThread", c_void_p),
|
||||
("dwProcessId", c_ulong),
|
||||
("dwThreadId", c_ulong),]
|
||||
|
||||
def to_str(self):
|
||||
return ''
|
||||
|
||||
|
||||
class MEMORY_BASIC_INFORMATION(Structure):
|
||||
_fields_ = [("BaseAddress", c_void_p),
|
||||
("AllocationBase", c_void_p),
|
||||
("AllocationProtect", c_ulong),
|
||||
("RegionSize", c_ulong),
|
||||
("State", c_ulong),
|
||||
("Protect", c_ulong),
|
||||
("Type", c_ulong),]
|
||||
|
||||
def to_str(self):
|
||||
return ''
|
||||
|
||||
|
||||
class SECURITY_ATTRIBUTES(Structure):
|
||||
_fields_ = [("Length", c_ulong),
|
||||
("SecDescriptor", c_void_p),
|
||||
("InheritHandle", c_bool)]
|
||||
|
||||
def to_str(self):
|
||||
return ''
|
||||
|
||||
|
||||
class COORD(Structure):
|
||||
_fields_ = [("X", c_short),
|
||||
("Y", c_short)]
|
||||
|
||||
def to_str(self):
|
||||
return ''
|
||||
|
||||
|
||||
class SMALL_RECT(Structure):
|
||||
_fields_ = [("Left", c_short),
|
||||
("Top", c_short),
|
||||
("Right", c_short),
|
||||
("Bottom", c_short)]
|
||||
|
||||
def to_str(self):
|
||||
return ''
|
||||
|
||||
|
||||
class CONSOLE_SCREEN_BUFFER_INFO(Structure):
|
||||
_fields_ = [("dwSize", COORD),
|
||||
("dwCursorPosition", COORD),
|
||||
("wAttributes", c_short),
|
||||
("srWindow", SMALL_RECT),
|
||||
("dwMaximumWindowSize", COORD)]
|
||||
|
||||
def to_str(self):
|
||||
return ''
|
||||
|
||||
|
||||
class CHAR_UNION(Union):
|
||||
_fields_ = [("UnicodeChar", c_wchar),
|
||||
("AsciiChar", c_char)]
|
||||
|
||||
def to_str(self):
|
||||
return ''
|
||||
|
||||
|
||||
class CHAR_INFO(Structure):
|
||||
_fields_ = [("Char", CHAR_UNION),
|
||||
("Attributes", c_short)]
|
||||
|
||||
def to_str(self):
|
||||
return ''
|
||||
|
||||
|
||||
class KEY_EVENT_RECORD(Structure):
|
||||
_fields_ = [("bKeyDown", c_byte),
|
||||
("pad2", c_byte),
|
||||
('pad1', c_short),
|
||||
("wRepeatCount", c_short),
|
||||
("wVirtualKeyCode", c_short),
|
||||
("wVirtualScanCode", c_short),
|
||||
("uChar", CHAR_UNION),
|
||||
("dwControlKeyState", c_int)]
|
||||
|
||||
def to_str(self):
|
||||
return ''
|
||||
|
||||
|
||||
class MOUSE_EVENT_RECORD(Structure):
|
||||
_fields_ = [("dwMousePosition", COORD),
|
||||
("dwButtonState", c_int),
|
||||
("dwControlKeyState", c_int),
|
||||
("dwEventFlags", c_int)]
|
||||
|
||||
def to_str(self):
|
||||
return ''
|
||||
|
||||
|
||||
class WINDOW_BUFFER_SIZE_RECORD(Structure):
|
||||
_fields_ = [("dwSize", COORD)]
|
||||
|
||||
def to_str(self):
|
||||
return ''
|
||||
|
||||
|
||||
class MENU_EVENT_RECORD(Structure):
|
||||
_fields_ = [("dwCommandId", c_uint)]
|
||||
|
||||
def to_str(self):
|
||||
return ''
|
||||
|
||||
|
||||
class FOCUS_EVENT_RECORD(Structure):
|
||||
_fields_ = [("bSetFocus", c_byte)]
|
||||
|
||||
def to_str(self):
|
||||
return ''
|
||||
|
||||
|
||||
class INPUT_UNION(Union):
|
||||
_fields_ = [("KeyEvent", KEY_EVENT_RECORD),
|
||||
("MouseEvent", MOUSE_EVENT_RECORD),
|
||||
("WindowBufferSizeEvent", WINDOW_BUFFER_SIZE_RECORD),
|
||||
("MenuEvent", MENU_EVENT_RECORD),
|
||||
("FocusEvent", FOCUS_EVENT_RECORD)]
|
||||
|
||||
def to_str(self):
|
||||
return ''
|
||||
|
||||
|
||||
class INPUT_RECORD(Structure):
|
||||
_fields_ = [("EventType", c_short),
|
||||
("Event", INPUT_UNION)]
|
||||
|
||||
def to_str(self):
|
||||
return ''
|
||||
|
||||
|
|
@ -1,659 +0,0 @@
|
|||
" File: autoload/delimitMate.vim
|
||||
" Version: 2.7
|
||||
" Modified: 2013-07-15
|
||||
" Description: This plugin provides auto-completion for quotes, parens, etc.
|
||||
" Maintainer: Israel Chauca F. <israelchauca@gmail.com>
|
||||
" Manual: Read ":help delimitMate".
|
||||
" ============================================================================
|
||||
|
||||
"let delimitMate_loaded = 1
|
||||
|
||||
if !exists('s:options')
|
||||
let s:options = {}
|
||||
endif
|
||||
|
||||
function! s:set(name, value, ...) "{{{
|
||||
let scope = a:0 ? a:1 : 's'
|
||||
let bufnr = bufnr('%')
|
||||
if !exists('s:options[bufnr]')
|
||||
let s:options[bufnr] = {}
|
||||
endif
|
||||
if scope == 's'
|
||||
let name = 's:options.' . bufnr . '.' . a:name
|
||||
else
|
||||
let name = scope . ':delimitMate_' . a:name
|
||||
if exists('name')
|
||||
exec 'unlet! ' . name
|
||||
endif
|
||||
endif
|
||||
exec 'let ' . name . ' = a:value'
|
||||
endfunction "}}}
|
||||
|
||||
function! s:get(name, ...) "{{{
|
||||
if a:0 == 2
|
||||
return deepcopy(get(a:2, 'delimitMate_' . a:name, a:1))
|
||||
elseif a:0 == 1
|
||||
let bufoptions = get(s:options, bufnr('%'), {})
|
||||
return deepcopy(get(bufoptions, a:name, a:1))
|
||||
else
|
||||
return deepcopy(eval('s:options.' . bufnr('%') . '.' . a:name))
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! s:exists(name, ...) "{{{
|
||||
let scope = a:0 ? a:1 : 's'
|
||||
if scope == 's'
|
||||
let bufnr = bufnr('%')
|
||||
let name = 'options.' . bufnr . '.' . a:name
|
||||
else
|
||||
let name = 'delimitMate_' . a:name
|
||||
endif
|
||||
return exists(scope . ':' . name)
|
||||
endfunction "}}}
|
||||
|
||||
function! s:is_jump(...) "{{{
|
||||
" Returns 1 if the next character is a closing delimiter.
|
||||
let char = s:get_char(0)
|
||||
let list = s:get('right_delims') + s:get('quotes_list')
|
||||
|
||||
" Closing delimiter on the right.
|
||||
if (!a:0 && index(list, char) > -1)
|
||||
\ || (a:0 && char == a:1)
|
||||
return 1
|
||||
endif
|
||||
|
||||
" Closing delimiter with space expansion.
|
||||
let nchar = s:get_char(1)
|
||||
if !a:0 && s:get('expand_space') && char == " "
|
||||
if index(list, nchar) > -1
|
||||
return 2
|
||||
endif
|
||||
elseif a:0 && s:get('expand_space') && nchar == a:1 && char == ' '
|
||||
return 3
|
||||
endif
|
||||
|
||||
if !s:get('jump_expansion')
|
||||
return 0
|
||||
endif
|
||||
|
||||
" Closing delimiter with CR expansion.
|
||||
let uchar = matchstr(getline(line('.') + 1), '^\s*\zs\S')
|
||||
if !a:0 && s:get('expand_cr') && char == ""
|
||||
if index(list, uchar) > -1
|
||||
return 4
|
||||
endif
|
||||
elseif a:0 && s:get('expand_cr') && uchar == a:1
|
||||
return 5
|
||||
endif
|
||||
return 0
|
||||
endfunction "}}}
|
||||
|
||||
function! s:rquote(char) "{{{
|
||||
let pos = matchstr(getline('.')[col('.') : ], escape(a:char, '[]*.^$\'), 1)
|
||||
let i = 0
|
||||
while s:get_char(i) ==# a:char
|
||||
let i += 1
|
||||
endwhile
|
||||
return i
|
||||
endfunction "}}}
|
||||
|
||||
function! s:lquote(char) "{{{
|
||||
let i = 0
|
||||
while s:get_char(i - 1) ==# a:char
|
||||
let i -= 1
|
||||
endwhile
|
||||
return i * -1
|
||||
endfunction "}}}
|
||||
|
||||
function! s:get_char(...) "{{{
|
||||
let idx = col('.') - 1
|
||||
if !a:0 || (a:0 && a:1 >= 0)
|
||||
" Get char from cursor.
|
||||
let line = getline('.')[idx :]
|
||||
let pos = a:0 ? a:1 : 0
|
||||
return matchstr(line, '^'.repeat('.', pos).'\zs.')
|
||||
endif
|
||||
" Get char behind cursor.
|
||||
let line = getline('.')[: idx - 1]
|
||||
let pos = 0 - (1 + a:1)
|
||||
return matchstr(line, '.\ze'.repeat('.', pos).'$')
|
||||
endfunction "s:get_char }}}
|
||||
|
||||
function! s:is_cr_expansion(...) " {{{
|
||||
let nchar = getline(line('.')-1)[-1:]
|
||||
let schar = matchstr(getline(line('.')+1), '^\s*\zs\S')
|
||||
let isEmpty = a:0 ? getline('.') =~ '^\s*$' : empty(getline('.'))
|
||||
if index(s:get('left_delims'), nchar) > -1
|
||||
\ && index(s:get('left_delims'), nchar)
|
||||
\ == index(s:get('right_delims'), schar)
|
||||
\ && isEmpty
|
||||
return 1
|
||||
elseif index(s:get('quotes_list'), nchar) > -1
|
||||
\ && index(s:get('quotes_list'), nchar)
|
||||
\ == index(s:get('quotes_list'), schar)
|
||||
\ && isEmpty
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
endif
|
||||
endfunction " }}} s:is_cr_expansion()
|
||||
|
||||
function! s:is_space_expansion() " {{{
|
||||
if col('.') > 2
|
||||
let pchar = s:get_char(-2)
|
||||
let nchar = s:get_char(1)
|
||||
let isSpaces =
|
||||
\ (s:get_char(-1)
|
||||
\ == s:get_char(0)
|
||||
\ && s:get_char(-1) == " ")
|
||||
|
||||
if index(s:get('left_delims'), pchar) > -1 &&
|
||||
\ index(s:get('left_delims'), pchar)
|
||||
\ == index(s:get('right_delims'), nchar) &&
|
||||
\ isSpaces
|
||||
return 1
|
||||
elseif index(s:get('quotes_list'), pchar) > -1 &&
|
||||
\ index(s:get('quotes_list'), pchar)
|
||||
\ == index(s:get('quotes_list'), nchar) &&
|
||||
\ isSpaces
|
||||
return 1
|
||||
endif
|
||||
endif
|
||||
return 0
|
||||
endfunction " }}} IsSpaceExpansion()
|
||||
|
||||
function! s:is_empty_matchpair() "{{{
|
||||
" get char before the cursor.
|
||||
let open = s:get_char(-1)
|
||||
let idx = index(s:get('left_delims'), open)
|
||||
if idx == -1
|
||||
return 0
|
||||
endif
|
||||
let close = get(s:get('right_delims'), idx, '')
|
||||
return close ==# s:get_char(0)
|
||||
endfunction "}}}
|
||||
|
||||
function! s:is_empty_quotes() "{{{
|
||||
" get char before the cursor.
|
||||
let quote = s:get_char(-1)
|
||||
let idx = index(s:get('quotes_list'), quote)
|
||||
if idx == -1
|
||||
return 0
|
||||
endif
|
||||
return quote ==# s:get_char(0)
|
||||
endfunction "}}}
|
||||
|
||||
function! s:cursor_idx() "{{{
|
||||
let idx = len(split(getline('.')[: col('.') - 1], '\zs')) - 1
|
||||
return idx
|
||||
endfunction "delimitMate#CursorCol }}}
|
||||
|
||||
function! s:get_syn_name() "{{{
|
||||
let col = col('.')
|
||||
if col == col('$')
|
||||
let col = col - 1
|
||||
endif
|
||||
return synIDattr(synIDtrans(synID(line('.'), col, 1)), 'name')
|
||||
endfunction " }}}
|
||||
|
||||
function! s:is_excluded_ft(ft) "{{{
|
||||
if !exists("g:delimitMate_excluded_ft")
|
||||
return 0
|
||||
endif
|
||||
return index(split(g:delimitMate_excluded_ft, ','), a:ft, 0, 1) >= 0
|
||||
endfunction "}}}
|
||||
|
||||
function! s:is_forbidden(char) "{{{
|
||||
if s:is_excluded_ft(&filetype)
|
||||
return 1
|
||||
endif
|
||||
if !s:get('excluded_regions_enabled')
|
||||
return 0
|
||||
endif
|
||||
let region = s:get_syn_name()
|
||||
return index(s:get('excluded_regions_list'), region) >= 0
|
||||
endfunction "}}}
|
||||
|
||||
function! s:balance_matchpairs(char) "{{{
|
||||
" Returns:
|
||||
" = 0 => Parens balanced.
|
||||
" > 0 => More opening parens.
|
||||
" < 0 => More closing parens.
|
||||
|
||||
let line = getline('.')
|
||||
let col = s:cursor_idx() - 1
|
||||
let col = col >= 0 ? col : 0
|
||||
let list = split(line, '\zs')
|
||||
let left = s:get('left_delims')[index(s:get('right_delims'), a:char)]
|
||||
let right = a:char
|
||||
let opening = 0
|
||||
let closing = 0
|
||||
|
||||
" If the cursor is not at the beginning, count what's behind it.
|
||||
if col > 0
|
||||
" Find the first opening paren:
|
||||
let start = index(list, left)
|
||||
" Must be before cursor:
|
||||
let start = start < col ? start : col - 1
|
||||
" Now count from the first opening until the cursor, this will prevent
|
||||
" extra closing parens from being counted.
|
||||
let opening = count(list[start : col - 1], left)
|
||||
let closing = count(list[start : col - 1], right)
|
||||
" I don't care if there are more closing parens than opening parens.
|
||||
let closing = closing > opening ? opening : closing
|
||||
endif
|
||||
|
||||
" Evaluate parens from the cursor to the end:
|
||||
let opening += count(list[col :], left)
|
||||
let closing += count(list[col :], right)
|
||||
|
||||
" Return the found balance:
|
||||
return opening - closing
|
||||
endfunction "}}}
|
||||
|
||||
function! s:is_smart_quote(char) "{{{
|
||||
" TODO: Allow using a:char in the pattern.
|
||||
let tmp = s:get('smart_quotes')
|
||||
if empty(tmp)
|
||||
return 0
|
||||
endif
|
||||
let regex = matchstr(tmp, '^!\?\zs.*')
|
||||
" Flip matched value if regex starts with !
|
||||
let mod = tmp =~ '^!' ? [1, 0] : [0, 1]
|
||||
let matched = search(regex, 'ncb', line('.')) > 0
|
||||
let noescaped = substitute(getline('.'), '\\.', '', 'g')
|
||||
let odd = (count(split(noescaped, '\zs'), a:char) % 2)
|
||||
let result = mod[matched] || odd
|
||||
return result
|
||||
endfunction "delimitMate#SmartQuote }}}
|
||||
|
||||
function! delimitMate#Set(...) "{{{
|
||||
return call('s:set', a:000)
|
||||
endfunction "}}}
|
||||
|
||||
function! delimitMate#Get(...) "{{{
|
||||
return call('s:get', a:000)
|
||||
endfunction "}}}
|
||||
|
||||
function! delimitMate#ShouldJump(...) "{{{
|
||||
return call('s:is_jump', a:000)
|
||||
endfunction "}}}
|
||||
|
||||
function! delimitMate#IsEmptyPair(str) "{{{
|
||||
if strlen(substitute(a:str, ".", "x", "g")) != 2
|
||||
return 0
|
||||
endif
|
||||
let idx = index(s:get('left_delims'), matchstr(a:str, '^.'))
|
||||
if idx > -1 &&
|
||||
\ s:get('right_delims')[idx] == matchstr(a:str, '.$')
|
||||
return 1
|
||||
endif
|
||||
let idx = index(s:get('quotes_list'), matchstr(a:str, '^.'))
|
||||
if idx > -1 &&
|
||||
\ s:get('quotes_list')[idx] == matchstr(a:str, '.$')
|
||||
return 1
|
||||
endif
|
||||
return 0
|
||||
endfunction "}}}
|
||||
|
||||
function! delimitMate#WithinEmptyPair() "{{{
|
||||
" if cursor is at column 1 return 0
|
||||
if col('.') == 1
|
||||
return 0
|
||||
endif
|
||||
" get char before the cursor.
|
||||
let char1 = s:get_char(-1)
|
||||
" get char under the cursor.
|
||||
let char2 = s:get_char(0)
|
||||
return delimitMate#IsEmptyPair( char1.char2 )
|
||||
endfunction "}}}
|
||||
|
||||
function! delimitMate#SkipDelim(char) "{{{
|
||||
if s:is_forbidden(a:char)
|
||||
return a:char
|
||||
endif
|
||||
let col = col('.') - 1
|
||||
let line = getline('.')
|
||||
if col > 0
|
||||
let cur = s:get_char(0)
|
||||
let pre = s:get_char(-1)
|
||||
else
|
||||
let cur = s:get_char(0)
|
||||
let pre = ""
|
||||
endif
|
||||
if pre == "\\"
|
||||
" Escaped character
|
||||
return a:char
|
||||
elseif cur == a:char
|
||||
" Exit pair
|
||||
return a:char . "\<Del>"
|
||||
elseif delimitMate#IsEmptyPair( pre . a:char )
|
||||
" Add closing delimiter and jump back to the middle.
|
||||
return a:char . "\<Left>"
|
||||
else
|
||||
" Nothing special here, return the same character.
|
||||
return a:char
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! delimitMate#ParenDelim(right) " {{{
|
||||
let left = s:get('left_delims')[index(s:get('right_delims'),a:right)]
|
||||
if s:is_forbidden(a:right)
|
||||
return left
|
||||
endif
|
||||
" Try to balance matchpairs
|
||||
if s:get('balance_matchpairs') &&
|
||||
\ s:balance_matchpairs(a:right) < 0
|
||||
return left
|
||||
endif
|
||||
let line = getline('.')
|
||||
let col = col('.')-2
|
||||
if s:get('smart_matchpairs') != ''
|
||||
let smart_matchpairs = substitute(s:get('smart_matchpairs'), '\\!', left, 'g')
|
||||
let smart_matchpairs = substitute(smart_matchpairs, '\\#', a:right, 'g')
|
||||
if line[col+1:] =~ smart_matchpairs
|
||||
return left
|
||||
endif
|
||||
endif
|
||||
if len(line) == (col + 1) && s:get('insert_eol_marker') == 1
|
||||
let tail = s:get('eol_marker')
|
||||
else
|
||||
let tail = ''
|
||||
endif
|
||||
return left . a:right . tail . repeat("\<Left>", len(split(tail, '\zs')) + 1)
|
||||
endfunction " }}}
|
||||
|
||||
function! delimitMate#QuoteDelim(char) "{{{
|
||||
if s:is_forbidden(a:char)
|
||||
return a:char
|
||||
endif
|
||||
let char_at = s:get_char(0)
|
||||
let char_before = s:get_char(-1)
|
||||
let nesting_on = index(s:get('nesting_quotes'), a:char) > -1
|
||||
let left_q = nesting_on ? s:lquote(a:char) : 0
|
||||
if nesting_on && left_q > 1
|
||||
" Nesting quotes.
|
||||
let right_q = s:rquote(a:char)
|
||||
let quotes = right_q > left_q + 1 ? 0 : left_q - right_q + 2
|
||||
let lefts = quotes - 1
|
||||
return repeat(a:char, quotes) . repeat("\<Left>", lefts)
|
||||
elseif char_at == a:char
|
||||
" Inside an empty pair, jump out
|
||||
return a:char . "\<Del>"
|
||||
elseif a:char == '"' && index(split(&ft, '\.'), "vim") != -1 && getline('.') =~ '^\s*$'
|
||||
" If we are in a vim file and it looks like we're starting a comment, do
|
||||
" not add a closing char.
|
||||
return a:char
|
||||
elseif s:is_smart_quote(a:char)
|
||||
" Seems like a smart quote, insert a single char.
|
||||
return a:char
|
||||
elseif (char_before == a:char && char_at != a:char)
|
||||
\ && !empty(s:get('smart_quotes'))
|
||||
" Seems like we have an unbalanced quote, insert one quotation
|
||||
" mark and jump to the middle.
|
||||
return a:char . "\<Left>"
|
||||
else
|
||||
" Insert a pair and jump to the middle.
|
||||
let sufix = ''
|
||||
if !empty(s:get('eol_marker')) && col('.') - 1 == len(getline('.'))
|
||||
let idx = len(s:get('eol_marker')) * -1
|
||||
let marker = getline('.')[idx : ]
|
||||
let has_marker = marker == s:get('eol_marker')
|
||||
let sufix = !has_marker ? s:get('eol_marker') : ''
|
||||
endif
|
||||
return a:char . a:char . "\<Left>"
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! delimitMate#JumpOut(char) "{{{
|
||||
if s:is_forbidden(a:char)
|
||||
return a:char
|
||||
endif
|
||||
let jump = s:is_jump(a:char)
|
||||
if jump == 1
|
||||
" HACK: Instead of <Right>, we remove the char to be jumped over and
|
||||
" insert it again. This will trigger re-indenting via 'indentkeys'.
|
||||
" Ref: https://github.com/Raimondi/delimitMate/issues/168
|
||||
return "\<Del>".a:char
|
||||
elseif jump == 3
|
||||
return "\<Right>\<Right>"
|
||||
elseif jump == 5
|
||||
return "\<Down>\<C-O>I\<Right>"
|
||||
else
|
||||
return a:char
|
||||
endif
|
||||
endfunction " }}}
|
||||
|
||||
function! delimitMate#JumpAny(...) " {{{
|
||||
if s:is_forbidden('')
|
||||
return ''
|
||||
endif
|
||||
if !s:is_jump()
|
||||
return ''
|
||||
endif
|
||||
" Let's get the character on the right.
|
||||
let char = s:get_char(0)
|
||||
if char == " "
|
||||
" Space expansion.
|
||||
return "\<Right>\<Right>"
|
||||
elseif char == ""
|
||||
" CR expansion.
|
||||
return "\<CR>" . getline(line('.') + 1)[0] . "\<Del>\<Del>"
|
||||
else
|
||||
return "\<Right>"
|
||||
endif
|
||||
endfunction " delimitMate#JumpAny() }}}
|
||||
|
||||
function! delimitMate#JumpMany() " {{{
|
||||
let line = split(getline('.')[col('.') - 1 : ], '\zs')
|
||||
let rights = ""
|
||||
let found = 0
|
||||
for char in line
|
||||
if index(s:get('quotes_list'), char) >= 0 ||
|
||||
\ index(s:get('right_delims'), char) >= 0
|
||||
let rights .= "\<Right>"
|
||||
let found = 1
|
||||
elseif found == 0
|
||||
let rights .= "\<Right>"
|
||||
else
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
if found == 1
|
||||
return rights
|
||||
else
|
||||
return ''
|
||||
endif
|
||||
endfunction " delimitMate#JumpMany() }}}
|
||||
|
||||
function! delimitMate#ExpandReturn() "{{{
|
||||
if s:is_forbidden("")
|
||||
return "\<CR>"
|
||||
endif
|
||||
let escaped = s:cursor_idx() >= 2
|
||||
\ && s:get_char(-2) == '\'
|
||||
let expand_right_matchpair = s:get('expand_cr') == 2
|
||||
\ && index(s:get('right_delims'), s:get_char(0)) > -1
|
||||
let expand_inside_quotes = s:get('expand_inside_quotes')
|
||||
\ && s:is_empty_quotes()
|
||||
\ && !escaped
|
||||
let is_empty_matchpair = s:is_empty_matchpair()
|
||||
if !pumvisible( )
|
||||
\ && ( is_empty_matchpair
|
||||
\ || expand_right_matchpair
|
||||
\ || expand_inside_quotes)
|
||||
let val = "\<Esc>a"
|
||||
if is_empty_matchpair && s:get('insert_eol_marker') == 2
|
||||
\ && !search(escape(s:get('eol_marker'), '[]\.*^$').'$', 'cnW', '.')
|
||||
let tail = getline('.')[col('.') - 1 : ]
|
||||
let times = len(split(tail, '\zs'))
|
||||
let val .= repeat("\<Right>", times) . s:get('eol_marker') . repeat("\<Left>", times + 1)
|
||||
endif
|
||||
let val .= "\<CR>"
|
||||
if &smartindent && !&cindent && !&indentexpr
|
||||
\ && s:get_char(0) == '}'
|
||||
" indentation is controlled by 'smartindent', and the first character on
|
||||
" the new line is '}'. If this were typed manually it would reindent to
|
||||
" match the current line. Let's reproduce that behavior.
|
||||
let shifts = indent('.') / &sw
|
||||
let spaces = indent('.') - (shifts * &sw)
|
||||
let val .= "^\<C-D>".repeat("\<C-T>", shifts).repeat(' ', spaces)
|
||||
endif
|
||||
" Expand:
|
||||
" XXX zv prevents breaking expansion with syntax folding enabled by
|
||||
" InsertLeave.
|
||||
let val .= "\<Esc>zvO"
|
||||
return val
|
||||
else
|
||||
return "\<CR>"
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! delimitMate#ExpandSpace() "{{{
|
||||
if s:is_forbidden("\<Space>")
|
||||
return "\<Space>"
|
||||
endif
|
||||
let escaped = s:cursor_idx() >= 2
|
||||
\ && s:get_char(-2) == '\'
|
||||
let expand_inside_quotes = s:get('expand_inside_quotes')
|
||||
\ && s:is_empty_quotes()
|
||||
\ && !escaped
|
||||
if s:is_empty_matchpair() || expand_inside_quotes
|
||||
" Expand:
|
||||
return "\<Space>\<Space>\<Left>"
|
||||
else
|
||||
return "\<Space>"
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! delimitMate#BS() " {{{
|
||||
if s:is_forbidden("")
|
||||
let extra = ''
|
||||
elseif &bs !~ 'start\|2'
|
||||
let extra = ''
|
||||
elseif delimitMate#WithinEmptyPair()
|
||||
let extra = "\<Del>"
|
||||
elseif s:is_space_expansion()
|
||||
let extra = "\<Del>"
|
||||
elseif s:is_cr_expansion()
|
||||
let extra = repeat("\<Del>",
|
||||
\ len(matchstr(getline(line('.') + 1), '^\s*\S')))
|
||||
else
|
||||
let extra = ''
|
||||
endif
|
||||
return "\<BS>" . extra
|
||||
endfunction " }}} delimitMate#BS()
|
||||
|
||||
function! delimitMate#Test() "{{{
|
||||
%d _
|
||||
" Check for script options:
|
||||
let result = [
|
||||
\ 'delimitMate Report',
|
||||
\ '==================',
|
||||
\ '',
|
||||
\ '* Options: ( ) default, (g) global, (b) buffer',
|
||||
\ '']
|
||||
for option in sort(keys(s:options[bufnr('%')]))
|
||||
if s:exists(option, 'b')
|
||||
let scope = '(b)'
|
||||
elseif s:exists(option, 'g')
|
||||
let scope = '(g)'
|
||||
else
|
||||
let scope = '( )'
|
||||
endif
|
||||
call add(result,
|
||||
\ scope . ' delimitMate_' . option
|
||||
\ . ' = '
|
||||
\ . string(s:get(option)))
|
||||
endfor
|
||||
call add(result, '')
|
||||
|
||||
let option = 'delimitMate_excluded_ft'
|
||||
call add(result,
|
||||
\(exists('g:'.option) ? '(g) ' : '( ) g:') . option . ' = '
|
||||
\. string(get(g:, option, '')))
|
||||
|
||||
call add(result, '--------------------')
|
||||
call add(result, '')
|
||||
|
||||
" Check if mappings were set.
|
||||
let left_delims = s:get('autoclose') ? s:get('left_delims') : []
|
||||
let special_keys = ['<BS>', '<S-BS>', '<S-Tab>', '<C-G>g']
|
||||
if s:get('expand_cr')
|
||||
call add(special_keys, '<CR>')
|
||||
endif
|
||||
if s:get('expand_space')
|
||||
call add(special_keys, '<Space>')
|
||||
endif
|
||||
let maps =
|
||||
\ s:get('right_delims')
|
||||
\ + left_delims
|
||||
\ + s:get('quotes_list')
|
||||
\ + s:get('apostrophes_list')
|
||||
\ + special_keys
|
||||
|
||||
call add(result, '* Mappings:')
|
||||
call add(result, '')
|
||||
for map in maps
|
||||
let output = ''
|
||||
if map == '|'
|
||||
let map = '<Bar>'
|
||||
endif
|
||||
redir => output | execute "verbose imap ".map | redir END
|
||||
call extend(result, split(output, '\n'))
|
||||
endfor
|
||||
|
||||
call add(result, '--------------------')
|
||||
call add(result, '')
|
||||
call add(result, '* Showcase:')
|
||||
call add(result, '')
|
||||
call setline(1, result)
|
||||
call s:test_mappings(s:get('left_delims'), 1)
|
||||
call s:test_mappings(s:get('quotes_list'), 0)
|
||||
|
||||
let result = []
|
||||
redir => setoptions
|
||||
echo " * Vim configuration:\<NL>"
|
||||
filetype
|
||||
echo ""
|
||||
set
|
||||
version
|
||||
redir END
|
||||
call extend(result, split(setoptions,"\n"))
|
||||
call add(result, '--------------------')
|
||||
setlocal nowrap
|
||||
call append('$', result)
|
||||
call feedkeys("\<Esc>\<Esc>", 'n')
|
||||
endfunction "}}}
|
||||
|
||||
function! s:test_mappings(list, is_matchpair) "{{{
|
||||
let prefix = "normal Go0\<C-D>"
|
||||
let last = "|"
|
||||
let open = s:get('autoclose') ? 'Open: ' : 'Open & close: '
|
||||
for s in a:list
|
||||
if a:is_matchpair
|
||||
let pair = s:get('right_delims')[index(s:get('left_delims'), s)]
|
||||
else
|
||||
let pair = s
|
||||
endif
|
||||
if !s:get('autoclose')
|
||||
let s .= pair
|
||||
endif
|
||||
exec prefix . open . s . last
|
||||
exec prefix . "Delete: " . s . "\<BS>" . last
|
||||
exec prefix . "Exit: " . s . pair . last
|
||||
if s:get('expand_space')
|
||||
\ && (a:is_matchpair || s:get('expand_inside_quotes'))
|
||||
exec prefix . "Space: " . s . " " . last
|
||||
exec prefix . "Delete space: " . s . " \<BS>" . last
|
||||
endif
|
||||
if s:get('expand_cr')
|
||||
\ && (a:is_matchpair || s:get('expand_inside_quotes'))
|
||||
exec prefix . "Car return: " . s . "\<CR>" . last
|
||||
exec prefix . "Delete car return: " . s . "\<CR>0\<C-D>\<BS>" . last
|
||||
endif
|
||||
call append('$', '')
|
||||
endfor
|
||||
endfunction "}}}
|
||||
|
||||
" vim:foldmethod=marker:foldcolumn=4:ts=2:sw=2
|
|
@ -1,67 +0,0 @@
|
|||
#Readme
|
||||
|
||||
This repository represents the latest bleeding-edge changes to gitv.
|
||||
Please help me find and remove any bugs by adding any problems you have
|
||||
to the issues tracker of this repository. Suggestions, pull requests and
|
||||
patches are also all very welcome. To download the latest stable release
|
||||
see the [gitv page on vim.org](http://www.vim.org/scripts/script.php?script_id=3574).
|
||||
|
||||
__Update:__ I have added an exciting new feature that allows you to pass
|
||||
a range to gitv. This has no effect in browser mode. In file mode
|
||||
however, only commits that affect at least one line in the range will be
|
||||
displayed. This is useful, for example, to view the commit history for a
|
||||
function and all of the changes made to it. You can easily watch the
|
||||
function 'evolve' as you move from commit to commit. For more
|
||||
information see the gitv documentation. If you have any problems with
|
||||
this new feature be sure to add them to the issues tracker.
|
||||
|
||||
You can see screenshots of the new range feature in action
|
||||
[here](http://www.gregsexton.org/2011/05/gitv-range/).
|
||||
|
||||
##Introduction
|
||||
|
||||
gitv is a 'gitk clone' plugin for the text editor Vim. The goal is
|
||||
to give you a similar set of functionality as a repository viewer.
|
||||
Using this plugin you can view a repository's history including
|
||||
branching and merging, you can see which commits refs point to.
|
||||
You can quickly and easily view what changed to which files and
|
||||
when. You can perform arbitrary diffs (using Vim's excellent built
|
||||
in diff functionality) and you can easily check out whole commits
|
||||
and branches or just individual files if need be.
|
||||
|
||||
Throw in the fact that it is running in Vim and you get for free:
|
||||
the ability to move over repository history quickly and precisely
|
||||
using Vim's built in movement operators. You get excellent code
|
||||
syntax highlighting due to Vim's built in ability. You can open up
|
||||
all sorts of repository views in multiple windows and position
|
||||
them exactly how you like. You can take advantage of Vim's
|
||||
registers to copy multiple fragments of code from previous
|
||||
commits. The list goes on.
|
||||
|
||||
This plugin is an extension of the fugitive plugin.
|
||||
|
||||
I hope you like it!
|
||||
|
||||
## Installation
|
||||
|
||||
Install in ~/.vim, or in ~\vimfiles if you're on Windows. This
|
||||
plugin should be fully pathogen compatible if you want to install
|
||||
it this way.
|
||||
|
||||
gitv was developed against Vim 7.3 but earlier versions of Vim
|
||||
should work. Vim 7.2+ is recommended as it ships with syntax
|
||||
highlighting for many Git file types. **You will also need the
|
||||
fugitive plugin installed and working for gitv to work.**
|
||||
|
||||
## Screenshots and Links
|
||||
|
||||
Here is a screenshot to keep you going.
|
||||
|
||||
![gitv](http://www.gregsexton.org/images/gitk-vim.jpg)
|
||||
|
||||
More can be found at the homepage for gitv:
|
||||
http://www.gregsexton.org/portfolio/gitv/
|
||||
|
||||
You can download stable release versions (and vote for gitv!) at
|
||||
[gitv’s page](http://www.vim.org/scripts/script.php?script_id=3574) on
|
||||
Vim.org.
|
BIN
.vim/autoload/gitv-1.1/doc/.DS_Store
vendored
BIN
.vim/autoload/gitv-1.1/doc/.DS_Store
vendored
Binary file not shown.
|
@ -1,482 +0,0 @@
|
|||
gitv -- gitk for vim.
|
||||
|
||||
AUTHOR: Greg Sexton <gregsexton@gmail.com> *gitv-author*
|
||||
WEBSITE: http://www.gregsexton.org/portfolio/gitv/
|
||||
LICENSE: Same terms as Vim itself (see :help license).
|
||||
NOTES: Much of the credit for gitv goes to Tim Pope and the fugitive plugin
|
||||
where this plugin either uses functionality directly or was inspired
|
||||
heavily.
|
||||
|
||||
gitv *gitv*
|
||||
|
||||
1. Introduction |gitv-introduction|
|
||||
2. Installation |gitv-installation|
|
||||
3. Usage |gitv-usage|
|
||||
4. Configuration Options |gitv-config-options|
|
||||
5. Changelog |gitv-changelog|
|
||||
6. Misc |gitv-misc|
|
||||
|
||||
==============================================================================
|
||||
1. Introduction *gitv-introduction*
|
||||
|
||||
|gitv| is a 'gitk clone' plugin for the text editor Vim. The goal is to give
|
||||
you a similar set of functionality as a repository viewer. Using this plugin
|
||||
you can view a repository's history including branching and merging, you can
|
||||
see which commits refs point to. You can quickly and easily view what changed
|
||||
to which files and when. You can perform arbitrary diffs (using Vim's
|
||||
excellent built in diff functionality) and you can easily check out whole
|
||||
commits and branches or just individual files if need be.
|
||||
|
||||
Throw in the fact that it is running in Vim and you get for free: the ability
|
||||
to move over repository history quickly and precisely using Vim's built in
|
||||
movement operators. You get excellent code syntax highlighting due to Vim's
|
||||
built in ability. You can open up all sorts of repository views in multiple
|
||||
windows and position them exactly how you like. You can take advantage of
|
||||
Vim's registers to copy multiple fragments of code from previous commits. The
|
||||
list goes on.
|
||||
|
||||
This plugin is an extension of the |fugitive| plugin.
|
||||
|
||||
I hope you like it!
|
||||
|
||||
==============================================================================
|
||||
2. Installation *gitv-installation*
|
||||
|
||||
Install in ~/.vim, or in ~\vimfiles if you're on Windows. This plugin should
|
||||
be fully pathogen compatible if you want to install it this way.
|
||||
|
||||
|gitv| was developed against Vim 7.3 but earlier versions of Vim should work.
|
||||
Vim 7.2+ is recommended as it ships with syntax highlighting for many Git file
|
||||
types. You will also need the |fugitive| plugin installed and working for
|
||||
|gitv| to work.
|
||||
|
||||
==============================================================================
|
||||
3. Usage *gitv-usage*
|
||||
|
||||
|gitv| defines the following command.
|
||||
|
||||
:[range]Gitv[!] [args]
|
||||
|
||||
Invoking this command on a buffer that belongs to a git
|
||||
repository causes the gitv browser to open. '!' causes gitv
|
||||
to open in file mode rather than browser mode. Any [args]
|
||||
supplied are passed on to the gitv viewer and can be used to
|
||||
narrow the commits that are shown. If this command is run
|
||||
on a buffer not belonging to a git repository a message
|
||||
stating 'Not a git repository.' is displayed.
|
||||
|
||||
When used with a [range] this has no effect in browser mode.
|
||||
In file mode it narrows the commits shown to only those
|
||||
affecting lines in the range. See section 3.8 for more
|
||||
details.
|
||||
|
||||
The following abbreviation is also defined so that you can type :gitv without
|
||||
capitalisation. The abbreviation is defined in such a way that this
|
||||
substitution is only performed when 'gitv' is the first word on the command
|
||||
line.
|
||||
>
|
||||
cabbrev gitv Gitv
|
||||
<
|
||||
|
||||
3.1 Browser mode
|
||||
|
||||
|gitv| has two distinct modes. Browser mode and file mode. The browser mode is
|
||||
opened in a new tab and allows the repository history to be viewed for all
|
||||
files. This is activated by running :Gitv without a '!'.
|
||||
|
||||
In this mode you can view the entire repository history and see which files
|
||||
were changed with each commit. This mode tries to closely resemble gitk.
|
||||
|
||||
3.2 File mode
|
||||
|
||||
File mode is opened in a |preview-window| above the buffer you are currently in.
|
||||
This view is tailored to act on the buffer that :Gitv! was run from, the
|
||||
"focused" file. Whilst in this mode all actions performed are specific to the
|
||||
single focused file. The browser only shows commits where the focused file
|
||||
changed. Selecting a commit, views the focused file as it was in that commit.
|
||||
Performing a check out only checks the focused file out as it was in the
|
||||
commit. And so on. See 3.4 for the differences.
|
||||
|
||||
3.3 Arguments
|
||||
|
||||
You can pass arguments to the :Gitv command. These allow you to filter and
|
||||
narrow the commits shown. Essentially, gitv is a glorified 'git log' wrapper
|
||||
and so any flag that 'git log' accepts so will gitv. gitv does not inspect the
|
||||
arguments passed on to 'git log' and so may not work if they don't make sense.
|
||||
|
||||
Without any arguments gitv behaves just like gitk and git log without
|
||||
arguments. It will display the commit history for the currently checked out
|
||||
branch.
|
||||
|
||||
Here are some particularly useful examples of arguments that could be
|
||||
passed to :Gitv. For more info see 'git help log' and in particular the
|
||||
section: "Commit Limiting".
|
||||
|
||||
Flag Description ~
|
||||
|
||||
--all View repository history for all refs.
|
||||
|
||||
<since>..<until> Show only commits between the named two commits. When
|
||||
either <since> or <until> is omitted, it defaults to
|
||||
HEAD, i.e. the tip of the current branch. For a more
|
||||
complete list of ways to spell <since> and <until>,
|
||||
see gitrevisions(7).
|
||||
|
||||
--merges View only merge commits.
|
||||
|
||||
-S<string> Look for differences that introduce or remove an
|
||||
instance of <string>. Note that this is different than
|
||||
the string simply appearing in diff output; see the
|
||||
pickaxe entry in gitdiffcore(7) for more details.
|
||||
|
||||
-G<regex> Look for differences whose added or removed line
|
||||
matches the given <regex>.
|
||||
|
||||
3.4 Key mappings.
|
||||
|
||||
This is a list of key mappings that will work only in the gitv browser window.
|
||||
Where appropriate the differences in action is described for the two modes.
|
||||
|
||||
Mode Map Description~
|
||||
|
||||
normal <cr> Opens a commit. In browser mode this will show the
|
||||
commit header information including the commit
|
||||
message. It will also display a full diff showing all the
|
||||
changes to files.
|
||||
|
||||
Tip: if you press <cr> on anything sensible you can
|
||||
view the expected output. For example pressing <cr> on
|
||||
the line beginning a file diff, it will display the
|
||||
diff using Vim's built in diff viewing capability.
|
||||
Pressing <cr> on the tree sha will list all the files
|
||||
in the commit and pressing <cr> on one of these will
|
||||
show that file as it was in the commit. And so on.
|
||||
|
||||
Pressing <cr> on the line "-- Load More --" will load
|
||||
|g:Gitv_CommitStep| more commits.
|
||||
|
||||
In file mode this will open the focused file as it was
|
||||
in the currently selected diff. This allows you to
|
||||
easily go back in time and look at the focused file.
|
||||
|
||||
Pressing <cr> on the top line in file mode opens the
|
||||
current working copy of the focused file.
|
||||
|
||||
normal o The same as <cr> but opens in a new |split|.
|
||||
normal O The same as <cr> but opens in a new |tab|.
|
||||
normal s The same as <cr> but opens in a new |vsplit|.
|
||||
|
||||
normal <c-cr> This performs the same thing as <cr> in browser mode.
|
||||
In file mode it opens the commit details rather than
|
||||
the focused file.
|
||||
|
||||
normal q Quits gitv. In browser mode this will close the entire
|
||||
tab. In file mode this closes only the |preview-window|.
|
||||
Note: in browser mode this will close the tab
|
||||
regardless of any windows you may have opened as well
|
||||
as the gitv windows.
|
||||
|
||||
normal u Forces an update of the content of the browser window.
|
||||
|
||||
normal co Performs a 'git checkout' of the commit the cursor is
|
||||
on. In both modes this will present you with a choice
|
||||
of whether you would like to checkout the sha or any
|
||||
ref that might point to this commit.
|
||||
|
||||
File mode differs in that it doesn't check out the
|
||||
entire commit but just the focused file in that
|
||||
commit.
|
||||
|
||||
Tip: in gVim this will present you with a pop up dialog.
|
||||
You can make this a text choice by performing ':set
|
||||
guioptions+=c.'
|
||||
|
||||
normal D Performs a diff using Vim's built in diff viewing
|
||||
capabilities. This does nothing in browser mode. In
|
||||
file mode it will diff the current file with the
|
||||
focused file in the commit under the cursor.
|
||||
|
||||
visual D In visual mode this performs a diff against the file
|
||||
in the commit at the top of the selection against the
|
||||
file in the commit at the bottom of the selection. The
|
||||
newest file is always on the right.
|
||||
|
||||
normal S This works for both browser and file mode. It opens a
|
||||
diffstat of everything that has changed since the
|
||||
commit under the cursor.
|
||||
|
||||
visual S In visual mode this works in exactly the same way as
|
||||
normal mode. However, it only shows what has changed in
|
||||
the range of commits that are highlighted.
|
||||
|
||||
visual m Merges the commit in either the top or bottom line of
|
||||
the selection in to the commit specified by the other
|
||||
end of the selection. This uses prompts to guide you
|
||||
through the merging and should be fairly intuitive. It
|
||||
will also confirm if you wish to perform a
|
||||
fast-forward merge or not.
|
||||
|
||||
gitv doesn't allow you to merge arbitrary commits. The
|
||||
lines at the top and bottom of the selection must
|
||||
contain refs in the form of tags, remotes or local
|
||||
branches.
|
||||
|
||||
normal git Enters command mode with ":Git " already typed for
|
||||
you. Just a convenient shortcut for executing git
|
||||
commands and watching them affect the repository.
|
||||
|
||||
Here is a list of extra key mappings that can be used to efficiently move
|
||||
around a repository history in the browser window.
|
||||
|
||||
Mode Map Description~
|
||||
|
||||
normal x Jumps the cursor forward to the next branching point
|
||||
in the history.
|
||||
|
||||
normal X Jumps the cursor backward to the previous branching
|
||||
point in the history.
|
||||
|
||||
normal r Jumps the cursor forward to the next ref in the
|
||||
history.
|
||||
|
||||
normal R Jumps the cursor backward to the previous ref in the
|
||||
history.
|
||||
|
||||
normal P Jumps the cursor to the commit referenced by HEAD.
|
||||
|
||||
3.5 Commands
|
||||
|
||||
Running the |:Git| command in the commit browser window, in either mode, will
|
||||
cause the |:Git| command to be run as expected but the commit history will
|
||||
automatically update to reflect any changes too.
|
||||
|
||||
3.6 Windows
|
||||
|
||||
In browser mode, two windows are opened initially. The "browser window" that
|
||||
displays the commit history and the "preview window" that shows the currently
|
||||
selected commit.
|
||||
|
||||
In file mode, a |preview-window| is opened above the current file. This is a
|
||||
browser window filtered to show commits only affecting the focused file. The
|
||||
window holding the focused file acts as the preview window in this mode.
|
||||
|
||||
NOTE: In both modes the buffer in the preview window is wiped after replacing
|
||||
it. This is to stop the quick build up of fugitive buffers. A buffer will not
|
||||
be wiped if it contains unsaved changes. Buffers are not wiped when opening a
|
||||
commit in a split, vsplit or a new tab.
|
||||
|
||||
When opening a commit, the window it will be opened in is determined by simple
|
||||
rules. If in browser mode and the layout is vertical it will open in the
|
||||
window to the immediate right (exactly as if you performed <c-w>l). If in a
|
||||
horizontal layout, it will be opened in the window immediately below (exactly
|
||||
as if you performed <c-w>j). If in file mode, it will open exactly like
|
||||
browser mode split horizontally. NOTE: It is for this reason that you should
|
||||
not move the browser window as it will cause commits to be opened in
|
||||
unexpected places.
|
||||
|
||||
3.7 Folding
|
||||
|
||||
Folding of branches is supported in the browser window. Initially all folds
|
||||
are always open and will open on a reload. You can collapse any branch by
|
||||
using Vim's built in fold operators. See |folding| for more details.
|
||||
|
||||
3.8 Using with a range of lines
|
||||
|
||||
If a range is passed to the :Gitv command it will have no effect in browser
|
||||
mode. In file mode however, only commits that affect at least one line in the
|
||||
range will be displayed. This is useful, for example, to view the commit
|
||||
history for a function and all of the changes made to it.
|
||||
|
||||
If a range of less than two lines is used then gitv opens in regular file
|
||||
mode.
|
||||
|
||||
Selecting a commit by pressing <cr> on it will show the file as it was in that
|
||||
commit with all lines not in the range folded away. This allows you to quickly
|
||||
and easily move from commit to commit viewing the evolution of the range of
|
||||
lines. Pressing <c-cr> will show you the commit details so that you can see
|
||||
any other changes it may have made.
|
||||
|
||||
The range that Git looks at is specified by the first and last line in the
|
||||
range passed to :Gitv. These lines are escaped appropriately and passed to Git
|
||||
to use as a regular expression. If you wish to modify either regex delimiter
|
||||
this can be done by pressing <cr> on the appropriate line near the top of the
|
||||
file mode buffer. Vim will prompt you to modify the regex. If you press enter
|
||||
without modification, nothing happens. If you modify the regex (Git supports
|
||||
POSIX regular expressions) gitv will automatically update.
|
||||
|
||||
You may also pass arguments to the :Gitv! command when using a range. This
|
||||
filters the commits that are to be compared for changes in the range. For
|
||||
example you could pass the name of a branch to only look at changes in commits
|
||||
on that branch.
|
||||
|
||||
Note: This feature requires the bash shell to be installed on your system and
|
||||
in your path. This should already be the case for the majority of users.
|
||||
|
||||
Note: Using a range searches back through the commit history looking at each
|
||||
section of lines for where changes occurred. It will only look at the last
|
||||
g:Gitv_CommitStep number, if you don't get any matches you could try pressing
|
||||
<cr> on the 'load more' line. This command may be slow if you choose a large
|
||||
range and have a large g:Gitv_CommitStep.
|
||||
|
||||
==============================================================================
|
||||
4. Configuration Options *gitv-config-options*
|
||||
|
||||
You can set the following options in your .vimrc to override the values used
|
||||
by |gitv|. The defaults are shown.
|
||||
|
||||
4.1 Commit Step
|
||||
|
||||
This is the number of commits to show each time. When pressing <cr> on
|
||||
"-- Load More --", the number of extra commits loaded is g:Gitv_CommitStep.
|
||||
The default is a screen's worth of lines. This should be set to an integer
|
||||
number. Setting this to a value _really_ high will load the entire repo in one
|
||||
go.
|
||||
>
|
||||
g:Gitv_CommitStep = &lines
|
||||
<
|
||||
|
||||
4.2 Open Horizontal
|
||||
|
||||
This is the default layout to use in browser mode. If set to 0 then browser
|
||||
mode will open in a vertical split. If set to 1 then browser mode will open in
|
||||
a horizontal split. If set to 'auto' then browser mode will open in a vertical
|
||||
split unless the content fits better in a horizontal split, in which case it
|
||||
will open horizontally.
|
||||
|
||||
The commit browser width and height is automatically sized to best fit the
|
||||
content in all modes and settings.
|
||||
>
|
||||
g:Gitv_OpenHorizontal = 0
|
||||
<
|
||||
|
||||
4.3 Git Executable
|
||||
|
||||
This is the name of the git executable to use to run commands. This should be
|
||||
a string.
|
||||
>
|
||||
g:Gitv_GitExecutable = 'git'
|
||||
<
|
||||
4.4 Wipe All on Close
|
||||
|
||||
This option should be set to either 0 (to disable) or 1 (to enable). If set to
|
||||
1 then on closing the browser mode by using the q key all buffers displayed in
|
||||
a window in the tab will be wiped before the tab is closed. This option allows
|
||||
you to limit the number of fugitive buffers that accumulate in the use of gitv.
|
||||
|
||||
NOTE: This will not wipe any buffer with unsaved content. It will however
|
||||
mercilessly wipe all buffers in the tab regardless of the file they hold.
|
||||
>
|
||||
g:Gitv_WipeAllOnClose = 0
|
||||
<
|
||||
|
||||
4.5 Wrap Lines
|
||||
|
||||
If set to 1 then line wrapping is enabled. This is useful if you have
|
||||
occasional very long commit messages.
|
||||
>
|
||||
g:Gitv_WrapLines = 0
|
||||
<
|
||||
|
||||
4.6 Truncate Commit Subjects
|
||||
|
||||
If set to 1 then commit subject truncation is enabled. This will truncate
|
||||
commit subjects, where necessary, so that the whole line will fit in one
|
||||
screen width. If this is set, then automatically switching to a horizontal
|
||||
layout will no longer work as commits will be truncated to always fit in a
|
||||
vertical split. NOTE: It is possible that this can truncate any refs pointing
|
||||
at a commit. In this situation it will not be possible to check out any of
|
||||
these refs. This is due to gitv being unable to recognise that they are refs.
|
||||
>
|
||||
g:Gitv_TruncateCommitSubjects = 0
|
||||
<
|
||||
|
||||
4.7 Open Preview On Launch
|
||||
|
||||
If set to 1 then the preview window is displayed when launching gitv in
|
||||
browser mode. If set to 0 then no preview window is displayed until a commit
|
||||
is opened. This option has no effect in file mode.
|
||||
>
|
||||
g:Gitv_OpenPreviewOnLaunch = 1
|
||||
<
|
||||
|
||||
4.8 Prompt to Delete Merge Branch
|
||||
|
||||
If set to 1 then, when performing a merge using gitv, you will be prompted if
|
||||
you wish to delete the topic branch. If you often merge a branch into another
|
||||
and rarely wish to delete branches, set this to 0. The default is 0.
|
||||
>
|
||||
let g:Gitv_PromptToDeleteMergeBranch = 0
|
||||
<
|
||||
==============================================================================
|
||||
5. Changelog *gitv-changelog*
|
||||
|
||||
1.1 Nodes displaying local changes are inserted above HEAD ref.
|
||||
Added range feature.
|
||||
Merging branches is possible in gitv.
|
||||
strwidth bugfix (thanks Adam Reeve).
|
||||
Prevent bdelete errors (thanks pydave).
|
||||
|
||||
1.0 First release. I hope you enjoy gitv!
|
||||
|
||||
==============================================================================
|
||||
6. Misc *gitv-misc*
|
||||
|
||||
6.1 Tips and tricks
|
||||
|
||||
I use the following mappings to make working with |gitv| easier.
|
||||
>
|
||||
nmap <leader>gv :Gitv --all<cr>
|
||||
nmap <leader>gV :Gitv! --all<cr>
|
||||
vmap <leader>gV :Gitv! --all<cr>
|
||||
<
|
||||
The vmap equivalent for file mode is to make dealing with ranges easier. It
|
||||
allows you to visually select a range of lines to view the commit history for
|
||||
that section of the file.
|
||||
|
||||
The following abbreviation makes running arbitrary git commands much easier.
|
||||
>
|
||||
cabbrev git Git
|
||||
<
|
||||
|
||||
The function: 'Gitv_OpenGitCommand(command, windowCmd)' is provided to allow
|
||||
the more advanced user to create their own commands. This function will
|
||||
execute the git command provided in the new window created using windowCmd.
|
||||
|
||||
By using this function you get for free: the buffer set up for read only git
|
||||
output, including syntax highlighting and many other tailored options. You
|
||||
also get mappings for 'u' to update the output and 'q' to easily close the
|
||||
window.
|
||||
|
||||
Here is an example of getting diff output both cached and not, in a vertical
|
||||
and horizontal split respectively.
|
||||
>
|
||||
call Gitv_OpenGitCommand("diff --no-color --cached", 'vnew')
|
||||
call Gitv_OpenGitCommand("diff --no-color", 'new')
|
||||
<
|
||||
|
||||
I like my diff colors to be green for added lines and red for removed lines,
|
||||
just like in the shell. Adding this to your vimrc will accomplish this.
|
||||
>
|
||||
highlight diffAdded guifg=#00bf00
|
||||
highlight diffRemoved guifg=#bf0000
|
||||
<
|
||||
|
||||
I highly recommend adding to your vimrc:
|
||||
>
|
||||
set lazyredraw
|
||||
<
|
||||
|
||||
This stops Vim from redrawing the screen during complex operations and results
|
||||
in much smoother looking plugins.
|
||||
|
||||
|
||||
6.2 Bugs, issues, features and contributing.
|
||||
|
||||
There are no known bugs. Hopefully there are not too many unknown. Please see
|
||||
below to help.
|
||||
|
||||
Bugs, suggestions, pull requests and patches are all very welcome. If you find
|
||||
issues with |gitv| please add them to the issues page on the github project.
|
||||
Anything else, feel free to email me: gregsexton@gmail.com.
|
||||
|
||||
vim:tw=78:ts=8:ft=help:norl:
|
File diff suppressed because it is too large
Load diff
|
@ -1,230 +0,0 @@
|
|||
" pathogen.vim - path option manipulation
|
||||
" Maintainer: Tim Pope <http://tpo.pe/>
|
||||
" Version: 2.0
|
||||
|
||||
" Install in ~/.vim/autoload (or ~\vimfiles\autoload).
|
||||
"
|
||||
" For management of individually installed plugins in ~/.vim/bundle (or
|
||||
" ~\vimfiles\bundle), adding `call pathogen#infect()` to your .vimrc
|
||||
" prior to `fileype plugin indent on` is the only other setup necessary.
|
||||
"
|
||||
" The API is documented inline below. For maximum ease of reading,
|
||||
" :set foldmethod=marker
|
||||
|
||||
if exists("g:loaded_pathogen") || &cp
|
||||
finish
|
||||
endif
|
||||
let g:loaded_pathogen = 1
|
||||
|
||||
" Point of entry for basic default usage. Give a directory name to invoke
|
||||
" pathogen#runtime_append_all_bundles() (defaults to "bundle"), or a full path
|
||||
" to invoke pathogen#runtime_prepend_subdirectories(). Afterwards,
|
||||
" pathogen#cycle_filetype() is invoked.
|
||||
function! pathogen#infect(...) abort " {{{1
|
||||
let source_path = a:0 ? a:1 : 'bundle'
|
||||
if source_path =~# '[\\/]'
|
||||
call pathogen#runtime_prepend_subdirectories(source_path)
|
||||
else
|
||||
call pathogen#runtime_append_all_bundles(source_path)
|
||||
endif
|
||||
call pathogen#cycle_filetype()
|
||||
endfunction " }}}1
|
||||
|
||||
" Split a path into a list.
|
||||
function! pathogen#split(path) abort " {{{1
|
||||
if type(a:path) == type([]) | return a:path | endif
|
||||
let split = split(a:path,'\\\@<!\%(\\\\\)*\zs,')
|
||||
return map(split,'substitute(v:val,''\\\([\\,]\)'',''\1'',"g")')
|
||||
endfunction " }}}1
|
||||
|
||||
" Convert a list to a path.
|
||||
function! pathogen#join(...) abort " {{{1
|
||||
if type(a:1) == type(1) && a:1
|
||||
let i = 1
|
||||
let space = ' '
|
||||
else
|
||||
let i = 0
|
||||
let space = ''
|
||||
endif
|
||||
let path = ""
|
||||
while i < a:0
|
||||
if type(a:000[i]) == type([])
|
||||
let list = a:000[i]
|
||||
let j = 0
|
||||
while j < len(list)
|
||||
let escaped = substitute(list[j],'[,'.space.']\|\\[\,'.space.']\@=','\\&','g')
|
||||
let path .= ',' . escaped
|
||||
let j += 1
|
||||
endwhile
|
||||
else
|
||||
let path .= "," . a:000[i]
|
||||
endif
|
||||
let i += 1
|
||||
endwhile
|
||||
return substitute(path,'^,','','')
|
||||
endfunction " }}}1
|
||||
|
||||
" Convert a list to a path with escaped spaces for 'path', 'tag', etc.
|
||||
function! pathogen#legacyjoin(...) abort " {{{1
|
||||
return call('pathogen#join',[1] + a:000)
|
||||
endfunction " }}}1
|
||||
|
||||
" Remove duplicates from a list.
|
||||
function! pathogen#uniq(list) abort " {{{1
|
||||
let i = 0
|
||||
let seen = {}
|
||||
while i < len(a:list)
|
||||
if has_key(seen,a:list[i])
|
||||
call remove(a:list,i)
|
||||
else
|
||||
let seen[a:list[i]] = 1
|
||||
let i += 1
|
||||
endif
|
||||
endwhile
|
||||
return a:list
|
||||
endfunction " }}}1
|
||||
|
||||
" \ on Windows unless shellslash is set, / everywhere else.
|
||||
function! pathogen#separator() abort " {{{1
|
||||
return !exists("+shellslash") || &shellslash ? '/' : '\'
|
||||
endfunction " }}}1
|
||||
|
||||
" Convenience wrapper around glob() which returns a list.
|
||||
function! pathogen#glob(pattern) abort " {{{1
|
||||
let files = split(glob(a:pattern),"\n")
|
||||
return map(files,'substitute(v:val,"[".pathogen#separator()."/]$","","")')
|
||||
endfunction "}}}1
|
||||
|
||||
" Like pathogen#glob(), only limit the results to directories.
|
||||
function! pathogen#glob_directories(pattern) abort " {{{1
|
||||
return filter(pathogen#glob(a:pattern),'isdirectory(v:val)')
|
||||
endfunction "}}}1
|
||||
|
||||
" Turn filetype detection off and back on again if it was already enabled.
|
||||
function! pathogen#cycle_filetype() " {{{1
|
||||
if exists('g:did_load_filetypes')
|
||||
filetype off
|
||||
filetype on
|
||||
endif
|
||||
endfunction " }}}1
|
||||
|
||||
" Checks if a bundle is 'disabled'. A bundle is considered 'disabled' if
|
||||
" its 'basename()' is included in g:pathogen_disabled[]' or ends in a tilde.
|
||||
function! pathogen#is_disabled(path) " {{{1
|
||||
if a:path =~# '\~$'
|
||||
return 1
|
||||
elseif !exists("g:pathogen_disabled")
|
||||
return 0
|
||||
endif
|
||||
let sep = pathogen#separator()
|
||||
return index(g:pathogen_disabled, strpart(a:path, strridx(a:path, sep)+1)) != -1
|
||||
endfunction "}}}1
|
||||
|
||||
" Prepend all subdirectories of path to the rtp, and append all 'after'
|
||||
" directories in those subdirectories.
|
||||
function! pathogen#runtime_prepend_subdirectories(path) " {{{1
|
||||
let sep = pathogen#separator()
|
||||
let before = filter(pathogen#glob_directories(a:path.sep."*"), '!pathogen#is_disabled(v:val)')
|
||||
let after = filter(pathogen#glob_directories(a:path.sep."*".sep."after"), '!pathogen#is_disabled(v:val[0:-7])')
|
||||
let rtp = pathogen#split(&rtp)
|
||||
let path = expand(a:path)
|
||||
call filter(rtp,'v:val[0:strlen(path)-1] !=# path')
|
||||
let &rtp = pathogen#join(pathogen#uniq(before + rtp + after))
|
||||
return &rtp
|
||||
endfunction " }}}1
|
||||
|
||||
" For each directory in rtp, check for a subdirectory named dir. If it
|
||||
" exists, add all subdirectories of that subdirectory to the rtp, immediately
|
||||
" after the original directory. If no argument is given, 'bundle' is used.
|
||||
" Repeated calls with the same arguments are ignored.
|
||||
function! pathogen#runtime_append_all_bundles(...) " {{{1
|
||||
let sep = pathogen#separator()
|
||||
let name = a:0 ? a:1 : 'bundle'
|
||||
if "\n".s:done_bundles =~# "\\M\n".name."\n"
|
||||
return ""
|
||||
endif
|
||||
let s:done_bundles .= name . "\n"
|
||||
let list = []
|
||||
for dir in pathogen#split(&rtp)
|
||||
if dir =~# '\<after$'
|
||||
let list += filter(pathogen#glob_directories(substitute(dir,'after$',name,'').sep.'*[^~]'.sep.'after'), '!pathogen#is_disabled(v:val[0:-7])') + [dir]
|
||||
else
|
||||
let list += [dir] + filter(pathogen#glob_directories(dir.sep.name.sep.'*[^~]'), '!pathogen#is_disabled(v:val)')
|
||||
endif
|
||||
endfor
|
||||
let &rtp = pathogen#join(pathogen#uniq(list))
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
let s:done_bundles = ''
|
||||
" }}}1
|
||||
|
||||
" Invoke :helptags on all non-$VIM doc directories in runtimepath.
|
||||
function! pathogen#helptags() " {{{1
|
||||
let sep = pathogen#separator()
|
||||
for dir in pathogen#split(&rtp)
|
||||
if (dir.sep)[0 : strlen($VIMRUNTIME)] !=# $VIMRUNTIME.sep && filewritable(dir.'/doc') == 2 && !empty(glob(dir.'/doc/*')) && (!filereadable(dir.'/doc/tags') || filewritable(dir.'/doc/tags'))
|
||||
helptags `=dir.'/doc'`
|
||||
endif
|
||||
endfor
|
||||
endfunction " }}}1
|
||||
|
||||
command! -bar Helptags :call pathogen#helptags()
|
||||
|
||||
" Like findfile(), but hardcoded to use the runtimepath.
|
||||
function! pathogen#rtpfindfile(file,count) "{{{1
|
||||
let rtp = pathogen#join(1,pathogen#split(&rtp))
|
||||
return fnamemodify(findfile(a:file,rtp,a:count),':p')
|
||||
endfunction " }}}1
|
||||
|
||||
function! s:find(count,cmd,file,...) " {{{1
|
||||
let rtp = pathogen#join(1,pathogen#split(&runtimepath))
|
||||
let file = pathogen#rtpfindfile(a:file,a:count)
|
||||
if file ==# ''
|
||||
return "echoerr 'E345: Can''t find file \"".a:file."\" in runtimepath'"
|
||||
elseif a:0
|
||||
let path = file[0:-strlen(a:file)-2]
|
||||
execute a:1.' `=path`'
|
||||
return a:cmd.' '.fnameescape(a:file)
|
||||
else
|
||||
return a:cmd.' '.fnameescape(file)
|
||||
endif
|
||||
endfunction " }}}1
|
||||
|
||||
function! s:Findcomplete(A,L,P) " {{{1
|
||||
let sep = pathogen#separator()
|
||||
let cheats = {
|
||||
\'a': 'autoload',
|
||||
\'d': 'doc',
|
||||
\'f': 'ftplugin',
|
||||
\'i': 'indent',
|
||||
\'p': 'plugin',
|
||||
\'s': 'syntax'}
|
||||
if a:A =~# '^\w[\\/]' && has_key(cheats,a:A[0])
|
||||
let request = cheats[a:A[0]].a:A[1:-1]
|
||||
else
|
||||
let request = a:A
|
||||
endif
|
||||
let pattern = substitute(request,'\'.sep,'*'.sep,'g').'*'
|
||||
let found = {}
|
||||
for path in pathogen#split(&runtimepath)
|
||||
let matches = split(glob(path.sep.pattern),"\n")
|
||||
call map(matches,'isdirectory(v:val) ? v:val.sep : v:val')
|
||||
call map(matches,'v:val[strlen(path)+1:-1]')
|
||||
for match in matches
|
||||
let found[match] = 1
|
||||
endfor
|
||||
endfor
|
||||
return sort(keys(found))
|
||||
endfunction " }}}1
|
||||
|
||||
command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Ve :execute s:find(<count>,'edit<bang>',<q-args>)
|
||||
command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vedit :execute s:find(<count>,'edit<bang>',<q-args>)
|
||||
command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vsplit :execute s:find(<count>,'split<bang>',<q-args>)
|
||||
command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vvsplit :execute s:find(<count>,'vsplit<bang>',<q-args>)
|
||||
command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vtabedit :execute s:find(<count>,'tabedit<bang>',<q-args>)
|
||||
command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vpedit :execute s:find(<count>,'pedit<bang>',<q-args>)
|
||||
command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vread :execute s:find(<count>,'read<bang>',<q-args>)
|
||||
command! -bar -bang -count=1 -nargs=1 -complete=customlist,s:Findcomplete Vopen :execute s:find(<count>,'edit<bang>',<q-args>,'lcd')
|
||||
|
||||
" vim:set ft=vim ts=8 sw=2 sts=2:
|
|
@ -1,82 +0,0 @@
|
|||
if exists("g:vim_php_cs_fixer") || &cp
|
||||
finish
|
||||
endif
|
||||
let g:vim_php_cs_fixer = 1
|
||||
|
||||
" Global options definition."{{{
|
||||
let g:php_cs_fixer_path = get(g:, 'php_cs_fixer_path', '~/php-cs-fixer.phar')
|
||||
let g:php_cs_fixer_level = get(g:, 'php_cs_fixer_level', 'all')
|
||||
let g:php_cs_fixer_php_path = get(g:, 'php_cs_fixer_php_path', 'php')
|
||||
let g:php_cs_fixer_enable_default_mapping = get(g:, 'php_cs_fixer_enable_default_mapping', '1')
|
||||
let g:php_cs_fixer_dry_run = get(g:, 'php_cs_fixer_dry_run', 0)
|
||||
let g:php_cs_fixer_verbose = get(g:, 'php_cs_fixer_verbose', 0)
|
||||
|
||||
let g:php_cs_fixer_command = g:php_cs_fixer_php_path.' '.g:php_cs_fixer_path.' fix'
|
||||
|
||||
if exists('g:php_cs_fixer_config')
|
||||
let g:php_cs_fixer_command = g:php_cs_fixer_command.' --config='.g:php_cs_fixer_config
|
||||
endif
|
||||
"}}}
|
||||
|
||||
|
||||
fun! PhpCsFixerFix(path, dry_run)
|
||||
|
||||
if !filereadable(expand(g:php_cs_fixer_path))
|
||||
echoerr(g:php_cs_fixer_path.' is not found')
|
||||
endif
|
||||
|
||||
let command = g:php_cs_fixer_command.' '.a:path
|
||||
|
||||
if a:dry_run == 1
|
||||
echohl Title | echo "[DRY RUN MODE]" | echohl None
|
||||
let command = command.' --dry-run'
|
||||
endif
|
||||
|
||||
if exists('g:php_cs_fixer_fixers_list')
|
||||
let command = command.' --fixers='.g:php_cs_fixer_fixers_list
|
||||
endif
|
||||
|
||||
let s:output = system(command)
|
||||
if v:shell_error
|
||||
echohl Error | echo s:output | echohl None
|
||||
else
|
||||
if a:dry_run != 0
|
||||
exec 'edit!'
|
||||
endif
|
||||
let s:nbLines = len(split(s:output, '\n'))
|
||||
let s:nbFilesModified = (s:nbLines - 1)
|
||||
|
||||
if g:php_cs_fixer_verbose == 1
|
||||
echohl Title | echo s:output | echohl None
|
||||
else
|
||||
if s:nbFilesModified > 0
|
||||
echohl Title | echo "There is ".s:nbFilesModified." file(s) modified(s)" | echohl None
|
||||
else
|
||||
echohl Title | echo "There is no cs to fix" | echohl None
|
||||
endif
|
||||
endif
|
||||
|
||||
" if there is no cs to fix, we have not to ask for remove dry run
|
||||
if a:dry_run == 1 && s:nbFilesModified > 0
|
||||
let l:confirmed = confirm("Do you want to launch command without dry-run option ?", "&Yes\n&No", 2)
|
||||
if l:confirmed == 1
|
||||
call PhpCsFixerFix(a:path, 0)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endfun
|
||||
|
||||
fun! PhpCsFixerFixDirectory()
|
||||
call PhpCsFixerFix(expand('%:p:h'), g:php_cs_fixer_dry_run)
|
||||
endfun
|
||||
|
||||
fun! PhpCsFixerFixFile()
|
||||
call PhpCsFixerFix(expand('%:p'), g:php_cs_fixer_dry_run)
|
||||
endfun
|
||||
|
||||
if(g:php_cs_fixer_enable_default_mapping == 1)
|
||||
nnoremap <silent><leader>pcd :call PhpCsFixerFixDirectory()<CR>
|
||||
nnoremap <silent><leader>pcf :call PhpCsFixerFixFile()<CR>
|
||||
endif
|
||||
|
||||
" vim: foldmethod=marker
|
1
.vim/autoload/zencoding-vim/.gitignore
vendored
1
.vim/autoload/zencoding-vim/.gitignore
vendored
|
@ -1 +0,0 @@
|
|||
/doc/tags
|
3
.vim/autoload/zencoding-vim/.gitmodules
vendored
3
.vim/autoload/zencoding-vim/.gitmodules
vendored
|
@ -1,3 +0,0 @@
|
|||
[submodule "docs"]
|
||||
path = docs
|
||||
url = git://github.com/mattn/zencoding-vim.git
|
|
@ -1,11 +0,0 @@
|
|||
all : zencoding-vim.zip
|
||||
|
||||
remove-zip:
|
||||
-rm doc/tags
|
||||
-rm zencoding-vim.zip
|
||||
|
||||
zencoding-vim.zip: remove-zip
|
||||
zip -r zencoding-vim.zip autoload plugin doc
|
||||
|
||||
release: zencoding-vim.zip
|
||||
vimup update-script zencoding.vim
|
|
@ -1,62 +0,0 @@
|
|||
ZenCoding-vim
|
||||
====
|
||||
[zencoding-vim](http://mattn.github.com/zencoding-vim) is vim script support for expanding abbreviation like zen-coding.
|
||||
|
||||
Installation
|
||||
---
|
||||
|
||||
[Download zip
|
||||
file](http://www.vim.org/scripts/script.php?script_id=2981):
|
||||
|
||||
cd ~/.vim
|
||||
unzip zencoding-vim.zip
|
||||
|
||||
If you install pathogen.vim:
|
||||
|
||||
cd ~/.vim/bundle # or make directory
|
||||
unzip /path/to/zencoding-vim.zip
|
||||
|
||||
If you get source from repository:
|
||||
|
||||
cd ~/.vim/bundle # or make directory
|
||||
git clone http://github.com/mattn/zencoding-vim.git
|
||||
|
||||
or:
|
||||
|
||||
git clone http://github.com/mattn/zencoding-vim.git
|
||||
cd zencoding-vim
|
||||
cp plugin/zencoding.vim ~/.vim/plugin/
|
||||
cp autoload/zencoding.vim ~/.vim/autoload/
|
||||
|
||||
|
||||
Quick Tutorial
|
||||
---
|
||||
|
||||
Open or create New File:
|
||||
|
||||
vim index.html
|
||||
|
||||
Type ("_" is the cursor position):
|
||||
|
||||
html:5_
|
||||
|
||||
Then type "<c-y>," (Ctrl + y + ','), you should see:
|
||||
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title></title>
|
||||
</head>
|
||||
<body>
|
||||
_
|
||||
</body>
|
||||
</html>
|
||||
|
||||
[More
|
||||
Tutorials](https://raw.github.com/mattn/zencoding-vim/master/TUTORIAL)
|
||||
|
||||
|
||||
Project Authors
|
||||
---
|
||||
[Yasuhiro Matsumoto](http://mattn.kaoriya.net/)
|
|
@ -1,212 +0,0 @@
|
|||
Tutorial of zencoding.vim
|
||||
|
||||
mattn <mattn.jp@gmail.com>
|
||||
|
||||
1. Expand Abbreviation
|
||||
|
||||
Type 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 Abbreviation
|
||||
|
||||
Write as below.
|
||||
---------------------
|
||||
test1
|
||||
test2
|
||||
test3
|
||||
---------------------
|
||||
Then do visual select(line wize) and type '<c-y>,'.
|
||||
If you request 'Tag:', then type 'ul>li*'.
|
||||
---------------------
|
||||
<ul>
|
||||
<li>test1</li>
|
||||
<li>test2</li>
|
||||
<li>test3</li>
|
||||
</ul>
|
||||
---------------------
|
||||
|
||||
If you type tag as 'blockquote', then you'll see as following.
|
||||
---------------------
|
||||
<blockquote>
|
||||
test1
|
||||
test2
|
||||
test3
|
||||
</blockquote>
|
||||
---------------------
|
||||
|
||||
3. Balance Tag Inward
|
||||
|
||||
type '<c-y>d' in insert mode.
|
||||
|
||||
4. Balance Tag Outward
|
||||
|
||||
type '<c-y>D' in insert mode.
|
||||
|
||||
5. Go to Next Edit Point
|
||||
|
||||
type '<c-y>n' in insert mode.
|
||||
|
||||
6. Go to Previous Edit Point
|
||||
|
||||
type '<c-y>N' in insert mode.
|
||||
|
||||
7. Update <img> Size
|
||||
|
||||
Move cursor to 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 included '<li>'
|
||||
---------------------
|
||||
<ul>
|
||||
<li class="list1"></li>
|
||||
<li class="list2"></li>
|
||||
<li class="list3"></li>
|
||||
</ul>
|
||||
---------------------
|
||||
and type 'J'
|
||||
---------------------
|
||||
<ul>
|
||||
<li class="list1"></li><li class="list2"></li><li class="list3"></li>
|
||||
</ul>
|
||||
---------------------
|
||||
|
||||
9. Remove 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 cursor in block
|
||||
---------------------
|
||||
<div class="foo">
|
||||
cursor is here
|
||||
</div>
|
||||
---------------------
|
||||
Type '<c-y>j' in insert mode.
|
||||
---------------------
|
||||
<div class="foo"/>
|
||||
---------------------
|
||||
|
||||
And type '<c-y>j' in there again.
|
||||
---------------------
|
||||
<div class="foo">
|
||||
</div>
|
||||
---------------------
|
||||
|
||||
11. Toggle Comment
|
||||
|
||||
Move cursor to 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 anchor from URL
|
||||
|
||||
Move cursor to URL
|
||||
---------------------
|
||||
http://www.google.com/
|
||||
---------------------
|
||||
Type '<c-y>a'
|
||||
---------------------
|
||||
<a href="http://www.google.com/">Google</a>
|
||||
---------------------
|
||||
|
||||
13. Make quoted text from URL
|
||||
|
||||
Move cursor to 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 zencoding.vim for language you using.
|
||||
|
||||
# cd ~/.vim
|
||||
# unzip zencoding-vim.zip
|
||||
|
||||
or if you install pathogen.vim:
|
||||
|
||||
# cd ~/.vim/bundle # or make directory
|
||||
# unzip /path/to/zencoding-vim.zip
|
||||
|
||||
if you get sources from repository:
|
||||
|
||||
# cd ~/.vim/bundle # or make directory
|
||||
# git clone http://github.com/mattn/zencoding-vim.git
|
||||
|
||||
15. Enable zencoding.vim for language you using.
|
||||
|
||||
You can customize the behavior of language you using.
|
||||
|
||||
---------------------
|
||||
# cat >> ~/.vimrc
|
||||
let g:user_zen_settings = {
|
||||
\ 'php' : {
|
||||
\ 'extends' : 'html',
|
||||
\ 'filters' : 'c',
|
||||
\ },
|
||||
\ 'xml' : {
|
||||
\ 'extends' : 'html',
|
||||
\ },
|
||||
\ 'haml' : {
|
||||
\ 'extends' : 'html',
|
||||
\ },
|
||||
\}
|
||||
---------------------
|
|
@ -1,383 +0,0 @@
|
|||
*zencoding.txt* ZenCoding for Vim
|
||||
|
||||
-------------------------------------------------------
|
||||
ZenCoding: vim plugins for HTML and CSS hi-speed coding
|
||||
-------------------------------------------------------
|
||||
|
||||
Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
|
||||
WebSite: http://mattn.kaoriya.net/
|
||||
Repository: http://github.com/mattn/zencoding-vim
|
||||
Site: http://mattn.github.com/zencoding-vim
|
||||
License: BSD style license
|
||||
|
||||
==============================================================================
|
||||
CONTENTS *zencoding-contents*
|
||||
|
||||
Introduction |zencoding-introduction|
|
||||
Install |zencoding-install|
|
||||
Tutorial |zencoding-tutorial|
|
||||
1. Expand Abbreviation |zencoding-expandabbr|
|
||||
2. Wrap with Abbreviation |zencoding-wrap-wtih-abbreviation|
|
||||
3. Balance Tag Inward |zencoding-balance-tag-inward|
|
||||
4. Balance Tag Outward |zencoding-balance-tag-outward|
|
||||
5. Go to Next Edit Point |zencoding-goto-next-point| |<C-Y>n|
|
||||
6. Go to Previous Edit Point |zencoding-goto-previous-point|
|
||||
7. Update <img> Size |zencoding-update-image-size|
|
||||
8. Merge Lines |zencoding-merge-lines|
|
||||
9. Remove Tag |zencoding-remove-tag|
|
||||
10. Split/Join Tag |zencoding-split-join-tag|
|
||||
11. Toggle Comment |zencoding-toggle-comment|
|
||||
12. Make anchor from URL |zencoding-make-anchor-url|
|
||||
13. Make quoted text from URL |zencoding-quoted-text-url|
|
||||
Customize |zencoding-customize|
|
||||
1. Key Mappings |zencoding-customize-keymappings|
|
||||
2. Indent Size |zencoding-indent-size|
|
||||
3. Define Tag's Behavior |zencoding-define-tags-behavior|
|
||||
4. Complete Tag |zencoding-complete-tag|
|
||||
ToDo |zencoding-todo|
|
||||
|
||||
==============================================================================
|
||||
INTRODUCTION *zencoding-introduction* *zencoding*
|
||||
|
||||
|ZenCoding| 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:
|
||||
>
|
||||
<div id="page">
|
||||
<div class="logo"></div>
|
||||
<ul id="navigation">
|
||||
<li><a href=""></a></li>
|
||||
<li><a href=""></a></li>
|
||||
<li><a href=""></a></li>
|
||||
<li><a href=""></a></li>
|
||||
<li><a href=""></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<
|
||||
Read more about current Zen Coding syntax
|
||||
http://code.google.com/p/zen-coding/wiki/ZenHTMLSelectorsEn
|
||||
|
||||
Abbreviation engine has a modular structure which allows you to expand
|
||||
abbreviations into different languages. Zen Coding currently supports CSS,
|
||||
HTML, XML/XSL and HAML languages via filters.
|
||||
|
||||
==============================================================================
|
||||
INSTALL *zencoding-install*
|
||||
|
||||
Install the distributed files into Vim runtime directory which is usually
|
||||
~/.vim/, or $HOME/vimfiles on Windows.
|
||||
|
||||
If you install pathogen that provided from Tim Pope, you should extract the
|
||||
file into 'bundle' directory.
|
||||
|
||||
==============================================================================
|
||||
TUTORIAL *zencoding-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
|
||||
'zencoding-tutor.txt'. Formally, open the file to start tutorial.
|
||||
|
||||
1. Expand Abbreviation *zencoding-expandabbr* *<C-Y>,*
|
||||
|
||||
Type 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 Abbreviation *zencoding-wrap-wtih-abbreviation* *v_<C-Y>,*
|
||||
|
||||
Write as below.
|
||||
>
|
||||
test1
|
||||
test2
|
||||
test3
|
||||
<
|
||||
Then do visual select(line wize) and type |<C-Y>,|.
|
||||
If you request 'Tag:', then type 'ul>li*'.
|
||||
>
|
||||
<ul>
|
||||
<li>test1</li>
|
||||
<li>test2</li>
|
||||
<li>test3</li>
|
||||
</ul>
|
||||
<
|
||||
If you type tag as 'blockquote', then you'll see as following.
|
||||
>
|
||||
<blockquote>
|
||||
test1
|
||||
test2
|
||||
test3
|
||||
</blockquote>
|
||||
<
|
||||
3. Balance Tag Inward *zencoding-balance-tag-inward* *<C-Y>d*
|
||||
|
||||
To select inward of ul tag, type |<C-Y>d| in insert mode.
|
||||
>
|
||||
<ul>
|
||||
* <li class="list1"></li>
|
||||
<li class="list2"></li>
|
||||
<li class="list3"></li>
|
||||
</ul>
|
||||
<
|
||||
If cursor is at '*', |<C-Y>d| select from begin of <ul> to end of </ul>.
|
||||
If cursor is at first of <li>, it select <li class="list1"></li>.
|
||||
|
||||
4. Balance Tag Outward *zencoding-balance-tag-outward* *<C-Y>D*
|
||||
|
||||
To select outward of ul tag, insert mode, type <C-Y>D in insert mode.
|
||||
>
|
||||
<ul>
|
||||
* <li class="list1"></li>
|
||||
<li class="list2"></li>
|
||||
<li class="list3"></li>
|
||||
</ul>
|
||||
<
|
||||
If cursor is at '*', |<C-Y>d| select from next letter of <ul> to previous
|
||||
letter of </ul>.
|
||||
If cursor is at first of <li>, it select <li class="list1"></li>.
|
||||
|
||||
5. Go to Next Edit Point *zencoding-goto-next-point* *<C-Y>n*
|
||||
|
||||
To jump next point that need to edit, type |<C-Y>n| in insert mode.
|
||||
>
|
||||
* <div id="foo" class="">foo</div>
|
||||
<div id="bar" class="bar"></li>
|
||||
<
|
||||
If cursor is at '*', |<C-Y>n| move a cursor into attribute value of div
|
||||
specified id as 'foo'. And type again |<C-Y>n| move a cursor into inner of
|
||||
div specified id as 'bar'.
|
||||
|
||||
6. Go to Previous Edit Point *zencoding-goto-previous-point* *<C-Y>N*
|
||||
|
||||
To jump previous point that need to edit, type |<C-Y>N| in insert mode.
|
||||
>
|
||||
<div id="foo" class="">foo</div>
|
||||
<div id="bar" class="bar"></li> *
|
||||
<
|
||||
If cursor is at '*', |<C-Y>N| move a cursor into div specified id as 'bar'.
|
||||
And type again |<C-Y>N| move a cursor into attribute value of 'foo'.
|
||||
|
||||
7. Update <img> Size *zencoding-update-image-size* *<C-Y>i*
|
||||
|
||||
To expand or update size of image, type |<C-Y>i| on img tag
|
||||
>
|
||||
<img src="foo.png" />
|
||||
<
|
||||
Type '<c-y>i' on img tag
|
||||
>
|
||||
<img src="foo.png" width="32" height="32" />
|
||||
<
|
||||
If you change image, then type it again. it will be following.
|
||||
>
|
||||
<img src="foo-48.png" width="32" height="48" />
|
||||
<
|
||||
8. Merge Lines *zencoding-merge-lines*
|
||||
|
||||
To join multi line text like following, type |J|.
|
||||
>
|
||||
<ul>
|
||||
<li class="list1"></li>
|
||||
<li class="list2"></li>
|
||||
<li class="list3"></li>
|
||||
</ul>
|
||||
<
|
||||
If you select part of line include <li> and type |J|, it will be following.
|
||||
>
|
||||
<ul>
|
||||
<li class="list1"></li><li class="list2"></li><li class="list3"></li>
|
||||
</ul>
|
||||
<
|
||||
9. Remove Tag *zencoding-remove-tag* *<C-Y>k*
|
||||
|
||||
To remove tag in the block, type |<C-Y>k|.
|
||||
>
|
||||
<div class="foo">
|
||||
<a>cursor is here</a>
|
||||
</div>
|
||||
<
|
||||
Type |<C-Y>k| in insert mode, then
|
||||
>
|
||||
<div class="foo">
|
||||
|
||||
</div>
|
||||
<
|
||||
And type |<C-Y>k| in there again, then div will be removed.
|
||||
|
||||
10. Split/Join Tag *zencoding-split-join-tag* *<C-Y>j*
|
||||
|
||||
To join block, type |<C-Y>j|.
|
||||
>
|
||||
<div class="foo">
|
||||
cursor is here
|
||||
</div>
|
||||
<
|
||||
Type |<C-Y>j| in insert mode. then,
|
||||
>
|
||||
<div class="foo"/>
|
||||
<
|
||||
And type |<C-Y>j| in there again.
|
||||
>
|
||||
<div class="foo">
|
||||
</div>
|
||||
<
|
||||
11. Toggle Comment *zencoding-toggle-comment* *<C-Y>/*
|
||||
|
||||
Move cursor to 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 anchor from URL *zencoding-make-anchor-url* *<C-Y>a*
|
||||
|
||||
Move cursor to URL
|
||||
>
|
||||
http://www.google.com/
|
||||
<
|
||||
Type |<C-Y>a|
|
||||
>
|
||||
<a href="http://www.google.com/">Google</a>
|
||||
<
|
||||
13. Make quoted text from URL *zencoding-quoted-text-url* *<C-Y>A*
|
||||
|
||||
Move cursor to 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>
|
||||
<
|
||||
==============================================================================
|
||||
CUSTOMIZE *zencoding-customize*
|
||||
|
||||
1. Key Mapping *zencoding-customize-keymappings*
|
||||
|
||||
To specify leading key for expanding or balance tag, or for all,
|
||||
Add this line in your vimrc: >
|
||||
>
|
||||
let g:user_zen_leader_key = '<c-y>'
|
||||
<
|
||||
Or if you prefer to map for each actions, then you set each variables.
|
||||
|
||||
'user_zen_expandabbr_key'
|
||||
'user_zen_expandword_key'
|
||||
'user_zen_balancetaginward_key'
|
||||
'user_zen_balancetagoutward_key'
|
||||
'user_zen_next_key'
|
||||
'user_zen_prev_key'
|
||||
'user_zen_imagesize_key'
|
||||
'user_zen_togglecomment_key'
|
||||
'user_zen_splitjointag_key'
|
||||
'user_zen_removetag_key'
|
||||
'user_zen_anchorizeurl_key'
|
||||
'user_zen_anchorizesummary_key'
|
||||
|
||||
2. Indent Size *zencoding-indent-size*
|
||||
|
||||
To change indent size of html, add this code in your vimrc.
|
||||
>
|
||||
let g:user_zen_settings = {
|
||||
\ 'html' : {
|
||||
\ 'indentation' : ' '
|
||||
\ },
|
||||
\}
|
||||
<
|
||||
If you prefer to change global indent size then add this.
|
||||
>
|
||||
let g:user_zen_settings = {
|
||||
\ 'indentation' : ' '
|
||||
\}
|
||||
<
|
||||
3. Define Tag's Behavior *zencoding-define-tags-behavior*
|
||||
|
||||
zencoding.vim can change behavior of expanding abbreviation for each
|
||||
filetypes as |Dictionary|. for details, see official site of zencoding.
|
||||
for example, vimmer can add following.
|
||||
>
|
||||
let g:user_zen_settings = {
|
||||
\ 'lang' : 'ja',
|
||||
\ 'html' : {
|
||||
\ 'filters' : 'html',
|
||||
\ 'indentation' : ' '
|
||||
\ },
|
||||
\ 'perl' : {
|
||||
\ 'indentation' : ' ',
|
||||
\ 'aliases' : {
|
||||
\ 'req' : "require '|'"
|
||||
\ },
|
||||
\ 'snippets' : {
|
||||
\ 'use' : "use strict\nuse warnings\n\n",
|
||||
\ 'w' : "warn \"${cursor}\";",
|
||||
\ },
|
||||
\ },
|
||||
\ 'php' : {
|
||||
\ 'extends' : 'html',
|
||||
\ 'filters' : 'html,c',
|
||||
\ },
|
||||
\ 'css' : {
|
||||
\ 'filters' : 'fc',
|
||||
\ },
|
||||
\ 'javascript' : {
|
||||
\ 'snippets' : {
|
||||
\ 'jq' : "$(function() {\n\t${cursor}${child}\n});",
|
||||
\ 'jq:each' : "$.each(arr, function(index, item)\n\t${child}\n});",
|
||||
\ 'fn' : "(function() {\n\t${cursor}\n})();",
|
||||
\ 'tm' : "setTimeout(function() {\n\t${cursor}\n}, 100);",
|
||||
\ },
|
||||
\ },
|
||||
\ 'java' : {
|
||||
\ 'indentation' : ' ',
|
||||
\ 'snippets' : {
|
||||
\ 'main': "public static void main(String[] args) {\n\t|\n}",
|
||||
\ 'println': "System.out.println(\"|\");",
|
||||
\ 'class': "public class | {\n}\n",
|
||||
\ },
|
||||
\ },
|
||||
\}
|
||||
<
|
||||
4. Complete Tag *zencoding-complete-tag*
|
||||
|
||||
If you want to complete tags using |omnifunc| then add this.
|
||||
>
|
||||
let g:use_zen_complete_tag = 1
|
||||
<
|
||||
==============================================================================
|
||||
TODO *zencoding-todo*
|
||||
* wrapping inline selected.
|
||||
* more documents.
|
||||
* more contributor.
|
||||
* more time to improve zencodig.vim.
|
||||
|
||||
==============================================================================
|
||||
vim:tw=78:ts=8:ft=help:norl:noet:fen:fdl=0:
|
|
@ -1,528 +0,0 @@
|
|||
if exists('g:user_zen_settings')
|
||||
let s:old_user_zen_settings = g:user_zen_settings
|
||||
unlet! g:user_zen_settings
|
||||
endif
|
||||
so plugin/zencoding.vim
|
||||
|
||||
function! s:testExpandAbbr()
|
||||
unlet! testgroups
|
||||
let testgroups = eval(join(filter(split(substitute(join(readfile(expand('%')), "\n"), '.*\nfinish\n', '', ''), '\n', 1), "v:val !~ '^\"'")))
|
||||
let failed = 0
|
||||
for testgroup in testgroups
|
||||
echohl MatchParen | echon "[" testgroup.category."]\n" | echohl None
|
||||
let tests = testgroup.tests
|
||||
let start = reltime()
|
||||
for n in range(len(tests))
|
||||
let testtitle = tests[n].name
|
||||
let testtitle = len(testtitle) < 57 ? (testtitle.repeat(' ', 57-len(testtitle))) : strpart(testtitle, 0, 57)
|
||||
echohl ModeMsg | echon "testing #".printf("%03d", n+1)
|
||||
echohl None | echon ": ".testtitle." ... "
|
||||
unlet! res | let res = zencoding#ExpandWord(tests[n].query, tests[n].type, 0)
|
||||
if res == tests[n].result
|
||||
echohl Title | echon "ok\n" | echohl None
|
||||
else
|
||||
echohl WarningMsg | echon "ng\n" | echohl None
|
||||
echohl ErrorMsg | echo "failed test #".(n+1) | echohl None
|
||||
set more
|
||||
echo " expect:".tests[n].result
|
||||
echo " got:".res
|
||||
echo ""
|
||||
let failed = 1
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
if failed
|
||||
break
|
||||
endif
|
||||
echo "past:".reltimestr(reltime(start))."\n"
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! s:testImageSize()
|
||||
silent! 1new
|
||||
silent! call setline(1, "img[src=http://mattn.kaoriya.net/images/logo.png]")
|
||||
silent! let start = reltime()
|
||||
exe "silent! normal A\<c-y>,\<c-y>i"
|
||||
let time = reltimestr(reltime(start))
|
||||
let line = getline(1)
|
||||
silent! bw!
|
||||
echohl MatchParen | echon "[image size]\n" | echohl None
|
||||
echohl ModeMsg | echon "testing image size" . repeat(' ', 54) . '... ' | echohl None
|
||||
let expect = '<img src="http://mattn.kaoriya.net/images/logo.png" alt="" width="96" height="96" />'
|
||||
if line == expect
|
||||
echohl Title | echon "ok\n" | echohl None
|
||||
echo "past:".time."\n"
|
||||
echo
|
||||
else
|
||||
echohl WarningMsg | echon "ng\n" | echohl None
|
||||
echohl ErrorMsg | echo "failed test image size" | echohl None
|
||||
echo " expect:".expect
|
||||
echo " got:".line
|
||||
echo ""
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:testMoveNextPrev()
|
||||
silent! 1new
|
||||
silent! call setline(1, "<foo></foo>")
|
||||
silent! call setline(2, "<bar></bar>")
|
||||
silent! call setline(3, "<baz dankogai=\"\"></baz>")
|
||||
let start = reltime()
|
||||
exe "silent! normal gg0\<c-y>n\<c-y>n\<c-y>n"
|
||||
let pos = getpos(".")
|
||||
let line = substitute(getline("."), '<baz \(\w\+\)=".*', '\1', '')
|
||||
silent! bw!
|
||||
echohl MatchParen | echon "[move next prev]\n" | echohl None
|
||||
echohl ModeMsg | echon "testing move next prev" . repeat(' ', 50) . '... ' | echohl None
|
||||
let time = reltimestr(reltime(start))
|
||||
let expect = [0,3,15,0]
|
||||
if pos == expect && line == 'dankogai'
|
||||
echohl Title | echon "ok\n" | echohl None
|
||||
echo "past:".time."\n"
|
||||
else
|
||||
echohl WarningMsg | echon "ng\n" | echohl None
|
||||
echohl ErrorMsg | echo "failed test image size" | echohl None
|
||||
echo " expect:".string(expect)
|
||||
echo " got:".string(pos)
|
||||
echo ""
|
||||
endif
|
||||
endfunction
|
||||
|
||||
let oldmore = &more
|
||||
let &more = 0
|
||||
|
||||
call s:testExpandAbbr()
|
||||
call s:testImageSize()
|
||||
call s:testMoveNextPrev()
|
||||
|
||||
if exists('g:user_zen_settings')
|
||||
let g:user_zen_settings = s:old_user_zen_settings
|
||||
endif
|
||||
|
||||
let &more=oldmore
|
||||
echo "done"
|
||||
|
||||
finish
|
||||
[
|
||||
{
|
||||
'category': 'html',
|
||||
'tests': [
|
||||
{
|
||||
'name': "div",
|
||||
'query': "div",
|
||||
'type': "html",
|
||||
'result': "<div></div>\n",
|
||||
},
|
||||
{
|
||||
'name': "div#wrapper",
|
||||
'query': "div#wrapper",
|
||||
'type': "html",
|
||||
'result': "<div id=\"wrapper\"></div>\n",
|
||||
},
|
||||
{
|
||||
'name': "div.box",
|
||||
'query': "div.box",
|
||||
'type': "html",
|
||||
'result': "<div class=\"box\"></div>\n",
|
||||
},
|
||||
{
|
||||
'name': "a[title=TITLE]",
|
||||
'query': "a[title=TITLE]",
|
||||
'type': "html",
|
||||
'result': "<a href=\"\" title=\"TITLE\"></a>\n",
|
||||
},
|
||||
{
|
||||
'name': "div#wrapper.box",
|
||||
'query': "div#wrapper.box",
|
||||
'type': "html",
|
||||
'result': "<div id=\"wrapper\" class=\"box\"></div>\n",
|
||||
},
|
||||
{
|
||||
'name': "div#wrapper.box.current",
|
||||
'query': "div#wrapper.box.current",
|
||||
'type': "html",
|
||||
'result': "<div id=\"wrapper\" class=\"box current\"></div>\n",
|
||||
},
|
||||
{
|
||||
'name': "div#wrapper.box.current[title=TITLE rel]",
|
||||
'query': "div#wrapper.box.current[title=TITLE rel]",
|
||||
'type': "html",
|
||||
'result': "<div id=\"wrapper\" rel=\"\" class=\"box current\" title=\"TITLE\"></div>\n",
|
||||
},
|
||||
{
|
||||
'name': "div#main+div#sub",
|
||||
'query': "div#main+div#sub",
|
||||
'type': "html",
|
||||
'result': "<div id=\"main\"></div>\n<div id=\"sub\"></div>\n",
|
||||
},
|
||||
{
|
||||
'name': "div#main>div#sub",
|
||||
'query': "div#main>div#sub",
|
||||
'type': "html",
|
||||
'result': "<div id=\"main\">\n\t<div id=\"sub\"></div>\n</div>\n",
|
||||
},
|
||||
{
|
||||
'name': "html:xt>div#header>div#logo+ul#nav>li.item-$*5>a",
|
||||
'query': "html:xt>div#header>div#logo+ul#nav>li.item-$*5>a",
|
||||
'type': "html",
|
||||
'result': "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">\n<head>\n\t<meta http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\" />\n\t<title></title>\n</head>\n<body>\n\t<div id=\"header\">\n\t\t<div id=\"logo\"></div>\n\t\t<ul id=\"nav\">\n\t\t\t<li class=\"item-1\">\n\t\t\t\t<a href=\"\"></a>\n\t\t\t</li>\n\t\t\t<li class=\"item-2\">\n\t\t\t\t<a href=\"\"></a>\n\t\t\t</li>\n\t\t\t<li class=\"item-3\">\n\t\t\t\t<a href=\"\"></a>\n\t\t\t</li>\n\t\t\t<li class=\"item-4\">\n\t\t\t\t<a href=\"\"></a>\n\t\t\t</li>\n\t\t\t<li class=\"item-5\">\n\t\t\t\t<a href=\"\"></a>\n\t\t\t</li>\n\t\t</ul>\n\t</div>\n\t\n</body>\n</html>",
|
||||
},
|
||||
{
|
||||
'name': "ol>li*2",
|
||||
'query': "ol>li*2",
|
||||
'type': "html",
|
||||
'result': "<ol>\n\t<li></li>\n\t<li></li>\n</ol>\n",
|
||||
},
|
||||
{
|
||||
'name': "a",
|
||||
'query': "a",
|
||||
'type': "html",
|
||||
'result': "<a href=\"\"></a>\n",
|
||||
},
|
||||
{
|
||||
'name': "obj",
|
||||
'query': "obj",
|
||||
'type': "html",
|
||||
'result': "<object data=\"\" type=\"\"></object>\n",
|
||||
},
|
||||
{
|
||||
'name': "cc:ie6>p+blockquote#sample$.so.many.classes*2",
|
||||
'query': "cc:ie6>p+blockquote#sample$.so.many.classes*2",
|
||||
'type': "html",
|
||||
'result': "<!--[if lte IE 6]>\n\t<p></p>\n\t<blockquote id=\"sample1\" class=\"so many classes\"></blockquote>\n\t<blockquote id=\"sample2\" class=\"so many classes\"></blockquote>\n\t\n<![endif]-->",
|
||||
},
|
||||
{
|
||||
'name': "tm>if>div.message",
|
||||
'query': "tm>if>div.message",
|
||||
'type': "html",
|
||||
'result': "<tm>\n\t<if>\n\t\t<div class=\"message\"></div>\n\t</if>\n</tm>\n",
|
||||
},
|
||||
{
|
||||
'name': "html:4t>div#wrapper>div#header+div#contents+div#footer",
|
||||
'query': "html:4t>div#wrapper>div#header+div#contents+div#footer",
|
||||
'type': "html",
|
||||
'result': "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n<html lang=\"en\">\n<head>\n\t<meta http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\">\n\t<title></title>\n</head>\n<body>\n\t<div id=\"wrapper\">\n\t\t<div id=\"header\"></div>\n\t\t<div id=\"contents\"></div>\n\t\t<div id=\"footer\"></div>\n\t</div>\n\t\n</body>\n</html>",
|
||||
},
|
||||
{
|
||||
'name': "a[href=http://www.google.com/].foo#hoge",
|
||||
'query': "a[href=http://www.google.com/].foo#hoge",
|
||||
'type': "html",
|
||||
'result': "<a id=\"hoge\" href=\"http://www.google.com/\" class=\"foo\"></a>\n",
|
||||
},
|
||||
{
|
||||
'name': "a[href=http://www.google.com/]{Google}",
|
||||
'query': "a[href=http://www.google.com/]{Google}",
|
||||
'type': "html",
|
||||
'result': "<a href=\"http://www.google.com/\">Google</a>\n",
|
||||
},
|
||||
{
|
||||
'name': "{ZenCoding}",
|
||||
'query': "{ZenCoding}",
|
||||
'type': "html",
|
||||
'result': "ZenCoding",
|
||||
},
|
||||
{
|
||||
'name': "a+b",
|
||||
'query': "a+b",
|
||||
'type': "html",
|
||||
'result': "<a href=\"\"></a>\n<b></b>\n",
|
||||
},
|
||||
{
|
||||
'name': "a>b>c<d",
|
||||
'query': "a>b>c<d",
|
||||
'type': "html",
|
||||
'result': "<a href=\"\"><b><c></c></b><d></d></a>\n",
|
||||
},
|
||||
{
|
||||
'name': "a>b>c<<d",
|
||||
'query': "a>b>c<<d",
|
||||
'type': "html",
|
||||
'result': "<a href=\"\"><b><c></c></b></a>\n<d></d>\n",
|
||||
},
|
||||
{
|
||||
'name': "blockquote>b>c<<d",
|
||||
'query': "blockquote>b>c<<d",
|
||||
'type': "html",
|
||||
'result': "<blockquote>\n\t<b><c></c></b>\n</blockquote>\n<d></d>\n",
|
||||
},
|
||||
{
|
||||
'name': "a[href=foo][class=bar]",
|
||||
'query': "a[href=foo][class=bar]",
|
||||
'type': "html",
|
||||
'result': "<a href=\"foo\" class=\"bar\"></a>\n",
|
||||
},
|
||||
{
|
||||
'name': "a[a=b][b=c=d][e]{foo}*2",
|
||||
'query': "a[a=b][b=c=d][e]{foo}*2",
|
||||
'type': "html",
|
||||
'result': "<a a=\"b\" b=\"c=d\" e=\"\" href=\"\">foo</a>\n<a a=\"b\" b=\"c=d\" e=\"\" href=\"\">foo</a>\n",
|
||||
},
|
||||
{
|
||||
'name': "a[a=b][b=c=d][e]*2{foo}",
|
||||
'query': "a[a=b][b=c=d][e]*2{foo}",
|
||||
'type': "html",
|
||||
'result': "<a a=\"b\" b=\"c=d\" e=\"\" href=\"\"></a>\n<a a=\"b\" b=\"c=d\" e=\"\" href=\"\"></a>\nfoo",
|
||||
},
|
||||
{
|
||||
'name': "a*2{foo}a",
|
||||
'query': "a*2{foo}a",
|
||||
'type': "html",
|
||||
'result': "<a href=\"\"></a>\n<a href=\"\"></a>\nfoo<a href=\"\"></a>\n",
|
||||
},
|
||||
{
|
||||
'name': "a{foo}*2>b",
|
||||
'query': "a{foo}*2>b",
|
||||
'type': "html",
|
||||
'result': "<a href=\"\">foo<b></b></a>\n<a href=\"\">foo<b></b></a>\n",
|
||||
},
|
||||
{
|
||||
'name': "a*2{foo}>b",
|
||||
'query': "a*2{foo}>b",
|
||||
'type': "html",
|
||||
'result': "<a href=\"\"></a>\n<a href=\"\"></a>\nfoo",
|
||||
},
|
||||
{
|
||||
'name': "table>tr>td.name#foo+td*3",
|
||||
'query': "table>tr>td.name#foo+td*3",
|
||||
'type': "html",
|
||||
'result': "<table>\n\t<tr>\n\t\t<td id=\"foo\" class=\"name\"></td>\n\t\t<td></td>\n\t\t<td></td>\n\t\t<td></td>\n\t</tr>\n</table>\n",
|
||||
},
|
||||
{
|
||||
'name': "div#header + div#footer",
|
||||
'query': "div#header + div#footer",
|
||||
'type': "html",
|
||||
'result': "<div id=\"header\"></div>\n<div id=\"footer\"></div>\n",
|
||||
},
|
||||
{
|
||||
'name': "#header + div#footer",
|
||||
'query': "#header + div#footer",
|
||||
'type': "html",
|
||||
'result': "<div id=\"header\"></div>\n<div id=\"footer\"></div>\n",
|
||||
},
|
||||
{
|
||||
'name': "#header > ul > li < p{Footer}",
|
||||
'query': "#header > ul > li < p{Footer}",
|
||||
'type': "html",
|
||||
'result': "<div id=\"header\">\n\t<ul>\n\t\t<li></li>\n\t</ul>\n\t<p>Footer</p>\n</div>\n",
|
||||
},
|
||||
{
|
||||
'name': "a#foo$$$*3",
|
||||
'query': "a#foo$$$*3",
|
||||
'type': "html",
|
||||
'result': "<a id=\"foo001\" href=\"\"></a>\n<a id=\"foo002\" href=\"\"></a>\n<a id=\"foo003\" href=\"\"></a>\n",
|
||||
},
|
||||
{
|
||||
'name': "ul+",
|
||||
'query': "ul+",
|
||||
'type': "html",
|
||||
'result': "<ul>\n\t<li></li>\n</ul>\n",
|
||||
},
|
||||
{
|
||||
'name': "table+",
|
||||
'query': "table+",
|
||||
'type': "html",
|
||||
'result': "<table>\n\t<tr>\n\t\t<td></td>\n\t</tr>\n</table>\n",
|
||||
},
|
||||
{
|
||||
'name': "#header>li<#content",
|
||||
'query': "#header>li<#content",
|
||||
'type': "html",
|
||||
'result': "<div id=\"header\">\n\t<li></li>\n</div>\n<div id=\"content\"></div>\n",
|
||||
},
|
||||
{
|
||||
'name': "(#header>li)<#content",
|
||||
'query': "(#header>li)<#content",
|
||||
'type': "html",
|
||||
'result': "<div id=\"header\">\n\t<li></li>\n</div>\n<div id=\"content\"></div>\n",
|
||||
},
|
||||
{
|
||||
'name': "a>b>c<<div",
|
||||
'query': "a>b>c<<div",
|
||||
'type': "html",
|
||||
'result': "<a href=\"\"><b><c></c></b></a>\n<div></div>\n",
|
||||
},
|
||||
{
|
||||
'name': "(#header>h1)+#content+#footer",
|
||||
'query': "(#header>h1)+#content+#footer",
|
||||
'type': "html",
|
||||
'result': "<div id=\"header\">\n\t<h1></h1>\n</div>\n<div id=\"content\"></div>\n<div id=\"footer\"></div>\n",
|
||||
},
|
||||
{
|
||||
'name': "(#header>h1)+(#content>(#main>h2+div#entry$.section*5>(h3>a)+div>p*3+ul+)+(#utilities))+(#footer>address)",
|
||||
'query': "(#header>h1)+(#content>(#main>h2+div#entry$.section*5>(h3>a)+div>p*3+ul+)+(#utilities))+(#footer>address)",
|
||||
'type': "html",
|
||||
'result': "<div id=\"header\">\n\t<h1></h1>\n</div>\n<div id=\"content\">\n\t<div id=\"main\">\n\t\t<h2></h2>\n\t\t<div id=\"entry1\" class=\"section\">\n\t\t\t<h3>\n\t\t\t\t<a href=\"\"></a>\n\t\t\t</h3>\n\t\t\t<div>\n\t\t\t\t<p></p>\n\t\t\t\t<p></p>\n\t\t\t\t<p></p>\n\t\t\t\t<ul>\n\t\t\t\t\t<li></li>\n\t\t\t\t</ul>\n\t\t\t</div>\n\t\t</div>\n\t\t<div id=\"entry2\" class=\"section\">\n\t\t\t<h3>\n\t\t\t\t<a href=\"\"></a>\n\t\t\t</h3>\n\t\t\t<div>\n\t\t\t\t<p></p>\n\t\t\t\t<p></p>\n\t\t\t\t<p></p>\n\t\t\t\t<ul>\n\t\t\t\t\t<li></li>\n\t\t\t\t</ul>\n\t\t\t</div>\n\t\t</div>\n\t\t<div id=\"entry3\" class=\"section\">\n\t\t\t<h3>\n\t\t\t\t<a href=\"\"></a>\n\t\t\t</h3>\n\t\t\t<div>\n\t\t\t\t<p></p>\n\t\t\t\t<p></p>\n\t\t\t\t<p></p>\n\t\t\t\t<ul>\n\t\t\t\t\t<li></li>\n\t\t\t\t</ul>\n\t\t\t</div>\n\t\t</div>\n\t\t<div id=\"entry4\" class=\"section\">\n\t\t\t<h3>\n\t\t\t\t<a href=\"\"></a>\n\t\t\t</h3>\n\t\t\t<div>\n\t\t\t\t<p></p>\n\t\t\t\t<p></p>\n\t\t\t\t<p></p>\n\t\t\t\t<ul>\n\t\t\t\t\t<li></li>\n\t\t\t\t</ul>\n\t\t\t</div>\n\t\t</div>\n\t\t<div id=\"entry5\" class=\"section\">\n\t\t\t<h3>\n\t\t\t\t<a href=\"\"></a>\n\t\t\t</h3>\n\t\t\t<div>\n\t\t\t\t<p></p>\n\t\t\t\t<p></p>\n\t\t\t\t<p></p>\n\t\t\t\t<ul>\n\t\t\t\t\t<li></li>\n\t\t\t\t</ul>\n\t\t\t</div>\n\t\t</div>\n\t</div>\n\t<div id=\"utilities\"></div>\n</div>\n<div id=\"footer\">\n\t<address></address>\n</div>\n",
|
||||
},
|
||||
{
|
||||
'name': "(div>(ul*2)*2)+(#utilities)",
|
||||
'query': "(div>(ul*2)*2)+(#utilities)",
|
||||
'type': "html",
|
||||
'result': "<div>\n\t<ul></ul>\n\t<ul></ul>\n\t<ul></ul>\n\t<ul></ul>\n</div>\n<div id=\"utilities\"></div>\n",
|
||||
},
|
||||
{
|
||||
'name': "table>(tr>td*3)*4",
|
||||
'query': "table>(tr>td*3)*4",
|
||||
'type': "html",
|
||||
'result': "<table>\n\t<tr>\n\t\t<td></td>\n\t\t<td></td>\n\t\t<td></td>\n\t</tr>\n\t<tr>\n\t\t<td></td>\n\t\t<td></td>\n\t\t<td></td>\n\t</tr>\n\t<tr>\n\t\t<td></td>\n\t\t<td></td>\n\t\t<td></td>\n\t</tr>\n\t<tr>\n\t\t<td></td>\n\t\t<td></td>\n\t\t<td></td>\n\t</tr>\n</table>\n",
|
||||
},
|
||||
{
|
||||
'name': "(((a#foo+a#bar)*2)*3)",
|
||||
'query': "(((a#foo+a#bar)*2)*3)",
|
||||
'type': "html",
|
||||
'result': "<a id=\"foo\" href=\"\"></a>\n<a id=\"bar\" href=\"\"></a>\n<a id=\"foo\" href=\"\"></a>\n<a id=\"bar\" href=\"\"></a>\n<a id=\"foo\" href=\"\"></a>\n<a id=\"bar\" href=\"\"></a>\n<a id=\"foo\" href=\"\"></a>\n<a id=\"bar\" href=\"\"></a>\n<a id=\"foo\" href=\"\"></a>\n<a id=\"bar\" href=\"\"></a>\n<a id=\"foo\" href=\"\"></a>\n<a id=\"bar\" href=\"\"></a>\n",
|
||||
},
|
||||
{
|
||||
'name': "div#box$*3>h3+p*2",
|
||||
'query': "div#box$*3>h3+p*2",
|
||||
'type': "html",
|
||||
'result': "<div id=\"box1\">\n\t<h3></h3>\n\t<p></p>\n\t<p></p>\n</div>\n<div id=\"box2\">\n\t<h3></h3>\n\t<p></p>\n\t<p></p>\n</div>\n<div id=\"box3\">\n\t<h3></h3>\n\t<p></p>\n\t<p></p>\n</div>\n"
|
||||
},
|
||||
{
|
||||
'name': "div#box.foo$$$.bar$$$*3",
|
||||
'query': "div#box.foo$$$.bar$$$*3",
|
||||
'type': "html",
|
||||
'result': "<div id=\"box\" class=\"foo001 bar001\"></div>\n<div id=\"box\" class=\"foo002 bar002\"></div>\n<div id=\"box\" class=\"foo003 bar003\"></div>\n",
|
||||
},
|
||||
{
|
||||
'name': "div#box$*3>h3+p.bar*2|e",
|
||||
'query': "div#box$*3>h3+p.bar*2|e",
|
||||
'type': "html",
|
||||
'result': "<div id=\"box1\">\n\t&lt;h3&gt;&lt;/h3&gt;\n\t&lt;p class=\"bar\"&gt;&lt;/p&gt;\n\t&lt;p class=\"bar\"&gt;&lt;/p&gt;\n</div>\n<div id=\"box2\">\n\t&lt;h3&gt;&lt;/h3&gt;\n\t&lt;p class=\"bar\"&gt;&lt;/p&gt;\n\t&lt;p class=\"bar\"&gt;&lt;/p&gt;\n</div>\n<div id=\"box3\">\n\t&lt;h3&gt;&lt;/h3&gt;\n\t&lt;p class=\"bar\"&gt;&lt;/p&gt;\n\t&lt;p class=\"bar\"&gt;&lt;/p&gt;\n</div>\n",
|
||||
},
|
||||
{
|
||||
'name': "div>div#page>p.title+p|c",
|
||||
'query': "div>div#page>p.title+p|c",
|
||||
'type': "html",
|
||||
'result': "<div>\n\t<!-- #page -->\n\t<div id=\"page\">\n\t\t<!-- .title -->\n\t\t<p class=\"title\"></p>\n\t\t<!-- /.title -->\n\t\t<p></p>\n\t</div>\n\t<!-- /#page -->\n</div>\n",
|
||||
},
|
||||
{
|
||||
'name': "link:css",
|
||||
'query': "link:css",
|
||||
'type': "html",
|
||||
'result': "<link media=\"all\" rel=\"stylesheet\" href=\"style.css\" type=\"text/css\" />\n",
|
||||
},
|
||||
{
|
||||
'name': "a[title=\"Hello', world\" rel]",
|
||||
'query': "a[title=\"Hello', world\" rel]",
|
||||
'type': "html",
|
||||
'result': "<a rel=\"\" href=\"\" title=\"Hello', world\"></a>\n",
|
||||
},
|
||||
{
|
||||
'name': "div>a#foo{bar}",
|
||||
'query': "div>a#foo{bar}",
|
||||
'type': "html",
|
||||
'result': "<div>\n\t<a id=\"foo\" href=\"\">bar</a>\n</div>\n",
|
||||
},
|
||||
{
|
||||
'name': ".content{Hello!}",
|
||||
'query': ".content{Hello!}",
|
||||
'type': "html",
|
||||
'result': "<div class=\"content\">Hello!</div>\n",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'category': 'css',
|
||||
'tests': [
|
||||
{
|
||||
'name': "@i",
|
||||
'query': "@i",
|
||||
'type': "css",
|
||||
'result': "@import url();",
|
||||
},
|
||||
{
|
||||
'name': "fs:n",
|
||||
'query': "fs:n",
|
||||
'type': "css",
|
||||
'result': "font-style: normal;",
|
||||
},
|
||||
{
|
||||
'name': "fl:l|fc",
|
||||
'query': "fl:l|fc",
|
||||
'type': "css",
|
||||
'result': "float: left;",
|
||||
},
|
||||
{
|
||||
'name': "bg+",
|
||||
'query': "bg+",
|
||||
'type': "css",
|
||||
'result': "background: #FFF url() 0 0 no-repeat;",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'category': 'haml',
|
||||
'tests': [
|
||||
{
|
||||
'name': "div>p+ul#foo>li.bar$[foo=bar][bar=baz]*3>{baz}",
|
||||
'query': "div>p+ul#foo>li.bar$[foo=bar][bar=baz]*3>{baz}",
|
||||
'type': "haml",
|
||||
'result': "<div>\n\t<p></p>\n\t<ul id=\"foo\">\n\t\t<li foo=\"bar\" bar=\"baz\" class=\"bar1\">baz</li>\n\t\t<li foo=\"bar\" bar=\"baz\" class=\"bar2\">baz</li>\n\t\t<li foo=\"bar\" bar=\"baz\" class=\"bar3\">baz</li>\n\t</ul>\n</div>\n",
|
||||
},
|
||||
{
|
||||
'name': "div>p+ul#foo>li.bar$[foo=bar][bar=baz]*3>{baz}|haml",
|
||||
'query': "div>p+ul#foo>li.bar$[foo=bar][bar=baz]*3>{baz}|haml",
|
||||
'type': "haml",
|
||||
'result': "%div\n %p\n %ul#foo\n %li.bar1{ :foo => \"bar\", :bar => \"baz\" } baz\n %li.bar2{ :foo => \"bar\", :bar => \"baz\" } baz\n %li.bar3{ :foo => \"bar\", :bar => \"baz\" } baz\n",
|
||||
},
|
||||
{
|
||||
'name': "a*3|haml",
|
||||
'query': "a*3|haml",
|
||||
'type': "haml",
|
||||
'result': "%a{ :href => \"\" }\n%a{ :href => \"\" }\n%a{ :href => \"\" }\n",
|
||||
},
|
||||
{
|
||||
'name': ".content{Hello!}|haml",
|
||||
'query': ".content{Hello!}|haml",
|
||||
'type': "haml",
|
||||
'result': "%div.content Hello!\n",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'category': 'xsl',
|
||||
'tests': [
|
||||
{
|
||||
'name': "vari",
|
||||
'query': "vari",
|
||||
'type': "xsl",
|
||||
'result': "<xsl:variable name=\"\"></xsl:variable>\n",
|
||||
},
|
||||
{
|
||||
'name': "ap>wp",
|
||||
'query': "ap>wp",
|
||||
'type': "xsl",
|
||||
'result': "<xsl:apply-templates select=\"\" mode=\"\">\n\t<xsl:with-param select=\"\" name=\"\"></xsl:with-param>\n</xsl:apply-templates>\n",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'category': 'xsd',
|
||||
'tests': [
|
||||
{
|
||||
'name': "w3c",
|
||||
'query': "xsd:w3c",
|
||||
'type': "xsd",
|
||||
'result': "<?xml version=\"1.0\"?>\n<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n\t<xsd:element name=\"\" type=\"\"/>\n</xsd:schema>",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'category': 'mustache',
|
||||
'tests': [
|
||||
{
|
||||
'name': "div#{{foo}}",
|
||||
'query': "div#{{foo}}",
|
||||
'type': "mustache",
|
||||
'result': "<div id=\"{{foo}}\"></div>\n",
|
||||
},
|
||||
{
|
||||
'name': "div.{{foo}}",
|
||||
'query': "div.{{foo}}",
|
||||
'type': "mustache",
|
||||
'result': "<div class=\"{{foo}}\"></div>\n",
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
" vim:set et:
|
|
@ -1,243 +0,0 @@
|
|||
script_name: ZenCoding.vim
|
||||
script_id: '2981'
|
||||
script_type: utility
|
||||
script_package: zencoding-vim.zip
|
||||
script_version: '0.58'
|
||||
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 zen-coding.
|
||||
ref: http://code.google.com/p/zen-coding/
|
||||
|
||||
There is a movie using zencoding.vim
|
||||
ref: http://mattn.github.com/zencoding-vim
|
||||
|
||||
Source Repository.
|
||||
ref: http://github.com/mattn/zencoding-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/zencoding-vim/raw/master/TUTORIAL
|
||||
|
||||
How work this:
|
||||
|
||||
http://mattn.github.com/zencoding-vim
|
||||
|
||||
Tips:
|
||||
|
||||
You can customize behavior of expanding with overriding config.
|
||||
This configuration will be marged at loading plugin.
|
||||
|
||||
let g:user_zen_settings = {
|
||||
\ 'indentation' : ' ',
|
||||
\ 'perl' : {
|
||||
\ 'aliases' : {
|
||||
\ 'req' : 'require '
|
||||
\ },
|
||||
\ 'snippets' : {
|
||||
\ 'use' : "use strict\nuse warnings\n\n",
|
||||
\ 'warn' : "warn \"|\";",
|
||||
\ }
|
||||
\ }
|
||||
\}
|
||||
|
||||
let g:user_zen_expandabbr_key = '<c-e>'
|
||||
|
||||
let g:use_zen_complete_tag = 1
|
||||
|
||||
You can set language attribute in html using zen_settings['lang'].
|
||||
|
||||
install_details: |
|
||||
|
||||
# cd ~/.vim
|
||||
# unzip zencoding-vim.zip
|
||||
|
||||
or if you install pathogen.vim:
|
||||
|
||||
# cd ~/.vim/bundle # or make directory
|
||||
# unzip /path/to/zencoding-vim.zip
|
||||
|
||||
if you get sources from repository:
|
||||
|
||||
# cd ~/.vim/bundle # or make directory
|
||||
# git clone http://github.com/mattn/zencoding-vim.git
|
||||
|
||||
versions:
|
||||
- '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
|
File diff suppressed because it is too large
Load diff
2
.vim/bundle/Vundle.vim/.gitignore
vendored
2
.vim/bundle/Vundle.vim/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
doc/tags
|
||||
.netrwhist
|
|
@ -1,111 +0,0 @@
|
|||
Pull Requests
|
||||
=============
|
||||
|
||||
1. Please squash your commits to minimize the log pollution. This is more of a convenience for the maintainer who pulls. If you are unfamiliar, see [here](http://ariejan.net/2011/07/05/git-squash-your-latests-commits-into-one/).
|
||||
|
||||
2. Clearly describe what you aim to fix or add to Vundle.
|
||||
|
||||
3. Try to minimize code changes and use existing style/functions.
|
||||
|
||||
Issues
|
||||
======
|
||||
|
||||
## Check For Answers
|
||||
|
||||
Before submitting an issue, be sure to check the following places for answers.
|
||||
|
||||
1. Vundle docs at [`:h vundle`](https://github.com/gmarik/Vundle.vim/blob/master/doc/vundle.txt).
|
||||
|
||||
2. The [FAQ](https://github.com/gmarik/Vundle.vim/search).
|
||||
|
||||
3. [Search](https://github.com/gmarik/Vundle.vim/search) the repository for related issues.
|
||||
|
||||
## Try To Eliminate Your Vimrc
|
||||
|
||||
In order to make sure it isn't just `.vimrc` replace your own config file with the [minimal vimrc](https://github.com/gmarik/Vundle.vim/blob/master/test/minirc.vim). Clear out bundles and then try to reproduce.
|
||||
|
||||
If the problem stops, likely there is an issue in your user configuration. You can incrementally add back your user changes to the minimal file testing the bug each time. This will allow you to slowly bisect the issue. You may want to test one plugin at a time.
|
||||
|
||||
If you can still reproduce the problem, try to find the smallest `.vimrc` config file that creates the problem to include later.
|
||||
|
||||
## Guidelines
|
||||
|
||||
To better respond to issues please follow these general guidelines when explaining the problem.
|
||||
|
||||
1. Clearly describe what the error is, if relevant attach output/screenshots.
|
||||
|
||||
2. Describe how developers can reproduce the bug, the steps should be from starting Vim.
|
||||
|
||||
3. Include your OS, version and architecture. For example, Windows 7 64, Kubuntu 13.04 32, etc...
|
||||
|
||||
4. If relevant to reproducing the bug, include the smallest subset of your `.vimrc` that causes the issue. Put this in code tags.
|
||||
|
||||
5. At the end of your issue, please put the output of `vim --version` in code tags.
|
||||
|
||||
## Example Post
|
||||
|
||||
I am using Vim on Kubuntu 13.04 64 bit and I get the following error... (add further explanation here)
|
||||
|
||||
To reproduce the bug, use the vimrc file below and run `:BundleInstall`... (continue with steps)
|
||||
|
||||
Vimrc:
|
||||
```
|
||||
set nocompatible
|
||||
syntax on
|
||||
filetype off
|
||||
set rtp+=~/.vim/bundle/Vundle.vim/
|
||||
call vundle#rc()
|
||||
Bundle 'gmarik/Vundle.vim'
|
||||
Bundle 'relevant/plugin'
|
||||
filetype plugin indent on
|
||||
|
||||
.... more user configs here...
|
||||
```
|
||||
|
||||
Vim Version:
|
||||
```
|
||||
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Aug 15 2013 10:58:39)
|
||||
Included patches: 1-5
|
||||
Modified by pkg-vim-maintainers@lists.alioth.debian.org
|
||||
Compiled by buildd@
|
||||
Huge version with GTK2 GUI. Features included (+) or not (-):
|
||||
+arabic +file_in_path +mouse_sgr +tag_binary
|
||||
+autocmd +find_in_path -mouse_sysmouse +tag_old_static
|
||||
+balloon_eval +float +mouse_urxvt -tag_any_white
|
||||
+browse +folding +mouse_xterm +tcl
|
||||
++builtin_terms -footer +multi_byte +terminfo
|
||||
+byte_offset +fork() +multi_lang +termresponse
|
||||
+cindent +gettext -mzscheme +textobjects
|
||||
+clientserver -hangul_input +netbeans_intg +title
|
||||
+clipboard +iconv +path_extra +toolbar
|
||||
+cmdline_compl +insert_expand +perl +user_commands
|
||||
+cmdline_hist +jumplist +persistent_undo +vertsplit
|
||||
+cmdline_info +keymap +postscript +virtualedit
|
||||
+comments +langmap +printer +visual
|
||||
+conceal +libcall +profile +visualextra
|
||||
+cryptv +linebreak +python +viminfo
|
||||
+cscope +lispindent -python3 +vreplace
|
||||
+cursorbind +listcmds +quickfix +wildignore
|
||||
+cursorshape +localmap +reltime +wildmenu
|
||||
+dialog_con_gui +lua +rightleft +windows
|
||||
+diff +menu +ruby +writebackup
|
||||
+digraphs +mksession +scrollbind +X11
|
||||
+dnd +modify_fname +signs -xfontset
|
||||
-ebcdic +mouse +smartindent +xim
|
||||
+emacs_tags +mouseshape -sniff +xsmp_interact
|
||||
+eval +mouse_dec +startuptime +xterm_clipboard
|
||||
+ex_extra +mouse_gpm +statusline -xterm_save
|
||||
+extra_search -mouse_jsbterm -sun_workshop
|
||||
+farsi +mouse_netterm +syntax
|
||||
system vimrc file: "$VIM/vimrc"
|
||||
user vimrc file: "$HOME/.vimrc"
|
||||
2nd user vimrc file: "~/.vim/vimrc"
|
||||
user exrc file: "$HOME/.exrc"
|
||||
system gvimrc file: "$VIM/gvimrc"
|
||||
user gvimrc file: "$HOME/.gvimrc"
|
||||
2nd user gvimrc file: "~/.vim/gvimrc"
|
||||
system menu file: "$VIMRUNTIME/menu.vim"
|
||||
fall-back for $VIM: "/usr/share/vim"
|
||||
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK -pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/harfbuzz -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -I/usr/include/tcl8.5 -D_REENTRANT=1 -D_THREAD_SAFE=1 -D_LARGEFILE64_SOURCE=1
|
||||
Linking: gcc -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,--as-needed -o vim -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lglib-2.0 -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE -lm -ltinfo -lnsl -lselinux -lacl -lattr -lgpm -ldl -L/usr/lib -llua5.1 -Wl,-E -fstack-protector -L/usr/local/lib -L/usr/lib/perl/5.14/CORE -lperl -ldl -lm -lpthread -lcrypt -L/usr/lib/python2.7/config-x86_64-linux-gnu -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions -L/usr/lib/x86_64-linux-gnu -ltcl8.5 -ldl -lpthread -lieee -lm -lruby-1.9.1 -lpthread -lrt -ldl -lcrypt -lm -L/usr/lib
|
||||
```
|
|
@ -1,7 +0,0 @@
|
|||
Copyright (C) 2010 http://github.com/gmarik
|
||||
|
||||
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,158 +0,0 @@
|
|||
## [Help Maintain Vundle](https://github.com/gmarik/Vundle.vim/issues/383)
|
||||
|
||||
## About
|
||||
|
||||
[Vundle] is short for _Vim bundle_ and is a [Vim] plugin manager.
|
||||
|
||||
[Vundle] allows you to...
|
||||
|
||||
* keep track of and [configure] your plugins right in the `.vimrc`
|
||||
* [install] configured plugins (a.k.a. scripts/bundle)
|
||||
* [update] configured plugins
|
||||
* [search] by name all available [Vim scripts]
|
||||
* [clean] unused plugins up
|
||||
* run the above actions in a *single keypress* with [interactive mode]
|
||||
|
||||
[Vundle] automatically...
|
||||
|
||||
* manages the [runtime path] of your installed scripts
|
||||
* regenerates [help tags] after installing and updating
|
||||
|
||||
[Vundle] is undergoing an [interface change], please stay up to date to get latest changes.
|
||||
|
||||
[![Gitter-chat](https://badges.gitter.im/gmarik/Vundle.vim.png)](https://gitter.im/gmarik/Vundle.vim) for discussion and support.
|
||||
|
||||
![Vundle-installer](http://i.imgur.com/Rueh7Cc.png)
|
||||
|
||||
## Quick Start
|
||||
|
||||
1. Introduction:
|
||||
|
||||
Installation requires [Git] and triggers [`git clone`] for each configured repository to `~/.vim/bundle/` by default.
|
||||
Curl is required for search.
|
||||
|
||||
If you are using Windows, go directly to [Windows setup]. If you run into any issues, please consult the [FAQ].
|
||||
See [Tips] for some advanced configurations.
|
||||
|
||||
2. Set up [Vundle]:
|
||||
|
||||
`$ git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim`
|
||||
|
||||
3. Configure Plugins:
|
||||
|
||||
Put this at the top of your `.vimrc` to use Vundle. Remove plugins you don't need, they are for illustration purposes.
|
||||
|
||||
```vim
|
||||
set nocompatible " be iMproved, required
|
||||
filetype off " required
|
||||
|
||||
" set the runtime path to include Vundle and initialize
|
||||
set rtp+=~/.vim/bundle/Vundle.vim
|
||||
call vundle#begin()
|
||||
" alternatively, pass a path where Vundle should install plugins
|
||||
"call vundle#begin('~/some/path/here')
|
||||
|
||||
" let Vundle manage Vundle, required
|
||||
Plugin 'gmarik/Vundle.vim'
|
||||
|
||||
" The following are examples of different formats supported.
|
||||
" Keep Plugin commands between vundle#begin/end.
|
||||
" plugin on GitHub repo
|
||||
Plugin 'tpope/vim-fugitive'
|
||||
" plugin from http://vim-scripts.org/vim/scripts.html
|
||||
Plugin 'L9'
|
||||
" Git plugin not hosted on GitHub
|
||||
Plugin 'git://git.wincent.com/command-t.git'
|
||||
" git repos on your local machine (i.e. when working on your own plugin)
|
||||
Plugin 'file:///home/gmarik/path/to/plugin'
|
||||
" The sparkup vim script is in a subdirectory of this repo called vim.
|
||||
" Pass the path to set the runtimepath properly.
|
||||
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
|
||||
" Avoid a name conflict with L9
|
||||
Plugin 'user/L9', {'name': 'newL9'}
|
||||
|
||||
" All of your Plugins must be added before the following line
|
||||
call vundle#end() " required
|
||||
filetype plugin indent on " required
|
||||
" To ignore plugin indent changes, instead use:
|
||||
"filetype plugin on
|
||||
"
|
||||
" Brief help
|
||||
" :PluginList - lists configured plugins
|
||||
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
|
||||
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
|
||||
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
|
||||
"
|
||||
" see :h vundle for more details or wiki for FAQ
|
||||
" Put your non-Plugin stuff after this line
|
||||
```
|
||||
|
||||
4. Install Plugins:
|
||||
|
||||
Launch `vim` and run `:PluginInstall`
|
||||
|
||||
To install from command line: `vim +PluginInstall +qall`
|
||||
|
||||
## Docs
|
||||
|
||||
See the [`:h vundle`](https://github.com/gmarik/Vundle.vim/blob/master/doc/vundle.txt) Vimdoc for more details.
|
||||
|
||||
## Changelog
|
||||
|
||||
See the [changelog](https://github.com/gmarik/Vundle.vim/blob/master/changelog.md).
|
||||
|
||||
## People Using Vundle
|
||||
|
||||
see [Examples](https://github.com/gmarik/Vundle.vim/wiki/Examples)
|
||||
|
||||
## Contributors
|
||||
|
||||
see [Vundle contributors](https://github.com/gmarik/Vundle.vim/graphs/contributors)
|
||||
|
||||
*Thank you!*
|
||||
|
||||
## Inspiration & Ideas
|
||||
|
||||
* [pathogen.vim](http://github.com/tpope/vim-pathogen/)
|
||||
* [Bundler](https://github.com/bundler/bundler)
|
||||
* [Scott Bronson](http://github.com/bronson)
|
||||
|
||||
## Also
|
||||
|
||||
* Vundle was developed and tested with [Vim] 7.3 on OS X, Linux and Windows
|
||||
* Vundle tries to be as [KISS](http://en.wikipedia.org/wiki/KISS_principle) as possible
|
||||
|
||||
## TODO:
|
||||
[Vundle] is a work in progress, so any ideas and patches are appreciated.
|
||||
|
||||
* ✓ activate newly added bundles on `.vimrc` reload or after `:PluginInstall`
|
||||
* ✓ use preview window for search results
|
||||
* ✓ Vim documentation
|
||||
* ✓ put Vundle in `bundles/` too (will fix Vundle help)
|
||||
* ✓ tests
|
||||
* ✓ improve error handling
|
||||
* allow specifying revision/version?
|
||||
* handle dependencies
|
||||
* show description in search results
|
||||
* search by description as well
|
||||
* make it rock!
|
||||
|
||||
[Vundle]:http://github.com/gmarik/Vundle.vim
|
||||
[Windows setup]:https://github.com/gmarik/Vundle.vim/wiki/Vundle-for-Windows
|
||||
[FAQ]:https://github.com/gmarik/Vundle.vim/wiki
|
||||
[Tips]:https://github.com/gmarik/Vundle.vim/wiki/Tips-and-Tricks
|
||||
[Vim]:http://www.vim.org
|
||||
[Git]:http://git-scm.com
|
||||
[`git clone`]:http://gitref.org/creating/#clone
|
||||
|
||||
[Vim scripts]:http://vim-scripts.org/vim/scripts.html
|
||||
[help tags]:http://vimdoc.sourceforge.net/htmldoc/helphelp.html#:helptags
|
||||
[runtime path]:http://vimdoc.sourceforge.net/htmldoc/options.html#%27runtimepath%27
|
||||
|
||||
[configure]:https://github.com/gmarik/Vundle.vim/blob/v0.10.2/doc/vundle.txt#L126-L233
|
||||
[install]:https://github.com/gmarik/Vundle.vim/blob/v0.10.2/doc/vundle.txt#L234-L254
|
||||
[update]:https://github.com/gmarik/Vundle.vim/blob/v0.10.2/doc/vundle.txt#L255-L265
|
||||
[search]:https://github.com/gmarik/Vundle.vim/blob/v0.10.2/doc/vundle.txt#L266-L295
|
||||
[clean]:https://github.com/gmarik/Vundle.vim/blob/v0.10.2/doc/vundle.txt#L303-L318
|
||||
[interactive mode]:https://github.com/gmarik/Vundle.vim/blob/v0.10.2/doc/vundle.txt#L319-L360
|
||||
[interface change]:https://github.com/gmarik/Vundle.vim/blob/v0.10.2/doc/vundle.txt#L372-L396
|
|
@ -1,83 +0,0 @@
|
|||
" Vundle is a shortcut for Vim Bundle and Is a simple plugin manager for Vim
|
||||
" Author: gmarik
|
||||
" HomePage: http://github.com/gmarik/Vundle.vim
|
||||
" Readme: http://github.com/gmarik/Vundle.vim/blob/master/README.md
|
||||
" Version: 0.10.2
|
||||
|
||||
" Plugin Commands
|
||||
com! -nargs=+ -bar Plugin
|
||||
\ call vundle#config#bundle(<args>)
|
||||
|
||||
com! -nargs=? -bang -complete=custom,vundle#scripts#complete PluginInstall
|
||||
\ call vundle#installer#new('!' == '<bang>', <q-args>)
|
||||
|
||||
com! -nargs=? -bang -complete=custom,vundle#scripts#complete PluginSearch
|
||||
\ call vundle#scripts#all('!' == '<bang>', <q-args>)
|
||||
|
||||
com! -nargs=0 -bang PluginList
|
||||
\ call vundle#installer#list('!' == '<bang>')
|
||||
|
||||
com! -nargs=? -bang PluginClean
|
||||
\ call vundle#installer#clean('!' == '<bang>')
|
||||
|
||||
com! -nargs=0 PluginDocs
|
||||
\ call vundle#installer#helptags(g:bundles)
|
||||
|
||||
" Aliases
|
||||
com! PluginUpdate PluginInstall!
|
||||
|
||||
" Vundle Aliases
|
||||
com! -nargs=? -bang -complete=custom,vundle#scripts#complete VundleInstall PluginInstall<bang> <args>
|
||||
com! -nargs=? -bang -complete=custom,vundle#scripts#complete VundleSearch PluginSearch<bang> <args>
|
||||
com! -nargs=? -bang VundleClean PluginClean<bang>
|
||||
com! -nargs=0 VundleDocs PluginDocs
|
||||
com! VundleUpdate PluginInstall!
|
||||
|
||||
" Deprecated Commands
|
||||
com! -nargs=+ Bundle call vundle#config#bundle(<args>)
|
||||
com! -nargs=? -bang -complete=custom,vundle#scripts#complete BundleInstall PluginInstall<bang> <args>
|
||||
com! -nargs=? -bang -complete=custom,vundle#scripts#complete BundleSearch PluginSearch<bang> <args>
|
||||
com! -nargs=0 -bang BundleList PluginList<bang>
|
||||
com! -nargs=? -bang BundleClean PluginClean<bang>
|
||||
com! -nargs=0 BundleDocs PluginDocs
|
||||
com! BundleUpdate PluginInstall!
|
||||
|
||||
" Set up the signs used in the installer window. (See :help signs)
|
||||
if (has('signs'))
|
||||
sign define Vu_error text=! texthl=Error
|
||||
sign define Vu_active text=> texthl=Comment
|
||||
sign define Vu_todate text=. texthl=Comment
|
||||
sign define Vu_new text=+ texthl=Comment
|
||||
sign define Vu_updated text=* texthl=Comment
|
||||
sign define Vu_deleted text=- texthl=Comment
|
||||
sign define Vu_helptags text=* texthl=Comment
|
||||
sign define Vu_pinned text== texthl=Comment
|
||||
endif
|
||||
|
||||
" Set up Vundle. This function has to be called from the users vimrc file.
|
||||
" This will force Vim to source this file as a side effect which wil define
|
||||
" the :Plugin command. After calling this function the user can use the
|
||||
" :Plugin command in the vimrc. It is not possible to do this automatically
|
||||
" because when loading the vimrc file no plugins where loaded yet.
|
||||
func! vundle#rc(...) abort
|
||||
let g:bundle_dir = len(a:000) > 0 ? expand(a:1, 1) : expand('$HOME/.vim/bundle', 1)
|
||||
let g:updated_bundles = []
|
||||
let g:vundle_log = []
|
||||
let g:vundle_changelog = ['Updated Plugins:']
|
||||
call vundle#config#init()
|
||||
endf
|
||||
|
||||
" Alternative to vundle#rc, offers speed up by modifying rtp only when end()
|
||||
" called later.
|
||||
func! vundle#begin(...) abort
|
||||
let g:vundle_lazy_load = 1
|
||||
call call('vundle#rc', a:000)
|
||||
endf
|
||||
|
||||
" Finishes putting plugins on the rtp.
|
||||
func! vundle#end(...) abort
|
||||
unlet g:vundle_lazy_load
|
||||
call vundle#config#activate_bundles()
|
||||
endf
|
||||
|
||||
" vim: set expandtab sts=2 ts=2 sw=2 tw=78 norl:
|
|
@ -1,278 +0,0 @@
|
|||
" ---------------------------------------------------------------------------
|
||||
" Add a plugin to the runtimepath.
|
||||
"
|
||||
" arg -- a string specifying the plugin
|
||||
" ... -- a dictionary of options for the plugin
|
||||
" return -- the return value from vundle#config#init_bundle()
|
||||
" ---------------------------------------------------------------------------
|
||||
func! vundle#config#bundle(arg, ...)
|
||||
let bundle = vundle#config#init_bundle(a:arg, a:000)
|
||||
if !s:check_bundle_name(bundle)
|
||||
return
|
||||
endif
|
||||
if exists('g:vundle_lazy_load') && g:vundle_lazy_load
|
||||
call add(g:bundles, bundle)
|
||||
else
|
||||
call s:rtp_rm_a()
|
||||
call add(g:bundles, bundle)
|
||||
call s:rtp_add_a()
|
||||
call s:rtp_add_defaults()
|
||||
endif
|
||||
return bundle
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" When lazy bundle load is used (begin/end functions), add all configured
|
||||
" bundles to runtimepath and reorder appropriately.
|
||||
" ---------------------------------------------------------------------------
|
||||
func! vundle#config#activate_bundles()
|
||||
call s:rtp_add_a()
|
||||
call s:rtp_add_defaults()
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" Initialize Vundle.
|
||||
"
|
||||
" Start a new bundles list and make sure the runtimepath does not contain
|
||||
" directories from a previous call. In theory, this should only be called
|
||||
" once.
|
||||
" ---------------------------------------------------------------------------
|
||||
func! vundle#config#init()
|
||||
if !exists('g:bundles') | let g:bundles = [] | endif
|
||||
call s:rtp_rm_a()
|
||||
let g:bundles = []
|
||||
let g:bundle_names = {}
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" Add a list of bundles to the runtimepath and source them.
|
||||
"
|
||||
" bundles -- a list of bundle objects
|
||||
" ---------------------------------------------------------------------------
|
||||
func! vundle#config#require(bundles) abort
|
||||
for b in a:bundles
|
||||
call s:rtp_add(b.rtpath)
|
||||
call s:rtp_add(g:bundle_dir)
|
||||
" TODO: it has to be relative rtpath, not bundle.name
|
||||
exec 'runtime! '.b.name.'/plugin/*.vim'
|
||||
exec 'runtime! '.b.name.'/after/*.vim'
|
||||
call s:rtp_rm(g:bundle_dir)
|
||||
endfor
|
||||
call s:rtp_add_defaults()
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" Create a bundle object from a bundle specification.
|
||||
"
|
||||
" name -- the bundle specification as a string
|
||||
" opts -- the options dictionary from then bundle definition
|
||||
" return -- an initialized bundle object
|
||||
" ---------------------------------------------------------------------------
|
||||
func! vundle#config#init_bundle(name, opts)
|
||||
if a:name != substitute(a:name, '^\s*\(.\{-}\)\s*$', '\1', '')
|
||||
echo "Spurious leading and/or trailing whitespace found in plugin spec '" . a:name . "'"
|
||||
endif
|
||||
let opts = extend(s:parse_options(a:opts), s:parse_name(substitute(a:name,"['".'"]\+','','g')), 'keep')
|
||||
let b = extend(opts, copy(s:bundle))
|
||||
let b.rtpath = s:rtpath(opts)
|
||||
return b
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" Check if the current bundle name has already been used in this running
|
||||
" instance and show an error to that effect.
|
||||
"
|
||||
" bundle -- a bundle object whose name is to be checked
|
||||
" return -- 0 if the bundle's name has been seen before, 1 otherwise
|
||||
" ---------------------------------------------------------------------------
|
||||
funct! s:check_bundle_name(bundle)
|
||||
if has_key(g:bundle_names, a:bundle.name)
|
||||
echoerr 'Vundle error: Name collision for Plugin ' . a:bundle.name_spec .
|
||||
\ '. Plugin ' . g:bundle_names[a:bundle.name] .
|
||||
\ ' previously used the name "' . a:bundle.name . '"' .
|
||||
\ '. Skipping Plugin ' . a:bundle.name_spec . '.'
|
||||
return 0
|
||||
endif
|
||||
let g:bundle_names[a:bundle.name] = a:bundle.name_spec
|
||||
return 1
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" Parse the options which can be supplied with the bundle specification.
|
||||
" Corresponding documentation: vundle-plugins-configure
|
||||
"
|
||||
" opts -- a dictionary with the user supplied options for the bundle
|
||||
" return -- a dictionary with the user supplied options for the bundle, this
|
||||
" will be merged with a s:bundle object into one dictionary.
|
||||
" ---------------------------------------------------------------------------
|
||||
func! s:parse_options(opts)
|
||||
" TODO: improve this
|
||||
if len(a:opts) != 1 | return {} | endif
|
||||
|
||||
if type(a:opts[0]) == type({})
|
||||
return a:opts[0]
|
||||
else
|
||||
return {'rev': a:opts[0]}
|
||||
endif
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" Parse the plugin specification. Corresponding documentation:
|
||||
" vundle-plugins-uris
|
||||
"
|
||||
" arg -- the string supplied to identify the plugin
|
||||
" return -- a dictionary with the folder name (key 'name') and the uri (key
|
||||
" 'uri') for cloning the plugin and the original argument (key
|
||||
" 'name_spec')
|
||||
" ---------------------------------------------------------------------------
|
||||
func! s:parse_name(arg)
|
||||
let arg = a:arg
|
||||
let git_proto = exists('g:vundle_default_git_proto') ? g:vundle_default_git_proto : 'https'
|
||||
|
||||
if arg =~? '^\s*\(gh\|github\):\S\+'
|
||||
\ || arg =~? '^[a-z0-9][a-z0-9-]*/[^/]\+$'
|
||||
let uri = git_proto.'://github.com/'.split(arg, ':')[-1]
|
||||
if uri !~? '\.git$'
|
||||
let uri .= '.git'
|
||||
endif
|
||||
let name = substitute(split(uri,'\/')[-1], '\.git\s*$','','i')
|
||||
elseif arg =~? '^\s*\(git@\|git://\)\S\+'
|
||||
\ || arg =~? '\(file\|https\?\)://'
|
||||
\ || arg =~? '\.git\s*$'
|
||||
let uri = arg
|
||||
let name = split( substitute(uri,'/\?\.git\s*$','','i') ,'\/')[-1]
|
||||
else
|
||||
let name = arg
|
||||
let uri = git_proto.'://github.com/vim-scripts/'.name.'.git'
|
||||
endif
|
||||
return {'name': name, 'uri': uri, 'name_spec': arg }
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" Modify the runtimepath, after all bundles have been added, so that the
|
||||
" directories that were in the default runtimepath appear first in the list
|
||||
" (with their 'after' directories last).
|
||||
" ---------------------------------------------------------------------------
|
||||
func! s:rtp_add_defaults()
|
||||
let current = &rtp
|
||||
set rtp&vim
|
||||
let default = &rtp
|
||||
let &rtp = current
|
||||
let default_rtp_items = split(default, ',')
|
||||
if !empty(default_rtp_items)
|
||||
let first_item = fnameescape(default_rtp_items[0])
|
||||
exec 'set rtp-=' . first_item
|
||||
exec 'set rtp^=' . first_item
|
||||
endif
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" Remove all paths for the plugins which are managed by Vundle from the
|
||||
" runtimepath.
|
||||
" ---------------------------------------------------------------------------
|
||||
func! s:rtp_rm_a()
|
||||
let paths = map(copy(g:bundles), 'v:val.rtpath')
|
||||
let prepends = join(paths, ',')
|
||||
let appends = join(paths, '/after,').'/after'
|
||||
exec 'set rtp-='.fnameescape(prepends)
|
||||
exec 'set rtp-='.fnameescape(appends)
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" Add all paths for the plugins which are managed by Vundle to the
|
||||
" runtimepath.
|
||||
" ---------------------------------------------------------------------------
|
||||
func! s:rtp_add_a()
|
||||
let paths = map(copy(g:bundles), 'v:val.rtpath')
|
||||
let prepends = join(paths, ',')
|
||||
let appends = join(paths, '/after,').'/after'
|
||||
exec 'set rtp^='.fnameescape(prepends)
|
||||
exec 'set rtp+='.fnameescape(appends)
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" Remove a directory and the corresponding 'after' directory from runtimepath.
|
||||
"
|
||||
" dir -- the directory name to be removed as a string. The corresponding
|
||||
" 'after' directory will also be removed.
|
||||
" ---------------------------------------------------------------------------
|
||||
func! s:rtp_rm(dir) abort
|
||||
exec 'set rtp-='.fnameescape(expand(a:dir, 1))
|
||||
exec 'set rtp-='.fnameescape(expand(a:dir.'/after', 1))
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" Add a directory and the corresponding 'after' directory to runtimepath.
|
||||
"
|
||||
" dir -- the directory name to be added as a string. The corresponding
|
||||
" 'after' directory will also be added.
|
||||
" ---------------------------------------------------------------------------
|
||||
func! s:rtp_add(dir) abort
|
||||
exec 'set rtp^='.fnameescape(expand(a:dir, 1))
|
||||
exec 'set rtp+='.fnameescape(expand(a:dir.'/after', 1))
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" Expand and simplify a path.
|
||||
"
|
||||
" path -- the path to expand as a string
|
||||
" return -- the expanded and simplified path
|
||||
" ---------------------------------------------------------------------------
|
||||
func! s:expand_path(path) abort
|
||||
return simplify(expand(a:path, 1))
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" Find the actual path inside a bundle directory to be added to the
|
||||
" runtimepath. It might be provided by the user with the 'rtp' option.
|
||||
" Corresponding documentation: vundle-plugins-configure
|
||||
"
|
||||
" opts -- a bundle dict
|
||||
" return -- expanded path to the corresponding plugin directory
|
||||
" ---------------------------------------------------------------------------
|
||||
func! s:rtpath(opts)
|
||||
return has_key(a:opts, 'rtp') ? s:expand_path(a:opts.path().'/'.a:opts.rtp) : a:opts.path()
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" a bundle 'object'
|
||||
" ---------------------------------------------------------------------------
|
||||
let s:bundle = {}
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" Return the absolute path to the directory inside the bundle directory
|
||||
" (prefix) where thr bundle will be cloned.
|
||||
"
|
||||
" return -- the target location to clone this bundle to
|
||||
" ---------------------------------------------------------------------------
|
||||
func! s:bundle.path()
|
||||
return s:expand_path(g:bundle_dir.'/'.self.name)
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" Determine if the bundle has the pinned attribute set in the config
|
||||
"
|
||||
" return -- 1 if the bundle is pinned, 0 otherwise
|
||||
" ---------------------------------------------------------------------------
|
||||
func! s:bundle.is_pinned()
|
||||
return get(self, 'pinned')
|
||||
endf
|
||||
|
||||
" vim: set expandtab sts=2 ts=2 sw=2 tw=78 norl:
|
|
@ -1,534 +0,0 @@
|
|||
" ---------------------------------------------------------------------------
|
||||
" Try to clone all new bundles given (or all bundles in g:bundles by default)
|
||||
" to g:bundle_dir. If a:bang is 1 it will also update all plugins (git pull).
|
||||
"
|
||||
" bang -- 1 or 0
|
||||
" ... -- any number of bundle specifications (separate arguments)
|
||||
" ---------------------------------------------------------------------------
|
||||
func! vundle#installer#new(bang, ...) abort
|
||||
let bundles = (a:1 == '') ?
|
||||
\ g:bundles :
|
||||
\ map(copy(a:000), 'vundle#config#bundle(v:val, {})')
|
||||
|
||||
let names = vundle#scripts#bundle_names(map(copy(bundles), 'v:val.name_spec'))
|
||||
call vundle#scripts#view('Installer',['" Installing plugins to '.expand(g:bundle_dir, 1)], names + ['Helptags'])
|
||||
|
||||
" This calls 'add' as a normal mode command. This is a buffer local mapping
|
||||
" defined in vundle#scripts#view(). The mapping will call a buffer local
|
||||
" command InstallPlugin which in turn will call vundle#installer#run() with
|
||||
" vundle#installer#install().
|
||||
call s:process(a:bang, (a:bang ? 'add!' : 'add'))
|
||||
|
||||
call vundle#config#require(bundles)
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" Iterate over all lines in a Vundle window and execute the given command for
|
||||
" every line. Used by the installation and cleaning functions.
|
||||
"
|
||||
" bang -- not used (FIXME)
|
||||
" cmd -- the (normal mode) command to execute for every line as a string
|
||||
" ---------------------------------------------------------------------------
|
||||
func! s:process(bang, cmd)
|
||||
let msg = ''
|
||||
|
||||
redraw
|
||||
sleep 1m
|
||||
|
||||
let lines = (getline('.','$')[0:-2])
|
||||
|
||||
for line in lines
|
||||
redraw
|
||||
|
||||
exec ':norm '.a:cmd
|
||||
|
||||
if 'error' == g:vundle_last_status
|
||||
let msg = 'With errors; press l to view log'
|
||||
endif
|
||||
|
||||
if 'updated' == g:vundle_last_status && empty(msg)
|
||||
let msg = 'Plugins updated; press u to view changelog'
|
||||
endif
|
||||
|
||||
" goto next one
|
||||
exec ':+1'
|
||||
|
||||
setl nomodified
|
||||
endfor
|
||||
|
||||
redraw
|
||||
echo 'Done! '.msg
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" Call another function in the different Vundle windows.
|
||||
"
|
||||
" func_name -- the function to call
|
||||
" name -- the bundle name to call func_name for (string)
|
||||
" ... -- the argument to be used when calling func_name (only the first
|
||||
" optional argument will be used)
|
||||
" return -- the status returned by the call to func_name
|
||||
" ---------------------------------------------------------------------------
|
||||
func! vundle#installer#run(func_name, name, ...) abort
|
||||
let n = a:name
|
||||
|
||||
echo 'Processing '.n
|
||||
call s:sign('active')
|
||||
|
||||
sleep 1m
|
||||
|
||||
let status = call(a:func_name, a:1)
|
||||
|
||||
call s:sign(status)
|
||||
|
||||
redraw
|
||||
|
||||
if 'new' == status
|
||||
echo n.' installed'
|
||||
elseif 'updated' == status
|
||||
echo n.' updated'
|
||||
elseif 'todate' == status
|
||||
echo n.' already installed'
|
||||
elseif 'deleted' == status
|
||||
echo n.' deleted'
|
||||
elseif 'helptags' == status
|
||||
echo n.' regenerated'
|
||||
elseif 'pinned' == status
|
||||
echo n.' pinned'
|
||||
elseif 'error' == status
|
||||
echohl Error
|
||||
echo 'Error processing '.n
|
||||
echohl None
|
||||
sleep 1
|
||||
else
|
||||
throw 'whoops, unknown status:'.status
|
||||
endif
|
||||
|
||||
let g:vundle_last_status = status
|
||||
|
||||
return status
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" Put a sign on the current line, indicating the status of the installation
|
||||
" step.
|
||||
"
|
||||
" status -- string describing the status
|
||||
" ---------------------------------------------------------------------------
|
||||
func! s:sign(status)
|
||||
if (!has('signs'))
|
||||
return
|
||||
endif
|
||||
|
||||
exe ":sign place ".line('.')." line=".line('.')." name=Vu_". a:status ." buffer=" . bufnr("%")
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" Install a plugin, then add it to the runtimepath and source it.
|
||||
"
|
||||
" bang -- 1 or 0, passed directly to vundle#installer#install()
|
||||
" name -- the name of a bundle (string)
|
||||
" return -- the return value from vundle#installer#install()
|
||||
" ---------------------------------------------------------------------------
|
||||
func! vundle#installer#install_and_require(bang, name) abort
|
||||
let result = vundle#installer#install(a:bang, a:name)
|
||||
let b = vundle#config#bundle(a:name, {})
|
||||
call vundle#installer#helptags([b])
|
||||
call vundle#config#require([b])
|
||||
return result
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" Install or update a bundle given by its name.
|
||||
"
|
||||
" bang -- 1 or 0, passed directly to s:sync()
|
||||
" name -- the name of a bundle (string)
|
||||
" return -- the return value from s:sync()
|
||||
" ---------------------------------------------------------------------------
|
||||
func! vundle#installer#install(bang, name) abort
|
||||
if !isdirectory(g:bundle_dir) | call mkdir(g:bundle_dir, 'p') | endif
|
||||
|
||||
let n = substitute(a:name,"['".'"]\+','','g')
|
||||
let matched = filter(copy(g:bundles), 'v:val.name_spec == n')
|
||||
|
||||
if len(matched) > 0
|
||||
let b = matched[0]
|
||||
else
|
||||
let b = vundle#config#init_bundle(a:name, {})
|
||||
endif
|
||||
|
||||
return s:sync(a:bang, b)
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" Call :helptags for all bundles in g:bundles.
|
||||
"
|
||||
" return -- 'error' if an error occurred, else return 'helptags'
|
||||
" ---------------------------------------------------------------------------
|
||||
func! vundle#installer#docs() abort
|
||||
let error_count = vundle#installer#helptags(g:bundles)
|
||||
if error_count > 0
|
||||
return 'error'
|
||||
endif
|
||||
return 'helptags'
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" Call :helptags for a list of bundles.
|
||||
"
|
||||
" bundles -- a list of bundle dictionaries for which :helptags should be
|
||||
" called.
|
||||
" return -- the number of directories where :helptags failed
|
||||
" ---------------------------------------------------------------------------
|
||||
func! vundle#installer#helptags(bundles) abort
|
||||
let bundle_dirs = map(copy(a:bundles),'v:val.rtpath')
|
||||
let help_dirs = filter(bundle_dirs, 's:has_doc(v:val)')
|
||||
|
||||
call s:log('')
|
||||
call s:log('Helptags:')
|
||||
|
||||
let statuses = map(copy(help_dirs), 's:helptags(v:val)')
|
||||
let errors = filter(statuses, 'v:val == 0')
|
||||
|
||||
call s:log('Helptags: '.len(help_dirs).' plugins processed')
|
||||
|
||||
return len(errors)
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" List all installed plugins.
|
||||
" Corresponding documentation: vundle-plugins-list
|
||||
"
|
||||
" bang -- not used
|
||||
" ---------------------------------------------------------------------------
|
||||
func! vundle#installer#list(bang) abort
|
||||
let bundles = vundle#scripts#bundle_names(map(copy(g:bundles), 'v:val.name_spec'))
|
||||
call vundle#scripts#view('list', ['" My Plugins'], bundles)
|
||||
redraw
|
||||
echo len(g:bundles).' plugins configured'
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" List and remove all directories in the bundle directory which are not
|
||||
" activated (added to the bundle list).
|
||||
"
|
||||
" bang -- 0 if the user should be asked to confirm every deletion, 1 if they
|
||||
" should be removed unconditionally
|
||||
" ---------------------------------------------------------------------------
|
||||
func! vundle#installer#clean(bang) abort
|
||||
let bundle_dirs = map(copy(g:bundles), 'v:val.path()')
|
||||
let all_dirs = (v:version > 702 || (v:version == 702 && has("patch51")))
|
||||
\ ? split(globpath(g:bundle_dir, '*', 1), "\n")
|
||||
\ : split(globpath(g:bundle_dir, '*'), "\n")
|
||||
let x_dirs = filter(all_dirs, '0 > index(bundle_dirs, v:val)')
|
||||
|
||||
if empty(x_dirs)
|
||||
let headers = ['" All clean!']
|
||||
let names = []
|
||||
else
|
||||
let headers = ['" Removing Plugins:']
|
||||
let names = vundle#scripts#bundle_names(map(copy(x_dirs), 'fnamemodify(v:val, ":t")'))
|
||||
end
|
||||
|
||||
call vundle#scripts#view('clean', headers, names)
|
||||
redraw
|
||||
|
||||
if (a:bang || empty(names))
|
||||
call s:process(a:bang, 'D')
|
||||
else
|
||||
call inputsave()
|
||||
let response = input('Continue? [Y/n]: ')
|
||||
call inputrestore()
|
||||
if (response =~? 'y' || response == '')
|
||||
call s:process(a:bang, 'D')
|
||||
endif
|
||||
endif
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" Delete to directory for a plugin.
|
||||
"
|
||||
" bang -- not used
|
||||
" dir_name -- the bundle directory to be deleted (as a string)
|
||||
" return -- 'error' if an error occurred, 'deleted' if the plugin folder was
|
||||
" successfully deleted
|
||||
" ---------------------------------------------------------------------------
|
||||
func! vundle#installer#delete(bang, dir_name) abort
|
||||
|
||||
let cmd = ((has('win32') || has('win64')) && empty(matchstr(&shell, 'sh'))) ?
|
||||
\ 'rmdir /S /Q' :
|
||||
\ 'rm -rf'
|
||||
|
||||
let bundle = vundle#config#init_bundle(a:dir_name, {})
|
||||
let cmd .= ' '.vundle#installer#shellesc(bundle.path())
|
||||
|
||||
let out = s:system(cmd)
|
||||
|
||||
call s:log('')
|
||||
call s:log('Plugin '.a:dir_name)
|
||||
call s:log(cmd, '$ ')
|
||||
call s:log(out, '> ')
|
||||
|
||||
if 0 != v:shell_error
|
||||
return 'error'
|
||||
else
|
||||
return 'deleted'
|
||||
endif
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" Check if a bundled plugin has any documentation.
|
||||
"
|
||||
" rtp -- a path (string) where the plugin is installed
|
||||
" return -- 1 if some documentation was found, 0 otherwise
|
||||
" ---------------------------------------------------------------------------
|
||||
func! s:has_doc(rtp) abort
|
||||
return isdirectory(a:rtp.'/doc')
|
||||
\ && (!filereadable(a:rtp.'/doc/tags') || filewritable(a:rtp.'/doc/tags'))
|
||||
\ && (v:version > 702 || (v:version == 702 && has("patch51")))
|
||||
\ ? !(empty(glob(a:rtp.'/doc/*.txt', 1)) && empty(glob(a:rtp.'/doc/*.??x', 1)))
|
||||
\ : !(empty(glob(a:rtp.'/doc/*.txt')) && empty(glob(a:rtp.'/doc/*.??x')))
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" Update the helptags for a plugin.
|
||||
"
|
||||
" rtp -- the path to the plugin's root directory (string)
|
||||
" return -- 1 if :helptags succeeded, 0 otherwise
|
||||
" ---------------------------------------------------------------------------
|
||||
func! s:helptags(rtp) abort
|
||||
" it is important to keep trailing slash here
|
||||
let doc_path = resolve(a:rtp . '/doc/')
|
||||
call s:log(':helptags '.doc_path)
|
||||
try
|
||||
execute 'helptags ' . doc_path
|
||||
catch
|
||||
call s:log("> Error running :helptags ".doc_path)
|
||||
return 0
|
||||
endtry
|
||||
return 1
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" Get the URL for the remote called 'origin' on the repository that
|
||||
" corresponds to a given bundle.
|
||||
"
|
||||
" bundle -- a bundle object to check the repository for
|
||||
" return -- the URL for the origin remote (string)
|
||||
" ---------------------------------------------------------------------------
|
||||
func! s:get_current_origin_url(bundle) abort
|
||||
let cmd = 'cd '.vundle#installer#shellesc(a:bundle.path()).' && git config --get remote.origin.url'
|
||||
let cmd = vundle#installer#shellesc_cd(cmd)
|
||||
let out = s:strip(s:system(cmd))
|
||||
return out
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" Get a short sha of the HEAD of the repository for a given bundle
|
||||
"
|
||||
" bundle -- a bundle object
|
||||
" return -- A 15 character log sha for the current HEAD
|
||||
" ---------------------------------------------------------------------------
|
||||
func! s:get_current_sha(bundle)
|
||||
let cmd = 'cd '.vundle#installer#shellesc(a:bundle.path()).' && git rev-parse HEAD'
|
||||
let cmd = vundle#installer#shellesc_cd(cmd)
|
||||
let out = s:system(cmd)[0:15]
|
||||
return out
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" Create the appropriate sync command to run according to the current state of
|
||||
" the local repository (clone, pull, reset, etc).
|
||||
"
|
||||
" In the case of a pull (update), also return the current sha, so that we can
|
||||
" later check that there has been an upgrade.
|
||||
"
|
||||
" bang -- 0 if only new plugins should be installed, 1 if existing plugins
|
||||
" should be updated
|
||||
" bundle -- a bundle object to create the sync command for
|
||||
" return -- A list containing the command to run and the sha for the current
|
||||
" HEAD
|
||||
" ---------------------------------------------------------------------------
|
||||
func! s:make_sync_command(bang, bundle) abort
|
||||
let git_dir = expand(a:bundle.path().'/.git/', 1)
|
||||
if isdirectory(git_dir) || filereadable(expand(a:bundle.path().'/.git', 1))
|
||||
|
||||
let current_origin_url = s:get_current_origin_url(a:bundle)
|
||||
if current_origin_url != a:bundle.uri
|
||||
call s:log('Plugin URI change detected for Plugin ' . a:bundle.name)
|
||||
call s:log('> Plugin ' . a:bundle.name . ' old URI: ' . current_origin_url)
|
||||
call s:log('> Plugin ' . a:bundle.name . ' new URI: ' . a:bundle.uri)
|
||||
" Directory names match but the origin remotes are not the same
|
||||
let cmd_parts = [
|
||||
\ 'cd '.vundle#installer#shellesc(a:bundle.path()) ,
|
||||
\ 'git remote set-url origin ' . vundle#installer#shellesc(a:bundle.uri),
|
||||
\ 'git fetch',
|
||||
\ 'git reset --hard origin/HEAD',
|
||||
\ 'git submodule update --init --recursive',
|
||||
\ ]
|
||||
let cmd = join(cmd_parts, ' && ')
|
||||
let cmd = vundle#installer#shellesc_cd(cmd)
|
||||
let initial_sha = ''
|
||||
return [cmd, initial_sha]
|
||||
endif
|
||||
|
||||
if !(a:bang)
|
||||
" The repo exists, and no !, so leave as it is.
|
||||
return ['', '']
|
||||
endif
|
||||
|
||||
let cmd_parts = [
|
||||
\ 'cd '.vundle#installer#shellesc(a:bundle.path()),
|
||||
\ 'git pull',
|
||||
\ 'git submodule update --init --recursive',
|
||||
\ ]
|
||||
let cmd = join(cmd_parts, ' && ')
|
||||
let cmd = vundle#installer#shellesc_cd(cmd)
|
||||
|
||||
let initial_sha = s:get_current_sha(a:bundle)
|
||||
else
|
||||
let cmd = 'git clone --recursive '.vundle#installer#shellesc(a:bundle.uri).' '.vundle#installer#shellesc(a:bundle.path())
|
||||
let initial_sha = ''
|
||||
endif
|
||||
return [cmd, initial_sha]
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" Install or update a given bundle object with git.
|
||||
"
|
||||
" bang -- 0 if only new plugins should be installed, 1 if existing plugins
|
||||
" should be updated
|
||||
" bundle -- a bundle object (dictionary)
|
||||
" return -- a string indicating the status of the bundle installation:
|
||||
" - todate : Nothing was updated or the repository was up to date
|
||||
" - new : The plugin was newly installed
|
||||
" - updated : Some changes where pulled via git
|
||||
" - error : An error occurred in the shell command
|
||||
" - pinned : The bundle is marked as pinned
|
||||
" ---------------------------------------------------------------------------
|
||||
func! s:sync(bang, bundle) abort
|
||||
" Do not sync if this bundle is pinned
|
||||
if a:bundle.is_pinned()
|
||||
return 'pinned'
|
||||
endif
|
||||
|
||||
let [ cmd, initial_sha ] = s:make_sync_command(a:bang, a:bundle)
|
||||
if empty(cmd)
|
||||
return 'todate'
|
||||
endif
|
||||
|
||||
let out = s:system(cmd)
|
||||
call s:log('')
|
||||
call s:log('Plugin '.a:bundle.name_spec)
|
||||
call s:log(cmd, '$ ')
|
||||
call s:log(out, '> ')
|
||||
|
||||
if 0 != v:shell_error
|
||||
return 'error'
|
||||
end
|
||||
|
||||
if empty(initial_sha)
|
||||
return 'new'
|
||||
endif
|
||||
|
||||
let updated_sha = s:get_current_sha(a:bundle)
|
||||
|
||||
if initial_sha == updated_sha
|
||||
return 'todate'
|
||||
endif
|
||||
|
||||
call add(g:updated_bundles, [initial_sha, updated_sha, a:bundle])
|
||||
return 'updated'
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" Escape special characters in a string to be able to use it as a shell
|
||||
" command with system().
|
||||
"
|
||||
" cmd -- the string holding the shell command
|
||||
" return -- a string with the relevant characters escaped
|
||||
" ---------------------------------------------------------------------------
|
||||
func! vundle#installer#shellesc(cmd) abort
|
||||
if ((has('win32') || has('win64')) && empty(matchstr(&shell, 'sh')))
|
||||
return '"' . substitute(a:cmd, '"', '\\"', 'g') . '"'
|
||||
endif
|
||||
return shellescape(a:cmd)
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" Fix a cd shell command to be used on Windows.
|
||||
"
|
||||
" cmd -- the command to be fixed (string)
|
||||
" return -- the fixed command (string)
|
||||
" ---------------------------------------------------------------------------
|
||||
func! vundle#installer#shellesc_cd(cmd) abort
|
||||
if ((has('win32') || has('win64')) && empty(matchstr(&shell, 'sh')))
|
||||
let cmd = substitute(a:cmd, '^cd ','cd /d ','') " add /d switch to change drives
|
||||
return cmd
|
||||
else
|
||||
return a:cmd
|
||||
endif
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" Make a system call. This can be used to change the way system calls
|
||||
" are made during developing, without searching the whole code base for
|
||||
" actual system() calls.
|
||||
"
|
||||
" cmd -- the command passed to system() (string)
|
||||
" return -- the return value from system()
|
||||
" ---------------------------------------------------------------------------
|
||||
func! s:system(cmd) abort
|
||||
return system(a:cmd)
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" Add a log message to Vundle's internal logging variable.
|
||||
"
|
||||
" str -- the log message (string)
|
||||
" prefix -- optional prefix for multi-line entries (string)
|
||||
" return -- a:str
|
||||
" ---------------------------------------------------------------------------
|
||||
func! s:log(str, ...) abort
|
||||
let prefix = a:0 > 0 ? a:1 : ''
|
||||
let fmt = '%Y-%m-%d %H:%M:%S'
|
||||
let lines = split(a:str, '\n', 1)
|
||||
let time = strftime(fmt)
|
||||
for line in lines
|
||||
call add(g:vundle_log, '['. time .'] '. prefix . line)
|
||||
endfor
|
||||
return a:str
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" Remove leading and trailing whitespace from a string
|
||||
"
|
||||
" str -- The string to rid of trailing and leading spaces
|
||||
" return -- A string stripped of side spaces
|
||||
" ---------------------------------------------------------------------------
|
||||
func! s:strip(str)
|
||||
return substitute(a:str, '\%^\_s*\(.\{-}\)\_s*\%$', '\1', '')
|
||||
endf
|
||||
|
||||
" vim: set expandtab sts=2 ts=2 sw=2 tw=78 norl:
|
|
@ -1,257 +0,0 @@
|
|||
" ---------------------------------------------------------------------------
|
||||
" Search the database from vim-script.org for a matching plugin. If no
|
||||
" argument is given, list all plugins. This function is used by the :Plugins
|
||||
" and :PluginSearch commands.
|
||||
"
|
||||
" bang -- if 1 refresh the script name cache, if 0 don't
|
||||
" ... -- a plugin name to search for
|
||||
" ---------------------------------------------------------------------------
|
||||
func! vundle#scripts#all(bang, ...)
|
||||
let b:match = ''
|
||||
let info = ['"Keymap: i - Install plugin; c - Cleanup; s - Search; R - Reload list']
|
||||
let matches = s:load_scripts(a:bang)
|
||||
if !empty(a:1)
|
||||
let matches = filter(matches, 'v:val =~? "'.escape(a:1,'"').'"')
|
||||
let info += ['"Search results for: '.a:1]
|
||||
" TODO: highlight matches
|
||||
let b:match = a:1
|
||||
endif
|
||||
call vundle#scripts#view('search',info, vundle#scripts#bundle_names(reverse(matches)))
|
||||
redraw
|
||||
echo len(matches).' plugins found'
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" Repeat the search for bundles.
|
||||
" ---------------------------------------------------------------------------
|
||||
func! vundle#scripts#reload() abort
|
||||
silent exec ':PluginSearch! '.(exists('b:match') ? b:match : '')
|
||||
redraw
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" Complete names for bundles in the command line.
|
||||
"
|
||||
" a, c, d -- see :h command-completion-custom
|
||||
" return -- all valid plugin names from vim-scripts.org as completion
|
||||
" candidates, see also :h command-completion-custom
|
||||
" ---------------------------------------------------------------------------
|
||||
func! vundle#scripts#complete(a,c,d)
|
||||
return join(s:load_scripts(0),"\n")
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" View the logfile after an update or installation.
|
||||
" ---------------------------------------------------------------------------
|
||||
func! s:view_log()
|
||||
if !exists('g:vundle_log_file')
|
||||
let g:vundle_log_file = tempname()
|
||||
endif
|
||||
|
||||
call writefile(g:vundle_log, g:vundle_log_file)
|
||||
execute 'silent pedit ' . g:vundle_log_file
|
||||
|
||||
wincmd P | wincmd H
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" Parse the output from git log after an update to create a change log for the
|
||||
" user.
|
||||
" ---------------------------------------------------------------------------
|
||||
func! s:create_changelog() abort
|
||||
for bundle_data in g:updated_bundles
|
||||
let initial_sha = bundle_data[0]
|
||||
let updated_sha = bundle_data[1]
|
||||
let bundle = bundle_data[2]
|
||||
|
||||
let cmd = 'cd '.vundle#installer#shellesc(bundle.path()).
|
||||
\ ' && git log --pretty=format:"%s %an, %ar" --graph '.
|
||||
\ initial_sha.'..'.updated_sha
|
||||
|
||||
let cmd = vundle#installer#shellesc_cd(cmd)
|
||||
|
||||
let updates = system(cmd)
|
||||
|
||||
call add(g:vundle_changelog, '')
|
||||
call add(g:vundle_changelog, 'Updated Plugin: '.bundle.name)
|
||||
|
||||
if bundle.uri =~ "https://github.com"
|
||||
call add(g:vundle_changelog, 'Compare at: '.bundle.uri[0:-5].'/compare/'.initial_sha.'...'.updated_sha)
|
||||
endif
|
||||
|
||||
for update in split(updates, '\n')
|
||||
let update = substitute(update, '\s\+$', '', '')
|
||||
call add(g:vundle_changelog, ' '.update)
|
||||
endfor
|
||||
endfor
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" View the change log after an update or installation.
|
||||
" ---------------------------------------------------------------------------
|
||||
func! s:view_changelog()
|
||||
call s:create_changelog()
|
||||
|
||||
if !exists('g:vundle_changelog_file')
|
||||
let g:vundle_changelog_file = tempname()
|
||||
endif
|
||||
|
||||
call writefile(g:vundle_changelog, g:vundle_changelog_file)
|
||||
execute 'silent pedit ' . g:vundle_changelog_file
|
||||
|
||||
wincmd P | wincmd H
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" Create a list of 'Plugin ...' lines from a list of bundle names.
|
||||
"
|
||||
" names -- a list of names (strings) of plugins
|
||||
" return -- a list of 'Plugin ...' lines suitable to be written to a buffer
|
||||
" ---------------------------------------------------------------------------
|
||||
func! vundle#scripts#bundle_names(names)
|
||||
return map(copy(a:names), ' printf("Plugin ' ."'%s'".'", v:val) ')
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" Open a buffer to display information to the user. Several special commands
|
||||
" are defined in the new buffer.
|
||||
"
|
||||
" title -- a title for the new buffer
|
||||
" headers -- a list of header lines to be displayed at the top of the buffer
|
||||
" results -- the main information to be displayed in the buffer (list of
|
||||
" strings)
|
||||
" ---------------------------------------------------------------------------
|
||||
func! vundle#scripts#view(title, headers, results)
|
||||
if exists('g:vundle_view') && bufloaded(g:vundle_view)
|
||||
exec g:vundle_view.'bd!'
|
||||
endif
|
||||
|
||||
exec 'silent pedit [Vundle] '.a:title
|
||||
|
||||
wincmd P | wincmd H
|
||||
|
||||
let g:vundle_view = bufnr('%')
|
||||
"
|
||||
" make buffer modifiable
|
||||
" to append without errors
|
||||
set modifiable
|
||||
|
||||
call append(0, a:headers + a:results)
|
||||
|
||||
setl buftype=nofile
|
||||
setl noswapfile
|
||||
|
||||
setl cursorline
|
||||
setl nonu ro noma
|
||||
if (exists('&relativenumber')) | setl norelativenumber | endif
|
||||
|
||||
setl ft=vundle
|
||||
setl syntax=vim
|
||||
syn keyword vimCommand Plugin
|
||||
syn keyword vimCommand Bundle
|
||||
syn keyword vimCommand Helptags
|
||||
|
||||
com! -buffer -bang -nargs=1 DeletePlugin
|
||||
\ call vundle#installer#run('vundle#installer#delete', split(<q-args>,',')[0], ['!' == '<bang>', <args>])
|
||||
|
||||
com! -buffer -bang -nargs=? InstallAndRequirePlugin
|
||||
\ call vundle#installer#run('vundle#installer#install_and_require', split(<q-args>,',')[0], ['!' == '<bang>', <q-args>])
|
||||
|
||||
com! -buffer -bang -nargs=? InstallPlugin
|
||||
\ call vundle#installer#run('vundle#installer#install', split(<q-args>,',')[0], ['!' == '<bang>', <q-args>])
|
||||
|
||||
com! -buffer -bang -nargs=0 InstallHelptags
|
||||
\ call vundle#installer#run('vundle#installer#docs', 'helptags', [])
|
||||
|
||||
com! -buffer -nargs=0 VundleLog call s:view_log()
|
||||
|
||||
com! -buffer -nargs=0 VundleChangelog call s:view_changelog()
|
||||
|
||||
nnoremap <buffer> q :silent bd!<CR>
|
||||
nnoremap <buffer> D :exec 'Delete'.getline('.')<CR>
|
||||
|
||||
nnoremap <buffer> add :exec 'Install'.getline('.')<CR>
|
||||
nnoremap <buffer> add! :exec 'Install'.substitute(getline('.'), '^Plugin ', 'Plugin! ', '')<CR>
|
||||
|
||||
nnoremap <buffer> i :exec 'InstallAndRequire'.getline('.')<CR>
|
||||
nnoremap <buffer> I :exec 'InstallAndRequire'.substitute(getline('.'), '^Plugin ', 'Plugin! ', '')<CR>
|
||||
|
||||
nnoremap <buffer> l :VundleLog<CR>
|
||||
nnoremap <buffer> u :VundleChangelog<CR>
|
||||
nnoremap <buffer> h :h vundle<CR>
|
||||
nnoremap <buffer> ? :norm h<CR>
|
||||
|
||||
nnoremap <buffer> c :PluginClean<CR>
|
||||
nnoremap <buffer> C :PluginClean!<CR>
|
||||
|
||||
nnoremap <buffer> s :PluginSearch
|
||||
nnoremap <buffer> R :call vundle#scripts#reload()<CR>
|
||||
|
||||
" goto first line after headers
|
||||
exec ':'.(len(a:headers) + 1)
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" Load the plugin database from vim-scripts.org .
|
||||
"
|
||||
" to -- the filename (string) to save the database to
|
||||
" return -- 0 on success, 1 if an error occurred
|
||||
" ---------------------------------------------------------------------------
|
||||
func! s:fetch_scripts(to)
|
||||
let scripts_dir = fnamemodify(expand(a:to, 1), ":h")
|
||||
if !isdirectory(scripts_dir)
|
||||
call mkdir(scripts_dir, "p")
|
||||
endif
|
||||
|
||||
let l:vim_scripts_json = 'http://vim-scripts.org/api/scripts.json'
|
||||
if executable("curl")
|
||||
let cmd = 'curl --fail -s -o '.vundle#installer#shellesc(a:to).' '.l:vim_scripts_json
|
||||
elseif executable("wget")
|
||||
let temp = vundle#installer#shellesc(tempname())
|
||||
let cmd = 'wget -q -O '.temp.' '.l:vim_scripts_json. ' && mv -f '.temp.' '.vundle#installer#shellesc(a:to)
|
||||
if (has('win32') || has('win64'))
|
||||
let cmd = substitute(cmd, 'mv -f ', 'move /Y ', '') " change force flag
|
||||
let cmd = vundle#installer#shellesc(cmd)
|
||||
end
|
||||
else
|
||||
echoerr 'Error curl or wget is not available!'
|
||||
return 1
|
||||
endif
|
||||
|
||||
call system(cmd)
|
||||
|
||||
if (0 != v:shell_error)
|
||||
echoerr 'Error fetching scripts!'
|
||||
return v:shell_error
|
||||
endif
|
||||
return 0
|
||||
endf
|
||||
|
||||
|
||||
" ---------------------------------------------------------------------------
|
||||
" Load the plugin database and return a list of all plugins.
|
||||
"
|
||||
" bang -- if 1 download the redatabase, else only download if it is not
|
||||
" readable on disk (i.e. does not exist)
|
||||
" return -- a list of strings, these are the names (valid bundle
|
||||
" specifications) of all plugins from vim-scripts.org
|
||||
" ---------------------------------------------------------------------------
|
||||
func! s:load_scripts(bang)
|
||||
let f = expand(g:bundle_dir.'/.vundle/script-names.vim-scripts.org.json', 1)
|
||||
if a:bang || !filereadable(f)
|
||||
if 0 != s:fetch_scripts(f)
|
||||
return []
|
||||
end
|
||||
endif
|
||||
return eval(readfile(f, 'b')[0])
|
||||
endf
|
||||
|
||||
" vim: set expandtab sts=2 ts=2 sw=2 tw=78 norl:
|
|
@ -1,22 +0,0 @@
|
|||
Change Log
|
||||
==========
|
||||
F = Feature, B = Bug Fix, D = Doc Change
|
||||
|
||||
### Version 0.10.2
|
||||
|
||||
- B: #430 Put user script directories before system directories in rtp
|
||||
- B: #455 Rename functions that start with `g:` + lowercase letter (Vim patch 7.4.264)
|
||||
|
||||
### Version 0.10.1
|
||||
- B: #451 Escape spaces when handling rtp directories
|
||||
|
||||
### Version 0.10
|
||||
- F: #415 Support plugin pinning (for non-git repos & preventing updates)
|
||||
- F: #440 Detect plugin name collisions
|
||||
- F: #418 Deferred rtp manipulation (speeds up start)
|
||||
- B: #418 Leave default rtp directories (i.e. ~/.vim) where they should be
|
||||
- B: #429 Fix newline character in log
|
||||
- B: #440 Detect changed remotes & update repos
|
||||
- D: #435 Image update in README.md
|
||||
- D: #419 Add function documentation
|
||||
- D: #436 Rename vundle to Vundle.vim, add modelines, quickstart update
|
|
@ -1,397 +0,0 @@
|
|||
*vundle.txt* Vundle, a plug-in manager for Vim. *vundle*
|
||||
|
||||
VUNDLE MANUAL
|
||||
|
||||
1. About Vundle |vundle-about|
|
||||
2. Quick Start |vundle-quickstart|
|
||||
3. Plugins |vundle-plugins|
|
||||
3.1. Configuring Plugins |vundle-plugins-configure|
|
||||
3.2. Supported URIs |vundle-plugins-uris|
|
||||
3.3. Installing Plugins |vundle-plugins-install|
|
||||
3.4. Updating Plugins |vundle-plugins-update|
|
||||
3.5. Searching Plugins |vundle-plugins-search|
|
||||
3.6. Listing Plugins |vundle-plugins-list|
|
||||
3.7. Cleaning Up |vundle-plugins-cleanup|
|
||||
4. Interactive Mode |vundle-interactive|
|
||||
5. Key Mappings |vundle-keymappings|
|
||||
6. Options |vundle-options|
|
||||
7. Plugin Interface Change |vundle-interface-change|
|
||||
|
||||
=============================================================================
|
||||
1. ABOUT VUNDLE ~
|
||||
*vundle-about*
|
||||
|
||||
Vundle is short for Vim bundle and is a Vim plugin manager.
|
||||
|
||||
Vundle allows you to...
|
||||
|
||||
- keep track of and configure your scripts right in the `.vimrc`
|
||||
- install configured scripts (a.k.a. bundle)
|
||||
- update configured scripts
|
||||
- search by name all available Vim scripts
|
||||
- clean unused scripts up
|
||||
- run the above actions in a single keypress with interactive mode
|
||||
|
||||
Vundle automatically...
|
||||
|
||||
- manages the runtime path of your installed scripts
|
||||
- regenerates help tags after installing and updating
|
||||
|
||||
Vundle's search uses http://vim-scripts.org to provide a list of all
|
||||
available Vim scripts.
|
||||
|
||||
Vundle is undergoing an interface change, see |vundle-interface-change| for
|
||||
more information.
|
||||
|
||||
=============================================================================
|
||||
2. QUICK START ~
|
||||
*vundle-quickstart*
|
||||
|
||||
1. Introduction:
|
||||
|
||||
Installation requires `Git` and triggers git clone for each configured
|
||||
repository to `~/.vim/bundle/` by default. Curl is required for search.
|
||||
|
||||
*vundle-windows*
|
||||
If you are using Windows, see instructions on the Wiki
|
||||
https://github.com/gmarik/Vundle.vim/wiki/Vundle-for-Windows.
|
||||
|
||||
*vundle-faq*
|
||||
If you run into any issues, please consult the FAQ at
|
||||
https://github.com/gmarik/Vundle.vim/wiki
|
||||
|
||||
2. Setup Vundle:
|
||||
>
|
||||
git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim
|
||||
<
|
||||
3. Configure bundles:
|
||||
|
||||
Put this at the top of your `.vimrc` to use Vundle. Remove bundles you
|
||||
don't need, they are for illustration purposes.
|
||||
>
|
||||
set nocompatible " be iMproved, required
|
||||
filetype off " required
|
||||
|
||||
" set the runtime path to include Vundle and initialize
|
||||
set rtp+=~/.vim/bundle/Vundle.vim
|
||||
call vundle#begin()
|
||||
" alternatively, pass a path where Vundle should install plugins
|
||||
"call vundle#begin('~/some/path/here')
|
||||
|
||||
" let Vundle manage Vundle, required
|
||||
Plugin 'gmarik/Vundle.vim'
|
||||
|
||||
" The following are examples of different formats supported.
|
||||
" Keep Plugin commands between vundle#begin/end.
|
||||
" plugin on GitHub repo
|
||||
Plugin 'tpope/vim-fugitive'
|
||||
" plugin from http://vim-scripts.org/vim/scripts.html
|
||||
Plugin 'L9'
|
||||
" Git plugin not hosted on GitHub
|
||||
Plugin 'git://git.wincent.com/command-t.git'
|
||||
" git repos on your local machine (i.e. when working on your own plugin)
|
||||
Plugin 'file:///home/gmarik/path/to/plugin'
|
||||
" The sparkup vim script is in a subdirectory of this repo called vim.
|
||||
" Pass the path to set the runtimepath properly.
|
||||
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
|
||||
" Avoid a name conflict with L9
|
||||
Plugin 'user/L9', {'name': 'newL9'}
|
||||
|
||||
" All of your Plugins must be added before the following line
|
||||
call vundle#end() " required
|
||||
filetype plugin indent on " required
|
||||
" To ignore plugin indent changes, instead use:
|
||||
"filetype plugin on
|
||||
"
|
||||
" Brief help
|
||||
" :PluginList - list configured plugins
|
||||
" :PluginInstall(!) - install (update) plugins
|
||||
" :PluginSearch(!) foo - search (or refresh cache first) for foo
|
||||
" :PluginClean(!) - confirm (or auto-approve) removal of unused plugins
|
||||
"
|
||||
" see :h vundle for more details or wiki for FAQ
|
||||
" Put your non-Plugin stuff after this line
|
||||
|
||||
4. Install configured bundles:
|
||||
|
||||
Launch vim and run
|
||||
>
|
||||
:PluginInstall
|
||||
<
|
||||
To install from command line:
|
||||
>
|
||||
vim +PluginInstall +qall
|
||||
|
||||
=============================================================================
|
||||
3. PLUGINS ~
|
||||
*vundle-plugins*
|
||||
|
||||
3.1 CONFIGURING PLUGINS ~
|
||||
*vundle-plugins-configure* *:Plugin*
|
||||
|
||||
Vundle tracks what plugins you want configured by the `Plugin` commands in your
|
||||
`.vimrc`. Each `Plugin` command tells Vundle to activate the script on startup
|
||||
adding it to your |runtimepath|. Commenting out or removing the line will
|
||||
disable the `Plugin`.
|
||||
|
||||
Each `Plugin` command takes a URI pointing to the script. No comments should
|
||||
follow on the same line as the command. Example:
|
||||
>
|
||||
Plugin 'git_URI'
|
||||
|
||||
The `Plugin` command can optionally take a second argument after the URI. It
|
||||
has to be a dictionary, separated from the URI by a comma. Each key-value pair
|
||||
in the dictionary is a configuration option.
|
||||
|
||||
The following per-script configuration options are available.
|
||||
|
||||
The 'rtp' option
|
||||
----------------
|
||||
|
||||
Specifies a directory inside the repository (relative path from the root of
|
||||
the repository) where the vim plugin resides. It determines the path that will
|
||||
be added to the |runtimepath|.
|
||||
|
||||
For example:
|
||||
>
|
||||
Plugin 'git_URI', {'rtp': 'some/subdir/'}
|
||||
|
||||
This can be used with git repositories that put the vim plugin inside a
|
||||
subdirectory.
|
||||
|
||||
The 'name' option
|
||||
-----------------
|
||||
|
||||
The name of the directory that will hold the local clone of the configured
|
||||
script.
|
||||
|
||||
For example:
|
||||
>
|
||||
Plugin 'git_URI', {'name': 'newPluginName'}
|
||||
|
||||
This can be used to prevent name collisions between plugins that Vundle would
|
||||
otherwise try to clone into the same directory. It also provides an additional
|
||||
level of customisation.
|
||||
|
||||
The 'pinned' option
|
||||
-------------------
|
||||
|
||||
A flag that, when set to a value of 1, tells Vundle not to perform any git
|
||||
operations on the plugin, while still adding the existing plugin under the
|
||||
`bundles` directories to the |runtimepath|.
|
||||
|
||||
For example:
|
||||
>
|
||||
Plugin 'mylocalplugin', {'pinned': 1}
|
||||
|
||||
This allows the users to include, with Vundle, plugins tracked with version
|
||||
control systems other than git, but the user is responsible for cloning and
|
||||
keeping up to date. It also allows the users to stay in the current version of
|
||||
a plugin that might have previously been updated by Vundle.
|
||||
|
||||
Please note that the URI will be treated the same as for any other plugins, so
|
||||
only the last part of it will be added to the |runtimepath|. The user is
|
||||
advised to use this flag only with single word URIs to avoid confusion.
|
||||
|
||||
3.2 SUPPORTED URIS ~
|
||||
*vundle-plugins-uris*
|
||||
|
||||
`Vundle` integrates very well with both GitHub and vim-scripts.org
|
||||
(http://vim-scripts.org/vim/scripts.html) allowing short URIs. It also allows
|
||||
the use of any URI `git` recognizes. In all of the following cases (except
|
||||
local) the 'https' protocol is used, see Vundle's options to override this.
|
||||
|
||||
More information on `git`'s protocols can be found at:
|
||||
http://git-scm.com/book/ch4-1.html
|
||||
|
||||
GitHub
|
||||
------
|
||||
GitHub is used when a user/repo is passed to `Plugin`.
|
||||
>
|
||||
Plugin 'gmarik/Vundle.vim' => https://github.com/gmarik/Vundle.vim
|
||||
|
||||
Vim Scripts
|
||||
-----------
|
||||
Any single word without a slash '/' is assumed to be from Vim Scripts.
|
||||
>
|
||||
Plugin 'ctrlp.vim' => https://github.com/vim-scripts/ctrlp.vim
|
||||
|
||||
Other Git URIs
|
||||
--------------
|
||||
No modification is performed on valid URIs that point outside the above
|
||||
URLs.
|
||||
>
|
||||
Plugin 'git://git.wincent.com/command-t.git'
|
||||
|
||||
Local Plugins
|
||||
-------------
|
||||
The git protocol supports local installation using the 'file://' protocol.
|
||||
This is handy when developing plugins locally. Follow the protocol with an
|
||||
absolute path to the script directory.
|
||||
>
|
||||
Plugin 'file:///path/from/root/to/plugin'
|
||||
|
||||
3.3 INSTALLING PLUGINS ~
|
||||
*vundle-plugins-install* *:PluginInstall*
|
||||
>
|
||||
:PluginInstall
|
||||
|
||||
Will install all plugins configured in your `.vimrc`. Newly installed
|
||||
plugins will be automatically enabled. Some plugins may require extra steps
|
||||
such as compilation or external programs, refer to their documentation.
|
||||
|
||||
PluginInstall allows installation of plugins by name:
|
||||
>
|
||||
:PluginInstall unite.vim
|
||||
|
||||
Installs and activates unite.vim. You can use Tab to auto-complete known
|
||||
script names. Note that the installation just described isn't permanent. To
|
||||
finish, you must put `Plugin 'unite.vim'` at the appropriate place in your
|
||||
`.vimrc` to tell Vundle to load the plugin at startup.
|
||||
|
||||
After installing plugins press 'l' (lowercase 'L') to see the log of commands
|
||||
if any errors occurred.
|
||||
|
||||
3.4 UPDATING PLUGINS ~
|
||||
*vundle-plugins-update* *:PluginUpdate* *:PluginInstall!*
|
||||
>
|
||||
:PluginInstall! " NOTE: bang(!)
|
||||
or >
|
||||
:PluginUpdate
|
||||
|
||||
Installs or updates the configured plugins. Press 'u' after updates complete
|
||||
to see the change log of all updated bundles. Press 'l' (lowercase 'L') to
|
||||
see the log of commands if any errors occurred.
|
||||
|
||||
3.5 SEARCHING PLUGINS ~
|
||||
*vundle-plugins-search* *:PluginSearch*
|
||||
>
|
||||
:PluginSearch
|
||||
|
||||
Search requires that `curl` be available on the system. The command searches
|
||||
Vim Scripts (http://vim-scripts.org/vim/scripts.html) for matching
|
||||
plugins. Results display in a new split window. For example:
|
||||
>
|
||||
PluginSearch foo
|
||||
|
||||
displays:
|
||||
>
|
||||
"Search results for: foo
|
||||
Plugin 'MarkdownFootnotes'
|
||||
Plugin 'VimFootnotes'
|
||||
Plugin 'foo.vim'
|
||||
<
|
||||
*:PluginSearch!*
|
||||
Alternatively, you can refresh the script list before searching by adding a
|
||||
bang to the command.
|
||||
>
|
||||
:PluginSearch! foo
|
||||
|
||||
If the command is run without argument:
|
||||
>
|
||||
:PluginSearch!
|
||||
|
||||
it will display all known plugins in the new split.
|
||||
|
||||
3.6 LISTING BUNDLES ~
|
||||
*vundle-plugins-list* *:PluginList*
|
||||
>
|
||||
:PluginList
|
||||
|
||||
Displays a list of installed bundles.
|
||||
|
||||
3.7 CLEANING UP ~
|
||||
*vundle-plugins-cleanup* *:PluginClean*
|
||||
>
|
||||
:PluginClean
|
||||
|
||||
Requests confirmation for the removal of all plugins no longered configured
|
||||
in your `.vimrc` but present in your bundle installation directory
|
||||
(default: `.vim/bundle/`).
|
||||
|
||||
*:PluginClean!*
|
||||
>
|
||||
:PluginClean!
|
||||
|
||||
Automatically confirm removal of unused bundles.
|
||||
|
||||
=============================================================================
|
||||
4. INTERACTIVE MODE ~
|
||||
*vundle-interactive*
|
||||
|
||||
Vundle provides a simple interactive mode to help you explore new plugins
|
||||
easily. Interactive mode is available after any command that lists `Plugins`
|
||||
such as PluginSearch, PluginList or Plugins. For instance:
|
||||
>
|
||||
:PluginSearch! unite
|
||||
|
||||
Searches for plugins matching 'unite' and yields a split window with:
|
||||
>
|
||||
"Keymap: i - Install bundle; c - Cleanup; s - Search; R - Reload list
|
||||
"Search results for: unite
|
||||
Plugin 'unite-scriptenames'
|
||||
Plugin 'unite.vim'
|
||||
Plugin 'unite-yarm'
|
||||
Plugin 'unite-gem'
|
||||
Plugin 'unite-locate'
|
||||
Plugin 'unite-font'
|
||||
Plugin 'unite-colorscheme'
|
||||
|
||||
To install a bundle, move your cursor to the Plugin of interest and then
|
||||
select a command. To install 'unite.vim' put your cursor on the line and
|
||||
then push `i`. For a more complete list see |vundle-keymappings|. After
|
||||
unite.vim is installed the `:Unite file` command should be available.
|
||||
|
||||
Note: Interactive installation doesn't update your `.vimrc`.
|
||||
|
||||
=============================================================================
|
||||
5. KEY MAPPINGS ~
|
||||
*vundle-keymappings*
|
||||
|
||||
KEY | DESCRIPTION
|
||||
----|-------------------------- >
|
||||
i | run :PluginInstall with name taken from line cursor is positioned on
|
||||
I | same as i, but runs :PluginInstall! to update bundle
|
||||
D | delete selected bundle (be careful not to remove local modifications)
|
||||
c | run :PluginClean
|
||||
s | run :PluginSearch
|
||||
R | fetch fresh script list from server
|
||||
|
||||
=============================================================================
|
||||
6. OPTIONS ~
|
||||
*vundle-options*
|
||||
>
|
||||
let g:vundle_default_git_proto = 'git'
|
||||
<
|
||||
This option makes Vundle use `git` instead of `https` when building
|
||||
absolute URIs. For example:
|
||||
>
|
||||
Plugin 'sjl/gundo.vim' -> git@github.com:sjl/gundo.git
|
||||
|
||||
=============================================================================
|
||||
7. VUNDLE INTERFACE CHANGE ~
|
||||
*vundle-interface-change* *:Bundle* *:BundleInstall!*
|
||||
*:BundleUpdate* *:BundleSearch* *:BundleList* *:BundleClean!*
|
||||
*:VundleInstall!* *:VundleUpdate* *:VundleSearch*
|
||||
*:VundleList* *:VundleClean!*
|
||||
|
||||
In order to bring in new changes, Vundle is adopting a new interface.
|
||||
Going forward we will support primarily the Plugin namespace, additionally
|
||||
for convenience we will also alias some commands to the Vundle namespace.
|
||||
The following table summarizes the interface changes.
|
||||
|
||||
Deprecated Names | New Names
|
||||
-----------------------------
|
||||
Bundle | Plugin
|
||||
BundleInstall(!) | PluginInstall(!), VundleInstall(!)
|
||||
BundleUpdate | PluginUpdate, VundleUpdate
|
||||
BundleSearch(!) | PluginSearch(!), VundleSearch(!)
|
||||
BundleClean | PluginClean(!), VundleClean(!)
|
||||
BundleList | PluginList
|
||||
|
||||
Note: The Bundle commands will be deprecated. You may continue using them,
|
||||
but they may not get all future updates. For instance, we have enabled
|
||||
comments on Plugin lines but not Bundle, since it requires a change in
|
||||
command declaration.
|
||||
|
||||
" vim: set expandtab sts=2 ts=2 sw=2 tw=78 ft=help norl:
|
|
@ -1,20 +0,0 @@
|
|||
-module(mmc_logmon_sup).
|
||||
-behaviour(supervisor).
|
||||
-export([init/1]).
|
||||
|
||||
init(_) ->
|
||||
{ok, {
|
||||
{one_for_one, 5, 1},
|
||||
[
|
||||
{listener,
|
||||
{aaa, start_link, []},
|
||||
permanent, 100, worker,
|
||||
[aaa]
|
||||
},
|
||||
{server,
|
||||
{bbb, start_link, []},
|
||||
permanent, 100, worker,
|
||||
[bbb]
|
||||
}
|
||||
]
|
||||
}}.
|
|
@ -1,8 +0,0 @@
|
|||
set nocompatible
|
||||
syntax on
|
||||
filetype off
|
||||
set rtp+=~/.vim/bundle/Vundle.vim/
|
||||
call vundle#rc()
|
||||
Bundle 'gmarik/Vundle.vim'
|
||||
filetype plugin indent on
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
" vim -u test/vimrc
|
||||
set nocompatible
|
||||
|
||||
set nowrap
|
||||
|
||||
let bundle_dir = '/tmp/vundle-test/bundles/'
|
||||
" let src = 'http://github.com/gmarik/vundle.git'
|
||||
|
||||
" Vundle Options
|
||||
" let g:vundle_default_git_proto = 'git'
|
||||
|
||||
silent execute '!mkdir -p '.bundle_dir
|
||||
silent execute '!ln -f -s ~/.vim/bundle/Vundle.vim '.bundle_dir
|
||||
|
||||
filetype off
|
||||
syntax on
|
||||
|
||||
runtime macros/matchit.vim
|
||||
|
||||
" This test should be executed in "test" directory
|
||||
exec 'set rtp^='.bundle_dir.'Vundle.vim/'
|
||||
|
||||
call vundle#rc(bundle_dir)
|
||||
|
||||
|
||||
Plugin 'molokai' " vim-scripts name
|
||||
|
||||
" github username with dashes
|
||||
Bundle 'vim-scripts/ragtag.vim'
|
||||
|
||||
" original repo
|
||||
Bundle 'altercation/vim-colors-solarized'
|
||||
" with extension
|
||||
Bundle 'nelstrom/vim-mac-classic-theme.git'
|
||||
"
|
||||
" invalid uri
|
||||
"Bundle 'nonexistinguser/yupppierepo.git'
|
||||
|
||||
" full uri
|
||||
Bundle 'https://github.com/vim-scripts/vim-game-of-life'
|
||||
" full uri
|
||||
Bundle 'git@github.com:gmarik/ingretu.git'
|
||||
" short uri
|
||||
Bundle 'gh:gmarik/snipmate.vim.git'
|
||||
Bundle 'github:mattn/gist-vim.git'
|
||||
|
||||
" local uri stuff
|
||||
Bundle '~/Dropbox/.gitrepos/utilz.vim.git'
|
||||
" Bundle 'file://Dropbox/.gitrepos/utilz.vim.git'
|
||||
|
||||
" with options
|
||||
Bundle 'rstacruz/sparkup.git', {'rtp': 'vim/'}
|
||||
Bundle 'matchit.zip', {'name': 'matchit'}
|
||||
|
||||
" Camel case
|
||||
Bundle 'vim-scripts/RubySinatra'
|
||||
|
||||
" syntax issue #203
|
||||
Bundle 'jimenezrick/vimerl'
|
||||
|
||||
" Static bundle: Same name as a valid vim-scripts bundle
|
||||
Bundle 'latte', {'pinned' : 1}
|
||||
if !isdirectory(expand(bundle_dir) . '/latte')
|
||||
call mkdir(expand(bundle_dir) . '/latte', 'p')
|
||||
endif
|
||||
|
||||
|
||||
filetype plugin indent on " Automatically detect file types.
|
||||
|
||||
set wildignore+=doc " should not break helptags
|
||||
set wildignore+=.git " should not break clone
|
||||
set wildignore+=.git/* " should not break clone
|
||||
set wildignore+=*/.git/*
|
||||
" TODO: helptags fails with this
|
||||
" set wildignore+=doc/* " should not break clone
|
||||
" set wildignore+=*/doc/*
|
||||
|
||||
au VimEnter * BundleInstall
|
||||
|
||||
" e test/files/erlang.erl
|
||||
" vim: set expandtab sts=2 ts=2 sw=2 tw=78:
|
1
.vim/bundle/ack.vim/.gitignore
vendored
1
.vim/bundle/ack.vim/.gitignore
vendored
|
@ -1 +0,0 @@
|
|||
tags
|
|
@ -1,157 +0,0 @@
|
|||
# ack.vim
|
||||
|
||||
Run your favorite search tool from Vim, with an enhanced results list.
|
||||
|
||||
This plugin was designed as a Vim frontend for the Perl module [App::Ack]. Ack
|
||||
can be used as a replacement for 99% of the uses of _grep_. The plugin allows
|
||||
you to run ack from Vim, and shows the results in a split window.
|
||||
|
||||
But here's a little secret for the Vim-seasoned: it's just a light wrapper for
|
||||
Vim's [grepprg] and the [quickfix] window for match results. This makes it easy
|
||||
to integrate with your own Vim configuration and use existing knowledge of core
|
||||
features. It also means the plugin is flexible to use with other search tools.
|
||||
|
||||
[App::Ack]: http://search.cpan.org/~petdance/ack/ack
|
||||
[grepprg]: http://vimdoc.sourceforge.net/htmldoc/options.html#'grepprg'
|
||||
[quickfix]: http://vimdoc.sourceforge.net/htmldoc/quickfix.html#quickfix
|
||||
|
||||
## Installation
|
||||
|
||||
### Ack
|
||||
|
||||
You will need ack (>= 2.0), of course. To install it follow the
|
||||
[manual](http://beyondgrep.com/install/).
|
||||
|
||||
### The Plugin
|
||||
|
||||
It is recommended to use one of the popular plugin managers for Vim. There are
|
||||
many and you probably already have a preferred one, but a few examples for your
|
||||
copy-and-paste convenience:
|
||||
|
||||
#### Pathogen
|
||||
|
||||
$ git clone https://github.com/mileszs/ack.vim.git ~/.vim/bundle/ack.vim
|
||||
|
||||
#### Vundle
|
||||
|
||||
```vim
|
||||
Plugin 'mileszs/ack.vim'
|
||||
```
|
||||
|
||||
#### NeoBundle
|
||||
|
||||
```vim
|
||||
NeoBundle 'mileszs/ack.vim'
|
||||
```
|
||||
|
||||
#### Manual (not recommended)
|
||||
|
||||
[Download][releases] the plugin and extract it in `~/.vim/` (or
|
||||
`%PROGRAMFILES%/Vim/vimfiles` on Windows).
|
||||
|
||||
[zipball]: https://github.com/mileszs/ack.vim/archive/master.zip
|
||||
|
||||
## Usage
|
||||
|
||||
:Ack [options] {pattern} [{directories}]
|
||||
|
||||
Search recursively in `{directories}` (which defaults to the current directory)
|
||||
for the `{pattern}`.
|
||||
|
||||
Files containing the search term will be listed in the quickfix window, along
|
||||
with the line number of the occurrence, once for each occurrence. `<Enter>` on
|
||||
a line in this window will open the file, and place the cursor on the matching
|
||||
line.
|
||||
|
||||
Just like where you use `:grep`, `:grepadd`, `:lgrep`, and :`lgrepadd`, you can
|
||||
use `:Ack`, `:AckAdd`, `:LAck`, and `:LAckAdd` respectively. (See `:help Ack`
|
||||
after installing, or [`doc/ack.txt`][doc] in the repo, for more information.)
|
||||
|
||||
For more ack help see [ack documentation](http://beyondgrep.com/documentation/).
|
||||
|
||||
[doc]: https://github.com/mileszs/ack.vim/blob/master/doc/ack.txt
|
||||
|
||||
### Keyboard Shortcuts
|
||||
|
||||
The quickfix results window is augmented with these convenience mappings:
|
||||
|
||||
? a quick summary of these keys, repeat to close
|
||||
o to open (same as Enter)
|
||||
O to open and close the quickfix window
|
||||
go to preview file, open but maintain focus on ack.vim results
|
||||
t to open in new tab
|
||||
T to open in new tab without moving to it
|
||||
h to open in horizontal split
|
||||
H to open in horizontal split, keeping focus on the results
|
||||
v to open in vertical split
|
||||
gv to open in vertical split, keeping focus on the results
|
||||
q to close the quickfix window
|
||||
|
||||
### Gotchas
|
||||
|
||||
Some characters have special meaning, and need to be escaped in your search
|
||||
pattern. For instance, `#`. You need to escape it with `:Ack '\\\#define
|
||||
foo'` to search for '#define foo'. See [issue #5].
|
||||
|
||||
[issue #5]: https://github.com/mileszs/ack.vim/issues/5
|
||||
|
||||
## Possibly FAQ
|
||||
|
||||
#### Can I use `ag` ([The Silver Searcher]) with this?
|
||||
|
||||
Absolutely, and probably other tools if their output is similar or you can
|
||||
write a pattern match for it--just set `g:ackprg`. If you like, you can fall
|
||||
back to Ack in case you use your vimrc on a system without Ag available:
|
||||
|
||||
```vim
|
||||
if executable('ag')
|
||||
let g:ackprg = 'ag --vimgrep'
|
||||
endif
|
||||
```
|
||||
|
||||
Since Ack is quite portable you might check a copy of it into your dotfiles
|
||||
repository in `~/bin` so you'll nearly always have it available.
|
||||
|
||||
#### What's the difference from ag.vim?
|
||||
|
||||
Well... not a lot really.
|
||||
|
||||
Present maintainer, yours truly, [kind of wishes they never forked][sadface],
|
||||
contributes to both, and wouldn't mind seeing them merged again. ag.vim got a
|
||||
nice code clean-up (which ack.vim is now hopefully getting), and ack.vim picked
|
||||
up a few features that haven't made their way to ag.vim, like `:AckWindow`,
|
||||
optional background search execution with [vim-dispatch], and auto-previewing.
|
||||
|
||||
[The Silver Searcher]: https://github.com/ggreer/the_silver_searcher
|
||||
[sadface]: https://github.com/mileszs/ack.vim/commit/d97090fb502d40229e6976dfec0e06636ba227d5#commitcomment-5771145
|
||||
|
||||
## Changelog
|
||||
|
||||
Please see [the Github releases page][releases].
|
||||
|
||||
### 1.0.9 (unreleased)
|
||||
|
||||
* Fix location list and layout of quickfix when using Dispatch (#154)
|
||||
* Fix the quick help overlay clobbering the list mappings
|
||||
* Fix `:AckFile` when using Dispatch
|
||||
* Restore original `'makeprg'` and `'errorformat'` when using Dispatch
|
||||
* Arrow keys also work for auto-preview (#158)
|
||||
* Internal refactoring and clean-up
|
||||
|
||||
## Credits
|
||||
|
||||
This plugin is derived from Antoine Imbert's blog post [Ack and Vim
|
||||
Integration][] (in particular, the function in the update to the post). [Miles
|
||||
Sterrett][mileszs] packaged it up as a plugin and documented it in Vim's help
|
||||
format, and since then [many contributors][contributors] have submitted
|
||||
enhancements and fixes.
|
||||
|
||||
And of course, where would we be without [Ack]. And, you know, Vim.
|
||||
|
||||
[Ack and Vim Integration]: http://blog.ant0ine.com/typepad/2007/03/ack-and-vim-integration.html
|
||||
[mileszs]: https://github.com/mileszs
|
||||
[contributors]: https://github.com/mileszs/ack.vim/graphs/contributors
|
||||
[Ack]: http://beyondgrep.com/
|
||||
|
||||
[vim-dispatch]: https://github.com/tpope/vim-dispatch
|
||||
[releases]: https://github.com/mileszs/ack.vim/releases
|
|
@ -1,227 +0,0 @@
|
|||
if exists('g:ack_use_dispatch')
|
||||
if g:ack_use_dispatch && !exists(':Dispatch')
|
||||
call s:Warn('Dispatch not loaded! Falling back to g:ack_use_dispatch = 0.')
|
||||
let g:ack_use_dispatch = 0
|
||||
endif
|
||||
else
|
||||
let g:ack_use_dispatch = 0
|
||||
endif
|
||||
|
||||
"-----------------------------------------------------------------------------
|
||||
" Public API
|
||||
"-----------------------------------------------------------------------------
|
||||
|
||||
function! ack#Ack(cmd, args) "{{{
|
||||
call s:Init(a:cmd)
|
||||
redraw
|
||||
|
||||
" Local values that we'll temporarily set as options when searching
|
||||
let l:grepprg = g:ackprg
|
||||
let l:grepformat = '%f:%l:%c:%m,%f:%l:%m' " Include column number
|
||||
|
||||
" Strip some options that are meaningless for path search and set match
|
||||
" format accordingly.
|
||||
if s:SearchingFilepaths()
|
||||
let l:grepprg = substitute(l:grepprg, '-H\|--column', '', 'g')
|
||||
let l:grepformat = '%f'
|
||||
endif
|
||||
|
||||
" If no pattern is provided, search for the word under the cursor
|
||||
let l:grepargs = empty(a:args) ? expand("<cword>") : a:args . join(a:000, ' ')
|
||||
|
||||
" NOTE: we escape special chars, but not everything using shellescape to
|
||||
" allow for passing arguments etc
|
||||
let l:escaped_args = escape(l:grepargs, '|#%')
|
||||
|
||||
echo "Searching ..."
|
||||
|
||||
if g:ack_use_dispatch
|
||||
call s:SearchWithDispatch(l:grepprg, l:escaped_args, l:grepformat)
|
||||
else
|
||||
call s:SearchWithGrep(a:cmd, l:grepprg, l:escaped_args, l:grepformat)
|
||||
endif
|
||||
|
||||
" Dispatch has no callback mechanism currently, we just have to display the
|
||||
" list window early and wait for it to populate :-/
|
||||
call ack#ShowResults()
|
||||
call s:Highlight(l:grepargs)
|
||||
endfunction "}}}
|
||||
|
||||
function! ack#AckFromSearch(cmd, args) "{{{
|
||||
let search = getreg('/')
|
||||
" translate vim regular expression to perl regular expression.
|
||||
let search = substitute(search, '\(\\<\|\\>\)', '\\b', 'g')
|
||||
call ack#Ack(a:cmd, '"' . search . '" ' . a:args)
|
||||
endfunction "}}}
|
||||
|
||||
function! ack#AckHelp(cmd, args) "{{{
|
||||
let args = a:args . ' ' . s:GetDocLocations()
|
||||
call ack#Ack(a:cmd, args)
|
||||
endfunction "}}}
|
||||
|
||||
function! ack#AckWindow(cmd, args) "{{{
|
||||
let files = tabpagebuflist()
|
||||
|
||||
" remove duplicated filenames (files appearing in more than one window)
|
||||
let files = filter(copy(sort(files)), 'index(files,v:val,v:key+1)==-1')
|
||||
call map(files, "bufname(v:val)")
|
||||
|
||||
" remove unnamed buffers as quickfix (empty strings before shellescape)
|
||||
call filter(files, 'v:val != ""')
|
||||
|
||||
" expand to full path (avoid problems with cd/lcd in au QuickFixCmdPre)
|
||||
let files = map(files, "shellescape(fnamemodify(v:val, ':p'))")
|
||||
let args = a:args . ' ' . join(files)
|
||||
|
||||
call ack#Ack(a:cmd, args)
|
||||
endfunction "}}}
|
||||
|
||||
function! ack#ShowResults() "{{{
|
||||
let l:handler = s:UsingLocList() ? g:ack_lhandler : g:ack_qhandler
|
||||
execute l:handler
|
||||
call s:ApplyMappings()
|
||||
redraw!
|
||||
endfunction "}}}
|
||||
|
||||
"-----------------------------------------------------------------------------
|
||||
" Private API
|
||||
"-----------------------------------------------------------------------------
|
||||
|
||||
function! s:ApplyMappings() "{{{
|
||||
if !s:UsingListMappings() || &filetype != 'qf'
|
||||
return
|
||||
endif
|
||||
|
||||
let l:wintype = s:UsingLocList() ? 'l' : 'c'
|
||||
let l:closemap = ':' . l:wintype . 'close<CR>'
|
||||
let g:ack_mappings.q = l:closemap
|
||||
|
||||
nnoremap <buffer> <silent> ? :call <SID>QuickHelp()<CR>
|
||||
|
||||
if g:ack_autoclose
|
||||
" We just map the 'go' and 'gv' mappings to close on autoclose, wtf?
|
||||
for key_map in items(g:ack_mappings)
|
||||
execute printf("nnoremap <buffer> <silent> %s %s", get(key_map, 0), get(key_map, 1) . l:closemap)
|
||||
endfor
|
||||
|
||||
execute "nnoremap <buffer> <silent> <CR> <CR>" . l:closemap
|
||||
else
|
||||
for key_map in items(g:ack_mappings)
|
||||
execute printf("nnoremap <buffer> <silent> %s %s", get(key_map, 0), get(key_map, 1))
|
||||
endfor
|
||||
endif
|
||||
|
||||
if exists("g:ackpreview") " if auto preview in on, remap j and k keys
|
||||
nnoremap <buffer> <silent> j j<CR><C-W><C-W>
|
||||
nnoremap <buffer> <silent> k k<CR><C-W><C-W>
|
||||
nmap <buffer> <silent> <Down> j
|
||||
nmap <buffer> <silent> <Up> k
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! s:GetDocLocations() "{{{
|
||||
let dp = ''
|
||||
for p in split(&rtp, ',')
|
||||
let p = p . '/doc/'
|
||||
if isdirectory(p)
|
||||
let dp = p . '*.txt ' . dp
|
||||
endif
|
||||
endfor
|
||||
|
||||
return dp
|
||||
endfunction "}}}
|
||||
|
||||
function! s:Highlight(args) "{{{
|
||||
if !g:ackhighlight
|
||||
return
|
||||
endif
|
||||
|
||||
let @/ = matchstr(a:args, "\\v(-)\@<!(\<)\@<=\\w+|['\"]\\zs.{-}\\ze['\"]")
|
||||
call feedkeys(":let &hlsearch=1 \| echo \<CR>", "n")
|
||||
endfunction "}}}
|
||||
|
||||
" Initialize state for an :Ack* or :LAck* search
|
||||
function! s:Init(cmd) "{{{
|
||||
let s:searching_filepaths = (a:cmd =~# '-g$') ? 1 : 0
|
||||
let s:using_loclist = (a:cmd =~# '^l') ? 1 : 0
|
||||
|
||||
if g:ack_use_dispatch && s:using_loclist
|
||||
call s:Warn('Dispatch does not support location lists! Proceeding with quickfix...')
|
||||
let s:using_loclist = 0
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! s:QuickHelp() "{{{
|
||||
execute 'edit' globpath(&rtp, 'doc/ack_quick_help.txt')
|
||||
|
||||
silent normal gg
|
||||
setlocal buftype=nofile bufhidden=hide nobuflisted
|
||||
setlocal nomodifiable noswapfile
|
||||
setlocal filetype=help
|
||||
setlocal nonumber norelativenumber nowrap
|
||||
setlocal foldmethod=diff foldlevel=20
|
||||
|
||||
nnoremap <buffer> <silent> ? :q!<CR>:call ack#ShowResults()<CR>
|
||||
endfunction "}}}
|
||||
|
||||
function! s:SearchWithDispatch(grepprg, grepargs, grepformat) "{{{
|
||||
let l:makeprg_bak = &l:makeprg
|
||||
let l:errorformat_bak = &l:errorformat
|
||||
|
||||
" We don't execute a :grep command for Dispatch, so add -g here instead
|
||||
if s:SearchingFilepaths()
|
||||
let l:grepprg = a:grepprg . ' -g'
|
||||
else
|
||||
let l:grepprg = a:grepprg
|
||||
endif
|
||||
|
||||
try
|
||||
let &l:makeprg = l:grepprg . ' ' . a:grepargs
|
||||
let &l:errorformat = a:grepformat
|
||||
|
||||
Make
|
||||
finally
|
||||
let &l:makeprg = l:makeprg_bak
|
||||
let &l:errorformat = l:errorformat_bak
|
||||
endtry
|
||||
endfunction "}}}
|
||||
|
||||
function! s:SearchWithGrep(grepcmd, grepprg, grepargs, grepformat) "{{{
|
||||
let l:grepprg_bak = &l:grepprg
|
||||
let l:grepformat_bak = &grepformat
|
||||
|
||||
try
|
||||
let &l:grepprg = a:grepprg
|
||||
let &grepformat = a:grepformat
|
||||
|
||||
silent execute a:grepcmd a:grepargs
|
||||
finally
|
||||
let &l:grepprg = l:grepprg_bak
|
||||
let &grepformat = l:grepformat_bak
|
||||
endtry
|
||||
endfunction "}}}
|
||||
|
||||
" Are we finding matching files, not lines? (the -g option -- :AckFile)
|
||||
function! s:SearchingFilepaths() "{{{
|
||||
return get(s:, 'searching_filepaths', 0)
|
||||
endfunction "}}}
|
||||
|
||||
" Predicate for whether mappings are enabled for list type of current search.
|
||||
function! s:UsingListMappings() "{{{
|
||||
if s:UsingLocList()
|
||||
return g:ack_apply_lmappings
|
||||
else
|
||||
return g:ack_apply_qmappings
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
" Were we invoked with a :LAck command?
|
||||
function! s:UsingLocList() "{{{
|
||||
return get(s:, 'using_loclist', 0)
|
||||
endfunction "}}}
|
||||
|
||||
function! s:Warn(msg) "{{{
|
||||
echohl WarningMsg | echomsg 'Ack: ' . a:msg | echohl None
|
||||
endf "}}}
|
||||
|
||||
" vim:set et sw=2 ts=2 tw=78 fdm=marker
|
|
@ -1,256 +0,0 @@
|
|||
*ack.txt* Plugin that integrates ack with Vim
|
||||
|
||||
==============================================================================
|
||||
Author: Antoine Imbert <antoine.imbert+ackvim@gmail.com> *ack-author*
|
||||
License: Same terms as Vim itself (see |license|)
|
||||
|
||||
==============================================================================
|
||||
INTRODUCTION *ack*
|
||||
|
||||
This plugin is a front for the Perl module App::Ack. Ack can be used as a
|
||||
replacement for grep. This plugin will allow you to run ack from vim, and
|
||||
shows the results in a split window.
|
||||
|
||||
:Ack[!] [options] {pattern} [{directory}] *:Ack*
|
||||
|
||||
Search recursively in {directory} (which defaults to the current
|
||||
directory) for the {pattern}. Behaves just like the |:grep| command, but
|
||||
will open the |Quickfix| window for you. If [!] is not given the first
|
||||
occurence is jumped to.
|
||||
|
||||
:AckAdd [options] {pattern} [{directory}] *:AckAdd*
|
||||
|
||||
Just like |:Ack|, but instead of making a new list, the matches are
|
||||
appended to the current |quickfix| list.
|
||||
|
||||
:AckFromSearch [{directory}] *:AckFromSearch*
|
||||
|
||||
Just like |:Ack| but the pattern is from previous search.
|
||||
|
||||
:LAck [options] {pattern} [{directory}] *:LAck*
|
||||
|
||||
Just like |:Ack| but instead of the |quickfix| list, matches are placed in
|
||||
the current |location-list|.
|
||||
|
||||
:LAckAdd [options] {pattern} [{directory}] *:LAckAdd*
|
||||
|
||||
Just like |:AckAdd| but instead of the |quickfix| list, matches are added
|
||||
to the current |location-list|
|
||||
|
||||
:AckFile [options] {pattern} [{directory}] *:AckFile*
|
||||
|
||||
Search recursively in {directory} (which defaults to the current
|
||||
directory) for filenames matching the {pattern}. Behaves just like the
|
||||
|:grep| command, but will open the |Quickfix| window for you.
|
||||
|
||||
:AckHelp[!] [options] {pattern} *:AckHelp*
|
||||
|
||||
Search vim documentation files for the {pattern}. Behaves just like the
|
||||
|:Ack| command, but searches only vim documentation .txt files
|
||||
|
||||
:LAckHelp [options] {pattern} *:LAckHelp*
|
||||
|
||||
Just like |:AckHelp| but instead of the |quickfix| list, matches are placed
|
||||
in the current |location-list|.
|
||||
|
||||
:AckWindow[!] [options] {pattern} *:AckWindow*
|
||||
|
||||
Search all buffers visible in the screen (current tab page only) files for
|
||||
the {pattern}.
|
||||
|
||||
:LAckWindow [options] {pattern} *:LAckWindow*
|
||||
|
||||
Just like |:AckWindow| but instead of the |quickfix| list, matches are
|
||||
placed in the current |location-list|.
|
||||
|
||||
Files containing the search term will be listed in the split window, along
|
||||
with the line number of the occurrence, once for each occurrence. <Enter> on
|
||||
a line in this window will open the file, and place the cursor on the matching
|
||||
line.
|
||||
|
||||
Note that if you are using Dispatch.vim with |g:ack_use_dispatch|, location
|
||||
lists are not supported, because Dispatch does not support them at this time.
|
||||
`:LAck` versions of commands above will give a warning and proceed to use the
|
||||
quickfix list instead.
|
||||
|
||||
See http://beyondgrep.com/ for more information on searching with ack.
|
||||
|
||||
|
||||
==============================================================================
|
||||
CONFIGURATION *ack-configuration*
|
||||
|
||||
*g:ackprg*
|
||||
g:ackprg
|
||||
Default for ubuntu: "ack-grep"
|
||||
Default for other systems: "ack"
|
||||
|
||||
Use this option to specify the search command and its default arguments.
|
||||
|
||||
Example:
|
||||
>
|
||||
let g:ackprg = "ag --vimgrep"
|
||||
<
|
||||
|
||||
*g:ack_default_options*
|
||||
g:ack_default_options
|
||||
Default: " -s -H --nocolor --nogroup --column"
|
||||
|
||||
Use this option to specify the default arguments given to `ack`. This is only
|
||||
used if |g:ackprg| has not been customized from the default--if you are using
|
||||
a custom search program instead of Ack, set your preferred options in
|
||||
|g:ackprg|.
|
||||
|
||||
NOTE: This option may be deprecated in the future. ~
|
||||
|
||||
Example:
|
||||
>
|
||||
let g:ack_default_options =
|
||||
\ " -s -H --nocolor --nogroup --column --smart-case --follow"
|
||||
<
|
||||
|
||||
*g:ack_apply_qmappings*
|
||||
g:ack_apply_qmappings
|
||||
Default: 1
|
||||
|
||||
This option enable mappings on quickview window.
|
||||
|
||||
*g:ack_apply_lmappings*
|
||||
g:ack_apply_lmappings
|
||||
Default: 1
|
||||
|
||||
This option enable mappings on Location list window.
|
||||
|
||||
*g:ack_mappings*
|
||||
g:ack_mappings
|
||||
Default: {
|
||||
\ "t": "<C-W><CR><C-W>T",
|
||||
\ "T": "<C-W><CR><C-W>TgT<C-W>j",
|
||||
\ "o": "<CR>",
|
||||
\ "O": "<CR><C-W><C-W>:ccl<CR>",
|
||||
\ "go": "<CR><C-W>j",
|
||||
\ "h": "<C-W><CR><C-W>K",
|
||||
\ "H": "<C-W><CR><C-W>K<C-W>b",
|
||||
\ "v": "<C-W><CR><C-W>H<C-W>b<C-W>J<C-W>t",
|
||||
\ "gv": "<C-W><CR><C-W>H<C-W>b<C-W>J" }
|
||||
|
||||
This option list all maps create on quickfix/Location list window.
|
||||
|
||||
Example, if you want to open the result in the middle of the screen:
|
||||
>
|
||||
let g:ack_mappings = { "o": "<CR>zz" }
|
||||
<
|
||||
|
||||
*g:ack_qhandler*
|
||||
g:ack_qhandler
|
||||
Default: "botright copen"
|
||||
|
||||
Command to open the quickview window.
|
||||
|
||||
If you want to open a quickview window with 30 lines you can do:
|
||||
>
|
||||
let g:ack_qhandler = "botright copen 30"
|
||||
<
|
||||
|
||||
*g:ack_lhandler*
|
||||
g:ack_lhandler
|
||||
Default: "botright lopen"
|
||||
|
||||
Command to open the Location list window.
|
||||
|
||||
If you want to open a Location list window with 30 lines you can do:
|
||||
>
|
||||
let g:ack_lhandler = "botright lopen 30"
|
||||
<
|
||||
|
||||
*g:ackhighlight*
|
||||
|
||||
g:ackhighlight
|
||||
Default: 0
|
||||
|
||||
Use this option to highlight the searched term.
|
||||
|
||||
Example:
|
||||
>
|
||||
let g:ackhighlight = 1
|
||||
<
|
||||
|
||||
*g:ack_autoclose*
|
||||
g:ack_autoclose
|
||||
Default: 0
|
||||
|
||||
Use this option to specify whether to close the quickfix window after
|
||||
using any of the shortcuts.
|
||||
|
||||
Example:
|
||||
>
|
||||
let g:ack_autoclose = 1
|
||||
<
|
||||
|
||||
*g:ack_autofold_results*
|
||||
|
||||
g:ack_autofold_results
|
||||
Default: 0
|
||||
|
||||
Use this option to fold the results in quickfix by file name. Only the current
|
||||
fold will be open by default and while you press 'j' and 'k' to move between the
|
||||
results if you hit other fold the last one will be closed and the current will
|
||||
be open.
|
||||
|
||||
Example:
|
||||
>
|
||||
let g:ack_autofold_results = 1
|
||||
<
|
||||
|
||||
*g:ackpreview*
|
||||
|
||||
g:ackpreview
|
||||
Default: 0
|
||||
|
||||
Use this option to automagically open the file with 'j' or 'k'.
|
||||
|
||||
Example:
|
||||
>
|
||||
let g:ackpreview = 1
|
||||
<
|
||||
|
||||
*g:ack_use_dispatch*
|
||||
|
||||
g:ack_use_dispatch
|
||||
Default: 0
|
||||
|
||||
Use this option to use vim-dispatch to run searches in the background, with a
|
||||
variety of execution backends for different systems.
|
||||
|
||||
Due to limitations in Dispatch at this time, location lists are unsupported
|
||||
and result windows will appear before results are ready. Still, these may be
|
||||
acceptable tradeoffs for very large projects where searches are slow.
|
||||
|
||||
Example:
|
||||
>
|
||||
let g:ack_use_dispatch = 1
|
||||
<
|
||||
|
||||
==============================================================================
|
||||
MAPPINGS *ack-mappings*
|
||||
|
||||
The following keyboard shortcuts are available in the quickfix window:
|
||||
|
||||
o open file (same as enter).
|
||||
|
||||
O open file and close quickfix window.
|
||||
|
||||
go preview file (open but maintain focus on ack.vim results).
|
||||
|
||||
t open in a new tab.
|
||||
|
||||
T open in new tab silently.
|
||||
|
||||
h open in horizontal split.
|
||||
|
||||
H open in horizontal split silently.
|
||||
|
||||
v open in vertical split.
|
||||
|
||||
gv open in vertical split silently.
|
||||
|
||||
q close the quickfix window.
|
|
@ -1,14 +0,0 @@
|
|||
==== ack.vim quick help ===============
|
||||
|
||||
*?:* Show/quit this help
|
||||
*t:* Open in a new tab
|
||||
*T:* Open in a new tab silently
|
||||
*o:* Open
|
||||
*O:* Open and close result window
|
||||
*go:* Preview
|
||||
*h:* Horizontal open
|
||||
*H:* Horizontal open silently
|
||||
*v:* Vertical open
|
||||
*gv:* Vertical open silently
|
||||
|
||||
========================================
|
|
@ -1,9 +0,0 @@
|
|||
if exists("g:ack_autofold_results") && g:ack_autofold_results
|
||||
setlocal foldlevel=0
|
||||
setlocal foldmethod=expr
|
||||
setlocal foldexpr=matchstr(getline(v:lnum),'^[^\|]\\+')==#matchstr(getline(v:lnum+1),'^[^\|]\\+')?1:'<1'
|
||||
setlocal foldenable
|
||||
setlocal foldclose=all
|
||||
setlocal foldopen=all
|
||||
nnoremap <buffer> j jzz
|
||||
endif
|
|
@ -1,79 +0,0 @@
|
|||
if exists('g:loaded_ack')
|
||||
finish
|
||||
endif
|
||||
|
||||
if !exists("g:ack_default_options")
|
||||
let g:ack_default_options = " -s -H --nocolor --nogroup --column"
|
||||
endif
|
||||
|
||||
" Location of the ack utility
|
||||
if !exists("g:ackprg")
|
||||
if executable('ack')
|
||||
let g:ackprg = "ack"
|
||||
elseif executable('ack-grep')
|
||||
let g:ackprg = "ack-grep"
|
||||
else
|
||||
finish
|
||||
endif
|
||||
let g:ackprg .= g:ack_default_options
|
||||
endif
|
||||
|
||||
if !exists("g:ack_apply_qmappings")
|
||||
let g:ack_apply_qmappings = !exists("g:ack_qhandler")
|
||||
endif
|
||||
|
||||
if !exists("g:ack_apply_lmappings")
|
||||
let g:ack_apply_lmappings = !exists("g:ack_lhandler")
|
||||
endif
|
||||
|
||||
let s:ack_mappings = {
|
||||
\ "t": "<C-W><CR><C-W>T",
|
||||
\ "T": "<C-W><CR><C-W>TgT<C-W>j",
|
||||
\ "o": "<CR>",
|
||||
\ "O": "<CR><C-W>p<C-W>c",
|
||||
\ "go": "<CR><C-W>p",
|
||||
\ "h": "<C-W><CR><C-W>K",
|
||||
\ "H": "<C-W><CR><C-W>K<C-W>b",
|
||||
\ "v": "<C-W><CR><C-W>H<C-W>b<C-W>J<C-W>t",
|
||||
\ "gv": "<C-W><CR><C-W>H<C-W>b<C-W>J" }
|
||||
|
||||
if exists("g:ack_mappings")
|
||||
let g:ack_mappings = extend(s:ack_mappings, g:ack_mappings)
|
||||
else
|
||||
let g:ack_mappings = s:ack_mappings
|
||||
endif
|
||||
|
||||
if !exists("g:ack_qhandler")
|
||||
let g:ack_qhandler = "botright copen"
|
||||
endif
|
||||
|
||||
if !exists("g:ack_lhandler")
|
||||
let g:ack_lhandler = "botright lopen"
|
||||
endif
|
||||
|
||||
if !exists("g:ackhighlight")
|
||||
let g:ackhighlight = 0
|
||||
endif
|
||||
|
||||
if !exists("g:ack_autoclose")
|
||||
let g:ack_autoclose = 0
|
||||
endif
|
||||
|
||||
if !exists("g:ack_autofold_results")
|
||||
let g:ack_autofold_results = 0
|
||||
endif
|
||||
|
||||
command! -bang -nargs=* -complete=file Ack call ack#Ack('grep<bang>', <q-args>)
|
||||
command! -bang -nargs=* -complete=file AckAdd call ack#Ack('grepadd<bang>', <q-args>)
|
||||
command! -bang -nargs=* -complete=file AckFromSearch call ack#AckFromSearch('grep<bang>', <q-args>)
|
||||
command! -bang -nargs=* -complete=file LAck call ack#Ack('lgrep<bang>', <q-args>)
|
||||
command! -bang -nargs=* -complete=file LAckAdd call ack#Ack('lgrepadd<bang>', <q-args>)
|
||||
command! -bang -nargs=* -complete=file AckFile call ack#Ack('grep<bang> -g', <q-args>)
|
||||
command! -bang -nargs=* -complete=help AckHelp call ack#AckHelp('grep<bang>', <q-args>)
|
||||
command! -bang -nargs=* -complete=help LAckHelp call ack#AckHelp('lgrep<bang>', <q-args>)
|
||||
command! -bang -nargs=* AckWindow call ack#AckWindow('grep<bang>', <q-args>)
|
||||
command! -bang -nargs=* LAckWindow call ack#AckWindow('lgrep<bang>', <q-args>)
|
||||
|
||||
let g:loaded_ack = 1
|
||||
|
||||
" vim:set et sw=2 ts=2 tw=78 fdm=marker
|
1
.vim/bundle/command-t/.gitattributes
vendored
1
.vim/bundle/command-t/.gitattributes
vendored
|
@ -1 +0,0 @@
|
|||
data/benchmark.yml export-ignore
|
5
.vim/bundle/command-t/.gitignore
vendored
5
.vim/bundle/command-t/.gitignore
vendored
|
@ -1,5 +0,0 @@
|
|||
.release-notes.txt
|
||||
.ruby-version
|
||||
command-t.recipe
|
||||
/.bundle
|
||||
vendor/bundle
|
9
.vim/bundle/command-t/.gitmodules
vendored
9
.vim/bundle/command-t/.gitmodules
vendored
|
@ -1,9 +0,0 @@
|
|||
[submodule "vendor/vimball"]
|
||||
path = vendor/vimball
|
||||
url = https://github.com/tomtom/vimball.rb.git
|
||||
[submodule "vendor/vimscriptuploader"]
|
||||
path = vendor/vimscriptuploader
|
||||
url = https://github.com/tomtom/vimscriptuploader.rb.git
|
||||
[submodule "vendor/vroom"]
|
||||
path = vendor/vroom
|
||||
url = https://github.com/google/vroom.git
|
|
@ -1,8 +0,0 @@
|
|||
Greg Hurrell <greg@hurrell.net> Greg Hurrell <greg@hurrell.net>
|
||||
Greg Hurrell <greg@hurrell.net> Wincent Colaiuta <win@wincent.com>
|
||||
Kevin Webster <webster.kevin@gmail.com> rabidpraxis <webster.kevin@gmail.com>
|
||||
Nicolas Alpi <nicolas.alpi@gmail.com> Spyou <nicolas.alpi@gmail.com>
|
||||
Noon Silk <noonsilk@gmail.com> Noon Silk <noonsilk@gmail.com>
|
||||
Noon Silk <noonsilk@gmail.com> Noon Silk <superhappyfun@gmail.com>
|
||||
Sung Pae <sung@metablu.com> guns <sung@metablu.com>
|
||||
Sung Pae <sung@metablu.com> guns <self@sungpae.com>
|
|
@ -1 +0,0 @@
|
|||
--colour
|
|
@ -1,2 +0,0 @@
|
|||
--- {}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
source 'https://rubygems.org'
|
||||
|
||||
gem 'nokogiri'
|
||||
gem 'mechanize'
|
||||
gem 'rake'
|
||||
gem 'rr'
|
||||
gem 'rspec'
|
|
@ -1,48 +0,0 @@
|
|||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
diff-lcs (1.2.5)
|
||||
domain_name (0.5.15)
|
||||
unf (>= 0.0.5, < 1.0.0)
|
||||
http-cookie (1.0.2)
|
||||
domain_name (~> 0.5)
|
||||
mechanize (2.7.3)
|
||||
domain_name (~> 0.5, >= 0.5.1)
|
||||
http-cookie (~> 1.0)
|
||||
mime-types (~> 2.0)
|
||||
net-http-digest_auth (~> 1.1, >= 1.1.1)
|
||||
net-http-persistent (~> 2.5, >= 2.5.2)
|
||||
nokogiri (~> 1.4)
|
||||
ntlm-http (~> 0.1, >= 0.1.1)
|
||||
webrobots (>= 0.0.9, < 0.2)
|
||||
mime-types (2.1)
|
||||
mini_portile (0.5.2)
|
||||
net-http-digest_auth (1.4)
|
||||
net-http-persistent (2.9.4)
|
||||
nokogiri (1.6.1)
|
||||
mini_portile (~> 0.5.0)
|
||||
ntlm-http (0.1.1)
|
||||
rake (10.1.1)
|
||||
rr (1.1.2)
|
||||
rspec (2.14.1)
|
||||
rspec-core (~> 2.14.0)
|
||||
rspec-expectations (~> 2.14.0)
|
||||
rspec-mocks (~> 2.14.0)
|
||||
rspec-core (2.14.7)
|
||||
rspec-expectations (2.14.5)
|
||||
diff-lcs (>= 1.1.3, < 2.0)
|
||||
rspec-mocks (2.14.5)
|
||||
unf (0.1.3)
|
||||
unf_ext
|
||||
unf_ext (0.0.6)
|
||||
webrobots (0.1.1)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
mechanize
|
||||
nokogiri
|
||||
rake
|
||||
rr
|
||||
rspec
|
|
@ -1,22 +0,0 @@
|
|||
Copyright 2010-2014 Greg Hurrell. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
2. 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.
|
||||
|
||||
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 HOLDERS 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.
|
|
@ -1,21 +0,0 @@
|
|||
rubyfiles := $(shell find ruby -name '*.rb')
|
||||
cfiles := $(shell find ruby -name '*.c')
|
||||
cheaders := $(shell find ruby -name '*.h')
|
||||
depends := $(shell find ruby -name depend)
|
||||
txtfiles := $(shell find doc -name '*.txt')
|
||||
vimfiles := $(shell find autoload plugin -name '*.vim')
|
||||
|
||||
vimball: command-t.vba
|
||||
|
||||
command-t.recipe: $(rubyfiles) $(cfiles) $(cheaders) $(depends) $(txtfiles) $(vimfiles)
|
||||
echo "$^" | perl -pe 's/ /\n/g' > $@
|
||||
command-t.vba: command-t.recipe
|
||||
vendor/vimball/vimball.rb -d . -b . vba $^
|
||||
|
||||
.PHONY: spec
|
||||
spec:
|
||||
rspec spec
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -f command-t.vba
|
|
@ -1 +0,0 @@
|
|||
doc/command-t.txt
|
|
@ -1,195 +0,0 @@
|
|||
require 'yaml'
|
||||
|
||||
def bail_on_failure
|
||||
exitstatus = $?.exitstatus
|
||||
if exitstatus != 0
|
||||
err "last command failed with exit status #{exitstatus}"
|
||||
exit 1
|
||||
end
|
||||
end
|
||||
|
||||
def version
|
||||
`git describe`.chomp
|
||||
end
|
||||
|
||||
def rubygems_version
|
||||
# RubyGems will barf if we try to pass an intermediate version number
|
||||
# like "1.1b2-10-g61a374a", so no choice but to abbreviate it
|
||||
`git describe --abbrev=0`.chomp
|
||||
end
|
||||
|
||||
def yellow
|
||||
"\033[33m"
|
||||
end
|
||||
|
||||
def red
|
||||
"\033[31m"
|
||||
end
|
||||
|
||||
def clear
|
||||
"\033[0m"
|
||||
end
|
||||
|
||||
def warn(str)
|
||||
puts "#{yellow}warning: #{str}#{clear}"
|
||||
end
|
||||
|
||||
def err(str)
|
||||
puts "#{red}error: #{str}#{clear}"
|
||||
end
|
||||
|
||||
def prepare_release_notes
|
||||
# extract base release notes from README.txt HISTORY section
|
||||
File.open('.release-notes.txt', 'w') do |out|
|
||||
lines = File.readlines('README.txt').each { |line| line.chomp! }
|
||||
while line = lines.shift do
|
||||
next unless line =~ /^HISTORY +\*command-t-history\*$/
|
||||
break unless lines.shift == '' &&
|
||||
(line = lines.shift) && line =~ /^\d\.\d/ &&
|
||||
lines.shift == ''
|
||||
while line = lines.shift and line != ''
|
||||
out.puts line
|
||||
end
|
||||
break
|
||||
end
|
||||
out.puts ''
|
||||
out.puts '# Please edit the release notes to taste.'
|
||||
out.puts '# Blank lines and lines beginning with a hash will be removed.'
|
||||
out.puts '# To abort, exit your editor with a non-zero exit status (:cquit in Vim).'
|
||||
end
|
||||
|
||||
unless system "$EDITOR .release-notes.txt"
|
||||
err "editor exited with non-zero exit status; aborting"
|
||||
exit 1
|
||||
end
|
||||
|
||||
filtered = read_release_notes
|
||||
File.open('.release-notes.txt', 'w') do |out|
|
||||
out.print filtered
|
||||
end
|
||||
end
|
||||
|
||||
def read_release_notes
|
||||
File.readlines('.release-notes.txt').reject do |line|
|
||||
line =~ /^(#.*|\s*)$/ # filter comment lines and blank lines
|
||||
end.join
|
||||
end
|
||||
|
||||
task :default => :spec
|
||||
|
||||
desc 'Print help on preparing a release'
|
||||
task :help do
|
||||
puts <<-END
|
||||
|
||||
The general release sequence is:
|
||||
|
||||
rake prerelease
|
||||
rake gem
|
||||
rake push
|
||||
rake upload:all
|
||||
|
||||
Note: the upload task depends on the Mechanize gem; and may require a
|
||||
prior `gem install mechanize`
|
||||
|
||||
END
|
||||
end
|
||||
|
||||
desc 'Run specs'
|
||||
task :spec do
|
||||
system 'bundle exec rspec spec'
|
||||
bail_on_failure
|
||||
end
|
||||
|
||||
desc 'Create vimball archive'
|
||||
task :vimball => :check_tag do
|
||||
system 'make'
|
||||
bail_on_failure
|
||||
FileUtils.cp 'command-t.vba', "command-t-#{version}.vba"
|
||||
end
|
||||
|
||||
desc 'Clean compiled products'
|
||||
task :clean do
|
||||
Dir.chdir 'ruby/command-t' do
|
||||
system 'make clean' if File.exists?('Makefile')
|
||||
system 'rm -f Makefile'
|
||||
end
|
||||
end
|
||||
|
||||
desc 'Clobber all generated files'
|
||||
task :clobber => :clean do
|
||||
system 'make clean'
|
||||
end
|
||||
|
||||
desc 'Compile extension'
|
||||
task :make do
|
||||
Dir.chdir 'ruby/command-t' do
|
||||
ruby 'extconf.rb'
|
||||
system 'make clean'
|
||||
bail_on_failure
|
||||
system 'make'
|
||||
bail_on_failure
|
||||
end
|
||||
end
|
||||
|
||||
namespace :make do
|
||||
desc 'Compile under all multiruby versions'
|
||||
task :all do
|
||||
system './compile-test.sh'
|
||||
bail_on_failure
|
||||
end
|
||||
end
|
||||
|
||||
namespace :spec do
|
||||
desc 'Run specs under all multiruby versions'
|
||||
task :all do
|
||||
system './multi-spec.sh'
|
||||
bail_on_failure
|
||||
end
|
||||
end
|
||||
|
||||
desc 'Check that the current HEAD is tagged'
|
||||
task :check_tag do
|
||||
unless system 'git describe --exact-match HEAD 2> /dev/null'
|
||||
warn 'current HEAD is not tagged'
|
||||
end
|
||||
end
|
||||
|
||||
desc 'Run checks prior to release'
|
||||
task :prerelease => ['make:all', 'spec:all', :vimball, :check_tag]
|
||||
|
||||
namespace :upload do
|
||||
desc 'Upload current vimball to Amazon S3'
|
||||
task :s3 => :vimball do
|
||||
sh 'aws --curl-options=--insecure put ' +
|
||||
"s3.wincent.com/command-t/releases/command-t-#{version}.vba " +
|
||||
"command-t-#{version}.vba"
|
||||
sh 'aws --curl-options=--insecure put ' +
|
||||
"s3.wincent.com/command-t/releases/command-t-#{version}.vba?acl " +
|
||||
'--public'
|
||||
end
|
||||
|
||||
desc 'Upload current vimball to www.vim.org'
|
||||
task :vim => :vimball do
|
||||
prepare_release_notes
|
||||
sh "vendor/vimscriptuploader/vimscriptuploader.rb \
|
||||
--id 3025 \
|
||||
--file command-t-#{version}.vba \
|
||||
--message-file .release-notes.txt \
|
||||
--version #{version} \
|
||||
--config ~/.vim_org.yml \
|
||||
.vim_org.yml"
|
||||
end
|
||||
|
||||
desc 'Upload current vimball everywhere'
|
||||
task :all => [ :s3, :vim ]
|
||||
end
|
||||
|
||||
desc 'Create the ruby gem package'
|
||||
task :gem => :check_tag do
|
||||
sh "gem build command-t.gemspec"
|
||||
end
|
||||
|
||||
desc 'Push gem to Gemcutter ("gem push")'
|
||||
task :push => :gem do
|
||||
sh "gem push command-t-#{rubygems_version}.gem"
|
||||
end
|
|
@ -1,12 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Copyright 2014 Vít Ondruch <v.ondruch@gmail.com> -->
|
||||
<component type="addon">
|
||||
<id>vim-command-t</id>
|
||||
<extends>gvim.desktop</extends>
|
||||
<name>command-t</name>
|
||||
<summary>Provides an extremely fast, intuitive mechanism for opening files with a minimal number of keystrokes</summary>
|
||||
<url type="homepage">https://wincent.com/products/command-t</url>
|
||||
<metadata_license>CC0-1.0</metadata_license>
|
||||
<project_license>BSD</project_license>
|
||||
<updatecontact>v.ondruch@gmail.com</updatecontact>
|
||||
</component>
|
|
@ -1,177 +0,0 @@
|
|||
" Copyright 2010-2014 Greg Hurrell. All rights reserved.
|
||||
" Licensed under the terms of the BSD 2-clause license.
|
||||
|
||||
if exists("g:command_t_autoloaded") || &cp
|
||||
finish
|
||||
endif
|
||||
let g:command_t_autoloaded = 1
|
||||
|
||||
function s:CommandTRubyWarning()
|
||||
echohl WarningMsg
|
||||
echo "command-t.vim requires Vim to be compiled with Ruby support"
|
||||
echo "For more information type: :help command-t"
|
||||
echohl none
|
||||
endfunction
|
||||
|
||||
function commandt#CommandTShowBufferFinder()
|
||||
if has('ruby')
|
||||
ruby $command_t.show_buffer_finder
|
||||
else
|
||||
call s:CommandTRubyWarning()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function commandt#CommandTShowFileFinder(arg)
|
||||
if has('ruby')
|
||||
ruby $command_t.show_file_finder
|
||||
else
|
||||
call s:CommandTRubyWarning()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function commandt#CommandTShowJumpFinder()
|
||||
if has('ruby')
|
||||
ruby $command_t.show_jump_finder
|
||||
else
|
||||
call s:CommandTRubyWarning()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function commandt#CommandTShowMRUFinder()
|
||||
if has('ruby')
|
||||
ruby $command_t.show_mru_finder
|
||||
else
|
||||
call s:CommandTRubyWarning()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function commandt#CommandTShowTagFinder()
|
||||
if has('ruby')
|
||||
ruby $command_t.show_tag_finder
|
||||
else
|
||||
call s:CommandTRubyWarning()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function commandt#CommandTFlush()
|
||||
if has('ruby')
|
||||
ruby $command_t.flush
|
||||
else
|
||||
call s:CommandTRubyWarning()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
if !has('ruby')
|
||||
finish
|
||||
endif
|
||||
|
||||
function CommandTListMatches()
|
||||
ruby $command_t.list_matches
|
||||
endfunction
|
||||
|
||||
function CommandTHandleKey(arg)
|
||||
ruby $command_t.handle_key
|
||||
endfunction
|
||||
|
||||
function CommandTBackspace()
|
||||
ruby $command_t.backspace
|
||||
endfunction
|
||||
|
||||
function CommandTDelete()
|
||||
ruby $command_t.delete
|
||||
endfunction
|
||||
|
||||
function CommandTAcceptSelection()
|
||||
ruby $command_t.accept_selection
|
||||
endfunction
|
||||
|
||||
function CommandTAcceptSelectionTab()
|
||||
ruby $command_t.accept_selection :command => $command_t.tab_command
|
||||
endfunction
|
||||
|
||||
function CommandTAcceptSelectionSplit()
|
||||
ruby $command_t.accept_selection :command => $command_t.split_command
|
||||
endfunction
|
||||
|
||||
function CommandTAcceptSelectionVSplit()
|
||||
ruby $command_t.accept_selection :command => $command_t.vsplit_command
|
||||
endfunction
|
||||
|
||||
function CommandTQuickfix()
|
||||
ruby $command_t.quickfix
|
||||
endfunction
|
||||
|
||||
function CommandTRefresh()
|
||||
ruby $command_t.refresh
|
||||
endfunction
|
||||
|
||||
function CommandTToggleFocus()
|
||||
ruby $command_t.toggle_focus
|
||||
endfunction
|
||||
|
||||
function CommandTCancel()
|
||||
ruby $command_t.cancel
|
||||
endfunction
|
||||
|
||||
function CommandTSelectNext()
|
||||
ruby $command_t.select_next
|
||||
endfunction
|
||||
|
||||
function CommandTSelectPrev()
|
||||
ruby $command_t.select_prev
|
||||
endfunction
|
||||
|
||||
function CommandTClear()
|
||||
ruby $command_t.clear
|
||||
endfunction
|
||||
|
||||
function CommandTClearPrevWord()
|
||||
ruby $command_t.clear_prev_word
|
||||
endfunction
|
||||
|
||||
function CommandTCursorLeft()
|
||||
ruby $command_t.cursor_left
|
||||
endfunction
|
||||
|
||||
function CommandTCursorRight()
|
||||
ruby $command_t.cursor_right
|
||||
endfunction
|
||||
|
||||
function CommandTCursorEnd()
|
||||
ruby $command_t.cursor_end
|
||||
endfunction
|
||||
|
||||
function CommandTCursorStart()
|
||||
ruby $command_t.cursor_start
|
||||
endfunction
|
||||
|
||||
" note that we only start tracking buffers from first (autoloaded) use of Command-T
|
||||
augroup CommandTMRUBuffer
|
||||
autocmd BufEnter * ruby CommandT::MRU.touch
|
||||
autocmd BufDelete * ruby CommandT::MRU.delete
|
||||
augroup END
|
||||
|
||||
ruby << EOF
|
||||
# require Ruby files
|
||||
begin
|
||||
require 'command-t/mru'
|
||||
require 'command-t/vim'
|
||||
require 'command-t/controller'
|
||||
$command_t = CommandT::Controller.new
|
||||
rescue LoadError
|
||||
load_path_modified = false
|
||||
::VIM::evaluate('&runtimepath').to_s.split(',').each do |path|
|
||||
lib = "#{path}/ruby"
|
||||
if !$LOAD_PATH.include?(lib) and File.exist?(lib)
|
||||
$LOAD_PATH << lib
|
||||
load_path_modified = true
|
||||
end
|
||||
end
|
||||
retry if load_path_modified
|
||||
|
||||
# could get here if C extension was not compiled, or was compiled
|
||||
# for the wrong architecture or Ruby version
|
||||
require 'command-t/stub'
|
||||
$command_t = CommandT::Stub.new
|
||||
end
|
||||
EOF
|
|
@ -1,33 +0,0 @@
|
|||
#!/usr/bin/env ruby
|
||||
#
|
||||
# Copyright 2013-2014 Greg Hurrell. All rights reserved.
|
||||
# Licensed under the terms of the BSD 2-clause license.
|
||||
|
||||
lib = File.expand_path('../../ruby', File.dirname(__FILE__))
|
||||
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
||||
|
||||
require 'command-t/ext'
|
||||
require 'command-t/util'
|
||||
require 'benchmark'
|
||||
require 'ostruct'
|
||||
require 'yaml'
|
||||
|
||||
yaml = File.expand_path('../../data/benchmark.yml', File.dirname(__FILE__))
|
||||
data = YAML.load_file(yaml)
|
||||
threads = CommandT::Util.processor_count
|
||||
|
||||
puts "Starting benchmark run (PID: #{Process.pid})"
|
||||
|
||||
Benchmark.bmbm do |b|
|
||||
data['tests'].each do |test|
|
||||
scanner = OpenStruct.new(:paths => test['paths'])
|
||||
matcher = CommandT::Matcher.new(scanner)
|
||||
b.report(test['name']) do
|
||||
test['times'].times do
|
||||
test['queries'].each do |query|
|
||||
matcher.sorted_matches_for(query, :threads => threads)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,76 +0,0 @@
|
|||
#!/usr/bin/env ruby
|
||||
#
|
||||
# Copyright 2014 Greg Hurrell. All rights reserved.
|
||||
# Licensed under the terms of the BSD 2-clause license.
|
||||
|
||||
lib = File.expand_path('../../ruby', File.dirname(__FILE__))
|
||||
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
||||
|
||||
require 'command-t/ext'
|
||||
require 'benchmark'
|
||||
require 'json'
|
||||
require 'pathname'
|
||||
require 'socket'
|
||||
|
||||
puts "Starting benchmark run (PID: #{Process.pid})"
|
||||
|
||||
TEST_TIMES = 10
|
||||
|
||||
Benchmark.bmbm do |b|
|
||||
b.report('watchman JSON') do
|
||||
TEST_TIMES.times do
|
||||
sockname = JSON[%x{watchman get-sockname}]['sockname']
|
||||
raise unless $?.exitstatus.zero?
|
||||
UNIXSocket.open(sockname) do |s|
|
||||
root = Pathname.new(ENV['PWD']).realpath
|
||||
s.puts JSON.generate(['watch-list'])
|
||||
if !JSON[s.gets]['roots'].include?(root)
|
||||
# this path isn't being watched yet; try to set up watch
|
||||
s.puts JSON.generate(['watch', root])
|
||||
|
||||
# root_restrict_files setting may prevent Watchman from working
|
||||
raise if JSON[s.gets].has_key?('error')
|
||||
end
|
||||
|
||||
s.puts JSON.generate(['query', root, {
|
||||
'expression' => ['type', 'f'],
|
||||
'fields' => ['name'],
|
||||
}])
|
||||
paths = JSON[s.gets]
|
||||
|
||||
# could return error if watch is removed
|
||||
raise if paths.has_key?('error')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
b.report('watchman binary') do
|
||||
TEST_TIMES.times do
|
||||
sockname = CommandT::Watchman::Utils.load(
|
||||
%x{watchman --output-encoding=bser get-sockname}
|
||||
)['sockname']
|
||||
raise unless $?.exitstatus.zero?
|
||||
|
||||
UNIXSocket.open(sockname) do |socket|
|
||||
root = Pathname.new(ENV['PWD']).realpath.to_s
|
||||
roots = CommandT::Watchman::Utils.query(['watch-list'], socket)['roots']
|
||||
if !roots.include?(root)
|
||||
# this path isn't being watched yet; try to set up watch
|
||||
result = CommandT::Watchman::Utils.query(['watch', root], socket)
|
||||
|
||||
# root_restrict_files setting may prevent Watchman from working
|
||||
raise if result.has_key?('error')
|
||||
end
|
||||
|
||||
query = ['query', root, {
|
||||
'expression' => ['type', 'f'],
|
||||
'fields' => ['name'],
|
||||
}]
|
||||
paths = CommandT::Watchman::Utils.query(query, socket)
|
||||
|
||||
# could return error if watch is removed
|
||||
raise if paths.has_key?('error')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,36 +0,0 @@
|
|||
Gem::Specification.new do |s|
|
||||
s.name = 'command-t'
|
||||
|
||||
# see note in the Rakefile about how intermediate version numbers
|
||||
# can break RubyGems
|
||||
v = `git describe --abbrev=0`.chomp
|
||||
s.version = v
|
||||
|
||||
s.authors = ['Greg Hurrell']
|
||||
s.email = 'greg@hurrell.net'
|
||||
|
||||
files =
|
||||
['README.txt', 'LICENSE', 'Gemfile', 'Rakefile'] +
|
||||
Dir.glob('{ruby,doc,plugin}/**/*')
|
||||
|
||||
files = files.reject { |f| f =~ /\.(rbc|o|log|plist|dSYM)/ }
|
||||
|
||||
s.files = files
|
||||
s.license = 'BSD'
|
||||
s.require_path = 'ruby'
|
||||
s.extensions = 'ruby/command-t/extconf.rb'
|
||||
|
||||
s.executables = []
|
||||
|
||||
s.has_rdoc = false
|
||||
s.homepage = 'https://wincent.com/products/command-t'
|
||||
|
||||
s.summary = 'The Command-T plug-in for VIM.'
|
||||
|
||||
s.description = <<-EOS
|
||||
Command-T provides a fast, intuitive mechanism for opening files with a
|
||||
minimal number of keystrokes. Its full functionality is only available when
|
||||
installed as a Vim plug-in, but it is also made available as a RubyGem so
|
||||
that other applications can make use of its searching algorithm.
|
||||
EOS
|
||||
end
|
|
@ -1,10 +0,0 @@
|
|||
#!/bin/sh -e
|
||||
cd ruby/command-t
|
||||
for RUBY_VERSION in $(ls ~/.multiruby/install); do
|
||||
echo "$RUBY_VERSION: building"
|
||||
export PATH=~/.multiruby/install/$RUBY_VERSION/bin:$PATH
|
||||
ruby extconf.rb
|
||||
make clean
|
||||
make
|
||||
echo "$RUBY_VERSION: finished"
|
||||
done
|
File diff suppressed because it is too large
Load diff
1
.vim/bundle/command-t/doc/.gitignore
vendored
1
.vim/bundle/command-t/doc/.gitignore
vendored
|
@ -1 +0,0 @@
|
|||
tags
|
File diff suppressed because it is too large
Load diff
|
@ -1 +0,0 @@
|
|||
.
|
|
@ -1 +0,0 @@
|
|||
.
|
|
@ -1 +0,0 @@
|
|||
.
|
|
@ -1 +0,0 @@
|
|||
.
|
|
@ -1 +0,0 @@
|
|||
.
|
|
@ -1 +0,0 @@
|
|||
.
|
|
@ -1 +0,0 @@
|
|||
.
|
|
@ -1,25 +0,0 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
function build_quietly()
|
||||
{
|
||||
(bundle install > /dev/null &&
|
||||
cd ruby/command-t &&
|
||||
ruby extconf.rb > /dev/null &&
|
||||
make clean > /dev/null &&
|
||||
make > /dev/null)
|
||||
}
|
||||
|
||||
OLD_PATH=$PATH
|
||||
for RUBY_VERSION in $(ls ~/.multiruby/install); do
|
||||
echo "$RUBY_VERSION: building"
|
||||
export PATH=~/.multiruby/install/$RUBY_VERSION/bin:$OLD_PATH
|
||||
build_quietly
|
||||
echo "$RUBY_VERSION: running spec suite"
|
||||
bundle exec rspec spec
|
||||
echo "$RUBY_VERSION: finished"
|
||||
done
|
||||
|
||||
# put things back the way we found them
|
||||
export PATH=$OLD_PATH
|
||||
echo "Restoring: $(ruby -v)"
|
||||
build_quietly
|
|
@ -1,26 +0,0 @@
|
|||
" Copyright 2010-2014 Greg Hurrell. All rights reserved.
|
||||
" Licensed under the terms of the BSD 2-clause license.
|
||||
|
||||
if exists("g:command_t_loaded") || &cp
|
||||
finish
|
||||
endif
|
||||
let g:command_t_loaded = 1
|
||||
|
||||
command CommandTBuffer call commandt#CommandTShowBufferFinder()
|
||||
command CommandTJump call commandt#CommandTShowJumpFinder()
|
||||
command CommandTMRU call commandt#CommandTShowMRUFinder()
|
||||
command CommandTTag call commandt#CommandTShowTagFinder()
|
||||
command -nargs=? -complete=dir CommandT call commandt#CommandTShowFileFinder(<q-args>)
|
||||
command CommandTFlush call commandt#CommandTFlush()
|
||||
|
||||
if !hasmapto(':CommandT<CR>') && maparg('<Leader>t', 'n') == ''
|
||||
silent! nnoremap <unique> <silent> <Leader>t :CommandT<CR>
|
||||
endif
|
||||
|
||||
if !hasmapto(':CommandTBuffer<CR>') && maparg('<Leader>b', 'n') == ''
|
||||
silent! nnoremap <unique> <silent> <Leader>b :CommandTBuffer<CR>
|
||||
endif
|
||||
|
||||
if !has('ruby')
|
||||
finish
|
||||
endif
|
|
@ -1,6 +0,0 @@
|
|||
Makefile
|
||||
*.o
|
||||
*.log
|
||||
ext.*
|
||||
!ext.c
|
||||
!ext.h
|
|
@ -1,430 +0,0 @@
|
|||
# Copyright 2010-2014 Greg Hurrell. All rights reserved.
|
||||
# Licensed under the terms of the BSD 2-clause license.
|
||||
|
||||
require 'command-t/finder/buffer_finder'
|
||||
require 'command-t/finder/jump_finder'
|
||||
require 'command-t/finder/file_finder'
|
||||
require 'command-t/finder/mru_buffer_finder'
|
||||
require 'command-t/finder/tag_finder'
|
||||
require 'command-t/match_window'
|
||||
require 'command-t/prompt'
|
||||
require 'command-t/vim/path_utilities'
|
||||
require 'command-t/util'
|
||||
|
||||
module CommandT
|
||||
class Controller
|
||||
include VIM::PathUtilities
|
||||
|
||||
def initialize
|
||||
@prompt = Prompt.new
|
||||
end
|
||||
|
||||
def show_buffer_finder
|
||||
@path = VIM::pwd
|
||||
@active_finder = buffer_finder
|
||||
show
|
||||
end
|
||||
|
||||
def show_jump_finder
|
||||
@path = VIM::pwd
|
||||
@active_finder = jump_finder
|
||||
show
|
||||
end
|
||||
|
||||
def show_mru_finder
|
||||
@path = VIM::pwd
|
||||
@active_finder = mru_finder
|
||||
show
|
||||
end
|
||||
|
||||
def show_tag_finder
|
||||
@path = VIM::pwd
|
||||
@active_finder = tag_finder
|
||||
show
|
||||
end
|
||||
|
||||
def show_file_finder
|
||||
# optional parameter will be desired starting directory, or ""
|
||||
|
||||
arg = ::VIM::evaluate('a:arg')
|
||||
if arg && arg.size > 0
|
||||
@path = File.expand_path(arg, VIM::pwd)
|
||||
else
|
||||
traverse = VIM::get_string('g:CommandTTraverseSCM') || 'file'
|
||||
case traverse
|
||||
when 'file'
|
||||
@path = nearest_ancestor(VIM::current_file_dir, scm_markers)
|
||||
when 'dir'
|
||||
@path = nearest_ancestor(VIM::pwd, scm_markers)
|
||||
end
|
||||
|
||||
@path = VIM::pwd unless @path
|
||||
end
|
||||
|
||||
@active_finder = file_finder
|
||||
file_finder.path = @path
|
||||
show
|
||||
rescue Errno::ENOENT
|
||||
# probably a problem with the optional parameter
|
||||
@match_window.print_no_such_file_or_directory
|
||||
end
|
||||
|
||||
def hide
|
||||
@match_window.leave
|
||||
if VIM::Window.select @initial_window
|
||||
if @initial_buffer.number == 0
|
||||
# upstream bug: buffer number misreported as 0
|
||||
# see: https://wincent.com/issues/1617
|
||||
::VIM::command "silent b #{@initial_buffer.name}"
|
||||
else
|
||||
::VIM::command "silent b #{@initial_buffer.number}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Take current matches and stick them in the quickfix window.
|
||||
def quickfix
|
||||
hide
|
||||
|
||||
matches = @matches.map do |match|
|
||||
"{ 'filename': '#{VIM::escape_for_single_quotes match}' }"
|
||||
end.join(', ')
|
||||
|
||||
::VIM::command 'call setqflist([' + matches + '])'
|
||||
::VIM::command 'cope'
|
||||
end
|
||||
|
||||
def refresh
|
||||
return unless @active_finder && @active_finder.respond_to?(:flush)
|
||||
@active_finder.flush
|
||||
list_matches!
|
||||
end
|
||||
|
||||
def flush
|
||||
@max_height = nil
|
||||
@min_height = nil
|
||||
@file_finder = nil
|
||||
@tag_finder = nil
|
||||
end
|
||||
|
||||
def handle_key
|
||||
key = ::VIM::evaluate('a:arg').to_i.chr
|
||||
if @focus == @prompt
|
||||
@prompt.add! key
|
||||
@needs_update = true
|
||||
else
|
||||
@match_window.find key
|
||||
end
|
||||
end
|
||||
|
||||
def backspace
|
||||
if @focus == @prompt
|
||||
@prompt.backspace!
|
||||
@needs_update = true
|
||||
end
|
||||
end
|
||||
|
||||
def delete
|
||||
if @focus == @prompt
|
||||
@prompt.delete!
|
||||
@needs_update = true
|
||||
end
|
||||
end
|
||||
|
||||
def accept_selection(options = {})
|
||||
selection = @match_window.selection
|
||||
hide
|
||||
open_selection(selection, options) unless selection.nil?
|
||||
end
|
||||
|
||||
def toggle_focus
|
||||
@focus.unfocus # old focus
|
||||
@focus = @focus == @prompt ? @match_window : @prompt
|
||||
@focus.focus # new focus
|
||||
end
|
||||
|
||||
def cancel
|
||||
hide
|
||||
end
|
||||
|
||||
def select_next
|
||||
@match_window.select_next
|
||||
end
|
||||
|
||||
def select_prev
|
||||
@match_window.select_prev
|
||||
end
|
||||
|
||||
def clear
|
||||
@prompt.clear!
|
||||
list_matches!
|
||||
end
|
||||
|
||||
def clear_prev_word
|
||||
@prompt.clear_prev_word!
|
||||
list_matches!
|
||||
end
|
||||
|
||||
def cursor_left
|
||||
@prompt.cursor_left if @focus == @prompt
|
||||
end
|
||||
|
||||
def cursor_right
|
||||
@prompt.cursor_right if @focus == @prompt
|
||||
end
|
||||
|
||||
def cursor_end
|
||||
@prompt.cursor_end if @focus == @prompt
|
||||
end
|
||||
|
||||
def cursor_start
|
||||
@prompt.cursor_start if @focus == @prompt
|
||||
end
|
||||
|
||||
def leave
|
||||
@match_window.leave
|
||||
end
|
||||
|
||||
def unload
|
||||
@match_window.unload
|
||||
end
|
||||
|
||||
def list_matches(options = {})
|
||||
return unless @needs_update || options[:force]
|
||||
|
||||
@matches = @active_finder.sorted_matches_for(
|
||||
@prompt.abbrev,
|
||||
:case_sensitive => case_sensitive?,
|
||||
:limit => match_limit,
|
||||
:threads => CommandT::Util.processor_count
|
||||
)
|
||||
@match_window.matches = @matches
|
||||
|
||||
@needs_update = false
|
||||
end
|
||||
|
||||
def tab_command
|
||||
VIM::get_string('g:CommandTAcceptSelectionTabCommand') || 'tabe'
|
||||
end
|
||||
|
||||
def split_command
|
||||
VIM::get_string('g:CommandTAcceptSelectionSplitCommand') || 'sp'
|
||||
end
|
||||
|
||||
def vsplit_command
|
||||
VIM::get_string('g:CommandTAcceptSelectionVSplitCommand') || 'vs'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def scm_markers
|
||||
markers = VIM::get_string('g:CommandTSCMDirectories')
|
||||
markers = markers && markers.split(/\s*,\s*/)
|
||||
markers = %w[.git .hg .svn .bzr _darcs] unless markers && markers.length
|
||||
markers
|
||||
end
|
||||
|
||||
def list_matches!
|
||||
list_matches(:force => true)
|
||||
end
|
||||
|
||||
def show
|
||||
@initial_window = $curwin
|
||||
@initial_buffer = $curbuf
|
||||
@match_window = MatchWindow.new \
|
||||
:highlight_color => VIM::get_string('g:CommandTHighlightColor'),
|
||||
:match_window_at_top => VIM::get_bool('g:CommandTMatchWindowAtTop'),
|
||||
:match_window_reverse => VIM::get_bool('g:CommandTMatchWindowReverse'),
|
||||
:min_height => min_height,
|
||||
:debounce_interval => VIM::get_number('g:CommandTInputDebounce') || 50,
|
||||
:prompt => @prompt
|
||||
@focus = @prompt
|
||||
@prompt.focus
|
||||
register_for_key_presses
|
||||
set_up_autocmds
|
||||
clear # clears prompt and lists matches
|
||||
end
|
||||
|
||||
def max_height
|
||||
@max_height ||= VIM::get_number('g:CommandTMaxHeight') || 0
|
||||
end
|
||||
|
||||
def min_height
|
||||
@min_height ||= begin
|
||||
min_height = VIM::get_number('g:CommandTMinHeight') || 0
|
||||
min_height = max_height if max_height != 0 && min_height > max_height
|
||||
min_height
|
||||
end
|
||||
end
|
||||
|
||||
def case_sensitive?
|
||||
if @prompt.abbrev.match(/[A-Z]/)
|
||||
if VIM::exists?('g:CommandTSmartCase')
|
||||
smart_case = VIM::get_bool('g:CommandTSmartCase')
|
||||
else
|
||||
smart_case = VIM::get_bool('&smartcase')
|
||||
end
|
||||
|
||||
if smart_case
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
if VIM::exists?('g:CommandTIgnoreCase')
|
||||
return !VIM::get_bool('g:CommandTIgnoreCase')
|
||||
end
|
||||
|
||||
false
|
||||
end
|
||||
|
||||
# Backslash-escape space, \, |, %, #, "
|
||||
def sanitize_path_string(str)
|
||||
# for details on escaping command-line mode arguments see: :h :
|
||||
# (that is, help on ":") in the Vim documentation.
|
||||
str.gsub(/[ \\|%#"]/, '\\\\\0')
|
||||
end
|
||||
|
||||
def default_open_command
|
||||
if !VIM::get_bool('&modified') ||
|
||||
VIM::get_bool('&hidden') ||
|
||||
VIM::get_bool('&autowriteall') && !VIM::get_bool('&readonly')
|
||||
VIM::get_string('g:CommandTAcceptSelectionCommand') || 'e'
|
||||
else
|
||||
'sp'
|
||||
end
|
||||
end
|
||||
|
||||
def ensure_appropriate_window_selection
|
||||
# normally we try to open the selection in the current window, but there
|
||||
# is one exception:
|
||||
#
|
||||
# - we don't touch any "unlisted" buffer with buftype "nofile" (such as
|
||||
# NERDTree or MiniBufExplorer); this is to avoid things like the "Not
|
||||
# enough room" error which occurs when trying to open in a split in a
|
||||
# shallow (potentially 1-line) buffer like MiniBufExplorer is current
|
||||
#
|
||||
# Other "unlisted" buffers, such as those with buftype "help" are treated
|
||||
# normally.
|
||||
initial = $curwin
|
||||
while true do
|
||||
break unless ::VIM::evaluate('&buflisted').to_i == 0 &&
|
||||
::VIM::evaluate('&buftype').to_s == 'nofile'
|
||||
::VIM::command 'wincmd w' # try next window
|
||||
break if $curwin == initial # have already tried all
|
||||
end
|
||||
end
|
||||
|
||||
def open_selection(selection, options = {})
|
||||
command = options[:command] || default_open_command
|
||||
selection = File.expand_path selection, @path
|
||||
selection = relative_path_under_working_directory selection
|
||||
selection = sanitize_path_string selection
|
||||
selection = File.join('.', selection) if selection =~ /^\+/
|
||||
ensure_appropriate_window_selection
|
||||
|
||||
@active_finder.open_selection command, selection, options
|
||||
end
|
||||
|
||||
def map(key, function, param = nil)
|
||||
::VIM::command "noremap <silent> <buffer> #{key} " \
|
||||
":call CommandT#{function}(#{param})<CR>"
|
||||
end
|
||||
|
||||
def term
|
||||
@term ||= ::VIM::evaluate('&term')
|
||||
end
|
||||
|
||||
def register_for_key_presses
|
||||
# "normal" keys (interpreted literally)
|
||||
numbers = ('0'..'9').to_a.join
|
||||
lowercase = ('a'..'z').to_a.join
|
||||
uppercase = lowercase.upcase
|
||||
punctuation = '<>`@#~!"$%&/()=+*-_.,;:?\\\'{}[] ' # and space
|
||||
(numbers + lowercase + uppercase + punctuation).each_byte do |b|
|
||||
map "<Char-#{b}>", 'HandleKey', b
|
||||
end
|
||||
|
||||
# "special" keys (overridable by settings)
|
||||
{
|
||||
'AcceptSelection' => '<CR>',
|
||||
'AcceptSelectionSplit' => ['<C-CR>', '<C-s>'],
|
||||
'AcceptSelectionTab' => '<C-t>',
|
||||
'AcceptSelectionVSplit' => '<C-v>',
|
||||
'Backspace' => '<BS>',
|
||||
'Cancel' => ['<C-c>', '<Esc>'],
|
||||
'Clear' => '<C-u>',
|
||||
'ClearPrevWord' => '<C-w>',
|
||||
'CursorEnd' => '<C-e>',
|
||||
'CursorLeft' => ['<Left>', '<C-h>'],
|
||||
'CursorRight' => ['<Right>', '<C-l>'],
|
||||
'CursorStart' => '<C-a>',
|
||||
'Delete' => '<Del>',
|
||||
'Quickfix' => '<C-q>',
|
||||
'Refresh' => '<C-f>',
|
||||
'SelectNext' => ['<C-n>', '<C-j>', '<Down>'],
|
||||
'SelectPrev' => ['<C-p>', '<C-k>', '<Up>'],
|
||||
'ToggleFocus' => '<Tab>',
|
||||
}.each do |key, value|
|
||||
if override = VIM::get_list_or_string("g:CommandT#{key}Map")
|
||||
Array(override).each do |mapping|
|
||||
map mapping, key
|
||||
end
|
||||
else
|
||||
Array(value).each do |mapping|
|
||||
unless mapping == '<Esc>' && term =~ /\A(screen|xterm|vt100)/
|
||||
map mapping, key
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def set_up_autocmds
|
||||
::VIM::command 'augroup Command-T'
|
||||
::VIM::command 'au!'
|
||||
::VIM::command 'autocmd CursorHold <buffer> :call CommandTListMatches()'
|
||||
::VIM::command 'augroup END'
|
||||
end
|
||||
|
||||
# Returns the desired maximum number of matches, based on available vertical
|
||||
# space and the g:CommandTMaxHeight option.
|
||||
#
|
||||
# Note the "available" space is actually a theoretical upper bound; it takes
|
||||
# into account screen dimensions but not things like existing splits which
|
||||
# may reduce the amount of space in practice.
|
||||
def match_limit
|
||||
limit = [1, VIM::Screen.lines - 5].max
|
||||
limit = [limit, max_height].min if max_height > 0
|
||||
limit
|
||||
end
|
||||
|
||||
def buffer_finder
|
||||
@buffer_finder ||= CommandT::BufferFinder.new
|
||||
end
|
||||
|
||||
def mru_finder
|
||||
@mru_finder ||= CommandT::MRUBufferFinder.new
|
||||
end
|
||||
|
||||
def file_finder
|
||||
@file_finder ||= CommandT::FileFinder.new nil,
|
||||
:max_depth => VIM::get_number('g:CommandTMaxDepth'),
|
||||
:max_files => VIM::get_number('g:CommandTMaxFiles'),
|
||||
:max_caches => VIM::get_number('g:CommandTMaxCachedDirectories'),
|
||||
:always_show_dot_files => VIM::get_bool('g:CommandTAlwaysShowDotFiles'),
|
||||
:never_show_dot_files => VIM::get_bool('g:CommandTNeverShowDotFiles'),
|
||||
:scan_dot_directories => VIM::get_bool('g:CommandTScanDotDirectories'),
|
||||
:wild_ignore => VIM::get_string('g:CommandTWildIgnore'),
|
||||
:scanner => VIM::get_string('g:CommandTFileScanner')
|
||||
end
|
||||
|
||||
def jump_finder
|
||||
@jump_finder ||= CommandT::JumpFinder.new
|
||||
end
|
||||
|
||||
def tag_finder
|
||||
@tag_finder ||= CommandT::TagFinder.new \
|
||||
:include_filenames => VIM::get_bool('g:CommandTTagIncludeFilenames')
|
||||
end
|
||||
end # class Controller
|
||||
end # module CommandT
|
|
@ -1,4 +0,0 @@
|
|||
# Copyright 2010-2014 Greg Hurrell. All rights reserved.
|
||||
# Licensed under the terms of the BSD 2-clause license.
|
||||
|
||||
CFLAGS += -Wall -Wextra -Wno-unused-parameter
|
|
@ -1,40 +0,0 @@
|
|||
// Copyright 2010-2014 Greg Hurrell. All rights reserved.
|
||||
// Licensed under the terms of the BSD 2-clause license.
|
||||
|
||||
#include "matcher.h"
|
||||
#include "watchman.h"
|
||||
|
||||
VALUE mCommandT = 0; // module CommandT
|
||||
VALUE cCommandTMatcher = 0; // class CommandT::Matcher
|
||||
VALUE mCommandTWatchman = 0; // module CommandT::Watchman
|
||||
VALUE mCommandTWatchmanUtils = 0; // module CommandT::Watchman::Utils
|
||||
|
||||
VALUE CommandT_option_from_hash(const char *option, VALUE hash)
|
||||
{
|
||||
VALUE key;
|
||||
if (NIL_P(hash))
|
||||
return Qnil;
|
||||
key = ID2SYM(rb_intern(option));
|
||||
if (rb_funcall(hash, rb_intern("has_key?"), 1, key) == Qtrue)
|
||||
return rb_hash_aref(hash, key);
|
||||
else
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
void Init_ext()
|
||||
{
|
||||
// module CommandT
|
||||
mCommandT = rb_define_module("CommandT");
|
||||
|
||||
// class CommandT::Matcher
|
||||
cCommandTMatcher = rb_define_class_under(mCommandT, "Matcher", rb_cObject);
|
||||
rb_define_method(cCommandTMatcher, "initialize", CommandTMatcher_initialize, -1);
|
||||
rb_define_method(cCommandTMatcher, "sorted_matches_for", CommandTMatcher_sorted_matches_for, -1);
|
||||
|
||||
// module CommandT::Watchman::Utils
|
||||
mCommandTWatchman = rb_define_module_under(mCommandT, "Watchman");
|
||||
mCommandTWatchmanUtils = rb_define_module_under(mCommandTWatchman, "Utils");
|
||||
rb_define_singleton_method(mCommandTWatchmanUtils, "load", CommandTWatchmanUtils_load, 1);
|
||||
rb_define_singleton_method(mCommandTWatchmanUtils, "dump", CommandTWatchmanUtils_dump, 1);
|
||||
rb_define_singleton_method(mCommandTWatchmanUtils, "query", CommandTWatchmanUtils_query, 2);
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
// Copyright 2010-2014 Greg Hurrell. All rights reserved.
|
||||
// Licensed under the terms of the BSD 2-clause license.
|
||||
|
||||
#include <ruby.h>
|
||||
|
||||
extern VALUE mCommandT; // module CommandT
|
||||
extern VALUE cCommandTMatcher; // class CommandT::Matcher
|
||||
extern VALUE mCommandTWatchman; // module CommandT::Watchman
|
||||
extern VALUE mCommandTWatchmanUtils; // module CommandT::Watchman::Utils
|
||||
|
||||
// Encapsulates common pattern of checking for an option in an optional
|
||||
// options hash. The hash itself may be nil, but an exception will be
|
||||
// raised if it is not nil and not a hash.
|
||||
VALUE CommandT_option_from_hash(const char *option, VALUE hash);
|
||||
|
||||
// Debugging macro.
|
||||
#define ruby_inspect(obj) rb_funcall(rb_mKernel, rb_intern("p"), 1, obj)
|
|
@ -1,38 +0,0 @@
|
|||
# Copyright 2010-2014 Greg Hurrell. All rights reserved.
|
||||
# Licensed under the terms of the BSD 2-clause license.
|
||||
|
||||
require 'mkmf'
|
||||
|
||||
def header(item)
|
||||
unless find_header(item)
|
||||
puts "couldn't find #{item} (required)"
|
||||
exit 1
|
||||
end
|
||||
end
|
||||
|
||||
# mandatory headers
|
||||
header('float.h')
|
||||
header('ruby.h')
|
||||
header('stdlib.h')
|
||||
header('string.h')
|
||||
|
||||
# optional headers (for CommandT::Watchman::Utils)
|
||||
if have_header('fcntl.h') &&
|
||||
have_header('stdint.h') &&
|
||||
have_header('sys/errno.h') &&
|
||||
have_header('sys/socket.h')
|
||||
RbConfig::MAKEFILE_CONFIG['DEFS'] ||= ''
|
||||
RbConfig::MAKEFILE_CONFIG['DEFS'] += ' -DWATCHMAN_BUILD'
|
||||
|
||||
have_header('ruby/st.h') # >= 1.9; sets HAVE_RUBY_ST_H
|
||||
have_header('st.h') # 1.8; sets HAVE_ST_H
|
||||
end
|
||||
|
||||
# optional
|
||||
if RbConfig::CONFIG['THREAD_MODEL'] == 'pthread'
|
||||
have_library('pthread', 'pthread_create') # sets HAVE_PTHREAD_H if found
|
||||
end
|
||||
|
||||
RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC']
|
||||
|
||||
create_makefile('ext')
|
|
@ -1,34 +0,0 @@
|
|||
# Copyright 2010-2014 Greg Hurrell. All rights reserved.
|
||||
# Licensed under the terms of the BSD 2-clause license.
|
||||
|
||||
require 'command-t/ext' # CommandT::Matcher
|
||||
|
||||
module CommandT
|
||||
# Encapsulates a Scanner instance (which builds up a list of available files
|
||||
# in a directory) and a Matcher instance (which selects from that list based
|
||||
# on a search string).
|
||||
#
|
||||
# Specialized subclasses use different kinds of scanners adapted for
|
||||
# different kinds of search (files, buffers).
|
||||
class Finder
|
||||
include VIM::PathUtilities
|
||||
|
||||
def initialize(path = Dir.pwd, options = {})
|
||||
raise RuntimeError, 'Subclass responsibility'
|
||||
end
|
||||
|
||||
# Options:
|
||||
# :limit (integer): limit the number of returned matches
|
||||
def sorted_matches_for(str, options = {})
|
||||
@matcher.sorted_matches_for str, options
|
||||
end
|
||||
|
||||
def open_selection(command, selection, options = {})
|
||||
::VIM::command "silent #{command} #{selection}"
|
||||
end
|
||||
|
||||
def path=(path)
|
||||
@scanner.path = path
|
||||
end
|
||||
end # class Finder
|
||||
end # CommandT
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue