Re: colseb_a.vim script, closign tags for vim /java.?

2006-06-11 Thread Luc Hermitte
* On Sun, Jun 11, 2006 at 03:13:22AM +0200, Marc Weber <[EMAIL PROTECTED]> 
wrote:
> I want the script to automatically close 
> 
> function with 
> endfunction
>  [...]
> 
> Using it with java I could imagine to complete
> try {
> 
> with
> } catch () {
> }
> [...]
> But I don't know exactly what to put in here?
> This is my attempt which didn't work yet.
> Can you help me?

Did you search for already existing solutions ?

For instance, I have a set of ftplugins for C&C++ [1] (and another for
VimL, ...) that expand `try', `for', ... in the complete form (with
brackets, placeholders, ...) when not within comment/string literal
contexts.

I know there are a lot of similar [2] solutions out there.

HTH,

[1]  (I have to
upload the UTF-8 friendly version of the plugin)
[2] If you except the context-awareness
-- 
Luc Hermitte
http://hermitte.free.fr/vim/


Re: colseb_a.vim script, closign tags for vim /java.?

2006-06-11 Thread A.J.Mechelynck

Marc Weber wrote:
I want the script to automatically close 

function with 
endfunction


while with
endwhile

for with
endfor
  

[...]

Looks like you have ideas for omni-completion on Vim files. You may want 
to define 'omnifunc' in a script of one of the following names:


user-private on Windows
$HOME/vimfiles/after/ftplugin/vim.vim

user-private on Unix
$HOME/.vim/after/ftplugin/vim.vim

system-wide on any platform
$VIM/vimfiles/after/ftplugin/vim.vim

(Create the directory if it doesn't exist yet.)

You may want to wrap the function definition and the "set omnifunc=" 
statement inside "if exists('+omnifunc')" to avoid errors with version-6 
Vim.


Then once your function is defined, type (in Insert mode) "end" (without 
the quotes) followed by Ctrl-X Ctrl-O and, if applicable, the word 
should be completed to one of "endif" "endwhile" "endfor" "endtry" or 
"endfunction". Hit Ctr-X Ctrl-O on a line with only zero or more spaces 
or tabs before the cursor, and you should get a menu of Ex-commands. And 
so on. The current ftplugin/vim.vim doesn't (yet) set up 
omni-completion, but IMHO it's a blemish -- at some future date (and you 
can help with it if you feel up to the task) the mechanism should become 
integrated within $VIMRUNTIME/ftplugin/vim.vim and described under the 
not-yet-existent ":help ft-vim-omni". (In the meantime, you may document 
what you write, by creating, for instance, a new helpfile named 
"$VIM/vimfiles/doc/omni.txt". Then you'll run ":helptags 
$VIM/vimfiles/doc" once to create (or update) a "tags" file in that 
directory so that from then on your "own" help will be automagically 
integrated with the Vim help on your system.


You may want to use as a source of inspiration the existing 
$VIMRUNTIME/ftplugin/c.vim, $VIMRUNTIME/ftplugin/html.vim, etc., which 
do define omni-completion. Don't change anything in the directory tree 
starting at $VIMRUNTIME, however, because any upgrade may silently 
change it back.


see
:help compl-omni
:help complete-functions
:help 'omnifunc'
:help ft-*-omni or :help ft-*-omni
:help after-directory
:help 'runtimepath'
etc.


Best regards,
Tony


colseb_a.vim script, closign tags for vim /java.?

2006-06-10 Thread Marc Weber
I want the script to automatically close 

function with 
endfunction

while with
endwhile

for with
endfor


Using it with java I could imagine to complete
try {

with
} catch () {
}
or 
} finally () {
}
But I don't know exactly what to put in here?
This is my attempt which didn't work yet.
Can you help me?

" {{{ Configuration for vim
au! FileType vim
\ let b:closeb_openre = '\%(while\|for\|fun\)\)'
\ | let b:closeb_closere = 'end\(while\|for|\fun)\)'
\ | let b:closeb_indentmagic = 0
\ | let b:closeb_skip = 'synIDattr(synIDtrans(synID(line("."), 
col("."), 0)), "name") =~ ' . "'" . 'Comment\|Constant\|PreProc' . "'"
\ | let b:closeb_isopen = "1"
\ | let b:closeb_openname = "mymatch"
\ | let b:closeb_closename = "'end'.mymatch"
\ | let b:closeb_makeclosetag = "'end' . mymatch . ''"
\ | let b:closeb_makeclosemiddle = ""
" note the middle newline ensures nice bevaviour for magicness,
" cutting it out will complicate things
" if makeclosemiddle returns '', makeclosetag will be taken 
instead
" }}}

Marc