bec1b5c8a9b1

Shell shit in the vimrc
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Fri, 11 Sep 2015 14:11:46 +0000
parents 21a0c7224791
children 0f635ab417a7
branches/tags (none)
files vim/vimrc

Changes

--- a/vim/vimrc	Tue Sep 08 16:39:27 2015 +0000
+++ b/vim/vimrc	Fri Sep 11 14:11:46 2015 +0000
@@ -279,6 +279,10 @@
 " Kill window
 nnoremap K :q<cr>
 
+" Save
+nnoremap s :w<cr>
+nnoremap :w<cr> :call input("NOPE!")<cr>
+
 " Man
 nnoremap M K
 
@@ -1170,6 +1174,15 @@
 augroup END
 
 " }}}
+" Makefile {{{
+
+augroup ft_make
+    au!
+
+    au Filetype make setlocal shiftwidth=8
+augroup END
+
+" }}}
 " Markdown {{{
 
 augroup ft_markdown
@@ -1470,6 +1483,79 @@
 augroup END
 
 " }}}
+" Shell {{{
+
+function! OpenShellRepl() "{{{
+    NeoRepl fish
+endfunction "}}}
+function! SendShellLine() "{{{
+    let view = winsaveview()
+
+    execute "normal! ^vg_\<esc>"
+    call NeoReplSendSelection()
+
+    call winrestview(view)
+endfunction "}}}
+function! SendShellParagraph() "{{{
+    let view = winsaveview()
+
+    execute "normal! ^vip\<esc>"
+    call NeoReplSendSelection()
+
+    call winrestview(view)
+endfunction "}}}
+function! SendShellSelection() "{{{
+    let view = winsaveview()
+
+    normal! gv
+    call NeoReplSendSelection()
+
+    call winrestview(view)
+endfunction "}}}
+function! SendShellBuffer() "{{{
+    let view = winsaveview()
+
+    execute "normal! ggVG\<esc>"
+    call NeoReplSendSelection()
+
+    call winrestview(view)
+endfunction "}}}
+
+augroup ft_shell
+    au!
+
+    " Set up some basic neorepl mappings.
+    "
+    " key  desc                   mnemonic
+    " \o - connect neorepl        [o]pen repl
+    " \l - send current line      [l]ine
+    " \p - send current paragraph [p]aragraph
+    " \e - send selected hunk     [e]val
+    " \r - send entire file       [r]eload file
+    " \c - send ctrl-l            [c]lear
+
+    au FileType sh nnoremap <buffer> <silent> <localleader>o :call OpenShellRepl()<cr>
+
+    " Send the current line to the REPL
+    au FileType sh nnoremap <buffer> <silent> <localleader>l :call SendShellLine()<cr>
+
+    " Send the current paragraph to the REPL
+    au FileType sh nnoremap <buffer> <silent> <localleader>p :call SendShellParagraph()<cr>
+
+    " " Send the current top-level hunk to the REPL
+    " au FileType sh nnoremap <buffer> <silent> <localleader>e :call SendShellTopLevelHunk()<cr>
+
+    " Send the current selection to the REPL
+    au FileType sh vnoremap <buffer> <silent> <localleader>e :<c-u>call SendShellSelection()<cr>
+
+    " Send the entire buffer to the REPL ([r]eload)
+    au FileType sh nnoremap <buffer> <silent> <localleader>r :call SendShellBuffer()<cr>
+
+    " Clear the REPL
+    au FileType sh nnoremap <buffer> <silent> <localleader>c :call NeoReplSendRaw("")<cr>
+augroup END
+
+" }}}
 " Standard In {{{
 
 augroup ft_stdin