Add fzf-complete-path-relative#628
Conversation
|
High expectation about this PR |
|
This works really nice! |
|
I am also looking forward to the request. This function is needed! |
|
+1 |
|
I made an up-to-date fork using this PR and changed the command to And I can say it works really, really well. Please add this in to upstream, that'd make a really useful addition. As far as I can see so far, there's no vim plugins or scripts that can adequately complete relative paths. The combination of fzf, fd and this PR is the best experience of completing paths I've ever had in an editor. |
is there anyway I can implement this by adding your PR's script to my |
|
@ybbond sure, there's not much to it. Here are the three lines in my " I use plug
Plug '/usr/local/opt/fzf'
Plug 'chmanie/fzf.vim'
inoremap <expr> <c-x><c-f> fzf#vim#complete#path_relative('fd')EDIT: Oh sorry, you mean using the upstream fzf.vim? Yeah I tried that as well and failed, too. Maybe it'd be worthwhile to put this into an external plugin that can be included separately. I'm thinking something like |
|
@chmanie yeah, I meant using btw, I noticed your location. Enjoy Indonesia! |
|
@junegunn are there any plans to merge this? |
|
@chmanie This hasn't merged yet, right? |
|
Here is a script if you want to use it with current fzf.vim plugin ( I adopted it to js/ts, but the idea stays the same) https://github.com/dragonofdeath/dotfiles/blob/master/nvim/.vim/scripts/fzf_js_import.vim |
|
I think this also does the trick, no? |
|
@cideM could you please explain, what this commands does? It works! However, it bothers me, that I was trying to solve the same problem via |
|
@cideM this trick was amazing, well done Sir 👏👏. @junegunn maybe worth it a mention on the wiki vim examples ? |
|
Here's a slight adjustment to the excellent command of @cideM, in order to deal with filenames that have spaces: inoremap <expr> <c-x><c-f> fzf#vim#complete("find -print0 <Bar> xargs --null realpath --relative-to " . expand("%:h"))In the line above I use Here's a version using inoremap <expr> <c-x><c-f> fzf#vim#complete("rg --files --hidden --no-ignore --null <Bar> xargs --null realpath --relative-to " . expand("%:h"))To answer the question of @zorgick: |
|
Maybe it's an old thread but I've made this function to insert the filename in the current buffer position '''vim |
|
Tested the PR and it fails when you try to complete an existing path that begins with "./" for example, instead of completing the path relatively to the opened file, it resolves the path and you get a path that is relative to the project. In contrast, the following works as described: |
Hello @junegunn
I've implemented a solution for a feature discussed in #303
Basic use case is to fuzzyfind a file and insert path to it that is relative to buffer.
It helps a lot with languages that do not have library paths (e.g. JavaScript).
Maybe it can help somebody save some time.
Cheers,