Further improved visual-execute
- Now also works in insert mode with <C-Space> (only current line) - Made vim.column more robust and added col alias
This commit is contained in:
parent
d36e470044
commit
3d427643bb
2 changed files with 15 additions and 6 deletions
13
lua/vim.moon
13
lua/vim.moon
|
@ -1,4 +1,4 @@
|
|||
--vim: set noexpandtab :miv--
|
||||
-- vim: set noexpandtab :miv --
|
||||
tree = (tab, level=0, skip="") ->
|
||||
if level==0
|
||||
print "┐"
|
||||
|
@ -6,7 +6,7 @@ tree = (tab, level=0, skip="") ->
|
|||
pre = (lvl, skip) ->
|
||||
for i=1,lvl
|
||||
if skip\sub(i,i) == "y"
|
||||
io.write " "
|
||||
io.write " "
|
||||
else
|
||||
io.write "│ "
|
||||
|
||||
|
@ -27,15 +27,18 @@ tree = (tab, level=0, skip="") ->
|
|||
|
||||
import max from math
|
||||
column = (col) ->
|
||||
if type(col)!="table" then col = {col}
|
||||
pad = (str, len) ->
|
||||
str..string.rep(" ", len-#str)
|
||||
width = 0
|
||||
for box in *col
|
||||
if type(box)!="table" then box = {box}
|
||||
for elem in *box
|
||||
width = max(width, #elem)
|
||||
|
||||
print "┌─"..string.rep("─",width).."─┐"
|
||||
for idx,box in ipairs(col)
|
||||
if type(box)!="table" then box={box}
|
||||
last = idx==#col
|
||||
for elem in *box
|
||||
io.write "│ "
|
||||
|
@ -58,4 +61,8 @@ draw = ->
|
|||
print table.concat(line, " ")
|
||||
|
||||
|
||||
{:tree, :column, :box, :draw}
|
||||
{
|
||||
:tree, :column, :box, :draw
|
||||
-- Aliases
|
||||
col: column
|
||||
}
|
||||
|
|
8
vimrc
8
vimrc
|
@ -409,14 +409,16 @@ noremap gk k
|
|||
nnoremap Y y$
|
||||
|
||||
" --- VISUAL EXECUTE ---
|
||||
vnoremap <C-CR> ""y<CR>
|
||||
\ :call setreg("\"", substitute(getreg("\""), "\n", "", ""), "v")<CR>
|
||||
\ :<C-r>"<CR>`<
|
||||
|
||||
let $LUA_PATH = $LUA_PATH.";".expand("<sfile>:p:h")."/lua/?.lua"
|
||||
let g:mooncompile = "!moonc ".expand("<sfile>:p:h")."/lua"
|
||||
command! Mooncompile silent exec g:mooncompile
|
||||
let g:exe_prg = "moonc -- | lua -l vim -"
|
||||
vnoremap <CR> :<C-U>exec "'<,'>!".g:exe_prg<CR>
|
||||
vnoremap <C-CR> ""y<CR>
|
||||
\ :call setreg("\"", substitute(getreg("\""), "\n", "", ""), "v")<CR>
|
||||
\ :<C-r>"<CR>`<
|
||||
inoremap <C-Space> <C-[>0v$:<C-U>exec "'<,'>!".g:exe_prg<CR>
|
||||
|
||||
" --- OTHER ---
|
||||
" Don't exit visual mode when "shifting"
|
||||
|
|
Loading…
Reference in a new issue