From 8dce3bfd6711d8839cba745ca96e0c7d0203afa7 Mon Sep 17 00:00:00 2001 From: Bill Niblock Date: Wed, 8 Jul 2015 15:09:18 -0400 Subject: [PATCH] Re-add templates as submodule (inital confusion resolved). --- .gitmodules | 3 + vim/README.md | 5 +- vim/vim/bundle/vim-templates | 1 + vim/vim/bundle/vim-templates/.gitattributes | 4 -- vim/vim/bundle/vim-templates/LICENSE | 21 ------- vim/vim/bundle/vim-templates/README.md | 23 ------- .../bundle/vim-templates/plugin/templates.vim | 62 ------------------- .../{bundle/vim-templates => }/templates/html | 0 .../{bundle/vim-templates => }/templates/perl | 0 .../{bundle/vim-templates => }/templates/post | 0 .../{bundle/vim-templates => }/templates/sh | 0 11 files changed, 7 insertions(+), 112 deletions(-) create mode 160000 vim/vim/bundle/vim-templates delete mode 100644 vim/vim/bundle/vim-templates/.gitattributes delete mode 100644 vim/vim/bundle/vim-templates/LICENSE delete mode 100644 vim/vim/bundle/vim-templates/README.md delete mode 100644 vim/vim/bundle/vim-templates/plugin/templates.vim rename vim/vim/{bundle/vim-templates => }/templates/html (100%) rename vim/vim/{bundle/vim-templates => }/templates/perl (100%) rename vim/vim/{bundle/vim-templates => }/templates/post (100%) rename vim/vim/{bundle/vim-templates => }/templates/sh (100%) diff --git a/.gitmodules b/.gitmodules index e85d93a..5b268ac 100644 --- a/.gitmodules +++ b/.gitmodules @@ -16,3 +16,6 @@ [submodule "dotbot"] path = dotbot url = https://github.com/anishathalye/dotbot +[submodule "vim/vim/bundle/vim-templates"] + path = vim/vim/bundle/vim-templates + url = https://github.com/ap/vim-templates.git diff --git a/vim/README.md b/vim/README.md index 9861005..6ef4476 100644 --- a/vim/README.md +++ b/vim/README.md @@ -14,14 +14,15 @@ Additionally, I have several extensions, as submodules, in .vim/bundle: * [Sneak](https://github.com/justinmk/vim-sneak) for getting around. * [Vinegar](https://github.com/tpope/vim-vinegar) for a convenient directory browser. -* and [Pathogen](https://github.com/tpope/vim-pathogen) to do the hard work. +* [Pathogen](https://github.com/tpope/vim-pathogen) to do the hard work. +* [Templates](https://github.com/ap/vim-templates.git) for easy templates. ###Font I prefer using the Droid Monospace font for powerline, which is bundled here for convenience. ####To-Do -* [ ] Customize Airline more. +* [ ] (Optional) Customize Airline more. * [ ] Consider adding [gist-vim](https://github.com/mattn/gist-vim) due to prevalence of Gist at work * [ ] Consider adding [vim-notes](https://github.com/xolox/vim-notes) and/or diff --git a/vim/vim/bundle/vim-templates b/vim/vim/bundle/vim-templates new file mode 160000 index 0000000..be2feee --- /dev/null +++ b/vim/vim/bundle/vim-templates @@ -0,0 +1 @@ +Subproject commit be2feeee0cb0e0790cdbfa4b0c602850a03d0f2a diff --git a/vim/vim/bundle/vim-templates/.gitattributes b/vim/vim/bundle/vim-templates/.gitattributes deleted file mode 100644 index 2700f94..0000000 --- a/vim/vim/bundle/vim-templates/.gitattributes +++ /dev/null @@ -1,4 +0,0 @@ -/plugin/templates.vim export-subst -/.gitattributes export-ignore -/README.md export-ignore -/LICENSE export-ignore diff --git a/vim/vim/bundle/vim-templates/LICENSE b/vim/vim/bundle/vim-templates/LICENSE deleted file mode 100644 index 287af79..0000000 --- a/vim/vim/bundle/vim-templates/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2014 Aristotle Pagaltzis - -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. diff --git a/vim/vim/bundle/vim-templates/README.md b/vim/vim/bundle/vim-templates/README.md deleted file mode 100644 index 5590c19..0000000 --- a/vim/vim/bundle/vim-templates/README.md +++ /dev/null @@ -1,23 +0,0 @@ -This is a Vim plugin for providing filetype-dependent templates for new files, using a simple but effective mechanism. - - -Usage ------ - -When you start a fresh buffer, setting a `filetype` on it will load the corresponding template. E.g. open Vim and issue - - :setf html - -You should find a skeleton HTML file, ready to fill in. - -One new command has been added for convenience: it is called `:New` and takes exactly one argument. It will open a new empty window and set the filetype for it to the argument given. - -A handful of templates are included, but the real purpose of the plugin is to allow you to easily create your own. - - -Creating templates ------------------- - -Templates are kept in `.vim/templates`. The template filename must be equal to the `filetype`. So when you set the filetype of an empty buffer to `html`, `.vim/templates/html` will be loaded. It's that simple. - -In the templates, you can use a `cursorline` directive to specify a position for the cursor after loading the template. Such a cursorline works much like a modeline: the word `cursor:` must appear, followed by one or two numbers and opionally the word `del`, all separated by whitespace. The first number specifies the line the cursor will be placed in. The second, if present, specifies a column. The optional word `del` directs the script to remove the cursorline at load time. Take a look at the templates supplied in the package, it should be fairly self-explanatory. diff --git a/vim/vim/bundle/vim-templates/plugin/templates.vim b/vim/vim/bundle/vim-templates/plugin/templates.vim deleted file mode 100644 index 04f5d92..0000000 --- a/vim/vim/bundle/vim-templates/plugin/templates.vim +++ /dev/null @@ -1,62 +0,0 @@ -" Vim global plugin for providing templates for new files -" Licence: The MIT License (MIT) -" Commit: $Format:%H$ -" {{{ Copyright (c) 2015 Aristotle Pagaltzis -" -" 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. -" }}} - -if exists( 'g:loaded_template' ) | finish | endif -let g:loaded_template = 1 - -augroup template - autocmd! - autocmd FileType * if line2byte( line( '$' ) + 1 ) == -1 | call s:loadtemplate( &filetype ) | endif -augroup END - -function! s:globpathlist( path, ... ) - let i = 1 - let result = a:path - while i <= a:0 - let result = substitute( escape( globpath( result, a:{i} ), ' ,\' ), "\n", ',', 'g' ) - if strlen( result ) == 0 | return '' | endif - let i = i + 1 - endwhile - return result -endfunction - -function! s:loadtemplate( filetype ) - let templatefile = matchstr( s:globpathlist( &runtimepath, 'templates', a:filetype ), '\(\\.\|[^,]\)*', 0 ) - if strlen( templatefile ) == 0 | return | endif - silent execute 1 'read' templatefile - 1 delete _ - if search( 'cursor:', 'W' ) - let cursorline = strpart( getline( '.' ), col( '.' ) - 1 ) - let y = matchstr( cursorline, '^cursor:\s*\zs\d\+\ze' ) - let x = matchstr( cursorline, '^cursor:\s*\d\+\s\+\zs\d\+\ze' ) - let d = matchstr( cursorline, '^cursor:\s*\d\+\s\+\(\d\+\s\+\)\?\zsdel\>\ze' ) - if ! strlen( x ) | let x = 0 | endif - if ! strlen( y ) | let y = 0 | endif - if d == 'del' | delete _ | endif - call cursor( y, x ) - endif - set nomodified -endfunction - -command -nargs=1 New new | set ft= diff --git a/vim/vim/bundle/vim-templates/templates/html b/vim/vim/templates/html similarity index 100% rename from vim/vim/bundle/vim-templates/templates/html rename to vim/vim/templates/html diff --git a/vim/vim/bundle/vim-templates/templates/perl b/vim/vim/templates/perl similarity index 100% rename from vim/vim/bundle/vim-templates/templates/perl rename to vim/vim/templates/perl diff --git a/vim/vim/bundle/vim-templates/templates/post b/vim/vim/templates/post similarity index 100% rename from vim/vim/bundle/vim-templates/templates/post rename to vim/vim/templates/post diff --git a/vim/vim/bundle/vim-templates/templates/sh b/vim/vim/templates/sh similarity index 100% rename from vim/vim/bundle/vim-templates/templates/sh rename to vim/vim/templates/sh