Re-add templates as submodule (inital confusion resolved).
This commit is contained in:
parent
1a490f7c81
commit
8dce3bfd67
11 changed files with 7 additions and 112 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
1
vim/vim/bundle/vim-templates
Submodule
1
vim/vim/bundle/vim-templates
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit be2feeee0cb0e0790cdbfa4b0c602850a03d0f2a
|
4
vim/vim/bundle/vim-templates/.gitattributes
vendored
4
vim/vim/bundle/vim-templates/.gitattributes
vendored
|
@ -1,4 +0,0 @@
|
|||
/plugin/templates.vim export-subst
|
||||
/.gitattributes export-ignore
|
||||
/README.md export-ignore
|
||||
/LICENSE export-ignore
|
|
@ -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.
|
|
@ -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.
|
|
@ -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 <pagaltzis@gmx.de>
|
||||
"
|
||||
" 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=<args>
|
Loading…
Add table
Add a link
Reference in a new issue