if !has('python')
    echom "No python!"
	finish
endif

python import sys
python import vim
python sys.path.append(vim.eval('expand("<sfile>:h")'))

function GitIssue()

python << endOfPython

from issue import list_all

list_all()

endOfPython

endfunction

command! Is call GitIssue()

Add a complete function now

if !has('python')
    echom "No python!"
	finish
endif

function Dummy(findstart, base)
     if a:findstart
	    " locate the start of the word
	    let line = getline('.')
	    let start = col('.') - 1
	    while start > 0 && line[start - 1] =~ '\a'
	      let start -= 1
	    endwhile
	    return start
	  else
	    " find months matching with "a:base"
	    let res = []
	    for m in split("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec")
	      if m =~ '^' . a:base
		call add(res, m)
	      endif
	    endfor
	    return res
	  endif
endfunction

setlocal omnifunc=Dummy

python import sys
python import vim
python sys.path.append(vim.eval('expand("<sfile>:h")'))

function GitIssue()

python << endOfPython

from issue import list_all

list_all()

endOfPython

endfunction

command! Is call GitIssue()


highlight link jsThis jsReturn
highlight link jsStorageClass jsClassKeyword
highlight link jsModuleKeywords jsClassKeyword
highlight link jsModuleOperators jsClassKeyword
highlight link jsArrowFunction NONE
highlight link jsImport jsClassKeyword
highlight link jsFrom jsClassKeyword
highlight link jsExport jsClassKeyword
highlight link jsExportDefault jsFuncName

Improve flow type syntax highlighting

syntax keyword flowTypeKeyword type nextgroup=flowTypeIdentifier
syntax region flowTypeIdentifier contained start=/\%(\s\+\k\)/ end=/=\@=/ nextgroup=jsFlowTypeValue
syntax match flowObjectProps contained /[0-9a-zA-Z_$?]*\(\s*:\)\@=/ skipwhite skipempty nextgroup=jsFlowTypeValue containedin=jsFlowObject

highlight link jsThis jsReturn
highlight link jsStorageClass jsClassKeyword
highlight link jsModuleKeywords jsClassKeyword
highlight link jsModuleOperators jsClassKeyword
highlight link jsArrowFunction NONE
highlight link jsImport jsClassKeyword
highlight link jsFrom jsClassKeyword
highlight link jsExport jsClassKeyword
highlight link jsExportDefault jsFuncName
highlight link jsFlowTypeKeyword Keyword
highlight link flowTypeKeyword Keyword
highlight link flowTypeIdentifier Function
highlight link flowObjectProps Special


" Javascript
autocmd Filetype javascript setlocal et ts=2 sts=2 sw=2
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd BufNewFile,BufRead Gulpfile* set filetype=javascript

Add default completion type for JS

" Javascript
autocmd Filetype javascript setlocal et ts=2 sts=2 sw=2
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd BufNewFile,BufRead Gulpfile* set filetype=javascript
autocmd FileType javascript let g:SuperTabDefaultCompletionType = "<c-x><c-o>"


let ignore_dirs = ['talks', 'out', '.cljs_rhino_repl', 'target', '.idea']
let ignore_file_exts = ['pack.js', 'min.css', 'min.js']

if executable('rg')
  " Use rg for denite
  " https://github.com/BurntSushi/ripgrep
  call denite#custom#var('grep', 'command', ['printargs.sh'])

  let rg_ignores = map(copy(ignore_file_exts), '"-g ''!*.".v:val."''"')
	\ + map(copy(ignore_dirs), '"-g ''!./".v:val."/**/*''"')

  call denite#custom#var('grep', 'default_opts',
			  \ ['rg', '--vimgrep', '--no-heading', '-i']
			  \ + rg_ignores)

  call denite#custom#var('grep', 'recursive_opts', [])
  call denite#custom#var('grep', 'final_opts', [])
  call denite#custom#var('grep', 'separator', ['--'])

  call denite#custom#var('file_rec', 'command', ['rg', '--files'] + rg_ignores)
endif

nnoremap <leader>d/ :Denite grep<CR>
nnoremap <leader>df :Denite file_rec<CR>
nnoremap <leader>db :Denite buffer<CR>

Add fancy prompt to denite

let ignore_dirs = ['talks', 'out', '.cljs_rhino_repl', 'target', '.idea']
let ignore_file_exts = ['pack.js', 'min.css', 'min.js']

if executable('rg')
  " Use rg for denite
  " https://github.com/BurntSushi/ripgrep
  call denite#custom#var('grep', 'command', ['printargs.sh'])

  let rg_ignores = map(copy(ignore_file_exts), '"-g ''!*.".v:val."''"')
	\ + map(copy(ignore_dirs), '"-g ''!./".v:val."/**/*''"')

  call denite#custom#var('grep', 'default_opts',
			  \ ['rg', '--vimgrep', '--no-heading', '-i']
			  \ + rg_ignores)

  call denite#custom#var('grep', 'recursive_opts', [])
  call denite#custom#var('grep', 'final_opts', [])
  call denite#custom#var('grep', 'separator', ['--'])

  call denite#custom#var('file_rec', 'command', ['rg', '--files'] + rg_ignores)
endif

call denite#custom#option('default', 'prompt', ' ❯')

nnoremap <leader>d/ :Denite grep<CR>
nnoremap <leader>df :Denite file_rec<CR>
nnoremap <leader>db :Denite buffer<CR>


if has("gui_running")
  set guioptions=acei
  set background=dark
  colorscheme vividchalk
  set listchars=tab:→\ ,eol:¬
  set list
  if has("gui_macvim")
    set guifont=Monaco:h12
  else
    set guifont=Monaco\ 11,\ DejaVu\ Sans\ Mono\ 10
  end
end

Decrease vim font size on Linux

if has("gui_running")
  set guioptions=acei
  set background=dark
  colorscheme vividchalk
  set listchars=tab:→\ ,eol:¬
  set list
  if has("gui_macvim")
    set guifont=Monaco:h12
  else
    set guifont=Monaco\ 9,\ DejaVu\ Sans\ Mono\ 9
  end
end


" ------------------------------------------------------------------------------
" vim-airline and related config
" ------------------------------------------------------------------------------
" Enable powerline fonts in vim-airline (like the branch icon)
" I'm using Consolas font for powerline, set in the iTerm Profile text settings:
" https://github.com/runsisi/consolas-font-for-powerline
let g:airline_powerline_fonts=1
" Suppress default mode messages and just use vim-airline
set noshowmode
" Show open buffer top tabline
let g:airline#extensions#tabline#enabled = 1

Remove buffer list from top of screen

" ------------------------------------------------------------------------------
" vim-airline and related config
" ------------------------------------------------------------------------------
" Enable powerline fonts in vim-airline (like the branch icon)
" I'm using Consolas font for powerline, set in the iTerm Profile text settings:
" https://github.com/runsisi/consolas-font-for-powerline
let g:airline_powerline_fonts=1
" Suppress default mode messages and just use vim-airline
set noshowmode
" Show open buffer top tabline
" let g:airline#extensions#tabline#enabled = 1


" 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
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,[,],,~

Add tab settings for racket

" 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
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,[,],,~


" Default indentation settings
setlocal tabstop=2
setlocal shiftwidth=2

" ? and ! are part of method names
setlocal iskeyword+=?,!

" RSpec
let g:rspec_command = 'call VtrSendCommand("bundle exec rspec {spec}")'
nnoremap <buffer> <Leader>t :call RunCurrentSpecFile()<CR>
nnoremap <buffer> <Leader>s :call RunNearestSpec()<CR>
nnoremap <buffer> <Leader>l :call RunLastSpec()<CR>
nnoremap <buffer> <Leader>a :call RunAllSpecs()<CR>

" AutoPairs
let b:AutoPairs = {'(':')', '[':']', '{':'}', "'":"'", '"':'"', '`':'`', '|':'|'}

" Switch
let b:switch_custom_definitions =
    \ [
    \   ['if', 'unless'],
    \   ['to', 'not_to'],
    \   ['first', 'last'],
    \   {
    \       '\(\w\+\)\[\([^]]*\)\]': '\1.fetch(\2)',
    \       '\(\w\+\)\.fetch(\([^)]*\))': '\1[\2]',
    \   }
    \ ]

Add leader command to run RSpec with documentation

" Default indentation settings
setlocal tabstop=2
setlocal shiftwidth=2

" ? and ! are part of method names
setlocal iskeyword+=?,!

" RSpec
let g:rspec_command = 'call VtrSendCommand("bundle exec rspec {spec}")'
nnoremap <buffer> <Leader>a :call RunAllSpecs()<CR>
nnoremap <buffer> <Leader>l :call RunLastSpec()<CR>
nnoremap <buffer> <Leader>L :call RunLastSpecWithDocumentation()<CR>
nnoremap <buffer> <Leader>s :call RunNearestSpec()<CR>
nnoremap <buffer> <Leader>t :call RunCurrentSpecFile()<CR>

function! RunLastSpecWithDocumentation()
    let l:old_rspec_command = g:rspec_command
    let g:rspec_command = 'call VtrSendCommand("bundle exec rspec {spec} --format=documentation")'

    call RunLastSpec()

    let g:rspec_command = l:old_rspec_command
endfunction

" AutoPairs
let b:AutoPairs = {'(':')', '[':']', '{':'}', "'":"'", '"':'"', '`':'`', '|':'|'}

" Switch
let b:switch_custom_definitions =
    \ [
    \   ['if', 'unless'],
    \   ['to', 'not_to'],
    \   ['first', 'last'],
    \   {
    \       '\(\w\+\)\[\([^]]*\)\]': '\1.fetch(\2)',
    \       '\(\w\+\)\.fetch(\([^)]*\))': '\1[\2]',
    \   }
    \ ]


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

" for tex
let g:tex_conceal = ''

Use 2 spaces as a tab in python 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
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

" for tex
let g:tex_conceal = ''


lua <<EOF
local lsp = require('lsp-zero')

lsp.preset('recommended')

local cmp = require('cmp')
local luasnip = require('luasnip')
local cmp_select = {behavior = cmp.SelectBehavior.Select}

lsp.setup_nvim_cmp({
  mapping = lsp.defaults.cmp_mappings({
    ['<C-k>'] = cmp.mapping.select_prev_item(cmp_select),
    ['<C-j>'] = cmp.mapping.select_next_item(cmp_select),
    ['<C-l>'] = cmp.mapping.confirm({ select = true }),
    -- go to next placeholder in the snippet
    ['<Tab>'] = cmp.mapping(function(fallback)
      if luasnip.jumpable(1) then
        luasnip.jump(1)
      else
        fallback()
      end
    end, {'i', 's'}),
    -- go to previous placeholder in the snippet
    ['<S-Tab>'] = cmp.mapping(function(fallback)
      if luasnip.jumpable(-1) then
        luasnip.jump(-1)
      else
        fallback()
      end
    end, {'i', 's'}),
  })
})

lsp.nvim_workspace()
lsp.setup()
EOF

Fix <CR> mapping with cmp

lua <<EOF
local lsp = require('lsp-zero')

lsp.preset('recommended')

local cmp = require('cmp')
local luasnip = require('luasnip')
local cmp_select = {behavior = cmp.SelectBehavior.Select}

lsp.setup_nvim_cmp({
  mapping = lsp.defaults.cmp_mappings({
    ['<CR>'] = cmp.mapping({
      i = function(fallback)
        if cmp.visible() then
          cmp.mapping.confirm({ select = false })()
          vim.api.nvim_input('<ESC>')
        else
          fallback()
        end
      end,
      n = cmp.mapping.confirm({ select = true }),
    }),
    ['<C-k>'] = cmp.mapping.select_prev_item(cmp_select),
    ['<C-j>'] = cmp.mapping.select_next_item(cmp_select),
    ['<C-l>'] = cmp.mapping.confirm({ select = true }),
    -- go to next placeholder in the snippet
    ['<Tab>'] = cmp.mapping(function(fallback)
      if luasnip.jumpable(1) then
        luasnip.jump(1)
      else
        fallback()
      end
    end, {'i', 's'}),
    -- go to previous placeholder in the snippet
    ['<S-Tab>'] = cmp.mapping(function(fallback)
      if luasnip.jumpable(-1) then
        luasnip.jump(-1)
      else
        fallback()
      end
    end, {'i', 's'}),
  })
})

lsp.nvim_workspace()
lsp.setup()
EOF


"------------------------------
" COMMON SETTINGS
"------------------------------

"Syntax coloring options
"------------------------------

syntax on
set background=dark

set number

set showcmd

"Indent options
"------------------------------
set autoindent
set smartindent

"Search options
"------------------------------
set hlsearch
set wrapscan
set incsearch
set ignorecase

set scrolljump=7
set scrolloff=7

"Tab indent options
"------------------------------
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab

"Wrap options
"------------------------------
set wrap
set linebreak
set whichwrap+=<,>,[,]
set backspace=indent,eol,start

" Highlight tabs, trailing spaces, unprintable characters
set list
set listchars=tab:>.,trail:.,extends:#,nbsp:.

"Status line
"------------------------------
set laststatus=2
set history=1000

set completeopt=menu
set wildmenu

"Backup and swap
"------------------------------
set nobackup
set noswapfile

"Encodings
"------------------------------
set encoding=utf-8
set termencoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8,cp1251,koi8-r,cp866

"Window options
"------------------------------
set winminwidth=0
set winminheight=0

"Other options
"------------------------------
set mouse=a

Remove redundant or unrequired options

"------------------------------
" COMMON SETTINGS
"------------------------------

"Syntax coloring options
"------------------------------

syntax on
set background=dark

set number

set showcmd

"Indent options
"------------------------------
set autoindent
set smartindent

"Search options
"------------------------------
set hlsearch
set wrapscan
set incsearch
set ignorecase

set scrolljump=7
set scrolloff=7

"Tab indent options
"------------------------------
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab

"Wrap options
"------------------------------
set wrap
set linebreak
set whichwrap+=<,>,[,]
set backspace=indent,eol,start

" Highlight tabs, trailing spaces, unprintable characters
set list
set listchars=tab:>.,trail:.,extends:#,nbsp:.

"Status line
"------------------------------
set laststatus=2
set history=1000

set completeopt=menu
set wildmenu

"Backup and swap
"------------------------------
set nobackup
set noswapfile

"Encodings
"------------------------------
set encoding=utf-8

"Other options
"------------------------------
set mouse=a


" Execute a Ruby file with <leader> rr
map <leader>rr :w<CR>:!ruby %<CR>

Add Pry REPL neoterm support

" Execute a Ruby file with <leader> rr
map <leader>rr :w<CR>:!ruby %<CR>
nmap <Leader>pry obinding.pry<C-[>:TT require '%'<CR><C-[><C-\>I


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

Plug 'tpope/vim-fugitive'
Plug 'flazz/vim-colorschemes'
Plug 'bling/vim-airline'
Plug 'tpope/vim-surround'
Plug 'jeetsukumaran/vim-buffergator'
Plug 'scrooloose/nerdcommenter'
Plug 'embear/vim-localvimrc'
Plug 'editorconfig/editorconfig-vim'
Plug 'bronson/vim-trailing-whitespace'
Plug 'nathanaelkane/vim-indent-guides'
Plug 'tpope/vim-sleuth'
Plug 'ervandew/supertab'
Plug 'rking/ag.vim'
Plug 'scrooloose/nerdtree'
Plug 'mbbill/undotree'
Plug 'airblade/vim-gitgutter'
Plug 'sudo.vim'
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'junegunn/fzf'
Plug 'benekastah/neomake'
Plug 'Shougo/deoplete.nvim'
Plug 'pangloss/vim-javascript'
Plug 'terryma/vim-multiple-cursors'
Plug 'tpope/vim-repeat'
Plug 'ludovicchabant/vim-gutentags'
Plug 'rust-lang/rust.vim'
Plug 'derekwyatt/vim-scala'

call plug#end()

Fix vim-airline plugins for repo migration

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

Plug 'tpope/vim-fugitive'
Plug 'flazz/vim-colorschemes'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'tpope/vim-surround'
Plug 'jeetsukumaran/vim-buffergator'
Plug 'scrooloose/nerdcommenter'
Plug 'embear/vim-localvimrc'
Plug 'editorconfig/editorconfig-vim'
Plug 'bronson/vim-trailing-whitespace'
Plug 'nathanaelkane/vim-indent-guides'
Plug 'tpope/vim-sleuth'
Plug 'ervandew/supertab'
Plug 'rking/ag.vim'
Plug 'scrooloose/nerdtree'
Plug 'mbbill/undotree'
Plug 'airblade/vim-gitgutter'
Plug 'sudo.vim'
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'junegunn/fzf'
Plug 'benekastah/neomake'
Plug 'Shougo/deoplete.nvim'
Plug 'pangloss/vim-javascript'
Plug 'terryma/vim-multiple-cursors'
Plug 'tpope/vim-repeat'
Plug 'ludovicchabant/vim-gutentags'
Plug 'rust-lang/rust.vim'
Plug 'derekwyatt/vim-scala'

call plug#end()


" markdown files run this as well
" https://stackoverflow.com/questions/22839269/why-does-vim-default-markdown-ftplugin-source-html-ftplugins-is-there-any-ways
if &ft !=# 'markdown'
  let b:prettier_ft_default_args = {
    \ 'parser': 'html',
    \ }
endif

augroup Prettier
  autocmd!
  if g:prettier#autoformat
    autocmd BufWritePre *.html call prettier#Autoformat()
  endif
augroup end

Make markdown check more resilient

" markdown files run this as well
" https://stackoverflow.com/questions/22839269/why-does-vim-default-markdown-ftplugin-source-html-ftplugins-is-there-any-ways
if &ft !=~ 'markdown'
  let b:prettier_ft_default_args = {
    \ 'parser': 'html',
    \ }
endif

augroup Prettier
  autocmd!
  if g:prettier#autoformat
    autocmd BufWritePre *.html call prettier#Autoformat()
  endif
augroup end


" ------------------------------------------------------------------------------
" Syntastic and related config
" ------------------------------------------------------------------------------
let g:syntastic_check_on_save=1 " Check syntax on save using MRI
let g:syntastic_enable_signs=1 " Display syntax error markers in gutter
let g:syntastic_auto_jump=1 " Automatically jump to first error reported

Check syntax after save was slowing vim down big time, so disable

" ------------------------------------------------------------------------------
" Syntastic and related config
" ------------------------------------------------------------------------------
" let g:syntastic_check_on_save=1 " Check syntax on save using MRI
let g:syntastic_enable_signs=1 " Display syntax error markers in gutter
let g:syntastic_auto_jump=1 " Automatically jump to first error reported


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

"My color scheme
Plug 'agude/eldar.vim'
"VimCompletesMe
Plug 'ajh17/VimCompletesMe'
"Surround
Plug 'tpope/vim-surround'
"Repeat (lets you use . with surround)
Plug 'tpope/vim-repeat'
"Vimwiki
Plug 'vimwiki/vimwiki'
"Tagbar
Plug 'majutsushi/tagbar'
"ctrlp
Plug 'ctrlpvim/ctrlp.vim'
"Python Syntax Highlighting
Plug 'hdima/python-syntax'
"Git support
Plug 'tpope/vim-fugitive'
" Better Diffing using git 1.8
Plug 'chrisbra/vim-diff-enhanced'
" PEP8 compliant indenting
Plug 'Vimjas/vim-python-pep8-indent'

" Neovim only

if has("nvim")
    " Autocomplete
    function! DoRemote(arg)
        UpdateRemotePlugins
    endfunction
    Plug 'Shougo/deoplete.nvim', { 'do': function('DoRemote') }
    " Jedi autocomplete
    Plug 'zchee/deoplete-jedi'
endif

call plug#end()

Use the new, correct location for `vim-eldar`

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

"My color scheme
Plug 'agude/vim-eldar'
"VimCompletesMe
Plug 'ajh17/VimCompletesMe'
"Surround
Plug 'tpope/vim-surround'
"Repeat (lets you use . with surround)
Plug 'tpope/vim-repeat'
"Vimwiki
Plug 'vimwiki/vimwiki'
"Tagbar
Plug 'majutsushi/tagbar'
"ctrlp
Plug 'ctrlpvim/ctrlp.vim'
"Python Syntax Highlighting
Plug 'hdima/python-syntax'
"Git support
Plug 'tpope/vim-fugitive'
" Better Diffing using git 1.8
Plug 'chrisbra/vim-diff-enhanced'
" PEP8 compliant indenting
Plug 'Vimjas/vim-python-pep8-indent'

" Neovim only

if has("nvim")
    " Autocomplete
    function! DoRemote(arg)
        UpdateRemotePlugins
    endfunction
    Plug 'Shougo/deoplete.nvim', { 'do': function('DoRemote') }
    " Jedi autocomplete
    Plug 'zchee/deoplete-jedi'
endif

call plug#end()


call plug#begin('~/.local/share/nvim/plugged')

Plug 'autozimu/LanguageClient-neovim', {
    \ 'branch': 'next',
    \ 'do': 'bash install.sh',
    \ }

call plug#end()

augroup filetype_rust
    autocmd!
    autocmd BufReadPost *.rs setlocal filetype=rust
augroup END

" Always draw sign column. Prevent buffer moving when adding/deleting sign.
set signcolumn=yes

let g:LanguageClient_serverCommands = {
    \ 'rust': ['rustup', 'run', 'stable', 'rls'],
    \ }
let $RUST_BACKTRACE = 1
let g:LanguageClient_loggingLevel = 'INFO'
let g:LanguageClient_loggingFile = stdpath('data') . '/LanguageClient.log'
let g:LanguageClient_serverStderr = stdpath('data') . '/LanguageServer.log'

Make example config more compatible.

call plug#begin('~/.local/share/nvim/plugged')

Plug 'autozimu/LanguageClient-neovim', {
    \ 'branch': 'next',
    \ 'do': 'bash install.sh',
    \ }

call plug#end()

augroup filetype_rust
    autocmd!
    autocmd BufReadPost *.rs setlocal filetype=rust
augroup END

" Always draw sign column. Prevent buffer moving when adding/deleting sign.
set signcolumn=yes

let g:LanguageClient_serverCommands = {
    \ 'rust': ['rustup', 'run', 'stable', 'rls'],
    \ }
let $RUST_BACKTRACE = 1
let g:LanguageClient_loggingLevel = 'INFO'
let g:LanguageClient_loggingFile =  expand('~/.local/share/nvim/LanguageClient.log')
let g:LanguageClient_serverStderr = expand('~/.local/share/nvim/LanguageServer.log')


" Author: Jon Gjengset <jon@thesquareplanet.com>
" Description: The next generation language server for Rust

call ale#Set('rust_analyzer_executable', 'ra_lsp_server')
call ale#Set('rust_analyzer_config', {})

function! ale_linters#rust#analyzer#GetCommand(buffer) abort
    return '%e'
endfunction

function! ale_linters#rust#analyzer#GetProjectRoot(buffer) abort
    let l:cargo_file = ale#path#FindNearestFile(a:buffer, 'Cargo.toml')

    return !empty(l:cargo_file) ? fnamemodify(l:cargo_file, ':h') : ''
endfunction

call ale#linter#Define('rust', {
\   'name': 'rust-analyzer',
\   'lsp': 'stdio',
\   'lsp_config': {b -> ale#Var(b, 'rust_analyzer_config')},
\   'executable': {b -> ale#Var(b, 'rust_analyzer_executable')},
\   'command': function('ale_linters#rust#analyzer#GetCommand'),
\   'project_root': function('ale_linters#rust#analyzer#GetProjectRoot'),
\})

Make more names match up

" Author: Jon Gjengset <jon@thesquareplanet.com>
" Description: The next generation language server for Rust

call ale#Set('rust_analyzer_executable', 'ra_lsp_server')
call ale#Set('rust_analyzer_config', {})

function! ale_linters#rust#analyzer#GetCommand(buffer) abort
    return '%e'
endfunction

function! ale_linters#rust#analyzer#GetProjectRoot(buffer) abort
    let l:cargo_file = ale#path#FindNearestFile(a:buffer, 'Cargo.toml')

    return !empty(l:cargo_file) ? fnamemodify(l:cargo_file, ':h') : ''
endfunction

call ale#linter#Define('rust', {
\   'name': 'analyzer',
\   'lsp': 'stdio',
\   'lsp_config': {b -> ale#Var(b, 'rust_analyzer_config')},
\   'executable': {b -> ale#Var(b, 'rust_analyzer_executable')},
\   'command': function('ale_linters#rust#analyzer#GetCommand'),
\   'project_root': function('ale_linters#rust#analyzer#GetProjectRoot'),
\})


" from http://vimcasts.org/episodes/tidying-whitespace/
function! Preserve(command)
  " Preparation: save last search, and cursor position.
  let _s=@/
  let save_cursor = getpos('.')
  " Do the business:
  execute a:command
  " Clean up: restore previous search history, and cursor position
  let @/=_s
  call setpos('.', save_cursor)
endfunction

Refactor Preserve function based on Mathias Bynens

" from http://vimcasts.org/episodes/tidying-whitespace/
function! Preserve(command)
  " Preparation: save last search, and cursor position.
  let save_cursor = getpos('.')
  let last_search = getreg('/')
  " Do the business:
  execute a:command
  " Clean up: restore previous search history, and cursor position
  call setpos('.', save_cursor)
  call setreg('/', last_search)
endfunction


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

let s:String = s:Vital.import('Data.String')

function! omni_swift#complete(first, base)
    if a:first
        let s:context = {}
        let s:context.input_text = getline('.')[0:col('.') - 1]
        let s:context.complete_pos = s:decide_position(
        \   s:context.input_text,
        \   col('.') - 1,
        \)
        return s:context.complete_pos
    else
        let s:context.complete_str = a:base
        return s:complete(s:context)
    endif
endfunction

function! s:decide_position(input_text, cursor_pos)
    let l:complete_pos = match(
    \   a:input_text,
    \   autocomplete_swift#generate_keyword_pattern() . '$',
    \)

    if l:complete_pos != -1
        return l:complete_pos
    endif

    return a:cursor_pos
endfunction

function! s:complete(context)
    if a:context.complete_pos == 0 && a:context.complete_str ==# ''
        return []
    end

    let l:candidates = []

    for l:c in autocomplete_swift#complete(line('.'), a:context.complete_pos)
        if s:String.starts_with(l:c.word, a:context.complete_str) == 0
            continue
        end
        call add(l:candidates, l:c)
    endfor

    return l:candidates
endfunction

Remove a needless verification for precondition.

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

let s:String = s:Vital.import('Data.String')

function! omni_swift#complete(first, base)
    if a:first
        let s:context = {}
        let s:context.input_text = getline('.')[0:col('.') - 1]
        let s:context.complete_pos = s:decide_position(
        \   s:context.input_text,
        \   col('.') - 1,
        \)
        return s:context.complete_pos
    else
        let s:context.complete_str = a:base
        return s:complete(s:context)
    endif
endfunction

function! s:decide_position(input_text, cursor_pos)
    let l:complete_pos = match(
    \   a:input_text,
    \   autocomplete_swift#generate_keyword_pattern() . '$',
    \)

    if l:complete_pos != -1
        return l:complete_pos
    endif

    return a:cursor_pos
endfunction

function! s:complete(context)
    let l:candidates = []

    for l:c in autocomplete_swift#complete(line('.'), a:context.complete_pos)
        if s:String.starts_with(l:c.word, a:context.complete_str) == 0
            continue
        end
        call add(l:candidates, l:c)
    endfor

    return l:candidates
endfunction


" Author: Kazark
" Purpose: utility functions for kazarc plugin

function kazarc#SetTabWidthOptionsTo(width)
    let &tabstop=a:width
    let &shiftwidth=&tabstop
    let &softtabstop=&tabstop
endfunction

function kazarc#TurnOnFancySearchFeatures()
    set incsearch
    set hlsearch
endfunction

Switch file formating from dos to unix


function! LSP#filename() abort
    return expand('%:p')
endfunction

function! LSP#text(...) abort
    let l:buf = get(a:000, 0, '')

    let l:lines = getbufline(l:buf, 1, '$')
    if len(l:lines) > 0 && l:lines[-1] !=# '' && &fixendofline
        let l:lines += ['']
    endif
    return l:lines
endfunction

function! LSP#line() abort
    return line('.') - 1
endfunction

function! LSP#character() abort
    return col('.') - 1
endfunction

function! LSP#range_start_line() abort
    let l:lnum = v:lnum ? v:lnum : getpos("'<")[1]
    return l:lnum - 1
endfunction

function! LSP#range_end_line() abort
    if v:lnum
        return v:lnum - 1 + v:count
    endif

    return getpos("'>")[1]
endfunction

function! LSP#visible_line_start() abort
    return line('w0') - 1
endfunction

function! LSP#visible_line_end() abort
    return line('w$') - 1
endfunction

function! LSP#viewport() abort
    return {
        \ 'start': LSP#visible_line_start(),
        \ 'end': LSP#visible_line_end() + 1,
        \ }
endfunction

Use `<afile>` to get filename that autocommand is executed on.

function! LSP#filename() abort
    return expand('<afile>:p')
endfunction

function! LSP#text(...) abort
    let l:buf = get(a:000, 0, '')

    let l:lines = getbufline(l:buf, 1, '$')
    if len(l:lines) > 0 && l:lines[-1] !=# '' && &fixendofline
        let l:lines += ['']
    endif
    return l:lines
endfunction

function! LSP#line() abort
    return line('.') - 1
endfunction

function! LSP#character() abort
    return col('.') - 1
endfunction

function! LSP#range_start_line() abort
    let l:lnum = v:lnum ? v:lnum : getpos("'<")[1]
    return l:lnum - 1
endfunction

function! LSP#range_end_line() abort
    if v:lnum
        return v:lnum - 1 + v:count
    endif

    return getpos("'>")[1]
endfunction

function! LSP#visible_line_start() abort
    return line('w0') - 1
endfunction

function! LSP#visible_line_end() abort
    return line('w$') - 1
endfunction

function! LSP#viewport() abort
    return {
        \ 'start': LSP#visible_line_start(),
        \ 'end': LSP#visible_line_end() + 1,
        \ }
endfunction


let b:prettier_ft_default_args = {
  \ 'parser': 'yaml',
  \ }

augroup Prettier
  autocmd!
  autocmd BufWritePre *.yaml call prettier#Autoformat()
augroup end

Add missing ".yml" in autocmd

let b:prettier_ft_default_args = {
  \ 'parser': 'yaml',
  \ }

augroup Prettier
  autocmd!
  autocmd BufWritePre *.yml,*.yaml call prettier#Autoformat()
augroup end


let GetCompDB = function('CMakeCompDB')
let g:neomake_cmakecompdb_maker = {
    \ 'exe': 'GetCompDB',
    \ 'args': ['']
    \ }
noremap <unique> <Plug>NeomakeCompDB :Neomake! cmakecompdb<CR>
function CMakeTargets()
    echo "Get CMake Targets"
endfunction

Change funcref for neomake maker.

function! GetCompDB()
    exec CMakeCompDB()
endfunc
let g:neomake_cmakecompdb_maker = {
    \ 'exe': function('GetCompDB'),
    \ 'args': ['']
    \ }
noremap <unique> <Plug>NeomakeCompDB :Neomake! cmakecompdb<CR>
function CMakeTargets()
    echo "Get CMake Targets"
endfunction


if exists("b:vtd_extra_highlights")
  finish
endif

"syntax match doneItem '.*DONE.*'
"highlight link doneItem Ignore

"syntax region doneItem start=/\^\z(\s*\)\S.*DONE.*/ end=/write/
"syntax region doneItem start=/^\z(\s\+\)\S.*DONE/ end=/(^\z1\S)\@=/
"syntax region doneItem start='^\z(\s\+\)\S.*DONE' skip='^\z1\s.*$' end='^'
"syntax region doneItem start='^\z(\s*\).*DONE' skip='^\z1' end='^' skipnl
"highlight link doneItem Error

syntax region doneItem start='^\z(\s*\)\S.*DONE.*$' skip='^\z1\s' end='^'me=e-1
syntax region doneItem start='^\z(\s*\)\S.*WONTDO.*$' skip='^\z1\s' end='^'me=e-1
highlight link doneItem Ignore

let b:vtd_extra_highlights = 1

Clean up DONE/WONTDO syntax highlighting code

if exists("b:vtd_extra_highlights")
  finish
endif

"syntax match doneItem '.*DONE.*'
"highlight link doneItem Ignore

syntax region doneItem start='^\z(\s*\)\S.*DONE.*$' skip='^\z1\s' end='^'me=e-1
syntax region doneItem start='^\z(\s*\)\S.*WONTDO.*$' skip='^\z1\s' end='^'me=e-1
highlight link doneItem Ignore

let b:vtd_extra_highlights = 1


let s:save_cpo = &cpoptions
set cpoptions&vim

function! OmniSharp#actions#navigate#Down(...) abort
  if a:0 > 0
    let Callback = a:1
    call s:Navigate(1, Callback)
  else
    call s:Navigate(1)
  endif
endfunction

function! OmniSharp#actions#navigate#Up(...) abort
  if a:0 > 0
    let Callback = a:1
    call s:Navigate(0, Callback)
  else
    call s:Navigate(0)
  endif
endfunction

function! s:Navigate(down, ...) abort
  if g:OmniSharp_server_stdio
    let Callback = a:0 ? a:1 : function('s:NavigateRH')
    let opts = { 'ResponseHandler': Callback }
    call OmniSharp#stdio#Request(a:down ? '/navigatedown' : '/navigateup', opts)
  else
    call OmniSharp#py#Eval(a:down ? 'navigateDown()' : 'navigateUp()')
    call OmniSharp#py#CheckForError()
  endif
endfunction

function! s:NavigateRH(response) abort
  if !a:response.Success | return | endif
  normal! m'
  call cursor(a:response.Body.Line, a:response.Body.Column)
endfunction

let &cpoptions = s:save_cpo
unlet s:save_cpo

" vim:et:sw=2:sts=2

Refactor NavigateUp/Down to use standard locations

let s:save_cpo = &cpoptions
set cpoptions&vim

" Navigate to the next member definition in the class.
" Optional arguments:
" Callback: When a callback is passed in, it is called after the response is
"           returned with the member location. No navigation is performed when a
"           callback is passed in.
function! OmniSharp#actions#navigate#Down(...) abort
  call s:Navigate(1, a:0 ? a:1 : function('OmniSharp#locations#Navigate'))
endfunction

" See OmniSharp#actions#navigate#Down
function! OmniSharp#actions#navigate#Up(...) abort
  call s:Navigate(0, a:0 ? a:1 : function('OmniSharp#locations#Navigate'))
endfunction

function! s:Navigate(down, Callback) abort
  if g:OmniSharp_server_stdio
    let RH = function('s:StdioNavigateRH', [a:Callback])
    let opts = { 'ResponseHandler': RH }
    call OmniSharp#stdio#Request(a:down ? '/navigatedown' : '/navigateup', opts)
  else
    call OmniSharp#py#Eval(a:down ? 'navigateDown()' : 'navigateUp()')
    call OmniSharp#py#CheckForError()
  endif
endfunction

function! s:StdioNavigateRH(Callback, response) abort
  if !a:response.Success | return | endif
  call a:Callback(OmniSharp#locations#Parse([a:response.Body])[0])
endfunction

let &cpoptions = s:save_cpo
unlet s:save_cpo

" vim:et:sw=2:sts=2


let ignore_dirs = ['talks', 'out', '.cljs_rhino_repl', 'target', '.idea']
let ignore_file_exts = ['pack.js', 'min.css', 'min.js']

if executable('rg')
  " Use rg for denite
  " https://github.com/BurntSushi/ripgrep
  call denite#custom#var('grep', 'command', ['printargs.sh'])

  let rg_ignores = map(copy(ignore_file_exts), '"-g ''!*.".v:val."''"')
	\ + map(copy(ignore_dirs), '"-g ''!./".v:val."/**/*''"')

  call denite#custom#var('grep', 'default_opts',
			  \ ['rg', '--vimgrep', '--no-heading', '-i']
			  \ + rg_ignores)

  call denite#custom#var('grep', 'recursive_opts', [])
  call denite#custom#var('grep', 'final_opts', [])
  call denite#custom#var('grep', 'separator', ['--'])

  call denite#custom#var('file_rec', 'command', ['rg', '--files'] + rg_ignores)
endif

call denite#custom#option('default', 'prompt', ' ❯')

nnoremap <leader>d/ :Denite grep<CR>
nnoremap <leader>df :Denite file_rec<CR>
nnoremap <leader>db :Denite buffer<CR>

Fix denite / ripgrep combo

let ignore_dirs = ['talks', 'out', '.cljs_rhino_repl', 'target', '.idea']
let ignore_file_exts = ['pack.js', 'min.css', 'min.js']

if executable('rg')
  " Use rg for denite
  " https://github.com/BurntSushi/ripgrep
  call denite#custom#var('grep', 'command', ['rg'])

  let rg_ignores = map(copy(ignore_file_exts), '"!*.".v:val')
	\ + map(copy(ignore_dirs), '"!./".v:val."/**/*"')

  let rg_ignore_args = []
  for i in rg_ignores
    let rg_ignore_args = rg_ignore_args + ['-g', i]
  endfor

  call denite#custom#var('grep', 'default_opts',
			  \ ['--vimgrep', '--no-heading', '-i']
			  \ + rg_ignore_args)

  call denite#custom#var('grep', 'recursive_opts', [])
  call denite#custom#var('grep', 'final_opts', [])
  call denite#custom#var('grep', 'separator', ['--'])

  call denite#custom#var('file_rec', 'command', ['rg', '--files'] + rg_ignore_args)
endif

call denite#custom#option('default', 'prompt', ' ❯')

nnoremap <leader>d/ :Denite grep<CR>
nnoremap <leader>df :Denite file_rec<CR>
nnoremap <leader>db :Denite buffer<CR>


" http://vimcasts.org/episodes/soft-wrapping-text/
function! SetupWrapping()
  set wrap linebreak nolist
  set showbreak=…
endfunction

" TODO: this should happen automatically for certain file types (e.g. markdown)
command! -nargs=* Wrap :call SetupWrapping()<CR>

vmap <D-j> gj
vmap <D-k> gk
vmap <D-$> g$
vmap <D-^> g^
vmap <D-0> g^
nmap <D-j> gj
nmap <D-k> gk
nmap <D-$> g$
nmap <D-^> g^
nmap <D-0> g^

Add textwidth for *.md files

" http://vimcasts.org/episodes/soft-wrapping-text/
function! SetupWrapping()
  set wrap linebreak nolist
  set showbreak=…
endfunction

" TODO: this should happen automatically for certain file types (e.g. markdown)
command! -nargs=* Wrap :call SetupWrapping()<CR>

vmap <D-j> gj
vmap <D-k> gk
vmap <D-$> g$
vmap <D-^> g^
vmap <D-0> g^
nmap <D-j> gj
nmap <D-k> gk
nmap <D-$> g$
nmap <D-^> g^
nmap <D-0> g^

au BufRead,BufNewFile *.md setlocal textwidth=80


" ----------------------------------------
" Platform Specific Configuration
" ----------------------------------------

set shell=bash

let g:has_powerline_font = 0

let s:uname = system("uname -s")
if s:uname =~ "Darwin"
  let g:has_powerline_font = filereadable("/Library/Fonts/Meslo LG M Regular for Powerline.otf") || filereadable($HOME."/Library/Fonts/Meslo LG M Regular for Powerline.otf")
else
  let g:has_powerline_font = filereadable($HOME."/.fonts/Meslo LG M Regular for Powerline.otf") || filereadable("/usr/local/share/fonts/Meslo LG M Regular for Powerline.otf")
endif
# FIXME: neovim does not correctly render powerline fonts in airline
if g:has_powerline_font
  set guifont=Meslo\ LG\ M\ for\ Powerline:h12
elseif has('gui_running')
  set guifont=Monaco:h12
else
  set guifont=Monospace:h12
endif

Fix comment type to be vim

" ----------------------------------------
" Platform Specific Configuration
" ----------------------------------------

set shell=bash

let g:has_powerline_font = 0

let s:uname = system("uname -s")
if s:uname =~ "Darwin"
  let g:has_powerline_font = filereadable("/Library/Fonts/Meslo LG M Regular for Powerline.otf") || filereadable($HOME."/Library/Fonts/Meslo LG M Regular for Powerline.otf")
else
  let g:has_powerline_font = filereadable($HOME."/.fonts/Meslo LG M Regular for Powerline.otf") || filereadable("/usr/local/share/fonts/Meslo LG M Regular for Powerline.otf")
endif
" FIXME: neovim does not correctly render powerline fonts in airline
if g:has_powerline_font
  set guifont=Meslo\ LG\ M\ for\ Powerline:h12
elseif has('gui_running')
  set guifont=Monaco:h12
else
  set guifont=Monospace:h12
endif


" set a map leader for more key combos
let mapleader = ','
let g:mapleader = ','

" scroll the viewport faster
nnoremap <C-e> 3<C-e>
nnoremap <C-y> 3<C-y>

" scroll by visual lines
nnoremap <silent> j gj
nnoremap <silent> k gk

" window movement shortcuts
map <C-h> :call WinMove('h')<cr>
map <C-j> :call WinMove('j')<cr>
map <C-k> :call WinMove('k')<cr>
map <C-l> :call WinMove('l')<cr>

Add remap to disable search highlights

" set a map leader for more key combos
let mapleader = ','
let g:mapleader = ','

" scroll the viewport faster
nnoremap <C-e> 3<C-e>
nnoremap <C-y> 3<C-y>

" scroll by visual lines
nnoremap <silent> j gj
nnoremap <silent> k gk

" window movement shortcuts
map <C-h> :call WinMove('h')<cr>
map <C-j> :call WinMove('j')<cr>
map <C-k> :call WinMove('k')<cr>
map <C-l> :call WinMove('l')<cr>

" disable search highlights
nnoremap <silent> <CR> :nohlsearch<CR><CR>


" Configure UI {
  " Use 24bit colors
  if (has("termguicolors"))
    set termguicolors
  endif

  " Theming
  set background=dark                            " Use dark variant of theme
  let g:one_allow_italics = 1                    " Allow italics in comments etc.
  colorscheme one                                " Set theme

  " Misc settings
  set linespace=0                                " No extra spaces between rows
  set number                                     " Line numbers on
  set showmatch                                  " Show matching brackets/parenthesis
  set winminheight=0                             " Windows can be 0 line high
  set whichwrap=b,s,h,l,<,>,[,]                  " Backspace and cursor keys wrap too
  set list                                       " Display whitespace
  set listchars=tab:›\ ,trail:•,extends:#,nbsp:. " Set whitespace symbols
  set foldenable                                 " Enable code folding
  set cursorline                                 " Highlight current line

  " Status line
  set laststatus=2                               " Always show the status line

  " Search
  set incsearch                                  " Find as you type search
  set hlsearch                                   " Highlight search terms
  set ignorecase                                 " Case insensitive search
  set smartcase                                  " Case sensitive when uc present

  " Splits
  set splitright                                 " Puts new vsplit windows to the right of the current
  set splitbelow                                 " Puts new split windows to the bottom of the current

  " Completion
  set completeopt=menu
" }

Disable cursorline for better performance.

" Configure UI {
  " Use 24bit colors
  if (has("termguicolors"))
    set termguicolors
  endif

  " Theming
  set background=dark                            " Use dark variant of theme
  let g:one_allow_italics = 1                    " Allow italics in comments etc.
  colorscheme one                                " Set theme

  " Misc settings
  set linespace=0                                " No extra spaces between rows
  set number                                     " Line numbers on
  set showmatch                                  " Show matching brackets/parenthesis
  set winminheight=0                             " Windows can be 0 line high
  set whichwrap=b,s,h,l,<,>,[,]                  " Backspace and cursor keys wrap too
  set list                                       " Display whitespace
  set listchars=tab:›\ ,trail:•,extends:#,nbsp:. " Set whitespace symbols
  set foldenable                                 " Enable code folding
  set nocursorline                               " Highlight current line

  " Status line
  set laststatus=2                               " Always show the status line

  " Search
  set incsearch                                  " Find as you type search
  set hlsearch                                   " Highlight search terms
  set ignorecase                                 " Case insensitive search
  set smartcase                                  " Case sensitive when uc present

  " Splits
  set splitright                                 " Puts new vsplit windows to the right of the current
  set splitbelow                                 " Puts new split windows to the bottom of the current

  " Completion
  set completeopt=menu
" }


" Tagbar toggle
map <Leader>rt :!ctags --extra=+f -R *<CR><CR>

Add mappings for Tagbar. rt to toggle, rtt to refresh

" Refresh Ctags
map <Leader>rtt :!ctags --extra=+f -R *<CR><CR>
map <Leader>rt :TagbarToggle<CR><CR>


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

Revert "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
      \ -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


if exists("g:loaded_runner")
  finish
endif
let g:loaded_runner = 1

function! Run()
  let file = @%
  if &filetype == "java"
    echo system("javac " . file . " && java " . strpart(file, 0, strlen(file) - 5))
  elseif &filetype == "c"
    echo system("gcc " . file . " && ./a.out")
  elseif &filetype == "cpp"
    echo system("g++ " . file . " && ./a.out")
  elseif &filetype == "python"
    echo system("python " . file)
  elseif &filetype == "ruby"
    echo system("ruby " . file)
  endif
endfunction

command! -nargs=0 RunnerRun :call Run()

Add java classpath, compile and run in different directory

if exists("g:loaded_runner")
  finish
endif
let g:loaded_runner = 1

function! Run()
  let file = @%
  if &filetype == "java"
    let classpath = fnamemodify(file, ':h')
    let classname = fnamemodify(file, ':t:r')
    echo system("javac " . file . " && java -cp " . classpath . " " . classname)
  elseif &filetype == "c"
    echo system("gcc " . file . " && ./a.out")
  elseif &filetype == "cpp"
    echo system("g++ " . file . " && ./a.out")
  elseif &filetype == "python"
    echo system("python " . file)
  elseif &filetype == "ruby"
    echo system("ruby " . file)
  endif
endfunction

command! -nargs=0 RunnerRun :call Run()


MP 'rdnetto/YCM-Generator',  { 'on': ['YcmGenerateConfig', 'CCGenerateConfig'], 'branch': 'stable' }

function! BuildYCM(info)
    " info is a dictionary with 3 fields
    " - name:   name of the plugin
    " - status: 'installed', 'updated', or 'unchanged'
    " - force:  set on PlugInstall! or PlugUpdate!
    if a:info.status ==# 'installed' || a:info.force
        if !g:WINDOWS
            !./install.py --clang-completer
        else
            !python ./install.py --clang-completer
    endif
endfunction

if !g:WINDOWS
    MP 'Valloric/YouCompleteMe', { 'do': function('BuildYCM'), 'on': [] }
else
    MP 'Valloric/YouCompleteMe', { 'do': function('BuildYCM'), 'for': ['c', 'cpp', 'python', 'vim', 'js', 'go', 'sh'] }
endif

" Load YCM for specific filetypes
function! s:invoke_ycm()
    let l:supported = ['c', 'cpp', 'python', 'vim', 'js', 'go', 'sh']
    let l:cur_ft = &filetype
    if index(l:supported, l:cur_ft) > -1
        call plug#load('YouCompleteMe')
    endif
endfunction

augroup LOAD_YCM
    autocmd!
    if !g:WINDOWS
        autocmd InsertEnter * call s:invoke_ycm() | autocmd! LOAD_YCM
    endif
augroup END

Change the triger of ycmd.

MP 'rdnetto/YCM-Generator',  { 'on': ['YcmGenerateConfig', 'CCGenerateConfig'], 'branch': 'stable' }

function! BuildYCM(info)
    " info is a dictionary with 3 fields
    " - name:   name of the plugin
    " - status: 'installed', 'updated', or 'unchanged'
    " - force:  set on PlugInstall! or PlugUpdate!
    if a:info.status ==# 'installed' || a:info.force
        if !g:WINDOWS
            !./install.py --clang-completer
        else
            !python ./install.py --clang-completer
    endif
endfunction

MP 'Valloric/YouCompleteMe', { 'do': function('BuildYCM'), 'for': ['c', 'cpp', 'python', 'vim', 'js', 'go', 'sh'] }

" " Load YCM for specific filetypes
" function! s:invoke_ycm()
"     let l:supported = ['c', 'cpp', 'python', 'vim', 'js', 'go', 'sh']
"     let l:cur_ft = &filetype
"     if index(l:supported, l:cur_ft) > -1
"         call plug#load('YouCompleteMe')
"     endif
" endfunction
"
" augroup LOAD_YCM
"     autocmd!
"     if !g:WINDOWS
"         autocmd InsertEnter * call s:invoke_ycm() | autocmd! LOAD_YCM
"     endif
" augroup END


" Hide the vim splash screen
set shortmess+=I

" Set terminal title bar
set title

" Use hidden buffers
set hidden

" Don't wrap lines
set nowrap

" Let cursor keys wrap around lines
set whichwrap+=<,>,h,l,[,]

" Always show line numbers
set number

" Highlight right gutter at 80 characters
set colorcolumn=80

" Highlight the current cursor line
set cursorline

" Set show matching parenthesis
set showmatch

" Remove the noise in the vertical divider between splits
:set fillchars+=vert:\

" Limit completion popup menu height
set pumheight =15

" ==========================================
" Code folding

" Fold based on indent
set foldmethod=indent

" Set the deepest fold is 10 levels
set foldnestmax=10

" Don't fold code by default
set nofoldenable

Add dash to word characters

" Hide the vim splash screen
set shortmess+=I

" Set terminal title bar
set title

" Use hidden buffers
set hidden

" Don't wrap lines
set nowrap

" Let cursor keys wrap around lines
set whichwrap+=<,>,h,l,[,]

" Always show line numbers
set number

" Highlight right gutter at 80 characters
set colorcolumn=80

" Highlight the current cursor line
set cursorline

" Set show matching parenthesis
set showmatch

" Remove the noise in the vertical divider between splits
:set fillchars+=vert:\

" Limit completion popup menu height
set pumheight =15

" ==========================================
" Code folding

" Fold based on indent
set foldmethod=indent

" Set the deepest fold is 10 levels
set foldnestmax=10

" Don't fold code by default
set nofoldenable

" Set - as keyword so that ctags work correctly with dashed-method-names
set isk+=-


if exists("g:loaded_splitjoin") || &cp
  finish
endif

let g:loaded_splitjoin = 1 " version number
let s:keepcpo          = &cpo
set cpo&vim

" Public Interface:
" =================

command! SplitjoinSplit call s:Split()
command! SplitjoinJoin  call s:Join()

" Internal Functions:
" ===================

function! s:Split()
  if !exists('b:splitjoin_split_callbacks')
    return
  end

  " expand any folds under the cursor, or we might replace the wrong area
  normal! zo

  call sj#PushCursor()

  for callback in b:splitjoin_split_callbacks
    if call(callback, []) == 1
      break
    endif
  endfor

  call sj#PopCursor()
endfunction

function! s:Join()
  if !exists('b:splitjoin_join_callbacks')
    return
  end

  " expand any folds under the cursor, or we might replace the wrong area
  normal! zo

  call sj#PushCursor()

  for callback in b:splitjoin_join_callbacks
    if call(callback, []) == 1
      break
    endif
  endfor

  call sj#PopCursor()
endfunction

let &cpo = s:keepcpo
unlet s:keepcpo

Fix error when there's no fold under the cursor

if exists("g:loaded_splitjoin") || &cp
  finish
endif

let g:loaded_splitjoin = 1 " version number
let s:keepcpo          = &cpo
set cpo&vim

" Public Interface:
" =================

command! SplitjoinSplit call s:Split()
command! SplitjoinJoin  call s:Join()

" Internal Functions:
" ===================

function! s:Split()
  if !exists('b:splitjoin_split_callbacks')
    return
  end

  " expand any folds under the cursor, or we might replace the wrong area
  silent! foldopen

  call sj#PushCursor()

  for callback in b:splitjoin_split_callbacks
    if call(callback, []) == 1
      break
    endif
  endfor

  call sj#PopCursor()
endfunction

function! s:Join()
  if !exists('b:splitjoin_join_callbacks')
    return
  end

  " expand any folds under the cursor, or we might replace the wrong area
  silent! foldopen

  call sj#PushCursor()

  for callback in b:splitjoin_join_callbacks
    if call(callback, []) == 1
      break
    endif
  endfor

  call sj#PopCursor()
endfunction

let &cpo = s:keepcpo
unlet s:keepcpo


"============================================================================
"File:        eslint_d.vim
"Description: Javascript syntax checker - using eslint
"Maintainer:  Maximilian Antoni
"License:     MIT <https://github.com/mantoni/eslint_d.js/blob/master/LICENSE>
"============================================================================

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

let s:save_cpo = &cpo
set cpo&vim

function! SyntaxCheckers_javascript_eslint_d_IsAvailable() dict
    if executable(self.getExec())
        return 1
    endif
    return 0
endfunction

function! SyntaxCheckers_javascript_eslint_d_GetLocList() dict
    let makeprg = self.makeprgBuild({'fname_before': 'lint'})

    let errorformat =
        \ '%E%f: line %l\, col %c\, Error - %m,' .
        \ '%W%f: line %l\, col %c\, Warning - %m'

    let loclist = SyntasticMake({
        \ 'makeprg': makeprg,
        \ 'errorformat': errorformat})

    return loclist
endfunction

call g:SyntasticRegistry.CreateAndRegisterChecker({
    \ 'filetype': 'javascript',
    \ 'name': 'eslint_d'})

let &cpo = s:save_cpo
unlet s:save_cpo

" vim: set sw=4 sts=4 et fdm=marker:

Remove `lint` command and add `--format compact` option

"============================================================================
"File:        eslint_d.vim
"Description: Javascript syntax checker - using eslint
"Maintainer:  Maximilian Antoni
"License:     MIT <https://github.com/mantoni/eslint_d.js/blob/master/LICENSE>
"============================================================================

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

let s:save_cpo = &cpo
set cpo&vim

function! SyntaxCheckers_javascript_eslint_d_IsAvailable() dict
    if executable(self.getExec())
        return 1
    endif
    return 0
endfunction

function! SyntaxCheckers_javascript_eslint_d_GetLocList() dict
    let makeprg = self.makeprgBuild({'fname_before': '--format compact'})

    let errorformat =
        \ '%E%f: line %l\, col %c\, Error - %m,' .
        \ '%W%f: line %l\, col %c\, Warning - %m'

    let loclist = SyntasticMake({
        \ 'makeprg': makeprg,
        \ 'errorformat': errorformat})

    return loclist
endfunction

call g:SyntasticRegistry.CreateAndRegisterChecker({
    \ 'filetype': 'javascript',
    \ 'name': 'eslint_d'})

let &cpo = s:save_cpo
unlet s:save_cpo

" vim: set sw=4 sts=4 et fdm=marker:


" Set maximum terminal color space.
set t_Co=256

" Set promptline.vim theme.
let g:promptline_theme = 'airline'

" Set colorscheme.
if has('gui_running')
  let g:airline#extensions#tmuxline#enabled = 0
  let g:airline_theme = 'zenburn'
  let g:zenburn_high_Contrast = 1
  colorscheme zenburn
  set background=dark
else
  if empty($VIM_COLOR)
    let g:airline_theme = 'solarized'
    colorscheme solarized
  elseif $VIM_COLOR =~# "^base16-"
    let g:airline_theme = substitute($VIM_COLOR, '-', '_', '')
  endif

  if empty($VIM_BACKGROUND)
    set background=dark
  else
    if $VIM_BACKGROUND == 'light'
      set background=light
    else
      set background=dark
    endif
  endif
endif

" Set font.
if has('gui_running')
  set guifont=Inconsolata\-g\ 11
endif

Set Powerline font variant in gui

" Set maximum terminal color space.
set t_Co=256

" Set promptline.vim theme.
let g:promptline_theme = 'airline'

" Set colorscheme.
if has('gui_running')
  let g:airline#extensions#tmuxline#enabled = 0
  let g:airline_theme = 'zenburn'
  let g:zenburn_high_Contrast = 1
  colorscheme zenburn
  set background=dark
else
  if empty($VIM_COLOR)
    let g:airline_theme = 'solarized'
    colorscheme solarized
  elseif $VIM_COLOR =~# "^base16-"
    let g:airline_theme = substitute($VIM_COLOR, '-', '_', '')
  endif

  if empty($VIM_BACKGROUND)
    set background=dark
  else
    if $VIM_BACKGROUND == 'light'
      set background=light
    else
      set background=dark
    endif
  endif
endif

" Set font.
if has('gui_running')
  set guifont=Inconsolata\-g\ for\ Powerline\ 11
endif


" Copyright 2015 Charles R. Hogg III. All rights reserved.
"
" Licensed under the Apache License, Version 2.0 (the "License");
" you may not use this file except in compliance with the License.
" You may obtain a copy of the License at
"
"     http://www.apache.org/licenses/LICENSE-2.0
"
" Unless required by applicable law or agreed to in writing, software
" distributed under the License is distributed on an "AS IS" BASIS,
" WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
" See the License for the specific language governing permissions and
" limitations under the License.

" @section Mappings

""
" Quit the VTD view window.
nnoremap <silent> <buffer> Q :call vtd#view#Exit()<CR>
nmap <silent> <buffer> q Q

" @section Autocmds

augroup vtd_view
  autocmd!
  autocmd FocusLost,BufLeave,FocusGained,BufEnter,CursorHold
      \ <buffer> call vtd#view#Enter()
augroup END

Use cursorline in VTD view

" Copyright 2015 Charles R. Hogg III. All rights reserved.
"
" Licensed under the Apache License, Version 2.0 (the "License");
" you may not use this file except in compliance with the License.
" You may obtain a copy of the License at
"
"     http://www.apache.org/licenses/LICENSE-2.0
"
" Unless required by applicable law or agreed to in writing, software
" distributed under the License is distributed on an "AS IS" BASIS,
" WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
" See the License for the specific language governing permissions and
" limitations under the License.

setlocal cursorline

" @section Mappings

""
" Quit the VTD view window.
nnoremap <silent> <buffer> Q :call vtd#view#Exit()<CR>
nmap <silent> <buffer> q Q

" @section Autocmds

augroup vtd_view
  autocmd!
  autocmd FocusLost,BufLeave,FocusGained,BufEnter,CursorHold
      \ <buffer> call vtd#view#Enter()
augroup END


let g:yankring_history_file = '.yankring-history'
nnoremap <leader>yr :YRShow<CR>
nnoremap <C-y> :YRShow<CR>

Use only one mapping for a thing


" vimlatex macros
call IMAP('DDpart', '\frac{\partial <++>}{\partial <++>}<++>', 'tex')

" conceal
set cole=2
let g:tex_conceal= 'adgm'
hi Conceal      gui=BOLD        guibg=#1e1e27   guifg=#c080d0

Add FRFIG IMAP for fig float row

" vimlatex macros
call IMAP('DDpart', '\frac{\partial <++>}{\partial <++>}<++>', 'tex')
call IMAP('FRFIG', "\<C-r>=FloatRowFig(2)\<CR>", 'tex')

function! FloatRowFig(cols)
	let cols = a:cols
	let ffigbox =
		\ "\\ffigbox{\<CR>" .
		\ "\\caption{<+caption text+>}\<CR>" .
		\ "\\label{fig:<+label+>}\<CR>" .
		\ "}\<CR>" .
		\ "{\\includegraphics[width=".string(1.0/cols)."\\textwidth]{<+file+>}}\<CR>"

	let ffigboxes = ''
	for i in range(1,cols)
		let ffigboxes = ffigboxes . ffigbox
	endfor

	return IMAP_PutTextWithMovement(
		\ "\\begin{figure}[<+Hhtpb+>]\<CR>" .
		\ "\\begin{floatrow}\<CR>" .
		\ "\\centering\<CR>" .
		\ ffigboxes .
		\ "\\end{floatrow}\<CR>" .
		\ "\\end{figure}<++>"
		\ )
endfunction

" conceal
set cole=2
let g:tex_conceal= 'adgm'
hi Conceal      gui=BOLD        guibg=#1e1e27   guifg=#c080d0


set nocompatible
filetype off

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

Bundle 'gmarik/vundle'

" File Navigation
Bundle 'git://git.wincent.com/command-t.git'
Bundle 'scrooloose/nerdtree'
Bundle 'mileszs/ack.vim'

" Editing
Bundle 'MSch/delimitMate'
Bundle 'UltiSnips'
Bundle 'godlygeek/tabular'
Bundle 'scrooloose/syntastic'
Bundle 'tpope/vim-commentary'
Bundle 'tpope/vim-endwise'
Bundle 'tpope/vim-repeat'
Bundle 'tpope/vim-surround'

" File Specific
Bundle 'bbommarito/vim-slim'
Bundle 'tpope/vim-rails'
Bundle 'kana/vim-textobj-user'
Bundle 'kchmck/vim-coffee-script'
Bundle 'nelstrom/vim-textobj-rubyblock'
Bundle 'gregsexton/MatchTag'

" Looks
Bundle 'nathanaelkane/vim-indent-guides'
Bundle 'skalnik/vim-irblack'
Bundle 'Lokaltog/vim-powerline'

" Misc
Bundle 'scratch.vim'
Bundle 'tpope/vim-fugitive'
Bundle 'robgleeson/hammer.vim'

filetype plugin indent on

Add easy motion & markdown

set nocompatible
filetype off

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

Bundle 'gmarik/vundle'

" File Navigation
Bundle 'git://git.wincent.com/command-t.git'
Bundle 'scrooloose/nerdtree'
Bundle 'mileszs/ack.vim'

" Editing
Bundle "Lokaltog/vim-easymotion"
Bundle 'MSch/delimitMate'
Bundle 'UltiSnips'
Bundle 'godlygeek/tabular'
Bundle 'scrooloose/syntastic'
Bundle 'tpope/vim-commentary'
Bundle 'tpope/vim-endwise'
Bundle 'tpope/vim-repeat'
Bundle 'tpope/vim-surround'

" File Specific
Bundle 'bbommarito/vim-slim'
Bundle 'tpope/vim-rails'
Bundle 'kana/vim-textobj-user'
Bundle 'kchmck/vim-coffee-script'
Bundle 'nelstrom/vim-textobj-rubyblock'
Bundle 'gregsexton/MatchTag'
Bundle 'tpope/vim-markdown'

" Looks
Bundle 'nathanaelkane/vim-indent-guides'
Bundle 'skalnik/vim-irblack'
Bundle 'Lokaltog/vim-powerline'

" Misc
Bundle 'scratch.vim'
Bundle 'tpope/vim-fugitive'
Bundle 'robgleeson/hammer.vim'

filetype plugin indent on


if !exists('b:splitjoin_split_callbacks')
  let b:splitjoin_split_callbacks = [
        \ 'sj#js#SplitArray',
        \ 'sj#js#SplitObjectLiteral',
        \ 'sj#js#SplitFunction',
        \ 'sj#js#SplitOneLineIf',
        \ 'sj#js#SplitArgs'
        \ ]
endif

if !exists('b:splitjoin_join_callbacks')
  let b:splitjoin_join_callbacks = [
        \ 'sj#js#JoinArray',
        \ 'sj#js#JoinArgs',
        \ 'sj#js#JoinFunction',
        \ 'sj#js#JoinOneLineIf',
        \ 'sj#js#JoinObjectLiteral',
        \ ]
endif

Fix array splitting in javascript

if !exists('b:splitjoin_split_callbacks')
  let b:splitjoin_split_callbacks = [
        \ 'sj#js#SplitObjectLiteral',
        \ 'sj#js#SplitArray',
        \ 'sj#js#SplitFunction',
        \ 'sj#js#SplitOneLineIf',
        \ 'sj#js#SplitArgs'
        \ ]
endif

if !exists('b:splitjoin_join_callbacks')
  let b:splitjoin_join_callbacks = [
        \ 'sj#js#JoinArray',
        \ 'sj#js#JoinArgs',
        \ 'sj#js#JoinFunction',
        \ 'sj#js#JoinOneLineIf',
        \ 'sj#js#JoinObjectLiteral',
        \ ]
endif


" copy to system clipboard
nmap <C-c> <plug>YankLinePreserveCursorPosition
vmap <C-c> <plug>VisualModeYank

" paste from system clipboard
nmap <C-v> <plug>EasyClipPasteAfter
imap <C-v> <plug>EasyClipInsertModePaste
cmap <C-v> <plug>EasyClipCommandModePaste

" clipboard settings:
"   'unnamed'
"        When set, system text copied with 'CTRL-C' or 'selected text'is
"        pasted in VIM  using 'middle-click'. Vim text copied with 'CTRL-C' or
"        'selected text' is pasted in the system using 'middle-click'.
"
"   'unnamedplus'
"        When set, system text copied with 'CTRL-C' is pasted in Vim using
"        'CTRL-V' and system 'selected text' is pasted in Vim using
"        'middle-click'. Vim text copied with 'CTRL-C' is pasted in the system
"        using 'CTRL-V' or and 'selected text' in Vim is pasted in the system
"        using 'middle-click'.
if has("gui_macvim")
   set clipboard=unnamed
else
   set clipboard=unnamedplus
endif

" move cursor to end of paste
let g:EasyClipAlwaysMoveCursorToEndOfPaste=1

" share copies across instances
let g:EasyClipShareYanks=1

Add vim move line with shift-M

" copy to system clipboard
nmap <C-c> <plug>YankLinePreserveCursorPosition
vmap <C-c> <plug>VisualModeYank

" paste from system clipboard
nmap <C-v> <plug>EasyClipPasteAfter
imap <C-v> <plug>EasyClipInsertModePaste
cmap <C-v> <plug>EasyClipCommandModePaste

" move entire line, just like 'D' deletes entire line
nmap M <Plug>MoveMotionEndOfLinePlug

" clipboard settings:
"   'unnamed'
"        When set, system text copied with 'CTRL-C' or 'selected text'is
"        pasted in VIM  using 'middle-click'. Vim text copied with 'CTRL-C' or
"        'selected text' is pasted in the system using 'middle-click'.
"
"   'unnamedplus'
"        When set, system text copied with 'CTRL-C' is pasted in Vim using
"        'CTRL-V' and system 'selected text' is pasted in Vim using
"        'middle-click'. Vim text copied with 'CTRL-C' is pasted in the system
"        using 'CTRL-V' or and 'selected text' in Vim is pasted in the system
"        using 'middle-click'.
if has("gui_macvim")
   set clipboard=unnamed
else
   set clipboard=unnamedplus
endif

" move cursor to end of paste
let g:EasyClipAlwaysMoveCursorToEndOfPaste=1

" share copies across instances
let g:EasyClipShareYanks=1


" Auto open nerd tree on startup
let g:nerdtree_tabs_open_on_gui_startup = 1
" Focus in the main content window
let g:nerdtree_tabs_focus_on_files = 1

let g:nerdtree_tabs_synchronize_view = 0
let g:nerdtree_tabs_synchronize_focus = 0

let g:nerdtree_tabs_autofind = 1

Remove autofind for nerdtree tabs


" 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

Fix <c-l> hashrocket mapping to use inoremap

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


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

syntax enable
set background=dark
silent! colorscheme gruvbox

filetype plugin indent on

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

if has('termguicolors')
  set termguicolors
endif

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

Set leader key to space

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

let mapleader=' '

syntax enable
set background=dark
silent! colorscheme gruvbox

filetype plugin indent on

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

if has('termguicolors')
  set termguicolors
endif

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


"
" delimitMate configuration
"

" Autoclose brackets
let delimitMate_autoclose = 1

" Expand <CR> characters
let delimitMate_expand_cr = 2

" Expand <space> characters
let delimitMate_expand_space = 1

" Try to balance brackets on the current line
let delimitMate_balance_matchpairs = 1

" Enable smart quote handling
let delimitMate_smart_quotes = 1

" Enable smart brackets handling
let delimitMate_smart_matchpairs = 1

Disable auto close of brackets

"
" delimitMate configuration
"

" Autoclose brackets
let delimitMate_autoclose = 0

" Expand <CR> characters
let delimitMate_expand_cr = 2

" Expand <space> characters
let delimitMate_expand_space = 1

" Try to balance brackets on the current line
let delimitMate_balance_matchpairs = 1

" Enable smart quote handling
let delimitMate_smart_quotes = 1

" Enable smart brackets handling
let delimitMate_smart_matchpairs = 1


iab DATE <C-R>=strftime("%d. %b %y")<CR>
iab TIME <C-R>=strftime("%H:%M")<CR>

Add abbreviations to a bunch of useful stuff

" Inserting Dates and Times
iab Ydate <C-R>=strftime("%d-%b-%Y")<CR>
" Example: 16-Apr-2016

iab Ytime <C-R>=strftime("%H:%M")<CR>
" Example: 22:21

iab YDATE <C-R>=strftime("%a %b %d %T %Z %Y")<CR>
" Example: Sat Apr 16 22:20:24 WEST 2016

" The lower letter alphabet.
iab Yalpha abcdefghijklmnopqrstuvwxyz

" The upper letter alphabet.
iab YALPHA ABCDEFGHIJKLMNOPQRSTUVWXYZ

" The ten digits.
iab Ydigit 1234567890

" The sixteen digits of a hexadecimal system.
iab Yhex 1234567890ABCDEF


map <F7> Ofrom pdb import set_trace; set_trace(); # TODO<esc>
map <F8> Oimport traceback, sys; traceback.print_exception(*sys.exc_info()); # TODO<esc>

map <Leader>r :w\|:!python %:p<CR>

Kill traceback mapping for Python in Vim.

map <F7> Ofrom pdb import set_trace; set_trace(); # TODO<esc>

map <Leader>r :w\|:!python %:p<CR>


" FZF Setttings
" github.com/mike325/.vim

setlocal norelativenumber
setlocal nonumber
setlocal bufhidden=wipe

nnoremap <buffer><nowait> <ESC> :q!<CR>
tnoremap <buffer><nowait> <ESC> <ESC>:q!<CR>

Fix quick quit for FZF

" FZF Setttings
" github.com/mike325/.vim

setlocal norelativenumber
setlocal nonumber
setlocal bufhidden=wipe

nmap <buffer><nowait> <ESC> :q!<CR>
tmap <buffer><nowait> <ESC> <C-c>


let g:easytags_suppress_ctags_warning = 1

if filereadable(glob("~/.vim/tags"))
    let g:easytags_file = '~/.vim/tags'
endif

if isdirectory(glob("~/.vim/tags_by_filetype"))
    let g:easytags_by_filetype = '~/.vim/tags_by_filetype'
endif

"prevent automatically generating the tagfile and syntax highlighting tags (default: 0)
if !exists("g:disableautotags")
    let g:disableautotags = 0
endif

if (g:disableautotags == 1)
    let g:easytags_auto_update = 0
    let g:easytags_auto_highlight = 0
else
    let g:easytags_auto_update = 1
    let g:easytags_auto_highlight = 1
endif

Use /tmp for the ctags temporary directory if it exists

let g:easytags_suppress_ctags_warning = 1

"set the temporary directory for ctags
if isdirectory(glob("/tmp"))
    let $TMPDIR = '/tmp'
endif

"put general tags in ~/.vim/tags
if filereadable(glob("~/.vim/tags"))
    let g:easytags_file = '~/.vim/tags'
endif

"put filetype-specific tags in ~/.vim/tags_by_filetype/
if isdirectory(glob("~/.vim/tags_by_filetype"))
    let g:easytags_by_filetype = '~/.vim/tags_by_filetype'
endif

"prevent automatically generating the tagfile and syntax highlighting tags (default: 0)
if !exists("g:disableautotags")
    let g:disableautotags = 0
endif

if (g:disableautotags == 1)
    let g:easytags_auto_update = 0
    let g:easytags_auto_highlight = 0
else
    let g:easytags_auto_update = 1
    let g:easytags_auto_highlight = 1
endif


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

Fix key mapping for buffer tag fuzzy search

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


nnoremap <silent> <plug>(GrepperOperator) :set opfunc=grepper#operator<cr>g@
xnoremap <silent> <plug>(GrepperOperator) :<c-u>call grepper#operator(visualmode())<cr>

command! -nargs=* -bar -complete=file Grepper call grepper#parse_flags(<q-args>)

if hasmapto('<plug>(GrepperOperator)')
  silent! call repeat#set("\<plug>(GrepperOperator)", v:count)
endif

Add default commands :Ag, :Ack etc.

nnoremap <silent> <plug>(GrepperOperator) :set opfunc=grepper#operator<cr>g@
xnoremap <silent> <plug>(GrepperOperator) :<c-u>call grepper#operator(visualmode())<cr>

command! -nargs=* -bar -complete=file Grepper call grepper#parse_flags(<q-args>)

if hasmapto('<plug>(GrepperOperator)')
  silent! call repeat#set("\<plug>(GrepperOperator)", v:count)
endif

let cmds = [
      \ ['Ack',     'ack'    ],
      \ ['Ag',      'ag'     ],
      \ ['Findstr', 'findstr'],
      \ ['GG',      'git'    ],
      \ ['Grep',    'grep'   ],
      \ ['Pt',      'pt'     ],
      \ ['Sift',    'sift'   ],
      \ ]

for [cmd, tool] in cmds
  if exists(':'.cmd) != 2
    execute 'command! -nargs=* -complete=file' cmd
          \ 'Grepper -noprompt -tool' tool '-query <args>'
  endif
endfor


command! XcodebuildBuild call <sid>build()
command! XcodebuildTest call <sid>test()

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

function! s:build()
  let cmd = s:base_command()  . s:xcpretty()
  call s:run_command(cmd)
endfunction

function! s:test()
  let cmd =  s:base_command() . ' -sdk iphonesimulator test' . s:xcpretty()
  call s:run_command(cmd)
endfunction

function! s:run_command(cmd)
  execute '!' . a:cmd
endfunction

function! s:base_command()
  return 'xcodebuild ' . s:build_target() . ' ' . s:scheme()
endfunction

function! s:build_target()
  let xcworkspaceFile = glob('*.xcworkspace')
  if empty(xcworkspaceFile)
    return '-project ' . s:project_file()
  else
    return '-workspace ' . xcworkspaceFile
  endif
endfunction

function! s:project_file()
  return globpath(expand('.'), '*.xcodeproj')
endfunction

function! s:scheme()
  let scheme = "silent ! source " . s:plugin_path . "/bin/find_scheme.sh \"" . s:project_file() . "\""
  return '-scheme '. scheme
endfunction

function! s:xcpretty()
  if executable('xcpretty')
    return ' | xcpretty --color --test'
  else
    return ''
  endif
endfunction

Fix running of find_scheme command

command! XcodebuildBuild call <sid>build()
command! XcodebuildTest call <sid>test()

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

function! s:build()
  let cmd = s:base_command()  . s:xcpretty()
  call s:run_command(cmd)
endfunction

function! s:test()
  let cmd =  s:base_command() . ' -sdk iphonesimulator test' . s:xcpretty()
  call s:run_command(cmd)
endfunction

function! s:run_command(cmd)
  execute '!' . a:cmd
endfunction

function! s:base_command()
  return 'xcodebuild ' . s:build_target() . ' ' . s:scheme()
endfunction

function! s:build_target()
  let xcworkspaceFile = glob('*.xcworkspace')
  if empty(xcworkspaceFile)
    return '-project ' . s:project_file()
  else
    return '-workspace ' . xcworkspaceFile
  endif
endfunction

function! s:project_file()
  return globpath(expand('.'), '*.xcodeproj')
endfunction

function! s:scheme()
  let scheme = system("source " . s:plugin_path . "/bin/find_scheme.sh \"" . s:project_file() . "\"")
  return '-scheme '. scheme
endfunction

function! s:xcpretty()
  if executable('xcpretty')
    return ' | xcpretty --color --test'
  else
    return ''
  endif
endfunction


" ----------------------------------------------------------------------------
" Indentation
" ----------------------------------------------------------------------------
" Copy indent from current line when starting a new line
set autoindent

" Backspace deletes like most programs in insert mode
set backspace=indent,eol,start

" A <Tab> in front of a line inserts blanks according to 'shiftwidth'
set smarttab

" Tabs are spaces: shortcut for inserting 2 spaces
set expandtab

" Round indent to multiple of 'shiftwidth'
set shiftround

" Number of columns to use for text indenting
set shiftwidth=2

" Number of spaces in tab when editing
set softtabstop=2

" Number of visual spaces per TAB
set tabstop=2

" Fix code indentation
nnoremap <F7> mzgg=G`z

" Display extra whitespace.
set list
set listchars=tab:»·,trail:·,nbsp:·

" Ident like most editors do.
" Note: In insert mode, you can just use Ctrl-t and Ctrl-d to indent/dedent.
nnoremap <TAB> >>
nnoremap <S-TAB> <<
vnoremap <TAB> >gv
vnoremap <S-TAB> <gv

Make every wrapped line visually indented

" ----------------------------------------------------------------------------
" Indentation
" ----------------------------------------------------------------------------
" Copy indent from current line when starting a new line
set autoindent

" Backspace deletes like most programs in insert mode
set backspace=indent,eol,start

" A <Tab> in front of a line inserts blanks according to 'shiftwidth'
set smarttab

" Tabs are spaces: shortcut for inserting 2 spaces
set expandtab

" Round indent to multiple of 'shiftwidth'
set shiftround

" Number of columns to use for text indenting
set shiftwidth=2

" Number of spaces in tab when editing
set softtabstop=2

" Number of visual spaces per TAB
set tabstop=2

" Fix code indentation
nnoremap <F7> mzgg=G`z

" Display extra whitespace.
set list
set listchars=tab:»·,trail:·,nbsp:·

" Make every wrapped line visually indented.
set breakindent
let &showbreak = '››› '

" Ident like most editors do.
" Note: In insert mode, you can just use Ctrl-t and Ctrl-d to indent/dedent.
nnoremap <TAB> >>
nnoremap <S-TAB> <<
vnoremap <TAB> >gv
vnoremap <S-TAB> <gv


" Handle these cases:
" include_recipe 'current_cookbook::foo' => ./foo.rb
" include_recipe "#{cookbook_name}::foo" => ./foo.rb
" include_recipe 'apache2::ssl' => apache2/recipes/ssl.rb

" Make gf work on Chef include_recipe lines
" Add all cookbooks/*/recipe dirs to Vim's path variable
setlocal path+=.,**1/recipes;cookbooks,**1;cookbooks

" make this case work:
" include_recipe 'apache2' => apache2/recipes/default.rb
setlocal suffixesadd+=/recipes/default.rb

" TODO: Add Berkshelf support
" require 'berkshelf'
" cbs = Berkshelf.cookbook_store
" cbs.storage_path.to_path

Make gf on Chef recipe jump to cb in '~/.berkshelf'

" ftplugin/chef.vim
" Copyright 2013 Doug Ireton

" Licensed under the Apache License, Version 2.0 (the "License");
" you may not use this file except in compliance with the License.
" You may obtain a copy of the License at

"     http://www.apache.org/licenses/LICENSE-2.0

" Unless required by applicable law or agreed to in writing, software
" distributed under the License is distributed on an "AS IS" BASIS,
" WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
" See the License for the specific language governing permissions and
" limitations under the License.

" Handle these cases:
" include_recipe 'current_cookbook::foo' => ./foo.rb
" include_recipe "#{cookbook_name}::foo" => ./foo.rb
" include_recipe 'apache2::ssl' => apache2/recipes/ssl.rb

" Make gf work on Chef include_recipe lines
" Add all cookbooks/*/recipe dirs to Vim's path variable
setlocal path+=.,**1/recipes;cookbooks,**1;cookbooks

" Add Berkshelf cookbooks to the search path
" TODO: Make this work on Windows
if isdirectory($BERKSHELF_PATH . '/cookbooks')
  setlocal path+=$BERKSHELF_PATH/cookbooks/**1/recipes,$BERKSHELF_PATH/cookbooks/**1
elseif isdirectory($HOME . '/.berkshelf/cookbooks')
  setlocal path+=$HOME/.berkshelf/cookbooks/**1/recipes,$HOME/.berkshelf/cookbooks/**1
endif

" make this case work:
" include_recipe 'apache2' => apache2/recipes/default.rb
setlocal suffixesadd+=/recipes/default.rb


" Vim syntax file
" Language: MLIR

" quit when a syntax file was already loaded
if exists("b:current_syntax")
  finish
endif

syn keyword mlirType index i1 i2 i4 i8 i13 i16 i32 i64
      \ f16 f32 tf_control
syn keyword mlirType memref tensor vector

syntax keyword mlirKeywords extfunc cfgfunc mlfunc for to step return
syntax keyword mlirConditional if else

syn match mlirInt "-\=\<\d\+\>"
syn match mlirFloat "-\=\<\d\+\.\d\+\>"
syn match mlirMapOutline "#.*$"
syn match mlirOperator      "[+\-*=]"

syn region mlirComment start="//" skip="\\$" end="$"
syn region mlirString matchgroup=mlirString start=+"+ end=+"+

hi def link mlirComment      Comment
hi def link mlirKeywords     Statement
hi def link mlirInt          Constant
hi def link mlirType         Type
hi def link mlirMapOutline   PreProc
hi def link mlirConditional  Conditional
hi def link mlirString       String
hi def link mlirOperator     Operator
hi def link mlirInstruction  Operator
hi def link mlirAffineOp     Operator

let b:current_syntax = "mlir"

Update vim syntax file to highlight core ops

" Vim syntax file
" Language: MLIR

" quit when a syntax file was already loaded
if exists("b:current_syntax")
  finish
endif

syn keyword mlirType index i1 i2 i4 i8 i13 i16 i32 i64
      \ f16 f32 tf_control
syn keyword mlirType memref tensor vector

syntax keyword mlirKeywords extfunc cfgfunc mlfunc for to step return
syntax keyword mlirConditional if else
syntax keyword mlirCoreOps dim addf addi subf subi mulf muli cmpi select constant affine_apply call call_indirect extract_element getTensor memref_cast tensor_cast load store alloc dealloc dma_start dma_wait

syn match mlirInt "-\=\<\d\+\>"
syn match mlirFloat "-\=\<\d\+\.\d\+\>"
syn match mlirMapOutline "#.*$"
syn match mlirOperator      "[+\-*=]"

syn region mlirComment start="//" skip="\\$" end="$"
syn region mlirString matchgroup=mlirString start=+"+ end=+"+

hi def link mlirComment      Comment
hi def link mlirKeywords     Statement
hi def link mlirCoreOps      Statement
hi def link mlirInt          Constant
hi def link mlirType         Type
hi def link mlirMapOutline   PreProc
hi def link mlirConditional  Conditional
hi def link mlirString       String
hi def link mlirOperator     Operator
hi def link mlirInstruction  Operator
hi def link mlirAffineOp     Operator

let b:current_syntax = "mlir"


set background=dark
colorscheme molokai
set autoindent

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

"Show line numbers
set nu

" File types
au BufRead,BufNewFile *.thrift set filetype=thrift
autocmd FileType gitcommit DiffGitCached | wincmd L | wincmd h

"Extra highlighting settings
au InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
au InsertLeave * match ExtraWhitespace /\s\+$/
highlight ExtraWhiteSpace ctermbg=52
setlocal spell spelllang=en_gb
hi SpellBad term=reverse ctermfg=white ctermbg=darkred

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

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

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

Remove thrift file detection. This is done by the plugin now.

set background=dark
colorscheme molokai
set autoindent

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

"Show line numbers
set nu

" File types
autocmd FileType gitcommit DiffGitCached | wincmd L | wincmd h

"Extra highlighting settings
au InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
au InsertLeave * match ExtraWhitespace /\s\+$/
highlight ExtraWhiteSpace ctermbg=52
setlocal spell spelllang=en_gb
hi SpellBad term=reverse ctermfg=white ctermbg=darkred

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

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

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


let g:ale_emit_conflict_warnings = 0
let g:ale_linters = {
       \ 'javascript': ['eslint']
       \ }
let g:ale_set_quickfix = 0
let g:ale_statusline_format = ['⨉ %d', '⚠ %d', '⬥ ok']
let g:ale_sign_error = '⚠ '
let g:ale_sign_warning = '⨉'
let g:ale_echo_msg_format = '[%linter%] %s'

highlight clear ALEErrorSign
highlight clear ALEWarningSign

set updatetime=1000

autocmd BufEnter * set conceallevel=0
autocmd CursorHold * call ale#Lint()
autocmd CursorHoldI * call ale#Lint()
autocmd InsertLeave * call ale#Lint()
autocmd TextChanged * call ale#Lint()

let g:ale_lint_on_text_changed = 0

Remove `ALE` settings as it already set in thoughtbot


" File ~/.vim/ftplugin/js.vim

setlocal cindent
setlocal smartindent
setlocal autoindent
setlocal ts=2
setlocal shiftwidth=2

Use common settings in js config

" File ~/.vim/ftplugin/js.vim

source ~/.vim/ftplugin/all.vim

setlocal cindent
setlocal smartindent
setlocal autoindent
setlocal ts=2
setlocal shiftwidth=2


" ------ Golang Settings -------
set runtimepath+=$GOROOT/misc/vim
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_structs = 1

autocmd FileType go autocmd BufWritePre <buffer> Fmt
exe "set rtp+=".globpath($GOPATH, "src/github.com/nsf/gocode/vim")
"set completeopt=menu,preview
set completeopt=menuone

Change command fmt to GoFmt

" ------ Golang Settings -------
set runtimepath+=$GOROOT/misc/vim
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_structs = 1

autocmd FileType go autocmd BufWritePre <buffer> GoFmt
exe "set rtp+=".globpath($GOPATH, "src/github.com/nsf/gocode/vim")
"set completeopt=menu,preview
set completeopt=menuone


set encoding=utf8
set list

" Invisibles
set listchars=tab:▸\ ,eol:¬

" Enable true color support
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
set termguicolors

" Enable cursor shape switching
let $NVIM_TUI_ENABLE_CURSOR_SHAPE=1

" Syntax highlighting
set nowrap
set textwidth=0
syntax enable
set background=dark
colorscheme adventurous

let g:airline_theme="solarized"

Add new eol character for vim

set encoding=utf8
set list

" Invisibles
set listchars=tab:▸\ ,eol:⨼

" Enable true color support
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
set termguicolors

" Enable cursor shape switching
let $NVIM_TUI_ENABLE_CURSOR_SHAPE=1

" Syntax highlighting
set nowrap
set textwidth=0
syntax enable
set background=dark
colorscheme adventurous

let g:airline_theme="solarized"


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

Revert "ignore dotfiles in listing"


let g:startify_change_to_dir = 0

" Create custom projections {{{
augroup configure_projects
    autocmd!
    autocmd User ProjectionistActivate call s:custom_projections()
augroup END
function! s:custom_projections() abort
    let b:projections_test = projectionist#query('test')
    if len(b:projections_test) > 0
        nnoremap mt<CR> :execute "Dispatch ". b:projections_test[0][1]<CR>
        nnoremap mt<Space> :execute "Dispatch ". b:projections_test[0][1]
        nnoremap mt! :execute "Dispatch! ". b:projections_test[0][1]<CR>
    endif
    let b:projections_linters = projectionist#query('linters')
    if len(b:projections_linters) > 0
        let b:ale_linters = {&filetype: b:projections_linters[0][1]}
    endif
    let b:projections_fixers = projectionist#query('fixers')
    if len(b:projections_fixers) > 0
        let b:ale_fixers = {&filetype: b:projections_fixers[0][1]}
    endif
endfunction
" }}}

Add python as the default dispatch

let g:startify_change_to_dir = 0

" Create custom projections {{{
augroup configure_projects
    autocmd!
    autocmd User ProjectionistActivate call s:custom_projections()
augroup END
function! s:custom_projections() abort
    let b:projections_test = projectionist#query('test')
    if len(b:projections_test) > 0
        nnoremap mt<CR> :execute "Dispatch ". b:projections_test[0][1]<CR>
        nnoremap mt<Space> :execute "Dispatch ". b:projections_test[0][1]
        nnoremap mt! :execute "Dispatch! ". b:projections_test[0][1]<CR>
    endif
    let b:projections_linters = projectionist#query('linters')
    if len(b:projections_linters) > 0
        let b:ale_linters = {&filetype: b:projections_linters[0][1]}
    endif
    let b:projections_fixers = projectionist#query('fixers')
    if len(b:projections_fixers) > 0
        let b:ale_fixers = {&filetype: b:projections_fixers[0][1]}
    endif
endfunction
" }}}

autocmd FileType python let b:dispatch = 'python %'


" vim: ts=4 sw=4 et

function! neomake#makers#ft#elixir#EnabledMakers()
    return ['elixir']
endfunction

function! neomake#makers#ft#elixir#elixir()
    return {
        \ 'errorformat':
            \ '** %s %f:%l: %m,' .
            \ '%f:%l: warning: %m'
        \ }
endfunction

Add credo maker for Elixir

" vim: ts=4 sw=4 et

function! neomake#makers#ft#elixir#EnabledMakers()
    return ['elixir']
endfunction

function! neomake#makers#ft#elixir#elixir()
    return {
        \ 'errorformat':
            \ '** %s %f:%l: %m,' .
            \ '%f:%l: warning: %m'
        \ }
endfunction

function! neomake#makers#ft#elixir#credo()
    return {
      \ 'exe': 'mix',
      \ 'args': ['credo', 'list', '%:p', '--one-line', '-i', 'readability'],
      \ 'errorformat': '[%t] %. %f:%l:%c %m'
      \ }
endfunction


" File type detection is On.
filetype on

" C/C++, Java
autocmd FileType c,cpp,java setl cindent
autocmd FileType c,cpp,java setl expandtab tabstop=4 shiftwidth=4 softtabstop=4 shiftround

" JavaScript
autocmd FileType javascript setl autoindent
autocmd FileType javascript setl expandtab tabstop=4 shiftwidth=4 softtabstop=4 shiftround

" Ruby [2010-05-07]
autocmd FileType ruby setl smartindent
autocmd FileType ruby setl expandtab tabstop=2 shiftwidth=2 softtabstop=2 shiftround
autocmd FileType ruby inoremap # X#

" Python
autocmd FileType python setl smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class
autocmd FileType python setl expandtab tabstop=4 shiftwidth=4 softtabstop=4 shiftround
autocmd FileType python inoremap # X#

" HTML
autocmd FileType html setl autoindent
autocmd FileType html setl expandtab tabstop=2 shiftwidth=2 softtabstop=2 shiftround

Change the indent size settings for javascript filetype.

" File type detection is On.
filetype on

" C/C++, Java
autocmd FileType c,cpp,java setl cindent
autocmd FileType c,cpp,java setl expandtab tabstop=4 shiftwidth=4 softtabstop=4 shiftround

" JavaScript
autocmd FileType javascript setl autoindent
autocmd FileType javascript setl expandtab tabstop=2 shiftwidth=2 softtabstop=2 shiftround

" Ruby [2010-05-07]
autocmd FileType ruby setl smartindent
autocmd FileType ruby setl expandtab tabstop=2 shiftwidth=2 softtabstop=2 shiftround
autocmd FileType ruby inoremap # X#

" Python
autocmd FileType python setl smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class
autocmd FileType python setl expandtab tabstop=4 shiftwidth=4 softtabstop=4 shiftround
autocmd FileType python inoremap # X#

" HTML
autocmd FileType html setl autoindent
autocmd FileType html setl expandtab tabstop=2 shiftwidth=2 softtabstop=2 shiftround


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>

Fix redefinition error messages for UpdateTextwithVars

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>


" Turn on Solarized 256 colors if the terminal supports it.
" (Why Solarized doesn't do this properly on its own is unknown.)
if &t_Co == 256
  let g:solarized_termcolors=256
endif

set background=dark
colorscheme solarized

Switch to Tomorrow-Night color scheme by default

" Turn on Solarized 256 colors if the terminal supports it.
" (Why Solarized doesn't do this properly on its own is unknown.)
if &t_Co == 256
  let g:solarized_termcolors=256
endif

set background=dark
colorscheme Tomorrow-Night


set nocompatible
syntax enable

filetype on
filetype plugin on
filetype indent on
filetype plugin indent on

set colorcolumn=79
set number
set tabstop=8

set noswapfile
" Use y+ to copy to system clipboard
set clipboard+=unnamedplus

" Show command effects incrementally.
set inccommand=nosplit

" Load other vim configs.
for file in split(glob('~/.config/nvim/conf.d/*.vim'), '\n')
	exe 'source' file
endfor

Add note about nvim autoload

set nocompatible
syntax enable

filetype on
filetype plugin on
filetype indent on
filetype plugin indent on

set colorcolumn=79
set number
set tabstop=8

set noswapfile
" Use y+ to copy to system clipboard
set clipboard+=unnamedplus

" Show command effects incrementally.
set inccommand=nosplit

" Load other vim configs.
" NOTE: ~/.config/nvim/autoload could be used instead
for file in split(glob('~/.config/nvim/conf.d/*.vim'), '\n')
	exe 'source' file
endfor


" include_recipe 'apache2::ssl' => apache2/recipes/ssl.rb
" include_recipe 'apache2' => 'apache2/recipes/default.rb

" Make gf work on Chef include_recipe lines
" Add all cookbooks/*/recipe dirs to Vim's path variable
setlocal path+=.
" cookbooks/**1

" setlocal includeexpr=substitute(substitute(v:fname,'.*','\\0/recipes/default',''),'$','.rb','')

Fix includeexpr, path, isfname to improve 'gf' for include_recipes

" include_recipe 'current_cookbook::foo' => ./foo.rb
" include_recipe 'apache2::ssl' => apache2/recipes/ssl.rb
" include_recipe 'apache2' => 'apache2/recipes/default.rb

" Make gf work on Chef include_recipe lines
" Add all cookbooks/*/recipe dirs to Vim's path variable
setlocal path+=.;cookbooks

setlocal isfname+=:
setlocal includeexpr=substitute(substitute(v:fname,'::','/recipes/',''),'$','.rb','')

" Ruby's
" setlocal includeexpr=substitute(substitute(v:fname,'::','/recipes/default','g'),'$','.rb','')


" Diff open windows, specifying which windows by their number
"
" Ex: With 3 windows in the top row and 1 in the bottom, diff the top left and top right windows:
"   :DiffThese 1, 3
function! s:DiffThese(...)
  let windows = a:000
  if len(a:000) == 0
    " Default to diffing the top 3 windows (assuming vimdiff)
    let windows = [1, 2, 3]
  endif

  let start_i = winnr()
  windo diffthis | if index(windows, winnr()) == -1 | set nodiff | endif
  execute start_i . "wincmd w"
endfunction

command! -n=? -bar DiffThese :call s:DiffThese(<args>)
" Assume rebasing, where your changes are in the 3rd window and the master changes are in the 1st
command! -n=0 -bar DiffTheirs :call s:DiffThese(1,2)
command! -n=0 -bar DiffMine :call s:DiffThese(2,3)
command! -n=0 -bar DiffChanges :call s:DiffThese(1,3)
command! -n=0 -bar DiffAll :call s:DiffThese(1,2,3,4)
command! -n=0 -bar DiffOff diffoff!

Rename DiffTheirs & DiffMine to DiffLeft & DiffRight, and add DiffWith

" Diff open windows, specifying which windows by their number
"
" Ex: With 3 windows in the top row and 1 in the bottom, diff the top left and top right windows:
"   :DiffThese 1, 3
function! s:DiffThese(...)
  let windows = a:000
  if len(a:000) == 0
    " Default to diffing the top 3 windows (assuming vimdiff)
    let windows = [1, 2, 3]
  endif

  let start_i = winnr()
  windo diffthis | if index(windows, winnr()) == -1 | set nodiff | endif
  execute start_i . "wincmd w"
endfunction

command! -n=? -bar DiffThese :call s:DiffThese(<args>)
command! -n=0 -bar DiffLeft :call s:DiffThese(1,2)
command! -n=0 -bar DiffRight :call s:DiffThese(2,3)
command! -n=0 -bar DiffChanges :call s:DiffThese(1,3)
command! -n=0 -bar DiffAll :call s:DiffThese(1,2,3,4)
command! -n=1 -bar DiffWith :call s:DiffThese(winnr(), <args>)
command! -n=0 -bar DiffOff diffoff!