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

feature request: Jump current file #37

Closed
1 task done
thevan96 opened this issue Jan 17, 2023 · 3 comments
Closed
1 task done

feature request: Jump current file #37

thevan96 opened this issue Jan 17, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@thevan96
Copy link

Did you check existing requests?

  • I have searched the existing issues

Describe the feature

How to jump to the current file open in oil buffer but cursor under the name file? Default now the cursor is on top

Provide background

I don't want to open the current folder of the current file and then must search the name file current again

Additional details

No response

@thevan96 thevan96 added the enhancement New feature or request label Jan 17, 2023
@stevearc
Copy link
Owner

There's already some logic in place to do what you're asking, but I did find an edge case where it didn't trigger. I fixed that edge case, but I'm not sure if that's the situation you discovered. Could you try it again, and if you still see the issue could give very specific steps to reproduce what you're seeing?

@thevan96
Copy link
Author

thevan96 commented Jan 18, 2023

If you used nerdtree, this feature is like NerdTreeFind, I write the wrap function but not cursor not under the name file.

function! JumpFile()
  let file_name = expand('%:p:t')
  Oil %:p:h
  call search(file_name)
endfunction
command! JumpFile call JumpFile()

Plug 'stevearc/oil.nvim'
nnoremap <leader>ff :JumpFile<cr>
nnoremap <leader>fv :vsp+JumpFile<cr>
nnoremap <leader>fs :sp+JumpFile<cr>

@stevearc
Copy link
Owner

So the reason that search() doesn't work is that Oil is async and so the buffer contents actually get rendered a millisecond or two after opening the buffer. If you want to open the parent directory, you should just run :Oil with no arguments. That will open the dir and jump the cursor to the location of the file you were just in. When you run :Oil <path> it disables any jumping logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants