123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261 |
- " __ __ _ __ _ _
- " \ \ / / | |/ _| ( ) (_)
- " \ \ /\ / /__ | | |_ ___|/ ___ __ ___ _ __ ___ _ __ ___
- " \ \/ \/ / _ \| | _/ _ \ / __| \ \ / / | '_ ` _ \| '__/ __|
- " \ /\ / (_) | | || __/ \__ \ \ V /| | | | | | | | | (__
- " \/ \/ \___/|_|_| \___| |___/ (_)_/ |_|_| |_| |_|_| \___|
-
-
- " Vim Plug {{{
-
- call plug#begin('~/.vim/plugged')
-
- " Visual
- Plug 'chriskempson/base16-vim'
- Plug 'vim-airline/vim-airline'
- Plug 'vim-airline/vim-airline-themes'
-
- " Fuzzy Finding
- Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
- Plug 'junegunn/fzf.vim'
-
- " Utils
- Plug 'tpope/vim-surround'
- Plug 'tpope/vim-fugitive'
- Plug 'tpope/vim-repeat'
- Plug 'tpope/vim-rsi'
- Plug 'tpope/vim-scriptease'
- Plug 'tpope/vim-afterimage'
-
- Plug 'haya14busa/incsearch.vim'
- Plug 'vim-scripts/matchit.zip'
- Plug 'junegunn/vim-easy-align'
-
- " Completion
- Plug 'ervandew/supertab'
- Plug 'Rip-Rip/clang_complete'
- Plug 'davidhalter/jedi-vim'
-
- " Misc
- Plug 'WolfeCub/vim-markdown-format', { 'for': ['md', 'markdown'] }
-
- call plug#end()
-
- " }}}
-
- " Basic Configuration {{{
-
- set nocompatible " be iMproved, required
- set tabstop=4 " Show existing tab with 4 spaces width
- set shiftwidth=4 " When indenting with '>', use 4 spaces width
- set expandtab " Basic tab options
- set hlsearch " Highlights search options
- set laststatus=2 " Displays statusline by default
- set backspace=2 " Allows for free backspacing
- set incsearch " Incremental search
- set ignorecase " Case insensitive matching
- set smartcase " Smartcase matching
- set showmatch " Show matching brackets when text indicator is over them
- set splitbelow " Open new splits below
- set splitright " Open new splits right
- set shortmess=atI " No intro message
- set title " Show the filename in the window titlebar
- set scrolloff=3 " Start scrolling three lines before the horizontal window border
- set visualbell " Disable screen flash bells
- set t_vb= " Disable audio bells
- set nostartofline " Don’t reset cursor to start of line when moving around.
- set foldenable " Turn on folds
- set fdm=indent " Fold on syntax
- set foldlevel=999 " Make it really high, so they're not displayed by default
- set hidden " Allow buffers with pending changes to be sent to background
- set timeoutlen=500 ttimeoutlen=0
-
- " Completion options
- set wildmode=list:longest
- set wildmenu "enable ctrl-n and ctrl-p to scroll thru matches
- set wildignore=*.o,*.obj,*~ "stuff to ignore when tab completing
- set wildignore+=*vim/backups*
- set wildignore+=*sass-cache*
- set wildignore+=*DS_Store*
- set wildignore+=vendor/rails/**
- set wildignore+=vendor/cache/**
- set wildignore+=*.gem
- set wildignore+=log/**
- set wildignore+=tmp/**
- set wildignore+=*.png,*.jpg,*.gif
-
- " }}}
-
- " Visual Configuration {{{
-
- set relativenumber
- set number
- set background=dark
- let base16colorspace=256 " Access colors present in 256 colorspace
- colorscheme base16-default-dark
- syntax enable
- set t_Co=256
- filetype on
- set showmatch
- set cursorline
- hi CursorLine cterm=bold ctermbg=NONE
-
- " }}}
-
- " Custom Keybinds {{{
-
- nnoremap <Space> <nop>
- let g:mapleader = "\<Space>"
- let g:maplocalleader = "\\"
-
- " Make j and k behave like they should for wrapped lines
- nnoremap j gj
- nnoremap k gk
- " Quick access to vimrc file
- nnoremap <leader>init :e ~/.vimrc<cr>
- " Fast saving
- nnoremap <leader>w :<C-u>update<cr>
- " Spellcheck
- noremap <leader>ss :setlocal spell!<cr>
- " Toggle folds
- nnoremap <silent> <Tab> :call Foldtoggle()<cr>
- " Source current file
- nnoremap <leader>S :source %<cr>
- " Source visual selection
- vnoremap <leader>S y:execute @@<cr>
- " Buffer navigation keybinds
- nnoremap <leader>b :b#<cr>
- nnoremap <leader>k :bd<cr>
- nnoremap <leader>m :Buffers<cr>
- " Tab navigation
- nnoremap <right> :tabnext<cr>
- nnoremap <left> :tabprevious<cr>
- " Don't lose visual selection with < >
- xnoremap < <gv
- xnoremap > >gv
- " Better redraw. Clears search and fixes syntax
- nnoremap <c-l> :nohlsearch<cr>:diffupdate<cr>:syntax sync fromstart<cr><c-l>
- " Quickly edit macros
- nnoremap <leader>@ :<c-u><c-r><c-r>='let @'. v:register .' = '. string(getreg(v:register))<cr><c-f><left>
- " FZF ag search
- nnoremap <leader>f :Ag<cr>
- " FZF search tags file
- nnoremap <leader>t :Tags<cr>
- nnoremap <leader>T :call fzf#vim#tags(expand('<cword>'))<cr>
-
- nnoremap <localleader><localleader> :b#<cr>
-
- " }}}
-
- " Custom Configuration {{{
-
- " Use :W to sudo write file
- command! W w !sudo tee % > /dev/null
-
- " Command to remove trailing whitespace
- function! TrimWhitespace()
- exec "%s/\\s\\+$//e"
- exec "normal! \<C-o>"
- endfunction
- command! -nargs=0 TrimWhitespace :call TrimWhitespace()
-
- " Adds the :Shell command to execute a command via the shell and place the result in a buffer
- function! s:ExecuteInShell(command)
- let command = join(map(split(a:command), 'expand(v:val)'))
- let winnr = bufwinnr('^' . command . '$')
- silent! execute winnr < 0 ? 'botright new ' . fnameescape(command) : winnr . 'wincmd w'
- setlocal buftype=nowrite bufhidden=wipe nobuflisted noswapfile nowrap number
- echo 'Execute ' . command . '...'
- silent! execute 'silent %!'. command
- silent! execute 'resize ' . line('$')
- silent! redraw
- silent! execute 'au BufUnload <buffer> execute bufwinnr(' . bufnr('#') . ') . ''wincmd w'''
- silent! execute 'nnoremap <silent> <buffer> <LocalLeader>r :call <SID>ExecuteInShell(''' . command . ''')<CR>'
- echo 'Shell command ' . command . ' executed.'
- endfunction
- command! -complete=shellcmd -nargs=+ Shell call s:ExecuteInShell(<q-args>)
-
- " Hides the error message when toggling folds
- function! Foldtoggle()
- try
- normal! za
- catch /E490/
- endtry
- endfunction
-
- " }}}
-
- " Plugin Configs {{{
-
- let g:airline_powerline_fonts = 1 " Sets the powerline font to work properly
- let g:airline#extensions#tabline#enabled = 1
-
- " FZF Settings
- " Insert mode completion
- imap <C-x><C-k> <Plug>(fzf-complete-word)
- imap <C-x><C-f> <Plug>(fzf-complete-path)
- imap <C-x><C-j> <Plug>(fzf-complete-file-ag)
- imap <C-x><C-l> <Plug>(fzf-complete-line)
- " [Tags] Command to generate tags file
- let g:fzf_tags_command = 'ctags -R'
-
- " incsearch
- map / <Plug>(incsearch-forward)
- map ? <Plug>(incsearch-backward)
- map g/ <Plug>(incsearch-stay)
-
- " Easy Align
- " Start interactive EasyAlign in visual mode (e.g. vipga)
- xmap ga <Plug>(EasyAlign)
- " Start interactive EasyAlign for a motion/text object (e.g. gaip)
- nmap ga <Plug>(EasyAlign)
-
- " Supertab
- let g:SuperTabDefaultCompletionType = "<C-X><C-O>"
- " If you prefer the Omni-Completion tip window to close when a selection is
- " made, these lines close it on movement in insert mode or when leaving
- " insert mode
- autocmd CursorMovedI * if pumvisible() == 0|pclose|endif
- autocmd InsertLeave * if pumvisible() == 0|pclose|endif
-
- " Set clang path for completion
- let g:clang_library_path='/usr/lib64/libclang.so.3.9'
-
- " Keybinds for Markdown Format
- nnoremap <leader>h1 :MakeHeader 1<cr>
- nnoremap <leader>h2 :MakeHeader 2<cr>
- nnoremap <leader>h3 :MakeHeader 3<cr>
- nnoremap <leader>h4 :MakeHeader 4<cr>
- nnoremap <leader>h5 :MakeHeader 5<cr>
- nnoremap <leader>h6 :MakeHeader 6<cr>
- vnoremap <leader>ll :<C-u>MakeList<cr>
- vnoremap <leader>nl :<C-u>MakeNumberedList<cr>
- vnoremap <leader>cb :<C-u>FencedCodeBlock<cr>
- vnoremap <leader>bq :<C-u>BlockQuote<cr>
- nnoremap <leader>li :MakeLink n<cr>
- vnoremap <leader>li :<C-u>MakeLink v<cr>
-
-
- " }}}
-
- " Temp & Testing {{{
-
- function! GetSyntaxID()
- return synID(line('.'), col('.'), 1)
- endfunction
-
- function! GetSyntaxParentID()
- return synIDtrans(GetSyntaxID())
- endfunction
-
- function! GetSyntax()
- echo synIDattr(GetSyntaxID(), 'name')
- exec "hi ".synIDattr(GetSyntaxParentID(), 'name')
- endfunction
-
- " }}}
-
- " Modeline {{{
- " vim: set fdm=marker foldlevel=0:
- "" }}}
|