if exists("g:python_linelength")
  let &l:textwidth=g:python_linelength
endif
" Exclude pylint: slow, must run on files in filesystem
let b:ale_linters_ignore = ['pylint']
let b:ale_fixers = ['black', 'isort', 'trim_whitespace']
let b:ale_python_black_options=printf('--line-length=%d', &l:textwidth)
let b:ale_python_flake8_options=printf('--max-line-length=%d', &l:textwidth)
let b:black_linelength=&l:textwidth

nnoremap <buffer> <silent> <localleader>b Oimport pdb; pdb.set_trace()  # XXX<esc>

Set other textwidth vars when textwidth is set

if exists("g:python_linelength")
  let &l:textwidth=g:python_linelength
endif
" Exclude pylint: slow, must run on files in filesystem
let b:ale_linters_ignore = ['pylint']
let b:ale_fixers = ['black', 'isort', 'trim_whitespace']

function UpdateTextwidthVars()
  let b:ale_python_black_options=printf('--line-length=%d', &l:textwidth)
  let b:ale_python_flake8_options=printf('--max-line-length=%d', &l:textwidth)
  let b:black_linelength=&l:textwidth
endfunction
call UpdateTextwidthVars()

" I can't find a way to make this buffer local but it doesn't matter much
" because the variables are irrelevant to non-python files.
augroup textwidth_onset
  autocmd! *
  autocmd OptionSet textwidth :call UpdateTextwidthVars()
augroup END

nnoremap <buffer> <silent> <localleader>b Oimport pdb; pdb.set_trace()  # XXX<esc>


" let NERDTree change my working directory if its root changes.
let NERDTreeChDirMode=2
" show hidden files
let NERDTreeShowHidden=1

map <Leader>n :NERDTreeToggle<CR>

Add nifty NERDTree autocmds from carlhuda/janus

" let NERDTree change my working directory if its root changes.
let NERDTreeChDirMode=2
" show hidden files
let NERDTreeShowHidden=1

map <Leader>n :NERDTreeToggle<CR>

" From github.com/carlhuda/janus
autocmd VimEnter * call s:CdIfDirectory(expand("<amatch>"))
autocmd FocusGained * call s:UpdateNERDTree()
autocmd WinEnter * call s:CloseIfOnlyNerdTreeLeft()

" Close all open buffers on entering a window if the only
" buffer that's left is the NERDTree buffer
function s:CloseIfOnlyNerdTreeLeft()
  if exists("t:NERDTreeBufName")
    if bufwinnr(t:NERDTreeBufName) != -1
      if winnr("$") == 1
        q
      endif
    endif
  endif
endfunction

" If the parameter is a directory, cd into it
function s:CdIfDirectory(directory)
  let explicitDirectory = isdirectory(a:directory)
  let directory = explicitDirectory || empty(a:directory)

  if explicitDirectory
    exe "cd " . fnameescape(a:directory)
  endif

  " Allows reading from stdin
  " ex: git diff | mvim -R -
  if strlen(a:directory) == 0
    return
  endif

  if directory
    NERDTree
    wincmd p
    bd
  endif

  if explicitDirectory
    wincmd p
  endif
endfunction

" NERDTree utility function
function s:UpdateNERDTree(...)
  let stay = 0

  if(exists("a:1"))
    let stay = a:1
  end

  if exists("t:NERDTreeBufName")
    let nr = bufwinnr(t:NERDTreeBufName)
    if nr != -1
      exe nr . "wincmd w"
      exe substitute(mapcheck("R"), "<CR>", "", "")
      if !stay
        wincmd p
      end
    endif
  endif

  if exists(":CommandTFlush") == 2
    CommandTFlush
  endif
endfunction


" Copyright 2013 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.
"
" go.vim: Vim filetype plugin for Go.

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

setlocal comments=s1:/*,mb:*,ex:*/,://
setlocal commentstring=//\ %s

let b:undo_ftplugin = "setl com< cms<"

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

Disable automatic line wrapping by textwidth.

" Copyright 2013 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.
"
" go.vim: Vim filetype plugin for Go.

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

setlocal formatoptions-=t

setlocal comments=s1:/*,mb:*,ex:*/,://
setlocal commentstring=//\ %s

let b:undo_ftplugin = "setl fo< com< cms<"

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


" How commands are mapped into Vim:
"
"     map  / noremap  :  command / visual modes
"     map! / noremap! :  command / insert mode
"     nmap / nnoremap :  command mode
"     imap / inoremap :  insert mode
"     vmap / vnoremap :  visual mode
"
"  Special command used in mappings (see also: help key-notation)
"
"     <C-c>    : go to command mode
"     <C-o>    : use command mode and return to last mode
"
" NOTE: the folllowing key combos can not be modified in Vim
"
"    C-; : can not be captured
"    C-[ : same as ESC
"    C-i : same mapping as TAB key
"    C-m : same mapping as ENTER key

" enter command mode faser
nnoremap  <leader><leader>  :
vnoremap  <leader><leader>  :

" fix missed <ESC>
noremap  `    <ESC>
noremap! `    <ESC>
noremap  <F1> <ESC>
noremap! <F1> <ESC>

" <esc> alternatives that are faster
inoremap jj          <ESC>
noremap! <C-Space>   <ESC>
vnoremap <C-Space>   <ESC>
nnoremap <C-Space>   <NOP>

" quickly reload the vimrc file
nnoremap <silent> <leader>z :so $MYVIMRC<CR>

Enable backtick (`) in Vim

" How commands are mapped into Vim:
"
"     map  / noremap  :  command / visual modes
"     map! / noremap! :  command / insert mode
"     nmap / nnoremap :  command mode
"     imap / inoremap :  insert mode
"     vmap / vnoremap :  visual mode
"
"  Special command used in mappings (see also: help key-notation)
"
"     <C-c>    : go to command mode
"     <C-o>    : use command mode and return to last mode
"
" NOTE: the folllowing key combos can not be modified in Vim
"
"    C-; : can not be captured
"    C-[ : same as ESC
"    C-i : same mapping as TAB key
"    C-m : same mapping as ENTER key

" enter command mode faser
nnoremap  <leader><leader>  :
vnoremap  <leader><leader>  :

" fix missed <ESC>
noremap  <F1> <ESC>
noremap! <F1> <ESC>

" <esc> alternatives that are faster
inoremap jj          <ESC>
noremap! <C-Space>   <ESC>
vnoremap <C-Space>   <ESC>
nnoremap <C-Space>   <NOP>

" quickly reload the vimrc file
nnoremap <silent> <leader>z :so $MYVIMRC<CR>


" Make nerdtree look nice
let NERDTreeMinimalUI = 1
let NERDTreeDirArrows = 1
let NERDTreeShowHidden = 1
let g:NERDTreeWinSize = 30

autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif

Disable directory listing at startup

" Make nerdtree look nice
let NERDTreeMinimalUI = 1
let NERDTreeDirArrows = 1
let NERDTreeShowHidden = 1
let g:NERDTreeWinSize = 30
let g:NERDTreeHijackNetrw = 0

autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif


let g:deoplete#enable_at_startup = 1
autocmd InsertLeave,CompleteDone * if pumvisible() == 0 | pclose | endif
set completeopt-=preview

Add deoplete settings for Clojure again

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


" Copy current file path (plus line number, if asked) to system pasteboard.
map <silent> <leader>cp :let @* = expand("%")<CR>:echo "Copied: ".expand("%")<CR>
map <silent> <leader>cP :let @* = expand("%").":".line(".")<CR>:echo "Copied: ".expand("%").":".line(".")<CR>

" Toggle spell check
map <leader>ss :setlocal spell!<cr>

" Mapping for writing all files in a tab
cabbrev wt silent windo w

" Gracefully handle holding shift too long after : for common commands
cabbrev Q q
cabbrev Qa qa
cabbrev Tabe tabe
cabbrev Tabn tabn
cabbrev W w
cabbrev Wa wa
cabbrev Wq wq
cabbrev Wt wt

" Make Y consistent with D and C.
map Y y$

" Indent/unindent visual mode selection with tab/shift+tab
vmap <tab> >gv
vmap <s-tab> <gv

Use Readline-like keybindings for command mode

" Copy current file path (plus line number, if asked) to system pasteboard.
map <silent> <leader>cp :let @* = expand("%")<CR>:echo "Copied: ".expand("%")<CR>
map <silent> <leader>cP :let @* = expand("%").":".line(".")<CR>:echo "Copied: ".expand("%").":".line(".")<CR>

" Toggle spell check
map <leader>ss :setlocal spell!<cr>

" Mapping for writing all files in a tab
cabbrev wt silent windo w

" Gracefully handle holding shift too long after : for common commands
cabbrev Q q
cabbrev Qa qa
cabbrev Tabe tabe
cabbrev Tabn tabn
cabbrev W w
cabbrev Wa wa
cabbrev Wq wq
cabbrev Wt wt

" Make Y consistent with D and C.
map Y y$

" Indent/unindent visual mode selection with tab/shift+tab
vmap <tab> >gv
vmap <s-tab> <gv

" Readline-like navigation for command mode
cnoremap <C-A> <Home>
cnoremap <C-B> <C-Left>
cnoremap <C-F> <C-Right>


if exists('g:loaded_gita')
  finish
endif
let g:loaded_gita = 1

" NOTE: A known minimum requirement is 7.3.1170 : Script local funcref is supported
if v:version < 703 || (v:version == 703 && !has('patch1170'))
  " NOTE: An announced requirement is Vim 7.4
  echohl ErrorMsg | echo 'gita: vim-gita requires Vim 7.4 or later' | echohl None
  finish
endif

command! GitaClear :call gita#core#expire()
command! -nargs=* -range -bang
      \ -complete=customlist,gita#command#complete
      \ Gita
      \ call gita#command#command(<q-bang>, [<line1>, <line2>], <q-args>)

augroup vim_gita_internal
  autocmd!
  autocmd FileReadCmd   gita://* nested call gita#content#autocmd('FileReadCmd')
  autocmd FileWriteCmd  gita://* nested call gita#content#autocmd('FileWriteCmd')
  autocmd BufReadCmd    gita:*   nested call gita#content#autocmd('BufReadCmd')
  autocmd BufWriteCmd   gita:*   nested call gita#content#autocmd('BufWriteCmd')
  autocmd BufReadCmd    gita:*/* nested call gita#content#autocmd('BufReadCmd')
  autocmd BufWriteCmd   gita:*/* nested call gita#content#autocmd('BufWriteCmd')
augroup END

Support a bar (|) in Gita command

if exists('g:loaded_gita')
  finish
endif
let g:loaded_gita = 1

" NOTE: A known minimum requirement is 7.3.1170 : Script local funcref is supported
if v:version < 703 || (v:version == 703 && !has('patch1170'))
  " NOTE: An announced requirement is Vim 7.4
  echohl ErrorMsg | echo 'gita: vim-gita requires Vim 7.4 or later' | echohl None
  finish
endif

command! GitaClear :call gita#core#expire()
command! -nargs=* -range -bang -bar
      \ -complete=customlist,gita#command#complete
      \ Gita
      \ call gita#command#command(<q-bang>, [<line1>, <line2>], <q-args>)

augroup vim_gita_internal
  autocmd!
  autocmd FileReadCmd   gita://* nested call gita#content#autocmd('FileReadCmd')
  autocmd FileWriteCmd  gita://* nested call gita#content#autocmd('FileWriteCmd')
  autocmd BufReadCmd    gita:*   nested call gita#content#autocmd('BufReadCmd')
  autocmd BufWriteCmd   gita:*   nested call gita#content#autocmd('BufWriteCmd')
  autocmd BufReadCmd    gita:*/* nested call gita#content#autocmd('BufReadCmd')
  autocmd BufWriteCmd   gita:*/* nested call gita#content#autocmd('BufWriteCmd')
augroup END


function! Powerline#Functions#fugitive#GetBranch(symbol) " {{{
	let ret = fugitive#statusline()

	let ret = substitute(ret, '\v\[?GIT\(([a-z0-9\-_\./:]+)\)\]?', a:symbol .' \1', 'gi')

	return ret
endfunction " }}}

Fix Fugitive statusline segment not working with ignorecase on

function! Powerline#Functions#fugitive#GetBranch(symbol) " {{{
	let ret = fugitive#statusline()

	let ret = substitute(ret, '\c\v\[?GIT\(([a-z0-9\-_\./:]+)\)\]?', a:symbol .' \1', 'g')

	return ret
endfunction " }}}


" Plugin settings

set rtp+=~/.vim/bundle/vim-project/

nmap <leader><S-t> :CommandTBuffer<CR>
nmap <leader>l :FSHere<CR>
nmap <leader><S-l> :split<CR> :FSBelow<CR>
nmap <leader>p :Welcome<CR>

Increase file count and folder depth for CommandT

" Plugin settings

let g:CommandTMaxFiles=100000
let g:CommandTMaxCachedDirectories=0
set rtp+=~/.vim/bundle/vim-project/

nmap <leader><S-t> :CommandTBuffer<CR>
nmap <leader>l :FSHere<CR>
nmap <leader><S-l> :split<CR> :FSBelow<CR>
nmap <leader>p :Welcome<CR>


" Make it beautiful - colors and fonts

if has("gui_running")
  " Show tab number (useful for Cmd-1, Cmd-2.. mapping)
  " For some reason this doesn't work as a regular set command,
  " (the numbers don't show up) so I made it a VimEnter event
  autocmd VimEnter * set guitablabel=%N:\ %t\ %M

  set lines=60
  set columns=190

  if has("gui_gtk2")
    set guifont=Inconsolata\ XL\ 11,Inconsolata\ 14,Monaco\ 11
  else
    set guifont=Inconsolata\ XL:h14,Inconsolata:h17,Monaco:h14
  end
else
  let g:CSApprox_loaded = 1

  " For people using a terminal that is not Solarized
  if exists("g:yadr_using_unsolarized_terminal")
    let g:solarized_termcolors=256
    let g:solarized_termtrans=1
  end
endif

" Tell the term has 256 colors.
set t_Co=256

colorscheme solarized
set background=dark

" Remove menu bar and tool bar.
set go=aei

Use Monaco font for mac instead.

" Make it beautiful - colors and fonts

if has("gui_running")
  " Show tab number (useful for Cmd-1, Cmd-2.. mapping)
  " For some reason this doesn't work as a regular set command,
  " (the numbers don't show up) so I made it a VimEnter event
  autocmd VimEnter * set guitablabel=%N:\ %t\ %M

  set lines=60
  set columns=190

  if has("gui_gtk2")
    set guifont=Inconsolata\ XL\ 11,Inconsolata\ 14,Monaco\ 11
  else
    set guifont=Monaco:h14
  end
else
  let g:CSApprox_loaded = 1

  " For people using a terminal that is not Solarized
  if exists("g:yadr_using_unsolarized_terminal")
    let g:solarized_termcolors=256
    let g:solarized_termtrans=1
  end
endif

" Tell the term has 256 colors.
set t_Co=256

colorscheme solarized
set background=dark

" Remove menu bar and tool bar.
set go=aei


" enable/disable Vim features and major settings

" allow Vim to manage buffers in the background
set hidden

" <TAB> completion matches up to first unknown character, similar to shell
" matching
set wildmode=list:longest

" Isolate swap files to a single directory instead of spreading around local
" file-system
set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp

" Disalbe weird prompts like "Press ENTER or type command to continue"
set shortmess=atI

Disable Vim bell for common errors.

" enable/disable Vim features and major settings

" allow Vim to manage buffers in the background
set hidden

" <TAB> completion matches up to first unknown character, similar to shell
" matching
set wildmode=list:longest

" Isolate swap files to a single directory instead of spreading around local
" file-system
set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp

" Disable weird prompts like "Press ENTER or type command to continue"
set shortmess=atI

" Disable bell (sound) alerts
set belloff=esc,error


" [ ] becomes [x], [x] becomes [ ], nothing gets [ ] at start
function! ToggleTodo()
  s/\[ \]/\[bbb\]/e
  s/\[x\]/\[ \]/e
  s/\[bbb\]/\[x\]/e
	s/^\(\s*\)\([^\[]\)/\1[ ] \2/e
endfunction

Fix bug in toggle todo

" [ ] becomes [x], [x] becomes [ ], nothing gets [ ] at start
function! ToggleTodo()
  s/\[ \]/\[bbb\]/e
  s/\[x\]/\[ \]/e
  s/\[bbb\]/\[x\]/e
	s/^\(\s*\)\([^\[ ]\)/\1[ ] \2/e
endfunction


" ----------------------------------------------------------------------------
" Airline
" ----------------------------------------------------------------------------
" Note: The airline theme is defined on the `theme.vim` file.

let g:airline_extensions = ['hunks', 'syntastic', 'tabline', 'whitespace']

let g:airline_powerline_fonts = 1

let g:airline#extensions#tabline#buffer_nr_format = '%s '
let g:airline#extensions#tabline#buffer_nr_show = 1
let g:airline#extensions#tabline#fnamecollapse = 0
let g:airline#extensions#tabline#fnamemod = ':t'

Fix syntastic and whitespace extra red space

" ----------------------------------------------------------------------------
" Airline
" ----------------------------------------------------------------------------
" Note: The airline theme is defined on the `theme.vim` file.

let g:airline_extensions = ['branch', 'hunks', 'tabline']

" I'm defining these 2 here because if I define them on the array, the
" statusline is rendered with some red spaces.
let g:airline#extensions#syntastic#enabled  = 1
let g:airline#extensions#whitespace#enabled = 1

let g:airline_powerline_fonts = 1

let g:airline#extensions#tabline#buffer_nr_format = '%s '
let g:airline#extensions#tabline#buffer_nr_show = 1
let g:airline#extensions#tabline#fnamecollapse = 0
let g:airline#extensions#tabline#fnamemod = ':t'


" File: swift.vim
" Author: Keith Smiley
" Description: Runtime files for Swift
" Last Modified: June 13, 2014

if exists("b:current_syntax")
  finish
endif

" Shebang
syntax match swiftShebang /#!.*$/

" Comment contained keywords
syntax keyword swiftTodos contained TODO XXX FIXME NOTE
syntax keyword swiftMarker contained MARK

" Comments
syntax match swiftComment /\/\/.*$/
      \ contains=swiftTodos,swiftMarker
syntax region swiftComment start=/\/\*/ end=/\*\//
      \ contains=swiftTodos,swiftMarker

" Literals
syntax region swiftString start=/"/ skip=/\\"/ end=/"/

" Set highlights
highlight default link swiftTodos TODO
highlight default link swiftString String
highlight default link swiftShebang Comment
highlight default link swiftComment Comment
highlight default link swiftMarker Comment

let b:current_syntax = "swift"

Add number and operator matchers

" File: swift.vim
" Author: Keith Smiley
" Description: Runtime files for Swift
" Last Modified: June 13, 2014

if exists("b:current_syntax")
  finish
endif

" Comments
" Shebang
syntax match swiftShebang /#!.*$/

" Comment contained keywords
syntax keyword swiftTodos contained TODO XXX FIXME NOTE
syntax keyword swiftMarker contained MARK

" Comment patterns
syntax match swiftComment /\/\/.*$/
      \ contains=swiftTodos,swiftMarker
syntax region swiftComment start=/\/\*/ end=/\*\//
      \ contains=swiftTodos,swiftMarker

" Literals
" Strings
syntax region swiftString start=/"/ skip=/\\"/ end=/"/

" Numbers
syntax match swiftNumber /\<\d\+\>/
syntax match swiftNumber /\<\d\+\.\d\+\>/
syntax match swiftNumber /\<0x\x\+\>/
syntax match swiftNumber /\<0b[01]\+\>/
syntax match swiftNumber /\<0o\o\+\>/

" Operators
syntax match swiftOperator "\v\~"
syntax match swiftOperator "\v!"
syntax match swiftOperator "\v\%"
syntax match swiftOperator "\v\^"
syntax match swiftOperator "\v\&"
syntax match swiftOperator "\v[^/]\*[^/]"
syntax match swiftOperator "\v-"
syntax match swiftOperator "\v\+"
syntax match swiftOperator "\v\="
syntax match swiftOperator "\v\|"
syntax match swiftOperator "\v[^/]\/[^/]"
syntax match swiftOperator "\v\."
syntax match swiftOperator "\v\<"
syntax match swiftOperator "\v\>"

" Set highlights
highlight default link swiftTodos TODO
highlight default link swiftShebang Comment
highlight default link swiftComment Comment
highlight default link swiftMarker Comment

highlight default link swiftString String
highlight default link swiftNumber Number

highlight default link swiftOperator Operator

let b:current_syntax = "swift"


if !jedi#init_python()
    finish
endif

if g:jedi#auto_initialization
    if g:jedi#completions_enabled
        " We need our own omnifunc, so this overrides the omnifunc set by
        " $VIMRUNTIME/ftplugin/python.vim.
        setlocal omnifunc=jedi#completions

        " map ctrl+space for autocompletion
        if g:jedi#completions_command == "<C-Space>"
            " In terminals, <C-Space> sometimes equals <Nul>.
            imap <buffer> <Nul> <C-Space>
        endif
        if g:jedi#completions_command != ""
            execute "inoremap <expr> <buffer> ".g:jedi#completions_command." jedi#complete_string(0)"
        endif
    endif
endif

Add select-mode mapping for completion trigger

if !jedi#init_python()
    finish
endif

if g:jedi#auto_initialization
    if g:jedi#completions_enabled
        " We need our own omnifunc, so this overrides the omnifunc set by
        " $VIMRUNTIME/ftplugin/python.vim.
        setlocal omnifunc=jedi#completions

        " map ctrl+space for autocompletion
        if g:jedi#completions_command == "<C-Space>"
            " In terminals, <C-Space> sometimes equals <Nul>.
            imap <buffer> <Nul> <C-Space>
            smap <buffer> <Nul> <C-Space>
        endif
        if g:jedi#completions_command != ""
            execute "inoremap <expr> <buffer> ".g:jedi#completions_command." jedi#complete_string(0)"
            " A separate mapping for select mode: deletes and completes.
            execute "snoremap <expr> <buffer> ".g:jedi#completions_command." '\<C-g>c'.jedi#complete_string(0)"
        endif
    endif
endif


call my_plugin#add('sonph/onehalf', {'rtp': 'vim/'})

function! Hook_post_source_onehalf()
  if $TERM !=# 'linux'
    colorscheme onehalflight
    hi! link IncSearch PMenuSel
  endif
endf

Add Clap Current Selection highlighting

call my_plugin#add('sonph/onehalf', {'rtp': 'vim/'})

function! Hook_post_source_onehalf()
  if $TERM !=# 'linux'
    colorscheme onehalflight
    hi! link IncSearch PMenuSel
    hi! link ClapCurrentSelection Function
  endif
endf


" Javascript definition
autocmd BufNewFile,BufRead Gulpfile*,*.js,*.javascript,*.es,*.jsx set filetype=javascript
autocmd Filetype javascript setlocal et ts=2 sts=2 sw=2

" Autocomplete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType javascript let g:SuperTabDefaultCompletionType = "<c-x><c-o>"

" JS Automatic formatting
autocmd BufWritePre *.js,*.jsx Neoformat
let g:neoformat_enabled_javascript = ['prettier']

" vim-jsx options
let g:javascript_plugin_flow = 1
let g:jsx_ext_required = 0

" JS Prettier options
nnoremap gp :silent %!prettier --stdin --trailing-comma none --single-quote --bracket-spacing --parser flow<CR>
autocmd FileType javascript set formatprg=prettier\ --stdin\ --parser\ flow\ --single-quote\ --bracket-spacing\ --trailing-comma\ none

" JS Beautify Options
autocmd FileType javascript noremap <buffer>  <c-f> :call JsBeautify()<cr>
autocmd FileType javascript vnoremap <buffer>  <c-f> :call RangeJsBeautify()<cr>
autocmd FileType jsx noremap <buffer> <c-f> :call JsxBeautify()<cr>
autocmd FileType jsx vnoremap <buffer> <c-f> :call RangeJsxBeautify()<cr>

Switch to default quotes for prettier

" Javascript definition
autocmd BufNewFile,BufRead Gulpfile*,*.js,*.javascript,*.es,*.jsx set filetype=javascript
autocmd Filetype javascript setlocal et ts=2 sts=2 sw=2

" Autocomplete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType javascript let g:SuperTabDefaultCompletionType = "<c-x><c-o>"

" JS Automatic formatting
autocmd BufWritePre *.js,*.jsx Neoformat
let g:neoformat_enabled_javascript = ['prettier']

" vim-jsx options
let g:javascript_plugin_flow = 1
let g:jsx_ext_required = 0

" JS Prettier options
nnoremap gp :silent %!prettier --stdin --trailing-comma none --bracket-spacing --parser flow<CR>
autocmd FileType javascript set formatprg=prettier\ --stdin\ --parser\ flow\ --bracket-spacing\ --trailing-comma\ none

" JS Beautify Options
autocmd FileType javascript noremap <buffer>  <c-f> :call JsBeautify()<cr>
autocmd FileType javascript vnoremap <buffer>  <c-f> :call RangeJsBeautify()<cr>
autocmd FileType jsx noremap <buffer> <c-f> :call JsxBeautify()<cr>
autocmd FileType jsx vnoremap <buffer> <c-f> :call RangeJsxBeautify()<cr>


set nocompatible

" General Vim behaviour.
set nowrap
set autoindent expandtab smarttab           " settings for indentation
set tabstop=2 shiftwidth=2 softtabstop=2    " use 2 spaces for indenting
set nobackup nowritebackup                  " turn off backup file creation
set statusline=%<%f\ %h%m%r%=%-20.(line=%l,col=%c%V,totlin=%L%)\%h%m%r%=%-40(,%n%Y%)\%P
set laststatus=2                            " always show the status line
set incsearch ignorecase smartcase hlsearch " search options
set hidden
set history=1000                            " remember the last 1000 command instead of the default 20
set scrolloff=4                             " scroll by 4 lines instead of a single line
filetype plugin indent on                   " Enable filetype-specific indenting and plugins

syntax on                                   " syntax highlighting

" Leader mappings
let mapleader = ","                         " The leader character is like a vim modifier key
map <leader>t :FuzzyFinderTextMate<CR>      " Start up the fuzzyfindertextmate by typing: ,t

set wildmenu                                " Make the command/file menu completion show more information
set wildmode=list:longest                   " Make the completions window larger

Add in a couple of settings for fuzzy finder and make a section for it.

set nocompatible

" General Vim behaviour.
set nowrap
set autoindent expandtab smarttab           " settings for indentation
set tabstop=2 shiftwidth=2 softtabstop=2    " use 2 spaces for indenting
set nobackup nowritebackup                  " turn off backup file creation
set statusline=%<%f\ %h%m%r%=%-20.(line=%l,col=%c%V,totlin=%L%)\%h%m%r%=%-40(,%n%Y%)\%P
set laststatus=2                            " always show the status line
set incsearch ignorecase smartcase hlsearch " search options
set hidden
set history=1000                            " remember the last 1000 command instead of the default 20
set scrolloff=4                             " scroll by 4 lines instead of a single line
filetype plugin indent on                   " Enable filetype-specific indenting and plugins

syntax on                                   " syntax highlighting

" Leader mappings
let mapleader = ","                         " The leader character is like a vim modifier key

set wildmenu                                " Make the command/file menu completion show more information
set wildmode=list:longest                   " Make the completions window larger

" Fuzzy Finder Settings
let g:fuzzy_ignore = "*.log"
let g:fuzzy_matching_limit = 70
map <leader>t :FuzzyFinderTextMate<CR>      " Start up the fuzzyfindertextmate by typing: ,t


" plugin/plugin.bbye.vim
"
" @file Configuration of the Bbye plugin

" Close the current buffer but preserve the window layout if possible
if dw#IsLoaded('vim-bbye')
  nnoremap <silent><special> <Leader>q :<C-U>Bdelete<CR>
else
  nnoremap <silent><special> <Leader>q :<C-U>lclose<CR>:bdelete<CR>
endif

Use <Leader>x in vim to close buffer

" plugin/plugin.bbye.vim
"
" @file Configuration of the Bbye plugin

" Close the current buffer but preserve the window layout if possible
if dw#IsLoaded('vim-bbye')
  nnoremap <silent><special> <Leader>x :<C-U>Bdelete<CR>
else
  nnoremap <silent><special> <Leader>x :<C-U>lclose<CR>:bdelete<CR>
endif


" ------------------------------------------------------------------------------
"  Command-T and related configuration
" ------------------------------------------------------------------------------
if &term =~ "xterm" || &term =~ "screen"
  " Ensure Escape key can close the match listing in Command-T
  let g:CommandTCancelMap = ['<ESC>', '<C-c>']
  " Ensure <C-j> and <C-k> can move up and down a list of file matches
  let g:CommandTSelectNextMap = ['<C-j>', '<ESC>OB']
  let g:CommandTSelectPrevMap = ['<C-k>', '<ESC>OA']
endif
" It seems that using Command T with mvim isn't quite working with regards
" to ignoring all files under a specific folder that I would expect,
" so provide some extra specific config to do that ignoring.
let g:CommandTWildIgnore=&wildignore . ",*/deps,*/_build"

Make Command-T wildignore a multiline string for easier addition of patterns in the future

" ------------------------------------------------------------------------------
"  Command-T and related configuration
" ------------------------------------------------------------------------------
if &term =~ "xterm" || &term =~ "screen"
  " Ensure Escape key can close the match listing in Command-T
  let g:CommandTCancelMap = ['<ESC>', '<C-c>']
  " Ensure <C-j> and <C-k> can move up and down a list of file matches
  let g:CommandTSelectNextMap = ['<C-j>', '<ESC>OB']
  let g:CommandTSelectPrevMap = ['<C-k>', '<ESC>OA']
endif
" It seems that using Command T with mvim isn't quite working with regards
" to ignoring all files under a specific folder that I would expect,
" so provide some extra specific config to do that ignoring.
let g:CommandTWildIgnore=&wildignore . "
  \*/deps,
  \*/_build,
  \*/assets/node_modules
  \"


syntax enable
colorscheme base16-default
set background=dark

set showcmd
set showmode
set backspace=indent,eol,start
set hidden
set wildmenu
set wildmode=list:longest
set ignorecase
set smartcase
set nofoldenable
set number
set ruler
set cursorline
set cuc cul
set incsearch
set hlsearch
set wrap
set scrolloff=3
set title
set visualbell
set noswapfile
set nobackup
set nowritebackup
set history=1000
set undolevels=1000
set wildignore=*.swp,*.swo,*.bak,*.class,*.lock
set tabstop=2
set shiftwidth=2
set expandtab
set encoding=utf-8
set clipboard=unnamed
set spelllang=en

map <A-Tab> :tabnext<Enter>
nmap <S-T>o :NERDTree<Enter>
nmap <S-T>c :NERDTreeClose<Enter>
nmap <Tab> <C-w>w
nmap <S-k> gg
nmap <S-j> G
vmap > >gv
vmap < <gv

Disable cursorline to improve performance in big files.

syntax enable
colorscheme base16-default
set background=dark

set showcmd
set showmode
set backspace=indent,eol,start
set hidden
set wildmenu
set wildmode=list:longest
set ignorecase
set smartcase
set nofoldenable
set number
set ruler
set incsearch
set hlsearch
set wrap
set scrolloff=3
set title
set visualbell
set noswapfile
set nobackup
set nowritebackup
set history=1000
set undolevels=1000
set wildignore=*.swp,*.swo,*.bak,*.class,*.lock
set tabstop=2
set shiftwidth=2
set expandtab
set encoding=utf-8
set clipboard=unnamed
set spelllang=en

map <A-Tab> :tabnext<Enter>
nmap <S-T>o :NERDTree<Enter>
nmap <S-T>c :NERDTreeClose<Enter>
nmap <Tab> <C-w>w
nmap <S-k> gg
nmap <S-j> G
vmap > >gv
vmap < <gv


autocmd FileType clojure nnoremap <buffer> <localleader>fe :Eval<cr>
autocmd FileType clojure vnoremap <buffer> <localleader>fe :Eval<cr>
autocmd FileType clojure nnoremap <buffer> <localleader>fE :%Eval<cr>
autocmd FileType clojure nnoremap <buffer> <localleader>fr :Require<cr>
autocmd FileType clojure nnoremap <buffer> <localleader>fR :Require!<cr>
autocmd FileType clojure nnoremap <buffer> <localleader>ft :RunTests<cr>
autocmd FileType clojure nnoremap <buffer> <localleader>fl :Last<cr>
nnoremap <localleader>fc :FireplaceConnect<cr>

Add some fireplace definition jump bindings

autocmd FileType clojure nnoremap <buffer> <localleader>fe :Eval<cr>
autocmd FileType clojure vnoremap <buffer> <localleader>fe :Eval<cr>
autocmd FileType clojure nnoremap <buffer> <localleader>fE :%Eval<cr>
autocmd FileType clojure nnoremap <buffer> <localleader>fr :Require<cr>
autocmd FileType clojure nnoremap <buffer> <localleader>fR :Require!<cr>
autocmd FileType clojure nnoremap <buffer> <localleader>ft :RunTests<cr>
autocmd FileType clojure nnoremap <buffer> <localleader>fl :Last<cr>
autocmd FileType clojure nnoremap <buffer> <localleader>fd ]<c-d>
autocmd FileType clojure nnoremap <buffer> <localleader>fD ]d
nnoremap <localleader>fc :FireplaceConnect<cr>


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

Plug 'chriskempson/base16-vim'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'scrooloose/nerdtree'
Plug 'vim-scripts/gitignore'
Plug 'airblade/vim-gitgutter'
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'tpope/vim-fugitive'
Plug 'mattn/emmet-vim'
Plug 'gregsexton/MatchTag'

" Syntax
Plug 'othree/yajs.vim'
Plug 'othree/es.next.syntax.vim'
Plug 'othree/javascript-libraries-syntax.vim'
Plug 'othree/html5.vim'
Plug 'ap/vim-css-color'
Plug 'hail2u/vim-css3-syntax'
Plug 'cakebaker/scss-syntax.vim'

call plug#end()

Add EditorConfig plugin to Vim

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

Plug 'chriskempson/base16-vim'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'scrooloose/nerdtree'
Plug 'vim-scripts/gitignore'
Plug 'airblade/vim-gitgutter'
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'tpope/vim-fugitive'
Plug 'mattn/emmet-vim'
Plug 'gregsexton/MatchTag'
Plug 'editorconfig/editorconfig-vim'

" Syntax
Plug 'othree/yajs.vim'
Plug 'othree/es.next.syntax.vim'
Plug 'othree/javascript-libraries-syntax.vim'
Plug 'othree/html5.vim'
Plug 'ap/vim-css-color'
Plug 'hail2u/vim-css3-syntax'
Plug 'cakebaker/scss-syntax.vim'

call plug#end()


if count(g:plugin_groups, 'javascript')

  " Default to JSHint for now if both exist because ESLint's ES6 support is spotty.
  if executable('jsxhint')
    let g:syntastic_javascript_checkers = ['jsxhint']
  elseif executable('jshint')
    let g:syntastic_javascript_checkers = ['jshint']
  elseif executable('eslint')
    let g:syntastic_javascript_checkers = ['eslint']
  endif

  Bundle 'briancollins/vim-jst'
  Bundle 'elzr/vim-json'
  Bundle 'groenewege/vim-less'
  Bundle 'kchmck/vim-coffee-script'

  " JSX highlighting, indenting, and parsing (for React.js).
  " Depends on: pangloss/vim-javascript
  let g:jsx_ext_required = 0  " Enable JSX support in vanilla JS files.
  Bundle 'mxw/vim-jsx'

  Bundle "othree/javascript-libraries-syntax.vim"
  Bundle 'pangloss/vim-javascript'
endif

Use ESLint by default as the Syntastic JS checker, as it now has JSX and robust ES6 support.

if count(g:plugin_groups, 'javascript')

  if executable('eslint')
    let g:syntastic_javascript_checkers = ['eslint']
  elseif executable('jshint')
    let g:syntastic_javascript_checkers = ['jshint']
  endif

  Bundle 'briancollins/vim-jst'
  Bundle 'elzr/vim-json'
  Bundle 'groenewege/vim-less'
  Bundle 'kchmck/vim-coffee-script'

  " JSX highlighting, indenting, and parsing (for React.js).
  " Depends on: pangloss/vim-javascript
  let g:jsx_ext_required = 0  " Enable JSX support in vanilla JS files.
  Bundle 'mxw/vim-jsx'

  Bundle "othree/javascript-libraries-syntax.vim"
  Bundle 'pangloss/vim-javascript'
endif


""" PHP

" Linting
let b:ale_fixers = ['phpcbf']
let b:ale_linters = ['php', 'phpcs']

Disable ALE Linters for all PHP files

""" PHP

" Linting
" let b:ale_fixers = ['phpcbf']
" let b:ale_linters = ['php', 'phpcs']


function s:lazyload(plugin, file_types)
  execute "autocmd FileType " . a:file_types . " packadd " . a:plugin
endfunction

call s:lazyload("LanguageClient", "python,ruby,rust")
call s:lazyload("bundler", "ruby")
call s:lazyload("ensime", "java,scala")
call s:lazyload("fireplace", "clojure")
call s:lazyload("intero-neovim", "haskell")
call s:lazyload("jedi", "python")
call s:lazyload("parinfer", "clojure,lisp,racket")
call s:lazyload("racer", "rust")
call s:lazyload("rake", "ruby")
call s:lazyload("textobj-rubyblock", "ruby")

Remove lazy load for removed package

function s:lazyload(plugin, file_types)
  execute "autocmd FileType " . a:file_types . " packadd " . a:plugin
endfunction

call s:lazyload("bundler", "ruby")
call s:lazyload("ensime", "java,scala")
call s:lazyload("fireplace", "clojure")
call s:lazyload("intero-neovim", "haskell")
call s:lazyload("jedi", "python")
call s:lazyload("parinfer", "clojure,lisp,racket")
call s:lazyload("racer", "rust")
call s:lazyload("rake", "ruby")
call s:lazyload("textobj-rubyblock", "ruby")


" tab
set expandtab
set tabstop=4
set shiftwidth=4
set softtabstop=4
set smarttab

autocmd BufNewFile,BufRead,BufReadPre *.coffee set filetype=coffee

augroup fileTypeIndent
    autocmd!
    autocmd BufNewFile,BufRead *.html setlocal tabstop=2 shiftwidth=2 softtabstop=2
    autocmd BufNewFile,BufRead *.coffee setlocal tabstop=2 shiftwidth=2 softtabstop=2
    autocmd BufNewFile,BufRead *.rkt setlocal tabstop=2 shiftwidth=2 softtabstop=2
    autocmd BufNewFile,BufRead *.py setlocal tabstop=2 shiftwidth=2 softtabstop=2
    autocmd BufNewFile,BufRead *.js setlocal tabstop=2 shiftwidth=2 softtabstop=2
augroup END

" appearance
set showmatch
set list
set listchars=tab:>.,trail:_,eol:↲,extends:>,precedes:<,nbsp:%

augroup fileTypeListChars
    autocmd!
    autocmd BufNewFile,BufRead *.go setlocal nolist
augroup END

" control
set backspace=start,eol,indent
set whichwrap=b,s,[,],,~
source $VIMRUNTIME/macros/matchit.vim

" spell check
set spell
set spelllang=en,cjk

" for tex
let g:tex_conceal = ''

Set conceallevel to 0 in vim

" tab
set expandtab
set tabstop=4
set shiftwidth=4
set softtabstop=4
set smarttab

autocmd BufNewFile,BufRead,BufReadPre *.coffee set filetype=coffee

augroup fileTypeIndent
    autocmd!
    autocmd BufNewFile,BufRead *.html setlocal tabstop=2 shiftwidth=2 softtabstop=2
    autocmd BufNewFile,BufRead *.coffee setlocal tabstop=2 shiftwidth=2 softtabstop=2
    autocmd BufNewFile,BufRead *.rkt setlocal tabstop=2 shiftwidth=2 softtabstop=2
    autocmd BufNewFile,BufRead *.py setlocal tabstop=2 shiftwidth=2 softtabstop=2
    autocmd BufNewFile,BufRead *.js setlocal tabstop=2 shiftwidth=2 softtabstop=2
augroup END

" appearance
set showmatch
set list
set listchars=tab:>.,trail:_,eol:↲,extends:>,precedes:<,nbsp:%

augroup fileTypeListChars
    autocmd!
    autocmd BufNewFile,BufRead *.go setlocal nolist
augroup END

" control
set backspace=start,eol,indent
set whichwrap=b,s,[,],,~
source $VIMRUNTIME/macros/matchit.vim

" spell check
set spell
set spelllang=en,cjk

" conceal
set conceallevel=0


" Disable YouCompleteMe when using vim-multiple-cursors
"
function! Multiple_cursors_before()
    if exists('*youcompleteme#EnableCursorMovedAutocommands')
        call youcompleteme#DisableCursorMovedAutocommands()
    endif
endfunction

function! Multiple_cursors_after()
    if exists('*youcompleteme#EnableCursorMovedAutocommands')
        call youcompleteme#EnableCursorMovedAutocommands()
    endif
endfunction

Disable deoplete while using multiple cursors

" Disable YouCompleteMe when using vim-multiple-cursors
"
function! Multiple_cursors_before()
    let b:deoplete_disable_auto_complete = 1
endfunction

function! Multiple_cursors_after()
    let b:deoplete_disable_auto_complete = 0
endfunction


setlocal textwidth=72
setlocal nofoldenable
setlocal spell

Add mapping to status page of vim-fugitive.

setlocal textwidth=72
setlocal nofoldenable
setlocal spell

noremap <silent> cx :<c-u>Gcommit -S<cr>


set nocompatible
set runtimepath+=~/.config/dotfiles/vim
set packpath+=~/.config/dotfiles/vim
autocmd!

Prepend to runtimepath/packpath instead of appending

set nocompatible
set runtimepath^=~/.config/dotfiles/vim
set packpath^=~/.config/dotfiles/vim
autocmd!


augroup CB2Abbreviations
  au!
  au User AfterBundles Abolish absense absence
  au User AfterBundles Abolish adddress address
  au User AfterBundles Abolish adress address
  au User AfterBundles Abolish asesment assessment
  au User AfterBundles Abolish asessment assessment
  au User AfterBundles Abolish assesment assessment
  au User AfterBundles Abolish dentifer identifier
  au User AfterBundles Abolish eligibilty eligibility
  au User AfterBundles Abolish eligiblity eligibility
  au User AfterBundles Abolish famly family
  au User AfterBundles Abolish referal referral
  au User AfterBundles Abolish residental residential
  au User AfterBundles Abolish resouce resource
  au User AfterBundles Abolish specifed specified
  au User AfterBundles Abolish unkown unknown

  au User BufEnterRails Rabbrev E:: Eligibility
augroup END

Add abbreviation RL:: => RemovalLocation

augroup CB2Abbreviations
  au!
  au User AfterBundles Abolish absense absence
  au User AfterBundles Abolish adddress address
  au User AfterBundles Abolish adress address
  au User AfterBundles Abolish asesment assessment
  au User AfterBundles Abolish asessment assessment
  au User AfterBundles Abolish assesment assessment
  au User AfterBundles Abolish dentifer identifier
  au User AfterBundles Abolish eligibilty eligibility
  au User AfterBundles Abolish eligiblity eligibility
  au User AfterBundles Abolish famly family
  au User AfterBundles Abolish referal referral
  au User AfterBundles Abolish residental residential
  au User AfterBundles Abolish resouce resource
  au User AfterBundles Abolish specifed specified
  au User AfterBundles Abolish unkown unknown

  au User BufEnterRails Rabbrev E:: Eligibility
  au User BufEnterRails Rabbrev RL:: RemovalLocation
augroup END


map <F2> :e %:p:s,.hh$,.X123X,:s,.cc$,.hh,:s,.X123X$,.cc,<CR>

" For work
" Disable textwidth otherwise using clang-format with formatexpr breaks insert
" mode
set textwidth=0
set colorcolumn=120

map <F5> /\%>120v.\+<CR>

" for actual C (not C++) programming where comments have explicit end
" characters, if starting a new line in the middle of a comment automatically
" insert the comment leader characters:
set formatoptions+=ro

Remove outdated C++ overrides in VIM

" Swap between header/impl
map <F2> :e %:p:s,.hh$,.X123X,:s,.cc$,.hh,:s,.X123X$,.cc,<CR>

" for actual C (not C++) programming where comments have explicit end
" characters, if starting a new line in the middle of a comment automatically
" insert the comment leader characters:
set formatoptions+=ro


" tab
set expandtab
set tabstop=4
set shiftwidth=4
set softtabstop=4
set smarttab

au BufRead,BufNewFile,BufReadPre *.coffee set filetype=coffee

augroup fileTypeIndent
    autocmd!
    autocmd BufNewFile,BufRead *.html setlocal tabstop=2 shiftwidth=2 softtabstop=2
    autocmd BufNewFile,BufRead *.coffee setlocal tabstop=2 shiftwidth=2 softtabstop=2
    autocmd BufNewFile,BufRead *.rkt setlocal tabstop=2 shiftwidth=2 softtabstop=2
    autocmd BufNewFile,BufRead *.py setlocal tabstop=2 shiftwidth=2 softtabstop=2
    autocmd BufNewFile,BufRead *.js setlocal tabstop=2 shiftwidth=2 softtabstop=2
augroup END

" appearance
set showmatch
set list
set listchars=tab:>.,trail:_,eol:↲,extends:>,precedes:<,nbsp:%

" control
set backspace=start,eol,indent
set whichwrap=b,s,[,],,~
source $VIMRUNTIME/macros/matchit.vim

" spell check
set spell
set spelllang=en,cjk

" for tex
let g:tex_conceal = ''

Hide list chars when editing go file

" tab
set expandtab
set tabstop=4
set shiftwidth=4
set softtabstop=4
set smarttab

au BufRead,BufNewFile,BufReadPre *.coffee set filetype=coffee

augroup fileTypeIndent
    autocmd!
    autocmd BufNewFile,BufRead *.html setlocal tabstop=2 shiftwidth=2 softtabstop=2
    autocmd BufNewFile,BufRead *.coffee setlocal tabstop=2 shiftwidth=2 softtabstop=2
    autocmd BufNewFile,BufRead *.rkt setlocal tabstop=2 shiftwidth=2 softtabstop=2
    autocmd BufNewFile,BufRead *.py setlocal tabstop=2 shiftwidth=2 softtabstop=2
    autocmd BufNewFile,BufRead *.js setlocal tabstop=2 shiftwidth=2 softtabstop=2
augroup END

" appearance
set showmatch
set list
set listchars=tab:>.,trail:_,eol:↲,extends:>,precedes:<,nbsp:%

augroup fileTypeListChars
    autocmd!
    autocmd BufNewFile,BufRead *.go setlocal nolist
augroup END

" control
set backspace=start,eol,indent
set whichwrap=b,s,[,],,~
source $VIMRUNTIME/macros/matchit.vim

" spell check
set spell
set spelllang=en,cjk

" for tex
let g:tex_conceal = ''


" Markdown syntax highlighting
  augroup mkd
    autocmd BufRead *.mkd  set ai formatoptions=tcroqn2 comments=n:>
    autocmd BufRead *.md  set ai formatoptions=tcroqn2 comments=n:>
    autocmd BufRead *.markdown  set ai formatoptions=tcroqn2 comments=n:>
  augroup END

" Allow old-school vim directory exploring
let NERDTreeHijackNetrw = 0

" Add some alignment patterns for :Tabular
AddTabularPattern!  symbols         / :/l0
AddTabularPattern!  hash            /=>/
AddTabularPattern!  chunks          / \S\+/l0

Fix tabular mappings so they occur after plugins have loaded

" Markdown syntax highlighting
  augroup mkd
    autocmd BufRead *.mkd  set ai formatoptions=tcroqn2 comments=n:>
    autocmd BufRead *.md  set ai formatoptions=tcroqn2 comments=n:>
    autocmd BufRead *.markdown  set ai formatoptions=tcroqn2 comments=n:>
  augroup END

" Allow old-school vim directory exploring
let NERDTreeHijackNetrw = 0

" Add some alignment patterns for :Tabular
function! CustomTabularPatterns()
  AddTabularPattern!  symbols         / :/l0
  AddTabularPattern!  hash            /=>/
  AddTabularPattern!  chunks          / \S\+/l0
endfunction
autocmd VimEnter * call CustomTabularPatterns()


set mouse=a
set title

Add defaults for cursor shapes

set mouse=a
set title

autocmd VimEnter,ColorScheme * :highlight default VimrDefaultCursor gui=reverse guibg=NONE guifg=NONE
set guicursor=a:block-VimrDefaultCursor
autocmd VimEnter,ColorScheme * :highlight default VimrInsertCursor guibg=fg
set guicursor=i:ver25-VimrInsertCursor


" Open a module (in sys.path) in a new window (like CTRL-M in IDLE)
" Place this somewhere in your .vimrc

func OpenModule(name)
python << EOF
import vim
name = vim.eval("a:name")
try:
    module = __import__(name)
    filename = getattr(module, "__file__", None)
    if filename:
        import re
        filename = re.sub(".py[co]", ".py", filename)
        vim.command("e %s" % filename)
    else:
        print "error: can't find module `%s` source" % name
except ImportError:
    print "error: can't find `%s` module" % name
EOF
endfunc
comm! -nargs=1 OM call OpenModule(<f-args>)

Add current directory to sys.path

" Open a module (in sys.path) in a new window (like CTRL-M in IDLE)
" Place this somewhere in your .vimrc

func OpenModule(name)
python << EOF
import os, sys
sys.path.append(os.getcwd())
import vim
name = vim.eval("a:name")
try:
    module = __import__(name)
    filename = getattr(module, "__file__", None)
    if filename:
        import re
        filename = re.sub(".py[co]", ".py", filename)
        vim.command("e %s" % filename)
    else:
        print "error: can't find module `%s` source" % name
except ImportError:
    print "error: can't find `%s` module" % name
EOF
endfunc
comm! -nargs=1 OM call OpenModule(<f-args>)


set shiftwidth=8
set softtabstop=8
set noexpandtab
set nolist

map <C-UP> :GoDef<CR>
nmap <Leader>d <Plug>(go-doc-vertical)
nmap <Leader>i :GoImports<CR>
nmap <Leader>l :GoMetaLinter<CR>
nmap <Leader>r :GoRename<CR>

"vimgrep word under cursor
nnoremap <Leader>g yiw:vimgrep /<C-r>"/g **/*.go

Enable syntax highlighting for Go

set shiftwidth=8
set softtabstop=8
set noexpandtab
set nolist

map <C-UP> :GoDef<CR>
nmap <Leader>d <Plug>(go-doc-vertical)
nmap <Leader>i :GoImports<CR>
nmap <Leader>l :GoMetaLinter<CR>
nmap <Leader>r :GoRename<CR>

"vimgrep word under cursor
nnoremap <Leader>g yiw:vimgrep /<C-r>"/g **/*.go

let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_structs = 1
let g:go_highlight_interfaces = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1


if exists(":Tabularize")
  nmap <Leader>a= :Tabularize /=<CR>
  vmap <Leader>a= :Tabularize /=<CR>
  nmap <Leader>a: :Tabularize /:\zs<CR>
  vmap <Leader>a: :Tabularize /:\zs<CR>
endif

Fix Tabularize mappings not working


" Set right mouse button action.
set mousemodel=popup_setpos

" Hide most gui elements.
set guioptions-=m " remove menu bar
set guioptions-=T " remove toolbar
set guioptions-=r " remove right-hand scroll bar
set guioptions-=L " remove left-hand scroll bar

Set focus to follow mouse.

" Set right mouse button action.
set mousemodel=popup_setpos

" Set focus to follow mouse.
set mousefocus

" Hide most gui elements.
set guioptions-=m " remove menu bar
set guioptions-=T " remove toolbar
set guioptions-=r " remove right-hand scroll bar
set guioptions-=L " remove left-hand scroll bar


" Often useful for picking out the this pointer and parameters.
function! vshelp#guess_correct_pointer()
	%smagic/\v(.\u{-}.=.\x+) /\1\r/g
	" Heap pointers on my platform start with the same bitpattern, so they're
	" easy to identify.
	v/07FF/d
	%sort /=/u
endf

function! vshelp#OpenInVisualStudio()
	let pos = getcurpos()
	let line = pos[1]
	let column = pos[2]
	let filename = fnameescape(vshelp#path#expand_as_unix_path('%:p'))
    python << EOP
try:
    import vshelp
    vshelp.vim_open_in_visualstudio()
except ImportError as err:
    print("ERROR: "+ str(err) +"\n"
    + """vshelp will fail to import when pywintypes fails to import.
Try removing pywin32 and pypiwin32 and then installing pypiwin32 again.
""")
EOP
endfunction

Use pythonx to match python script location

" Often useful for picking out the this pointer and parameters.
function! vshelp#guess_correct_pointer()
	%smagic/\v(.\u{-}.=.\x+) /\1\r/g
	" Heap pointers on my platform start with the same bitpattern, so they're
	" easy to identify.
	v/07FF/d
	%sort /=/u
endf

function! vshelp#OpenInVisualStudio()
	let pos = getcurpos()
	let line = pos[1]
	let column = pos[2]
	let filename = fnameescape(vshelp#path#expand_as_unix_path('%:p'))
    pythonx << EOP
try:
    import vshelp
    vshelp.vim_open_in_visualstudio()
except ImportError as err:
    print("ERROR: "+ str(err) +"\n"
    + """vshelp will fail to import when pywintypes fails to import.
Try removing pywin32 and pypiwin32 and then installing pypiwin32 again.
""")
EOP
endfunction


" abbreviations
iab fis for (int i = 0; i < .size(); ++i) {<CR>}<ESC>-f.i
iab ato atoi(.c_str())<ESC>F.i
iab vs vector<string>
iab AC accumulate(.begin(), .end(), 0);<ESC>2F.i

" make commands
map! <F5> <ESC>:wa!<cr>:make run<cr>
map! <F6> <ESC>:wa!<cr>:make test<cr>
map! <F6> <ESC>:wa!<cr>:make<cr>

Add VimCoder mapping in insert mode

" abbreviations
iab fis for (int i = 0; i < .size(); ++i) {<CR>}<ESC>-f.i
iab ato atoi(.c_str())<ESC>F.i
iab vs vector<string>
iab AC accumulate(.begin(), .end(), 0);<ESC>2F.i

" make commands
map <F5> <ESC>:wa!<cr>:make run<cr>
map <F6> <ESC>:wa!<cr>:make test<cr>
map <F7> <ESC>:wa!<cr>:make<cr>
map! <F5> <ESC>:wa!<cr>:make run<cr>
map! <F6> <ESC>:wa!<cr>:make test<cr>
map! <F7> <ESC>:wa!<cr>:make<cr>


set cursorline      " highlight currently focused line
set relativenumber  " show line numbers relative to cursor
set novisualbell    " don't flash the screen
set laststatus=2    " always show status line
set wildignore+=*.o,*.obj,.git,*.rbc,*.class,.svn,vendor/gems/*
set wildmenu        " tab-completion menu for command mode
set wildmode=list:longest,full
set list            " display otherwise invisible characters
set listchars=tab:\\_,extends:>,precedes:<,nbsp:%
set noshowmode
set lazyredraw      " don't redraw screen while macros are executing

Update symbols used to show non-printable characters.

set cursorline      " highlight currently focused line
set relativenumber  " show line numbers relative to cursor
set novisualbell    " don't flash the screen
set laststatus=2    " always show status line
set wildignore+=*.o,*.obj,.git,*.rbc,*.class,.svn,vendor/gems/*
set wildmenu        " tab-completion menu for command mode
set wildmode=list:longest,full
set list            " display otherwise invisible characters
set listchars=tab:▸\ ,extends:❯,precedes:❮,nbsp:␣
set showbreak=↪
set noshowmode
set lazyredraw      " don't redraw screen while macros are executing


if !exists("g:loaded_nvim_treesitter")
  finish
endif

lua <<EOF
require('nvim-treesitter.configs').setup{
  ensure_installed = {
    "bash",
    "dockerfile",
    "go",
    "ruby",
    "yaml",
    "json",
    "toml",
  }, -- this is available in the list of official parsers
  ignore_install = {}, -- list of parsers to ignore installing
  highlight = {
    enable = true
  },
  incremental_selection = {
    enable = true
  },
  textobjects = {
    enable = true
  },
}
EOF

Fix endwise working when treesitter is enabled

if !exists("g:loaded_nvim_treesitter")
  finish
endif

lua <<EOF
require('nvim-treesitter.configs').setup{
  ensure_installed = {
    "bash",
    "dockerfile",
    "go",
    "ruby",
    "yaml",
    "json",
    "toml",
  }, -- this is available in the list of official parsers
  ignore_install = {}, -- list of parsers to ignore installing
  highlight = {
    enable = true,
    additional_vim_regex_highlighting = true,
  },
  incremental_selection = {
    enable = true
  },
  textobjects = {
    enable = true
  },
}
EOF


" Synchronize jedi-vim with pyenv.
if jedi#init_python()
  function! s:jedi_auto_force_py_version() abort
    let major_version = pyenv#python#get_internal_major_version()
    call jedi#force_py_version(major_version)
  endfunction
  augroup vim-pyenv-jedi
    autocmd!
    autocmd User vim-pyenv-activate-post call s:jedi_auto_force_py_version()
    autocmd User vim-pyenv-deactivate-post call s:jedi_auto_force_py_version()
  augroup END
endif

Add TODO since pyenv does not sync jedi version

" Synchronize jedi-vim with pyenv.
" TODO This does not actually work anymore.
if jedi#init_python()
  function! s:jedi_auto_force_py_version() abort
    let major_version = pyenv#python#get_internal_major_version()
    call jedi#force_py_version(major_version)
  endfunction
  augroup vim-pyenv-jedi
    autocmd!
    autocmd User vim-pyenv-activate-post call s:jedi_auto_force_py_version()
    autocmd User vim-pyenv-deactivate-post call s:jedi_auto_force_py_version()
  augroup END
endif


augroup filetypedetect
    au BufRead,BufNewFile *.tmux set filetype=tmux
    au BufRead,BufNewFile *.ssh set filetype=sshconfig
    au BufRead,BufNewFile *.git set filetype=gitconfig
augroup END

Mark .cron as crontab files

augroup filetypedetect
    au BufRead,BufNewFile *.tmux set filetype=tmux
    au BufRead,BufNewFile *.ssh set filetype=sshconfig
    au BufRead,BufNewFile *.git set filetype=gitconfig
    au BufRead,BufNewFile *.cron set filetype=crontab
augroup END


" ============================================================================
" File:         AutoSave.vim
" Last Changed: 2012-11-12
" ============================================================================

let s:save_cpo = &cpo
set cpo&vim

let g:auto_save=0

set updatetime=330
au CursorHold,InsertLeave * call AutoSave()
command! AutoSaveToggle :call ToggleAutoSave()
nmap \ast :AutoSaveToggle<CR>

function! AutoSave()
  if g:auto_save >= 1
    silent! wa
  endif
endfunction

function! ToggleAutoSave()
  if g:auto_save >= 1
    let g:auto_save = 0
    echo "AutoSave is OFF"
  else
    let g:auto_save = 1
    echo "AutoSave is ON"
  endif
endfunction

let &cpo = s:save_cpo

Use implicit Leader key mapping

" ============================================================================
" File:         AutoSave.vim
" Last Changed: 2012-11-12
" ============================================================================

let s:save_cpo = &cpo
set cpo&vim

let g:auto_save=0

set updatetime=200
au CursorHold,InsertLeave * call AutoSave()
command! AutoSaveToggle :call ToggleAutoSave()
nmap <Leader>ast :AutoSaveToggle<CR>

function! AutoSave()
  if g:auto_save >= 1
    silent! wa
  endif
endfunction

function! ToggleAutoSave()
  if g:auto_save >= 1
    let g:auto_save = 0
    echo "AutoSave is OFF"
  else
    let g:auto_save = 1
    echo "AutoSave is ON"
  endif
endfunction

let &cpo = s:save_cpo


let b:ale_linters = ['golangci-lint']
let b:ale_fixers = ['goimports']
setlocal noexpandtab

"autocmd BufWritePre *.go :call LanguageClient#textDocument_formatting_sync()

nnoremap <silent> <leader>t :e %:h/%:t:r_test.%:e<cr>
nnoremap <silent> <leader>T :e %:s?_test??<cr>

" Snippets
iabbrev xtable tests := []struct{<cr>msg string<cr>wantErr string<cr>}{<cr>{<cr>msg: "ok",<cr>wantErr: "",<cr>},<cr>{<cr>msg: "err",<cr>wantErr: "foo",<cr>},<cr>}<cr><cr>for _, tt := range tests {<cr>t.Run(tt.msg, func(t *testing.T) {<cr>TODO<cr>})<cr>}
iabbrev xtest func TestTODO(t *testing.T) {<cr>TODO<cr>}<cr>
iabbrev example func TestTODO(t *testing.T) {<cr>}<cr>
iabbrev xterr if tt.wantErr != "" {<cr>assert.Error(t, err)<cr>assert.EqualError(t, err, tt.wantErr)<cr>return<cr>}<cr>assert.NoError(t, err)
iabbrev xerr if err != nil {<cr>return err<cr>}
iabbrev xforv for i := range
iabbrev xforp for _, i := range

Change the table test snippet to conform to static analysis better

let b:ale_linters = ['golangci-lint']
let b:ale_fixers = ['goimports']
setlocal noexpandtab

"autocmd BufWritePre *.go :call LanguageClient#textDocument_formatting_sync()

nnoremap <silent> <leader>t :e %:h/%:t:r_test.%:e<cr>
nnoremap <silent> <leader>T :e %:s?_test??<cr>

" Snippets
iabbrev xtable tests := []struct{<cr>msg string<cr>wantErr string<cr>}{<cr>{<cr>msg: "ok",<cr>wantErr: "",<cr>},<cr>}<cr><cr>for i := range tests {<cr>tt := tests[i]<cr>t.Run(tt.msg, func(t *testing.T) {<cr>TODO<cr>})<cr>}
iabbrev xtest func TestTODO(t *testing.T) {<cr>TODO<cr>}<cr>
iabbrev example func TestTODO(t *testing.T) {<cr>}<cr>
iabbrev xterr if tt.wantErr != "" {<cr>assert.Error(t, err)<cr>assert.EqualError(t, err, tt.wantErr)<cr>return<cr>}<cr>assert.NoError(t, err)
iabbrev xerr if err != nil {<cr>return err<cr>}
iabbrev xforv for i := range
iabbrev xforp for _, i := range


function! sj#php#SplitArray()
  let arraypattern = '\(array\)\s*(\(.*\))'
  let line         = getline('.')

  if line !~? arraypattern
    return 0
  else
    let [from, to] = sj#LocateBracesOnLine('(', ')')

    if from < 0 && to < 0
      return 0
    else
      let pairs = sj#ParseJsonObjectBody(from + 1, to - 1)
      let body  = "(\n".join(pairs, ",\n")."\n)"
      call sj#ReplaceMotion('Va(', body)

      let body_start = line('.') + 1
      let body_end   = body_start + len(pairs)

      call sj#PushCursor()
      exe "normal! jV".(body_end - body_start)."j2="
      call sj#PopCursor()
    endif

    return 1
  endif
endfunction

function! sj#php#JoinArray()
  normal! $

  let body = sj#GetMotion('Vi(',)
  if g:splitjoin_normalize_whitespace
    let body = substitute(body, '\s*=>\s*', ' => ', 'g')
  endif
  let body = join(sj#TrimList(split(body, "\n")), ' ')
  call sj#ReplaceMotion('Va(', '('.body.')')

  return 1
endfunction

Align by => if option is set

function! sj#php#SplitArray()
  let arraypattern = '\(array\)\s*(\(.*\))'
  let line         = getline('.')

  if line !~? arraypattern
    return 0
  else
    let [from, to] = sj#LocateBracesOnLine('(', ')')

    if from < 0 && to < 0
      return 0
    else
      let pairs = sj#ParseJsonObjectBody(from + 1, to - 1)
      let body  = "(\n".join(pairs, ",\n")."\n)"
      call sj#ReplaceMotion('Va(', body)

      let body_start = line('.') + 1
      let body_end   = body_start + len(pairs)

      call sj#PushCursor()
      exe "normal! jV".(body_end - body_start)."j2="
      call sj#PopCursor()

      if g:splitjoin_align
        call sj#Align(body_start, body_end, 'ruby_hash')
      endif
    endif

    return 1
  endif
endfunction

function! sj#php#JoinArray()
  normal! $

  let body = sj#GetMotion('Vi(',)
  if g:splitjoin_normalize_whitespace
    let body = substitute(body, '\s*=>\s*', ' => ', 'g')
  endif
  let body = join(sj#TrimList(split(body, "\n")), ' ')
  call sj#ReplaceMotion('Va(', '('.body.')')

  return 1
endfunction


" the Requirements File Format syntax support for Vim
" Version: 1.4.2
" Author:  raimon <raimon49@hotmail.com>
" License: MIT LICENSE

if exists("b:current_syntax") && b:current_syntax == "requirements"
    finish
endif

syn case match

syn region requirementsComment start="[ \t]*#" end="$"
syn match requirementsCommandOption "\v^\[?--?[a-zA-Z\-]*\]?"
syn match requirementsVersionSpecifiers "\v(\=\=\=?|\<\=?|\>\=?|\~\=|\!\=)"
syn match requirementsPackageName "\v^[a-zA-Z][a-zA-Z\-_\.0-9]*"
syn match requirementsVersionControls "\v(git\+?|hg\+|svn\+|bzr\+)\S+"

hi link requirementsComment Comment
hi link requirementsCommandOption Special
hi link requirementsVersionSpecifiers Boolean
hi link requirementsPackageName Identifier
hi link requirementsVersionControls Identifier

let b:current_syntax = "requirements"

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

Update pattern of package name

" the Requirements File Format syntax support for Vim
" Version: 1.4.2
" Author:  raimon <raimon49@hotmail.com>
" License: MIT LICENSE

if exists("b:current_syntax") && b:current_syntax == "requirements"
    finish
endif

syn case match

syn region requirementsComment start="[ \t]*#" end="$"
syn match requirementsCommandOption "\v^\[?--?[a-zA-Z\-]*\]?"
syn match requirementsVersionSpecifiers "\v(\=\=\=?|\<\=?|\>\=?|\~\=|\!\=)"
syn match requirementsPackageName "\v^([a-zA-Z0-9][a-zA-Z0-9\-_\.]*[a-zA-Z0-9])"
syn match requirementsVersionControls "\v(git\+?|hg\+|svn\+|bzr\+)\S+"

hi link requirementsComment Comment
hi link requirementsCommandOption Special
hi link requirementsVersionSpecifiers Boolean
hi link requirementsPackageName Identifier
hi link requirementsVersionControls Identifier

let b:current_syntax = "requirements"

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


"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 typo in exec command.

"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


let g:phpcomplete_parse_docblock_comments = 1

Add comment explaining how to generate tags file

" Generate tags with patched ctags from
" https://github.com/shawncplus/phpcomplete.vim/wiki/Patched-ctags
" like this:
" ctags -R --fields=+aimS --languages=php
let g:phpcomplete_parse_docblock_comments = 1


" Run Neomake on write.
augroup neomake-run
  autocmd!
  autocmd BufWritePost * Neomake
augroup END

Set Neomake makers for javascript dynamically

" Run Neomake on write.
augroup neomake-run
  autocmd!
  autocmd BufWritePost * Neomake
augroup END

function! s:local_javascript_makers()
  let l:makers = []

  if executable('jshint') && !executable('eslint')
    call add(l:makers, 'jshint')
  endif

  if executable('eslint') && !executable('standard')
    call add(l:makers, 'eslint')
  endif

  if executable('standard')
    call add(l:makers, 'standard')
  endif

  if executable('flow') && filereadable(findfile('.flowconfig', '.;'))
    call add(l:makers, 'flow')
  endif

  return l:makers
endfunction

" Set enabled node makers.
augroup neomake-makers-node
  autocmd!
  autocmd FileType javascript
    \ let b:neomake_javascript_enabled_makers = s:local_javascript_makers()
  autocmd FileType javascript.jsx
    \ let b:neomake_jsx_enabled_makers = s:local_javascript_makers()
augroup END


"
" Configuration options specific to third-party plugins
"

""""""""""""""""""""""""""""""
" => CTRL-P
""""""""""""""""""""""""""""""
let g:ctrlp_working_path_mode = 0

let g:ctrlp_map = '<c-f>'
map <c-b> :CtrlPBuffer<cr>

let g:ctrlp_max_height = 20
let g:ctrlp_custom_ignore = 'node_modules\|^\.DS_Store\|^\.git\|^\.coffee'

Set better vim keyboard shortcuts for CtrlP

"
" Configuration options specific to third-party plugins
"

""""""""""""""""""""""""""""""
" => CTRL-P
""""""""""""""""""""""""""""""
let g:ctrlp_working_path_mode = 0

let g:ctrlp_map = '<c-f>'
map <c-b> :CtrlPBuffer<cr>

let g:ctrlp_max_height = 20
let g:ctrlp_custom_ignore = 'node_modules\|^\.DS_Store\|^\.git\|^\.coffee'

map <leader>t :CtrlP<CR>
map <leader>o :CtrlPBuffer<CR>
map <leader>r :CtrlPMRU<CR>
map <leader>m :CtrlPMixed<CR>


" abbreviations
iab fis for (int i = 0; i < .size(); ++i) {<CR>}<ESC>-f.i
iab ato atoi(.c_str())<ESC>F.i
iab vs vector<string>
iab vi vector<int>
iab vll vector<long long>
iab ll long long
iab vb vector<bool>
iab AC accumulate(.begin(), .end(), 0);<ESC>2F.i

" make commands
map <F5> <ESC>:wa!<cr>:make run<cr>
map <F6> <ESC>:wa!<cr>:make test<cr>
map <F7> <ESC>:wa!<cr>:make<cr>
map <F3> <ESC>:wa!<cr>:vs Makefile<cr>/CXXFLAGS<cr>A -std=c++11<ESC>ZZ
map! <F5> <ESC>:wa!<cr>:make run<cr>
map! <F6> <ESC>:wa!<cr>:make test<cr>
map! <F7> <ESC>:wa!<cr>:make<cr>
map! <F3> <ESC>:wa!<cr>:vs Makefile<cr>/CXXFLAGS<cr>A -std=c++11<ESC>ZZ

Create Vim shortcut for "-std=c++0x" in Makefile

" abbreviations
iab fis for (int i = 0; i < .size(); ++i) {<CR>}<ESC>-f.i
iab ato atoi(.c_str())<ESC>F.i
iab vs vector<string>
iab vi vector<int>
iab vll vector<long long>
iab ll long long
iab vb vector<bool>
iab AC accumulate(.begin(), .end(), 0);<ESC>2F.i

" make commands
map <F3> <ESC>:wa!<cr>:vs Makefile<cr>/CXXFLAGS<cr>A -std=c++11<ESC>ZZ
map! <F3> <ESC>:wa!<cr>:vs Makefile<cr>/CXXFLAGS<cr>A -std=c++11<ESC>ZZ
map <F4> <ESC>:wa!<cr>:vs Makefile<cr>/CXXFLAGS<cr>A -std=c++0x<ESC>ZZ
map! <F4> <ESC>:wa!<cr>:vs Makefile<cr>/CXXFLAGS<cr>A -std=c++0x<ESC>ZZ
map <F5> <ESC>:wa!<cr>:make run<cr>
map! <F5> <ESC>:wa!<cr>:make run<cr>
map <F6> <ESC>:wa!<cr>:make test<cr>
map! <F6> <ESC>:wa!<cr>:make test<cr>
map <F7> <ESC>:wa!<cr>:make<cr>
map! <F7> <ESC>:wa!<cr>:make<cr>


" specify 2-space indent for Ruby files
setlocal expandtab
setlocal tabstop=2 shiftwidth=2 softtabstop=2

" highlight ruby whitespace errors
let ruby_space_errors = 1
let g:rubycomplete_buffer_loading = 1
let g:rubycomplete_classes_in_global = 1

" set the 'foldmethod' option to 'syntax' and allow folding of
" classes, modules, methods, code blocks, heredocs and comments.
let ruby_fold = 1

" Use v or # to get a variable interpolation (inside of a string)}
" ysiw#   Wrap the token under the cursor in #{}
" v...s#  Wrap the selection in #{}
let b:surround_118 = "#{ \r }"    " v
let b:surround_35  = "#{ \r }"    " #

" Select text in an ERb file with visual mode and then press s- or s=
" Or yss- to do entire line.
let b:surround_45 = "<% \r -%>"   " -
let b:surround_61 = "<%= \r %>"   " =

" Activate Ruby.vim's tooltips for Ruby keywords
setlocal ballooneval

" The compiler plugins contain instructions which allow Vim to run the
" specified source file with an appropriate executable, parse any errors, and
" jump to the corresponding error location if required.
compiler ruby

Add keymapping for Gary Bernhardt's hashrocket

" specify 2-space indent for Ruby files
setlocal expandtab
setlocal tabstop=2 shiftwidth=2 softtabstop=2

" highlight ruby whitespace errors
let ruby_space_errors = 1
let g:rubycomplete_buffer_loading = 1
let g:rubycomplete_classes_in_global = 1

" set the 'foldmethod' option to 'syntax' and allow folding of
" classes, modules, methods, code blocks, heredocs and comments.
let ruby_fold = 1

" Gary Bernhardt's hashrocket
imap <c-l> <space>=><space>

" Use v or # to get a variable interpolation (inside of a string)}
" ysiw#   Wrap the token under the cursor in #{}
" v...s#  Wrap the selection in #{}
let b:surround_118 = "#{ \r }"    " v
let b:surround_35  = "#{ \r }"    " #

" Select text in an ERb file with visual mode and then press s- or s=
" Or yss- to do entire line.
let b:surround_45 = "<% \r -%>"   " -
let b:surround_61 = "<%= \r %>"   " =

" Activate Ruby.vim's tooltips for Ruby keywords
setlocal ballooneval

" The compiler plugins contain instructions which allow Vim to run the
" specified source file with an appropriate executable, parse any errors, and
" jump to the corresponding error location if required.
compiler ruby


NeoBundleLazy 'scrooloose/syntastic', {
      \ 'autoload': {
      \   'insert': 1,
      \   'filetypes': ['ruby', 'erb'],
      \ }
      \ }

NeoBundle 'editorconfig/editorconfig-vim', {
      \ }

Add Konfekt/FastFold to speed up insert mode when folding is happening

NeoBundleLazy 'scrooloose/syntastic', {
      \ 'autoload': {
      \   'insert': 1,
      \   'filetypes': ['ruby', 'erb'],
      \ }
      \ }

NeoBundle 'editorconfig/editorconfig-vim'

NeoBundle 'Konfekt/FastFold'


set background=dark
colorscheme Tomorrow-Night-Blue

if !has("gui_running")
  colorscheme desert
end

Change terminal vim color scheme

set background=dark
colorscheme Tomorrow-Night-Blue

if !has("gui_running")
  colorscheme Tomorrow-Night
end


let s:Vital = vital#of('autocomplete_swift')

let s:Http = s:Vital.import('Web.HTTP')
let s:Json = s:Vital.import('Web.JSON')

let s:command_name = 'sourcekittendaemon'
let s:host = 'localhost'
let s:port = -1

function! sourcekitten_daemon#complete(path, offset)
    if sourcekitten_daemon#is_enabled() != 1
        return []
    endif

    let l:response = s:Http.get(
    \   s:address . '/complete',
    \   {},
    \   {
    \       'X-Offset': a:offset,
    \       'X-Path': a:path,
    \   }
    \)

    if l:response.success != 1
        return []
    endif

    return s:Json.decode(l:response.content)
endfunction

function! sourcekitten_daemon#enable(port)
    let s:port = a:port
    let s:address = 'http://' . s:host . ':' . s:port
endfunction

function! sourcekitten_daemon#disable()
    let s:port = -1
endfunction

function! sourcekitten_daemon#is_executable()
    return executable(s:command_name)
endfunction

function! sourcekitten_daemon#is_enabled()
    return sourcekitten_daemon#port != -1
endfunction

function! sourcekitten_daemon#port()
    return s:port
endfunction

Add '()' to call function.

let s:Vital = vital#of('autocomplete_swift')

let s:Http = s:Vital.import('Web.HTTP')
let s:Json = s:Vital.import('Web.JSON')

let s:command_name = 'sourcekittendaemon'
let s:host = 'localhost'
let s:port = -1

function! sourcekitten_daemon#complete(path, offset)
    if sourcekitten_daemon#is_enabled() != 1
        return []
    endif

    let l:response = s:Http.get(
    \   s:address . '/complete',
    \   {},
    \   {
    \       'X-Offset': a:offset,
    \       'X-Path': a:path,
    \   }
    \)

    if l:response.success != 1
        return []
    endif

    return s:Json.decode(l:response.content)
endfunction

function! sourcekitten_daemon#enable(port)
    let s:port = a:port
    let s:address = 'http://' . s:host . ':' . s:port
endfunction

function! sourcekitten_daemon#disable()
    let s:port = -1
endfunction

function! sourcekitten_daemon#is_executable()
    return executable(s:command_name)
endfunction

function! sourcekitten_daemon#is_enabled()
    return sourcekitten_daemon#port() != -1
endfunction

function! sourcekitten_daemon#port()
    return s:port
endfunction


" Rspec mappings
map <Leader>t :call RunCurrentSpecFile()<CR>
map <Leader>s :call RunNearestSpec()<CR>
map <Leader>l :call RunLastSpec()<CR>

let s:plugin_path = expand("<sfile>:p:h:h")

if has("gui_macvim")
  let g:rspec_command = "silent !" . s:plugin_path . "/bin/run_in_os_x_terminal 'rspec {spec}'"
else
  let g:rspec_command = "!echo rspec {spec} && rspec {spec}"
endif

function! RunCurrentSpecFile()
  if InSpecFile()
    let l:spec = @%
    call SetLastSpecCommand(l:spec)
    call RunSpecs(l:spec)
  endif
endfunction

function! RunNearestSpec()
  if InSpecFile()
    let l:spec = @% . ":" . line(".")
    call SetLastSpecCommand(l:spec)
    call RunSpecs(l:spec)
  endif
endfunction

function! RunLastSpec()
  if exists("s:last_spec_command")
    call RunSpecs(s:last_spec_command)
  endif
endfunction

function! InSpecFile()
  return match(expand("%"), "_spec.rb$") != -1
endfunction

function! SetLastSpecCommand(spec)
  let s:last_spec_command = a:spec
endfunction

function! RunSpecs(spec)
  write
  execute substitute(g:rspec_command, "{spec}", a:spec, "g")
endfunction

Check if gui version of vim is running

" Rspec mappings
map <Leader>t :call RunCurrentSpecFile()<CR>
map <Leader>s :call RunNearestSpec()<CR>
map <Leader>l :call RunLastSpec()<CR>

let s:plugin_path = expand("<sfile>:p:h:h")

if has("gui_running") && has("gui_macvim")
  let g:rspec_command = "silent !" . s:plugin_path . "/bin/run_in_os_x_terminal 'rspec {spec}'"
else
  let g:rspec_command = "!echo rspec {spec} && rspec {spec}"
endif

function! RunCurrentSpecFile()
  if InSpecFile()
    let l:spec = @%
    call SetLastSpecCommand(l:spec)
    call RunSpecs(l:spec)
  endif
endfunction

function! RunNearestSpec()
  if InSpecFile()
    let l:spec = @% . ":" . line(".")
    call SetLastSpecCommand(l:spec)
    call RunSpecs(l:spec)
  endif
endfunction

function! RunLastSpec()
  if exists("s:last_spec_command")
    call RunSpecs(s:last_spec_command)
  endif
endfunction

function! InSpecFile()
  return match(expand("%"), "_spec.rb$") != -1
endfunction

function! SetLastSpecCommand(spec)
  let s:last_spec_command = a:spec
endfunction

function! RunSpecs(spec)
  write
  execute substitute(g:rspec_command, "{spec}", a:spec, "g")
endfunction


" Abrimos siempre
"TagbarOpen
"TlistOpen

" Tabulación
set shiftwidth=2
set tabstop=2
set softtabstop=2

" JSON syntax highlighting
au BufNewFile,BufRead *.json set ft=javascript
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS

Remove JSON as js filetype

" Abrimos siempre
"TagbarOpen
"TlistOpen

" Tabulación
set shiftwidth=2
set tabstop=2
set softtabstop=2

au FileType javascript set omnifunc=javascriptcomplete#CompleteJS
" JSON syntax highlighting
" au BufNewFile,BufRead *.json set ft=javascript


" ~/.vim/after/ftplugin/go.vim

setlocal formatoptions+=ro
call filetype#UndoPlugin('setlocal formatoptions<')

setlocal shiftwidth=8 softtabstop=0 noexpandtab
call filetype#UndoPlugin('setlocal shiftwidth< softtabstop< expandtab<')

let b:syntastic_checkers = ['go']
call filetype#UndoPlugin('unlet b:syntastic_checkers')

nnoremap <buffer> <LocalLeader>=  :<C-U>Fmt<CR>
call filetype#UndoPlugin('nunmap <buffer> <LocalLeader>=')

nnoremap <buffer> <LocalLeader>i  :<C-U>Import <C-R><C-W><CR>
call filetype#UndoPlugin('nunmap <buffer> <LocalLeader>i')

Replace <C-R><C-W> with expand() in Vim mapping

" ~/.vim/after/ftplugin/go.vim

setlocal formatoptions+=ro
call filetype#UndoPlugin('setlocal formatoptions<')

setlocal shiftwidth=8 softtabstop=0 noexpandtab
call filetype#UndoPlugin('setlocal shiftwidth< softtabstop< expandtab<')

let b:syntastic_checkers = ['go']
call filetype#UndoPlugin('unlet b:syntastic_checkers')

nnoremap <buffer> <LocalLeader>=  :<C-U>Fmt<CR>
call filetype#UndoPlugin('nunmap <buffer> <LocalLeader>=')

nnoremap <buffer> <LocalLeader>i  :<C-U>Import <C-R>=expand('<cword>')<CR><CR>
call filetype#UndoPlugin('nunmap <buffer> <LocalLeader>i')


" Normal mode mappings.

" Toggle fold at current position.
" (Using s-tab to avoid collision between <tab> and <C-i>).
nnoremap <s-tab> za

" Avoid unintentional switches to Ex mode.
nmap Q q

" Multi-mode mappings (Normal, Visual, Operating-pending modes).
noremap Y y$

nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l

" Like vim-vinegar.
nnoremap <silent> - :silent edit <C-R>=empty(expand('%')) ? '.' : expand('%:p:h')<CR><CR>

" For each time K has produced timely, useful results, I have pressed it 10,000
" times without meaning to, triggering an annoying delay.
nnoremap K <nop>

" Repurpose cursor keys (accessible near homerow via "SpaceFN" layout) for one
" of my most oft-use key sequences.
nnoremap <silent> <Up> :cprevious<CR>
nnoremap <silent> <Down> :cnext<CR>
nnoremap <silent> <Left> :cpfile<CR>
nnoremap <silent> <Right> :cnfile<CR>

Store (some) relative line jumps in the jump list

" Normal mode mappings.

" Toggle fold at current position.
" (Using s-tab to avoid collision between <tab> and <C-i>).
nnoremap <s-tab> za

" Avoid unintentional switches to Ex mode.
nmap Q q

" Multi-mode mappings (Normal, Visual, Operating-pending modes).
noremap Y y$

nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l

" Like vim-vinegar.
nnoremap <silent> - :silent edit <C-R>=empty(expand('%')) ? '.' : expand('%:p:h')<CR><CR>

" For each time K has produced timely, useful results, I have pressed it 10,000
" times without meaning to, triggering an annoying delay.
nnoremap K <nop>

" Repurpose cursor keys (accessible near homerow via "SpaceFN" layout) for one
" of my most oft-use key sequences.
nnoremap <silent> <Up> :cprevious<CR>
nnoremap <silent> <Down> :cnext<CR>
nnoremap <silent> <Left> :cpfile<CR>
nnoremap <silent> <Right> :cnfile<CR>

" Store relative line number jumps in the jumplist if they exceed a threshold.
nnoremap <expr> k (v:count > 5 ? "m'" . v:count : '') . 'k'
nnoremap <expr> j (v:count > 5 ? "m'" . v:count : '') . 'j'


" Create and set cache directories.
if empty($XDG_CACHE_HOME)
  let $XDG_CACHE_HOME = $HOME . '/.cache'
endif

if !isdirectory($XDG_CACHE_HOME . '/nvim')
  call mkdir($XDG_CACHE_HOME . '/nvim', 'p')
endif

for dir in ['backup', 'swap', 'undo', 'session']
  if !isdirectory($XDG_CACHE_HOME . '/nvim/' . dir)
    call mkdir($XDG_CACHE_HOME . '/nvim/' . dir, 'p')
  endif
endfor

set backupdir=$XDG_CACHE_HOME/nvim/backup
set directory=$XDG_CACHE_HOME/nvim/swap
set undodir=$XDG_CACHE_HOME/nvim/undo

" Set vim-session path (created above).
let g:session_directory = $XDG_CACHE_HOME . '/nvim/session'

" Load ginit for neovim-dot-app.
if exists('neovim_dot_app')
  source $XDG_CONFIG_HOME/nvim/ginit.vim
endif

Revert "Load ginit.vim for neovim-dot-app"


let g:ctrlp_max_height = 20
let g:ctrlp_match_window_reversed = 0
let g:ctrlp_dotfiles = 0

" When a file is chosen that's already open in a window, don't jump that
" window.
let g:ctrlp_jump_to_buffer = 0

Revert "CtrlP: Don't jump to an existing window with buff."


function! _EscapeText_python(text)
  return substitute(a:text, "\n", "
", "g")
endfunction

Remove empty lines from Python code.

function! _EscapeText_python(text)
  let no_empty_lines = substitute(a:text, '\n\s*\ze\n', "", "g")
  return substitute(no_empty_lines, "\n", "
", "g")
endfunction


set guicursor+=a:blinkwait0 " disable cursor blink in gvim
set guioptions-=r           " disable right scrollbar
set guioptions-=L           " disable left scrollbar
set guioptions-=T
set guioptions-=m
set guifont=Ubuntu\ Mono\ for\ Powerline\ 12
"set guiheadroom=0
set background=dark

Use PragmataPro font in GVim

set guicursor+=a:blinkwait0 " disable cursor blink in gvim
set guioptions-=r           " disable right scrollbar
set guioptions-=L           " disable left scrollbar
set guioptions-=T
set guioptions-=m
set guifont=PragmataPro\ 12
"set guiheadroom=0
set background=dark


setlocal sw=4 ts=4 sts=4 noexpandtab
au BufWritePre *.go :silent Fmt

Fix the weird cursor issue

setlocal sw=4 ts=4 sts=4 noexpandtab
au BufWritePre Fmt


" High quality async completion
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }

let language_client_install = [
    \ 'bash install.sh',
    \ 'yarn global add javascript-typescript-langserver',
    \ 'yarn global add bash-language-server',
    \ 'pip install python-language-server']

" Language completion
Plug 'autozimu/LanguageClient-neovim', {
    \ 'branch': 'next',
    \ 'do': join(language_client_install, ' && '),
    \ }

" Currently there is no language client that supports go-completion. Use
" deoplete-go for this job. We can still rely on sourcegraph/go-langserver for
" goto defs etc.
Plug 'zchee/deoplete-go'

" Linting + Fixing support
Plug 'neomake/neomake'
Plug 'sbdchd/neoformat'

Add do make for deoplete-go

" High quality async completion
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }

let language_client_install = [
    \ 'bash install.sh',
    \ 'yarn global add javascript-typescript-langserver',
    \ 'yarn global add bash-language-server',
    \ 'pip install python-language-server']

" Language completion
Plug 'autozimu/LanguageClient-neovim', {
    \ 'branch': 'next',
    \ 'do': join(language_client_install, ' && '),
    \ }

" Currently there is no language client that supports go-completion. Use
" deoplete-go for this job. We can still rely on sourcegraph/go-langserver for
" goto defs etc.
Plug 'zchee/deoplete-go', { 'do': 'make'}

" Linting + Fixing support
Plug 'neomake/neomake'
Plug 'sbdchd/neoformat'


set colorcolumn=+1 " show textwidth limit
autocmd ColorScheme * highlight! link ColorColumn StatusLineNC

set regexpengine=1        " Do not use NFA because doxygen style will be slow
let g:load_doxygen_syntax=1 " Load doxygen syntax by default

if has('gui_running')
    colorscheme gruvbox
    set background=dark
else
    " do nothing
    colorscheme desert
endif

syntax on

Use gruvbox in console UI.

set colorcolumn=+1 " show textwidth limit
autocmd ColorScheme * highlight! link ColorColumn StatusLineNC

set regexpengine=1        " Do not use NFA because doxygen style will be slow
let g:load_doxygen_syntax=1 " Load doxygen syntax by default

" if has('gui_running')
    colorscheme gruvbox
    set background=dark
" endif

syntax on


" ABOLISH: abbreviations for LaTeX :)

Abolish git \gls{git}
Abolish correcti{f,fs} \gls{,pl}{patch}
Abolish Linux \gls{linux}
Abolish vger \spacedlowsmallcap{vger}
Abolish cvs \gls{cvs}
Abolish os{,s} \gls{,pl}{os}
Abolish uni{x,ces} \gls{,pl}{unix}
Abolish linuxkernel \gls{linuxkernel}
Abolish bsd \gls{bsd}
Abolish lkml \gls{lkml}
Abolish bitkeeper \gls{bitkeeper}
Abolish versioncontrol \gls{versioncontrol}
" Abolish '---' ~---

" Add quick delimiters for tex (since delimitmate and vim-latex are
" conflicting)
inoremap <buffer> ( ()<C-G>U<Left>
inoremap <buffer> [ []<C-G>U<Left>
inoremap <buffer> { {}<C-G>U<Left>
inoremap <buffer> " ""<C-G>U<Left>
inoremap <buffer> « «~~»<C-G>U<Left><Left>

" Hide 80 char limit
set colorcolumn=0

Fix typo in Abolish settings

" ABOLISH: abbreviations for LaTeX :)

Abolish git \gls{git}
Abolish correcti{f,fs} \gls{,pl}{patch}
Abolish Linux \gls{linux}
Abolish vger \spacedlowsmallcaps{vger}
Abolish cvs \gls{cvs}
Abolish os{,s} \gls{,pl}{os}
Abolish uni{x,ces} \gls{,pl}{unix}
Abolish linuxkernel \gls{linuxkernel}
Abolish bsd \gls{bsd}
Abolish lkml \gls{lkml}
Abolish bitkeeper \gls{bitkeeper}
Abolish versioncontrol \gls{versioncontrol}
" Abolish '---' ~---

" Add quick delimiters for tex (since delimitmate and vim-latex are
" conflicting)
inoremap <buffer> ( ()<C-G>U<Left>
inoremap <buffer> [ []<C-G>U<Left>
inoremap <buffer> { {}<C-G>U<Left>
inoremap <buffer> " ""<C-G>U<Left>
inoremap <buffer> « «~~»<C-G>U<Left><Left>

" Hide 80 char limit
set colorcolumn=0


" Author: Masashi Iizuka <liquidz.uo@gmail.com>
" Description: linter for clojure using clj-kondo https://github.com/borkdude/clj-kondo

function! ale_linters#clojure#clj_kondo#HandleCljKondoFormat(buffer, lines) abort
    " output format
    " <filename>:<line>:<column>: <issue type>: <message>
    let l:pattern = '\v^[a-zA-Z]?:?[^:]+:(\d+):(\d+):? ((Exception|error|warning): ?(.+))$'
    let l:output = []

    for l:match in ale#util#GetMatches(a:lines, l:pattern)
        let l:type = 'E'

        if l:match[4] is? 'warning'
            let l:type = 'W'
        endif

        call add(l:output, {
        \   'lnum': l:match[1] + 0,
        \   'col': l:match[2] + 0,
        \   'text': l:match[3],
        \   'type': l:type,
        \})
    endfor

    return l:output
endfunction

call ale#linter#Define('clojure', {
\   'name': 'clj-kondo',
\   'output_stream': 'stdout',
\   'executable': 'clj-kondo',
\   'command': 'clj-kondo --lint %t',
\   'callback': 'ale_linters#clojure#clj_kondo#HandleCljKondoFormat',
\})

Use cache for clj-kondo linter

" Author: Masashi Iizuka <liquidz.uo@gmail.com>
" Description: linter for clojure using clj-kondo https://github.com/borkdude/clj-kondo

function! ale_linters#clojure#clj_kondo#HandleCljKondoFormat(buffer, lines) abort
    " output format
    " <filename>:<line>:<column>: <issue type>: <message>
    let l:pattern = '\v^[a-zA-Z]?:?[^:]+:(\d+):(\d+):? ((Exception|error|warning): ?(.+))$'
    let l:output = []

    for l:match in ale#util#GetMatches(a:lines, l:pattern)
        let l:type = 'E'

        if l:match[4] is? 'warning'
            let l:type = 'W'
        endif

        call add(l:output, {
        \   'lnum': l:match[1] + 0,
        \   'col': l:match[2] + 0,
        \   'text': l:match[3],
        \   'type': l:type,
        \})
    endfor

    return l:output
endfunction

call ale#linter#Define('clojure', {
\   'name': 'clj-kondo',
\   'output_stream': 'stdout',
\   'executable': 'clj-kondo',
\   'command': 'clj-kondo --cache --lint %t',
\   'callback': 'ale_linters#clojure#clj_kondo#HandleCljKondoFormat',
\})


" ----------------------------------------------------------------------------
" Gitgutter
" ----------------------------------------------------------------------------
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


let g:Powerline_symbols='fancy'
let g:Powerline_colorscheme='skwp'

Set Powerline colorscheme to Solarized256

let g:Powerline_symbols='fancy'
let g:Powerline_colorscheme='solarized256'


function! sj#vue#SplitCssDefinition()
    if GetVueSection() != 'style'
        return 0
    endif
    return sj#css#SplitDefinition()
endfunction

function! sj#vue#JoinCssDefinition()
    if GetVueSection() != 'style'
        return 0
    endif
    return sj#css#JoinDefinition()
endfunction

function! sj#vue#SplitCssMultilineSelector()
    if GetVueSection() != 'style'
        return 0
    endif
    return sj#css#SplitMultilineSelector()
endfunction

function! sj#vue#JoinCssMultilineSelector()
    if GetVueSection() != 'style'
        return 0
    endif
    return sj#css#JoinMultilineSelector()
endfunction

function! GetVueSection()
  let l:startofsection = search('\v^\<(template|script|style)\>', 'bn')
  return substitute(getline(startofsection), '\v[<>]', '', 'g')
endfunction

Make GetVueSection a private function

function! sj#vue#SplitCssDefinition()
    if s:GetVueSection() != 'style'
        return 0
    endif
    return sj#css#SplitDefinition()
endfunction

function! sj#vue#JoinCssDefinition()
    if s:GetVueSection() != 'style'
        return 0
    endif
    return sj#css#JoinDefinition()
endfunction

function! sj#vue#SplitCssMultilineSelector()
    if s:GetVueSection() != 'style'
        return 0
    endif
    return sj#css#SplitMultilineSelector()
endfunction

function! sj#vue#JoinCssMultilineSelector()
    if s:GetVueSection() != 'style'
        return 0
    endif
    return sj#css#JoinMultilineSelector()
endfunction

function! s:GetVueSection()
  let l:startofsection = search('\v^\<(template|script|style)\>', 'bn')
  return substitute(getline(startofsection), '\v[<>]', '', 'g')
endfunction


" Original form was a single mapping that did everything, made by dza on #vim
" I refactored it into its current function+command form, which is much nicer

" create a Scratch buffer with MRU
function! s:ShowMRU(bang) abort
  if a:bang ==? '!'
    TScratch
  else
    SScratch
  endif

  0put =v:oldfiles
  normal! gg
endfunction

" I'd like a command better
command! -bang MRU call s:ShowMRU(<q-bang>)

Set nowrap in MRU buffer

" Original form was a single mapping that did everything, made by dza on #vim
" I refactored it into its current function+command form, which is much nicer

" create a Scratch buffer with MRU
function! s:ShowMRU(bang) abort
  if a:bang ==? '!'
    TScratch
  else
    SScratch
  endif

  setlocal nowrap
  0put =v:oldfiles
  normal! gg
endfunction

" I'd like a command better
command! -bang MRU call s:ShowMRU(<q-bang>)


augroup neomake_hooks
    autocmd!
    autocmd BufRead,BufWritePost * Neomake
    autocmd BufRead,BufWritePost *.js Neomake standard
augroup END

Set standard as js linter

augroup neomake_hooks
    autocmd!
    autocmd BufRead,BufWritePost * Neomake
    autocmd BufRead,BufWritePost *.js Neomake standard
augroup END

let g:neomake_javascript_enabled_makers = ['standard']


" std::cout, std::cin, etc.
inoremap ;in std::cin<space>>><space>
inoremap ;out std::cout<space><<<space>
inoremap ;end <<<space>std::endl;

" Basic new file
inoremap ;main #include <iostream><CR><CR>int main() {<CR>return 0;<CR>}<Esc>kO

Add conditional snippets for c++

" std::cout, std::cin, etc.
inoremap ;in std::cin >>
inoremap ;out std::cout <<
inoremap ;end << std::endl;

" Basic new file
inoremap ;main #include <iostream><CR><CR>int main() {<CR>return 0;<CR>}<Esc>kO

" if
inoremap ;if if () {<CR><++><CR>}<++><Esc>kk0f)i
inoremap ;elif <space>else if () {<CR><++><CR>}<++><Esc>kk0f)i
inoremap ;else <space>else {<CR><CR>}<++><Esc>ki<Tab>


" Language:    CoffeeScript
" Maintainer:  Mick Koch <kchmck@gmail.com>
" URL:         http://github.com/kchmck/vim-coffee-script
" License:     WTFPL

if exists("b:did_ftplugin")
  finish
endif

let b:did_ftplugin = 1

setlocal formatoptions-=t formatoptions+=croql
setlocal comments=s:###,m:\ ,e:###,:#
setlocal commentstring=#\ %s

" Compile the current file on write.
if exists("coffee_compile_on_save")
  autocmd BufWritePost *.coffee silent !coffee -c <afile> &
endif

Add FileWritePost to save-compile autocmd

" Language:    CoffeeScript
" Maintainer:  Mick Koch <kchmck@gmail.com>
" URL:         http://github.com/kchmck/vim-coffee-script
" License:     WTFPL

if exists("b:did_ftplugin")
  finish
endif

let b:did_ftplugin = 1

setlocal formatoptions-=t formatoptions+=croql
setlocal comments=s:###,m:\ ,e:###,:#
setlocal commentstring=#\ %s

" Compile the current file on write.
if exists("coffee_compile_on_save")
  autocmd BufWritePost,FileWritePost *.coffee silent !coffee -c <afile> &
endif


" ===========================================================================
" Author:   Majd Taby <mtaby@me.com>
" License:  MIT License
" ===========================================================================

" NOTE: This plugin is based heavily on Geoffrey Grosenbach's peepopen.vim
" plugin.

" Exit quickly when:
" - this plugin was already loaded (or disabled)
" - when 'compatible' is set
if &cp || exists("g:waldo_loaded") && g:waldo_loaded
  finish
endif
let g:waldo_loaded = 1

let s:save_cpo = &cpo
set cpo&vim

" ============================================================================
" Waldo support

function s:LaunchWaldoViaVim()
  let cwd = getcwd()
  silent exe  "!open -a Waldo " . shellescape(cwd)
  silent exe  "!open -a Waldo " . shellescape(cwd)
endfunction

command! Waldo :call <SID>LaunchWaldoViaVim()

noremap <unique> <script> <Plug>Waldo <SID>Launch
noremap <SID>Launch :call <SID>LaunchWaldoViaVim()<CR>

if !hasmapto('<Plug>Waldo')
  map <unique> <silent> <Leader>f <Plug>Waldo
endif

Revert "HACK: Couldn't figure out another way to make the app focus on launch :("

" ===========================================================================
" Author:   Majd Taby <mtaby@me.com>
" License:  MIT License
" ===========================================================================

" NOTE: This plugin is based heavily on Geoffrey Grosenbach's peepopen.vim
" plugin.

" Exit quickly when:
" - this plugin was already loaded (or disabled)
" - when 'compatible' is set
if &cp || exists("g:waldo_loaded") && g:waldo_loaded
  finish
endif
let g:waldo_loaded = 1

let s:save_cpo = &cpo
set cpo&vim

" ============================================================================
" Waldo support

function s:LaunchWaldoViaVim()
  let cwd = getcwd()
  silent exe  "!open -a Waldo " . shellescape(cwd)
endfunction

command! Waldo :call <SID>LaunchWaldoViaVim()

noremap <unique> <script> <Plug>Waldo <SID>Launch
noremap <SID>Launch :call <SID>LaunchWaldoViaVim()<CR>

if !hasmapto('<Plug>Waldo')
  map <unique> <silent> <Leader>f <Plug>Waldo
endif


" Highlight search findings
set hlsearch
" Case insensitive search...
set ignorecase
" ...Except when using capital letters
set smartcase

" Line numbers
set number
" relative to the current line
set relativenumber

"4 spaces for indentation
set expandtab
set tabstop=4
set shiftwidth=4

"Automatically change working directory to that of current file
set autochdir

" Open 2 levels of folds by default
set foldlevelstart=2

" Disable conceal on current line
set concealcursor=""

" 80 character column
set colorcolumn=80
set textwidth=80

" Saner splits
set splitright
set splitbelow

" highligh cursor line & column
set cursorline
set cursorcolumn

" Automatically reload init.vim when it is changed. Either in the dotfiles
" directory or in the nvim config directory
if !exists("autocommands_loaded")
    let autocommands_loaded = 1
    autocmd bufwritepost $HOME/.config/nvim/* source $HOME/.config/nvim/init.vim
    autocmd bufwritepost $HOME/.config/dotfiles/neovim/* source $HOME/.config/nvim/init.vim
endif

au BufNewFile,BufRead *.es6 set filetype=javascript

" Auto insert mode in the terminal
autocmd BufEnter * if &buftype == "terminal" | startinsert | endif

Change defualt line length to 92 characters

" Highlight search findings
set hlsearch
" Case insensitive search...
set ignorecase
" ...Except when using capital letters
set smartcase

" Line numbers
set number
" relative to the current line
set relativenumber

"4 spaces for indentation
set expandtab
set tabstop=4
set shiftwidth=4

"Automatically change working directory to that of current file
set autochdir

" Open 2 levels of folds by default
set foldlevelstart=2

" Disable conceal on current line
set concealcursor=""

" 92 character column
set colorcolumn=92
set textwidth=92

" Saner splits
set splitright
set splitbelow

" highligh cursor line & column
set cursorline
set cursorcolumn

" Automatically reload init.vim when it is changed. Either in the dotfiles
" directory or in the nvim config directory
if !exists("autocommands_loaded")
    let autocommands_loaded = 1
    autocmd bufwritepost $HOME/.config/nvim/* source $HOME/.config/nvim/init.vim
    autocmd bufwritepost $HOME/.config/dotfiles/neovim/* source $HOME/.config/nvim/init.vim
endif

au BufNewFile,BufRead *.es6 set filetype=javascript

" Auto insert mode in the terminal
autocmd BufEnter * if &buftype == "terminal" | startinsert | endif


" Colorscheme settings
" github.com/mike325/.vim

set background=dark
set cursorline

if has#option('termguicolors')
    set termguicolors
endif

if !has('nvim')
    let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
    let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
endif

try
    if has#plugin('sonokai')
        if has#plugin('vim-airline')
            let g:airline_theme = 'sonokai'
        endif
        let g:sonokai_better_performance = os#name('windows') ? 0 : 1
        let g:sonokai_style = 'shusia'
        let g:sonokai_enable_italic = 1
        let g:sonokai_disable_italic_comment = 1
        let g:sonokai_diagnostic_line_highlight = 1
        colorscheme sonokai
    elseif has#plugin('ayu-vim') && has('nvim')
        let g:ayucolor = 'dark'
        colorscheme ayu
    elseif has#plugin('onedark.vim')
        colorscheme onedark
    else
        colorscheme torte
        set nocursorline
    endif
catch /E185/
    colorscheme torte
    set nocursorline
endtry

Add sonokai performance mode in windows

" Colorscheme settings
" github.com/mike325/.vim

set background=dark
set cursorline

if has#option('termguicolors')
    set termguicolors
endif

if !has('nvim')
    set t_Co=256
    let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
    let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
endif

try
    if has#plugin('sonokai')
        if has#plugin('vim-airline')
            let g:airline_theme = 'sonokai'
        endif
        let g:sonokai_better_performance = 1
        let g:sonokai_style = 'shusia'
        let g:sonokai_enable_italic = 1
        let g:sonokai_disable_italic_comment = 1
        let g:sonokai_diagnostic_line_highlight = 1
        colorscheme sonokai
    elseif has#plugin('ayu-vim') && has('nvim')
        let g:ayucolor = 'dark'
        colorscheme ayu
    elseif has#plugin('onedark.vim')
        colorscheme onedark
    else
        colorscheme torte
        set nocursorline
    endif
catch /E185/
    colorscheme torte
    set nocursorline
endtry


call plug#begin()

" Plugins
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'

" Themes
Plug 'sickill/vim-monokai'

" Git
Plug 'airblade/vim-gitgutter'

call plug#end()

" Use UTF-8 encoding
set encoding=utf-8

" View line numbers
set number

" Configure vim-airline
let g:airline_theme='simple'
set laststatus=2

" Configure vim-monokai with syntax highlighting
syntax enable
colorscheme monokai

" Enable clipboard yanking
set clipboard+=unnamedplus

Update nvim config to use vim-sensible plugin

call plug#begin()

" Plugins
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'

" Themes
Plug 'sickill/vim-monokai'

" Git
Plug 'airblade/vim-gitgutter'

" Config
Plug 'tpope/vim-sensible'

call plug#end()

" View line numbers
set number

" Configure vim-airline
let g:airline_theme='simple'

" Configure vim-monokai with syntax highlighting
colorscheme monokai

" Enable clipboard yanking
set clipboard+=unnamedplus


" COLORS

set t_Co=256
set background=light
"colorscheme paramount
colorscheme Tomorrow

Use transparent version of Tomorrow Night

" COLORS

set t_Co=256
set background=light
"colorscheme paramount
colorscheme Tomorrow-Night
hi Normal ctermbg=none


augroup startup
    autocmd!
    autocmd BufNewFile,BufReadPost,FilterReadPost,FileReadPost * :set number            " Always show line number on new buffer
augroup end
set nowrap

set nobackup        " Don't use backup file

set cursorline
augroup CursorLine
    autocmd!
    autocmd VimEnter,WinEnter,BufWinEnter * setlocal cursorline
    autocmd WinLeave * setlocal nocursorline
augroup END

" Tab
set tabstop=4
set shiftwidth=0
set softtabstop=-1
set expandtab

" UTF-8
set encoding=utf-8
set termencoding=utf-8
set fileencoding=utf-8

" Scrolling
set scrolloff=5
set sidescrolloff=5
set lazyredraw

set magic             " Regular expressions

set autoread

let $VISUAL = 'nvr -cc split --remote-wait'         " Split instead of nested editor inside neovim terminal

set exrc
set secure

Make neovim use X clipboard by default

augroup startup
    autocmd!
    autocmd BufNewFile,BufReadPost,FilterReadPost,FileReadPost * :set number            " Always show line number on new buffer
augroup end
set nowrap

set nobackup        " Don't use backup file

set cursorline
augroup CursorLine
    autocmd!
    autocmd VimEnter,WinEnter,BufWinEnter * setlocal cursorline
    autocmd WinLeave * setlocal nocursorline
augroup END

" Tab
set tabstop=4
set shiftwidth=0
set softtabstop=-1
set expandtab

" UTF-8
set encoding=utf-8
set termencoding=utf-8
set fileencoding=utf-8

" Scrolling
set scrolloff=5
set sidescrolloff=5
set lazyredraw

set magic             " Regular expressions

set autoread

set clipboard=unnamed,unnamedplus

let $VISUAL = 'nvr -cc split --remote-wait'         " Split instead of nested editor inside neovim terminal

set exrc
set secure