Skip to content

I made some minor modifications #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tags
19 changes: 18 additions & 1 deletion doc/eteSkeleton.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,23 @@ Once the skeleton is loaded, the tags in the "test_script.py" file will be
replaced by the tags in eteSskeleton.tags (which are located in the plugin
directory).

You can enable loose filename matching by setting g:EteSkeleton_loosefiletype
to true in your ~/.vimrc. This will cause any filename to match against a
skeleton file regardess of the _.

example >
let g:EteSkeleton_loosefiletype = 1

~/.vim/skeleton/python
~/.vim/skeleton/test_python

:e test.py

In this case, |eteSkeleton| will load "test_python" skeleton file.




==============================================================================
USAGE *eteSkeleton-usage*

Expand Down Expand Up @@ -106,7 +123,7 @@ COMMANDS *eteSkeleton-commands*
TAGS *eteSkeleton-tags*

Tags are a simple list of tagname=tagvalue stored in the "eteSkeleton.tags"
file (which is located in the plugin folder). It can be manually edited or
file (which is located in the $VIMRUNTIME/skeleton/tags folder). It can be manually edited or
modified by the eteSkeleton commands. Please note that the {tagname} must be
written without the <> symbols in the tag list; however, as the {tagvalue} will
be evaluated, you must use quotes (i.e. " ") when you write Strings.
Expand Down
70 changes: 47 additions & 23 deletions plugin/eteSkeleton.vim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
" eteSkeleton
" Autor: ellethee <[email protected]>
" Autor: ellethee <[email protected]>
" Version: 1.0.1
" License: MIT
" Last change: 2010 Dec 14
Expand All @@ -26,12 +26,20 @@
if exists("g:loaded_eteSkeleton") || &cp
finish
endif
let g:loaded_eteSkeleton = 101
let g:loaded_eteSkeleton = 101
let s:save_cpo = &cpo
let s:ETES_SKELETONS = "skeleton"
let s:ETES_TAGS = globpath(&rtp,"plugin/eteSkeleton.tags")
let s:ETES_TAGS = globpath(&rtp,s:ETES_SKELETONS."/tags/eteSkeleton.tags")
set cpo&vim

if !exists("s:ETES_TAGS")
echom "Can't find " $HOME."/.vim/".s:ETES_SKELETONS."/tags/eteSkeleton.tags"
endif

if !exists("g:EteSkeleton_loosefiletype")
let g:EteSkeleton_loosefiletype = 0
endif

command! -nargs=0 EteSkeleton call s:eteSkeleton_get()
command! -nargs=0 EteSkelList call s:eteSkeleton_list()
command! -nargs=1 EteSkelAdd call s:eteSkeleton_add(<q-args>)
Expand All @@ -51,21 +59,29 @@ fu! s:eteSkeleton_makeskel(...)
echo "Creo lo skeletro: ".l:path."/".l:name
exec ":w! ".l:path."/".l:name
exec ":e! ".l:path."/".l:name
endfu
endfu
fu! s:msort(l1, l2)
return len(a:l2) - len(a:l1)
endfu
fu! s:eteSkeleton_list()
for riga in readfile(s:ETES_TAGS)
echo riga
endfor
if exists("s:ETES_TAGS")
for riga in readfile(s:ETES_TAGS)
echo riga
endfor
else
echo "No tags"
endif
endfu
fu! s:eteSkeleton_addtag()
let l:cword = expand("<cWORD>")
if len(l:cword)
call s:eteSkeleton_add(l:cword)
if exists("s:ETES_TAGS")
let l:cword = expand("<cWORD>")
if len(l:cword)
call s:eteSkeleton_add(l:cword)
else
echoerr "Posizionarsi su di una parola"
endif
else
echoerr "Posizionarsi su di una parola"
echoerr "no tagfile found"
endif
endfu
fu! s:eteSkeleton_add(tag)
Expand All @@ -87,25 +103,31 @@ fu! s:eteSkeleton_add(tag)
call writefile(l:lista, s:ETES_TAGS)
endfu
fu! s:eteSkeleton_del(tag)
let l:tag = substitute(substitute(a:tag,"<","",""),">","","")
let l:lista = readfile(s:ETES_TAGS)
call filter(l:lista,'v:val !~ "^'.l:tag.'="')
call writefile(l:lista, s:ETES_TAGS)
if exists("s:ETES_TAGS")
let l:tag = substitute(substitute(a:tag,"<","",""),">","","")
let l:lista = readfile(s:ETES_TAGS)
call filter(l:lista,'v:val !~ "^'.l:tag.'="')
call writefile(l:lista, s:ETES_TAGS)
endif
endfu
fu! s:eteSkeleton_replace()
for l:riga in readfile(s:ETES_TAGS)
if l:riga[0] != '"' && len(l:riga[0]) != 0
let l:vals = split(l:riga, "=")
let l:vals = split(l:riga, "=")
for l:idx in range(1,line("$"))
if getline(l:idx) =~ "<".l:vals[0].">"
silent! exec l:idx."s/<".l:vals[0].">/".eval(l:vals[1])
silent! exec l:idx."s#<".l:vals[0].">#".eval(l:vals[1])."#g"
endif
endfor
endif
endfor
endfu
fu! s:eteSkeleton_get()
let l:fname = expand("%:r")
if g:EteSkeleton_loosefiletype
let l:fname = expand("%:t:r") . "_" . &l:filetype
else
let l:fname = expand("%:t:r")
endif
let l:rlist = sort(map(split(globpath(&rtp, s:ETES_SKELETONS."/*".
\&l:filetype."*"),"\n"),'fnamemodify(v:val,":t")'), "s:msort")
for l:item in l:rlist
Expand All @@ -114,16 +136,18 @@ fu! s:eteSkeleton_get()
\l:item))
if len(l:pfile)
silent keepalt 0 read `=join(l:pfile)`
call s:eteSkeleton_replace()
if exists("s:ETES_TAGS")
call s:eteSkeleton_replace()
endif
endif
break
endif
endfor
return
endfu
return
endfu
fu! s:eteSkeleton_check()
if &l:filetype != ""
execute "EteSkeleton"
execute "EteSkeleton"
endif
return
endfu
Expand All @@ -135,4 +159,4 @@ augroup END
let &cpo= s:save_cpo
unlet s:save_cpo

" vim:fdm=marker:
" vim:fdm=marker tw=4 sw=4: