function! GSO(question)

let firstarg=a:question

python << EOF

import vim

import os
import pickle as pkl
from io import BytesIO
from lxml import etree
from gso import load_up_answers, load_up_questions

question = vim.eval("firstarg")
vim.current.buffer.append(question)

results = []
i = 0
for result in load_up_questions(str(question), "python"):
    results.append(result)
    i += 1
    if i > 1:
        break

question_url = results[0][0]
answers = load_up_answers(question_url)

def wrap_with_root_tag(xml_string):
    xml_string = u"<root>"+xml_string+u"</root>"
    return xml_string

root = etree.iterparse(BytesIO(wrap_with_root_tag(answers[0][1]).encode('utf-8')))
for action, elem in root:
    if elem.tag == u'p' or elem.tag == u'code':
        for line in str(elem.text).split('\n'):
            vim.current.buffer.append(line)

EOF

endfunction

" command! -nargs=1 GSO call GSO(question)

Remove default language as python

function! GSO(question)

let firstarg=a:question

python << EOF

import vim

import os
import pickle as pkl
from io import BytesIO
from lxml import etree
from gso import load_up_answers, load_up_questions

question = vim.eval("firstarg")
vim.current.buffer.append(question)

results = []
i = 0
for result in load_up_questions(str(question)):
    results.append(result)
    i += 1
    if i > 1:
        break

question_url = results[0][0]
answers = load_up_answers(question_url)

def wrap_with_root_tag(xml_string):
    xml_string = u"<root>"+xml_string+u"</root>"
    return xml_string

root = etree.iterparse(BytesIO(wrap_with_root_tag(answers[0][1]).encode('utf-8')))
for action, elem in root:
    if elem.tag == u'p' or elem.tag == u'code':
        for line in str(elem.text).split('\n'):
            vim.current.buffer.append(line)

EOF

endfunction

" command! -nargs=1 GSO call GSO(question)


" --------------------------------------------------------------------------
" Dusk Colour Scheme
" --------------------------------------------------------------------------

hi clear

if exists("syntax_on")
    syntax reset
endif

let colors_name = "dusk"

hi Comment          ctermfg=8
hi Normal           ctermfg=none        ctermbg=none
hi NonText          ctermfg=none        ctermbg=none
hi LineNr           ctermfg=8
hi CursorLineNr     ctermfg=8
hi String           ctermfg=3
hi Keyword          ctermfg=2
hi Statement        ctermfg=2
hi Function         ctermfg=4
hi PreProc          ctermfg=5
hi Constant         ctermfg=6
hi Character        ctermfg=6
hi Number           ctermfg=6
hi Visual                               ctermbg=237
hi Search                               ctermbg=237
hi MatchParen                           ctermbg=none        cterm=underline
hi StatusLine       ctermfg=244         ctermbg=0

Update vim colorscheme ErrorMsg background

" --------------------------------------------------------------------------
" Dusk Colour Scheme
" --------------------------------------------------------------------------

hi clear

if exists("syntax_on")
    syntax reset
endif

let colors_name = "dusk"

hi Comment          ctermfg=8
hi Normal           ctermfg=none        ctermbg=none
hi NonText          ctermfg=none        ctermbg=none
hi LineNr           ctermfg=8
hi CursorLineNr     ctermfg=8
hi String           ctermfg=3
hi Keyword          ctermfg=2
hi Statement        ctermfg=2
hi Function         ctermfg=4
hi PreProc          ctermfg=5
hi Constant         ctermfg=6
hi Character        ctermfg=6
hi Number           ctermfg=6
hi Visual                               ctermbg=237
hi Search                               ctermbg=237
hi MatchParen                           ctermbg=none        cterm=underline
hi StatusLine       ctermfg=244         ctermbg=0
hi ErrorMsg                             ctermbg=52


set termguicolors
colorscheme despacio
highlight Normal guibg=none ctermbg=none
highlight NonText guibg=none ctermbg=none
highlight LineNr guibg=none ctermbg=none

let g:airline_theme = 'ubaryd'

" NERDTree Key
nnoremap <leader>n :NERDTreeToggle<CR>

" Neomake
augroup neomake_lint
    autocmd!
    autocmd BufWritePost * Neomake
augroup END

Change airline theme to minimalist

set termguicolors
colorscheme despacio
highlight Normal guibg=none ctermbg=none
highlight NonText guibg=none ctermbg=none
highlight LineNr guibg=none ctermbg=none

let g:airline_theme = 'minimalist'

" NERDTree Key
nnoremap <leader>n :NERDTreeToggle<CR>

" Neomake
augroup neomake_lint
    autocmd!
    autocmd BufWritePost * Neomake
augroup END


" be consistent with C and D which reach the end of line
nnoremap Y y$
set encoding=utf-8
set backspace=indent,eol,start

Exit to normal mode on "jj"

" be consistent with C and D which reach the end of line
nnoremap Y y$
set encoding=utf-8
set backspace=indent,eol,start

inoremap <silent> jj <esc>


hi clear
if exists("syntax_on")
    syntax reset
endif

" Load the base color scheme
runtime colors/peachpuff.vim

" Overload the colorscheme name
let g:colors_name = "my-peachpuff"

" Setup my own colors
hi Folded       guibg=grey30 guifg=gold ctermfg=darkgrey ctermbg=none
hi FoldColumn   guibg=grey30 guifg=tan ctermfg=darkgrey ctermbg=none
hi Search       cterm=reverse ctermbg=none

Modify the Search highlight colors.

hi clear
if exists("syntax_on")
    syntax reset
endif

" Load the base color scheme
runtime colors/peachpuff.vim

" Overload the colorscheme name
let g:colors_name = "my-peachpuff"

" Setup my own colors
hi Folded       guibg=grey30 guifg=gold ctermfg=darkgrey ctermbg=none
hi FoldColumn   guibg=grey30 guifg=tan ctermfg=darkgrey ctermbg=none
hi Search       ctermfg=0 ctermbg=3


let python_highlight_all = 1

Set up `yapf2` for Python code formatting

let python_highlight_all = 1

" Arch suffixes its Python 2 binaries with '2'
if executable('yapf2')
  Glaive codefmt yapf_executable='yapf2'
end


" HTML5 ominicomplete & syntax
NeoBundleLazy 'othree/html5.vim', {
            \     'autoload': {'filetypes': ['html']}
            \  }
" CSS3 syntax
NeoBundleLazy 'hail2u/vim-css3-syntax', {
            \     'autoload': {'filetypes': ['css']}
            \  }
" Coq syntax
NeoBundleLazy 'jvoorhis/coq.vim', {
            \     'autoload': {'filetypes': ['coq']}
            \  }
" CoffeeScript
if v:version >= 704
    au BufRead,BufNewFile,BufReadPre *.coffee set filetype=coffee
    NeoBundleLazy 'kchmck/vim-coffee-script', {
                \     'autoload': {'filetypes': ['coffee']}
                \  }
endif
" Scala
au BufRead,BufNewFile,BufReadPre *.scala set filetype=scala
NeoBundleLazy 'derekwyatt/vim-scala', {
                \     'autoload': {'filetypes': ['scala']}
                \  }

Enable HTML5 syntax highlighting in htmldjango

" HTML5 ominicomplete & syntax
NeoBundleLazy 'othree/html5.vim', {
            \     'autoload': {'filetypes': ['html', 'htmldjango']}
            \  }
" CSS3 syntax
NeoBundleLazy 'hail2u/vim-css3-syntax', {
            \     'autoload': {'filetypes': ['css']}
            \  }
" Coq syntax
NeoBundleLazy 'jvoorhis/coq.vim', {
            \     'autoload': {'filetypes': ['coq']}
            \  }
" CoffeeScript
if v:version >= 704
    au BufRead,BufNewFile,BufReadPre *.coffee set filetype=coffee
    NeoBundleLazy 'kchmck/vim-coffee-script', {
                \     'autoload': {'filetypes': ['coffee']}
                \  }
endif
" Scala
au BufRead,BufNewFile,BufReadPre *.scala set filetype=scala
NeoBundleLazy 'derekwyatt/vim-scala', {
                \     'autoload': {'filetypes': ['scala']}
                \  }


" Set filetype for file names without format.
augroup file_type_check
  autocmd!
  autocmd BufNewFile,BufRead *named.conf* set ft=named
  autocmd BufNewFile,BufRead *.txt,INSTALL,NEWS,README,TODO
        \ if &ft == ""  |
        \   set ft=text |
        \ endif
augroup END

" Write all changed buffers when Vim loses input focus.
augroup write_buffer_on_focus_lost
  autocmd!
  autocmd FocusLost * silent! wall
augroup END

" Restore cursor position when opening file except for gitcommit filetype.
augroup restore_cursor_position
  autocmd!
  autocmd BufReadPost *
        \ if &ft !=# 'gitcommit' && line("'\"") > 1 && line("'\"") <= line("$") |
        \   exe "normal! g`\"" |
        \ endif
augroup END

Set txt as the filetype of LICENSE files

" Set filetype for file names without format.
augroup file_type_check
  autocmd!
  autocmd BufNewFile,BufRead *named.conf* set ft=named
  autocmd BufNewFile,BufRead *.txt,INSTALL,LICENSE,NEWS,README,TODO
        \ if &ft == ""  |
        \   set ft=text |
        \ endif
augroup END

" Write all changed buffers when Vim loses input focus.
augroup write_buffer_on_focus_lost
  autocmd!
  autocmd FocusLost * silent! wall
augroup END

" Restore cursor position when opening file except for gitcommit filetype.
augroup restore_cursor_position
  autocmd!
  autocmd BufReadPost *
        \ if &ft !=# 'gitcommit' && line("'\"") > 1 && line("'\"") <= line("$") |
        \   exe "normal! g`\"" |
        \ endif
augroup END


nnoremap <buffer> <Left> :CoqToCursor<CR>
nnoremap <buffer> <Right> :CoqToCursor<CR>
nnoremap <buffer> <Up> :CoqUndo<CR>
nnoremap <buffer> <Down> :CoqNext<CR>

Make vim Coq bindings work in insert mode

nnoremap <buffer> <Left> :CoqToCursor<CR>
nnoremap <buffer> <Right> :CoqToCursor<CR>
nnoremap <buffer> <Up> :CoqUndo<CR>
nnoremap <buffer> <Down> :CoqNext<CR>

inoremap <buffer> <Left> <C-o>:CoqToCursor<CR>
inoremap <buffer> <Right> <C-o>:CoqToCursor<CR>
inoremap <buffer> <Up> <C-o>:CoqUndo<CR>
inoremap <buffer> <Down> <C-o>:CoqNext<CR>


if !exists('g:colors_name') || g:colors_name != 'solarized8_dark'
  colorscheme solarized8_dark
endif

Add vim keybinding to switch solarized themes

if !exists('g:colors_name') || g:colors_name != 'solarized8_dark'
  colorscheme solarized8_dark
endif

nnoremap  <localleader>B :<c-u>exe "colors" (g:colors_name =~# "dark"
    \ ? substitute(g:colors_name, 'dark', 'light', '')
    \ : substitute(g:colors_name, 'light', 'dark', '')
    \ )<cr>


filetype off

set rtp+=~/.vim/bundle/Vundle.vim/
call vundle#rc()

Plugin 'altercation/vim-colors-solarized'
Plugin 'airblade/vim-gitgutter'
Plugin 'derekwyatt/vim-scala'
Plugin 'gmarik/Vundle.vim'
Plugin 'groenewege/vim-less'
Plugin 'jalvesaq/R-Vim-runtime'
Plugin 'jalvesaq/Nvim-R'
Plugin 'jistr/vim-nerdtree-tabs'
Plugin 'kien/ctrlp.vim'
Plugin 'majutsushi/tagbar'
Plugin 'scrooloose/syntastic'
Plugin 'scrooloose/nerdtree'
Plugin 'tpope/vim-commentary'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-markdown'
Plugin 'Valloric/YouCompleteMe'
Plugin 'Valloric/MatchTagAlways'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'https://bitbucket.org/snakemake/snakemake', {'rtp': 'misc/vim/'}

" Restore
filetype on

Use own Snakemake Vim configuration

filetype off

set rtp+=~/.vim/bundle/Vundle.vim/
call vundle#rc()

Plugin 'altercation/vim-colors-solarized'
Plugin 'airblade/vim-gitgutter'
Plugin 'derekwyatt/vim-scala'
Plugin 'gmarik/Vundle.vim'
Plugin 'groenewege/vim-less'
Plugin 'jalvesaq/R-Vim-runtime'
Plugin 'jalvesaq/Nvim-R'
Plugin 'jistr/vim-nerdtree-tabs'
Plugin 'kien/ctrlp.vim'
Plugin 'majutsushi/tagbar'
Plugin 'scrooloose/syntastic'
Plugin 'scrooloose/nerdtree'
Plugin 'tpope/vim-commentary'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-markdown'
Plugin 'Valloric/YouCompleteMe'
Plugin 'Valloric/MatchTagAlways'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'klmr/vim-snakemake'

" Restore
filetype on


" Powerline - The ultimate statusline utility
"
" Author: Kim Silkebækken <kim.silkebaekken+vim@gmail.com>
" Source repository: https://github.com/Lokaltog/vim-powerline

" Script initialization {{{
	if exists('g:Powerline_loaded') || &compatible || version < 702
		finish
	endif

	let g:Powerline_loaded = 1
" }}}
" Set default options {{{
	function! s:InitOptions(options) " {{{
		for [key, value] in items(a:options)
			if ! exists('g:Powerline_' . key)
				exec printf('let g:Powerline_%s = %s', key, string(value))
			endif
		endfor
	endfunction " }}}
	call s:InitOptions({
	\   'theme'        : 'distinguished'
	\ , 'symbols'      : 'compatible'
	\ , 'cache_file'   : '/tmp/Powerline.cache'
	\ })
" }}}
" Autocommands {{{
	augroup Powerline
		autocmd!

		" Reload statuslines when changing color scheme
		au ColorScheme *
			\ call Pl#Load()

		au BufEnter,WinEnter *
			\ call Pl#UpdateStatusline(1)

		au BufLeave,WinLeave *
			\ call Pl#UpdateStatusline(0)
	augroup END
" }}}

Update statusline when filetype is changed

" Powerline - The ultimate statusline utility
"
" Author: Kim Silkebækken <kim.silkebaekken+vim@gmail.com>
" Source repository: https://github.com/Lokaltog/vim-powerline

" Script initialization {{{
	if exists('g:Powerline_loaded') || &compatible || version < 702
		finish
	endif

	let g:Powerline_loaded = 1
" }}}
" Set default options {{{
	function! s:InitOptions(options) " {{{
		for [key, value] in items(a:options)
			if ! exists('g:Powerline_' . key)
				exec printf('let g:Powerline_%s = %s', key, string(value))
			endif
		endfor
	endfunction " }}}
	call s:InitOptions({
	\   'theme'        : 'distinguished'
	\ , 'symbols'      : 'compatible'
	\ , 'cache_file'   : '/tmp/Powerline.cache'
	\ })
" }}}
" Autocommands {{{
	augroup Powerline
		autocmd!

		" Reload statuslines when changing color scheme
		au ColorScheme *
			\ call Pl#Load()

		au BufEnter,WinEnter,FileType *
			\ call Pl#UpdateStatusline(1)

		au BufLeave,WinLeave *
			\ call Pl#UpdateStatusline(0)
	augroup END
" }}}


" All the Vim settings go here!
" =============================

""""""""""""""""""""""""""""""
" Appearance
""""""""""""""""""""""""""""""
set t_Co=256 " Explicitly tell vim that the terminal supports 256 colors"
colorscheme onedark
let g:airline_theme='onedark'
set termencoding=utf-8

if has("unix")
  let s:uname = system("uname -s")
  if s:uname =~ "Darwin"
    let g:onedark_termcolors=16
  else
    let g:onedark_termcolors=256
  endif
endif

set background=dark

let mapleader = ","			" map leader key to ','

set textwidth=120
set relativenumber
set number
set hlsearch				" highlight search terms
set list listchars=tab:»·,trail:·	" show hidden tabs and white spaces

set autowrite				" save on buffer switch
set hidden				" hide buffers instead of closing them
set history=1000			" remember more commands and search history
set undolevels=1000			" use many muchos levels of undo
set timeoutlen=1000 ttimeoutlen=0	" make escape command faster

""""""""""""""""""""""""""""""
" Gathers vim files
""""""""""""""""""""""""""""""
set backupdir=~/.vim/.backup/
set directory=~/.vim/.swap/

Configure vim to search while typing

" All the Vim settings go here!
" =============================

""""""""""""""""""""""""""""""
" Appearance
""""""""""""""""""""""""""""""
set t_Co=256 " Explicitly tell vim that the terminal supports 256 colors"
colorscheme onedark
let g:airline_theme='onedark'
set termencoding=utf-8

if has("unix")
  let s:uname = system("uname -s")
  if s:uname =~ "Darwin"
    let g:onedark_termcolors=16
  else
    let g:onedark_termcolors=256
  endif
endif

set background=dark

let mapleader = ","			" map leader key to ','

set textwidth=120
set relativenumber
set number
set hlsearch				" highlight search terms
set incsearch       " search as you type"
set list listchars=tab:»·,trail:·	" show hidden tabs and white spaces

set autowrite				" save on buffer switch
set hidden				" hide buffers instead of closing them
set history=1000			" remember more commands and search history
set undolevels=1000			" use many muchos levels of undo
set timeoutlen=1000 ttimeoutlen=0	" make escape command faster

""""""""""""""""""""""""""""""
" Gathers vim files
""""""""""""""""""""""""""""""
set backupdir=~/.vim/.backup/
set directory=~/.vim/.swap/


function! GetCompDB()
    exec CMakeCompDB()
endfunc
"let FnCMakeCompDB = function("GetCompDB")
"let funccmakecompdb = string(FnCMakeCompDB)
"let RunCMakeCompDB = function('GetCompDB')
"function cmake.run() dict
"   let self.fn = function('GetCompDB')
"endfunction
let g:neomake_cmakecompdb_maker = {
    \ 'exe': string(function("GetCompDB")),
    \ 'args': ['']
    \ }
noremap <unique> <Plug>NeomakeCompDB :Neomake! cmakecompdb<CR>
function! CMakeTargets()
    echo "Get CMake Targets"
endfunction

Tweak exe argument for neomake maker.

function! GetCompDB()
    exec CMakeCompDB()
endfunc
"let FnCMakeCompDB = function("GetCompDB")
"let funccmakecompdb = string(FnCMakeCompDB)
"let RunCMakeCompDB = function('GetCompDB')
"   let self.fn = function("GetCompDB")
function cmake.run() dict
   let self.fn = GetCompDB
endfunction
let g:neomake_cmakecompdb_maker = {
    \ 'exe': string(cmake.run),
    \ 'args': ['']
    \ }
noremap <unique> <Plug>NeomakeCompDB :Neomake! cmakecompdb<CR>
function! CMakeTargets()
    echo "Get CMake Targets"
endfunction


"function! GetCompDB()
"    exec CMakeCompDB()
"endfunc
"let FnCMakeCompDB = function("GetCompDB")
"let funccmakecompdb = string(FnCMakeCompDB)
"let RunCMakeCompDB = function('GetCompDB')
"   let self.fn = function("GetCompDB")
"function cmake.run() dict
"   let self.fn = FnCMakeCompDB
"endfunction
"let g:neomake_cmakecompdb_maker = {
"    \ 'exe': string(FnCMakeCompDB),
"    \ 'args': ['']
"    \ }
noremap <unique> <Plug>GenerateCompDB :exec CMakeCompDB()<CR>
function! CMakeTargets()
    echo "Get CMake Targets"
endfunction

Fix command mapping for plugin.

"function! GetCompDB()
"    exec CMakeCompDB()
"endfunc
"let FnCMakeCompDB = function("GetCompDB")
"let funccmakecompdb = string(FnCMakeCompDB)
"let RunCMakeCompDB = function('GetCompDB')
"   let self.fn = function("GetCompDB")
"function cmake.run() dict
"   let self.fn = FnCMakeCompDB
"endfunction
"let g:neomake_cmakecompdb_maker = {
"    \ 'exe': string(FnCMakeCompDB),
"    \ 'args': ['']
"    \ }
nmap <unique> <Plug>GenerateCompDB :exec CMakeCompDB()<CR>
function! CMakeTargets()
    echo "Get CMake Targets"
endfunction


" ==========================================
" Syntastic settings

let g:syntastic_javascript_syntax_checker = "jshint"
let g:syntastic_coffee_coffeelint_args="--csv --file $HOME/.coffeelint.json"
let g:syntastic_ruby_checkers = ['mri', 'rubocop']
let g:syntastic_check_on_open = 0

Add rbenv shims for rubocop

" ==========================================
" Syntastic settings

let g:syntastic_javascript_syntax_checker = "jshint"
let g:syntastic_coffee_coffeelint_args="--csv --file $HOME/.coffeelint.json"
let g:syntastic_ruby_checkers = ['mri', 'rubocop']
let g:syntastic_ruby_rubocop_exec = "$RBENV_ROOT/shims/ruby $RBENV_ROOT/shims/rubocop"
let g:syntastic_check_on_open = 0


set enc=utf-8
set fenc=utf-8
set ambiwidth=double

Add "scriptencoding" config for nvim

set encoding=utf-8
set fileencoding=utf-8
scriptencoding utf-8

set ambiwidth=double


" Variables
let s:no_python_support = "Vim is compiled without python support"
let s:no_ruby_support = "Vim is compiled without ruby support"

" Plugins that requires python support
if !has("python")
  call janus#disable_plugin("gundo", s:no_python_support)
endif

" Plugins that requires ruby support
if !has("ruby")
  call janus#disable_plugin("ruby", s:no_ruby_support)
endif

" Ack requires ack command
if !executable("ack") && !executable("ack-grep")
  call janus#disable_plugin("ack", "The ack program is not installed")
endif

" Gist-vim requires curl
if !executable("curl")
  call janus#disable_plugin("gist", "The curl program is not installed")
endif

" Tagbar requires ctags
if !executable("ctags")
  call janus#disable_plugin("tagbar", "The ctags program is not installed")
endif

" nodejs does not protect itself
" See #336
if exists("*DetectNode")
  call janus#disable_plugin("nodejs", "Nodejs already exists on your system.")
endif

Configure Ack plugin to use ack-grep when that one is available

" Variables
let s:no_python_support = "Vim is compiled without python support"
let s:no_ruby_support = "Vim is compiled without ruby support"

" Plugins that requires python support
if !has("python")
  call janus#disable_plugin("gundo", s:no_python_support)
endif

" Plugins that requires ruby support
if !has("ruby")
  call janus#disable_plugin("ruby", s:no_ruby_support)
endif

" Ack requires ack command
if executable("ack")
  " use default config
elseif executable("ack-grep")
  let g:ackprg="ack-grep -H --nocolor --nogroup --column"
else
  call janus#disable_plugin("ack", "The ack program is not installed")
endif

" Gist-vim requires curl
if !executable("curl")
  call janus#disable_plugin("gist", "The curl program is not installed")
endif

" Tagbar requires ctags
if !executable("ctags")
  call janus#disable_plugin("tagbar", "The ctags program is not installed")
endif

" nodejs does not protect itself
" See #336
if exists("*DetectNode")
  call janus#disable_plugin("nodejs", "Nodejs already exists on your system.")
endif


" Copyright 2011 The Go Authors. All rights reserved.
" Use of this source code is governed by a BSD-style
" license that can be found in the LICENSE file.
"
" fmt.vim: Vim command to format Go files with gofmt.
"
" This filetype plugin add a new commands for go buffers:
"
"   :Fmt
"
"       Filter the current Go buffer through gofmt.
"       It tries to preserve cursor position and avoids
"       replacing the buffer with stderr output.
"

command! -buffer Fmt call s:GoFormat()

function! s:GoFormat()
    let view = winsaveview()
    %!gofmt
    if v:shell_error
        %| " output errors returned by gofmt
           " TODO(dchest): perhaps, errors should go to quickfix
        undo
	echohl Error | echomsg "Gofmt returned error" | echohl None
    endif
    call winrestview(view)
endfunction

" vim:ts=4:sw=4:et

Send GoFmt errors to a location list

" Copyright 2011 The Go Authors. All rights reserved.
" Use of this source code is governed by a BSD-style
" license that can be found in the LICENSE file.
"
" fmt.vim: Vim command to format Go files with gofmt.
"
" This filetype plugin add a new commands for go buffers:
"
"   :Fmt
"
"       Filter the current Go buffer through gofmt.
"       It tries to preserve cursor position and avoids
"       replacing the buffer with stderr output.
"

command! -buffer Fmt call s:GoFormat()

function! s:GoFormat()
    let view = winsaveview()
    silent %!gofmt
    if v:shell_error
        let errors = []
        for line in getline(1, line('$'))
            let tokens = matchlist(line, '^\(.\{-}\):\(\d\+\):\(\d\+\)\s*\(.*\)')
            if !empty(tokens)
                call add(errors, {"filename": @%,
                                 \"lnum":     tokens[2],
                                 \"col":      tokens[3],
                                 \"text":     tokens[4]})
            endif
        endfor
        if empty(errors)
            % | " Couldn't detect gofmt error format, output errors
        endif
        undo
        if !empty(errors)
            call setloclist(0, errors, 'r')
        endif
        echohl Error | echomsg "Gofmt returned error" | echohl None
    endif
    call winrestview(view)
endfunction

" vim:ts=4:sw=4:et


if janus#is_plugin_enabled("ctrlp")
  let g:ctrlp_map = ''
  let g:ctrlp_custom_ignore = {
    \ 'dir':  '\.git$\|\.hg$\|\.svn$',
    \ 'file': '\.pyc$\|\.pyo$\|\.rbc$|\.rbo$\|\.class$\|\.o$\|\~$\',
    \ }
endif

if has("gui_macvim") && has("gui_running")
  call janus#add_mapping('ctrlp', 'map', '<D-t>', ':CtrlP<CR>')
  call janus#add_mapping('ctrlp', 'imap', '<D-t>', '<ESC>:CtrlP<CR>')
else
  call janus#add_mapping('ctrlp', 'map', '<C-t>', ':CtrlP<CR>')
  call janus#add_mapping('ctrlp', 'imap', '<C-t>', '<ESC>:CtrlP<CR>')
endif

Remove superfluous map to :CtrlP

if janus#is_plugin_enabled("ctrlp")
  let g:ctrlp_map = ''
  let g:ctrlp_custom_ignore = {
    \ 'dir':  '\.git$\|\.hg$\|\.svn$',
    \ 'file': '\.pyc$\|\.pyo$\|\.rbc$|\.rbo$\|\.class$\|\.o$\|\~$\',
    \ }
endif

if has("gui_macvim") && has("gui_running")
  call janus#add_mapping('ctrlp', 'map', '<D-t>', ':CtrlP<CR>')
  call janus#add_mapping('ctrlp', 'imap', '<D-t>', '<ESC>:CtrlP<CR>')
endif


autocmd BufRead,BufNewFile *.tf set filetype=terraform
autocmd BufRead,BufNewFile *.tfvars set filetype=terraform
autocmd BufRead,BufNewFile *.tfstate set filetype=json
autocmd BufRead,BufNewFile *.tfstate.backup set filetype=json

Remove Vim's default filetype detection for .tf files

" By default, Vim associates .tf files with TinyFugue - tell it not to.
autocmd! filetypedetect BufRead,BufNewFile *.tf
autocmd BufRead,BufNewFile *.tf set filetype=terraform
autocmd BufRead,BufNewFile *.tfvars set filetype=terraform
autocmd BufRead,BufNewFile *.tfstate set filetype=json
autocmd BufRead,BufNewFile *.tfstate.backup set filetype=json


set nocompatible

let g:CommandTMaxHeight = 20
" let g:easytags_suppress_ctags_warning = 1
let g:easytags_resolve_links = 1
let g:easytags_cmd = '/usr/local/bin/ctags'
let g:easytags_dynamic_files = 1

let g:UltiSnipsEditSplit = "horizontal"
let g:UltiSnipsExpandTrigger = "<c-tab>"
let g:UltiSnipsListSnippets = "<c-s-tab>"

source ~/.vim/bundles.vim

syntax on
filetype plugin indent on

" For all text files set 'textwidth' to 78 characters.
autocmd FileType text setlocal textwidth=78

" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
autocmd BufReadPost *
  \ if line("'\"") > 0 && line("'\"") <= line("$") |
  \   exe "normal! g`\"" |
  \ endif

function! GitStatusLine()
  if exists('g:loaded_fugitive')
    return fugitive#statusline()
  endif
  return "(fugitive not loaded)"
endfunction

set statusline=%{GitStatusLine()}\ %<%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P

Store vim notes in Dropbox or /Users/mange

set nocompatible

let g:CommandTMaxHeight = 20
" let g:easytags_suppress_ctags_warning = 1
let g:easytags_resolve_links = 1
let g:easytags_cmd = '/usr/local/bin/ctags'
let g:easytags_dynamic_files = 1

let g:UltiSnipsEditSplit = "horizontal"
let g:UltiSnipsExpandTrigger = "<c-tab>"
let g:UltiSnipsListSnippets = "<c-s-tab>"

if isdirectory($HOME . '/Dropbox/Notes')
  let g:notes_directory = '~/Dropbox/Notes'
elseif isdirectory($HOME . '/Documents/Notes')
  let g:notes_directory = '~/Documents/Notes'
endif

source ~/.vim/bundles.vim

syntax on
filetype plugin indent on

" For all text files set 'textwidth' to 78 characters.
autocmd FileType text setlocal textwidth=78

" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
autocmd BufReadPost *
  \ if line("'\"") > 0 && line("'\"") <= line("$") |
  \   exe "normal! g`\"" |
  \ endif

function! GitStatusLine()
  if exists('g:loaded_fugitive')
    return fugitive#statusline()
  endif
  return "(fugitive not loaded)"
endfunction

set statusline=%{GitStatusLine()}\ %<%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P


set number         " Show line number
set showcmd        " Show the command you are typing in the bottom right corner
set hidden         " Allow buffers to exist without a window
syntax on          " Turn on syntax highlighting

" ================ Indentation ===============

set tabstop=2
set shiftwidth=2
set softtabstop=2
set expandtab
set autoindent

" Set tab completion propery
set wildmode=longest,list,full
set wildmenu

" Set backup directory
set dir=/private/tmp,/tmp
set backupcopy=yes

" I mistype these all the time
command! W w
command! Q q
command! Qa qa
command! QA qa

colorscheme solarized

" Remove the scrollbar
set guioptions-=r
set guioptions-=L

" Set font
set guifont=Monaco\ for\ Powerline:h13

" Search options
set incsearch
set hlsearch

" Always show the status line
set laststatus=2

" Whitespace highlighting
silent! nnoremap <silent> <Leader>$ :set list!<CR>
silent! nnoremap <silent> <Leader>h :noh<return>

" Pretty UTF8 characters
set listchars=tab:▸\ ,eol:¬
set showbreak=…

if has('mouse_sgr')
  set mouse=a
  set ttymouse=sgr
elseif has('mouse')
  set mouse=a
  set ttymouse=xterm2
endif

set completeopt=longest,menu
runtime macros/matchit.vim

Allow shared clipboard on mac

set number         " Show line number
set showcmd        " Show the command you are typing in the bottom right corner
set hidden         " Allow buffers to exist without a window
syntax on          " Turn on syntax highlighting

" ================ Indentation ===============

set tabstop=2
set shiftwidth=2
set softtabstop=2
set expandtab
set autoindent

" Set tab completion propery
set wildmode=longest,list,full
set wildmenu

" Set backup directory
set dir=/private/tmp,/tmp
set backupcopy=yes

" I mistype these all the time
command! W w
command! Q q
command! Qa qa
command! QA qa

colorscheme solarized

" Remove the scrollbar
set guioptions-=r
set guioptions-=L

" Set font
set guifont=Monaco\ for\ Powerline:h13

" Search options
set incsearch
set hlsearch

" Always show the status line
set laststatus=2

" Whitespace highlighting
silent! nnoremap <silent> <Leader>$ :set list!<CR>
silent! nnoremap <silent> <Leader>h :noh<return>

" Pretty UTF8 characters
set listchars=tab:▸\ ,eol:¬
set showbreak=…

if has('mouse_sgr')
  set mouse=a
  set ttymouse=sgr
elseif has('mouse')
  set mouse=a
  set ttymouse=xterm2
endif

set completeopt=longest,menu
runtime macros/matchit.vim

set clipboard=unnamed


" Does not work on pending 'blocks', only single lines
"
" Given:
" it "foo bar" do
"   pending("bla bla"
"
" Produce:
" xit "foo bar" do
"
function! ChangePendingRspecToXit()
  " Find the next occurrence of pending
  while(search("pending(") > 0)
    " Delete it
    normal dd
    " Search backwards to the it block
    ?it\s
    " add an 'x' to the 'it' to make it 'xit'
    normal ix
  endwhile
endfunction

nnoremap <silent> ,rxit :call ChangePendingRspecToXit()<cr>

" insert a before { } block around a line
nnoremap <silent> ,bf ^ibefore { <esc>$a }

Change ,bf mapping conflicting with buffer list ,b

" Does not work on pending 'blocks', only single lines
"
" Given:
" it "foo bar" do
"   pending("bla bla"
"
" Produce:
" xit "foo bar" do
"
function! ChangePendingRspecToXit()
  " Find the next occurrence of pending
  while(search("pending(") > 0)
    " Delete it
    normal dd
    " Search backwards to the it block
    ?it\s
    " add an 'x' to the 'it' to make it 'xit'
    normal ix
  endwhile
endfunction

nnoremap <silent> ,rxit :call ChangePendingRspecToXit()<cr>

" insert a before { } block around a line
nnoremap <silent> \bf ^ibefore { <esc>$a }


let g:vimwiki_list = [{'path': '~/vimwiki/',
                      \ 'syntax': 'markdown', 'ext': '.md'}]
let g:vimwiki_global_ext = 0

nnoremap <Leader>we :e ~/vimwiki/<CR>

Save and Load vimwiki files when focus is lost / gained

let g:vimwiki_list = [{'path': '~/vimwiki/',
                      \ 'syntax': 'markdown', 'ext': '.md'}]
let g:vimwiki_global_ext = 0

nnoremap <Leader>we :e ~/vimwiki/<CR>

au FocusGained,BufEnter */vimwiki/* :silent! !
au FocusLost,WinLeave */vimwiki/* :w


" Vim filetype plugin
" Language              Markdown
" Maintainer            Ben Knoble <ben.knoble@gmail.com>

" Wrap at 80 characters
setlocal textwidth=80
" Spell check on
setlocal spell spelllang=en_us

Add heading level commands for Markdown

" Vim filetype plugin
" Language              Markdown
" Maintainer            Ben Knoble <ben.knoble@gmail.com>

" Wrap at 80 characters
setlocal textwidth=80
" Spell check on
setlocal spell spelllang=en_us

function! UnderlineHeading(level)
  if a:level == 1
    normal! yypVr=
  elseif a:level == 2
    normal! yypVr-
  else
    execute "normal! I### "
  endif
endfunction

nnoremap <LocalLeader>u1 :call UnderlineHeading(1)<CR>
nnoremap <LocalLeader>u2 :call UnderlineHeading(2)<CR>
nnoremap <LocalLeader>u3 :call UnderlineHeading(3)<CR>


" ftplugin/javascript.vim

" intelligent autocompleter
set omnifunc=javascriptcomplete#CompleteJS

" F1 comment line
map <F1> 0i//<esc>j
imap <F1> <esc>0i//<esc>j

" F2 uncomment line
map <F2> :s/^\/\///e<return>:noh<return>j

" F3 structured comment
map <F3> o<esc>i/<esc>79.yyp0O//<space>
imap <F3> <esc>o<esc>i/<esc>79.yyp0O//<space>

" F4 file header
map <F4> <esc>1GO// Creation Date: <esc>:r! date "+\%Y.\%m.\%d"<return><esc><esc>kJo// Author: Fernando L. Canizo - http://flc.muriandre.com/<esc>o<esc>0xxo<return><esc>kO"use strict";<enter><enter>

" use TAB character when TAB is pressed
set noexpandtab

" number of spaces to show for a TAB
set tabstop=4

" number of spaces for indent (>>, endfunction
set shiftwidth=4

" number of spaces for a tab in editing operations
set softtabstop=4

set textwidth=0

set smartindent

" TODO it would be nice to have this when on a comment, but it's not cool for code
set nowrap
set smartcase

colorscheme conanperlgray

" highlight unwanted spaces
call SpaceHighlightor()

Remove author from Javascript headers

" ftplugin/javascript.vim

" intelligent autocompleter
set omnifunc=javascriptcomplete#CompleteJS

" F1 comment line
map <F1> 0i//<esc>j
imap <F1> <esc>0i//<esc>j

" F2 uncomment line
map <F2> :s/^\/\///e<return>:noh<return>j

" F3 structured comment
map <F3> o<esc>i/<esc>79.yyp0O//<space>
imap <F3> <esc>o<esc>i/<esc>79.yyp0O//<space>

" F4 file header
map <F4> <esc>1GO// Creation Date: <esc>:r! date "+\%Y.\%m.\%d"<return><esc>kJo<esc>0xxo<return><esc>kO"use strict";<esc>G

" use TAB character when TAB is pressed
set noexpandtab

" number of spaces to show for a TAB
set tabstop=4

" number of spaces for indent (>>, endfunction
set shiftwidth=4

" number of spaces for a tab in editing operations
set softtabstop=4

set textwidth=0

set smartindent

" TODO it would be nice to have this when on a comment, but it's not cool for code
set nowrap
set smartcase

colorscheme conanperlgray

" highlight unwanted spaces
call SpaceHighlightor()


syntax enable
set background=dark
set t_Co=256
colorscheme gruvbox
"let g:hybrid_custom_term_colors = 1
"colorscheme hybrid

" Disable background highlight and instead underline it
hi clear SpellBad
hi SpellBad cterm=underline

if g:colors_name == 'monokai'
  hi clear Error
  hi clear SpellLocal
  hi clear SpellCap
  hi clear SpellRare
  hi clear DiffText
  hi Error ctermfg=196
  hi SpellLocal cterm=underline
  hi DiffText ctermfg=189 ctermbg=67
endif

Fix greyed-out background in VSCode while using vim in its terminal emulator

syntax enable
set background=dark
set t_Co=256

" This gets rid of the grey background
let g:solarized_termtrans = 1

colorscheme solarized

"let g:hybrid_custom_term_colors = 1
"colorscheme hybrid

" Disable background highlight and instead underline it
hi clear SpellBad
hi SpellBad cterm=underline

if g:colors_name == 'monokai'
  hi clear Error
  hi clear SpellLocal
  hi clear SpellCap
  hi clear SpellRare
  hi clear DiffText
  hi Error ctermfg=196
  hi SpellLocal cterm=underline
  hi DiffText ctermfg=189 ctermbg=67
endif


set number
set expandtab
set shiftwidth=2
set softtabstop=-1
set cursorline
set textwidth=80
set showcmd
set list
set undofile

let mapleader=' '
let maplocalleader=' '

syntax enable
set background=dark
silent! colorscheme gruvbox

filetype plugin indent on

" :h ft-syntax-omni
if has("autocmd") && exists("+omnifunc")
  autocmd Filetype *
        \ if &omnifunc == "" |
        \  setlocal omnifunc=syntaxcomplete#Complete |
        \ endif
endif

if has('termguicolors')
  set termguicolors
endif

lua << EOF
-- source remaining config
require('lsp')
require('plugins')
EOF

Use only one status line

set number
set expandtab
set shiftwidth=2
set softtabstop=-1
set cursorline
set textwidth=80
set showcmd
set list
set undofile
set laststatus=3

let mapleader=' '
let maplocalleader=' '

syntax enable
set background=dark
silent! colorscheme gruvbox

filetype plugin indent on

" :h ft-syntax-omni
if has("autocmd") && exists("+omnifunc")
  autocmd Filetype *
        \ if &omnifunc == "" |
        \  setlocal omnifunc=syntaxcomplete#Complete |
        \ endif
endif

if has('termguicolors')
  set termguicolors
endif

lua << EOF
-- source remaining config
require('lsp')
require('plugins')
EOF


"============================================================================
"File:        mri.vim
"Description: Syntax checking plugin for syntastic.vim
"Maintainer:  Martin Grenfell <martin.grenfell at gmail dot com>
"License:     This program is free software. It comes without any warranty,
"             to the extent permitted by applicable law. You can redistribute
"             it and/or modify it under the terms of the Do What The Fuck You
"             Want To Public License, Version 2, as published by Sam Hocevar.
"             See http://sam.zoy.org/wtfpl/COPYING for more details.
"
"============================================================================
function! SyntaxCheckers_ruby_GetLocList()

    let makeprg = 'ruby -w -T1 -c '.shellescape(expand('%'))
    if !has('win32')
        let makeprg = 'RUBYOPT= ' . makeprg
    endif

    "this is a hack to filter out a repeated useless warning in rspec files
    "containing lines like
    "
    "  foo.should == 'bar'
    "
    "which always generate the warning below
    let errorformat = '%-G%.%#warning: useless use of == in void context'

    let errorformat .=  ',%-GSyntax OK,%E%f:%l: syntax error\, %m,%Z%p^,%W%f:%l: warning: %m,%Z%p^,%W%f:%l: %m,%-C%.%#'
    return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
endfunction

Fix warning suppression in MRI 1.9.3

"============================================================================
"File:        mri.vim
"Description: Syntax checking plugin for syntastic.vim
"Maintainer:  Martin Grenfell <martin.grenfell at gmail dot com>
"License:     This program is free software. It comes without any warranty,
"             to the extent permitted by applicable law. You can redistribute
"             it and/or modify it under the terms of the Do What The Fuck You
"             Want To Public License, Version 2, as published by Sam Hocevar.
"             See http://sam.zoy.org/wtfpl/COPYING for more details.
"
"============================================================================
function! SyntaxCheckers_ruby_GetLocList()

    let makeprg = 'ruby -w -T1 -c '.shellescape(expand('%'))
    if !has('win32')
        let makeprg = 'RUBYOPT= ' . makeprg
    endif

    "this is a hack to filter out a repeated useless warning in rspec files
    "containing lines like
    "
    "  foo.should == 'bar'
    "
    "which always generate the warning below
    let errorformat = '%-G%.%#warning: possibly useless use of == in void context'

    let errorformat .=  ',%-GSyntax OK,%E%f:%l: syntax error\, %m,%Z%p^,%W%f:%l: warning: %m,%Z%p^,%W%f:%l: %m,%-C%.%#'
    return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
endfunction


" Default to filename searches
let g:ctrlp_by_filename=1
" Force Ctrl P plugin to not clear the cache
let g:ctrlp_clear_cache_on_exit=0
" Buffer tag searching for functions only
nnoremap <c-b> :CtrlPBufTag<CR>
let g:ctrlp_buftag_types={
    \ 'php': '--PHP-kinds=+f-vc'
\}
" On git projects, use it to list the files tracked and to be tracked
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files . -co --exclude-standard', 'find %s -type f']
let g:ctrlp_prompt_mappings = {
  \ 'AcceptSelection("e")': [],
  \ 'AcceptSelection("t")': ['<cr>', '<c-m>'],
\}

Revert "Vim: Ctrl-p opens the file in new tab after <ctr>"


" Start manual completion with Ctrl-Space.
inoremap <expr> <C-Space> neocomplete#start_manual_complete()

" Tab completion.
imap <expr> <Tab> pumvisible() ? "\<C-N>" : "<Tab>"

" Snippet completion with Ctrl-Tab.
imap <expr> <C-Tab> neosnippet#expandable_or_jumpable() ?
  \ "\<Plug>(neosnippet_expand_or_jump)"
  \: pumvisible() ? "\<C-N>" : "<C-Tab>"

" Snippet tab navigation.
smap <expr> <C-Tab> neosnippet#expandable_or_jumpable() ?
  \ "\<Plug>(neosnippet_expand_or_jump)" : "\<C-Tab>"

" Close popup on enter.
inoremap <expr> <CR> neocomplete#close_popup() . "\<CR>"

" Smart close popup on Ctrl-W.
imap <expr> <C-W> pumvisible() ?
  \ neocomplete#smart_close_popup() . "\<C-H>" : "<C-W>"

" Complete common sting with Ctrl-Space.
inoremap <expr> <C-L> neocomplete#complete_common_string()

" Popup navigation with Ctrl-J and Ctrl-K.
inoremap <expr> <C-J> pumvisible() ? "\<C-N>" : "\<C-J>"
inoremap <expr> <C-K> pumvisible() ? "\<C-P>" : "\<C-K>"

Use Ctrl-H for snippet completion

" Start manual completion with Ctrl-Space.
inoremap <expr> <C-Space> neocomplete#start_manual_complete()

" Tab completion.
imap <expr> <Tab> pumvisible() ? "\<C-N>" : "<Tab>"

" Snippet completion with Ctrl-H.
imap <expr> <C-H> neosnippet#expandable_or_jumpable() ?
  \ "\<Plug>(neosnippet_expand_or_jump)" : "<C-H>"

" Snippet tab navigation.
smap <expr> <C-Tab> neosnippet#expandable_or_jumpable() ?
  \ "\<Plug>(neosnippet_expand_or_jump)" : "\<C-Tab>"

" Close popup on enter.
inoremap <expr> <CR> neocomplete#close_popup() . "\<CR>"

" Smart close popup on Ctrl-W.
imap <expr> <C-W> pumvisible() ?
  \ neocomplete#smart_close_popup() . "\<C-H>" : "<C-W>"

" Complete common sting with Ctrl-Space.
inoremap <expr> <C-L> neocomplete#complete_common_string()

" Popup navigation with Ctrl-J and Ctrl-K.
inoremap <expr> <C-J> pumvisible() ? "\<C-N>" : "\<C-J>"
inoremap <expr> <C-K> pumvisible() ? "\<C-P>" : "\<C-K>"


"-------------------------------------------------------------------------------------------------"
" AUTHOR:  Andrew Michaud - https://andrewmichaud.com                                             "
" FILE:    init.vim                                                                               "
" PURPOSE: vim configuration file.                                                                "
" UPDATED: 2016-08-24                                                                             "
" LICENSE: ISC                                                                                "
"-------------------------------------------------------------------------------------------------"
""" Be vim, load reloaded file, make mouse work, make backspace nice, utf-8 is great.
set nocompatible autoread mouse=a backspace=indent,eol,start encoding=utf-8
syntax enable

""" Format text automatically in a nice way, use largest history, use smarttab.
set formatoptions+=tcqj history=10000 smarttab

""" Make opening files not suck, make search better, be faster, indent.
set wildmenu wildmode=list:longest,full incsearch ttyfast autoindent

""" Use XDG dirs. Neovim does this by default. dir==swap dir.
set viminfo+=n$XDG_DATA_HOME/vim/viminfo dir=$XDG_DATA_HOME/vim/swap//
set runtimepath+=$XDG_CONFIG_HOME/vim,$XDG_DATA_HOME/vim/site
set undodir=$XDG_DATA_HOME/vim/undo

""" I don't know if neovim sets this by default, assuming.
let g:netrw_home=$XDG_DATA_HOME."/vim"

""" Syntax, and 256 colors!
filetype plugin indent on
set t_Co=256

""" Share config with neovim. Will eventually make it easy to get rid of plain vim forever.
source $XDG_CONFIG_HOME/nvim/init.vim

Use vim 8.0+'s nice defaults.

"-------------------------------------------------------------------------------------------------"
" AUTHOR:  Andrew Michaud - https://andrewmichaud.com                                             "
" FILE:    init.vim                                                                               "
" PURPOSE: vim configuration file.                                                                "
" UPDATED: 2016-10-10                                                                             "
" LICENSE: ISC                                                                                "
"-------------------------------------------------------------------------------------------------"
""" Force 256 colors.
set t_Co=256

source $VIMRUNTIME/defaults.vim

""" Reload file if changed under us. Use UTF-8.
set autoread encoding=utf-8

""" Format text automatically in a nice way, use largest history, use smarttab.
set formatoptions+=tcqj history=10000 smarttab

""" Make search better, be faster, indent.
set wildmode=list:longest,full ttyfast autoindent

""" Use XDG dirs. Neovim does this by default. dir==swap dir.
set viminfo+=n$XDG_DATA_HOME/vim/viminfo dir=$XDG_DATA_HOME/vim/swap//
set runtimepath+=$XDG_CONFIG_HOME/vim,$XDG_DATA_HOME/vim/site
set undodir=$XDG_DATA_HOME/vim/undo

""" I don't know if neovim sets this by default, assuming.
let g:netrw_home=$XDG_DATA_HOME."/vim"

""" Share config with neovim. Will eventually make it easy to get rid of plain vim forever.
source $XDG_CONFIG_HOME/nvim/init.vim


set number
set expandtab
set shiftwidth=2
set softtabstop=-1
set cursorline
set textwidth=80
set showcmd
set list
set undofile
set breakindent
set linebreak
if has('termguicolors')
  set termguicolors
endif
set laststatus=3

Revert "nvim: Use only one status line"


function! GSO(question)

let firstarg=a:question

python << EOF

import vim

import os
import pickle as pkl
from io import BytesIO
from lxml import etree
from gso import load_up_answers, load_up_questions

question = vim.eval("firstarg")
vim.current.buffer.append(question)

results = []
i = 0
for result in load_up_questions(str(question)):
    results.append(result)
    i += 1
    if i > 1:
        break

question_url = results[0][0]
answers = load_up_answers(question_url)

def wrap_with_root_tag(xml_string):
    xml_string = u"<root>"+xml_string+u"</root>"
    return xml_string

root = etree.iterparse(BytesIO(wrap_with_root_tag(answers[0][1]).encode('utf-8')))
for action, elem in root:
    if elem.tag == u'p' or elem.tag == u'code':
        for line in str(elem.text).split('\n'):
            vim.current.buffer.append(line)

EOF

endfunction

" command! -nargs=1 GSO call GSO(question)

Fix appending of SO answer

function! GSO(question)

let firstarg=a:question

python << EOF

import vim

import os
import pickle as pkl
from io import BytesIO
from lxml import etree
from gso import load_up_answers, load_up_questions

question = vim.eval("firstarg")
vim.current.buffer.append(question)

results = []
i = 0
for result in load_up_questions(str(question)):
    results.append(result)
    i += 1
    if i > 1:
        break

question_url = results[0][0]
answers = load_up_answers(question_url)

def wrap_with_root_tag(xml_string):
    xml_string = u"<root>"+xml_string+u"</root>"
    return xml_string

parser = etree.XMLParser(recover=True)
root = etree.parse(
    BytesIO(wrap_with_root_tag(answers[0][1]).encode('utf-8')),
    parser=parser)

vim.current.buffer.append('')
for elem in root.iter():
    #if elem.tag == u'p' or elem.tag == u'code':
    for line in str(elem.text).split('\n'):
        if line != "None":
            vim.current.buffer[-1] += line
    for line in str(elem.tail).split('\n'):
        if line != "None":
            vim.current.buffer[-1] += (line)

EOF

endfunction

command! -nargs=1 GSO call GSO(question)


" BEGIN
if exists("g:loaded_pivo") || &cp
  finish
endif
let g:loaded_pivo = 1
let s:keepcpo     = &cpo
set cpo&vim

let PivoBufferName = "__Pivotal__"
let PivoProjectId  = 0
let PivoApiToken   = 0

function! s:PivoBufferOpen()
    " Check whether the buffer is already created
    let pivo_bufnum = bufnr(g:PivoBufferName)
    if pivo_bufnum == -1
        " open a new buffer
        exe "new " . g:PivoBufferName
    else
        " Pivo buffer is already created,
        " check whether it is open in one of the windows.
        let pivo_winnum = bufwinnr(pivo_bufnum)
        if pivo_winnum != -1
            " Jump to the window which has the buffer if we are not
            " already in that window
            if winnr() != pivo_winnum
                exe pivo_winnum . "wincmd w"
            endif
        else
            " Create a new Pivo buffer
            exe "split +buffer" . pivo_bufnum
        endif
    endif
endfunction

function! s:SetPivoBuffer()
    nnoremap <buffer> q :quit<CR>
endfunction
autocmd BufNewFile __Pivotal__ call s:SetPivoBuffer()

command! -nargs=0 Pivo call s:PivoBufferOpen()

" END
let &cpo= s:keepcpo
unlet s:keepcpo

Add PUBLIC and PRIVATE comment labels

" BEGIN
if exists("g:loaded_pivo") || &cp
  finish
endif
let g:loaded_pivo = 1
let s:keepcpo     = &cpo
set cpo&vim

let PivoBufferName = "__Pivotal__"
let PivoProjectId  = 0
let PivoApiToken   = 0

" PUBLIC

function! s:PivoBufferOpen()
    " Check whether the buffer is already created
    let pivo_bufnum = bufnr(g:PivoBufferName)
    if pivo_bufnum == -1
        " open a new buffer
        exe "new " . g:PivoBufferName
    else
        " Pivo buffer is already created,
        " check whether it is open in one of the windows.
        let pivo_winnum = bufwinnr(pivo_bufnum)
        if pivo_winnum != -1
            " Jump to the window which has the buffer if we are not
            " already in that window
            if winnr() != pivo_winnum
                exe pivo_winnum . "wincmd w"
            endif
        else
            " Create a new Pivo buffer
            exe "split +buffer" . pivo_bufnum
        endif
    endif
endfunction

function! s:SetPivoBuffer()
    nnoremap <buffer> q :quit<CR>
endfunction
autocmd BufNewFile __Pivotal__ call s:SetPivoBuffer()

command! -nargs=0 Pivo call s:PivoBufferOpen()

" PRIVATE

" END
let &cpo= s:keepcpo
unlet s:keepcpo


set background=dark

try
    set t_Co=256                      " Make vim aware of 256 colorspace
    let base16colorspace=256          " Enable base16 256 colorspace
    colorscheme base16-default-dark
    highlight SpellBad ctermbg=0
catch /^Vim\%((\a\+)\)\=:E185/
    " Well, not much I can do at the moment
endtry

set autoindent

set showmatch
set matchpairs=(:),{:},[:],<:>

"Show line numbers
set number
set relativenumber

"Extra highlighting settings
au InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
au InsertLeave * match ExtraWhitespace /\s\+$/
highlight ExtraWhiteSpace ctermbg=52
set spell spelllang=en_gb
set hlsearch

" Always show the status bar at the bottom of the window
set laststatus=2
set incsearch

" Don't show the mode if we are using lightline.
if exists('g:solarnz_will_load_lightline')
    set noshowmode
endif

set list lcs=trail:·,tab:»·

let &t_SI = "\e]50;CursorShape=1\x7"
let &t_EI = "\e]50;CursorShape=0\x7"

if has('nvim')
    set inccommand=split
endif

Fix some issues with spelling mistake highlight colours

set background=dark

try
    set t_Co=256                      " Make vim aware of 256 colorspace
    let base16colorspace=256          " Enable base16 256 colorspace
    colorscheme base16-default-dark
    highlight SpellBad ctermbg=0
    highlight SpellCap ctermbg=0
    highlight SpellRare ctermbg=0
    highlight SpellLocal ctermbg=0
catch /^Vim\%((\a\+)\)\=:E185/
    " Well, not much I can do at the moment
endtry

set autoindent

set showmatch
set matchpairs=(:),{:},[:],<:>

"Show line numbers
set number
set relativenumber

"Extra highlighting settings
au InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
au InsertLeave * match ExtraWhitespace /\s\+$/
highlight ExtraWhiteSpace ctermbg=52
set spell spelllang=en_gb
set hlsearch

" Always show the status bar at the bottom of the window
set laststatus=2
set incsearch

" Don't show the mode if we are using lightline.
if exists('g:solarnz_will_load_lightline')
    set noshowmode
endif

set list lcs=trail:·,tab:»·

let &t_SI = "\e]50;CursorShape=1\x7"
let &t_EI = "\e]50;CursorShape=0\x7"

if has('nvim')
    set inccommand=split
endif


" Vim filetype plugin
" Language:              Python
" Maintainer:            Ben Knoble <ben.knoble@gmail.com>

if exists('b:undo_ftplugin')
  let b:undo_ftplugin .= ' | '
else
  let b:undo_ftplugin = ''
endif

let python_highlight_all = 1

setlocal textwidth=79

nnoremap <buffer> <LocalLeader>P :term python<CR>
nnoremap <buffer> <LocalLeader>p :term ++close python<CR>

let b:undo_ftplugin .= "setlocal textwidth<"
let b:undo_ftplugin .= " | unlet python_highlight_all"
let b:undo_ftplugin .= " | exe 'nunmap <buffer> <LocalLeader>P'"
let b:undo_ftplugin .= " | exe 'nunmap <buffer> <LocalLeader>p'"

Use unlet! to avoid errors

" Vim filetype plugin
" Language:              Python
" Maintainer:            Ben Knoble <ben.knoble@gmail.com>

if exists('b:undo_ftplugin')
  let b:undo_ftplugin .= ' | '
else
  let b:undo_ftplugin = ''
endif

let python_highlight_all = 1

setlocal textwidth=79

nnoremap <buffer> <LocalLeader>P :term python<CR>
nnoremap <buffer> <LocalLeader>p :term ++close python<CR>

let b:undo_ftplugin .= "setlocal textwidth<"
let b:undo_ftplugin .= " | unlet! python_highlight_all"
let b:undo_ftplugin .= " | exe 'nunmap <buffer> <LocalLeader>P'"
let b:undo_ftplugin .= " | exe 'nunmap <buffer> <LocalLeader>p'"


scriptencoding utf-8

colorscheme solarized

set background=dark             " Define background style
set number                      " Line numbers are good
set backspace=indent,eol,start  " Allow backspace in insert mode
set history=1000                " Store lots of :cmdline history
set showcmd                     " Show incomplete cmds down the bottom
set showmode                    " Show current mode down the bottom
set gcr=a:blinkon0              " Disable cursor blink
set visualbell                  " No sounds
set autoread                    " Reload files changed outside vim
set hidden                      " See http://items.sjbach.com/319/configuring-vim-right
set wmh=0                       " Windows need not have height
set mouse=a                     " Enable mouse
set encoding=utf-8              " UTF-8 makes the world a better place
set clipboard=unnamed           " Share * register w/ unnamed (system copy/paste support)
syntax on                       " Turn on syntax highlighting

" Display tabs and trailing spaces visually
set list listchars=tab:\ \ ,trail:·

set nowrap       " Don't wrap lines
set linebreak    " Wrap lines at convenient points

" Disable the scrollbars (NERDTree)
set guioptions-=r
set guioptions-=L

Disable resize when closing splits

scriptencoding utf-8

colorscheme solarized

set background=dark             " Define background style
set number                      " Line numbers are good
set backspace=indent,eol,start  " Allow backspace in insert mode
set history=1000                " Store lots of :cmdline history
set showcmd                     " Show incomplete cmds down the bottom
set showmode                    " Show current mode down the bottom
set gcr=a:blinkon0              " Disable cursor blink
set visualbell                  " No sounds
set autoread                    " Reload files changed outside vim
set hidden                      " See http://items.sjbach.com/319/configuring-vim-right
set wmh=0                       " Windows need not have height
set mouse=a                     " Enable mouse
set encoding=utf-8              " UTF-8 makes the world a better place
set clipboard=unnamed           " Share * register w/ unnamed (system copy/paste support)
set noequalalways               " Don't resize when closing splits
syntax on                       " Turn on syntax highlighting

" Display tabs and trailing spaces visually
set list listchars=tab:\ \ ,trail:·

set nowrap       " Don't wrap lines
set linebreak    " Wrap lines at convenient points

" Disable the scrollbars (NERDTree)
set guioptions-=r
set guioptions-=L


" Copyright 2010-present Greg Hurrell. All rights reserved.
" Licensed under the terms of the BSD 2-clause license.

if exists('g:command_t_loaded') || &compatible
  finish
endif
let g:command_t_loaded = 1

" HACK: use both old and new during early development
call commandt#isengard#init()
call commandt#mirkwood#init()
finish

" if has('patch-7-4-1829') && get(g:, 'CommandTEngine', 'isengard') ==? 'isengard'
"   call commandt#isengard#init()
" else
"   call commandt#mirkwood#init()
" endif

Make "next" branch slightly less aggressive

" Copyright 2010-present Greg Hurrell. All rights reserved.
" Licensed under the terms of the BSD 2-clause license.

if exists('g:command_t_loaded') || &compatible
  finish
endif
let g:command_t_loaded = 1

" HACK: use both old and new during early development
if has('patch-7-4-1829') && get(g:, 'CommandTEngine', 'mirkwood') ==? 'isengard'
  call commandt#isengard#init()
endif
call commandt#mirkwood#init()
finish

" if has('patch-7-4-1829') && get(g:, 'CommandTEngine', 'isengard') ==? 'isengard'
"   call commandt#isengard#init()
" else
"   call commandt#mirkwood#init()
" endif


" Required for operations modifying multiple buffers like rename.
set hidden

let g:LanguageClient_serverCommands = {
    \ 'python': ['pyls'],
    \ 'javascript': ['javascript-typescript-stdio'],
    \ 'javascript.jsx': ['javascript-typescript-stdio'],
    \ 'go': ['/home/chris/go/bin/gopls'],
    \ 'rust': ['rls'],
    \ 'c': ['cquery'],
    \ }

"let g:LanguageClient_useVirtualText = 0
let g:LanguageClient_hoverPreview = "Never"

nnoremap <silent> gd :call LanguageClient_textDocument_definition()<CR>

nnoremap <F5> :call LanguageClient_contextMenu()<CR>
vnoremap <F5> :call LanguageClient_contextMenu()<CR>

nnoremap tg :call LanguageClient_contextMenu()<CR>
vnoremap tg :call LanguageClient_contextMenu()<CR>

let g:deoplete#enable_at_startup = 1

Add intelephense as the php language server

" Required for operations modifying multiple buffers like rename.
set hidden

let g:LanguageClient_serverCommands = {
    \ 'python': ['pyls'],
    \ 'javascript': ['javascript-typescript-stdio'],
    \ 'javascript.jsx': ['javascript-typescript-stdio'],
    \ 'go': ['/home/chris/go/bin/gopls'],
    \ 'rust': ['rls'],
    \ 'c': ['cquery'],
    \ 'php': ['/usr/bin/intelephense', '--stdio'],
    \ }

"let g:LanguageClient_useVirtualText = 0
let g:LanguageClient_hoverPreview = "Never"

nnoremap <silent> gd :call LanguageClient_textDocument_definition()<CR>

nnoremap <F5> :call LanguageClient_contextMenu()<CR>
vnoremap <F5> :call LanguageClient_contextMenu()<CR>

nnoremap tg :call LanguageClient_contextMenu()<CR>
vnoremap tg :call LanguageClient_contextMenu()<CR>

let g:deoplete#enable_at_startup = 1


function! ChompedSystem( ... )
	return substitute(call('system', a:000), '\n\+$', '', '')
endfunction

" Redirect the output of a Vim or external command into a scratch buffer
function! Redir(cmd) abort
    let output = execute(a:cmd)
    vnew
	let w:scratch = 1
    setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile
    call setline(1, split(output, "\n"))
endfunction
command! -nargs=1 Redir silent call Redir(<q-args>)

Remove Redir since it's possible with vim commands


" Make it beautiful - colors and fonts

if has("gui_running")
  colors desert
  au GUIEnter * winpos 0 0
  set lines=999 columns=999 " fullscreen mode - Linux
  set guioptions-=T  "remove toolbar
  set guioptions-=m  "remove menu bar
endif

" =============== THEME =================
syntax enable
colorscheme solarized
set background=dark

" =============== NO ERROR BELLS ============
set noerrorbells visualbell t_vb=
if has('autocmd')
  autocmd GUIEnter * set visualbell t_vb=
endif

Fix solarized vim on terminal

" ============= Make it beautiful - colors and fonts
if has("gui_running")
  colors desert
  au GUIEnter * winpos 0 0
  set lines=999 columns=999 " fullscreen mode - Linux
  set guioptions-=T  "remove toolbar
  set guioptions-=m  "remove menu bar
endif

" =============== THEME =================
syntax enable
let g:solarized_termtrans=1
"let g:solarized_termcolors=256
colorscheme solarized
set background=dark

" =============== NO ERROR BELLS ============
set noerrorbells visualbell t_vb=
if has('autocmd')
  autocmd GUIEnter * set visualbell t_vb=
endif


" via: http://rails-bestpractices.com/posts/60-remove-trailing-whitespace
" Strip trailing whitespace
function! <SID>StripTrailingWhitespaces()
    " Preparation: save last search, and cursor position.
    let _s=@/
    let l = line(".")
    let c = col(".")
    " Do the business:
    %s/\s\+$//e
    " Clean up: restore previous search history, and cursor position
    let @/=_s
    call cursor(l, c)
endfunction
command! StripTrailingWhitespaces call <SID>StripTrailingWhitespaces()
nmap ,w :StripTrailingWhitespaces<CR>
autocmd FileType c,cpp,java,php,ruby,python,elixir autocmd BufWritePre <buffer> :call <SID>StripTrailingWhitespaces()

Change strip trailing whitespace shortcut

" via: http://rails-bestpractices.com/posts/60-remove-trailing-whitespace
" Strip trailing whitespace
function! <SID>StripTrailingWhitespaces()
    " Preparation: save last search, and cursor position.
    let _s=@/
    let l = line(".")
    let c = col(".")
    " Do the business:
    %s/\s\+$//e
    " Clean up: restore previous search history, and cursor position
    let @/=_s
    call cursor(l, c)
endfunction
command! StripTrailingWhitespaces call <SID>StripTrailingWhitespaces()
nmap <leader>kw :StripTrailingWhitespaces<CR>
autocmd FileType c,cpp,java,php,ruby,python,elixir autocmd BufWritePre <buffer> :call <SID>StripTrailingWhitespaces()


setlocal tabstop=4
setlocal softtabstop=4
setlocal shiftwidth=4
setlocal textwidth=88
setlocal expandtab
setlocal autoindent

nnoremap <buffer> <Leader>tt :compiler pytest<cr>:make %<cr>
nnoremap <buffer> <Leader>ta :compiler pytest<cr>:make<cr>

" Neoformat configuration.
let g:neoformat_run_all_formatters = 1
let g:neoformat_enabled_python = ['black', 'isort', 'docformatter']

" Neomake configuration.
let g:neomake_python_enabled_makers = ['flake8', 'pydocstyle']

Improve 'path' for Python files

setlocal tabstop=4
setlocal softtabstop=4
setlocal shiftwidth=4
setlocal textwidth=88
setlocal expandtab
setlocal autoindent

" Set the path to something more suitable for Python projects. This enables
" :find and related commands to do the right thing.
setlocal path=.,**

nnoremap <buffer> <Leader>tt :compiler pytest<cr>:make %<cr>
nnoremap <buffer> <Leader>ta :compiler pytest<cr>:make<cr>

" Neoformat configuration.
let g:neoformat_run_all_formatters = 1
let g:neoformat_enabled_python = ['black', 'isort', 'docformatter']

" Neomake configuration.
let g:neomake_python_enabled_makers = ['flake8', 'pydocstyle']


" Vim syntax file
" Language:     Cretonne
" Maintainer:   Jakob Stoklund Olesen <stoklund@2pi.dk
" Last Change:  Sep 22, 2016

if version < 600
  syntax clear
elseif exists("b:current_syntax")
  finish
endif

syn keyword ctonHeader test isa set
syn keyword ctonDecl function stack_slot jump_table
syn keyword ctonFilecheck check sameln nextln unordered not regex contained

syn match ctonType  /\<[bif]\d\+\(x\d\+\)\?\>/
syn match ctonEntity /\<\(v\|vx\|ss\|jt\|\)\d\+\>/
syn match ctonLabel /\<ebb\d+\>/

syn match ctonNumber /-\?\<\d\+\>/
syn match ctonNumber /-\?\<0x\x\+\(\.\x*\)\(p[+-]\?\d\+\)\?\>/

syn region ctonCommentLine start=";" end="$" contains=ctonFilecheck

hi def link ctonHeader        Keyword
hi def link ctonDecl          Keyword
hi def link ctonType          Type
hi def link ctonEntity        Identifier
hi def link ctonLabel         Label
hi def link ctonNumber        Number
hi def link ctonCommentLine   Comment
hi def link ctonFilecheck     SpecialComment

let b:current_syntax = "cton"

Add Vim syntax support for Name and HexSequence tokens.

" Vim syntax file
" Language:     Cretonne
" Maintainer:   Jakob Stoklund Olesen <stoklund@2pi.dk
" Last Change:  Sep 22, 2016

if version < 600
  syntax clear
elseif exists("b:current_syntax")
  finish
endif

" Disable spell checking even in comments.
" They tend to refer to weird stuff like assembler mnemonics anyway.
syn spell notoplevel

syn keyword ctonHeader test isa set
syn keyword ctonDecl function stack_slot jump_table
syn keyword ctonFilecheck check sameln nextln unordered not regex contained

syn match ctonType  /\<[bif]\d\+\(x\d\+\)\?\>/
syn match ctonEntity /\<\(v\|vx\|ss\|jt\|fn\|sig\)\d\+\>/
syn match ctonLabel /\<ebb\d+\>/
syn match ctonName /%\w\+\>/

syn match ctonNumber /-\?\<\d\+\>/
syn match ctonNumber /-\?\<0x\x\+\(\.\x*\)\(p[+-]\?\d\+\)\?\>/
syn match ctonHexSeq /#\x\+\>/

syn region ctonCommentLine start=";" end="$" contains=ctonFilecheck

hi def link ctonHeader        Keyword
hi def link ctonDecl          Keyword
hi def link ctonType          Type
hi def link ctonEntity        Identifier
hi def link ctonLabel         Label
hi def link ctonName          String
hi def link ctonNumber        Number
hi def link ctonHexSeq        Number
hi def link ctonCommentLine   Comment
hi def link ctonFilecheck     SpecialComment

let b:current_syntax = "cton"


" Use ; for cmdline. ; usually shows next results for f/F/t/T commands.
noremap ; :

" Use , to show next results for f/F/t/T commands. Usually shows previous
" results, which is now disabled.
noremap , ;

" Unbind C-z to stop accidentally stopping process.
" Might put this back in soon.
noremap <C-z> <Nop>

" Unbind arrow keys
noremap <Up> <Nop>
noremap <Down> <Nop>
noremap <Left> <Nop>
noremap <Right> <Nop>
inoremap <Up> <Nop>
inoremap <Down> <Nop>
inoremap <Left> <Nop>
inoremap <Right> <Nop>

" Easymotion
noremap <Space> <Nop>
let g:EasyMotion_leader_key = "<Space>"

" Use perl-style regular expressions
nnoremap / /\v
vnoremap / /\v

" Escape insert mode w/jj
inoremap jj <ESC>

" Behave properly on long lines
nnoremap j gj
nnoremap k gk

"""""""""" Leader commands

" :nohl
nnoremap <leader>n :nohl<CR>

" Don't care about most NERDcomment functionality, just want toggle
nnoremap <leader>c :call NERDComment(0,"toggle")<CR>
vnoremap <leader>c :call NERDComment(0,"toggle")<CR>

Change vim comment toggle to C-c

" Use ; for cmdline. ; usually shows next results for f/F/t/T commands.
noremap ; :

" Use , to show next results for f/F/t/T commands. Usually shows previous
" results, which is now disabled.
noremap , ;

" Unbind C-z to stop accidentally stopping process.
" Might put this back in soon.
noremap <C-z> <Nop>

" Unbind arrow keys
noremap <Up> <Nop>
noremap <Down> <Nop>
noremap <Left> <Nop>
noremap <Right> <Nop>
inoremap <Up> <Nop>
inoremap <Down> <Nop>
inoremap <Left> <Nop>
inoremap <Right> <Nop>

" Easymotion
noremap <Space> <Nop>
let g:EasyMotion_leader_key = "<Space>"

" Use perl-style regular expressions
nnoremap / /\v
vnoremap / /\v

" Escape insert mode w/jj
inoremap jj <ESC>

" Behave properly on long lines
nnoremap j gj
nnoremap k gk

" Don't care about most NERDcomment functionality, just want toggle
nnoremap <C-c> :call NERDComment(0,"toggle")<CR>
vnoremap <C-c> :call NERDComment(0,"toggle")<CR>

"""""""""" Leader commands

" :nohl
nnoremap <leader>n :nohl<CR>


" disable the bell
set vb t_vb=

" enable line numbering
set number

" disable startup message
set shortmess+=I

" statusline
set laststatus=2

" auto reload changed files
set autoread
set checktime

" mouse compatibility
set mouse=a

" x clipboard access
set clipboard+=unnamedplus

" case-insensitive searching - case-sensitive if uppercase letters are used
set ignorecase
set smartcase

" store all swap files centrally
set directory=$HOME/.config/nvim/tmp/swap/
if !isdirectory(expand(&directory))
  call mkdir(expand(&directory), 'p')
endif

" store all backup files centrally
set backupdir=$HOME/.config/nvim/tmp/backup/
if !isdirectory(expand(&backupdir))
  call mkdir(expand(&backupdir), 'p')
endif

" persistent undo
set undofile
set undodir=$HOME/.config/nvim/tmp/undo/
set undolevels=500
set undoreload=500
if !isdirectory(expand(&undodir))
  call mkdir(expand(&undodir), 'p')
endif

" don't keep commenting on enter or o/O
autocmd BufNewFile,BufRead * setlocal formatoptions-=ro

" always show tab line
set showtabline=2

" don't show mode in command line
set noshowmode

Revert "Add checktime option to (hopefully) auto reload"

" disable the bell
set vb t_vb=

" enable line numbering
set number

" disable startup message
set shortmess+=I

" statusline
set laststatus=2

" auto reload changed files
set autoread

" mouse compatibility
set mouse=a

" x clipboard access
set clipboard+=unnamedplus

" case-insensitive searching - case-sensitive if uppercase letters are used
set ignorecase
set smartcase

" store all swap files centrally
set directory=$HOME/.config/nvim/tmp/swap/
if !isdirectory(expand(&directory))
  call mkdir(expand(&directory), 'p')
endif

" store all backup files centrally
set backupdir=$HOME/.config/nvim/tmp/backup/
if !isdirectory(expand(&backupdir))
  call mkdir(expand(&backupdir), 'p')
endif

" persistent undo
set undofile
set undodir=$HOME/.config/nvim/tmp/undo/
set undolevels=500
set undoreload=500
if !isdirectory(expand(&undodir))
  call mkdir(expand(&undodir), 'p')
endif

" don't keep commenting on enter or o/O
autocmd BufNewFile,BufRead * setlocal formatoptions-=ro

" always show tab line
set showtabline=2

" don't show mode in command line
set noshowmode


echo "Starting the example Python Plugin"

function DoItVimL()
    echo "DoItVimL"
endfunction

Add comment to sample VimL

" The VimL/VimScript code is included in this sample plugin to demonstrate the
" two different approaches but it is not required you use VimL. Feel free to
" delete this code and proceed without it.

echo "Starting the example Python Plugin"

function DoItVimL()
    echo "DoItVimL"
endfunction


let g:ConqueTerm_InsertOnEnter = 1
let g:ConqueTerm_CWInsert = 1
let g:ConqueTerm_Color = 2
let g:ConqueTerm_ReadUnfocused = 1 " update conqueterm buffer while we're not looking (for running tests)

" Open up a variety of commands in the ConqueTerm
nmap <silent> <Leader>cc :execute 'ConqueTermSplit script/console --irb=pry'<CR>
nmap <silent> <Leader>pp :execute 'ConqueTermSplit pry'<CR>
nmap <silent> <Leader>zz :execute 'ConqueTermSplit zsh'<CR>

let g:ConqueTerm_SendVisKey = '<Leader>e'

Remove unused ,zz binding interfering with ,z previous buffer

let g:ConqueTerm_InsertOnEnter = 1
let g:ConqueTerm_CWInsert = 1
let g:ConqueTerm_Color = 2
let g:ConqueTerm_ReadUnfocused = 1 " update conqueterm buffer while we're not looking (for running tests)

" Open up a variety of commands in the ConqueTerm
nmap <silent> <Leader>cc :execute 'ConqueTermSplit script/console --irb=pry'<CR>
nmap <silent> <Leader>pp :execute 'ConqueTermSplit pry'<CR>

let g:ConqueTerm_SendVisKey = '<Leader>e'


" set background=light " light theme
set background=dark " dark theme
colorscheme solarized

let g:solarized_diffmode="high"

highlight clear IncSearch
highlight IncSearch term=reverse cterm=reverse ctermfg=7 ctermbg=0 guifg=Black guibg=Yellow
highlight VertSplit ctermbg=NONE guibg=NONE

function! GitBranch()
  return system("git rev-parse --abbrev-ref HEAD 2>/dev/null | tr -d '\n'")
endfunction

function! StatuslineGit()
  let l:branchname = GitBranch()
  return strlen(l:branchname) > 0?'  '.l:branchname.' ':''
endfunction

" Always show statusline
set laststatus=2

" Statusline appearance
set statusline=
set statusline+=%#PmenuSel#
set statusline+=%{StatuslineGit()}
set statusline+=%#LineNr#
set statusline+=%<
set statusline+=\ %f
set statusline+=%m
set statusline+=%=
set statusline+=%#CursorColumn#
set statusline+=\ %y
set statusline+=\ %{&fileencoding?&fileencoding:&encoding}
set statusline+=\[%{&fileformat}\]
set statusline+=\ %P
set statusline+=\ %l:%c
set statusline+=\
set statusline+=%m%h%r

Load solarized diff setting before colorscheme.

" set background=light " light theme
set background=dark " dark theme
let g:solarized_diffmode="high"
colorscheme solarized

highlight clear IncSearch
highlight IncSearch term=reverse cterm=reverse ctermfg=7 ctermbg=0 guifg=Black guibg=Yellow
highlight VertSplit ctermbg=NONE guibg=NONE

function! GitBranch()
  return system("git rev-parse --abbrev-ref HEAD 2>/dev/null | tr -d '\n'")
endfunction

function! StatuslineGit()
  let l:branchname = GitBranch()
  return strlen(l:branchname) > 0?'  '.l:branchname.' ':''
endfunction

" Always show statusline
set laststatus=2

" Statusline appearance
set statusline=
set statusline+=%#PmenuSel#
set statusline+=%{StatuslineGit()}
set statusline+=%#LineNr#
set statusline+=%<
set statusline+=\ %f
set statusline+=%m
set statusline+=%=
set statusline+=%#CursorColumn#
set statusline+=\ %y
set statusline+=\ %{&fileencoding?&fileencoding:&encoding}
set statusline+=\[%{&fileformat}\]
set statusline+=\ %P
set statusline+=\ %l:%c
set statusline+=\
set statusline+=%m%h%r


" Plugins will be downloaded in the specified directory.
call plug#begin('~/.vim/plugins')

    " Git Tools
    " > http://vimcasts.org/episodes/fugitive-vim---a-complement-to-command-line-git/
    Plug 'tpope/vim-fugitive'            " Various git commands
    Plug 'airblade/vim-gitgutter'        " Git diff indicators in the signcolumn

    " Fuzzy searching
    Plug 'junegunn/fzf'
    Plug 'junegunn/fzf.vim'

    " Language specific extensions
    Plug 'dag/vim-fish', { 'for': 'fish' }
    Plug 'fatih/vim-go', { 'for': 'go', 'do': 'GoUpdateBinaries' }

    " LSP client
    Plug 'neoclide/coc.nvim', { 'branch': 'release' }

    Plug 'tpope/vim-commentary'
    Plug 'tpope/vim-surround'

    " > http://vimcasts.org/episodes/aligning-text-with-tabular-vim/
    Plug 'godlygeek/tabular'

" Plugins become visible to Vim after this call.
call plug#end()

Add language extensions for toml

" Plugins will be downloaded in the specified directory.
call plug#begin('~/.vim/plugins')

    " Git Tools
    " > http://vimcasts.org/episodes/fugitive-vim---a-complement-to-command-line-git/
    Plug 'tpope/vim-fugitive'            " Various git commands
    Plug 'airblade/vim-gitgutter'        " Git diff indicators in the signcolumn

    " Fuzzy searching
    Plug 'junegunn/fzf'
    Plug 'junegunn/fzf.vim'

    " Language specific extensions
    Plug 'dag/vim-fish', { 'for': 'fish' }
    Plug 'fatih/vim-go', { 'for': 'go', 'do': 'GoUpdateBinaries' }
    Plug 'cespare/vim-toml', { 'for': 'toml' }

    " LSP client
    Plug 'neoclide/coc.nvim', { 'branch': 'release' }

    Plug 'tpope/vim-commentary'
    Plug 'tpope/vim-surround'

    " > http://vimcasts.org/episodes/aligning-text-with-tabular-vim/
    Plug 'godlygeek/tabular'

" Plugins become visible to Vim after this call.
call plug#end()


if has("gui_running")
  if has("gui_macvim")
    set fuoptions=maxvert,maxhorz
    set guifont=Monaco:h10
    set guioptions-=T " remove toolbar
    set guioptions-=r " remove scrollbars
    set guioptions-=L
    set stal=0 " turn on tabs off by default
  end

  set anti

  " Default size of window
  set columns=140
  set lines=50

  set transp=5

  " Love this for adjusting from laptop to desktop monitor
  function! Change_size()
   if !exists('w:wide')
     let w:wide = 0
   endif
   if w:wide == 1
     set columns=140
     let w:wide = 0
   else
     set columns=260
     let w:wide = 1
   endif
  endfunction

  map <leader>w :call Change_size()<CR>
endif

Add ,= to even out windows

if has("gui_running")
  if has("gui_macvim")
    set fuoptions=maxvert,maxhorz
    set guifont=Monaco:h10
    set guioptions-=T " remove toolbar
    set guioptions-=r " remove scrollbars
    set guioptions-=L
    set stal=0 " turn on tabs off by default
  end

  set anti

  " Default size of window
  set columns=140
  set lines=50

  set transp=5

  " Love this for adjusting from laptop to desktop monitor
  function! Change_size()
   if !exists('w:wide')
     let w:wide = 0
   endif
   if w:wide == 1
     set columns=140
     let w:wide = 0
   else
     set columns=260
     let w:wide = 1
   endif
  endfunction

  map <leader>w :call Change_size()<CR>

  " Adjust windows to be same size
  map <Leader>= <C-w>=
endif


if exists('g:sniphpets_unittest_autoload')
    finish
endif

let g:sniphpets_unittest_autoload = 1

fun! sniphpets#unittest#resolve_alternate(...)
    let fqn = a:0 > 0 ? a:1 : sniphpets#resolve_fqn()

    let unittest_namespace = sniphpets#settings('unittest_namespace', 'Tests?')
    let unittest_suffix = sniphpets#settings('unittest_suffix', 'Test')

    let alternate = substitute(substitute(fqn, printf('\v(^|\\)%s\\', unittest_namespace), '\1', ''), printf('\v%s$', unittest_suffix), '', '')

    if alternate == fqn
       return ''
    endif

    return substitute(alternate, '^\', '', '')
endf

Use fqn() instead of resolve_fqn()

if exists('g:sniphpets_unittest_autoload')
    finish
endif

let g:sniphpets_unittest_autoload = 1

fun! sniphpets#unittest#resolve_alternate(...)
    let fqn = a:0 > 0 ? a:1 : sniphpets#fqn()

    let unittest_namespace = sniphpets#settings('unittest_namespace', 'Tests?')
    let unittest_suffix = sniphpets#settings('unittest_suffix', 'Test')

    let alternate = substitute(substitute(fqn, printf('\v(^|\\)%s\\', unittest_namespace), '\1', ''), printf('\v%s$', unittest_suffix), '', '')

    if alternate == fqn
       return ''
    endif

    return substitute(alternate, '^\', '', '')
endf


set directory=~/.vim/backup
set backupdir=~/.vim/backup

set smartindent
set tabstop=2
set shiftwidth=2
set expandtab

set ai
set number
set hlsearch
set ignorecase
set smartcase

set spell spelllang=en_us
set mousemodel=popup_setpos

set laststatus=2

let g:powerline_loaded = 1

let g:airline_powerline_fonts = 1

let g:NERDTreeChDirMode = 2

let g:DeleteTrailingWhitespace = 1
let g:DeleteTrailingWhitespace_Action = 'delete'

if has('gui_running')
  colorscheme molokai
  set background=dark
else
  set background=dark
endif

if has('gui_running')
  set guifont=Inconsolata\ XL\ 10
endif

Set airline_theme when in tmux session.

set directory=~/.vim/backup
set backupdir=~/.vim/backup

set smartindent
set tabstop=2
set shiftwidth=2
set expandtab

set ai
set number
set hlsearch
set ignorecase
set smartcase

set spell spelllang=en_us
set mousemodel=popup_setpos

set laststatus=2

let g:powerline_loaded = 1

let g:airline_powerline_fonts = 1

let g:NERDTreeChDirMode = 2

let g:DeleteTrailingWhitespace = 1
let g:DeleteTrailingWhitespace_Action = 'delete'

if has('gui_running')
  colorscheme molokai
  set background=dark
else
  set background=dark

  if strlen($TMUX)
    let g:airline_theme = 'solarized'
  endif
endif

if has('gui_running')
  set guifont=Inconsolata\ XL\ 10
endif


" Main plugins
Plug 'w0rp/ale'
Plug 'jiangmiao/auto-pairs'
Plug 'jlanzarotta/bufexplorer'
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'junegunn/fzf', {'dir': '~/.fzf', 'do': './install --bin'}
Plug 'autozimu/LanguageClient-neovim', {'branch': 'next', 'do': 'bash install.sh'}
Plug 'preservim/nerdtree'
Plug 'altercation/vim-colors-solarized'
Plug 'lambdalisue/suda.vim'
Plug 'ervandew/supertab'
Plug 'SirVer/ultisnips'
Plug 'vim-airline/vim-airline'
Plug 'moll/vim-bbye'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-surround'
Plug 'cespare/vim-toml'

" Plugin extras
Plug 'junegunn/fzf.vim'
Plug 'vim-airline/vim-airline-themes'
Plug 'honza/vim-snippets'

Add path to show git status

" Main plugins
Plug 'w0rp/ale'
Plug 'jiangmiao/auto-pairs'
Plug 'jlanzarotta/bufexplorer'
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'junegunn/fzf', {'dir': '~/.fzf', 'do': './install --bin'}
Plug 'autozimu/LanguageClient-neovim', {'branch': 'next', 'do': 'bash install.sh'}
Plug 'preservim/nerdtree'
Plug 'altercation/vim-colors-solarized'
Plug 'lambdalisue/suda.vim'
Plug 'ervandew/supertab'
Plug 'SirVer/ultisnips'
Plug 'vim-airline/vim-airline'
Plug 'moll/vim-bbye'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-surround'
Plug 'cespare/vim-toml'

" Plugin extras
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'junegunn/fzf.vim'
Plug 'vim-airline/vim-airline-themes'
Plug 'honza/vim-snippets'


set termguicolors
colorscheme despacio
let g:despacio_Sunset = 1
highlight Normal guibg=none ctermbg=none
highlight NonText guibg=none ctermbg=none
highlight LineNr guibg=none ctermbg=none

" Airline
let g:airline_theme = 'minimalist'

" Lint
autocmd! BufWritePost,BufEnter * Neomake
let g:neomake_open_list = 2

" File management
nnoremap <leader>n :NERDTreeToggle<CR>
nnoremap <leader>d :Denite file_rec<CR>

" Deoplete
let g:deoplete#enable_at_startup = 1
let g:deoplete#omni_patterns = {}
let g:deoplete#omni_patterns.java = '[^. *\t]\.\w*'
let g:deoplete#sources = {}
let g:deoplete#sources._ = []
let g:deoplete#file#enable_buffer_path = 1

" Deoplete use tab
inoremap <expr><tab> pumvisible() ? "\<c-n>" : "\<tab>"

" vim-javacomplete2
autocmd FileType java setlocal omnifunc=javacomplete#Complete

Make tab key use <C-x><C-o> by default

set termguicolors
colorscheme despacio
let g:despacio_Sunset = 1
highlight Normal guibg=none ctermbg=none
highlight NonText guibg=none ctermbg=none
highlight LineNr guibg=none ctermbg=none

" Airline
let g:airline_theme = 'minimalist'

" Lint
autocmd! BufWritePost,BufEnter * Neomake
let g:neomake_open_list = 2

if filereadable("build.gradle")
    let g:neomake_java_enabled_makers = ['gradle']
endif

" File management
nnoremap <leader>n :NERDTreeToggle<CR>
nnoremap <leader>d :Denite file_rec<CR>

" Deoplete
let g:deoplete#enable_at_startup = 1
let g:deoplete#omni_patterns = {}
let g:deoplete#omni_patterns.java = '[^. *\t]\.\w*'
let g:deoplete#sources = {}
let g:deoplete#sources._ = []
let g:deoplete#file#enable_buffer_path = 1

" Deoplete use tab
inoremap <expr><tab> pumvisible() ? "\<c-n>" : "\<c-x>\<c-o>"

" vim-javacomplete2
autocmd FileType java setlocal omnifunc=javacomplete#Complete


let mapleader=","

" no swap files
set noswapfile

" always show the status line
set laststatus=2

" display column and line indicator
set cursorcolumn
set cursorline

" Line Numbers
set rnu
set nu

" syntax highlighting
syntax on

" Set line numbers and relative line numbers
set number
set relativenumber
set numberwidth=1

" Set 7 lines to the cursor when moving vertically with j/k
set so=7

" Wrapping - No wrap, scroll one char at a time
set nowrap
set sidescroll=1
set listchars+=precedes:<,extends:>

" Indenting
set tabstop=4
set shiftwidth=4
set expandtab

" Filetype detection
filetype on
filetype plugin on
filetype indent on

" Parentheses
set showmatch

" Folding
set foldmethod=syntax
set foldcolumn=0
let javaScript_fold=1
set foldlevelstart=99

" Searching
set wrapscan
set hlsearch

" Turn on the Wild menu
set wildmenu

" ignore for fuzzy find
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store,*\\tmp\\*,*.swp,*.zip,*.exe,*\\bin\\*,*\\packages\\*,*\\obj\\*

Improve file searching by adding node_modules to wildignore and setting path to recursive search

let mapleader=","

" no swap files
set noswapfile

" always show the status line
set laststatus=2

" display column and line indicator
set cursorcolumn
set cursorline

" Line Numbers
set rnu
set nu

" syntax highlighting
syntax on

" Set line numbers and relative line numbers
set number
set relativenumber
set numberwidth=1

" Set 7 lines to the cursor when moving vertically with j/k
set so=7

" Wrapping - No wrap, scroll one char at a time
set nowrap
set sidescroll=1
set listchars+=precedes:<,extends:>

" Indenting
set tabstop=4
set shiftwidth=4
set expandtab

" Filetype detection
filetype on
filetype plugin on
filetype indent on

" Parentheses
set showmatch

" Folding
set foldmethod=syntax
set foldcolumn=0
let javaScript_fold=1
set foldlevelstart=99

" Searching
set wrapscan
set hlsearch

" Turn on the Wild menu
set wildmenu

" ignore for fuzzy find
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store,*\\tmp\\*,*.swp,*.zip,*.exe,*\\bin\\*,*\\packages\\*,*\\obj\\*,*/node_modules/*

" add recursive folder searching to find
set path+=**


MP 'tpope/vim-surround'
MP 'pelodelfuego/vim-swoop'
MP 'terryma/vim-multiple-cursors'

MP 'scrooloose/nerdcommenter',        { 'on': '<Plug>NERDCommenterToggle' }

MP 'jiangmiao/auto-pairs', { 'on': [] }

augroup spacevimAutoPairs
  autocmd!
  autocmd CursorHold,CursorHoldI,InsertEnter * call plug#load('auto-pairs') | call AutoPairsTryInit() | autocmd! spacevimAutoPairs
augroup END

Allow disabling auto-pairs as it somehows interupts vim-clap

MP 'tpope/vim-surround'
MP 'pelodelfuego/vim-swoop'
MP 'terryma/vim-multiple-cursors'

MP 'scrooloose/nerdcommenter',        { 'on': '<Plug>NERDCommenterToggle' }

MP 'jiangmiao/auto-pairs', { 'on': [] }

function! s:TryInitAutoPairs() abort
  if !has_key(g:plugs, 'auto-pairs')
    return
  endif
  if !exists('g:AutoPairsLoaded')
    call plug#load('auto-pairs')
  endif
  if exists('*AutoPairsTryInit')
    call AutoPairsTryInit()
  endif
  autocmd! spacevimAutoPairs
endfunction

augroup spacevimAutoPairs
  autocmd!
  autocmd CursorHold,CursorHoldI,InsertEnter * call <SID>TryInitAutoPairs()
augroup END


" c
autocmd BufNewFile,BufRead *.c,*.h call SetCOptions()
function SetCOptions()
	setlocal filetype=c
	setlocal colorcolumn=81
	setlocal commentstring=//\ %s " prefer // over /*...*/ for single-line comments
endfunction

" fish
autocmd BufNewFile,BufRead *.fish call SetFishOptions()
function SetFishOptions()
	setlocal filetype=fish
endfunction

" latex - fix "plaintex" filetype detection shit
autocmd BufNewFile,BufRead *.tex call SetLatexOptions()
function SetLatexOptions()
	setlocal filetype=tex
endfunction

" rust
autocmd BufNewFile,BufRead *.rs call SetRustOptions()
function SetRustOptions()
	setlocal filetype=rust
	setlocal commentstring=//\ %s
endfunction

" typescript
autocmd BufNewFile,BufRead *.ts call SetTSOptions()
function SetTSOptions()
  setlocal filetype=typescript
endfunction

" yaml
autocmd FileType yaml call SetYamlOptions()
function SetYamlOptions()
	setlocal indentkeys-=<:>
endfunction

Remove fish filetype vim config

" c
autocmd BufNewFile,BufRead *.c,*.h call SetCOptions()
function SetCOptions()
	setlocal filetype=c
	setlocal colorcolumn=81
	setlocal commentstring=//\ %s " prefer // over /*...*/ for single-line comments
endfunction

" latex - fix "plaintex" filetype detection shit
autocmd BufNewFile,BufRead *.tex call SetLatexOptions()
function SetLatexOptions()
	setlocal filetype=tex
endfunction

" rust
autocmd BufNewFile,BufRead *.rs call SetRustOptions()
function SetRustOptions()
	setlocal filetype=rust
	setlocal commentstring=//\ %s
endfunction

" typescript
autocmd BufNewFile,BufRead *.ts call SetTSOptions()
function SetTSOptions()
  setlocal filetype=typescript
endfunction

" yaml
autocmd FileType yaml call SetYamlOptions()
function SetYamlOptions()
	setlocal indentkeys-=<:>
endfunction


"mark syntax errors with :signs
let g:syntastic_enable_signs=1

"automatically jump to the error when saving the file
let g:syntastic_auto_jump=0

"show the error list automatically
let g:syntastic_auto_loc_list=0

" configure syntastic syntax checking to check on open as well as save
let g:syntastic_check_on_open=0

let g:syntastic_html_tidy_ignore_errors=[" proprietary attribute \"ng-"]

" Checkers
let g:syntastic_ruby_checkers = ['rubocop']
let g:syntastic_scss_checkers = ['scss_lint']
let g:syntastic_slim_checkers = ['slimrb']
let g:syntastic_javascript_checkers = ['eslint']
let g:syntastic_chef_checkers = ['foodcritic']

Change VIM rubocop exec path

"mark syntax errors with :signs
let g:syntastic_enable_signs=1

"automatically jump to the error when saving the file
let g:syntastic_auto_jump=0

"show the error list automatically
let g:syntastic_auto_loc_list=0

" configure syntastic syntax checking to check on open as well as save
let g:syntastic_check_on_open=0

let g:syntastic_html_tidy_ignore_errors=[" proprietary attribute \"ng-"]

" Checkers
let g:syntastic_ruby_checkers = ['rubocop']
let g:syntastic_scss_checkers = ['scss_lint']
let g:syntastic_slim_checkers = ['slimrb']
let g:syntastic_javascript_checkers = ['eslint']
let g:syntastic_chef_checkers = ['foodcritic']

let g:syntastic_ruby_rubocop_exec = '~/.rbenv/shims/rubocop'


call plug#begin('~/.vim/plugged')

Plug 'chriskempson/base16-vim'                                          " base16 themes
Plug 'tpope/vim-fugitive', {'for': []}                                  " git <3
Plug 'scrooloose/syntastic'                                             " syntax checking
Plug 'editorconfig/editorconfig-vim'
Plug 'ctrlpvim/ctrlp.vim'                                               " fuzzy searching
Plug 'airblade/vim-gitgutter'                                           " show what lines have changed when inside a git repo
Plug 'valloric/youcompleteme', {'do': './install.py --clang-completer'} " completion
Plug 'haya14busa/incsearch.vim'                                         " a better insearch
Plug 'junegunn/vim-easy-align'                                          " easy align text
Plug 'jamessan/vim-gnupg', {'for': []}                                  " transparent editing of gpg files
Plug 'plasticboy/vim-markdown', {'for': 'markdown'}                     " Markdown vim mode
Plug 'mhinz/vim-startify'                                               " the fancy start screen for vim
Plug 'tpope/vim-eunuch'                                                 " helpers for UNIX
Plug 'easymotion/vim-easymotion'                                        " Vim motions on speed

" Add plugins to &runtimepath
call plug#end()

Use PGP for GPG files

call plug#begin('~/.vim/plugged')

Plug 'chriskempson/base16-vim'                                          " base16 themes
Plug 'tpope/vim-fugitive', {'for': []}                                  " git <3
Plug 'scrooloose/syntastic'                                             " syntax checking
Plug 'editorconfig/editorconfig-vim'
Plug 'ctrlpvim/ctrlp.vim'                                               " fuzzy searching
Plug 'airblade/vim-gitgutter'                                           " show what lines have changed when inside a git repo
Plug 'valloric/youcompleteme', {'do': './install.py --clang-completer'} " completion
Plug 'haya14busa/incsearch.vim'                                         " a better insearch
Plug 'junegunn/vim-easy-align'                                          " easy align text
Plug 'jamessan/vim-gnupg' " transparent editing of gpg files
Plug 'plasticboy/vim-markdown', {'for': 'markdown'}                     " Markdown vim mode
Plug 'mhinz/vim-startify'                                               " the fancy start screen for vim
Plug 'tpope/vim-eunuch'                                                 " helpers for UNIX
Plug 'easymotion/vim-easymotion'                                        " Vim motions on speed

" Add plugins to &runtimepath
call plug#end()


let g:deoplete#enable_at_startup = 1
let g:deoplete#keyword_patterns = {}
let g:deoplete#keyword_patterns.clojure = '[\w!$%&*+/:<=>?@\^_~\-\.#]*'
autocmd InsertLeave,CompleteDone * if pumvisible() == 0 | pclose | endif

Disable the deoplete preview window

let g:deoplete#enable_at_startup = 1
let g:deoplete#keyword_patterns = {}
let g:deoplete#keyword_patterns.clojure = '[\w!$%&*+/:<=>?@\^_~\-\.#]*'
autocmd InsertLeave,CompleteDone * if pumvisible() == 0 | pclose | endif
set completeopt-=preview


" Vim filetype plugin file
" Language: LLVM Assembly
" Maintainer: The LLVM team, http://llvm.org/

if exists("b:did_ftplugin")
  finish
endif
let b:did_ftplugin = 1

setlocal softtabstop=2 shiftwidth=2
setlocal expandtab

Add the IR's comment prefix to the comments list. This allows vim to intelligently wrap prose written in IR comment blocks. This has bothered me for roughly ever, and my fellow IRC denziens convinced me to fix it.

" Vim filetype plugin file
" Language: LLVM Assembly
" Maintainer: The LLVM team, http://llvm.org/

if exists("b:did_ftplugin")
  finish
endif
let b:did_ftplugin = 1

setlocal softtabstop=2 shiftwidth=2
setlocal expandtab
setlocal comments+=:;


if !has('python')
    echoerr "This plugin requires python."
    finish
endif

if exists('vim_c_grayout_loaded')
    finish
else
    let g:vim_c_grayout_loaded = 1
    let g:grayout_debug = 0
    let g:grayout_debug_logfile = 0
    let g:grayout_debug_compiler_inout = 0
    let g:grayout_cmd_line = 'clang -x c++ -E -'

    highlight PreprocessorGrayout cterm=italic gui=italic ctermfg=DarkGray guifg=DarkGray
    sign define PreprocessorGrayout linehl=PreprocessorGrayout

    python import sys
endif

function! UpdateGrayout()
    if !exists("b:num_grayout_lines")
        let b:num_grayout_lines = 0
    endif

    if !exists('b:grayout_cmd_line')
        call s:LoadConfig()
    endif

    python sys.argv = ["grayout"]
    pyfile grayout.py
endfunction

function! ClearGrayout()
    python sys.argv = ["clear"]
    pyfile grayout.py
endfunction

function! s:LoadConfig()
    python sys.argv = ["config"]
    pyfile grayout.py
endfunction

Add -w and -P flags to the default cmd line

if !has('python')
    echoerr "This plugin requires python."
    finish
endif

if exists('vim_c_grayout_loaded')
    finish
else
    let g:vim_c_grayout_loaded = 1
    let g:grayout_debug = 0
    let g:grayout_debug_logfile = 0
    let g:grayout_debug_compiler_inout = 0
    let g:grayout_cmd_line = 'clang -x c++ -w -P -E -'

    highlight PreprocessorGrayout cterm=italic gui=italic ctermfg=DarkGray guifg=DarkGray
    sign define PreprocessorGrayout linehl=PreprocessorGrayout

    python import sys
endif

function! UpdateGrayout()
    if !exists("b:num_grayout_lines")
        let b:num_grayout_lines = 0
    endif

    if !exists('b:grayout_cmd_line')
        call s:LoadConfig()
    endif

    python sys.argv = ["grayout"]
    pyfile grayout.py
endfunction

function! ClearGrayout()
    python sys.argv = ["clear"]
    pyfile grayout.py
endfunction

function! s:LoadConfig()
    python sys.argv = ["config"]
    pyfile grayout.py
endfunction


" Mappings for neosnippet https://github.com/Shougo/neosnippet.vim
let g:neosnippet#snippets_directory .= ", ~/.dotfiles/vim/snippets"

" SuperTab like snippets behavior.
imap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)"
\: pumvisible() ? "\<C-n>" : "\<TAB>"
smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)"
\: "\<TAB>"

if has('conceal')
    set conceallevel=2 concealcursor=i
endif

Make dotfiles the primary snippets dir.

" Mappings for neosnippet https://github.com/Shougo/neosnippet.vim
let g:neosnippet#snippets_directory .= ",~/.dotfiles/vim/snippets"

" SuperTab like snippets behavior.
imap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)"
\: pumvisible() ? "\<C-n>" : "\<TAB>"
smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)"
\: "\<TAB>"

if has('conceal')
    set conceallevel=2 concealcursor=i
endif


" Personal vim configuration.
" Maintainer: Lorenzo Cabrini <lorenzo.cabrini@gmail.com>

" General options
set nocompatible
set backspace=indent,eol,start
set showcmd
set showmatch
set incsearch
set autowrite
set hidden
set history=50
set ruler

" Tabs and spaces
set tabstop=8
set expandtab
set shiftwidth=4
set softtabstop=4

" Settings for color terminals and in the GUI.
if &t_Co > 2 || has("gui_running")
  syntax on
  set background=dark
  colorscheme elflord
  set hlsearch
endif

" Enable filetype plugins
if has("autocmd")
  filetype plugin indent on
endif

" If lightline is installed
if isdirectory($HOME . "/.vim/pack/lightline")
  set laststatus=2
  set noshowmode
endif

Fix path to lightline plugin.

" Personal vim configuration.
" Maintainer: Lorenzo Cabrini <lorenzo.cabrini@gmail.com>

" General options
set nocompatible
set backspace=indent,eol,start
set showcmd
set showmatch
set incsearch
set autowrite
set hidden
set history=50
set ruler

" Tabs and spaces
set tabstop=8
set expandtab
set shiftwidth=4
set softtabstop=4

" Settings for color terminals and in the GUI.
if &t_Co > 2 || has("gui_running")
  syntax on
  set background=dark
  colorscheme elflord
  set hlsearch
endif

" Enable filetype plugins
if has("autocmd")
  filetype plugin indent on
endif

" If lightline is installed
if isdirectory($HOME . "/.vim/pack/plugins/start/lightline")
  set laststatus=2
  set noshowmode
endif


" Need this here for Vundle
set nocompatible

" Load Vundle for managing scripts
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()

" Let Vundle update itself
Bundle 'gmarik/vundle'

" Color schemes
Bundle 'Wombat'
" Syntaxes
Bundle 'wikipedia.vim'

Bundle 'scrooloose/nerdcommenter'
Bundle 'myusuf3/numbers.vim'
Bundle 'tpope/vim-surround'
Bundle 'kien/ctrlp.vim'

" LaTeX
Bundle 'git://vim-latex.git.sourceforge.net/gitroot/vim-latex/vim-latex'

Remove wikipedia syntax, update Vim-LaTeX source

" Need this here for Vundle
set nocompatible

" Load Vundle for managing scripts
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()

" Let Vundle update itself
Bundle 'gmarik/vundle'

" Color schemes
Bundle 'Wombat'

Bundle 'scrooloose/nerdcommenter'
Bundle 'myusuf3/numbers.vim'
Bundle 'tpope/vim-surround'
Bundle 'kien/ctrlp.vim'

" LaTeX
Bundle 'jcf/vim-latex'


let g:ctrlp_custom_ignore = {
  \ 'dir':  '\v[\/]\.(git|hg|svn)$',
  \ 'file': '\v\.(exe|so|dll)$',
  \ }

Add CtrlP cache clearing shortcut

let g:ctrlp_custom_ignore = {
  \ 'dir':  '\v[\/]\.(git|hg|svn)$',
  \ 'file': '\v\.(exe|so|dll)$',
  \ }

map <leader>C :CtrlPClearCache<cr>


filetype off " required!
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

Plugin 'gmarik/Vundle.vim'
Plugin 'vim-scripts/paredit.vim'
Plugin 'scrooloose/nerdtree'
Plugin 'kien/ctrlp.vim'
Plugin 'itchyny/lightline.vim'
Plugin 'scrooloose/syntastic'
Plugin 'altercation/vim-colors-solarized'

call vundle#end()
filetype plugin indent on " required!

colorscheme solarized

let g:lightline = {'colorscheme': 'solarized_dark',}

" Brief help
" " :PluginList          - list configured plugins
" " :PluginInstall(!)    - install (update) plugins
" " :PluginSearch(!) foo - search (or refresh cache first) for foo
" " :PluginClean(!)      - confirm (or auto-approve) removal of unused plugins

Use official fork of CtrlP

filetype off " required!
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

Plugin 'gmarik/Vundle.vim'
Plugin 'vim-scripts/paredit.vim'
Plugin 'scrooloose/nerdtree'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'itchyny/lightline.vim'
Plugin 'scrooloose/syntastic'
Plugin 'altercation/vim-colors-solarized'

call vundle#end()
filetype plugin indent on " required!

colorscheme solarized

let g:lightline = {'colorscheme': 'solarized_dark',}

" Brief help
" " :PluginList          - list configured plugins
" " :PluginInstall(!)    - install (update) plugins
" " :PluginSearch(!) foo - search (or refresh cache first) for foo
" " :PluginClean(!)      - confirm (or auto-approve) removal of unused plugins


set t_Co=256
set background=dark
silent! colorscheme Tomorrow-Night
silent! let g:airline_theme='tomorrow'

" Feel free to override the colorscheme by adding a line to ~/.vimrc.local
" such as the following:
"
" colorscheme solarized
" let g:airline_theme='solarized'

Switch to light theme: Asus PB287Q has shitty dark shade fidelity

set t_Co=256
set background=dark
silent! colorscheme Tomorrow
silent! let g:airline_theme='tomorrow'

" Feel free to override the colorscheme by adding a line to ~/.vimrc.local
" such as the following:
"
" colorscheme solarized
" let g:airline_theme='solarized'


Plug 'bling/vim-airline'

set laststatus=2
let g:airline_powerline_fonts = 1
let g:airline#extensions#syntastic#enabled = 1

Update airline to new repo

Plug 'vim-airline/vim-airline'

set laststatus=2
let g:airline_powerline_fonts = 1
let g:airline#extensions#syntastic#enabled = 1


let g:gitgutter_sign_added = '✚'
let g:gitgutter_sign_modified = '✹'
let g:gitgutter_sign_removed = '✖'
let g:gitgutter_sign_removed_first_line = '➜'
let g:gitgutter_sign_modified_removed = '✗'

" Use 'ag' as the default grep command
if executable('ag')
  let g:gitgutter_grep_command = 'ag'
endif

Reduce "updatetime" so that git diff markers appear more quickly

set updatetime=250

let g:gitgutter_sign_added = '✚'
let g:gitgutter_sign_modified = '✹'
let g:gitgutter_sign_removed = '✖'
let g:gitgutter_sign_removed_first_line = '➜'
let g:gitgutter_sign_modified_removed = '✗'

" Use 'ag' as the default grep command
if executable('ag')
  let g:gitgutter_grep_command = 'ag'
endif