GithubHelp home page GithubHelp logo

zsaberlv0 / zfvimdirdiff Goto Github PK

View Code? Open in Web Editor NEW
56.0 4.0 3.0 276 KB

directory diff plugin with split treeview, similar to BeyondCompare, fully async and low dependency

Shell 0.40% Batchfile 0.55% Vim Script 98.23% Python 0.82%
vim-scripts diff treeview vim

zfvimdirdiff's Introduction

Hi there 👋 Welcome to my GitHub!

here's some interesting things I developed:

Buy me a coffee?

zfvimdirdiff's People

Contributors

albfan avatar idbrii avatar micchy326 avatar zsaberlv0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

zfvimdirdiff's Issues

Doesn't seem to work

I have two folders that some files are different.
The output is meaningless. Doesn't show sub directory files, I don't see which is different.
uris are the same , and python_lsp is different.

Do you calculate hash?
image

Doesn't create intermediate folders with doing "sync here"

Steps:

mkdir -p hi/there/folder hi/unwanted ha
touch hi/there/folder/file hi/unwanted/file
gvim .
:DirDiff hi ha
/folder
dp

Nothing happens.

I'd expect directory 'there' to be created when I'm trying to sync (ZF_DirDiffSyncToThere). Instead, I have to copy each parent folder (using Yes instead of All to avoid getting directory 'unwanted'). Once the parent folders exist, I can use dp to copy the file.

Am I doing something wrong?

When a folder is curdir, Header shows folder is root

:cd ~/code/project
:ZFDirDiff ~/code/project/ ~/code/project2/

output:

[LEFT]: ~/code/project
[LEFT]: /

Because plugin/ZFVimDirDiff.vim:51 appends a / to the end of an empty string returned by ZF_DirDiffPathFormat:

        call add(text, '[LEFT]: ' . ZF_DirDiffPathFormat(t:ZFDirDiff_fileLeft, ':.') . '/')

Windows下可以不跳出cmd.exe 吗?

比如,可以用 call xolox#misc#os#exec({'command': 'vimrun', 'async': 1})
这样的东西来控制在后台做对比吗?或者最新的job能做这样的事情吗?

Ignores dir/file distinction from ZFVimIgnore

In ZFVimIgnore, you can specify dir and file matchers, but ZFVimDirDiff ignores this difference, leading to some wrong behaviour, for example:

  • The default settings of ZFVimIgnore contain a file matcher *.d (I suppose to ignore dependency files generated by compilers)
  • ZFVimDirDiff uses this *.d too match directories as well, so directories ending with .d are ignored as well, which is a pity, as on linux those are used quite a bit (e.g. /etc/conf.d).

I don't know if you want to make this distinction in this plugin, if not, you can close this and I'll use ZFIgnoreOff as a workaround in these cases.

`highlight link ZFDirDiffHL_Same Normal` doesn't change highlight

Describe the bug:

Using highlight link ZFDirDiffHL_Same Normal in vimrc or ~/.vim/after/plugin/zfdirdiff.vim doesn't change highlight.

To reproduce:

  1. create reprovimrc.vim:
" Invoke with:
" gvim -Nu ~/.vim/reprovimrc.vim -U NONE +"ZFDirDiff ~/.vim/bundle/zfdirdiff/test/left/ ~/.vim/bundle/zfdirdiff/test/right/"

" all plugins should work with sensible as a baseline.
let s:plugins = ['sensible']
let s:plugins += ['zfdirdiff']

set runtimepath-=~/.vim
set runtimepath-=~/.vim/after
set runtimepath-=~/vimfiles
set runtimepath-=~/vimfiles/after
for plugin in s:plugins
    exec "set runtimepath^=~/.vim/bundle/". plugin
    exec "set runtimepath+=~/.vim/bundle/". plugin ."/after"
endfor
set viminfofile=NONE

colorscheme desert

" This doesn't work -- what README says to do.
highlight link ZFDirDiffHL_Same Normal
" This works
"~ highlight default link ZFDirDiffHL_Same Normal
  1. start with gvim -Nu ~/.vim/reprovimrc.vim -U NONE +"ZFDirDiff ~/.vim/bundle/zfdirdiff/test/left/ ~/.vim/bundle/zfdirdiff/test/right/"
  2. copy b.txt to the other side
  3. observe that b.txt is highlighted with Fold (orange text) instead of Normal (white text)
  4. Do :highlight link ZFDirDiffHL_Same Normal and b.txt now looks as expected

I tried moving the highlight commands from ZFVimDirDiff.vim to a new syntax/ZFDirDiffRight.vim (and Left), but then neither command worked from my vimrc.

My read of the docs is that you're doing the right thing, so is this a vim bug?

Environment:

  • vim version : 8.2.2497 x64
  • OS : win10 x64

diff dir 页签增加自动刷新快捷键

发现有时候从 diff file 回到 diff dir 页签时,刚同步完的两个文件高亮没有变化。
下意识就想到有没有刷新功能。
这在有外部程序更改了文件夹内容时也可能有用的。

Just checking, is this file needed?

This file
Hi,
Thanks for the great plugin - just wondering - is the above file needed?
It empty, and I suspect my system isn't set up to handle unicode as well as it needs to be to work with this file - I just wondered if it's meant to be there given no other files in the repository seem to have unicode filenames?
Thanks,
John

Improve performance

I strongly recommend using it, as it saves a lot of processing time.
In Linux you usually have md5sum that you can introduce into diff.sh . if the hash is the same, mark it as same.

But it is easy to implement it in python i.e.

import hashlib
file1_path = 'path/to/your/file1.txt'
file2_path = 'path/to/your/file2.txt'
def calculate_file_hash(file_path):
    with open(file_path, 'rb') as file:
        file_hash = hashlib.sha256(file.read()).hexdigest()
    return file_hash
file1_hash = calculate_file_hash(file1_path)
file2_hash = calculate_file_hash(file2_path)

Or even lua maybe.
https://github.com/kikito/md5.lua

和ctags插件冲突

在安装了这个插件后,会导致 韦大的 vim-quickui/vim-preview不能正常工作 , 报不能找到 相应tags的错误
vim-gutentags也失效,但是我看生成的tags文件,内容是正常的。
在centos untun20.04, windows, 以及 U-ctags, e-ctags都会出现这个问题
部分情况下连c-]都会出错,不能跳转、preview

Current window changes when doing diffParentDir in left window

I think the purpose of diffThisDir (cd) and diffParentDir (u) is to navigate around to find the right folder to diff. But if I do that in the left window, then after the command completes the focus changes to the right window. This makes navigation awkward -- and confusing if you try to do uu because you know you want to go up multiple levels.

Convert to autoload functions

There's a lot of code in dirdiff, but it's a plugin with very specific use cases: you don't use it every time you start up vim. Instead of processing all of that vimscript every time you start vim, just do it when you diff dirs!

:h autoload explains more about it, but now that dirdiff depends on ZFVimJob it seems like there's even more code to load on startup and makes it a good candidate for autoload.

A shortcut to this conversion is to autoload just the commands:

Move plugin/*.vim to autoload/zfdirdiff/, rename some functions, and move the :command lines back to plugin/zfdirdiff.vim. Could also make some wrapper functions in plugin/zfdirdiff.vim for backwards compatibility.

Renames would look like:

  • ZFDirDiffAPI_init -> zfdirdiff#api#init
  • ZFDirDiffMark -> zfdirdiff#mark#Mark
  • ZFDirDiffUnmark -> zfdirdiff#mark#Unmark

Since this only uses vim's autoload naming for a few functions, you'd also want a load function in each autoload file and call all of them at the top of autoload/zfdirdiff/api.vim so they'll all load:

function! zfdirdiff#ui#load() abort
endf

(Autoload will use the function name to discover the file, load it, and call the function.)

zfdirdiff has a ton of global functions that people could be using. Putting one of those load dummy functions in api.vim would allow people to call zfdirdiff#api#load() in their vimrc to have access to those global functions (but also lose the benefits of autoload).

Or you could autoload all the functions in api.vim. Or all the functions you want exposed (then you wouldn't need those load dummy functions).

Something like these two substitutes might get you most of the way there for a full conversion since you've already namespaced functions with underscores:

%s/\v\s\zsZFDirDiff_(\k+)_(\k+)\(/zfdirdiff#\1#\2(/g
%s/\v\s\zsZFDirDiff_(\k*)\(/zfdirdiff#\1(/g

But I can see one problem you'd run into are functions like ZFDirDiff_excludeCheck_fallback() because zfdirdiff#excludeCheck#fallback() vim requires an autoload function with that name to be in autoload/zfdirdiff/excludeCheck.vim.

I'm not sure what to do with all the configuration. Also move it to autoload?

zfdirdiff is a big plugin and has a bunch of dependencies, so converting to autoload is a big task. If you don't want to write your plugins with autoload, I get it. Thanks for the great plugin regardless!

Less texty labels

This capital letters looks old and unneccessary as plugin do a split.

I change it with:

diff --git i/plugin/ui.vim w/plugin/ui.vim
index e957093..d216e49 100644
--- i/plugin/ui.vim
+++ w/plugin/ui.vim
@@ -38,14 +38,12 @@ endfunction
 if !exists('*ZFDirDiffUI_cbHeader')
     function! ZFDirDiffUI_cbHeader(taskData)
         let headerL = [
-                    \   '[LEFT]: ' . ZFDirDiffAPI_pathHint(a:taskData['pathL'], ':~'),
-                    \   '[LEFT]: ' . ZFDirDiffAPI_pathHint(a:taskData['pathL'], ':.'),
-                    \   '------------------------------------------------------------',
+                    \   ZFDirDiffAPI_pathHint(a:taskData['pathL'], ':p'),
+                    \   '',
                     \ ]
         let headerR = [
-                    \   '[RIGHT]: ' . ZFDirDiffAPI_pathHint(a:taskData['pathR'], ':~'),
-                    \   '[RIGHT]: ' . ZFDirDiffAPI_pathHint(a:taskData['pathR'], ':.'),
-                    \   '------------------------------------------------------------',
+                    \   ZFDirDiffAPI_pathHint(a:taskData['pathR'], ':p'),
+                    \   '',
                     \ ]
         return {
                     \   'headerL' : headerL,
@@ -318,9 +316,9 @@ function! s:diffUI_bufSetup(isLeft)
     setlocal nowrap
     setlocal noswapfile
     if a:isLeft
-        silent! file [LEFT]
+        silent! file [DirDiff Left]
     else
-        silent! file [RIGHT]
+        silent! file [DirDiff Right]
     endif
     setlocal nomodified
     setlocal nomodifiable
@@ -928,7 +926,7 @@ function! ZFDirDiffUIAction_markToDiff()
                     \ }
         call ZFDirDiffHLImpl_dataChanged(t:ZFDirDiff_taskData, bufnr)
         echo '[ZFDirDiff] mark again to diff with: '
-                    \ . (isLeft ? '[LEFT]' : '[RIGHT]')
+                    \ . (isLeft ? '[DirDiff Left]' : '[DirDiff Right]')
                     \ . parentPath . diffNode['name']
         return
     endif

I see there're more of this marking files, but still did not investigate all features of plugin.

Is it possible to work on customize this labels?

在windows下,可以指定shell来做diff

我把vim的shell设置成了git-bash带的bash,diff 就失败了。

if filereadable("C:/git-sdk-64/usr/bin/bash.exe")
    let &shell='C:/git-sdk-64/usr/bin/bash.exe'
    let &shellcmdflag="--login -c"
    let &shellxquote="\""
    let $CHERE_INVOKING=1
    set shellslash
endif

这种情况下,其实是用 bash 去执行了cmd.exe 的命令了。

假如我想在gvim里启动shell,用git-bash带的bash,这个功能更强;在做文件夹diff的时候,用cmd.exe 来执行,cmd.exe 启动更快。git-bash/cygwin bash 启动一下,要好几秒。

Dummy file/folder 当比较两个文件夹的时候

当比较两个文件夹的时候,某一侧的对应的文件/文件夹不存在,是不是可以用一个 Dummy 的 file/folder来代表一下呢?这样设置折叠为 indent 的时候 就可以两边折叠出的效果一样了。不一样的文件较多的时候,两边分别一折叠,显示就乱了。
这是一边折叠,一边不折叠的时候
image

这是两边都折叠的时候。和前期项目比较,前期的项目少了一些文件,所以显示的很乱。
image

对比文件夹时,复制文件后报一堆错误

Hi, 我又来用你的工具了。
对比目录窗口下,我使用 dp 命令后从一边复制(缺失的)文件到另一边,然后报一堆错误,
b:isLeft 未定义
然后目录对比的标签页被关闭
但文件是复制成功的,重新对比目录时能发现

needs redraw! after any action

I think there's a TODO on README about this.

just triggering :redraw! after each task is enough to view all buffers again

I can work on this, if there's no better workaround

Suggestion: use Normal for ZFDirDiffHL_Same

I found the diff highlighting colors confusing at first because it lacked the familiar red of my diff colors and it had an unfamiliar yellow from my folding. I don't think it makes sense to add red (unless you separated the colors between left and right so only on left was removed red and only on right was added green). But what do you think about de-emphasizing files that are the same just like you diffs are displayed?

" change this:
highlight link ZFDirDiffHL_Same Folded
" to this:
highlight link ZFDirDiffHL_Same Normal

Users can always add that line to ~/.vim/after/plugin/zfdirdiff.vim with the same result, but I thought it would make sense to be the default behaviour. I tested several colorschemes (jellybeans, moira, lucius, navajo-night) and only one made Folded look less eye-catching than Normal.

Convert to autoload functions

There's a lot of code in dirdiff, but it's a plugin with very specific use cases: you don't use it every time you start up vim. Instead of processing all of that vimscript every time, just do it when you start vim.

:h autoload explains more about it, but now that dirdiff depends on ZFVimJob it seems like there's even more code to load on startup and makes it a good candidate for autoload.

A shortcut to this conversion is to autoload just the commands:

Move plugin/*.vim to autoload/zfdirdiff/, rename some functions, and move the :command lines back to plugin/zfdirdiff.vim. Could also make some wrapper functions in plugin/zfdirdiff.vim for backwards compatibility.

Renames would look like:

  • ZFDirDiffAPI_init -> zfdirdiff#api#init
  • ZFDirDiffMark -> zfdirdiff#mark#Mark
  • ZFDirDiffUnmark -> zfdirdiff#mark#Unmark

Since this only uses vim's autoload naming for a few functions, you'd also want a load function in each autoload file and call all of them at the top of autoload/zfdirdiff/api.vim so they'll all load:

function! zfdirdiff#ui#load() abort
endf

(Autoload will use the function name to discover the file, load it, and call the function.)

zfdirdiff has a ton of global functions that people could be using. Putting one of those load dummy functions in api.vim would allow people to call zfdirdiff#api#load() in their vimrc to have access to those global functions, but also lose the benefits of autoload.

Or you could autoload all the functions in api.vim. Or all the functions you want exposed (then you wouldn't need those load dummy functions).

Something like these two substitutes might get you most of the way there for a full conversion since you've already namespaced functions with underscores:

%s/\v\s\zsZFDirDiff_(\k+)_(\k+)\(/zfdirdiff#\1#\2(/g
%s/\v\s\zsZFDirDiff_(\k*)\(/zfdirdiff#\1(/g

But I can see one problem you'd run into are functions like ZFDirDiff_excludeCheck_fallback() because zfdirdiff#excludeCheck#fallback() vim requires an autoload function with that name to be in autoload/zfdirdiff/excludeCheck.vim.

I'm not sure what to do with all the configuration. Also move it to autoload?

zfdirdiff is a big plugin and has a bunch of dependencies, so converting to autoload is a big task. If you don't want to write your plugins with autoload, I get it. Thanks for the great plugin regardless!

Is it possible to remove ZF prefix?f

Thanks a lot for creating this plugin, works exactly as expected, but why all the ZF prefix?

for diff two dirs I just expect to provide a DirDiff command.

Is it possible to work on that?

By now I solve it using:

command! -nargs=+ -complete=file DirDiff :call ZFDirDiff(<f-args>)

CursorLine highlighting is changed in dirdiff and isn't restored when leaving

I use full height CursorLine (I think I'm just using the default color because it's not defined in my colorscheme). When I open ZFDirDiff, the CursorLine changes to underline instead (looks like I can g:ZFDirDiffHLFunc_addHL to customize). When I leave ZFDirDiff, it's not restored.

Minimal repro:

let s:plugins = ['sensible']
let s:plugins += ['zfvimdirdiff']

set runtimepath-=~/.vim
set runtimepath-=~/.vim/after
set runtimepath-=~/vimfiles
set runtimepath-=~/vimfiles/after
for plugin in s:plugins
    exec "set runtimepath^=~/.vim/bundle/". plugin
    exec "set runtimepath+=~/.vim/bundle/". plugin ."/after"
endfor
set viminfofile=NONE

set cursorline
colorscheme desert

command! Test ZFDirDiff ~/.vim/colors ~/.vim/plugin
$ mvim -Nu ~/.vim/reprovimrc.vim -U NONE ~/.vim/reprovimrc.vim 
" navigate up and down to see full height cursorline. Then:
Test
" navigate up and down to see underline cursorline. Then:
tabclose
" navigate up and down to see underline cursorline instead of full height one.

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.