Created
December 31, 2019 01:55
-
-
Save itbcodedev/e4aa32682225986bf9596d27ad7e6ef8 to your computer and use it in GitHub Desktop.
vimrc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
| "{{{ => General | |
| """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
| "Necessary for cool features of vim | |
| set nocompatible | |
| " Enable syntax highlighting | |
| syntax enable | |
| " Mouse support only in normal mode | |
| set mouse=n | |
| " https://github.com/numirias/security | |
| set nomodeline | |
| "}}} | |
| """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
| "{{{ => Plugins | |
| """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
| " Vim-plug | |
| " Automatic installaion of vim-plug | |
| if empty(glob('~/.vim/autoload/plug.vim')) | |
| silent !mkdir -p ~/.vim/autoload | |
| silent !curl -fLo ~/.vim/autoload/plug.vim | |
| \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim | |
| autocmd VimEnter * PlugInstall | |
| endif | |
| call plug#begin('~/.vim/plugged') | |
| " Motions, objects, operators | |
| Plug 'wellle/targets.vim' " Quotes, Separator, brace objects | |
| Plug 'vim-scripts/visualrepeat' " Visual mode repeat | |
| Plug 'tpope/vim-repeat' " Repeat random actions | |
| Plug 'tpope/vim-commentary' " Toggle comments | |
| Plug 'tpope/vim-surround' " Change surround | |
| Plug 'tpope/vim-unimpaired' " [/] mappings for vim | |
| Plug 'justinmk/vim-sneak' " Sneak 's' motion and object | |
| Plug 'vim-scripts/matchit.zip' " % works for more languages | |
| " Buffers, Tags, QuickFix | |
| Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --key-bindings --completion' } | |
| Plug 'junegunn/fzf.vim' " fuzzy searching | |
| Plug 'vim-scripts/taglist.vim', { 'on': 'TlistToggle' } " Tag browser | |
| " VCS Related | |
| Plug 'tpope/vim-fugitive' " Best Git integration | |
| Plug 'airblade/vim-gitgutter' " Gutter for vim | |
| " Completions and compilations | |
| Plug 'tpope/vim-dispatch' " Async command exec in vim | |
| Plug 'w0rp/ale' | |
| Plug 'Valloric/YouCompleteMe', { 'do': './install.py --all' } | |
| " Support for different filetypes | |
| Plug 'sheerun/vim-polyglot' " Syntax highlighthing | |
| Plug 'tpope/vim-apathy' " figure out import statements | |
| " UI | |
| Plug 'itchyny/lightline.vim' | |
| " Experimental | |
| " Plug 'Raimondi/delimitMate' " Close matching parens and ilk | |
| Plug 'burnettk/vim-angular' | |
| Plug 'https://github.com/leafgarland/typescript-vim' | |
| Plug 'https://github.com/Quramy/vim-js-pretty-template' | |
| Plug 'jiangmiao/auto-pairs' | |
| Plug 'vim-airline/vim-airline' | |
| Plug 'vim-airline/vim-airline-themes' | |
| Plug 'mhinz/vim-signify' | |
| Plug 'Yggdroot/indentLine' | |
| call plug#end() | |
| "}}} | |
| """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
| "{{{ => Plugins Specific | |
| """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
| " YCM | |
| """"""""""""" | |
| nnoremap gD :YcmCompleter GoTo<CR> | |
| nnoremap gr :YcmCompleter GoToReferences<CR> | |
| nnoremap gR :YcmCompleter RefactorRename<CR> | |
| nnoremap go :YcmCompleter OrganizeImports<CR> | |
| nnoremap <leader>g :YcmDiags<CR> | |
| let g:ycm_confirm_extra_conf = 0 | |
| let g:ycm_collect_identifiers_from_tags_file = 1 | |
| " ALE | |
| """"""""""""" | |
| nmap <silent> [w <Plug>(ale_previous_wrap) | |
| nmap <silent> ]w <Plug>(ale_next_wrap) | |
| " FZF | |
| """"""""""""" | |
| let g:fzf_layout = { 'up': '~40%' } | |
| nnoremap <silent> <C-p> :Files<CR> | |
| nnoremap <silent> <leader>b :Buffers<CR> | |
| "}}} | |
| """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
| "{{{ => VIM user interface | |
| """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
| " Set 256 colors in vim | |
| set t_Co=256 | |
| " Set the title of the terminal | |
| set title | |
| " Always show current position | |
| set ruler | |
| " This is the most awesome configurationa ever, is shows both | |
| " the absolute and relative numbering together to make jumps | |
| " easier | |
| set number | |
| " set relativenumber | |
| " Configure backspace so it acts as it should act | |
| set backspace=eol,start,indent | |
| set whichwrap+=<,>,h,l | |
| " Don't redraw while executing macros (good performance config) | |
| set lazyredraw | |
| " For regular expressions turn magic on | |
| set magic | |
| " How many tenths of a second to blink when matching brackets | |
| set mat=2 | |
| " No annoying sound on errors | |
| set noerrorbells | |
| set novisualbell | |
| set t_vb= | |
| set tm=500 | |
| " Mark the current line | |
| set cursorline | |
| " For the vimdow | |
| set winwidth=84 | |
| set winheight=5 | |
| set winminheight=5 | |
| set winheight=999 | |
| "}}} | |
| """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
| "{{{ => Search Related | |
| """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
| " When searching try to be smart about cases | |
| set smartcase | |
| set ignorecase | |
| " Highlight search results | |
| set hlsearch | |
| " Makes search act like search in modern browsers | |
| set incsearch | |
| " Show matching brackets when text indicator is over them | |
| set showmatch | |
| " Taken from www.vi-improved.org/recommendations | |
| if executable("ag") | |
| set grepprg=ag\ --nogroup\ --nocolor\ --ignore-case\ --column | |
| set grepformat=%f:%l:%c:%m,%f:%l:%m | |
| endif | |
| "}}} | |
| """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
| "{{{ => Fold | |
| """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
| " Folding is enabled by default | |
| set foldenable | |
| " Only very nested blocks will be folded | |
| set foldlevelstart=2 " 99 means everything will open up | |
| " The maximum nesting level | |
| set foldnestmax=10 | |
| " Don't open folds on search | |
| set fdo-=search | |
| "}}} | |
| """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
| "{{{ => Key bindings | |
| """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
| " With a map leader it's possible to do extra key combinations | |
| " like <leader>w saves the current file | |
| let mapleader = " " | |
| let g:mapleader = " " | |
| " The annoying jump over wrapped lines is removed | |
| nnoremap j gj | |
| nnoremap k gk | |
| "mapping for the windows | |
| nnoremap <C-j> <C-w>j | |
| nnoremap <C-h> <C-w>h | |
| nnoremap <C-k> <C-w>k | |
| nnoremap <C-l> <C-w>l | |
| nnoremap <C-w>- :split<CR> | |
| nnoremap <C-w>\ :vsplit<CR> | |
| " Taken from @Tarrasch's vimrc | |
| " Edit vimrc | |
| nnoremap <silent> <leader>ev :e $MYVIMRC<CR> | |
| nnoremap <silent> <leader>sv :so $MYVIMRC<CR> | |
| " Exit | |
| nnoremap <leader>q :q!<CR> | |
| " In ex mode use <C-p> <C-n> for scroll | |
| cnoremap <C-p> <Up> | |
| cnoremap <C-n> <Down> | |
| " for spelling options when writing | |
| nnoremap <silent> <leader>s :set spell!<CR> | |
| set spelllang=en_gb | |
| " after a search, this mapping removes the highlighing | |
| nnoremap <silent> <leader>/ :nohlsearch<CR> | |
| " white spaces | |
| nnoremap <silent> <leader>w :set list!<CR> | |
| " Paste from clipboard | |
| nnoremap <leader>v :set paste<CR>"+p:set nopaste<CR> | |
| " Sudo this file if opened without root priveileges | |
| nnoremap <leader>su <Esc>:w !sudo tee % >/dev/null<CR> | |
| " Get the count of a search string | |
| nnoremap <leader>c <Esc>:%s///gn<CR> | |
| """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
| " => Files, backups, and completions | |
| """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
| " Set utf8 as standard encoding and en_US as the standard language | |
| set fileencoding=utf-8 | |
| set encoding=utf8 | |
| " Use Unix as the standard file type | |
| set ffs=unix,dos,mac | |
| " Set to auto read when a file is changed from the outside | |
| set autoread | |
| " Sets how many lines of history VIM has to remember and undolevels | |
| set history=9999 | |
| set undolevels=9999 | |
| " No swaps, this is usually helpful in two cases: | |
| " 1. Vim crashes before save - swap | |
| " 2. You use two instances of vim on the same file - swap | |
| " 3. Protect against crash-during-write - backups | |
| " 4. Goback to previous version - git + undo | |
| " set swapfile | |
| " set directory^=~/.vim/swap// | |
| " set writebackup | |
| " set nobackup " but do not persist backup after successful write | |
| " set backupcopy=auto " use rename-and-write-new method whenever safe | |
| " set backupdir^=~/.vim/backup// | |
| " If you use git + undo long enough, and have a durable laptop which doesn't | |
| " explode, you can do without swaps and backups, otherwise read above | |
| set noswapfile | |
| set nowb | |
| set nobackup | |
| " Time travelling with vim | |
| " All changes are automatically saved; All undos are logged, so we can always move | |
| " back and forth between changes and files without worrying | |
| set undofile | |
| set undodir=~/.vim/undodir// | |
| au FocusLost * silent! wa | |
| " Enable filetype plugins | |
| filetype on | |
| filetype plugin on | |
| filetype indent on | |
| " Netrw setup | |
| " This converts netrw to a poor man's project finder | |
| let g:netrw_banner=0 " Don't show hideous banner | |
| let g:netrw_altv=1 " Open splits to the right | |
| let g:netrw_liststyle=3 " Tree view | |
| " Useful to use :find as a fuzzy finder by recursing, but slows down 'gf' | |
| " My advice would be to use a dedicated fuzzy finder instead | |
| " set path+=** | |
| " Use '*' for fuzzy search | |
| set wildmenu | |
| " Tab completion: mimics the behaviour of zsh | |
| set wildmode=list:longest,full | |
| " Adding omnicomplete | |
| set ofu=syntaxcomplete#Complete | |
| " Ignore compiled files | |
| set wildignore=*.o,*~,*.pyc,*.so,*.swp,*.zip,*/tmp/* | |
| "}}} | |
| """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
| "{{{ => Text, and indent related | |
| """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
| " Be smart when using tabs ;) | |
| set smarttab | |
| " Migrated to editorconfig | |
| " 1 tab == 4 spaces | |
| set shiftwidth=4 | |
| set tabstop=4 | |
| set softtabstop=4 | |
| set expandtab "Converts tabs into space characters | |
| " Textwrap at 120 haracters | |
| set tw=120 | |
| set wrap | |
| " Indentation | |
| set autoindent "Auto indent | |
| set smartindent "Smart indent | |
| "}}} | |
| """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
| "{{{ => Status line | |
| """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
| " Always show the status line | |
| set laststatus=2 | |
| " Show editor mode | |
| set showmode | |
| " Height of the command bar | |
| set cmdheight=1 | |
| "}}} | |
| """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
| "{{{ => Text objects | |
| """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
| " "in indentation" (indentation level sans any surrounding empty lines) | |
| xnoremap <silent> ii :<c-u>call functions#indent#inIndentation()<cr> | |
| " "around indentation" (indentation level and any surrounding empty lines) | |
| xnoremap <silent> ai :<c-u>call functions#indent#aroundIndentation()<cr> | |
| " "in line" (entire line sans white-space; cursor at beginning--ie, ^) | |
| xnoremap <silent> il :<c-u>normal! g_v^<cr> | |
| " "around line" (entire line sans trailing newline; cursor at beginning--ie, 0) | |
| xnoremap <silent> al :<c-u>normal! $v0<cr> | |
| "}}} | |
| """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
| "{{{ => My precious | |
| """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
| " Remove trailing whitespace | |
| " Taken from www.vi-improved.org/recommendations | |
| nnoremap <Leader>fw :<C-U>call functions#stripwhitespace#StripTrailingWhitespace()<CR> | |
| " Qargs populates args list with quickfix search list | |
| " Taken from vim tips book | |
| command! -nargs=0 -bar Qargs execute 'args' functions#qargs#QuickfixFilenames() | |
| " Autorun Commands | |
| """"""""""""""""""" | |
| augroup configgroup | |
| autocmd! | |
| " Return to last edit position when opening files (You want this!) | |
| autocmd BufReadPost * | |
| \ if line("'\"") > 0 && line("'\"") <= line("$") | | |
| \ exe "normal! g`\"" | | |
| \ endif | |
| " Additional Syntax Highlighting | |
| au BufEnter *.mrconfig set filetype=dosini | |
| au BufEnter *.git set filetype=dosini | |
| au BufEnter *.vcsh set filetype=dosini | |
| augroup END | |
| "}}} | |
| " | |
| " | |
| " | |
| " | |
| set clipboard=unnamedplus | |
| noremap <Leader>y "*y | |
| noremap <Leader>p "*p | |
| noremap <Leader>Y "+y | |
| noremap <Leader>P "+p | |
| autocmd FileType typescript JsPreTmpl html | |
| autocmd FileType typescript syn clear foldBraces | |
| au FileType javascript setlocal formatprg=prettier | |
| au FileType javascript.jsx setlocal formatprg=prettier | |
| au FileType typescript setlocal formatprg=prettier\ --parser\ typescript | |
| au FileType html setlocal formatprg=js-beautify\ --type\ html | |
| au FileType scss setlocal formatprg=prettier\ --parser\ css | |
| au FileType css setlocal formatprg=prettier\ --parser\ css | |
| " air-line | |
| let g:airline_powerline_fonts = 1 | |
| if !exists('g:airline_symbols') | |
| let g:airline_symbols = {} | |
| endif | |
| " unicode symbols | |
| let g:airline_left_sep = '»' | |
| let g:airline_left_sep = '▶' | |
| let g:airline_right_sep = '«' | |
| let g:airline_right_sep = '◀' | |
| let g:airline_symbols.linenr = '␊' | |
| let g:airline_symbols.linenr = '' | |
| let g:airline_symbols.linenr = '¶' | |
| let g:airline_symbols.branch = '⎇' | |
| let g:airline_symbols.paste = 'ρ' | |
| let g:airline_symbols.paste = 'Þ' | |
| let g:airline_symbols.paste = '∥' | |
| let g:airline_symbols.whitespace = 'Ξ' | |
| " airline symbols | |
| let g:airline_left_sep = '' | |
| let g:airline_left_alt_sep = '' | |
| let g:airline_right_sep = '' | |
| let g:airline_right_alt_sep = '' | |
| let g:airline_symbols.branch = '' | |
| let g:airline_symbols.readonly = '' | |
| let g:airline_symbols.linenr = '' | |
| let g:indentLine_leadingSpaceEnabled = 1 | |
| let g:indentLine_leadingSpaceChar = '·' | |
| set listchars=tab:·\ ,trail:· | |
| set list | |
| set guifont=Ubuntu\ Mono\ 10 | |
| if has('gui_running') | |
| set guifont=Consolas\ NF\ 10 | |
| endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment