From 49f01140715cb35dd8f5643a09c120c8e5785a82 Mon Sep 17 00:00:00 2001 From: Riyyi Date: Mon, 5 Feb 2018 20:11:55 +0100 Subject: [PATCH] Add vim nerdtree, nerdcommenter --- etc/vimrc | 43 +++++++++++++++++++++++++++++--- usr/share/vim/vimfiles/pack/list | 2 ++ 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/etc/vimrc b/etc/vimrc index d1bb13e..0d07a8d 100644 --- a/etc/vimrc +++ b/etc/vimrc @@ -46,23 +46,56 @@ set laststatus=2 set noshowmode set nowrap -" Plugins +"" Plugin configuration + +" Lightline let g:lightline = {} let g:lightline.colorscheme = 'Tomorrow_Night_Bright' let g:lightline.separator = {'left': "\ue0b0", 'right': "\ue0b2"} let g:lightline.subseparator = {'left': "\ue0b1", 'right': "\ue0b3"} +" Lightline-bufferline let g:lightline.tabline = {'left': [['buffers']], 'right': [['close']]} let g:lightline.component_expand = {'buffers': 'lightline#bufferline#buffers'} let g:lightline.component_type = {'buffers': 'tabsel'} let g:lightline#bufferline#min_buffer_count = 2 +" NERD Commenter +let g:NERDCommentEmptyLines=1 +let g:NERDSpaceDelims=1 +let g:NERDTrimTrailingWhitespace=1 + +" NERD Tree +let g:NERDTreeMinimalUI=1 +let g:NERDTreeAutoDeleteBuffer=1 + "" Autocommands " Remove trailing whitespace in the following filetypes autocmd FileType c,cpp,ino,java,py,php,sh,tex autocmd BufWritePre %s/\s\+$//e +" Close vim if only window is NERD Tree +autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif + +"" Functions + +function! CloseTab() + let bufNr = bufnr('%') + let nerdTreeStatus = exists('t:NERDTreeBufName') && bufwinnr(t:NERDTreeBufName) != -1 + let currentFile = expand('%:t') + + if nerdTreeStatus + execute "NERDTreeClose" + if currentFile !~# "NERD_tree" + execute "bw "bufNr + execute "NERDTreeToggle" + endif + else + execute "bw "bufNr + endif +endfunction + "" Keybindings " Tab/Shift+Tab functionality @@ -73,7 +106,11 @@ vnoremap >gv vnoremap :bprevious -nnoremap :bnext +nnoremap :bprevious +nnoremap :bnext +nnoremap :call CloseTab() nmap 1 lightline#bufferline#go(1) +" Toggle NERD Tree +nnoremap :NERDTreeToggle + diff --git a/usr/share/vim/vimfiles/pack/list b/usr/share/vim/vimfiles/pack/list index 98ad2ce..a53b186 100644 --- a/usr/share/vim/vimfiles/pack/list +++ b/usr/share/vim/vimfiles/pack/list @@ -1,5 +1,7 @@ start: https://github.com/itchyny/lightline.vim.git https://github.com/mgee/lightline-bufferline.git +https://github.com/scrooloose/nerdtree.git +https://github.com/scrooloose/nerdcommenter.git opt: https://github.com/kristijanhusak/vim-hybrid-material.git