This is a collection of dotfiles and scripts for my bspwm setup
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

172 lines
4.0 KiB

" Disable unused components
set nobackup
set nocompatible
" Setup paths
set backupdir=$XDG_CACHE_HOME/vim,/var/tmp,/tmp
set directory=$XDG_CACHE_HOME/vim,/var/tmp,/tmp
set packpath^=$XDG_CONFIG_HOME/vim
set runtimepath^=$XDG_CONFIG_HOME/vim
set viminfo+=n$XDG_CACHE_HOME/vim_history
"" General
filetype plugin on
syntax on
" Behavior
set clipboard=unnamedplus
set encoding=utf-8
set fileencoding=utf-8
set hidden
set history=1000
set mouse=a
set ttimeoutlen=0
set undolevels=1000
set suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc,.png,.jpg
set wildignore=*.bak,*.swp,*.o,*.info,*.aux,*.log,*.dvi,*.bbl,*.blg,*.brf,*.cb,*.ind,*.idx,*.ilg,*.inx,*.out,*.toc,*.png,*.jpg
" Editing
set number
set ruler
set background=dark
colorscheme hybrid_reverse
set cursorline
highlight clear CursorLine
highlight CursorLineNr cterm=bold
highlight clear SpellBad
highlight SpellBad ctermbg=8 ctermfg=15
" Cursor shape
let &t_SI = "\<Esc>[6 q"
let &t_SR = "\<Esc>[4 q"
let &t_EI = "\<Esc>[2 q"
" Indentation
set autoindent
filetype indent on
set backspace=indent,eol,start
set noexpandtab
set shiftround
set tabstop=4
set softtabstop=4
set shiftwidth=4
" UI
set laststatus=2
set noshowmode
set nowrap
"" Plugin configuration
" color_coded, libclang-based syntax highlighting
let g:color_coded_enabled = 1
let g:color_coded_filetypes = ['c', 'cpp']
" lightline.vim
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': [['text']]}
let g:lightline.component_expand = {'buffers': 'lightline#bufferline#buffers'}
let g:lightline.component_type = {'buffers': 'tabsel'}
let g:lightline.component = {'text': 'buffers'}
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:NERDTreeIgnore = ['\.git', '\.bak']
let g:NERDTreeAutoDeleteBuffer=1
let g:NERDTreeDirArrowExpandable = ' '
" let g:NERDTreeDirArrowCollapsible = ' '
let g:NERDTreeMinimalUI=1
let g:NERDTreeShowHidden=1
" vimtex
let g:tex_flavor = 'latex'
let g:vimtex_view_method = 'zathura'
"" Autocommands
" Remove trailing whitespace in the following filetypes
augroup TrailingWhitespace
autocmd! FileType c,cpp,h,ino,java,py,php,sh,tex autocmd BufWritePre <buffer> %s/\s\+$//e
augroup END
" Close vim if only window is NERD Tree
augroup CloseVimTree
autocmd! bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
augroup END
augroup PreventBuffer
autocmd FileType nerdtree let t:nerdtree_winnr = bufwinnr('%')
autocmd BufWinEnter * call PreventBuffersInNERDTree()
augroup END
"" 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
function! PreventBuffersInNERDTree()
if bufname('#') =~ 'NERD_tree' && bufname('%') !~ 'NERD_tree'
\ && exists('t:nerdtree_winnr') && bufwinnr('%') == t:nerdtree_winnr
\ && &buftype == ''
let bufNr = bufnr('%')
close
execute 'b 'bufNr
execute 'NERDTreeToggle'
execute "normal! \<c-w>\<c-w>"
endif
endfunction
"" Keybindings
" Tab/Shift+Tab functionality
nnoremap <Tab> >>_
nnoremap <S-Tab> <<_
inoremap <S-Tab> <C-D>
vnoremap <Tab> >gv
vnoremap <S-Tab> <gv
" Buffer switching
nnoremap <silent> <C-h> :bprevious<CR>
nnoremap <silent> <C-l> :bnext<CR>
nnoremap <silent> <C-w> :call CloseTab()<CR>
nmap <Leader>1 <Plug>lightline#bufferline#go(1)
" Toggle NERD Tree
nnoremap <silent> <C-t> :NERDTreeToggle<CR>
"" Commands
:command WQ wq
:command Wq wq
:command W w
:command Q q