From b13bb4e2d1f883ba7f84bfaa55ad36ef7110c998 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Tue, 28 Feb 2023 17:48:48 +0100 Subject: [nvim+git] add diffview --- .config/nvim/init.vim | 1 + .config/nvim/plugins/_install.vim | 1 + .config/nvim/plugins/_load.vim | 1 + .config/nvim/plugins/diffview.vim | 6 ++++++ .config/nvim/plugins/nerdtree.vim | 21 +++++++++++++++++++-- 5 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 .config/nvim/plugins/diffview.vim (limited to '.config/nvim') diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index 7c59a81..5e9fb44 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -8,6 +8,7 @@ function UtilityWinfiletypes() return winfiletypes endfunction +let g:NERDTreeNoInitFiletypes = ["DiffviewFiles"] let g:NERDTreeStatusLineTabSwitchFiletypes = ["nerdtree", "help"] diff --git a/.config/nvim/plugins/_install.vim b/.config/nvim/plugins/_install.vim index 9bc483c..60a1f74 100644 --- a/.config/nvim/plugins/_install.vim +++ b/.config/nvim/plugins/_install.vim @@ -10,6 +10,7 @@ Plug 'Xuyuanp/nerdtree-git-plugin' Plug 'nvim-lua/plenary.nvim' Plug 'nvim-telescope/telescope.nvim' +Plug 'sindrets/diffview.nvim' Plug 'airblade/vim-gitgutter' diff --git a/.config/nvim/plugins/_load.vim b/.config/nvim/plugins/_load.vim index c101014..4917b89 100644 --- a/.config/nvim/plugins/_load.vim +++ b/.config/nvim/plugins/_load.vim @@ -1,5 +1,6 @@ source ~/.config/nvim/plugins/aerial.vim source ~/.config/nvim/plugins/comment.vim +source ~/.config/nvim/plugins/diffview.vim source ~/.config/nvim/plugins/gitgutter.vim source ~/.config/nvim/plugins/indent_blankline.vim source ~/.config/nvim/plugins/leap.vim diff --git a/.config/nvim/plugins/diffview.vim b/.config/nvim/plugins/diffview.vim new file mode 100644 index 0000000..4b9d2f0 --- /dev/null +++ b/.config/nvim/plugins/diffview.vim @@ -0,0 +1,6 @@ +lua < 0 || exists('s:std_in') | wincmd p | endif - autocmd VimEnter * if argc() > 0 | silent NERDTreeFind | wincmd p | endif endif +function NERDTreeInit() + if !&diff + let buffer_type = getbufvar(bufnr(), "&filetype") + if index(g:NERDTreeNoInitFiletypes, buffer_type) == -1 + NERDTree + + if argc() > 0 || exists('s:std_in') + wincmd p + endif + + if argc() > 0 + silent NERDTreeFind + wincmd p + endif + endif + endif +endfunction +autocmd VimEnter * call NERDTreeInit() + autocmd BufWinEnter * if getcmdwintype() == '' | silent NERDTreeMirror | endif autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif -- cgit v1.2.3