Closed IgorGee closed 4 years ago
I don't get the question or request. It seems what you explained is what exactly this plugin (fern-mapping-project-top.vim) does.
This plugin is providing the action to take to me to the project top. But I'd like this to happen automatically when I open fern.
I tried implementing that functionality according to the wiki, but it wasn't working.
But I'd like this to happen automatically when I open fern.
I'm not sure if I got your question correctly but it sounds like you'd like to open fern on the project root of the current working directory right?
Then
e.g.
function! s:my_fern() abort
let path = getcwd()
let found = find('.git/..', path . ';')
let path = empty(found) ? path : found
let path = fnamemodify(path, ':p')
execute printf('Fern %s', fnameescape(path))
endfunction
nnoremap <silent> <Leader>f :<C-u>call <SID>my_fern()<CR>
Almost.
Say I have the following directory:
dotfiles/x/.c/n/m/zsh
And the following file:
dotfiles/x/.c/n/m/zsh/abc.sh
If I'm editing abc.sh
while my pwd
is dotfiles/x/.c/n/m/zsh
and I open fern, I want fern to show me everything underneath dotfiles, and the cursor on abc.sh
.
This is my desired end-result when opening fern while editing post-compinit.zsh
:
If fern-action-project-top
is triggered from here:
This is my end result:
Then use -reveal=%
like
function! s:my_fern() abort
let path = getcwd()
let found = find('.git/..', path . ';')
let path = empty(found) ? path : found
let path = fnamemodify(path, ':p')
execute printf('Fern %s -reveal=%%', fnameescape(path))
endfunction
nnoremap <silent> <Leader>f :<C-u>call <SID>my_fern()<CR>
Ah, I think I got it. Yes, the project-top
action does NOT reveal. I'll add extra mappings for that.
Please update the plugin and try project-top:reveal
action. @IgorGee
Perfect.
I appreciate the quick responses and turnaround!
I see there is a section in the wiki about this, but I was unable to get it to work.
Wiki
Not sure if it's outdated, because I don't see any references to
fern-my-enter-project-root
.Here is what I have: