Deoplete.nvim: Treat the directory of current file as base directory for directory completion

Created on 28 Dec 2015  路  16Comments  路  Source: Shougo/deoplete.nvim

When deoplete attempts to autocomplete relative paths, it seems that it's using the CWD that was set on vim open. I think a better way is to use the directory of the current file as base for autocompletion suggestions.

enhancement

Most helpful comment

@nabn

I think it's more logical. for example, If i'm in a file src/components/Navigation/index.js and I want to import some utility functions from src/Utilities/network_utils.js, it'd be better if the plugin i'm using suggests Utilities when i type in '../../' from the navigation/index.js file.

How about using

set autochdir

All 16 comments

i think is is not a good ideal,for most project,the file path we need complete is not in the directory of current file ,but in some specified path of current project

@wsdjeg This depends on the file used. I think it needs a b:var for this.

@wsdjeg I'm not sure if I follow what you mean.. I primarily work with javascript files where I'm constantly using relative paths to assets, module imports, etc. I've used YouCompleteMe and a couple other completion plugins in the past, they all use the behavior as I'm trying to suggest.
I think it's more logical. for example, If i'm in a file src/components/Navigation/index.js and I want to import some utility functions from src/Utilities/network_utils.js, it'd be better if the plugin i'm using suggests Utilities when i type in '../../' from the navigation/index.js file.

My workflow includes a tmuxinator session with vim opened from the project directory. Do tell me if my setup is too specific to be considered, but I think that's hardly the case..

:echo getcwd() is not you project's root path?
i think the plugin now complete file path bash on getcwd();
for example my project root path is ~/projectT/
contains these files

~/projectT/src/wsdjeg/Foo.java
~/projectT/pic/test.png
~/projectT/utils/test.sh

in vim :echo getcwd() show /home/wsdjeg/projectT/
when i am editting ~/projectT/src/wsdjeg/Foo.java
if i want want use the png file;
i just neet to type ./ then the popup menu contais src,utils,and pic

https://github.com/airblade/vim-rooter
this plugin maybe what you want.

@nabn

I think it's more logical. for example, If i'm in a file src/components/Navigation/index.js and I want to import some utility functions from src/Utilities/network_utils.js, it'd be better if the plugin i'm using suggests Utilities when i type in '../../' from the navigation/index.js file.

How about using

set autochdir

It is worth noting that pluggins like clang_complete and (as far as i know) ternjs cannot find modules imported from the project root without special configuration. At least in these two contexts, the only sane behavior for file completion of relative paths is relative to the file itself.

I agree that this should be a configurable setting, maybe even a language dependent one.

@SageEx I don't recommend to use autochdir option.
It conflicts the plugins.

I can implement this feature. But it is really needed?
If you want to complete the files from the relative path, you should install neoinclude.vim.
Why don't you use neoinclude.vim with deoplete?

If neoinclude does not support your filetypes, neoinclude should be fixed.
I think it is not file source work.

@Shougo Just installing neoinclude does not gives the same behaviour as using ./ and autochdir. How can I configure it ?
What I want is that ./ should complete filename with current file's working directory - that feels more natural and quite useful.

@Shougo Just installing neoinclude does not gives the same behaviour as using ./ and autochdir. How can I configure it ?

It works if the input text is matched include option pattern.

What I want is that ./ should complete filename with current file's working directory - that feels more natural and quite useful.

i think is is not a good ideal,for most project,the file path we need complete is not in the directory of current file ,but in some specified path of current project

So, I think is is natural.
If the exception is nothing, OK. I will change the behaviour.
I don't want to add the option.

@Shougo the g:deoplete#file#enable_buffer_path default value should be 0,let deoplete works like before

OK

thanks!

@Shougo Thanks for the quick fix.

Thanks! It works perfectly with the flag set!

Was this page helpful?
0 / 5 - 0 ratings