Git Product home page Git Product logo

vim-fern-mapping-project-top's Introduction

๐ŸŒฟ fern-mapping-project-top.vim

fern plugin

fern.vim plugin which add project-top mapping to enter a project top.

Usage

This plugin automatically add the following actions to file scheme.

Mapping Action Description
project-top Find .git from the node and enter a found directory
project-top:reveal Find .git from the node and enter a found directory with revealing the cursor node

vim-fern-mapping-project-top's People

Contributors

lambdalisue avatar

Stargazers

Andy Shevchenko avatar  avatar  avatar tg-z avatar Igor avatar Florent avatar Tsuyoshi CHO avatar

Watchers

 avatar James Cloos avatar  avatar

Forkers

aharenaz

vim-fern-mapping-project-top's Issues

[Feature Request] Provide option to always open directory of nearest .git folder

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:

function! s:map_enter_project_root(helper) abort
  " NOTE: require 'file' scheme
  let root = a:helper.get_root_node()
  let path = root._path
  let path = finddir('.git/..', path . ';')
  execute printf('Fern %s', fnameescape(path))
endfunction

function! FernInit() abort
  " Find and enter project root
  nnoremap <buffer><silent>
        \ <Plug>(fern-my-enter-project-root)
        \ :<C-u>call fern#helper#call(funcref('<SID>map_enter_project_root'))<CR>
  nmap <buffer><expr><silent>
        \ ^
        \ fern#smart#scheme(
        \   "^",
        \   {
        \     'file': "\<Plug>(fern-my-enter-project-root)",
        \   }
        \ )
  ...
endfunction

augroup FernGroup
  autocmd!
  autocmd FileType fern call FernInit()
augroup END

Having user defined code that calls a fern action breaks fern

@lambdalisue I call a fern action like:

function! s:init_fern() abort
  call fern#action#call('project-top:reveal')
endfunction
augroup my-fern
  au! *
  au FileType fern call s:init_fern()
augroup END

After re-sourcing config, the drawer shows nothing the first time, then doesn't open at all.

Could it be that fern#action#call('project-top:reveal') is executed too soon?

Thank you for your outstanding modules :)

Doesn't seem to be working

Maybe I'm misunderstanding what this mapping is meant to do.

Given a project like so:

root/
 |
 --abc/
 | |
 | --x.sh
 | --y.sh
 --pqr/
 .git/

When I open x.sh, fern opens with the parent as abc.

abc/
 --x.sh
 --y.sh

My expectation is that pressing ^ will refresh fern to include the root structure I mentioned earlier.

I have the following plugins installed:

fern
fern-git-status
fern-mapping-git
fern-nerdfont
fern-renderer-nerdfont
fern-mapping-project-top

Here are my customizations:

" Disable netrw.
let g:loaded_netrw  = 1
let g:loaded_netrwPlugin = 1
let g:loaded_netrwSettings = 1
let g:loaded_netrwFileHandlers = 1
" Custom settings and mappings.
let g:fern#disable_default_mappings = 1
let g:fern#default_hidden = 1
let g:fern#renderer = "nerdfont"

augroup my-fern-hijack
  autocmd!
  autocmd BufEnter * ++nested call s:hijack_directory()
augroup END

function! s:hijack_directory() abort
  let path = expand('%:p')
  if !isdirectory(path)
    return
  endif
  bwipeout %
  execute printf('Fern %s', fnameescape(path))
endfunction

noremap <silent> <Leader>f :Fern . -drawer -reveal=% -toggle -width=35<CR><C-w>=

function! FernInit() abort
  nmap <buffer><expr>
        \ <Plug>(fern-my-open-expand-collapse)
        \ fern#smart#leaf(
        \   "\<Plug>(fern-action-open:select)",
        \   "\<Plug>(fern-action-expand)",
        \   "\<Plug>(fern-action-collapse)",
        \ )
  nmap <buffer> <CR> <Plug>(fern-action-mark:toggle)j
  nmap <buffer> h <Plug>(fern-action-collapse)
  nmap <buffer> l <Plug>(fern-my-open-expand-collapse)
  nmap <buffer> n <Plug>(fern-action-new-path)
  nmap <buffer> d <Plug>(fern-action-remove)
  nmap <buffer> m <Plug>(fern-action-move)
  nmap <buffer> M <Plug>(fern-action-rename)
  nmap <buffer> r <Plug>(fern-action-reload)
  nmap <buffer> b <Plug>(fern-action-open:split)
  nmap <buffer> v <Plug>(fern-action-open:vsplit)
  nmap <buffer><nowait> < <Plug>(fern-action-leave)
  nmap <buffer><nowait> > <Plug>(fern-action-enter)
  nmap <buffer> ^ <Plug>(fern-action-project-top)
endfunction

augroup FernGroup
  autocmd!
  autocmd FileType fern call FernInit()
augroup END

Disabling these settings has no effect.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.