~gpanders/dotfiles

94d2080028b9b067d488e691bbc2308419488fe3 — Greg Anders 1 year, 10 months ago 27d2d10
Vim housekeeping
M vim/.vim/after/ftplugin/python.vim => vim/.vim/after/ftplugin/python.vim +15 -3
@@ 2,7 2,20 @@
let b:undo_ftplugin = get(b:, 'undo_ftplugin', '')

" gz opens a split window with a python shell
nmap <buffer> gz <Plug>(PytermOpen)
if !exists('g:pyterm_cmd')
  for s:cmd in ['ipython', 'python3', 'python']
    if executable(s:cmd)
      let g:pyterm_cmd = s:cmd
      break
    endif
  endfor
  unlet s:cmd
endif

if exists('g:pyterm_cmd')
  nnoremap <silent> <buffer> gz :<C-U>call easyterm#open(g:pyterm_cmd)<CR>
  let b:undo_ftplugin .= '|nun <buffer> gz'
endif

" Set textwidth to 88 to mimic black
setlocal textwidth=88


@@ 17,8 30,7 @@ setlocal foldnestmax=2
let b:undo_ftplugin .= '|setl tw< fo< fdm< fdn<'

" Try to infer python version from shebang
let s:line1 = getline(1)
let s:python = matchstr(s:line1, 'python\([23]\)\?')
let s:python = matchstr(getline(1), '^#!.*\zspython\([23]\)\?')

" Populate path from python's sys.path
call ft#python#set_path(s:python)

M vim/.vim/after/plugin/abolish.vim => vim/.vim/after/plugin/abolish.vim +1 -1
@@ 2,7 2,7 @@
" Author: Greg Anders <greg@gpanders.com>
" Date: 2019-03-04

if !get(g:, 'loaded_abolish', 0)
if !get(g:, 'loaded_abolish')
  finish
endif


M vim/.vim/after/plugin/ale.vim => vim/.vim/after/plugin/ale.vim +1 -1
@@ 6,7 6,7 @@
let s:save_cpo = &cpo
set cpo&vim

if !get(g:, 'loaded_ale', 0)
if !get(g:, 'loaded_ale')
  finish
endif


M vim/.vim/after/plugin/coc.vim => vim/.vim/after/plugin/coc.vim +1 -1
@@ 2,7 2,7 @@
" Author: Greg Anders <greg@gpanders.com>
" Date: 2019-01-04

if !get(g:, 'did_coc_loaded', 0) || !has('nvim')
if !get(g:, 'did_coc_loaded') || !has('nvim')
  finish
endif


M vim/.vim/after/plugin/dirvish.vim => vim/.vim/after/plugin/dirvish.vim +1 -1
@@ 2,7 2,7 @@
" Author: Greg Anders <greg@gpanders.com>
" Date: 2018-12-06

if !get(g:, 'loaded_dirvish', 0)
if !get(g:, 'loaded_dirvish')
  unlet g:loaded_netrwPlugin
  runtime plugin/netrwPlugin.vim
  finish

M vim/.vim/after/plugin/dispatch.vim => vim/.vim/after/plugin/dispatch.vim +1 -1
@@ 2,7 2,7 @@
" Author: Greg Anders <greg@gpanders.com>
" Date: 2018-12-03

if !get(g:, 'loaded_dispatch', 0)
if !get(g:, 'loaded_dispatch')
  finish
endif


M vim/.vim/after/plugin/easyalign.vim => vim/.vim/after/plugin/easyalign.vim +1 -1
@@ 2,7 2,7 @@
" Author: Greg Anders <greg@gpanders.com>
" Date: 2019-02-28

if !get(g:, 'loaded_easy_align_plugin', 0)
if !get(g:, 'loaded_easy_align_plugin')
  finish
endif


M vim/.vim/after/plugin/fugitive.vim => vim/.vim/after/plugin/fugitive.vim +1 -1
@@ 2,7 2,7 @@
" Author: Greg Anders <greg@gpanders.com>
" Date: 2018-12-03

if !get(g:, 'loaded_fugitive', 0)
if !get(g:, 'loaded_fugitive')
  finish
endif


M vim/.vim/after/plugin/fzf.vim => vim/.vim/after/plugin/fzf.vim +2 -2
@@ 2,12 2,12 @@
" Author: Greg Anders <greg@gpanders.com>

" Check for local installation if not already loaded
if !get(g:, 'loaded_fzf', 0) && isdirectory($HOME . '/.fzf')
if !get(g:, 'loaded_fzf') && isdirectory($HOME . '/.fzf')
  silent! source ~/.fzf/plugin/fzf.vim
endif

" If fzf is still not found, give up
if !get(g:, 'loaded_fzf', 0)
if !get(g:, 'loaded_fzf')
  finish
endif


M vim/.vim/after/plugin/gutentags.vim => vim/.vim/after/plugin/gutentags.vim +1 -1
@@ 2,7 2,7 @@
" Author: Greg Anders <greg@gpanders.com>
" Date: 2018-12-03

if !get(g:, 'loaded_gutentags', 0)
if !get(g:, 'loaded_gutentags')
  finish
endif


D vim/.vim/after/plugin/oldfiles.vim => vim/.vim/after/plugin/oldfiles.vim +0 -19
@@ 1,19 0,0 @@
" oldfiles.vim configuration
" Author: Greg Anders <greg@gpanders.com>
" Date: 2019-02-28

let s:save_cpo = &cpo
set cpo&vim

if !get(g:, 'loaded_oldfiles', 0)
  finish
endif

let g:oldfiles_blacklist = [
      \ 'vim/.*/doc/.\+\.txt$',
      \ '^fugitive://',
      \ '/\.git/.*'
      \ ]

let &cpo = s:save_cpo
unlet s:save_cpo

M vim/.vim/after/plugin/signify.vim => vim/.vim/after/plugin/signify.vim +1 -1
@@ 2,7 2,7 @@
" Author: Greg Anders <greg@gpanders.com>
" Date: 2019-05-30

if !get(g:, 'loaded_signify', 0)
if !get(g:, 'loaded_signify')
  finish
endif


M vim/.vim/after/plugin/sneak.vim => vim/.vim/after/plugin/sneak.vim +1 -1
@@ 2,6 2,6 @@
" Author: Greg Anders <greg@gpanders.com>
" Date: 2018-12-03

if !get(g:, 'loaded_sneak_plugin', 0)
if !get(g:, 'loaded_sneak_plugin')
  finish
endif

M vim/.vim/after/plugin/toggle_bg.vim => vim/.vim/after/plugin/toggle_bg.vim +2 -2
@@ 2,11 2,11 @@
" Author: Greg Anders <greg@gpanders.com>
" Date: 2019-03-27

if !exists('g:loaded_toggle_bg')
if !get(g:, 'loaded_toggle_bg')
  finish
endif

let g:toggle_bg_dark = 'base16-eighties'
let g:toggle_bg_light = 'base16-solarized-light'

nnoremap <silent> <F5> :ToggleBg<CR>
nnoremap <silent> <F5> :<C-U>ToggleBg<CR>

M vim/.vim/after/plugin/ultisnips.vim => vim/.vim/after/plugin/ultisnips.vim +1 -1
@@ 2,7 2,7 @@
" Author: Greg Anders <greg@gpanders.com>
" Date: 2019-02-27

if !get(g:, 'did_plugin_ultisnips', 0)
if !get(g:, 'did_plugin_ultisnips')
  finish
endif


M vim/.vim/autoload/cursorline.vim => vim/.vim/autoload/cursorline.vim +2 -2
@@ 1,10 1,10 @@
function! cursorline#toggle(enable)
  if a:enable
    if index(g:cursorline_blacklist, &ft) < 0 && exists('b:cul')
    if index(get(g:, 'cursorline_blacklist', []), &ft) < 0 && exists('b:cul')
      let &l:cursorline = b:cul
    endif
  else
    if index(g:cursorline_blacklist, &ft) < 0
    if index(get(g:, 'cursorline_blacklist', []), &ft) < 0
      let b:cul = &l:cursorline
      let &l:cursorline = 0
    endif

R vim/.vim/autoload/pyterm.vim => vim/.vim/autoload/easyterm.vim +19 -20
@@ 1,31 1,30 @@
function pyterm#open(...)
" Re-use a terminal buffer window for the same command
" Author: Greg Anders

" Create a terminal buffer using `cmd` as the command to start and an optional
" name as the second argument. If this function is called again with the same
" `cmd` / `name` argument, re-open the existing buffer instead of creating
" another new buffer. This is useful for terminal buffers that should persist
" (e.g. REPLs)
function easyterm#open(cmd, ...)
  if a:0 && !empty(a:1)
    let name = a:1
  else
    let name = a:cmd
  endif

  let buf = filter(range(1, bufnr('$')),
        \ 'bufexists(v:val) && getbufvar(v:val, "pyterm", 0)')
        \ 'bufexists(v:val) && getbufvar(v:val, "' . name . '", 0)')
  let height = winheight(0) / 3
  if empty(buf)
    " No buffer yet, so start a new one
    if a:0
      let pyprog = a:1
    elseif executable('ipython')
      let pyprog = 'ipython'
    elseif executable('python')
      let pyprog = 'python'
    elseif executable('python3')
      let pyprog = 'python3'
    elseif executable('python2')
      let pyprog = 'python2'
    endif

    if has('nvim')
      execute 'botright ' . height . 'sp | term ' . pyprog
      autocmd BufEnter <buffer> startinsert
      execute 'botright ' . height . 'sp | term ' . a:cmd
    else
      execute 'botright term ' . pyprog
      execute 'botright term ' . a:cmd
      execute 'resize ' . height
      autocmd BufEnter <buffer> normal i
    endif
    setlocal nonumber nobuflisted
    let b:pyterm = 1
    let b:{name} = 1
  else
    " Buffer already exists
    let bufinfo = getbufinfo(buf[0])[0]

A vim/.vim/autoload/toggle_bg.vim => vim/.vim/autoload/toggle_bg.vim +25 -0
@@ 0,0 1,25 @@
" See :h xterm-true-color
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"

function! toggle_bg#toggle()
  if exists('g:toggle_bg_dark') && exists('g:toggle_bg_light')
    if !&termguicolors
      set termguicolors
    endif

    if g:colors_name ==# g:toggle_bg_dark
      execute 'colorscheme' g:toggle_bg_light
    else
      execute 'colorscheme' g:toggle_bg_dark
    endif
  else
    " If no colorschemes are defined then just toggle the bg setting
    if &bg ==# 'dark'
      set bg=light
    else
      set bg=dark
    endif
  endif
endfunction


D vim/.vim/plugin/pyterm.vim => vim/.vim/plugin/pyterm.vim +0 -12
@@ 1,12 0,0 @@
" Create an interactive Python terminal in vim
" Author: Greg Anders <greg@gpanders.com>
" Date: 2018-12-19

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

command -nargs=? Pyterm call pyterm#open(<f-args>)

nnoremap <silent> <Plug>(PytermOpen) :<C-U>Pyterm<CR>

M vim/.vim/plugin/toggle_bg.vim => vim/.vim/plugin/toggle_bg.vim +1 -22
@@ 7,25 7,4 @@ if exists('g:loaded_toggle_bg') || !(has('termguicolors') || has('gui'))
endif
let g:loaded_toggle_bg = 1

function! s:toggle_bg()
  if exists('g:toggle_bg_dark') && exists('g:toggle_bg_light')
    if !&termguicolors
      set termguicolors
    endif

    if g:colors_name ==# g:toggle_bg_dark
      execute 'colorscheme' g:toggle_bg_light
    else
      execute 'colorscheme' g:toggle_bg_dark
    endif
  else
    " If no colorschemes are defined then just toggle the bg setting
    if &bg ==# 'dark'
      set bg=light
    else
      set bg=dark
    endif
  endif
endfunction

command! -nargs=0 ToggleBg call s:toggle_bg()
command! -nargs=0 ToggleBg call toggle_bg#toggle()

M vim/.vim/vimrc => vim/.vim/vimrc +2 -1
@@ 96,6 96,7 @@ endif
set backup
set completeopt^=menuone
set confirm
set cursorline
set define=
set expandtab
set hidden


@@ 340,7 341,7 @@ xnoremap # y?\V<C-R>"<CR>

" Make neovim terminal behave like the vim terminal
if has('nvim')
  tnoremap <C-W><C-W> <C-\><C-N><C-W><C-W>
  tnoremap <C-W> <C-\><C-N><C-W>
  tnoremap <C-W>: <C-\><C-N>:
  tnoremap <C-W>. <C-W>
  tnoremap <C-W><C-\> <C-\>