[development] Vim for Drupal request

Sam Tresler sam at treslerdesigns.com
Sat Aug 1 13:44:41 UTC 2009


My mistake Victor, .vimrc needs to take an absolute path change

set tags .vim/drupal6.tags

to

set tags ~/.vim/drupal6.tags

if that doesn't work, try manually loading the tags file in vim with
:set tags=/home/yourhome/.vim/drupal6.tags and see if it will work

Good catch on the hooks/ dir, I re-wrote that to have the -d flag as I 
wasn't keen on traversing the entire cvs download to get to the file.

I'll add .inc files to the vim doc as well, as I believe they aren't 
there currently.

Let me know if that works for you.

-S

Victor Kane wrote:
> OK, first of all, thanks so much for the fruits of an idle moment! I use 
> vim all the time now, and this is great.
> 
> Now, a problem and a solution.
> 
> I executed the below cvs statement on the command line
> But since it includes "-d drupal6", it doesn't create a hooks directory, 
> but rather a drupal6 directory.
> Error:
> $ ctags -R -o drupal6.tags hooks
> ctags: Warning: cannot open source file "hooks" : No such file or directory
> 
> So the following does work:
> 
> $ ctags -R -o drupal6.tags drupal6
> 
> Then, you probably want to include .inc files in the list, yielding:
> 
> if has("autocmd")
>   " Drupal *.module and *.install files.
>   augroup module
>     autocmd BufRead,BufNewFile *.module set filetype=php
>     autocmd BufRead,BufNewFile *.install set filetype=php
>     autocmd BufRead,BufNewFile *.inc set filetype=php
>     set tags=.vim/drupal6.tags
>   augroup END
> endif
> 
> However, when editing a file, , Ctrl-] gives error:
> 
> E433: No tags file
> E426: tag not found: drupal_get_form         
> 
> Am I missing something?
> 
> Victor Kane
> http://awebfactory.com.ar
> 
> On Fri, Jul 31, 2009 at 6:58 PM, Sam Tresler <sam at treslerdesigns.com 
> <mailto:sam at treslerdesigns.com>> wrote:
> 
>     You know... it said that at the top of the api.drupal.org
>     <http://api.drupal.org> page, but I guess it didn't occur to me to
>     actually look...   Thanks.
> 
>     Works like a charm.  I'd really rather skip the first incarnation I
>     had, and just have the hooks loaded.  I'll update the vim docs here
>     shortly, but for the record.
> 
> 
>     $ cvs -z6
>     -d:pserver:anonymous:anonymous at cvs.drupal.org:/cvs/drupal-contrib co
>     -r DRUPAL-6--1 -d drupal6 contributions/docs/developer/hooks
>     $ ctags -R -o drupal6.tags hooks
>     $ mv drupal.tags ~/.vim
> 
>     (make the .vim directory if you need to)
> 
>     Then add this to ~/.vimrc
> 
>     if has("autocmd")
>       " Drupal *.module and *.install files.
>       augroup module
>         autocmd BufRead,BufNewFile *.module set filetype=php
>         autocmd BufRead,BufNewFile *.install set filetype=php
>         set tags=.vim/drupal6.tags
>       augroup END
>     endif
> 
>     And you have code-hinting for drupal core in vim.  Just remember to
>     update it as you change versions. But it sounds like in Drupal 7
>     this can scrape directly from .api.php files; I haven't even looked
>     at those yet.
> 
>     Now what was I doing before this diversion....
> 
>     -S
> 
> 
> 
> 
>     Neil Drumm wrote:
> 
>         6.x and lower:
>         http://cvs.drupal.org/viewvc.py/drupal/contributions/docs/developer/hooks/?pathrev=DRUPAL-6--1
>         7.x: *.api.php in module directories.
> 
>         -Neil
> 
>         On Fri, Jul 31, 2009 at 2:03 PM, Sam Tresler
>         <sam at treslerdesigns.com <mailto:sam at treslerdesigns.com>
>         <mailto:sam at treslerdesigns.com <mailto:sam at treslerdesigns.com>>>
>         wrote:
> 
>            Thanks Neil,
>             Some further digging and I found out that php code completion in
>            vim can map to a ctags output file, which is pretty easy to
>         generate.
> 
>            ctags -R -o drupal6.tags --langmap=php:.module *
> 
>            then load it in vim
> 
>            :set tags=drupal6.tags
> 
>            and you have code complete for every function in core.
> 
>            However, this unfortunately doesn't get code complete on
>         hooks, as
>            they aren't actually named in core, but constructed from
>            modulename_function().
> 
>            So, I guess my next question is where are the hook function
>            definitions from api.drupal.org <http://api.drupal.org>
>         <http://api.drupal.org> generated?
> 
> 
>            Thanks in advance.
> 
>            -S
> 
> 
> 
> 
>            Neil Drumm wrote:
> 
>                http://api.drupal.org/api/function_dump/6 might have
>         worked at
>                some point. I honestly haven't paid any attention to that
>         page,
>                which might integrate with IDEs; apparently no one else
>         has either.
> 
>                This list is already available in JSON format in the
>         development
>                version of API module. That or another format should be
>         present
>                in the future for an api_filter module to provide an input
>                format filter without running the api module.
> 
>                -Neil
> 
>                On Fri, Jul 31, 2009 at 12:26 PM, Sam Tresler
>                <sam at treslerdesigns.com <mailto:sam at treslerdesigns.com>
>         <mailto:sam at treslerdesigns.com <mailto:sam at treslerdesigns.com>>
>                <mailto:sam at treslerdesigns.com
>         <mailto:sam at treslerdesigns.com> <mailto:sam at treslerdesigns.com
>         <mailto:sam at treslerdesigns.com>>>>
> 
>                wrote:
> 
>                   I am working on a drupalcomplete.vim file and would
>         like to
>                generate
>                   an list of all of Drupal 6 (and eventually 5,7, etc)
>         functions,
>                   objects, and anything else that might warrant code
>         completion.
> 
>                   I believe that api.drupal.org <http://api.drupal.org>
>         <http://api.drupal.org>
>                <http://api.drupal.org> scrapes this
> 
>                   automatically from core.  I can manipulate the data to
>         match the
>                   format I need no problem, but I thought I would ask
>         here before I
>                   went about finding my own way to scrape the data from
>         a cvs
>                checkout.
> 
>                   This was broached before here
>                        
>         http://lists.drupal.org/pipermail/development/2009-February/032090.html
>                   but appears stalled.
> 
>                   yes, I have too much time on my hands currently.
> 
>                   Cheers. -Sam
> 
> 
> 
> 
>                --        Neil Drumm
>                http://delocalizedham.com
> 
> 
> 
> 
>         -- 
>         Neil Drumm
>         http://delocalizedham.com
> 
> 


More information about the development mailing list