Using goto with user-defined modules in jedi-vim - vim

jedi-vim works very well with modules and functions installed on my system. For example, if I put the cursor on glob.glob() and hit <leader>d, jedi-vim brings me to the definition of glob() in /usr/lib/python/.
However, for a user-defined module where a function is imported with a line like
from mymodule import myfunction
jedi-vim may not bring me to the function definition. It instead gives the message "jedi-vim: No documentation found for that" if the modules is not in the same directory as the file I'm editing. Similarly, typing <Shift>k gives the same error message.
Do you know how to make user-defined modules in a different directory work with jedi-vim?

If you want to solve this from within vim, the right variable to set is PYTHONPATH. See this doc.
So if you add this to your .vimrc
let $PYTHONPATH .= ';' . 'path/to/distant/file/'
then Jedi's goto command also works on the distant file.
The . is the vim script string concatenation.

Related

vimrc how to invoke unix find?

i want to set the tags variable to the set of all gotags files i generated in specific folder(s) using exuberant Ctags. (gotags is nothing but the tags file renamed).
i put following lines in my .vimrc file.
set tags+=/usr/local/go/src/gotags
set tags+=`find /home/vimal/gowork/src -name gotags`
but it doesnt work and i get the following error
$ vi ~/.vimrc
Error detected while processing /home/vimal/.vimrc:
line 157:
E518: Unknown option: /home/vimal/gowork/src
Press ENTER or type command to continue
how can i fix the error and set the tags variable with the value: list of all the gotags files under one directory tree.
Inventing new syntax tends not to work that well in practice. Use system() to run external commands from Vim, not backticks. Also set in Vim is weird, it doesn't evaluate RHS the way you expect. Most of the time it's a lot simpler to use let &option = ... instead of set option=....
Anyway, to answer your question, you don't need to run find(1) for that, plain Vim functions are enough for what you want:
let &tags = join(extend([&tags, '/usr/local/go/src/gotags'],
\ findfile('gotags', '/home/vimal/gowork/src', -1)), ',')

How to run in vim plantuml on MacOsX?

Adapting the instructions at http://zbz5.net/sequence-diagrams-vim-and-plantuml, I have this in my .vimrc file on MacOSX Yosemite:
let g:plantuml_executable_script='java -jar /Users/Documents/plantuml.jar'
I have Java installed correctly as "java -version" gives a version number.
In another directory I have a uml file, diag.uml:
#startuml
Alice -> Bob: test
#enduml
When I open vim, type ":" and type g, I get a message saying "Regular expression missing from global". How do I run the expression given by the let variable above?
g:plantuml_executable_script is the name of the variable containing the command to execute; you don't need to type its name into Vim.
Install the plugin mentioned in the article; it'll use g:plantuml_executable_script to set makeprg, and you'll be able to process any PlantUML file by typing :make in Vim.

A function to load a simple plugin acts different when called during start-up

I have simple pseudo vim plugin that I use to test and observe how things are executed by VIM. So here is my function that I use to trigger the plugin:
function! myCore#load_plugin()
let s:plugin_core = '/broadcast/foo/dev/myVimBundles'
echo "---> " . s:plugin_core . " <---"
NeoBundle 'myDummyPlugin', {'name' : 'myDummyPlugin', 'base' : '/broadcast/foo/dev/myVimBundles', 'directory' : 'myDummyPlugin'}
endfunction
So when I call this function as part of a start up script, like for example inside my .vimrc, I can see that the plugin files inside "/myDummyPlugin/plugin" and "/myDummyPlugin/after/plugin" are loaded but the "syntax", "indent" and "ftdetect" are ignored.
However once VIM is started and I call the very same function above, it executes perfectly including all the file type, index and syntax components.
I find this really strange, any ideas?
Thanks.

Find command in vim gets incomplete path

In vim when I'm using :find to open another file, it misses the first component of the relative path.
For example, if I'm looking for a file that's in:
./foo/bar/file.txt
I'll type
:find **/file.txt
It finds the file but then tries to open
bar/file.txt
It works correctly if I type
./**/file.txt
But I'm lazy and don't want to type that much. Is there some config I'm missing that will correctly locate and open this path?
My Solution
I simply appended the main source code dir to my path
exec "set path^=src/**"
Is your 'path' set? That (IMO) is a pretty handy way to keep from even typing the **/ bit.
In my setup, there's an environment variable that defines which project I'm currently in so I use that and construct a path with that as the root. In a nutshell:
let s:rootdir = $PROJECT_DIR
let s:path = 'src/**;' . s:rootdir . ',scripts/**;' . s:rootdir
execute "set path=" . s:path
Then I can just :find a_file.txt and it searches my src hierarchy then my scripts hierarchy for the file.

Vim problem with gf command

I am using Vim and I have set the path (set path+= c:/work/etc/etc) to my project directory (for C#), but still using command 'gf' give me error:
E:447 Can't find file.
Is there anything I am doing wrong over here?
G'day,
To get a bit more detail on your current path settings you can see what's being included and the files vim can't find by entering the command:
:checkpath
and you'll get a dump of the files not found, e.g.
--- Included files not found in path ---
<io.h>
vim.h -->
<functions.h>
<clib/exec_protos.h>
Or you can get a listing of all included files, both found and not found, by entering
:checkpath!
Enter
:help path
to get more info on the path syntax.
Edit: Don't forget that using the syntax
set path=/work
will completely reset your path variable to what you've just declared. I'd suggest using
set path+=/work
instead. This won't clobber the current path and will just add your /work directory instead.
HTH
I also found out that
:set path+=./foo/bar
adds a search location relative to the directory of the current file, just like '.' does.
My vim didn't want to search for such include
#include <common/util/string.h>
So what I needed to do was
:set path+=foo/bar
instead of
:set path+=./foo/bar
The former adds a search path relative to current working directory. Hopefully it helps someone.
First can you open the file using :find file.name ? (:help find for more info). If this does not work then your path is wrong. If :find does locate your file then do the following:
Insure that you are not in Visual/Insert mode
Place cursor on the first letter of the filename and press gf
I know this is an old question, but I also had some troubles with this for another reason and it took me some time to find out why. I hope this might be helpful to someone.
When a directory is matched with wildignore, gf does not work for files in it, nor does :find.
This is obvious if you read wildignore's documentation, but I forgot I ever changed this variable, and what it was for exactly. Also I used a glob, and it was not immediately apparent to me that the directory I was using gf in, was also matched with this glob.
Make sure there is no leading character to the file name if you press gf, i.e. using gf when the cursor is on help.txt will not work here:
file=help.txt
If you are talking about the gf tool wri††en by tomnomnom then here's how to set-up:
Setting PATH for GO (if you have not setup yet).
export GOROOT=$HOME/go
export PATH=$PATH:$GOROOT/bin
Step 1: Download tool from github
Step 2: cp -r path/to/tomnomnom/gf/examples ~/.gf
Step 3: source ~/tools/gf/gf-completion.bash
Now gf should work along with auto-completion from anywhere.
Source: Original sources are present at his repo.

Resources