Browse Source

Add simple math vim mapping, Update files

`<Leader>m` evaluates the current line with the expression register and
appends the result with an `=`.
Weiyi Lou 9 years ago
parent
commit
a705e95d93
3 changed files with 54 additions and 20 deletions
  1. 22 0
      shell/zsh/completions/_tmuxinator
  2. 28 20
      vim/autoload/plug.vim
  3. 4 0
      vim/vimrc

+ 22 - 0
shell/zsh/completions/_tmuxinator

@@ -1,5 +1,27 @@
 #compdef tmuxinator mux
 # ------------------------------------------------------------------------------
+# Copyright (c) 2010-2016 Christopher Chow
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+# ------------------------------------------------------------------------------
+#
 # Description
 # -----------
 #

+ 28 - 20
vim/autoload/plug.vim

@@ -397,7 +397,20 @@ function! s:reorg_rtp()
 endfunction
 
 function! s:doautocmd(...)
-  execute 'doautocmd' ((v:version > 703 || has('patch442')) ? '<nomodeline>' : '') join(a:000)
+  if exists('#'.join(a:000, '#'))
+    execute 'doautocmd' ((v:version > 703 || has('patch442')) ? '<nomodeline>' : '') join(a:000)
+  endif
+endfunction
+
+function! s:dobufread(names)
+  for name in a:names
+    let path = s:rtp(g:plugs[name]).'/**'
+    for dir in ['ftdetect', 'ftplugin']
+      if len(finddir(dir, path))
+        return s:doautocmd('BufRead')
+      endif
+    endfor
+  endfor
 endfunction
 
 function! plug#load(...)
@@ -415,9 +428,7 @@ function! plug#load(...)
   for name in a:000
     call s:lod([name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
   endfor
-  if exists('#BufRead')
-    doautocmd BufRead
-  endif
+  call s:dobufread(a:000)
   return 1
 endfunction
 
@@ -453,9 +464,7 @@ function! s:lod(names, types, ...)
       endif
       call s:source(rtp, a:2)
     endif
-    if exists('#User#'.name)
-      call s:doautocmd('User', name)
-    endif
+    call s:doautocmd('User', name)
   endfor
 endfunction
 
@@ -463,21 +472,19 @@ function! s:lod_ft(pat, names)
   let syn = 'syntax/'.a:pat.'.vim'
   call s:lod(a:names, ['plugin', 'after/plugin'], syn, 'after/'.syn)
   execute 'autocmd! PlugLOD FileType' a:pat
-  if exists('#filetypeplugin#FileType')
-    doautocmd filetypeplugin FileType
-  endif
-  if exists('#filetypeindent#FileType')
-    doautocmd filetypeindent FileType
-  endif
+  call s:doautocmd('filetypeplugin', 'FileType')
+  call s:doautocmd('filetypeindent', 'FileType')
 endfunction
 
 function! s:lod_cmd(cmd, bang, l1, l2, args, names)
   call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
+  call s:dobufread(a:names)
   execute printf('%s%s%s %s', (a:l1 == a:l2 ? '' : (a:l1.','.a:l2)), a:cmd, a:bang, a:args)
 endfunction
 
 function! s:lod_map(map, names, prefix)
   call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin'])
+  call s:dobufread(a:names)
   let extra = ''
   while 1
     let c = getchar(0)
@@ -846,13 +853,14 @@ function! s:names(...)
 endfunction
 
 function! s:check_ruby()
-  silent! ruby require 'thread'; VIM::command('let g:plug_ruby = 1')
-  if get(g:, 'plug_ruby', 0)
-    unlet g:plug_ruby
-    return 1
-  endif
-  redraw!
-  return s:warn('echom', 'Warning: Ruby interface is broken')
+  silent! ruby require 'thread'; VIM::command("let g:plug_ruby = '#{RUBY_VERSION}'")
+  if !exists('g:plug_ruby')
+    redraw!
+    return s:warn('echom', 'Warning: Ruby interface is broken')
+  endif
+  let ruby_version = split(g:plug_ruby, '\.')
+  unlet g:plug_ruby
+  return s:version_requirement(ruby_version, [1, 8, 7])
 endfunction
 
 function! s:update_impl(pull, force, args) abort

+ 4 - 0
vim/vimrc

@@ -236,6 +236,10 @@ map <leader>s :source $MYVIMRC<CR>:echo "vimrc reloaded..."<CR>
 
   " Search for version control conflict markers
   map <Leader>c /\v^[<\|=>]{7}( .*\|$)<CR>
+
+  " Do math on the current line.
+  map <silent> <Leader>m :exe "normal 0f=d$"<CR>0y$A=<C-r>=<C-r>"<CR><Esc>
+  "map <silent> <Leader>m yyp:.!bc<CR>
   " }}}
 " }}}