Updated: Comment #18

Problem/Motivation

There are two problems with the vimrc file as created or modified by the installation script for this project:

  1. If the script downloads the current version of pathogen, then the lines added to the vimrc file will not have the correct syntax.
  2. If the user already has a vimrc file, then the script may need to add "filetype plugin on".

Proposed resolution

Update the drush-based installation script.

Remaining tasks

  1. Test whether pathogen is already installed, and which syntax it expects, before adding lines to the vimrc file.
  2. Test whether ftplugins are already enabled before adding the :filetype line.

User interface changes

None.

API changes

None.

None.

Original report by @technicalknocokout

Just tried installing using the drush install instructions, install scripts appeared to run fine without error. Now vim reports the following whenever I edit a file:

Error detected while processing <user path>/.vimrc:
line    3:
E118: Too many arguments for function: pathogen#infect
line    4:
E118: Too many arguments for function: pathogen#infect
Press ENTER or type command to continue

vim --version
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled May 31 2012 14:41:25)
MacOS X (unix) version

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

benjifisher’s picture

Near the top of your vimrc file (i.e., <user path>/.vimrc) there should be a couple of lines like

" Following line added by drush vimrc-install on Sun, 21 Oct 2012 01:03:51 -0400
call pathogen#infect('/Users/benji/.drush/vimrc/bundle')

In fact, judging by the error message, the non-comment part will be lines 3 and 4. What do you have there? Probably the fix will be pretty obvious, and I will have to adjust the script to escape the appropriate characters: spaces, commas?

technicalknockout’s picture

Thanks for the reply! Here is the stuff the script added to my vimrc:

" Following lines added by drush vimrc-install on Tue, 09 Jul 2013 18:19:48 +0000.
set nocompatible
call pathogen#infect('<user path>/.drush/vimrc/bundle')
call pathogen#infect('<user path>/.vim/bundle')
" End of vimrc-install additions.

In the script the actual path to my home folder is where I put <user path>, I just didn't wanna post that.

benjifisher’s picture

That looks normal. Are there any unusual characters in <user path>: spaces, commas, single quotes, backslashes?

The function pathogen#infect() expects one argument. The error message is pretty clear: this function is being called with multiple arguments.

No, wait. It takes a variable number of arguments. It should never generate that error message.

Maybe something is wrong with your version of pathogen. What does
:function pathogen#infect
tell you? The function declaration should be
function! pathogen#infect(...)

Maybe there is something wrong with your version of vim. You gave the first few lines of vim --version, but what features are compiled in? Do you have Huge, Big, Normal, Small, or Tiny version of vim?

What error message, if any, do you get when you call
:call pathogen#infect('<user path>/.drush/vimrc/bundle')
manually?

technicalknockout’s picture

No unusual characters the user path: /Users/ and username is a-z characters.
This is what I get with :function pathogen#infect

   function pathogen#infect()
1    call pathogen#runtime_append_all_bundles()
2    call pathogen#cycle_filetype()
   endfunction

Vim version is Huge version without GUI.
Calling manually I get the same error: E118: Too many arguments for function

benjifisher’s picture

Category: bug » support

Aha: there is something wrong with your version of pathogen. I think it is very old. According to https://github.com/tpope/vim-pathogen/commits/master/autoload/pathogen.v... this function was added on May 13, 2011 as a function with no arguments. On June 13, 2011, the function was modified so that you can optionally specify the path (defaults to ~/.vim/bundle).

I suggest you get the current version of pathogen (~/.vim/autoload/pathogen.vim). If that is not a good option for you, then you could replace the two lines in your vimrc file with
call pathogen#infect()
and then (untested)
$ ln -s <user path>/.drush/vimrc/bundle/vim-plugin-for-drupal ~/.vim/bundle

It is also possible that there is more than one version of pathogen.vim on your system, and the wrong one is being loaded. You should be able to diagnose this with
:scriptnames

I am changing the category to "support request." If my solution works, then please change the status to "fixed."

technicalknockout’s picture

Title: E118: Too many arguments for function: pathogen#infect » Update install script for newest pathogen file
Category: support » feature

Ok, I updated to the latest vim-pathogen and that got rid of the error but not sure yet how to tell if it's working correctly :) I'll do a little more homework, but just wanted to report I got the following messages related to the drush vimrc-install code:

Change pathogen#infect('/Users/<username>/.drush/vimrc/bundle') to pathogen#infect('/Users/<username>/.drush/vimrc/bundle/{}')
Change pathogen#infect('/Users/<username>/.vim/bundle') to pathogen#infect('/Users/<username>/.vim/bundle/{}')

I guess then this might be a feature request? to update for latest pathogen file as of this time...

benjifisher’s picture

Thanks for letting me know about the warnings. I want to think about how to minimize incompatibilities. I prefer the noisy warning messages you get to the silent failure I get when I add "/{}" to the pathogen#infect() lines in my vimrc file.

To see whether it is working correctly, you can check
:set rtp?
If pathogen is working, then this should include all subdirectories of /Users/<username>/.drush/vimrc/bundle and of /Users/<username>/.vim/bundle. You should start to see al the Drupal goodness that this project provides. As a test, edit a PHP file in your Drupal project and try
:echo b:Drupal_info

technicalknockout’s picture

Category: feature » support

OK, I see the .drush/vimrc/bundle and I can run Drush commands with :Drush from vim now - so cool :) I'm also seeing what looks like colored markers for the drupal coding standards. :echo b:Drupal_info throws some errors though:

E121: Undefined variable: b:Drupal_info
E15: Invalid expression: b:Drupal_info

Not sure that's something that needs fixing or something else in my environment - should I be worried about that? Thanks so much for your help!

benjifisher’s picture

What file were you editing when you got the error?

technicalknockout’s picture

Just tried again - error happens when editing
theme template.php
custom module .module file
index.php at drupal root

benjifisher’s picture

If we cannot figure this out quickly, maybe we should open a separate issue.

Those files should all work.

Did you start a new vim session after updating pathogen and editing your vimrc file?

Does
:set ft?
give the result php.drupal?

technicalknockout’s picture

yes it does, for all those files.

benjifisher’s picture

This makes a difference. If b:Drupal_info is not set, then a lot of things will not work.

You did not answer the first question in #11.

OK, I can think of one explanation. If you have simply
:filetype on
in your vimrc file (the leading ":" is optional) that would explain it. If this is the case, then (when editing almost any file--say index.php to be specific)
:echo did_load_ftplugin
should give an error. In this case,

:filetype plugin on
:e!
:echo did_load_ftplugin
:echo b:Drupal_info

should give you different results.

If that is not the right answer, then this is what is supposed to happen, with some tests, when you :e index.php:

  1. The 'filetype' option is set to php.drupal. (Seems to work according to #12. :set ft?)
  2. The filetype plugins (ftplugins) for php and for drupal are :source'd, in that order. (:scriptnames)
  3. When this project's ftplugin/drupal.vim is :source'd, one of the first few lines is :let b:Drupal_info = drupal#DrupalInfo(). (:echo b:Drupal_info

Maybe you can figure out which step is broken.

For the record, what version of this project are you using: 7.x-1.0 or the latest git (only one more commit) or (I hope not) an earlier version?

technicalknockout’s picture

I have exited and started vim every time I change the vimrc file or any vim config- is that what you mean by start a new vim session?

Ok in vim running the following does output some php array for b:Drupal_info

:filetype plugin on
:e!
:echo did_load_ftplugin
:echo b:Drupal_info
technicalknockout’s picture

I'm running whatever version the drush installer installs. Don't really see a changelog or version info in the ~/.drush/vimrc dir. Is there a way to output the version number of a file to check?

benjifisher’s picture

@technicalknockout:

Thanks for helping me figure out what is going on!

The version probably does not matter for this question. If you downloaded with git, then git show should tell you which commit is checked out. You are right, I should include a changelog, especially now that there is a full release (7.x-1.0).

I have exited and started vim every time I change the vimrc file or any vim config- is that what you mean by start a new vim session?

For the record, yes.


The install script creates a vimrc file if you do not already have one. In this case, you would get the line
:source $VIMRUNTIME/vimrc_example.vim

which :source's the example vimrc file that comes with the standard vim distribution. Among other things, this gives you

:filetype plugin indent on

I am pretty sure that you already had a vimrc file, and that it already included

:filetype on

In this case, the install script will add some lines to the start of your vimrc file, mostly related to pathogen. I did not think to check the :filetype settings. I will have to do something about that.

You should be able to get the full benefit from this project by finding the :filetype line in your vimrc file and adding "plugin". Or add

:filetype plugin indent on

or

:source $VIMRUNTIME/vimrc_example.vim
technicalknockout’s picture

Status: Active » Fixed

Yes, it's almost like you're reading my vimrc file :-)

I just added 'plugin' to two lines in my vimrc so they now read as follows:

filetype plugin on
filetype plugin indent on

Now :echo b:Drupal_info outputs an array with keys 'DRUPAL_ROOT', 'TYPE', 'CORE', and 'INFO_FILE'.

Thanks for your help!

benjifisher’s picture

Status: Fixed » Needs work

I still need to update the install script, so I am marking this issue as NW. Maybe I should update the issue summary now that I know what needs to be done.

benjifisher’s picture

Issue summary: View changes

adding vim version info

benjifisher’s picture

benjifisher’s picture

Issue summary: View changes

Update the summary, now that the problems have been diagnosed.

estoyausente’s picture

Same problem. I haven't idea about the solution :-(

Suscribe.

ronaldmulero’s picture

fwiw, here's a patch to add "/{}" to the values of $vimrcbundle and $bundle in vimrc.drush.inc, so that it will install .vimrc with (e.g. OSX):
call pathogen#infect('/Users/[username]/.drush/vimrc/bundle/{}')
call pathogen#infect('/Users/[username]/.vim/bundle/{}')

benjifisher’s picture

Status: Needs work » Fixed
FileSize
2.96 KB

@estoyausente: What problem are you having? During the course of this issue, @technicalknockout had two or three problems, and the discussion above gives solutions to them all. If you are getting warning messages from pathogen because your version of pathogen is not compatible with your version of this project, then do what the messages tell you to do.

@ronaldmulero: See my comment in #7 above for why I do not want to use that solution. Also, your patch would fix only one of the two problems in the issue summary.

I have attached a patch that solves both problems, and (I hope) does not create new ones if you already have an older version of pathogen installed. I will take a chance and commit it without further review, so I am marking this issue fixed.

  • Commit caa02cd on 7.x-1.x:
    Issue #2038201 by benjifisher | technicalknockout: Update install script...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

benjifisher’s picture