Archived
1
0
Fork 0
This repository has been archived on 2024-10-31. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/simpleDots/vim/vimrc

341 lines
10 KiB
VimL
Raw Permalink Normal View History

"
" Install plugins
"
2021-04-22 21:16:20 +02:00
set nocompatible " be iMproved, required
filetype off " required
2024-06-25 10:28:44 +02:00
" set the runtime path to include Vundle and initialize
2024-10-23 09:15:27 +02:00
" Install with git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
2024-06-25 10:28:44 +02:00
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
Plugin 'Raimondi/delimitMate' " Autoclose quotes, parenthesis, brackets, etc.
2024-10-23 09:15:27 +02:00
Plugin 'Yggdroot/indentLine'
2024-06-25 10:28:44 +02:00
Plugin 'airblade/vim-gitgutter' " Git-indicators on the left
Plugin 'dhruvasagar/vim-table-mode' " Nice ascii tables
Plugin 'itchyny/lightline.vim' " Status-line
Plugin 'junegunn/vim-easy-align' " Align at any chars
Plugin 'ntpeters/vim-better-whitespace' " Complain on evil eol whitespace
2024-10-23 09:15:27 +02:00
Plugin 'preservim/nerdcommenter' " Comments...
2024-06-25 10:28:44 +02:00
Plugin 'preservim/nerdtree' " Nerdtree...
Plugin 'tpope/vim-fugitive' " git integration
call vundle#end()
2021-04-22 21:16:20 +02:00
filetype plugin indent on
syntax on
syntax sync minlines=256
"
" Settings
"
2021-04-22 21:16:20 +02:00
set autoindent
set autoread " Automatically reread changed files without asking me anything
set autowrite " Automatically save before :next, :make etc.
set backspace=indent,eol,start " Makes backspace key more powerful.
2021-04-22 21:16:20 +02:00
set complete=.,w,b,u,t
set completeopt=longest,menuone
set display+=lastline
set encoding=utf-8 " Set default encoding to UTF-8
set fileformats=unix,dos,mac " Prefer Unix over Windows over OS 9 formats
2021-04-22 21:16:20 +02:00
set hidden
set history=500
set hlsearch
set ignorecase
set incsearch
set laststatus=2
set lazyredraw
set nobackup " Don't create annoying backup files
set nocursorcolumn
set nocursorline
2021-04-22 21:16:20 +02:00
set noerrorbells " No beeps
set noshowmode " We show the mode with airlien or lightline
set noswapfile " Don't use swapfile
set nowritebackup
set nrformats-=octal
set number " Show line numbers
set re=1
2021-04-22 21:16:20 +02:00
set ruler " Show the cursor position all the time
set scrolloff=7
set showcmd " Show me what I'm typing
set showmatch " Show matching brackets by flickering
set sidescrolloff=7
set smartcase
set splitbelow " Split horizontal windows below to the current windows
set splitright " Split vertical windows right to the current windows
set synmaxcol=300
set tabpagemax=50
set ttyfast
" Make Vim to handle long lines nicely.
set wrap
set textwidth=79
set formatoptions=qrn1
2021-04-22 21:16:20 +02:00
" Time out on key codes but not mappings.
set notimeout
set ttimeout
set ttimeoutlen=10
2021-04-22 21:16:20 +02:00
if has('gui_running')
"set transparency=3
set regexpengine=1 " fix js regex syntax
endif
2021-06-26 13:50:32 +02:00
" Better colorhandling
if has('termguicolors')
set termguicolors
endif
2021-04-22 21:16:20 +02:00
let mapleader = ","
2021-04-22 21:16:20 +02:00
" dont save .netrwhist history
let g:netrw_dirhistmax=0
2021-04-22 21:16:20 +02:00
" Allow saving of files as sudo when I forgot to start vim using sudo.
cmap w!! w !sudo tee > /dev/null %
2021-04-22 21:16:20 +02:00
" open help vertically
command! -nargs=* -complete=help Help vertical belowright help <args>
" Different Cursorshapes for the modes
2023-12-25 15:48:01 +01:00
"let &t_SI = "\<Esc>[6 q"
"let &t_SR = "\<Esc>[4 q"
"let &t_EI = "\<Esc>[2 q"
2021-04-22 21:16:20 +02:00
" ==================== Remap Keys ====================
" Remaps % to tab so navigate to matching brackets
nnoremap <tab> %
vnoremap <tab> %
2021-04-22 21:16:20 +02:00
" Visual mode pressing * or # searches for the current selection
vnoremap <silent> * :call VisualSelection('f')<CR>
vnoremap <silent> # :call VisualSelection('b')<CR>
2021-04-22 21:16:20 +02:00
" Center, kill hl
nnoremap n nzzzv
nnoremap N Nzzzv
nnoremap <leader><space> :nohlsearch<CR>
nnoremap <space> zz
" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
" so that you can undo CTRL-U after inserting a line break.
inoremap <C-U> <C-G>u<C-U>
2021-04-22 21:16:20 +02:00
" Toggle line numbers and rulers
nmap <leader>ll :set number!<cr>
nmap <leader>lr :set relativenumber!<cr>
2021-04-22 21:16:20 +02:00
nmap <leader>cc :set cursorcolumn!<cr>
nmap <leader>cl :set cursorline!<cr>
" Better split switching with alt
map <M-j> <C-W>j
map <M-k> <C-W>k
map <M-h> <C-W>h
map <M-l> <C-W>l
map <M-down> <C-W>j
map <M-up> <C-W>k
map <M-left> <C-W>h
map <M-right> <C-W>l
2021-04-22 21:16:20 +02:00
" Move up and down on split lines
map <Up> gk
map <Down> gj
map k gk
map j gj
2021-04-22 21:16:20 +02:00
" Spell checking
nnoremap <F6> :setlocal spell! spell?<CR>
2021-04-22 21:16:20 +02:00
map <leader>ss :setlocal spell!<cr>
map <leader>sn ]s
map <leader>sp [s
map <leader>sa zg
map <leader>s? z=
" trim all whitespaces away
nnoremap <leader>W :%s/\s\+$//<cr>:let @/=''<CR>
" Do not show stupid q: window
map q: :q
2021-04-22 21:16:20 +02:00
" Paste Mode
set pastetoggle=<F2>
nmap p :pu<CR>
2021-04-22 21:16:20 +02:00
" ==================== File Type settings ====================
set tabstop=4
set softtabstop=4
set shiftwidth=4
set noexpandtab
set shiftround
set smarttab
2021-04-22 21:16:20 +02:00
au BufNewFile,BufRead *.vim setlocal noet ts=4 sw=4 sts=4
2022-02-18 00:28:49 +01:00
au BufNewFile,BufRead *.ino setlocal noet ts=4 sw=4 sts=4
2021-04-22 21:16:20 +02:00
au BufNewFile,BufRead *.txt setlocal noet ts=4 sw=4 sts=4
au BufNewFile,BufRead *.md setlocal noet ts=4 sw=4 sts=4
au BufNewFile,BufRead *.json setlocal et ts=2 sw=2 sts=2
au BufNewFile,BufRead *.go setlocal noet ts=4 sw=4 sts=4
au BufNewFile,BufRead *.lua setlocal noet ts=4 sw=4 sts=4
au BufNewFile,BufRead *.py setlocal et ts=4 sw=4 sts=4
au BufNewFile,BufRead *.yml,*.yaml setlocal et ts=2 sw=2 sts=2
au BufNewFile,BufRead *.htm,*.html setlocal noet ts=4 sw=4 sts=4
au FileType dockerfile setlocal et ts=2 sw=2 sts=2
au FileType nginx setlocal noet ts=4 sw=4 sts=4
au FileType fstab,systemd set noet
au FileType gitconfig,sh,toml set noet
" ==================== Wildmenu ====================
set wildmenu
set wildmode=list:full
set wildignore+=.hg,.git,.svn " Version control
set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files
set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images
set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
set wildignore+=*.spl " compiled spelling word lists
set wildignore+=*.sw? " Vim swap files
set wildignore+=*.DS_Store " OSX bullshit
set wildignore+=*.luac " Lua byte code
set wildignore+=migrations " Django migrations
set wildignore+=go/pkg " Go static files
set wildignore+=go/bin " Go bin files
set wildignore+=go/bin-vagrant " Go bin-vagrant files
set wildignore+=*.pyc " Python byte code
set wildignore+=*.orig " Merge resolution files
2021-04-22 21:16:20 +02:00
" ==================== PLUGIN: Fugitive ====================
nnoremap <leader>ga :Git add %:p<CR><CR>
nnoremap <leader>gs :Gstatus<CR>
nnoremap <leader>gp :Gpush<CR>
vnoremap <leader>gb :Gblame<CR>
2021-04-22 21:16:20 +02:00
" ==================== PLUGIN: Lightline ====================
"
let g:lightline = {
\ 'active': {
\ 'left': [ [ 'mode', 'paste'],
\ [ 'fugitive', 'filename', 'modified', 'ctrlpmark' ],
\ ],
\ 'right': [ [ 'lineinfo' ],
\ [ 'percent' ],
\ [ 'fileformat', 'fileencoding', 'filetype' ] ]
\ },
\ 'inactive': {
\ },
\ 'component_function': {
\ 'lineinfo': 'LightLineInfo',
\ 'percent': 'LightLinePercent',
\ 'modified': 'LightLineModified',
\ 'filename': 'LightLineFilename',
\ 'fileformat': 'LightLineFileformat',
\ 'filetype': 'LightLineFiletype',
\ 'fileencoding': 'LightLineFileencoding',
\ 'mode': 'LightLineMode',
\ 'fugitive': 'LightLineFugitive',
\ 'ctrlpmark': 'CtrlPMark',
\ },
\ }
function! LightLineModified()
if &filetype == "help"
return ""
elseif &modified
return "+"
elseif &modifiable
return ""
else
return ""
endif
endfunction
function! LightLineFileformat()
return winwidth(0) > 70 ? &fileformat : ''
endfunction
function! LightLineFiletype()
return winwidth(0) > 70 ? (strlen(&filetype) ? &filetype : 'no ft') : ''
endfunction
function! LightLineFileencoding()
return winwidth(0) > 70 ? (strlen(&fenc) ? &fenc : &enc) : ''
endfunction
function! LightLineInfo()
return winwidth(0) > 60 ? printf("%3d:%-2d", line('.'), col('.')) : ''
endfunction
function! LightLinePercent()
return &ft =~? 'vimfiler' ? '' : (100 * line('.') / line('$')) . '%'
endfunction
function! LightLineFugitive()
return exists('*fugitive#head') ? fugitive#head() : ''
endfunction
function! LightLineMode()
let fname = expand('%:t')
return fname == 'ControlP' ? 'CtrlP' :
\ &ft == 'vimfiler' ? 'VimFiler' :
\ winwidth(0) > 60 ? lightline#mode() : ''
endfunction
function! LightLineFilename()
let fname = expand('%:t')
if mode() == 't'
return ''
endif
return fname == 'ControlP' ? g:lightline.ctrlp_item :
\ &ft == 'vimfiler' ? vimfiler#get_status_string() :
\ ('' != LightLineReadonly() ? LightLineReadonly() . ' ' : '') .
\ ('' != fname ? fname : '[No Name]')
endfunction
function! LightLineReadonly()
return &ft !~? 'help' && &readonly ? 'RO' : ''
endfunction
function! CtrlPMark()
if expand('%:t') =~ 'ControlP'
call lightline#link('iR'[g:lightline.ctrlp_regex])
return lightline#concatenate([g:lightline.ctrlp_prev, g:lightline.ctrlp_item
\ , g:lightline.ctrlp_next], 0)
else
return ''
endif
endfunction
let g:ctrlp_status_func = {
\ 'main': 'CtrlPStatusFunc_1',
\ 'prog': 'CtrlPStatusFunc_2',
\ }
2021-04-22 21:16:20 +02:00
" ==================== PLUGIN: NerdTree ====================
" For toggling
nmap <C-n> :NERDTreeToggle<CR>
nmap <F7> :NERDTreeToggle<CR>
noremap <Leader>n :NERDTreeToggle<cr>
noremap <Leader>f :NERDTreeFind<cr>
let NERDTreeShowHidden=1
let NERDTreeIgnore=['\.vim$', '\~$', '\.git$', '.DS_Store']
" Close nerdtree and vim on close file
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
2024-10-23 09:15:27 +02:00
" ==================== Base64 de- and encoding ====================
let g:indentLine_enabled = 0
let g:indentLine_char = '┊'
nmap <leader>il :IndentLinesToggle<cr>
2024-05-06 10:31:36 +02:00
" ==================== Base64 de- and encoding ====================
vnoremap <leader>b64d y:let @"=system('base64 -w 0 --decode', @")<cr>gvP
vnoremap <leader>b64e y:let @"=system('base64 -w 0', @")<cr>gvP
" vim:ts=2:sw=2:et