Skip to content

Instantly share code, notes, and snippets.

@thraizz
Created October 9, 2020 09:33
Show Gist options
  • Save thraizz/98fffe30fcd0615b2121a9b8e5902873 to your computer and use it in GitHub Desktop.
Save thraizz/98fffe30fcd0615b2121a9b8e5902873 to your computer and use it in GitHub Desktop.
Awesome Vim: My vim documented configuration
set nocompatible " be iMproved, required
set noshowmode
set shell=/bin/zsh
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
Plugin 'xolox/vim-misc'
" Always use the right delimiters for out-commenting stuff
Plugin 'scrooloose/nerdcommenter'
" nerdtree is a plugin that shows a nice filetree. Nice for file operations like moving, copying, deleting and navigation.
Plugin 'scrooloose/nerdtree'
" Plugin for fixing indentation
Plugin 'Yggdroot/indentLine'
" Plugin for detecting right indentation
Plugin 'ciaranm/detectindent'
" Plugin for linting and fixing various programming languages.
Plugin 'dense-analysis/ale'
" Vue syntax highlighting
Plugin 'posva/vim-vue'
" Distraction-free file inspection by placing the buffer in the middle of vim
Plugin 'junegunn/goyo.vim'
" Marks modifications, removals and additions in git projects
Plugin 'airblade/vim-gitgutter'
" Like VSCode's ctrlp. Blazingly-fast switching of files, searching in project and opening recently opened files.
Plugin 'ctrlpvim/ctrlp.vim'
" Surround words easily with various marks, like ',",{ etc
Plugin 'tpope/vim-surround'
Plugin 'tpope/vim-repeat'
" Create ascii art for highlighting code sections
Plugin 'fadein/vim-FIGlet'
" My favorite colorschemes, includes a light and a dark theme. Should be adapted to be a repo with just the vim folder inside.
Plugin 'sonph/onehalf', {'rtp': 'vim/'}
" Status bar which displays important vim informations
Plugin 'itchyny/lightline.vim'
" Turn something to <something></something> real-quick.
Plugin 'mattn/emmet-vim'
" A good terminal wrapper.
Plugin 'vimlab/split-term.vim'
" Search through files in current directory
Plugin 'mileszs/ack.vim'
call vundle#end() " required
filetype plugin indent on " required
""" Behaviour on Events: Autocommands
autocmd StdinReadPre * let s:std_in=1
" Show NERDTree when opening a directory with vim
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | exe 'cd '.argv()[0] | endif
" Resize the window automatically
autocmd VimResized * wincmd =
""" Making VIM look nice: Visual Settings
syntax on
set splitbelow
" I use relative numbers to see how far I have to jump, e.g. 3k to jump to the headline of this section
set relativenumber
set conceallevel=1
" Fixes issues with the status bar
set laststatus=2
set cursorline
" Fixes colors in TMUX
set t_Co=256
" I have a cronjob that copies either onehalfdark or onehalflight colorscheme to current.vim, based on the time. Care for your eyes!
colorscheme current
" if exists('+termguicolors')
" let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
" let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
" set termguicolors
" endif
""" Plugin Configurations
" ALE Vim settings, a syntanx linter
let g:ale_linter_aliases = {'vue': ['vue', 'javascript']}
let g:ale_linters = {'javascript': ['eslint'], 'vue': ['eslint'], 'python': ['flake8']}
let g:ale_fixers = {'javascript': ['eslint'], 'vue': ['eslint'], 'python': ['autopep8']}
let g:ale_fix_on_save = 1
" CtrlP Settings; search files with Ctrl - P and hide .git files
let g:ctrlp_user_command = 'fd --type f --hidden --follow --exclude .git'
" Emmet Settings; something,, would result in <something></something>
let g:user_emmet_leader_key=','
let g:indentLine_conceallevel=1
let g:indentLine_char='|'
let g:indentLine_enabled=1
let g:ackprg = 'rg --vimgrep --type-not sql --smart-case'
" Auto close the Quickfix list after pressing '<enter>' on a list item
let g:ack_autoclose = 1
" Any empty ack search will search for the work the cursor is on
let g:ack_use_cword_for_empty_search = 1
let g:lightline = { 'colorscheme': 'onehalfdark' }
""" Keymaps
" Escape with jj and clear search buffer
imap jj <ESC>:noh<CR>
" Show current files in Buffer with Ctrl+f
map <C-f> :CtrlPBuffer<CR>
" Show/Hide NERDTree with Ctrl+n
map <C-n> :NERDTreeToggle<CR>
" In insert or command mode, move normally by using Ctrl
inoremap <C-h> <Left>
inoremap <C-j> <Down>
inoremap <C-k> <Up>
inoremap <C-l> <Right>
inoremap <S-Tab> <C-d>
cnoremap <C-h> <Left>
cnoremap <C-j> <Down>
cnoremap <C-k> <Up>
cnoremap <C-l> <Right>
nnoremap <C-s> :Ack!<Space>
" Navigate quickfix list with ease
nnoremap <silent> [q :cprevious<CR>
nnoremap <silent> ]q :cnext<CR>
" Unindent with Shift Tab
nnoremap <S-Tab> <<
" Excecute with F9
noremap <F9> :!%:p<ENTER>
" Show next merge conflict with F8
noremap <silent> <F8> /^\(<\{7\}\\|>\{7\}\\|=\{7\}\\|\|\{7\}\)\( \\|$\)<cr>
" Don't jump to first match
cnoreabbrev Ack Ack!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment