Closed timsofteng closed 4 years ago
I've been dreaming such features but it's not easy while I'd like to keep the plugin simple and quick. So it would take loooong time to provide such feature.
It's sad. This is only feature I miss after NERDtree.
I may misunderstood the feature so it would be nice if you explain the feature with some screenshot/screencast in this issue so that people (including me) do not need to install and try NERDTree and its git integration.
I think for berer understanding you could just look at this nerdtree plugin:
https://github.com/Xuyuanp/nerdtree-git-plugin
It's what I mean.
Maybe it integrates with gitgutter plugin. I don't know.
This is git status integration for defx: https://github.com/kristijanhusak/defx-git The icons on the left of each tree node mark the git status.
@rafi I like your indicator. Could you share the config like below?
call defx#custom#column('git', 'indicators', {
\ 'Modified' : '✹',
\ 'Staged' : '✚',
\ 'Untracked' : '✭',
\ 'Renamed' : '➜',
\ 'Unmerged' : '═',
\ 'Ignored' : '☒',
\ 'Deleted' : '✖',
\ 'Unknown' : '?'
\ })
And colors?
hi Defx_git_Untracked guibg=NONE guifg=NONE ctermbg=NONE ctermfg=NONE
hi Defx_git_Ignored guibg=NONE guifg=NONE ctermbg=NONE ctermfg=NONE
hi Defx_git_Unknown guibg=NONE guifg=NONE ctermbg=NONE ctermfg=NONE
hi Defx_git_Renamed ctermfg=214 guifg=#fabd2f
hi Defx_git_Modified ctermfg=214 guifg=#fabd2f
hi Defx_git_Unmerged ctermfg=167 guifg=#fb4934
hi Defx_git_Deleted ctermfg=167 guifg=#fb4934
hi Defx_git_Staged ctermfg=142 guifg=#b8bb26
@lambdalisue sure:
" Defx settings (notice that root marker is empty)
call defx#custom#option('_', {
\ 'resume': 1,
\ 'winwidth': 25,
\ 'split': 'vertical',
\ 'direction': 'topleft',
\ 'show_ignored_files': 0,
\ 'columns': 'indent:git:icons:filename',
\ 'root_marker': '',
\ 'ignored_files':
\ '.mypy_cache,.pytest_cache,.git,.hg,.svn,.stversions'
\ . ',__pycache__,.sass-cache,*.egg-info,.DS_Store,*.pyc'
\ })
call defx#custom#column('mark', { 'readonly_icon': '', 'selected_icon': '' })
call defx#custom#column('filename', { 'root_marker_highlight': 'Comment' })
" Defx icons
call defx#custom#column('git', {
\ 'indicators': {
\ 'Modified' : '•',
\ 'Staged' : '✚',
\ 'Untracked' : 'ᵁ',
\ 'Renamed' : '≫',
\ 'Unmerged' : '≠',
\ 'Ignored' : 'ⁱ',
\ 'Deleted' : '✖',
\ 'Unknown' : '⁇'
\ }
\ })
" Defx highlights
highlight! Defx_git_Modified ctermfg=1 guifg=#D370A3
highlight! Defx_git_Staged ctermfg=10 guifg=#A3D572
highlight! Defx_git_Deleted ctermfg=167 guifg=#fb4934
highlight def link Defx_filename_directory Directory
highlight def link Defx_git_Renamed Title
highlight def link Defx_git_Unmerged Label
highlight def link Defx_git_Untracked Comment
highlight def link Defx_git_Ignored Comment
highlight def link Defx_git_Unknown Comment
You can also find nice custom commands I wrote: https://github.com/rafi/vim-config/blob/master/config/plugins/defx.vim
Also, I'm currently testing this autocmd to refresh opened/closed defx buffers when moving between windows of different lcd
:
" Handle working-directory changes appropriately
autocmd DirChanged * if bufwinnr('tab'.tabpagenr()) != -1
\ | let cw = winnr()
\ | Defx -toggle -buffer-name=tab`tabpagenr()`
\ | execute('lcd ' . v:event['cwd'])
\ | Defx -toggle `getcwd()` -buffer-name=tab`tabpagenr()`
\ | execute(cw . 'wincmd w')
\ | elseif bufnr('tab' . tabpagenr()) != -1
\ | execute(bufnr('tab' . tabpagenr()) . 'bwipeout')
\ | endif
@lambdalisue So may i try this feature or it ins't ready yet?
@timsofteng you can track the progress at https://github.com/lambdalisue/fern.vim/pull/124 - once that is merged, we could install https://github.com/lambdalisue/fern-badge-git.vim
@rafi oh, sure. got it
@timsofteng @rafi It's still under development but you can try https://github.com/lambdalisue/fern-plugin-git.vim with the latest fern.vim. Note that I'll use force push often to that repository so it's not stable.
@lambdalisue Thanks! I'll try it asap. I have few more questions about your plugin but i guess it's better to ask without opening issue. Could you please share your contact info like messenger or email? Thanks.
At least for now, it's better to open a new issue here if your question is related to fern.vim while other users can reply, see, or whatever. I probably avoid messages if you send it through a closed way like email, twitter DM, or whatever.
@lambdalisue how can I enable it? I've added the new badge git plugin, but nothing happens. (I also git reset --hard origin/master
to the latest forced pushed version)
Nothing. It should be automatically enabled... Additionally, no way to debug now.
@lambdalisue are you sure? I tried fern.vim+badge plugin without any settings and nothing shows..
did you update fern as well?
@lambdalisue yes indeed :)
Reproduced and fixed. Please update fern/fern-plugin-git and retry. I've confirmed that with the following vimrc
" vim -u ~/.vim/vimrc.min
if has('vim_starting')
set nocompatible
endif
nnoremap ; :
nnoremap : ;
set packpath=
set runtimepath+=~/.config/nvim/pack/minpac/start/fern.vim
set runtimepath+=~/.config/nvim/pack/minpac/start/fern-plugin-git.vim
filetype plugin indent on
syntax on
Now you need https://github.com/lambdalisue/fern.vim/pull/126 to try fern-git.vim
Using the sign column for badges is an excellent choice.
No more weird indent jumping or NERDTree conceal
shenanigans either.
Good choice.
I need to test this new feature more thoroughly soon, only had a 5 minute test the other day, could not get the badges working likely because I did not run the correct development branch. But I did notice some significant scroll slowdown once I added a directory of 2,000 untracked files. So hopefully shelling out to the git
command only happens infrequently (e.g only on BufEnter into the fern window)? To-be-determined soon once I have time to experiment.
Using the sign column for badges is an excellent choice. No more weird indent jumping or NERDTree conceal shenanigans either.
I'm sorry but this is not correct. I had decided to use sign column for marks and not badges. I have not decided yet about what the badge is. But I hate indent jumping thus I'm not going to allow that. I don't care about conceal thus it's one choice.
But I did notice some significant scroll slowdown once I added a directory of 2,000 untracked files. So hopefully shelling out to the git command only happens infrequently (e.g only on BufEnter into the fern window)? To-be-determined soon once I have time to experiment.
Good point. Yes, I've also noticed that the feature might cause performance issues even that the command is executed asynchronously. Thus probably I'll change the design or even strategy to get similar features from the screencast what I've pasted at last.
Note again that this Git integration feature is under very active development. I did a lot of force push and I break the feature everyday.
Sorry, my bad, I thought the badges where in the sign column via the image in this post.
Still a work in progress, all good.
Good point. Yes, I've also noticed that the feature might cause performance issues even that the command is executed asynchronously.
Asynchronous is great. However, big repos are a challenge. Hence, the less git status
is called the better.
@lambdalisue are you using <pathspec>
with git status
? e.g. git status -- [<pathspec>...]
? I did some small benchmarks and it's faster specifying the exact path.
Where is the performance bottleneck? Executing 'git status', or parsing output in vimscript?
Vim script, unfortunately. Of course using <pathspec>
is elegant and sufficient but I'd like to keep performance even there are a lot of files that are displayed in fern.vim thus it does not help much.
https://github.com/lambdalisue/fern-git-status.vim https://github.com/lambdalisue/fern-mapping-git.vim
I think the plugin become ready to use thus close this. Please make an issue on that repository if you have issues or whatever.
Hello. Fern is very cool file tree. It's quick and flexible. Can you please implement git integration to it? I mean flags like modified, deleted, added, etc. Thanks.