${0} @@ -610,7 +608,7 @@ snippet map# snippet map+ - ${5}${6} + ${5}${6} snippet mark ${0} @@ -627,17 +625,17 @@ snippet menu:t ${0} snippet meta - + snippet meta:s - + snippet meta:d - + snippet meta:compat - + snippet meta:refresh - + snippet meta:utf - + snippet meter ${0} snippet nav @@ -665,13 +663,13 @@ snippet movie - - + + + pluginspage="http://www.apple.com/quicktime/download/" /> snippet ol
    @@ -711,7 +709,7 @@ snippet p. snippet p#

    ${0}

    snippet param - + snippet pre
     		${0}
    @@ -774,7 +772,7 @@ snippet select+
     snippet small
     	${0}
     snippet source
    -	
    +	
     snippet span
     	${0}
     snippet span.
    @@ -853,7 +851,7 @@ snippet tr+
     		td+${0}
     	
     snippet track
    -	 {
    +		${0}
    +	});
    +snippet it "it" b
    +	it('${1:}', () => {
    +		${0}
    +	});
    +snippet exp "expect" b
    +	expect(${1:})${0};
    +snippet expe "expect" b
    +	expect(${1:}).to.equal(${0});
    +snippet expd "expect" b
    +	expect(${1:}).to.deep.equal(${0});
    diff --git a/sources_non_forked/vim-snippets/snippets/javascript/javascript.snippets b/sources_non_forked/vim-snippets/snippets/javascript/javascript.snippets
    index 0d054f4e..db04e545 100644
    --- a/sources_non_forked/vim-snippets/snippets/javascript/javascript.snippets
    +++ b/sources_non_forked/vim-snippets/snippets/javascript/javascript.snippets
    @@ -30,6 +30,11 @@ snippet (f
     	(function(${1}) {
     		${0}
     	}(${2}));
    +# Minify safe iife
    +snippet ;fe
    +	;(function(${1}) {
    +		${0}
    +	}(${2}))
     # self-defining function
     snippet sdf
     	var ${1:function_name} = function (${2:argument}) {
    diff --git a/sources_non_forked/vim-snippets/snippets/make.snippets b/sources_non_forked/vim-snippets/snippets/make.snippets
    index 8367b8fe..332d6fc9 100644
    --- a/sources_non_forked/vim-snippets/snippets/make.snippets
    +++ b/sources_non_forked/vim-snippets/snippets/make.snippets
    @@ -25,7 +25,26 @@ snippet add
     snippet print
     	print-%: ; @echo $*=$($*)
     # ifeq
    -snippet ifeq
    +snippet if
     	ifeq (${1:cond0}, ${2:cond1})
     		${0}
     	endif
    +# ifeq ... else ... endif
    +snippet ife
    +	ifeq (${1:cond0}, ${2:cond1})
    +		${3}
    +	else
    +		${0}
    +	endif
    +# else ...
    +snippet el
    +	else
    +		${0}
    +# .DEFAULT_GOAL := target
    +snippet default
    +	.DEFAULT_GOAL := ${1}
    +# help target for self-documented Makefile
    +snippet help
    +	help: ## Prints help for targets with comments
    +		@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $\$1, $\$2}'
    +	${0}
    diff --git a/sources_non_forked/vim-snippets/snippets/mustache.snippets b/sources_non_forked/vim-snippets/snippets/mustache.snippets
    new file mode 100644
    index 00000000..8296afcb
    --- /dev/null
    +++ b/sources_non_forked/vim-snippets/snippets/mustache.snippets
    @@ -0,0 +1,18 @@
    +# if {{#value}} ... {{/value}}
    +snippet if
    +	{{#${1:value}}}
    +	${0}
    +	{{/$1}}
    +# if not {{^value}} ... {{/value}}
    +snippet ifn
    +	{{^${1:value}}}
    +	${0}
    +	{{/$1}}
    +# if else {{#value}} ... {{/value}} {{^value}} ... {{/value}}
    +snippet ife
    +	{{#${1:value}}}
    +	${2}
    +	{{/$1}}
    +	{{^$1}}
    +	${3}
    +	{{/$1}}
    diff --git a/sources_non_forked/vim-snippets/snippets/php.snippets b/sources_non_forked/vim-snippets/snippets/php.snippets
    index 9edefa2c..06448590 100644
    --- a/sources_non_forked/vim-snippets/snippets/php.snippets
    +++ b/sources_non_forked/vim-snippets/snippets/php.snippets
    @@ -2,6 +2,8 @@ snippet ${8:$1} = $$1;
    +
     		return $this;
     	}
    -# getter method
    -snippet gm
    +snippet gm "PHP Class Getter Setter"
     	/**
     	 * Gets the value of ${1:foo}
     	 *
    -	 * @return ${2:$1}
    +	 * @return ${2:string}
     	 */
    -	${3:public} function get${4:$2}()
    +	${3:public} function get${4:$1}()
     	{
     		return $this->${5:$1};
     	}
    @@ -81,13 +79,14 @@ snippet $s
     #getter
     snippet $g
     	${1:$foo}->get${0:Bar}();
    -
     # Tertiary conditional
     snippet =?:
     	$${1:foo} = ${2:true} ? ${3:a} : ${0};
     snippet ?:
     	${1:true} ? ${2:a} : ${0}
    -
    +snippet t "$retVal = (condition) ? a : b"
    +	$${1:retVal} = (${2:condition}) ? ${3:a} : ${4:b};
    +# Predefined variables
     snippet C
     	$_COOKIE['${1:variable}']
     snippet E
    @@ -104,7 +103,12 @@ snippet S
     	$_SERVER['${1:variable}']
     snippet SS
     	$_SESSION['${1:variable}']
    -
    +snippet get "get"
    +	$_GET['${1}']
    +snippet post "post"
    +	$_POST['${1}']
    +snippet session "session"
    +	$_SESSION['${1}']
     # the following are old ones
     snippet inc
     	include '${1:file}';
    @@ -205,7 +209,19 @@ snippet doc_h
     	 * @copyright ${4:$2}, `strftime('%d %B, %Y')`
     	 * @package ${0:default}
     	 */
    -
    +snippet doc_i "interface someClass {}"
    +	/**
    +	 * $1
    +	 * @package ${2:default}
    +	 * @author ${3:`!v g:snips_author`}
    +	 **/
    +	interface ${1:someClass}
    +	{${4}
    +	}
    +snippet inheritdoc "@inheritdoc docblock"
    +	/**
    +	 * {@inheritdoc}
    +	 */
     # Interface
     snippet interface
     	/**
    @@ -218,6 +234,18 @@ snippet interface
     	{
     		${0}
     	}
    +# Trait
    +snippet trait
    +	/**
    +	 * ${2:undocumented class}
    +	 *
    +	 * @package ${3:default}
    +	 * @author ${4:`g:snips_author`}
    +	 */
    +	trait ${1:`vim_snippets#Filename()`}
    +	{
    +		${0}
    +	}
     # class ...
     snippet class
     	/**
    @@ -242,55 +270,54 @@ snippet nc
     		${0}
     	}
     # define(...)
    -snippet def
    -	define('${1}'${2});
    +snippet def "define('VARIABLE_NAME', 'definition')"
    +	define('${1:VARIABLE_NAME}', ${2:'definition'});
     # defined(...)
     snippet def?
     	${1}defined('${2}')
    -snippet wh
    +snippet wh "while (condition) { ... }"
     	while (${1:/* condition */}) {
     		${0}
     	}
    -# do ... while
    -snippet do
    +snippet do "do { ... } while (condition)"
     	do {
     		${0}
    -	} while (${1:/* condition */});
    -snippet if
    -	if (${1:/* condition */}) {
    +	} while (${1});
    +snippet if "if (condition) { ... }"
    +	if (${1}) {
     		${0}
     	}
    -snippet ifn
    -	if (!${1:/* condition */}) {
    +snippet ifn "if (!condition) { ... }"
    +	if (!${1}) {
     		${2}
     	}
    -snippet ifil
    -	
    +snippet ifil " ... "
    +	
     		${0}
     	
    -snippet ife
    -	if (${1:/* condition */}) {
    +snippet ife "if (cond) { ... } else { ... }"
    +	if (${1}) {
     		${2}
     	} else {
     		${3}
     	}
     	${0}
    -snippet ifeil
    -	
    -		${2:}
    +snippet ifeil " ...  ... "
    +	
    +		${2}
     	
    -		${3:}
    +		${3}
     	
     	${0}
    -snippet el
    +snippet el "else { ... }"
     	else {
     		${0}
     	}
    -snippet eif
    -	elseif (${1:/* condition */}) {
    +snippet eif "elseif(condition) { ... }"
    +	elseif (${1}) {
     		${0}
     	}
    -snippet switch
    +snippet switch "switch($var) { case 'xyz': ... default: .... }"
     	switch ($${1:variable}) {
     		case '${2:value}':
     			${3}
    @@ -300,34 +327,33 @@ snippet switch
     			${4}
     			break;
     	}
    -snippet case
    +snippet case "case 'value': ... break"
     	case '${1:value}':
     		${2}
     		break;
    -snippet for
    +snippet for "for ($i = 0; $i < $count; $i++) { ... }"
     	for ($${2:i} = 0; $$2 < ${1:count}; $$2${3:++}) {
     		${0}
     	}
    -snippet foreach
    +snippet foreach "foreach ($var as $value) { .. }"
     	foreach ($${1:variable} as $${2:value}) {
     		${0}
     	}
    -snippet foreachil
    +snippet foreachil "  ... "
     	
    -		${0:}
    +		${0}
     	
    -snippet foreachk
    +snippet foreachk "foreach ($var as $key => $value) { .. }"
     	foreach ($${1:variable} as $${2:key} => $${3:value}) {
     		${0}
     	}
    -snippet foreachkil
    +snippet foreachkil " $value): ?>  ... "
     	 $${3:value}): ?>
     		${0:}
     	
    -# $... = array (...)
    -snippet array b
    +snippet array "$... = array(...)"
     	$${1:arrayName} = array('${2}' => ${3});
    -snippet try
    +snippet try "try { ... } catch (Exception $e) { ... }"
     	try {
     		${0}
     	} catch (${1:Exception} $e) {
    @@ -357,14 +383,22 @@ snippet http_redirect
     	header ("HTTP/1.1 301 Moved Permanently");
     	header ("Location: ".URL);
     	exit();
    +snippet log "error_log(var_export($var, true));"
    +	error_log(var_export(${1}, true));
    +snippet var "var_export($var)"
    +	var_export(${1});
    +snippet ve "Dumb debug helper in HTML"
    +	echo '
    ' . var_export(${1}, 1) . '
    '; +snippet pc "Dumb debug helper in cli" + var_export($1);$0 # Getters & Setters -snippet gs +snippet gs "PHP Class Getter Setter" /** * Gets the value of ${1:foo} * - * @return ${2:$1} + * @return ${2:string} */ - public function get${3:$2}() + public function get${3:$1}() { return $this->${4:$1}; } @@ -413,14 +447,12 @@ snippet aw array_walk($${1:foo}, function(&$${2:v}, $${3:k}) { $$2 = ${0}; }); - # static var assign once snippet static_var static $${1} = null; if (is_null($$1)){ $$1 = ${2}; } - snippet CSVWriter assertEquals()" $this->assertEquals(${1:expected}, ${2:actual}); - -snippet asne +snippet asne "$this->assertNotEquals()" $this->assertNotEquals(${1:expected}, ${2:actual}); - -snippet asf - $this->assertFalse(${1:Something}); - -snippet ast - $this->assertTrue(${1:Something}); - -snippet asfex - $this->assertFileExists(${1:path/to/file}); - -snippet asfnex - $this->assertFileNotExists(${1:path/to/file}); - -snippet ascon - $this->assertContains(${1:Search Value}, ${2:Array or Iterator}); - -snippet ashk - $this->assertArrayHasKey(${1:key}, ${2:array}); - -snippet asnhk - this->assertArrayNotHasKey(${1:value}, ${2:array}); - -snippet ascha - $this->assertClassHasAttribute('${1:Attribute Name}', '${2:ClassName}'); - -snippet asi +snippet asf "$this->assertFalse()" + $this->assertFalse(${1}); +snippet ast "$this->assertTrue()" + $this->assertTrue(${1}); +snippet asfex "$this->assertFileExists()" + $this->assertFileExists(${1:'path/to/file'}); +snippet asfnex "$this->assertFileNotExists()" + $this->assertFileNotExists(${1:'path/to/file'}); +snippet ascon "$this->assertContains()" + $this->assertContains(${1:$needle}, ${2:$haystack}); +snippet ashk "$this->assertArrayHasKey()" + $this->assertArrayHasKey(${1:$key}, ${2:$array}); +snippet asnhk "$this->assertArrayNotHasKey()" + this->assertArrayNotHasKey(${1:$key}, ${2:$array}); +snippet ascha "$this->assertClassHasAttribute()" + $this->assertClassHasAttribute(${1:$attributeName}, '${2:$className}'); +snippet asi "$this->assertInstanceOf(...)" $this->assertInstanceOf(${1:expected}, ${2:actual}); - -snippet tc - public function test${1:name_of_the_test}() +snippet test "public function testXYZ() { ... }" + public function test${1}() { - ${0:code} + ${0} } -snippet te +snippet setup "protected function setUp() { ... }" + protected function setUp() + { + ${0} + } +snippet teardown "protected function tearDown() { ... }" + protected function tearDown() + { + ${0} + } +snippet exp "phpunit expects" + expects($this->${1:once}()) + ->method('${2}') + ->with($this->equalTo(${3})${4}) + ->will($this->returnValue(${5})); +snippet testcmt "phpunit comment with group" + /** + * @group ${1} + */ +snippet fail "$this->fail()" + $this->fail(${1}); +snippet marki "$this->markTestIncomplete()" + $this->markTestIncomplete(${1}); +snippet marks "$this->markTestSkipped()" + $this->markTestSkipped(${1}); +# end of phpunit snippets +snippet te "throw new Exception()" throw new ${1:Exception}("${2:Error Processing Request}"); - snippet fpc "file_put_contents" b file_put_contents(${1:file}, ${2:content}${3:, FILE_APPEND});$0 - snippet sr "str_replace" str_replace(${1:search}, ${2:replace}, ${3:subject})$0 - snippet ia "in_array" in_array(${1:needle}, ${2:haystack})$0 - snippet is "isset" isset(${1:var})$0 - snippet isa "isset array" isset($${1:array}[${2:key}])$0 - snippet in "is_null" is_null($${1:var})$0 - snippet fe "file_exists" file_exists(${1:file})$0 - snippet id "is_dir" is_dir(${1:path})$0 diff --git a/sources_non_forked/vim-snippets/snippets/ruby.snippets b/sources_non_forked/vim-snippets/snippets/ruby.snippets index a6340e46..772f4644 100644 --- a/sources_non_forked/vim-snippets/snippets/ruby.snippets +++ b/sources_non_forked/vim-snippets/snippets/ruby.snippets @@ -1,5 +1,7 @@ snippet enc # encoding: utf-8 +snippet frozen + # frozen_string_literal: true snippet #! #!/usr/bin/env ruby # New Block diff --git a/sources_non_forked/vim-snippets/snippets/sass.snippets b/sources_non_forked/vim-snippets/snippets/sass.snippets new file mode 100644 index 00000000..7207360c --- /dev/null +++ b/sources_non_forked/vim-snippets/snippets/sass.snippets @@ -0,0 +1,36 @@ +extends css + +snippet $ + $${1:variable}: ${0:value} +snippet imp + @import '${0}' +snippet mix + @mixin ${1:name}(${2}) + ${0} +snippet inc + @include ${1:mixin}(${2}) +snippet ext + @extend ${0} +snippet fun + @function ${1:name}(${2:args}) + ${0} +snippet if + @if ${1:condition} + ${0} +snippet ife + @if ${1:condition} + ${2} + @else + ${0} +snippet eif + @else if ${1:condition} + ${0} +snippet for + @for ${1:$i} from ${2:1} through ${3:3} + ${0} +snippet each + @each ${1:$item} in ${2:items} + ${0} +snippet while + @while ${1:$i} ${2:>} ${3:0} + ${0} diff --git a/sources_non_forked/vim-snippets/snippets/tex.snippets b/sources_non_forked/vim-snippets/snippets/tex.snippets index a618ceb1..68ac5d05 100644 --- a/sources_non_forked/vim-snippets/snippets/tex.snippets +++ b/sources_non_forked/vim-snippets/snippets/tex.snippets @@ -16,57 +16,57 @@ snippet dmo \DeclareMathOperator # \begin{}...\end{} snippet begin \begin{} ... \end{} block \begin{${1:env}} - ${0} + ${0:${VISUAL}} \end{$1} # Tabular snippet tab tabular (or arbitrary) environment \begin{${1:tabular}}{${2:c}} - ${0} + ${0:${VISUAL}} \end{$1} snippet thm thm (or arbitrary) environment with optional argument \begin[${1:author}]{${2:thm}} - ${0} + ${0:${VISUAL}} \end{$2} snippet center center environment \begin{center} - ${0} + ${0:${VISUAL}} \end{center} # Align(ed) snippet ali align(ed) environment \begin{align${1:ed}} \label{eq:${2}} - ${0} + ${0:${VISUAL}} \end{align$1} # Gather(ed) snippet gat gather(ed) environment \begin{gather${1:ed}} - ${0} + ${0:${VISUAL}} \end{gather$1} # Equation snippet eq equation environment \begin{equation} - ${0} + ${0:${VISUAL}} \end{equation} # Equation snippet eql Labeled equation environment \begin{equation} \label{eq:${2}} - ${0} + ${0:${VISUAL}} \end{equation} # Equation snippet eq* unnumbered equation environment \begin{equation*} - ${0} + ${0:${VISUAL}} \end{equation*} # Unnumbered Equation snippet \ unnumbered equation: \[ ... \] \[ - ${0} + ${0:${VISUAL}} \] # Equation array snippet eqnarray eqnarray environment \begin{eqnarray} - ${0} + ${0:${VISUAL}} \end{eqnarray} # Label snippet lab \label @@ -90,7 +90,7 @@ snippet itemize itemize environment \item ${0} \end{itemize} snippet item \item - \item ${1} + \item ${1:${VISUAL}} # Description snippet desc description environment \begin{description} @@ -103,18 +103,18 @@ snippet ]i \item (recursive) # Matrix snippet mat smart matrix environment \begin{${1:p/b/v/V/B/small}matrix} - ${0} + ${0:${VISUAL}} \end{$1matrix} # Cases snippet cas cases environment \begin{cases} ${1:equation}, &\text{ if }${2:case}\\ - ${0} + ${0:${VISUAL}} \end{cases} # Split snippet spl split environment \begin{split} - ${0} + ${0:${VISUAL}} \end{split} # Part snippet part document \part @@ -203,32 +203,32 @@ snippet fcite \footcite[]{} \footcite[${1}]{${2}}${0} #Formating text: italic, bold, underline, small capital, emphase .. snippet it italic text - \textit{${0:text}} + \textit{${0:${VISUAL:text}}} snippet bf bold face text - \textbf{${0:text}} + \textbf{${0:${VISUAL:text}}} snippet under underline text - \underline{${0:text}} + \underline{${0:${VISUAL:text}}} snippet emp emphasize text - \emph{${0:text}} + \emph{${0:${VISUAL:text}}} snippet sc small caps text - \textsc{${0:text}} + \textsc{${0:${VISUAL:text}}} #Choosing font snippet sf sans serife text - \textsf{${0:text}} + \textsf{${0:${VISUAL:text}}} snippet rm roman font text - \textrm{${0:text}} + \textrm{${0:${VISUAL:text}}} snippet tt typewriter (monospace) text - \texttt{${0:text}} + \texttt{${0:${VISUAL:text}}} #Math font snippet mf mathfrak - \mathfrak{${0:text}} + \mathfrak{${0:${VISUAL:text}}} snippet mc mathcal - \mathcal{${0:text}} + \mathcal{${0:${VISUAL:text}}} snippet ms mathscr - \mathscr{${0:text}} + \mathscr{${0:${VISUAL:text}}} #misc snippet ft \footnote - \footnote{${0:text}} + \footnote{${0:${VISUAL:text}}} snippet fig figure environment (includegraphics) \begin{figure} \begin{center} @@ -260,19 +260,19 @@ snippet lim \lim_{} \lim_{${1:n \to \infty}} ${0} snippet frame frame environment \begin{frame}[${1:t}]{${2:title}} - ${0} + ${0:${VISUAL}} \end{frame} snippet block block environment \begin{block}{${1:title}} - ${0} + ${0:${VISUAL}} \end{block} snippet alert alertblock environment \begin{alertblock}{${1:title}} - ${0} + ${0:${VISUAL}} \end{alertblock} snippet example exampleblock environment \begin{exampleblock}{${1:title}} - ${0} + ${0:${VISUAL}} \end{exampleblock} snippet col2 two-column environment \begin{columns} @@ -301,7 +301,7 @@ snippet lra langle rangle # Code listings snippet lst \begin{listing}[language=${1:language}] - ${0} + ${0:${VISUAL}} \end{listing} snippet lsi \lstinline|${1}| ${0} diff --git a/sources_non_forked/vim-snippets/snippets/twig.snippets b/sources_non_forked/vim-snippets/snippets/twig.snippets new file mode 100644 index 00000000..47997c3b --- /dev/null +++ b/sources_non_forked/vim-snippets/snippets/twig.snippets @@ -0,0 +1,34 @@ +snippet bl "{% block xyz %} .. {% endblock xyz %}" + {% block ${1} %} + ${2} + {% endblock $1 %} +snippet js "{% javascripts 'xyz' %} .. {% endjavascripts %}" + {% javascripts '${1}' %} + + {% endjavascripts %} +snippet css "{% stylesheets 'xyz' %} .. {% endstylesheets %}" + {% stylesheets '${1}' %} + + {% endstylesheets %} +snippet if "{% if %} .. {% endif %}" + {% if ${1} %} + ${2} + {% endif %} +snippet ife "{% if %} .. {% else %} .. {% endif %}" + {% if ${1} %} + ${2} + {% else %} + ${0} + {% endif %} +snippet el "{% else %}" + {% else %} + ${0} +snippet eif "{% elseif %}" + {% elseif ${1} %} + ${0} +snippet for "{% for x in y %} .. {% endfor %}" + {% for ${1} in ${2} %} + ${3} + {% endfor %} +snippet ext "{% extends xyz %}" + {% extends ${1} %} diff --git a/sources_non_forked/vim-snippets/snippets/vhdl.snippets b/sources_non_forked/vim-snippets/snippets/vhdl.snippets new file mode 100644 index 00000000..f13f5bf9 --- /dev/null +++ b/sources_non_forked/vim-snippets/snippets/vhdl.snippets @@ -0,0 +1,127 @@ +# +## Libraries + +snippet lib + library ${1} + use ${1}.${2} + +# Standard Libraries +snippet libs + library IEEE; + use IEEE.std_logic_1164.ALL; + use IEEE.numeric_std.ALL; + +# Xilinx Library +snippet libx + library UNISIM; + use UNISIM.VCOMPONENTS.ALL; + +## Entity Declaration +snippet ent + entity ${1:`vim_snippets#Filename()`} is + generic ( + ${2} + ); + port ( + ${3} + ); + end entity $1; + +## Architecture +snippet arc + architecture ${1:behav} of ${2:`vim_snippets#Filename()`} is + + ${3} + + begin + + + end $1; + +## Declarations +# std_logic +snippet st + signal ${1} : std_logic; +# std_logic_vector +snippet sv + signal ${1} : std_logic_vector (${2} downto 0); +# std_logic in +snippet ist + ${1} : in std_logic; +# std_logic_vector in +snippet isv + ${1} : in std_logic_vector (${2} downto 0); +# std_logic out +snippet ost + ${1} : out std_logic; +# std_logic_vector out +snippet osv + ${1} : out std_logic_vector (${2} downto 0); +# unsigned +snippet un + signal ${1} : unsigned (${2} downto 0); +## Process Statements +# process +snippet pr + process (${1}) + begin + ${2} + end process; +# process with clock +snippet prc + process (${1:clk}) + begin + if rising_edge ($1) then + ${2} + end if; + end process; +# process all +snippet pra + process (${1:all}) + begin + ${2} + end process; +## Control Statements +# if +snippet if + if ${1} then + ${2} + end if; +# if +snippet ife + if ${1} then + ${2} + else + ${3} + end if; +# else +snippet el + else + ${1} +# if +snippet eif + elsif ${1} then + ${2} +# case +snippet ca + case ${1} is + ${2} + end case; +# when +snippet wh + when ${1} => + ${2} +# for +snippet for + for ${1:i} in ${2} ${3:to} ${4} loop + ${5} + end loop; +# while +snippet wh + while ${1} loop + ${2} + end loop; +## Misc +# others +snippet oth + (others => '${1:0}'); diff --git a/sources_non_forked/vim-surround/plugin/surround.vim b/sources_non_forked/vim-surround/plugin/surround.vim index 6a986e89..46f32529 100644 --- a/sources_non_forked/vim-surround/plugin/surround.vim +++ b/sources_non_forked/vim-surround/plugin/surround.vim @@ -92,7 +92,7 @@ function! s:process(string) let m = matchstr(a:string,nr2char(i).'.\{-\}\ze'.nr2char(i)) if m != '' let m = substitute(strpart(m,1),'\r.*','','') - let repl_{i} = input(substitute(m,':\s*$','','').': ') + let repl_{i} = input(match(m,'\w\+$') >= 0 ? m.': ' : m) endif endfor let s = "" diff --git a/sources_non_forked/vim-yankstack/.gitignore b/sources_non_forked/vim-yankstack/.gitignore new file mode 100644 index 00000000..655a3682 --- /dev/null +++ b/sources_non_forked/vim-yankstack/.gitignore @@ -0,0 +1,2 @@ +.rvmrc +doc/tags diff --git a/sources_non_forked/vim-yankstack/Gemfile b/sources_non_forked/vim-yankstack/Gemfile new file mode 100644 index 00000000..f2e1aba5 --- /dev/null +++ b/sources_non_forked/vim-yankstack/Gemfile @@ -0,0 +1,4 @@ +source 'https://rubygems.org' + +gem "vimbot", :git => "git@github.com:maxbrunsfeld/vimbot.git" +gem "rspec" diff --git a/sources_non_forked/vim-yankstack/Gemfile.lock b/sources_non_forked/vim-yankstack/Gemfile.lock new file mode 100644 index 00000000..c17e2f41 --- /dev/null +++ b/sources_non_forked/vim-yankstack/Gemfile.lock @@ -0,0 +1,25 @@ +GIT + remote: git@github.com:maxbrunsfeld/vimbot.git + revision: 489cb3283a89d3e7891d9d9765188179c764317b + specs: + vimbot (0.0.1) + +GEM + remote: https://rubygems.org/ + specs: + diff-lcs (1.1.3) + rspec (2.8.0) + rspec-core (~> 2.8.0) + rspec-expectations (~> 2.8.0) + rspec-mocks (~> 2.8.0) + rspec-core (2.8.0) + rspec-expectations (2.8.0) + diff-lcs (~> 1.1.2) + rspec-mocks (2.8.0) + +PLATFORMS + ruby + +DEPENDENCIES + rspec + vimbot! diff --git a/sources_non_forked/vim-yankstack/README.md b/sources_non_forked/vim-yankstack/README.md new file mode 100644 index 00000000..2fcfc769 --- /dev/null +++ b/sources_non_forked/vim-yankstack/README.md @@ -0,0 +1,134 @@ +yankstack.vim +============= + +Author: Max Brunsfeld + +[Yankstack.vim](https://github.com/maxbrunsfeld/vim-yankstack) is a +lightweight implementation of the Emacs 'kill ring' for Vim. It allows you to +yank and delete things without worrying about losing the text that you yanked +previously. It effectively turns your default register into a stack, and lets +you cycle through the items in the stack after doing a paste. + +This plugin is intended to be a simpler alternative to the +[yankring](https://github.com/chrismetcalf/vim-yankring) plugin. It has a fairly +complete [test suite](https://github.com/maxbrunsfeld/vim-yankstack/blob/master/spec/yankstack/yankstack_spec.rb) +based on [rspec](https://www.relishapp.com/rspec) +and [vimbot](https://github.com/maxbrunsfeld/vimbot). + +## Installation ## + +I recommend loading your plugins with +[vundle](https://github.com/gmarik/vundle) or +[pathogen](https://github.com/tpope/vim-pathogen). + +## Key Mappings ## + +By default, yankstack adds only 2 key bindings, in normal and visual modes: + +- ```meta-p``` - cycle *backward* through your history of yanks +- ```meta-shift-p``` - cycle *forwards* through your history of yanks + +After pasting some text using ```p``` or ```P```, you can cycle through your +yank history using these commands. Typing either of these keys *without* pasting first +will do a normal paste (the same as typing `p`). This also works in insert mode. + +### the 'meta' key + +If you're using MacVim, and you want to use +this plugin's default key bindings (or any bindings involving the `option` +key), you must ```:set macmeta```. On Linux, you may have issues with the meta key if your terminal is running in 7bit mode. +Instructions for dealing with this can be found on the [wiki](https://github.com/maxbrunsfeld/vim-yankstack/wiki/Linux-terminal-configurations-for-correct-meta-key-handling) + +## Commands ## + +You can see the contents of the yank-stack using the ```:Yanks``` command. +Its output is similar to the ```:registers``` command. + +## Configuration ## + +Yankstack defines two plugin mappings that you can map to keys of your choosing. +The same mappings work in normal and insert modes. + +- ```yankstack_substitute_older_paste``` - cycle backwards through your history of yanks +- ```yankstack_substitute_newer_paste``` - cycle forwards through your history of yanks + +For example, if you wanted to define some mappings based on your 'leader' key, +you could do this: + +``` +nmap p yankstack_substitute_older_paste +nmap P yankstack_substitute_newer_paste +``` + +Also, if you want to load yankstack without the default key mappings, just +``` let g:yankstack_map_keys = 0 ``` +in your .vimrc file. + +## Compatibility ## + +Yankstack works by mapping the yank and paste keys to functions that do some +book-keeping before calling through to the normal yank/paste keys. You may want +to define your own mappings of the yank and paste keys. For example, I like to +map the ```Y``` key to ```y$```, so that it behaves the same as ```D``` and +```C```. The yankstack mappings need to happen **before** you define any such +mappings of your own. To achieve this, just call ```yankstack#setup()``` in +your vimrc, before defining your mappings: + +``` +call yankstack#setup() +nmap Y y$ +" other mappings involving y, d, c, etc +``` + +You can also prevent certain keys from being remapped by setting the `g:yankstack_yank_keys` +to the keys of your choosing. For example, if you only want Yankstack to remap `y` and `d`: + +``` +let g:yankstack_yank_keys = ['y', 'd'] +``` + +## Contributing, Feedback ## + +I'd enjoy hearing anybody's feedback on yankstack, and welcome any contribution. +Check it out on [github](https://github.com/maxbrunsfeld/vim-yankstack)! + +## Changelog ## + + +### 1.0.6 (2014-08-04) + - Allow customization of the list of keys to be remapped. + +### 1.0.5 (2012-07-19) + - Fix bug where on certain versions of vim, the first time you tried + to cycle through your yanks after doing a normal paste, an extra + paste was created. + +### 1.0.4 (2012-07-01) + - Make it so that yankstack-cycling keys cause a normal paste if they are + used without pasting first. Fix stack-cycling in insert-mode. + +### 1.0.3 (2012-05-04): + - Fix bug when overwriting text in select mode. This was causing + problems for snipMate users. + +### 1.0.2 (2012-4-20): + - Add test coverage using rspec and [vimbot](https://github.com/maxbrunsfeld/vimbot)! + - Perfect the behavior of the yankstack when pasting over text in visual + mode + - Fix bug where 's' and 'S' didn't push to the yankstack + +### 1.0.1 (2012-2-11): + - Change default key bindings, update readme, add link to github page. + +### 1.0.1 (2011-12-08): + - Fix bug when displaying empty yanks. + +### 1.0.0 (2011-12-04): + - Remove unnecessary dependency on the undotree() function. Plugin should + now work on any recent version of vim. + +## License ## +Copyright (c) Max Brunsfeld. Distributed under the same terms as Vim itself. +See the vim license. + + vim:tw=78:ts=8:ft=help:norl: diff --git a/sources_non_forked/vim-yankstack/autoload/yankstack.vim b/sources_non_forked/vim-yankstack/autoload/yankstack.vim new file mode 100644 index 00000000..8feb49e8 --- /dev/null +++ b/sources_non_forked/vim-yankstack/autoload/yankstack.vim @@ -0,0 +1,197 @@ +" yankstack.vim - keep track of your history of yanked/killed text +" +" Maintainer: Max Brunsfeld +" Version: 1.0.6 +" Todo: +" + +let s:yankstack_tail = [] +let g:yankstack_size = 30 +let s:last_paste = { 'changedtick': -1, 'key': '', 'mode': 'n', 'count': 1, 'register': '' } + +if !exists('g:yankstack_yank_keys') + let g:yankstack_yank_keys = ['c', 'C', 'd', 'D', 's', 'S', 'x', 'X', 'y', 'Y'] +endif + +function! s:yank_with_key(key) + call s:before_yank() + return a:key +endfunction + +function! s:paste_with_key(key, mode, register, count) + return s:paste_from_yankstack(a:key, a:mode, a:register, a:count, 1) +endfunction + +function! s:paste_from_yankstack(key, mode, register, count, is_new) + let keys = a:count . a:key + let keys = (a:register == s:default_register()) ? keys : ('"' . a:register . keys) + let s:last_paste = { 'key': a:key, 'mode': a:mode, 'register': a:register, 'count': a:count, 'changedtick': -1 } + call feedkeys("\yankstack_after_paste", "m") + + if a:mode == 'n' + exec 'normal!' keys + elseif a:mode == 'v' + if a:is_new + call s:before_yank() + call feedkeys("\yankstack_substitute_older_paste", "t") + exec 'normal! gv' . keys + else + let head = s:get_yankstack_head() + exec 'normal! gv' . keys + call s:set_yankstack_head(head) + endif + + " In insert mode, this function's return value is used in an + " expression mapping. In other modes, it is called for its + " side effects only. + elseif a:mode == 'i' + return keys + endif + + silent! call repeat#setreg(a:register) + silent! call repeat#set(a:key, a:count) +endfunction + +function! s:substitute_paste(offset, current_mode) + if s:last_change_was_paste() + silent undo + call s:yankstack_rotate(a:offset) + return s:paste_from_yankstack(s:last_paste.key, s:last_paste.mode, s:last_paste.register, s:last_paste.count, 0) + else + return s:paste_from_yankstack(s:default_paste_key(a:current_mode), a:current_mode, v:register, '', 1) + endif +endfunction + +function! s:before_yank() + let head = s:get_yankstack_head() + if !empty(head.text) && (empty(s:yankstack_tail) || (head != s:yankstack_tail[0])) + call insert(s:yankstack_tail, head) + let s:yankstack_tail = s:yankstack_tail[: g:yankstack_size-1] + endif +endfunction + +function! s:yankstack_rotate(offset) + if empty(s:yankstack_tail) | return | endif + let offset_left = a:offset + while offset_left != 0 + let head = s:get_yankstack_head() + if offset_left > 0 + let entry = remove(s:yankstack_tail, 0) + call add(s:yankstack_tail, head) + let offset_left -= 1 + elseif offset_left < 0 + let entry = remove(s:yankstack_tail, -1) + call insert(s:yankstack_tail, head) + let offset_left += 1 + endif + call s:set_yankstack_head(entry) + endwhile +endfunction + +function! s:get_yankstack_head() + let reg = s:default_register() + return { 'text': getreg(reg), 'type': getregtype(reg) } +endfunction + +function! s:set_yankstack_head(entry) + let reg = s:default_register() + call setreg(reg, a:entry.text, a:entry.type) +endfunction + +function! s:after_paste() + let s:last_paste.changedtick = b:changedtick +endfunction + +function! s:last_change_was_paste() + return b:changedtick == s:last_paste.changedtick +endfunction + +function! s:default_register() + let clipboard_flags = split(&clipboard, ',') + if index(clipboard_flags, 'unnamedplus') >= 0 + return "+" + elseif index(clipboard_flags, 'unnamed') >= 0 + return "*" + else + return "\"" + endif +endfunction + +function! s:default_paste_key(mode) + if a:mode == 'i' + return "\u\" . s:default_register() + else + return "p" + endif +endfunction + +function! g:Yankstack() + return [s:get_yankstack_head()] + s:yankstack_tail +endfunction + +command! -nargs=0 Yanks call s:show_yanks() +function! s:show_yanks() + echohl WarningMsg | echo "--- Yanks ---" | echohl None + let i = 0 + for yank in g:Yankstack() + call s:show_yank(yank, i) + let i += 1 + endfor +endfunction + +function! s:show_yank(yank, index) + let index = printf("%-4d", a:index) + let lines = split(a:yank.text, '\n') + let line = empty(lines) ? '' : lines[0] + let line = substitute(line, '\t', repeat(' ', &tabstop), 'g') + if len(line) > 80 || len(lines) > 1 + let line = line[: 80] . '…' + endif + + echohl Directory | echo index + echohl None | echon line + echohl None +endfunction + +function! yankstack#setup() + if exists('g:yankstack_did_setup') | return | endif + let g:yankstack_did_setup = 1 + + let paste_keys = ['p', 'P', 'gp', 'gP'] + let word_characters = split("qwertyuiopasdfghjklzxcvbnm1234567890_", '\zs') + + for key in g:yankstack_yank_keys + exec 'nnoremap ' key 'yank_with_key("' . key . '")' + exec 'xnoremap ' key 'yank_with_key("' . key . '")' + endfor + + for key in paste_keys + exec 'nnoremap ' key ':call paste_with_key("' . key . '", "n", v:register, v:count1)' + exec 'xnoremap ' key ':call paste_with_key("' . key . '", "v", v:register, v:count1)' + endfor + + for key in word_characters + exec 'smap ' key 'yank_with_key("' . key . '")' + endfor +endfunction + +nnoremap yankstack_substitute_older_paste :call substitute_paste(v:count1, 'n') +nnoremap yankstack_substitute_newer_paste :call substitute_paste(-v:count1, 'n') +xnoremap yankstack_substitute_older_paste :call substitute_paste(v:count1, 'v') +xnoremap yankstack_substitute_newer_paste :call substitute_paste(-v:count1, 'v') +inoremap yankstack_substitute_older_paste =substitute_paste(v:count1, 'i') +inoremap yankstack_substitute_newer_paste =substitute_paste(-v:count1, 'i') + +nnoremap yankstack_after_paste :call after_paste() +xnoremap yankstack_after_paste :call after_paste() +inoremap yankstack_after_paste :call after_paste() + +if !exists('g:yankstack_map_keys') || g:yankstack_map_keys + nmap yankstack_substitute_older_paste + xmap yankstack_substitute_older_paste + imap yankstack_substitute_older_paste + nmap yankstack_substitute_newer_paste + xmap yankstack_substitute_newer_paste + imap yankstack_substitute_newer_paste +endif + diff --git a/sources_non_forked/vim-yankstack/doc/yankstack.txt b/sources_non_forked/vim-yankstack/doc/yankstack.txt new file mode 100644 index 00000000..2a7dee5f --- /dev/null +++ b/sources_non_forked/vim-yankstack/doc/yankstack.txt @@ -0,0 +1,124 @@ +*yankstack.txt* Plugin for storing and cycling through yanked text strings. + +Author: Max Brunsfeld + +|yankstack-introduction| Introduction +|yankstack-installation| Installation +|yankstack-initialization| Initialization +|yankstack-commands| Commands +|yankstack-configuration| Configuration +|yankstack-changelog| Changelog + +INTRODUCTION *yankstack-introduction* + +[Yankstack.vim](https://github.com/maxbrunsfeld/vim-yankstack) is a +lightweight implementation of the Emacs 'kill ring' for Vim. It allows you to +yank and delete things without worrying about losing the text that you yanked +previously. It effectively turns your default register into a stack, and lets +you cycle through the items in the stack after doing a paste. + +This plugin is intended to be a simpler alternative to the {Yankring} plugin +(https://github.com/chrismetcalf/vim-yankring). + +INSTALLATION *yankstack-installation* + +I recommend loading your plugins with {Pathogen} +(https://github.com/tpope/vim-pathogen), so you can just clone this repo into +your "bundle" directory. + +KEY MAPPINGS *yankstack-mappings* + +By default, yankstack adds only 2 key mappings, in normal and visual modes: + +Mapping Action ~ +meta-p cycle backward through your history of yanks +meta-shift-p cycle forwards through your history of yanks + +After pasting some text using |p| or |P|, you can cycle through your +yank history using these commands. + +Typing either of these keys without pasting first will do a normal paste +(the same as typing `p`). This also works in insert mode. + +A note about the meta key - if you're using MacVim, and you want to use +this plugin's default key bindings (or any bindings involving the `option` +key), you must :set |macmeta|. + +COMMANDS *yankstack-commands* + +You can see the contents of the yank-stack using the :Yanks command. +Its output is similar to the |registers| command. > + + :Yanks (lists the contents of the yank-stack) + +CONFIGURATION *yankstack-configuration* + +If you want to load yankstack without defining any of the default key +mappings, just add > + + let g:yankstack_map_keys = 0 + +to your |.vimrc| file. + +Yankstack defines three plugin mappings that you can map to keys of your +choosing. The same mappings work in normal and insert modes. + +Mapping Name Action ~ +yankstack_substitute_older_paste cycle BACKWARDs through your history of yanks +yankstack_substitute_newer_paste cycle FORWARDS through your history of yanks + +For example, if you wanted to define some mappings based on your |leader| key, you could do this: > + + nmap p yankstack_substitute_older_paste + nmap P yankstack_substitute_newer_paste + + +COMPATIBILITY *yankstack-compatibility* + +Yankstack works by mapping the yank and paste keys to functions that do some +book-keeping before calling through to the normal yank/paste keys. You may +want to define your own mappings of the yank and paste keys. For example, I +like to map the |Y| key to "y$", so that it behaves the same as |D| and |C|. +The yankstack mappings need to happen **BEFORE** you define any such +mappings of your own. To achieve this, just call 'yankstack#setup()'in your +|vimrc|, before defining your mappings: > + + call yankstack#setup() + nmap Y y$ + +CHANGELOG *yankstack-changelog* + +1.0.5 (2012-07-19) + - Fix bug where on certain versions of vim, the first time you tried + to cycle through your yanks after doing a normal paste, an extra + paste was created. + +1.0.4 (2012-07-01) + - Make it so that yankstack-cycling keys cause a normal paste if they are + used without pasting first. Fix stack-cycling in insert-mode. + +1.0.3 (2012-05-04): + - Fix bug when overwriting text in select mode. This was causing + problems for snipMate users. + +1.0.2 (2012-4-20): + - Add test coverage using rspec and [vimbot](https://github.com/maxbrunsfeld/vimbot)! + - Perfect the behavior of the yankstack when pasting over text in visual + mode + - Fix bug where 's' and 'S' didn't push to the yankstack + +1.0.1 (2012-02-11): + - Change default key bindings, update readme, add link to github page. + +1.0.1 (2011-12-08): + - Fix bug when displaying empty yanks. + +1.0 (2011-12-04): + - Remove unnecessary dependency on the undotree() function. Plugin should + now work on any recent version of vim. + + *yankstack-license* +Copyright (c) Max Brunsfeld. Distributed under the same terms as Vim itself. +See |license|. + + vim:tw=78:ts=8:ft=help:norl: diff --git a/sources_non_forked/vim-yankstack/plugin/yankstack.vim b/sources_non_forked/vim-yankstack/plugin/yankstack.vim new file mode 100644 index 00000000..a5ad03b7 --- /dev/null +++ b/sources_non_forked/vim-yankstack/plugin/yankstack.vim @@ -0,0 +1 @@ +call yankstack#setup() diff --git a/sources_non_forked/vim-yankstack/spec/fixtures/repeat.vim b/sources_non_forked/vim-yankstack/spec/fixtures/repeat.vim new file mode 100644 index 00000000..e8fe7237 --- /dev/null +++ b/sources_non_forked/vim-yankstack/spec/fixtures/repeat.vim @@ -0,0 +1,115 @@ +" repeat.vim - Let the repeat command repeat plugin maps +" Maintainer: Tim Pope +" Version: 1.1 +" GetLatestVimScripts: 2136 1 :AutoInstall: repeat.vim + +" Installation: +" Place in either ~/.vim/plugin/repeat.vim (to load at start up) or +" ~/.vim/autoload/repeat.vim (to load automatically as needed). +" +" License: +" Copyright (c) Tim Pope. Distributed under the same terms as Vim itself. +" See :help license +" +" Developers: +" Basic usage is as follows: +" +" silent! call repeat#set("\MappingToRepeatCommand",3) +" +" The first argument is the mapping that will be invoked when the |.| key is +" pressed. Typically, it will be the same as the mapping the user invoked. +" This sequence will be stuffed into the input queue literally. Thus you must +" encode special keys by prefixing them with a backslash inside double quotes. +" +" The second argument is the default count. This is the number that will be +" prefixed to the mapping if no explicit numeric argument was given. The +" value of the v:count variable is usually correct and it will be used if the +" second parameter is omitted. If your mapping doesn't accept a numeric +" argument and you never want to receive one, pass a value of -1. +" +" Make sure to call the repeat#set function _after_ making changes to the +" file. +" +" For mappings that use a register and want the same register used on +" repetition, use: +" +" silent! call repeat#setreg("\MappingToRepeatCommand", v:register) +" +" This function can (and probably needs to be) called before making changes to +" the file (as those typically clear v:register). Therefore, the call sequence +" in your mapping will look like this: +" +" nnoremap MyMap +" \ :execute 'silent! call repeat#setreg("\Plug>MyMap", v:register)' +" \ call MyFunction(v:register, ...) +" \ silent! call repeat#set("\Plug>MyMap") + +if exists("g:loaded_repeat") || &cp || v:version < 700 + finish +endif +let g:loaded_repeat = 1 + +let g:repeat_tick = -1 +let g:repeat_reg = ['', ''] + +" Special function to avoid spurious repeats in a related, naturally repeating +" mapping when your repeatable mapping doesn't increase b:changedtick. +function! repeat#invalidate() + let g:repeat_tick = -1 +endfunction + +function! repeat#set(sequence,...) + let g:repeat_sequence = a:sequence + let g:repeat_count = a:0 ? a:1 : v:count + let g:repeat_tick = b:changedtick +endfunction + +function! repeat#setreg(sequence,register) + let g:repeat_reg = [a:sequence, a:register] +endfunction + +function! repeat#run(count) + if g:repeat_tick == b:changedtick + let r = '' + if g:repeat_reg[0] ==# g:repeat_sequence && !empty(g:repeat_reg[1]) + if g:repeat_reg[1] ==# '=' + " This causes a re-evaluation of the expression on repeat, which + " is what we want. + let r = '"=' . getreg('=', 1) . "\" + else + let r = '"' . g:repeat_reg[1] + endif + endif + + let c = g:repeat_count + let s = g:repeat_sequence + let cnt = c == -1 ? "" : (a:count ? a:count : (c ? c : '')) + call feedkeys(r . cnt, 'n') + call feedkeys(s) + else + call feedkeys((a:count ? a:count : '') . '.', 'n') + endif +endfunction + +function! repeat#wrap(command,count) + let preserve = (g:repeat_tick == b:changedtick) + exe 'norm! '.(a:count ? a:count : '').a:command . (&foldopen =~# 'undo' ? 'zv' : '') + if preserve + let g:repeat_tick = b:changedtick + endif +endfunction + +nnoremap . :call repeat#run(v:count) +nnoremap u :call repeat#wrap('u',v:count) +if maparg('U','n') ==# '' + nnoremap U :call repeat#wrap('U',v:count) +endif +nnoremap :call repeat#wrap("\C-R>",v:count) + +augroup repeatPlugin + autocmd! + autocmd BufLeave,BufWritePre,BufReadPre * let g:repeat_tick = (g:repeat_tick == b:changedtick || g:repeat_tick == 0) ? 0 : -1 + autocmd BufEnter,BufWritePost * if g:repeat_tick == 0|let g:repeat_tick = b:changedtick|endif +augroup END + +" vim:set ft=vim et sw=4 sts=4: diff --git a/sources_non_forked/vim-yankstack/spec/spec_helper.rb b/sources_non_forked/vim-yankstack/spec/spec_helper.rb new file mode 100644 index 00000000..8fa4b47f --- /dev/null +++ b/sources_non_forked/vim-yankstack/spec/spec_helper.rb @@ -0,0 +1,9 @@ +require "vimbot" + +PLUGIN_ROOT = File.expand_path("../..", __FILE__) +VIM_REPEAT_PATH = File.expand_path("spec/fixtures/repeat.vim", PLUGIN_ROOT) + +RSpec.configure do |c| + c.alias_it_should_behave_like_to :it_has_behavior, 'has behavior:' +end + diff --git a/sources_non_forked/vim-yankstack/spec/yankstack/yankstack_spec.rb b/sources_non_forked/vim-yankstack/spec/yankstack/yankstack_spec.rb new file mode 100644 index 00000000..327fb5fc --- /dev/null +++ b/sources_non_forked/vim-yankstack/spec/yankstack/yankstack_spec.rb @@ -0,0 +1,343 @@ +require "spec_helper" + +describe "Yankstack" do + let(:vim) { Vimbot::Driver.new } + + before(:all) do + vim.start + + vim.set "visualbell" + vim.set "noerrorbells" + vim.set "macmeta" + + vim.set "runtimepath+=#{PLUGIN_ROOT}" + vim.runtime "plugin/yankstack.vim" + + vim.source VIM_REPEAT_PATH + end + + after(:all) { vim.stop } + before(:each) { vim.clear_buffer } + + shared_examples "yanking and pasting" do + let(:yank_keys) { "yw" } + + before do + vim.insert "first_line", "second_line", "third_line", "fourth_line" + vim.normal "gg" + vim.normal yank_keys, 'j', yank_keys, 'j', yank_keys, 'j', yank_keys + end + + it "pushes every yanked string to the :Yanks stack" do + yank_entries[0].should match /0\s+fourth_line/ + yank_entries[1].should match /1\s+third_line/ + yank_entries[2].should match /2\s+second_line/ + yank_entries[3].should match /3\s+first_line/ + end + + describe "yanking with different keys" do + before do + vim.normal "A", "", "line to delete", "", "^" + end + + keys_that_change_register = [ + 'cc', 'C', + 'dd', 'D', + 's', 'S', + 'x', 'X', + 'yy', 'Y' + ] + + keys_that_change_register.each do |key| + it "pushes to the stack when deleting text with '#{key}'" do + vim.normal key + yank_entries[1].should match /1\s+fourth_line/ + end + end + + it "pushes to the stack when overwriting text in select mode" do + vim.type "V" + vim.type "", "this overwrites the last line" + yank_entries[0].should include "line to delete" + yank_entries[1].should include "fourth_line" + end + end + + context "in normal mode" do + before { vim.normal "o", "" } + + describe "pasting a string with 'p'" do + before { vim.normal "p" } + + it "pastes the most recently yanked string" do + vim.line_number.should == 5 + vim.line.should == "fourth_line" + end + + describe "pressing the repeat key with '.'" do + it "pastes again" do + pending unless File.exists?(VIM_REPEAT_PATH) + + vim.type "." + vim.line.should == "fourth_linefourth_line" + end + end + + describe "typing the 'cycle paste' key" do + before { vim.normal "" } + + it "replaces the pasted string with the previously yanked text" do + vim.line.should == "third_line" + end + + it "rotates the previously yanked text to the top of the yank stack" do + yank_entries[0].should include 'third_line' + yank_entries[1].should include 'second_line' + yank_entries[2].should include 'first_line' + yank_entries[-1].should include 'fourth_line' + end + + it "rotates through the yanks when pressed multiple times" do + vim.normal "" + vim.line.should == "second_line" + vim.normal "" + vim.line.should == "first_line" + + vim.normal "" + vim.line.should == "second_line" + vim.normal "" + vim.line.should == "third_line" + vim.normal "" + vim.line.should == "fourth_line" + end + end + end + + describe "typing the `substitute_older_paste` key without pasting first" do + before { vim.type "" } + + it "pastes the most recently yanked string" do + vim.line_number.should == 5 + vim.line.should == "fourth_line" + end + + describe "typing the 'cycle paste' key" do + before { vim.normal "" } + + it "replaces the pasted text with the previously yanked text" do + vim.line.should == "third_line" + end + end + end + + describe "typing the `substitute_newer_paste` key without pasting first" do + before { vim.type "" } + + it "pastes the most recently yanked string" do + vim.line_number.should == 5 + vim.line.should == "fourth_line" + end + + describe "typing the 'cycle paste' key" do + before { vim.normal "" } + + it "replaces the pasted text with the previously yanked text" do + vim.line.should == "third_line" + end + end + end + + it "allows pasting from a non-default register" do + reg = 'a' + vim.normal "gg" + vim.normal %("#{reg}y$) + vim.normal "G" + + vim.normal %("#{reg}p) + vim.line.should == "first_line" + end + + it "allows pasting with a count" do + vim.normal "3p" + vim.line_number.should == 5 + vim.line.should == "fourth_line" * 3 + end + end + + context "in visual mode, with text highlighted" do + before do + vim.normal "A", "line to overwrite" + vim.normal "V" + end + + describe "pasting a string with 'p'" do + before do + vim.type "p" + end + + it "overwrites the selection with the most recently yanked string" do + vim.line.should == "fourth_line" + end + + it "moves the the overwritten text to the bottom of the stack" do + yank_entries[0].should include "fourth_line" + yank_entries[1].should include "third_line" + yank_entries[2].should include "second_line" + yank_entries[-1].should include "line to overwrite" + end + + describe "typing the 'cycle older paste' key" do + before { vim.normal "" } + + it "replaces the pasted text with the previously yanked text" do + vim.line.should == "third_line" + end + + it "moves the previously yanked text to the top of the stack" do + yank_entries[0].should include "third_line" + yank_entries[1].should include "second_line" + yank_entries[2].should include "first_line" + yank_entries[-2].should include "line to overwrite" + yank_entries[-1].should include "fourth_line" + end + + describe "typing the 'cycle newer paste' key" do + before { vim.normal "" } + + it "replaces the pasted text with the previously yanked text" do + vim.line.should == "fourth_line" + end + + it "moves the previously yanked text to the top of the stack" do + yank_entries[0].should include "fourth_line" + yank_entries[1].should include "third_line" + yank_entries[2].should include "second_line" + yank_entries[3].should include "first_line" + yank_entries[-1].should include "line to overwrite" + end + end + end + end + + describe "typing the `substitute_older_paste` key without pasting first" do + before { vim.type "" } + + it "overwrites the selection with the most recently yanked string" do + vim.line_number.should == 5 + vim.line.should == "fourth_line" + end + end + + describe "typing the `substitute_newer_paste` key without pasting first" do + before { vim.type "" } + + it "overwrites the selection with the most recently yanked string" do + vim.line_number.should == 5 + vim.line.should == "fourth_line" + end + end + + it "allows pasting with a count" do + vim.type "3p" + + vim.line_number.should == 5 + vim.line.should == "fourth_line" + + vim.normal 'j' + vim.line_number.should == 6 + vim.line.should == "fourth_line" + + vim.normal 'j' + vim.line_number.should == 7 + vim.line.should == "fourth_line" + end + end + + context "in insert mode" do + before do + vim.normal "A", "()", "" + vim.type "" + end + + describe "typing the `substitute_older_paste` after a character-wise yank" do + it "pastes the most recently yanked text after the cursor" do + vim.line_number.should == 5 + vim.line.should == "(fourth_line)" + end + + it "stays in insert mode, with the cursor at the end of the pasted text" do + vim.should be_in_insert_mode + vim.column_number.should == "(fourth_line".length + 1 + end + + describe "typing the `substitute_older_paste` key again" do + before { vim.type "" } + + it "replaces the pasted text with the previously yanked text" do + vim.line_number.should == 5 + vim.line.should == "(third_line)" + end + + it "stays in insert mode, with the cursor at the end of the pasted text" do + vim.should be_in_insert_mode + vim.column_number.should == "(third_line".length+1 + end + + it "rotates the previously yanked text to the top of the yank stack" do + yank_entries[0].should include 'third_line' + yank_entries[1].should include 'second_line' + yank_entries[2].should include 'first_line' + yank_entries[-1].should include 'fourth_line' + end + + it "rotates through the yanks when pressed multiple times" do + vim.type "" + vim.line_number.should == 5 + vim.line.should == "(second_line)" + + vim.type "" + vim.line_number.should == 5 + vim.line.should == "(first_line)" + + vim.type "" + vim.line_number.should == 5 + vim.line.should == "(second_line)" + + vim.type "" + vim.line_number.should == 5 + vim.line.should == "(third_line)" + + vim.type "" + vim.line_number.should == 5 + vim.line.should == "(fourth_line)" + end + end + end + + describe "typing `substitute_older_paste` after a line-wise yank" do + let(:yank_keys) { "yy" } + + xit "pastes and puts the cursor after the pasted text" do + vim.line_number.should == 6 + vim.line.should == ")" + vim.type "" + vim.line.should == "(fourth_line" + end + end + end + end + + describe "when using the normal default register" do + it_has_behavior "yanking and pasting" + end + + describe "when using the system clipboard as the default register" do + before { vim.set "clipboard", "unnamed" } + it_has_behavior "yanking and pasting" + end + + def yank_entries + @yank_entries ||= vim.command("Yanks").split("\n")[1..-1] + end +end + diff --git a/temp_dirs/undodir/.gitignore b/temp_dirs/undodir/.gitignore new file mode 100644 index 00000000..47e856eb --- /dev/null +++ b/temp_dirs/undodir/.gitignore @@ -0,0 +1,2 @@ +# http://stackoverflow.com/a/932982 +!.gitignore diff --git a/temp_dirs/undodir/README.md b/temp_dirs/undodir/README.md new file mode 100644 index 00000000..37f6debe --- /dev/null +++ b/temp_dirs/undodir/README.md @@ -0,0 +1 @@ +Undo dir for VIM diff --git a/update_plugins.py b/update_plugins.py index 5ea87f24..07116c96 100644 --- a/update_plugins.py +++ b/update_plugins.py @@ -19,7 +19,7 @@ PLUGINS = """ ack.vim https://github.com/mileszs/ack.vim ag.vim https://github.com/rking/ag.vim bufexplorer https://github.com/corntrace/bufexplorer -ctrlp.vim https://github.com/kien/ctrlp.vim +ctrlp.vim https://github.com/ctrlpvim/ctrlp.vim mayansmoke https://github.com/vim-scripts/mayansmoke nerdtree https://github.com/scrooloose/nerdtree nginx-vim-syntax https://github.com/evanmiller/nginx-vim-syntax @@ -40,8 +40,6 @@ vim-surround https://github.com/tpope/vim-surround vim-expand-region https://github.com/terryma/vim-expand-region vim-multiple-cursors https://github.com/terryma/vim-multiple-cursors vim-fugitive https://github.com/tpope/vim-fugitive -vim-airline https://github.com/vim-airline/vim-airline -vim-airline-themes https://github.com/vim-airline/vim-airline-themes goyo.vim https://github.com/junegunn/goyo.vim vim-zenroom2 https://github.com/amix/vim-zenroom2 syntastic https://github.com/scrooloose/syntastic @@ -52,6 +50,8 @@ vim-gitgutter https://github.com/airblade/vim-gitgutter gruvbox https://github.com/morhetz/gruvbox vim-flake8 https://github.com/nvie/vim-flake8 vim-pug https://github.com/digitaltoad/vim-pug +vim-yankstack https://github.com/maxbrunsfeld/vim-yankstack +lightline.vim https://github.com/itchyny/lightline.vim """.strip() GITHUB_ZIP = '%s/archive/master.zip' diff --git a/vimrcs/basic.vim b/vimrcs/basic.vim index 8c579772..837469f7 100644 --- a/vimrcs/basic.vim +++ b/vimrcs/basic.vim @@ -84,9 +84,9 @@ set wildmenu " Ignore compiled files set wildignore=*.o,*~,*.pyc if has("win16") || has("win32") - set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store -else set wildignore+=.git\*,.hg\*,.svn\* +else + set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store endif "Always show current position @@ -199,17 +199,13 @@ set wrap "Wrap lines """""""""""""""""""""""""""""" " Visual mode pressing * or # searches for the current selection " Super useful! From an idea by Michael Naumann -vnoremap * :call VisualSelection('f', '') -vnoremap # :call VisualSelection('b', '') +vnoremap * :call VisualSelection('', '')/=@/ +vnoremap # :call VisualSelection('', '')?=@/ """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Moving around, tabs, windows and buffers """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Treat long lines as break lines (useful when moving around in them) -map j gj -map k gk - " Map to / (search) and Ctrl- to ? (backwards search) map / map ? @@ -260,12 +256,7 @@ catch endtry " Return to last edit position when opening files (You want this!) -" autocmd BufReadPost * -" \ if line("'\"") > 0 && line("'\"") <= line("$") | -" \ exe "normal! g`\"" | -" \ endif -" Remember info about open buffers on close -" set viminfo^=% +au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif """""""""""""""""""""""""""""" @@ -275,7 +266,7 @@ endtry set laststatus=2 " Format the status line -set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l +set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l\ \ Column:\ %c """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" @@ -284,7 +275,7 @@ set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ " Remap VIM 0 to first non-blank character map 0 ^ -" Move a line of text using ALT+[jk] or Comamnd+[jk] on mac +" Move a line of text using ALT+[jk] or Command+[jk] on mac nmap mz:m+`z nmap mz:m-2`z vmap :m'>+`mzgv`yo`z @@ -384,14 +375,10 @@ function! VisualSelection(direction, extra_filter) range let l:pattern = escape(@", '\\/.*$^~[]') let l:pattern = substitute(l:pattern, "\n$", "", "") - if a:direction == 'b' - execute "normal ?" . l:pattern . "^M" - elseif a:direction == 'gv' + if a:direction == 'gv' call CmdLine("Ag \"" . l:pattern . "\" " ) elseif a:direction == 'replace' call CmdLine("%s" . '/'. l:pattern . '/') - elseif a:direction == 'f' - execute "normal /" . l:pattern . "^M" endif let @/ = l:pattern diff --git a/vimrcs/extended.vim b/vimrcs/extended.vim index b0c0d35b..499959a2 100644 --- a/vimrcs/extended.vim +++ b/vimrcs/extended.vim @@ -21,12 +21,6 @@ elseif has("unix") set gfn=Monospace\ 11 endif -" Open MacVim in fullscreen mode -if has("gui_macvim") - set fuoptions=maxvert,maxhorz - au GUIEnter * set fullscreen -endif - " Disable scrollbars (real hackers don't use scrollbars for navigation!) set guioptions-=r set guioptions-=R @@ -34,13 +28,8 @@ set guioptions-=l set guioptions-=L " Colorscheme -if has("gui_running") - set background=dark - colorscheme peaksea -else - colorscheme desert - let g:colors_name="desert" -endif +set background=dark +colorscheme peaksea """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" diff --git a/vimrcs/filetypes.vim b/vimrcs/filetypes.vim index 164454eb..8c4eb9db 100644 --- a/vimrcs/filetypes.vim +++ b/vimrcs/filetypes.vim @@ -17,6 +17,9 @@ au FileType python map 1 /class au FileType python map 2 /def au FileType python map C ?class au FileType python map D ?def +au FileType python set cindent +au FileType python set cinkeys-=0# +au FileType python set indentkeys-=0# """""""""""""""""""""""""""""" @@ -54,3 +57,11 @@ endfunction au FileType coffee call CoffeeScriptFold() au FileType gitcommit call setpos('.', [0, 1, 1, 0]) + + +"""""""""""""""""""""""""""""" +" => Shell section +"""""""""""""""""""""""""""""" +if exists('$TMUX') + set term=screen-256color +endif diff --git a/vimrcs/plugins_config.vim b/vimrcs/plugins_config.vim index da48f593..44d761cb 100644 --- a/vimrcs/plugins_config.vim +++ b/vimrcs/plugins_config.vim @@ -1,5 +1,5 @@ """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Important: +" Important: " This requries that you install https://github.com/amix/vimrc ! " """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" @@ -30,13 +30,10 @@ map f :MRU """""""""""""""""""""""""""""" -" => YankRing +" => YankStack """""""""""""""""""""""""""""" -if has("win16") || has("win32") - " Don't do anything -else - let g:yankring_history_dir = '~/.vim_runtime/temp_dirs/' -endif +nmap yankstack_substitute_older_paste +nmap yankstack_substitute_newer_paste """""""""""""""""""""""""""""" @@ -81,7 +78,7 @@ let NERDTreeShowHidden=0 let NERDTreeIgnore = ['\.pyc$', '__pycache__'] let g:NERDTreeWinSize=35 map nn :NERDTreeToggle -map nb :NERDTreeFromBookmark +map nb :NERDTreeFromBookmark map nf :NERDTreeFind @@ -100,10 +97,32 @@ au FileType mako vmap Si S"i${ _(2f"a) } """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => vim-airline config (force color) +" => lightline """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -let g:airline_theme="luna" +let g:lightline = { + \ 'colorscheme': 'wombat', + \ } +let g:lightline = { + \ 'colorscheme': 'wombat', + \ 'active': { + \ 'left': [ ['mode', 'paste'], + \ ['fugitive', 'readonly', 'filename', 'modified'] ], + \ 'right': [ [ 'lineinfo' ], ['percent'] ] + \ }, + \ 'component': { + \ 'readonly': '%{&filetype=="help"?"":&readonly?"🔒":""}', + \ 'modified': '%{&filetype=="help"?"":&modified?"+":&modifiable?"":"-"}', + \ 'fugitive': '%{exists("*fugitive#head")?fugitive#head():""}' + \ }, + \ 'component_visible_condition': { + \ 'readonly': '(&filetype!="help"&& &readonly)', + \ 'modified': '(&filetype!="help"&&(&modified||!&modifiable))', + \ 'fugitive': '(exists("*fugitive#head") && ""!=fugitive#head())' + \ }, + \ 'separator': { 'left': ' ', 'right': ' ' }, + \ 'subseparator': { 'left': ' ', 'right': ' ' } + \ } """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Vimroom @@ -140,7 +159,7 @@ func! SyntasticCheckCoffeescript() execute "SyntasticCheck" execute "Errors" endfunc -nnoremap l :call SyntasticCheckCoffeescript() +nnoremap c :call SyntasticCheckCoffeescript() """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""