Skip to content

Instantly share code, notes, and snippets.

@metalrufflez
Created November 29, 2017 15:35
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 metalrufflez/3403c9158bfc1f729b2baa09961e4c7b to your computer and use it in GitHub Desktop.
Save metalrufflez/3403c9158bfc1f729b2baa09961e4c7b to your computer and use it in GitHub Desktop.
" vim: set ft=vim:
function! SSHconfigFolds()
let thisline = getline(v:lnum)
if match(thisline, '^## ') >= 0
return ">2"
elseif match(thisline, '^# ') >= 0
return ">1"
else
return "="
endif
endfunction
setlocal foldexpr=SSHconfigFolds()
au BufRead,BufNewFile *.ssh/config set foldexpr=SSHconfigFolds()
function! FoldText()
let foldsize = (v:foldend-v:foldstart)
return getline(v:foldstart).' ('.foldsize.' lines)'
endfunction
" Vundle configfile source. Add the bundles to ~/.vundle and not here
" Do not add any config BEFORE this line
source ~/.vundle
source ~/.vim_functions
" BASIC CONFIG {{{1
syn on
set bg=dark
set is ic hls scs aw ru si ai
set sw=4 sts=4 ts=4
set noexpandtab
set wildmenu wim=longest,list
set cursorline relativenumber
set nocompatible modeline modelines=1
set showmode showcmd ttyfast
set laststatus=2
set noshowmode
set scrolloff=3
set undofile
colorscheme hybrid
filetype plugin indent on
" Setting swap and undo directories
set undodir=$HOME/.vim/undo
set backupdir=$HOME/.vim/swap
set directory=$HOME/.vim/swap
" Color fix
let &t_Co=256
" REMAPS {{{1
cab W w
cab Wq wq
" Fix j/k
" nnoremap j gj
" nnoremap k gk
" Easily return to normal mode using jj or kk
inoremap jj <ESC>
" Easily clean search hilighting with \<space>
nnoremap <leader><space> :noh<cr>
" Easily clean search hilighting with \<space>
nnoremap <leader>n :set relativenumber!<cr>
" Easily set paste!
nnoremap <leader>p :set paste!<cr>
" Remove trailing whitespace with \q
nnoremap <leader>q :%s/\s\+$//<cr>:let @/=''<CR>
" Easy switch wrap/nowrap
nnoremap <leader>w :set wrap!<CR>
" Runs bash
nnoremap <leader>b :!bash<CR>
" Easy open/close folds
nnoremap <leader>z zi
vnoremap <leader>z zi
nnoremap <Space> za
vnoremap <Space> za
nnoremap <S-Space> zA
vnoremap <S-Space> zA
nnoremap <silent> n n:call HLNext(0.4)<cr>
nnoremap <silent> N N:call HLNext(0.4)<cr>
" Remaps to easily switch to other split:
" nnoremap <D-h> <C-w>h
" nnoremap <D-j> <C-w>j
" nnoremap <D-k> <C-w>k
" nnoremap <D-l> <C-w>l
vmap <expr> <S-h> DVB_Drag('left')
vmap <expr> <S-l> DVB_Drag('right')
vmap <expr> <S-k> DVB_Drag('down')
vmap <expr> <S-j> DVB_Drag('up')
vmap <expr> D DVB_Duplicate()
" MAPPING MAGIC {{{1
" Toggle visible whitespace
nmap <leader>l :set list!<CR>
set listchars=tab:▸\ ,eol:¬
" Open VSplit with vimrc
nnoremap <leader>ev <C-w><C-v><C-l>:e $MYVIMRC<cr>
" Source vimrc
nnoremap <leader>er :source ~/.vimrc
" Open VSplit e move to it
nnoremap <leader>v <C-w>v<C-w>l
" Open file Browser vertically
nnoremap <leader>\| :Ve<cr>
" Open file Browser horizontally
nnoremap <leader>_ :Se<cr>
" Always display search results in the center of the screen
nnoremap n nzz
nnoremap N Nzz
nnoremap * *zz
nnoremap # #zz
nnoremap g* g*zz
nnoremap g# g#zz
" PLUGIN CONFIG {{{1
" Enable Indent Guides
let g:indent_guides_enable_on_vim_startup=1
" NERDTree Toggle
map <leader>T :NERDTreeToggle<CR>
map <leader>t :NERDTreeFocus<CR>
map <leader>c :NERDTreeCWD<CR>
let NERDTreeHijackNetrw=0
let NERDTreeShowBookmarks=1
" NERDTree auto close
au bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
" Auto Open if no file
" autocmd StdinReadPre * let s:std_in=1
" autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
" Gundo Toggle
nnoremap <leader>u :GundoToggle<CR>
" Gundo Settings
let g:gundo_right = 1
let g:gundo_close_on_revert = 1
let g:gundo_preview_bottom = 1
" Taglist plugin mapping
nmap <leader>o :TagbarToggle<CR>
let g:tagbar_type_ansible = {
\ 'ctagstype' : 'ansible',
\ 'kinds' : [
\ 't:tasks'
\ ],
\ 'sort' : 0
\ }
" THeme
let g:enable_bold_font = 1
" Airline Config
let g:airline_powerline_fonts = 1
let g:airline_theme = 'hybridline'
let g:airline_extensions = ['branch']
let g:airline#extensions#tabline#enabled = 1
" Syntastic Settings
let g:syntastic_json_checkers=['jsonlint']
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_error_symbol = '✗'
let g:syntastic_warning_symbol = '!'
" Git Push
nmap <leader>gp :Git push<CR>
" CTRL-P
nnoremap <C-o> :CtrlPMRUFiles<CR>
" ADVANCED CONFIGS {{{1
" Return cursor to where left
au BufWinLeave ?* mkview
au BufWinEnter ?* silent loadview
" Save when losing focus
" au FocusLost ?* :wa
" FILE TYPE SPECIFIC CONFIGS {{{2
" Custom file syntax
au BufRead,BufNewFile *.pp set filetype=puppet
au BufRead,BufNewFile *.{md,markdown,mdown,mkd,mkdn} set ft=mkd
au BufRead,BufNewFile *.{json,jsonp} set filetype=json
au BufRead,BufNewFile *.sls set filetype=sls
au BufRead,BufNewFile */ansible/*.yml set filetype=ansible
au BufRead,BufNewFile *.j2 set filetype=jinja2
" Python
au FileType python set omnifunc=pythoncomplete#Complete
autocmd CursorMovedI * if pumvisible() == 0|pclose|endif
autocmd InsertLeave * if pumvisible() == 0|pclose|endif
" JSON settings
au Filetype json set sts=2 ts=2 sw=2 foldmethod=syntax
" vim-task rebinding
au Filetype task inoremap <silent> <buffer> <C-E> <ESC>:call Toggle_task_status()<CR>i
au Filetype task noremap <silent> <buffer> <C-E> :call Toggle_task_status()<CR>
" Preview
nmap <leader>i :Preview<CR>
" Folding Configs {{{2
au BufRead,BufNewFile ?* set foldtext=FoldText()
" SSHconfig
au BufRead,BufNewFile *.ssh/config set foldexpr=SSHconfigFolds()
" Vim configs
au FileType vim set foldmethod=marker
" MACVIM CONFIG {{{1
if has("gui_running")
set guioptions-=r
set guioptions-=L
" set guifont=DroidSansMonoSlashedForPowerline:h12
set guifont=PragmataProMono:h14
endif
" vim: set ft=vim:
" Vundle config
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" Vundle config
filetype plugin indent on
" Bundles {{{1
Bundle 'gmarik/vundle'
Bundle 'msanders/snipmate.vim'
Bundle 'tpope/vim-surround'
Bundle 'tpope/vim-repeat'
Bundle 'tpope/vim-commentary'
Bundle 'tpope/vim-unimpaired'
Bundle 'tpope/vim-fugitive'
Bundle 'scrooloose/nerdtree'
Bundle 'scrooloose/syntastic'
Bundle 'sjl/gundo.vim'
Bundle 'matthias-guenther/hammer.vim'
Bundle 'godlygeek/tabular'
Bundle 'Valloric/YouCompleteMe'
Bundle 'junegunn/goyo.vim'
Bundle 'junegunn/limelight.vim'
Bundle 'ctrlpvim/ctrlp.vim'
" Bundle 'fholgado/minibufexpl.vim'
Bundle 'bling/vim-airline'
Bundle 'nvie/vim-flake8'
Bundle 'majutsushi/tagbar'
Bundle 'mtth/scratch.vim'
" Bundle 'AutoTag'
" Colorschemes {{{1
Bundle 'sjl/badwolf'
Bundle 'tomasr/molokai'
Bundle 'croaker/mustang-vim'
Bundle 'altercation/vim-colors-solarized'
Bundle 'chriskempson/vim-tomorrow-theme'
Bundle 'nanotech/jellybeans.vim'
Bundle 'djjcast/mirodark'
Plugin 'kristijanhusak/vim-hybrid-material'
Plugin 'w0ng/vim-hybrid'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'nathanaelkane/vim-indent-guides'
" Syntax {{{1
Bundle 'plasticboy/vim-markdown'
Bundle 'elzr/vim-json'
Bundle 'vim-ruby/vim-ruby'
Bundle 'rodjek/vim-puppet'
Bundle "lepture/vim-jinja"
Bundle "saltstack/salt-vim"
Bundle 'chase/vim-ansible-yaml'
Bundle 'Matt-Deacalion/vim-systemd-syntax'
Bundle 'robbles/logstash.vim'
Bundle 'stephpy/vim-yaml'
Bundle 'nginx.vim'
Bundle 'hdima/python-syntax'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment