mdreves / vim-scaladoc

Scaladoc for vim
7 stars 4 forks source link

E492: Not an editor command: ScalaDoc #1

Open noahlz opened 11 years ago

noahlz commented 11 years ago

I am getting this error when attempting :ScalaDoc in a scala file.

:help scaladoc works and displays the help text.

Python support is enabled (compile flag +python) and many other plugins work.

Ubuntu 12.04 LTS / Vim 7.3

mdreves commented 11 years ago

At first glance it appears to be installation related. Are you using pathogen or vundle? What directory did you install it to?

noahlz commented 11 years ago

pathogen and .vim/bundle

:help scaladoc works and displays the help file

noahlz commented 11 years ago

What is the minimum Python version? I am using 2.7.3

mdreves commented 11 years ago

2.7.3 is fine. I'm using 2.7.2. I can't see it being a ubunutu issue (I've tested on Mac), but I'll run a quick test later today when I get a chance to make sure.

noahlz commented 11 years ago

Possible solutions:

http://stackoverflow.com/questions/8953777/vim-not-an-editor-command-minibufexplorer

https://github.com/tpope/vim-pathogen/issues/13

mdreves commented 11 years ago

I tried with Ubuntu 12.04 / Vim 7.3 / Python 2.7.3 and it is working fine for me. Can you run this command and paste the output:

:set runtimepath?

noahlz commented 11 years ago

runtimepath=~/.vim,~/.vim/bundle/CSApprox,~/.vim/bundle/Command-T,~/.vim/bundle/aftercolors,~/.vim/bundle/auto-pairs,~/.vim/bundle/conque_2.3,~/.vim/bundle/nerdtree,~/.vim/bundle/paredit.vim,~/.vim/bundle/snipmate.vim,~/.vim/bundle/surround,~/.vim/bundle/taglist_46,~/.vim/bundle/vim-airline,~/.vim/bundle/vim-classpath,~/.vim/bundle/vim-clojure-static,~/.vim/bundle/vim-dispatch,~/.vim/bundle/vim-fireplace,~/.vim/bundle/vim-fugitive,~/.vim/bundle/vim-markdown,~/.vim/bundle/vim-pipe,~/.vim/bundle/vim-redl,~/.vim/bundle/vim-scala,~/.vim/bundle/vim-scaladoc,~/.vim/bundle/vimux,/var/lib/vim/addons ,/usr/share/vim/vimfiles,/usr/share/vim/vim73,/usr/share/vim/vimfiles/after,/var/lib/vim/addons/after,~/.vim/bundle/CSApprox/after,~/.vim/bundle/snipmate.vim/after,~/.vim/bundle/vim-scala/after,~/.vim/after

mdreves commented 11 years ago

It's in your runtime path, so that's not the issue. Maybe try re-install?

cd ~/.vim/bundle rm -rf vim-scaladoc git clone git://github.com/mdreves/vim-scaladoc.git

There should be a ~/.vim/bundle/vim-scaladoc/plugin/scaladoc.vim file that contains the ScalaDoc mapping. You can also try running the following command directly to see if the rest of the installation is working:

:call scaladoc#Search("list")

noahlz commented 11 years ago

It works after I manually execute

command -buffer -nargs=+ ScalaDoc :call scaladoc#Search('<f-args>')

mdreves commented 11 years ago

That's odd, can you restart and run the following:

:echo exists(":ScalaDoc")

noahlz commented 11 years ago

:echo exists(":ScalaDoc") 2

Adding the following to my .vimrc works as well:

nnoremap K :call scaladoc#Search(expand("<cword>"))<CR>

mdreves commented 11 years ago

Did you reinstall? Unless you added the 'command -buffer...' to your .vimrc, after restart :ScalaDoc should have gone back to not working. So you are seeing :echo exists(":ScalaDoc") returning 2, and :ScalaDoc still not working. That's very strange.

I can take out the exists check for :ScalaDoc in my code, although I'm puzzled why it would behave this way. Alternatively you can add the 'command -buffer...' to your .vimrc for a quickfix.

noahlz commented 11 years ago

What's in your vimrc related to this plugin?

I have been trying to resolve this issue on my own for about an hour, and nothing I am trying is working. I am following other plugins such as vim-fireplace (clojure plugin) as a model, as well as attempting some of the patterns described in this blog post by @sjl

http://stevelosh.com/blog/2011/09/writing-vim-plugins/

noahlz commented 11 years ago

I took the following steps:

1) Removed all plugins except pathogen and vim-scaladoc 2) Changed .vimrc to contain only the following:

set nocompatible
call pathogen#infect() 

Result of :ScalaDoc list

Error detected while processing function scaladoc#Search:
line   23:
Traceback (most recent call last):
  File "<string>", line 11, in <module>
  File "/home/noahlz/.vim/bundle/vim-scaladoc/pylibs/scaladoc.py", line 71, in Search
    api_path = _FindLocalDocs(file_name)
  File "/home/noahlz/.vim/bundle/vim-scaladoc/pylibs/scaladoc.py", line 162, in _FindLocalDocs
    (path, tail) = os.path.split(path)
  File "/usr/lib/python2.7/posixpath.py", line 83, in split
    i = p.rfind('/') + 1
AttributeError: 'NoneType' object has no attribute 'rfind'
Press ENTER or type command to continue
mdreves commented 11 years ago

Your original problem doesn't seem to be there anymore. If you can run :ScalaDoc then the mapping is working. The problem you have now is that you are running from an unnamed file and vim-scaladoc uses your local file to try to find a path to local docs. I've uploaded a patch for this so that it will work on unnamed files as well.

Regarding what is in my .vimrc related to this plugin. I've tried it with and without any settings and it works for me. Let me know if you still see issues, although I'm still puzzled by why you were first seeing the :ScalaDoc not found issue. It's as if there was an incomplete download.

noahlz commented 11 years ago

It works when I set up my .vimrc as in this commit

Understood that the error is due to running :ScalaDoc in an unnamed buffer.

noahlz commented 11 years ago

Ok, I have solid reproduction steps for this issue:

1) Only plugin installed with pathogen: vim-scaladoc 2) Only contents of .vimrc:

set nocompatible
call pathogen#infect() 

3) Start vim with just $ vim (don't specify an initial file on the command line). ScalaDoc function does not work.

4) When starting vim with an initial file, i.e. $ vim HelloWorld.scala - it works as advertised.

mdreves commented 11 years ago

If you are referring to the AttributeError, then yes that is the bug fixed by my last push. If you are saying that :ScalaDoc is returning E492 then there is something not right with the installation or at least I can't reproduce it.