Skip to content

Instantly share code, notes, and snippets.

@andrewstuart
Created May 17, 2017 17:22
Show Gist options
  • Save andrewstuart/bba90d6e9f7532688259dcee7cbc637a to your computer and use it in GitHub Desktop.
Save andrewstuart/bba90d6e9f7532688259dcee7cbc637a to your computer and use it in GitHub Desktop.
inoremap jk <Esc>
call pathogen#infect()
filetype plugin indent on
set nocompatible "This fixes the problem where arrow keys do not function properly on some systems.
set t_Co=256 "256 colors.
set background=dark
set cursorline "Highlight the cursor row.
set cursorcolumn "Highlight the cursor column.
set title "Make the window title awesome."
colors molokai
syntax on "Enables syntax highlighting for programming languages
set hidden "Allow changing buffers without having to write changes.
"set mouse=a "Allows you to click around the text editor with your mouse to move the cursor
set showmatch "Highlights matching brackets in programming languages
set autoindent "If you're indented, new lines will also be indented
set smartindent "Automatically indents lines after opening a bracket in programming languages
set backspace=2 "This makes the backspace key function like it does in other programs.
set tabstop=2 "How much space Vim gives to a tab
set number "Enables line numbering
set smarttab "Improves tabbing
set shiftwidth=2 "Assists code formatting
set expandtab
set diffopt+=vertical
"Search stuff
set incsearch ignorecase smartcase
"set shellcmdflag=-ic
"setlocal spell "Enables spell checking (CURRENTLY DISABLED because it's kinda annoying). Make sure to uncomment the next line if you use this.
"set spellfile=~/.vimwords.add "The location of the spellcheck dictionary. Uncomment this line if you uncomment the previous line.
set foldmethod=manual "Lets you hide sections of code
" set foldlevelstart=99
" nnoremap ; :
" nnoremap : ;
"--- The following commands make the navigation keys work like standard editors
imap <silent> <Down> <C-o>gj
imap <silent> <Up> <C-o>gk
map <F5> <Esc>:wall<CR>
map <F6> <Esc>:wqall<CR>
" imap <F5> <Esc>:wall<CR>
imap <F6> <Esc>:wqall<CR>
nmap <silent> <Down> gj
nmap <silent> <Up> gk
"--- Ends navigation commands
"--- The following adds a sweet menu, press F4 to use it.
source $VIMRUNTIME/menu.vim
set wildmenu
set cpo-=<
set wcm=<C-Z>
map <F2> :NERDTreeToggle<CR>
map <F4> :emenu <C-Z>
let &colorcolumn="81,120"
" let g:vim_markdown_folding_disabled=1
au FileType markdown set tw=80
au BufRead,BufNewFile .jshintrc set filetype=json
"Custom filename mappings
au BufRead,BufNewFile *.ino set filetype=arduino
au BufRead,BufNewFile *.es6 set filetype=es6.javascript
au BufRead,BufNewFile *test/spec/* set filetype=jasmine.javascript
au BufRead,BufNewFile *.xsl set filetype=xsl.xml
au BufRead,BufNewFile *.{jsp,html} set filetype=html
au BufRead,BufNewFile *.{xjb} set filetype=xjb.xml
au BufRead,BufNewFile Gruntfile.js set filetype=grunt.javascript
au BufRead,BufNewFile gulpfile* set filetype=gulp.javascript
au BufRead,BufNewFile *.tmpl.html set filetype=html.gohtmltmpl
"Autoreload xrdb
function! Xrdb()
let cmd = "xrdb " . expand("%")
let resp = system(cmd)
endfunction
au BufWritePost *.Xresources call Xrdb()
" let g:javascript_conceal=1
" set conceallevel=1
" let javascript_enable_domhtmlcss=1
"Function to commit.
function! GitCommit ()
execute 'write'
let message = input('Enter commit message: ')
execute '!git add ' . bufname('%') . ' && git commit -m ''' . message . ''';'
endfunction
imap <F7> <Esc>:call GitCommit()<CR>
map <F7> <Esc>:call GitCommit()<CR>
map <F10> :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<' . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<CR>
"Yank all lines to clipboard and return to place
map <leader>gy mMgg"*yG'M
let mapleader="\\"
" GO Settings
au FileType go nmap <leader>a <Plug>(go-alternate)
au FileType go nmap <leader>r <Plug>(go-run)
au FileType go nmap <leader>b <Plug>(go-build)
au FileType go nmap <leader>t <Plug>(go-test)
au FileType go nmap <leader>c <Plug>(go-coverage)
au FileType go nmap <leader>gb <Plug>(go-coverage-browser)
au FileType go nmap <leader>gd <Plug>(go-doc)
" au FileType go nmap <leader>gv <Plug>(go-doc-vertical)
au FileType go nmap <leader>i <Plug>(go-info)
au FileType go nmap <leader>gi <Plug>(go-install)
au FileType go nmap <leader>gr <Plug>(go-rename)
au FileType go nmap <leader>s <Plug>(go-implements)
au FileType go nmap <leader>d :!dlv debug .<CR>
au FileType go nmap <leader>md :make deploy<CR>
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_fields = 1
let g:go_highlight_types = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1
let g:go_snippet_case_type="camelcase"
let g:go_fmt_command= "goimports"
" GO+syntastic settings
let g:syntastic_go_checkers=["golint", "govet", "errcheck"]
let g:syntastic_mode_map = { "mode": "active" }
" let g:syntastic_mode_map = { "mode": "active", "passive_filetypes": ["go"] }
let g:go_list_type = "quickfix"
" JS settings
au FileType grunt.javascript nmap <leader>gr :!grunt<CR>
au FileType gulp.javascript nmap <leader>gr :!gulp<CR>
au FileType javascript nmap <leader>gnd :!node .<CR>
au FileType javascript nmap <leader>r :!node %<CR>
au FileType javascript nmap <leader>b :!gulp<CR>
au FileType es6.javascript nmap <leader>r :!babel-node %<CR>
" BASH Settings
au FileType sh nmap <leader>r :!./%<CR>
au FileType sh nmap <leader>s :!sudo %<CR>
au FileType groovy nmap <leader>r :!groovy %<CR>
au BufRead,BufNewFile *.gradle set filetype=gradle.groovy
au FileType gradle* nmap <leader>r :!gradle build<CR>
"YCM Settings (no conflict with Ultisnips)
let g:ycm_filetype_blacklist = {
\ 'md': 1,
\ 'python': 1
\}
let g:ycm_key_list_select_completion = ['<C-n>', '<Down>']
let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>']
" better key bindings for UltiSnipsExpandTrigger
let g:UltiSnipsExpandTrigger = "<tab>"
let g:UltiSnipsJumpForwardTrigger = "<tab>"
let g:UltiSnipsSnippetDirectories = ["UltiSnips", "snips"]
let g:EclimCompletionMethod='omnifunc'
au FileType sql nmap <leader>r :call RunSql()<CR>
function! RunSql ()
if exists('g:psql_cmd')
execute 'write'
execute '!' . g:psql_cmd . ' < ' . bufname('%') . '| less ;'
endif
endfunction
function! FormatXML ()
execute '%s/<\([^>]\)*>/\r&\r/g'
normal! gg=G
normal! ^O
execute 'g/^$/d'
endfunction
let g:jsx_ext_required = 0
let g:javascript_plugin_jsdoc = 1
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
" let g:syntastic_javascript_checkers=["eslint"]
let g:syntastic_java_checkers=[]
" Python settings
let g:pymode_python = 'python3'
" let g:pymode_rope_complete_on_dot = 0
au FileType python nmap <leader>gr :!python %<CR>
au FileType yaml nmap <leader>r :KubeApply<CR>
function! DoPrettyXML()
" save the filetype so we can restore it later
let l:origft = &ft
set ft=
" delete the xml header if it exists. This will
" permit us to surround the document with fake tags
" without creating invalid xml.
1s/<?xml .*?>//e
" insert fake tags around the entire document.
" This will permit us to pretty-format excerpts of
" XML that may contain multiple top-level elements.
0put ='<PrettyXML>'
$put ='</PrettyXML>'
silent %!xmllint --format -
" xmllint will insert an <?xml?> header. it's easy enough to delete
" if you don't want it.
" delete the fake tags
2d
$d
" restore the 'normal' indentation, which is one extra level
" too deep due to the extra tags we wrapped around the document.
silent %<
" back to home
1
" restore the filetype
exe "set ft=" . l:origft
endfunction
command! PrettyXML call DoPrettyXML()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment