Skip to content

Instantly share code, notes, and snippets.

@voger
Created March 11, 2018 10:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save voger/6425aa526ecc5ba01d5f2a6a11485128 to your computer and use it in GitHub Desktop.
Save voger/6425aa526ecc5ba01d5f2a6a11485128 to your computer and use it in GitHub Desktop.
" Get the defaults that most users want.
unlet! skip_defaults_vim
source $VIMRUNTIME/defaults.vim
filetype plugin indent on
call plug#begin('~/.vim/plugged')
Plug 'tpope/vim-fugitive' " Git support
Plug 'junegunn/vim-peekaboo' " Peek content of the registers
Plug 'junegunn/vim-easy-align' " A Vim alignment plugin
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } " A command-line fuzzy finder
Plug 'junegunn/fzf.vim'
Plug 'scrooloose/nerdtree', {'on':['NERDTreeToggle', 'NERDTreeInit', 'NERDTree', 'VimEnter']} " File manager
Plug 'tpope/vim-surround' " Surround stuff
Plug 'xtal8/traces.vim' " Range and pattern preview for Command-line mode
" Fuzzy file search
Plug 'voger/vim-numbertoggle' " Toggle line numbers
Plug 'tpope/vim-commentary' " Comment lines
Plug 'tpope/vim-eunuch' " helpers for UNIX
Plug 'cohama/lexima.vim' " Autoclose parentheses
Plug 'godlygeek/tabular' " Tabularize
Plug 'mileszs/ack.vim' " Search tool
Plug 'gerw/vim-HiLinkTrace' " Theming helper
Plug 'jlanzarotta/bufexplorer' " Explore open buffers
Plug 'airblade/vim-rooter' " Change root according to current project
" Plug 'Valloric/YouCompleteMe', { 'do': './install.py' } " Completion framework
Plug 'Yggdroot/indentLine' " Display indent guides
Plug '907th/vim-auto-save' " Autosave files
Plug 'qpkorr/vim-bufkill' " Close buffers without closing windows
Plug 'jszakmeister/vim-togglecursor' " Toggle the cursor shape in the terminal for Vim.
Plug 'kana/vim-textobj-user' " Create your own text objects. Required by Julian/vim-textobj-variable-segment
Plug 'Julian/vim-textobj-variable-segment' " A text object to turn foo_bar_baz into foo_baz *and* quuxSpamEggs into quuxEggs *and* shine your shoes
Plug 'romainl/vim-cool' " A very simple plugin that makes hlsearch more useful.
" Language support
Plug 'alvan/vim-closetag' " Auto close (X)HTML tags
Plug 'othree/html5.vim' " HTML5 omnicomplete and syntax
Plug 'plasticboy/vim-markdown' " Markdown support
Plug 'JamshedVesuna/vim-markdown-preview' " Preview markdown
Plug 'elixir-editors/vim-elixir' " Elixir language support.
Plug 'slashmili/alchemist.vim' " Elixir language support
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
" Test plugins
"
if has('nvim')
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
else
Plug 'Shougo/deoplete.nvim'
Plug 'roxma/nvim-yarp'
Plug 'roxma/vim-hug-neovim-rpc'
endif
call plug#end()
let g:deoplete#enable_at_startup = 1
" <Ctrl-l> redraws the screen and removes any search highlighting.
nnoremap <silent> <C-l> :nohl<CR><C-l>
" Trim white space from these file types
autocmd FileType *.c,*.cpp,*.java,*.php,*.ex,*.exs,*.eex,*.js,*.sh autocmd BufWritePre <buffer> %s/\s\+$//e
" Mappings
"
" indent file with F7
map <F7> mzgg=G`z
" Toggle NERDTree
map <C-n> :NERDTreeToggle<CR>
" switch between relative and non relative numbers
nmap <silent> <F2> :exec &nu==&rnu? "se nornu!" : "se rnu!"<CR>
" nmap : exec "se nornu!"<CR>
let g:UltiSnipsExpandTrigger="<c-space>"
let g:UltiSnipsListSnippets="<shift-space>"
let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>"
" Ident line don't mess with JSON quotes
let g:indentLine_fileTypeExclude = ['json']
" %% means cwd
cnoremap <expr> %% getcmdtype() == ':' ? expand('%:h').'/' : '%%'
" Kill other buffers
nnoremap <Leader>ba :w<bar>%bd<bar>e#<CR>
packadd! matchit " Enable matchit plugin
" Test FZF
nnoremap <C-p> :<C-u>FZF<CR>
let vim_markdown_preview_hotkey='<C-m>' " Preview markdown
let vim_markdown_preview_browser='google-chrome-stable'
let vim_markdown_preview_temp_file=0 " Don't delete the generated html after loaded in the browser
let g:vim_markdown_folding_disabled = 1 " Disable folding in markdown
let g:vim_markdown_conceal = 0 " Disable concealing in markdown
let vim_markdown_preview_github=1 " Use GitHub flavoured markdown.
let vim_markdown_preview_use_xdg_open=1 " Open browser
let g:auto_save=1 " enable AutoSave on Vim startup
" IndentLine Cusomization
let g:indentLine_color_dark = 1
let g:indentLine_color_term=234
let g:indentLine_bgcolor_term = 233
let g:indentLine_concealcursor = 'inc'
let g:indentLine_cwnceallevwl = 2
let g:togglecursor_default = "block"
let g:togglecursor_insert = "line"
let g:togglecursor_leave = "line"
let g:togglecursor_disable_tmux = 0
" rooter identifies root by
let g:rooter_patterns = ['.git/']
" Closetag activates on these files
let g:closetag_filenames = '*.html,*.html.eex'
" Customize statusline
set statusline=%f " file path
set statusline+=\ [%{strlen(&fenc)?&fenc:'none'}, " file encoding
set statusline+=%{&ff}] " file format
set statusline+=%h " help file flag
set statusline+=%m " modified flag
set statusline+=%r " read only flag
set statusline+=%y " filetype
set statusline+=%= " left/right separator
set statusline+=%c, " cursor column
set statusline+=%l/%L " cursor line/total lines
set statusline+=\ [%p%%] " percent through file]
if has("wildmenu")
set wildignore+=*.a,*.o
set wildignore+=*.bmp,*.gif,*.ico,*.jpg,*.png
set wildignore+=*.DS_Store,.git,*.hg,*.svn
set wildignore+=*~,*.swp,*.tmp
set wildignore+=*.so,*/_build/*,*/deps/*
set wildignore+=*.zip,*.tar.*
set wildmenu
set wildignorecase
set wildmode=longest:full,list:full
endif
" Lexima customizations
call lexima#add_rule({'char': '*', 'input_after': '*', 'filetype': 'markdown'})
call lexima#add_rule({'char': '*', 'at': '\%#\*', 'leave': 1, 'filetype': 'markdown'})
call lexima#add_rule({'char': '<BS>', 'at': '\*\%#\*', 'delete': 1, 'filetype': 'markdown'})
" Custom surround
autocmd FileType markdown let b:surround_42 = "*\r*"
" formatting
set tabstop=2
set softtabstop=2 " Tab key indents by 2 spaces.
set shiftwidth=2 " >> indents by 2 spaces.
set shiftround " >> indents to next multiple of 'shiftwidth'
set expandtab " Use spaces instead of tabs.
set autoindent " Indent according to previous line.
set backspace=indent,eol,start " Make backspace work as you would expect.
" appearance
set showmatch
set display+=lastline " Show as much as possible of the last line.
set showmode " Show current mode in command-line.
set showcmd " Show already typed keys when more are expected.
set ttyfast " Faster redrawing.
" set lazyredraw " Only redraw when necessary.
colorscheme monokai " Color scheme custom monokai
set number relativenumber " Turn on relative line numbers
set laststatus=2 " Always display the status line
set switchbuf=usetab " on open buffer search everywhere
" searching
set hlsearch " highlight search items
set ignorecase " case-insensitive searches
set smartcase " ignore case
" Create non existing directories when saving new files
" https://stackoverflow.com/questions/4292733/vim-creating-parent-directories-on-save
function! s:MkNonExDir(file, buf)
if empty(getbufvar(a:buf, '&buftype')) && a:file!~#'\v^\w+\:\/'
let dir=fnamemodify(a:file, ':h')
if !isdirectory(dir)
call mkdir(dir, 'p')
endif
endif
endfunction
augroup BWCCreateDir
autocmd!
autocmd BufWritePre * :call s:MkNonExDir(expand('<afile>'), +expand('<abuf>'))
augroup END
" Put all temporary files under the same directory.
" https://github.com/mhinz/vim-galore#temporary-files
"
" create directories if needed
if exists("*mkdir")
for dir in ["files", "files/backup", "files/swap", "files/undo", "files/info"]
if !isdirectory($HOME . "/.vim/" . dir)
call mkdir($HOME . "/.vim/" . dir)
endif
endfor
endif
set backup
set backupdir =$HOME/.vim/files/backup/
set backupext =-vimbackup
set backupskip =
set directory =$HOME/.vim/files/swap/
set updatecount =100
set undofile
set undodir =$HOME/.vim/files/undo/
set viminfo ='100,n$HOME/.vim/files/info/viminfo
unlet! skip_defaults_vim
source $VIMRUNTIME/defaults.vim
filetype plugin indent on
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment