Friday, May 11, 2012

Re: Introduction to omnifunc / complete-functions

If you download that archive, which files does it contain?

./syntax/octave.vim

Now there is one file only. Try to find all functions which look similar
to the one found in the help.
The only function I've found is:

function! s:CheckForFunctions()

Does it take 2 arguments such as the sample from help?

fun! CompleteMonths(findstart, base)

No. Thus is this plugin likely to provide what you're looking for?
No.

http://www.vim.org/scripts/script.php?script_id=3600
Now reread the description:

OMNIFUNC
* The syntax file has a list of every valid function in Octave which
* makes it useful as an auto-completion dictionary for use with ViM's
* omnifunc function. Once installed, type a few letters of the name of
* a function and then use Ctrl-X Ctrl-O to bring up a list of possible
* matches.

How to enable such completion? Don't know exactly. Eg open the syntax
file and use ctrl-n - AFAIK that completes all words found in all open
buffers. (Most simple - only useful enough to know in same cases).

Googling finds two ways:
http://vim.wikia.com/wiki/Completion_using_a_syntax_file
and
http://www.vim.org/scripts/script.php?script_id=3172

wait - what did the description say?

\ setlocal omnifunc=syntaxcomplete#Complete |

Now you have to know that all words having a # are actually paths.
Eg sytnaxcomplete#Something is actually syntaxcomplete.vim
a#b#Foo is a/b.vim etc.

So let's have a look at vim's runtime files. Does it ship with that
autoload function?

:e $VIMRUNTIME/**/*syntaxcomplete.vim<tab>

Yeah - a path is found. Thus copy pasting that code or running
setlocal omnifunc=syntaxcomplete#Complete in any way is all you have to
do to make c-x c-o work. Don't know exactly how the script_id 3172
differs from that implementation (You may find out by looking at authors
dates and comparing)

How does it do it? Basically it processes the output of :syntax list
somehow:

redir @l
silent! exec 'syntax list '.join(list_parms)
redir END

syntax list does not show anything of interest?
Add this to your ~/.vimrc:

filetype indent plugin on | syn on

Still trouble? Write again.


How to improve this all? By more dynamic: Extract functions from
system('octave', "help --list") output somehow, see
http://www.gnu.org/software/octave/doc/interpreter/Getting-Help.html (2.3)
You can even use doc .. and display function documentation then.

If you want to do this I can help you implementing caches etc. Contact
me off list so that we can implement this all so that you can distribute
and maintain your first plugin.

Marc Weber

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: