Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filename completion #34

Closed
cvlmtg opened this issue Oct 24, 2016 · 10 comments
Closed

filename completion #34

cvlmtg opened this issue Oct 24, 2016 · 10 comments

Comments

@cvlmtg
Copy link

cvlmtg commented Oct 24, 2016

would it be possible to make filename completion relative to file directory instead of current working directory? setting autochdir in vim breaks other things, so it isn't really an option.

thanks!

@ghost
Copy link

ghost commented Oct 24, 2016

Filename completion works that way, but first you need to type ./ before filename. Then you can even go "up" in the directory tree without problems.

@cvlmtg
Copy link
Author

cvlmtg commented Oct 25, 2016

no, it doesn't work that way.

let's say I have this project:

tmp
  project
    app
      stores
        a-store.js
      components
        a-component.jsx

the CWD is /tmp/project and I'm editing app/components/a-component.jsx. If I want to include the store, this is what happens:

schermata 2016-10-25 alle 10 05 24

as you can see when adding ./ the completion start from the working directory and not the file directory.

@josefson
Copy link

As @maln0ir said, that's how vim's filename completion works.
Try loading your app/components/a-component.jsx from /tmp/project with vim -u NONE -N path/to/a-component.jsx. This will open vanilla/default vim.
Now try vim default filename completion: ./ + it will suggest files from CWD instead of the buffer/file directory.

@cvlmtg
Copy link
Author

cvlmtg commented Oct 30, 2016

As @maln0ir said, that's how vim's filename completion works.

sorry, I understood it as "it's already working the way you are asking". anyway, neocomplete is able to make file completion working relative to the file dir even if autochdir is not set. I've seen file completion is handled via python in completor, so I suppose it might be possibile to make it work relative to the file dir here too, but I don't know python :)

@amadeus
Copy link

amadeus commented Nov 10, 2016

I came from Neocomplete as well, and this would be super helpful to have since I often like to keep my current pwd at a project level, and not a file level.

@aliev
Copy link

aliev commented Dec 12, 2016

@cvlmtg why not to use set autochdir? or the most smart and quick fix (if you're using nerdtree or want to keep project root):

autocmd InsertEnter * let save_cwd = getcwd() | set autochdir
autocmd InsertLeave * set noautochdir | execute 'cd' fnameescape(save_cwd)

taken from here http://superuser.com/questions/604122/vim-file-name-completion-relative-to-current-file

@cvlmtg
Copy link
Author

cvlmtg commented Dec 12, 2016

@aliev setting autochdir breaks a lot of things in my workflow. I'll try the "smart" fix even if it's annoying to see the file path in the status bar change every time I enter or leave insert mode. I still think it would be more correct fix this in completor and not in my vimrc

@SageEx
Copy link

SageEx commented Feb 4, 2017

Support for this would be really nice.

@maralla
Copy link
Owner

maralla commented Feb 6, 2017

Now the filename completion is relative to current editing file directory. #74

@amadeus
Copy link

amadeus commented Feb 6, 2017

You are a god amongst men. Thank you!

@maralla maralla closed this as completed Nov 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants