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
11
lua/vim.moon
11
lua/vim.moon
|
@ -1,4 +1,4 @@
|
||||||
--vim: set noexpandtab :miv--
|
-- vim: set noexpandtab :miv --
|
||||||
tree = (tab, level=0, skip="") ->
|
tree = (tab, level=0, skip="") ->
|
||||||
if level==0
|
if level==0
|
||||||
print "┐"
|
print "┐"
|
||||||
|
@ -27,15 +27,18 @@ tree = (tab, level=0, skip="") ->
|
||||||
|
|
||||||
import max from math
|
import max from math
|
||||||
column = (col) ->
|
column = (col) ->
|
||||||
|
if type(col)!="table" then col = {col}
|
||||||
pad = (str, len) ->
|
pad = (str, len) ->
|
||||||
str..string.rep(" ", len-#str)
|
str..string.rep(" ", len-#str)
|
||||||
width = 0
|
width = 0
|
||||||
for box in *col
|
for box in *col
|
||||||
|
if type(box)!="table" then box = {box}
|
||||||
for elem in *box
|
for elem in *box
|
||||||
width = max(width, #elem)
|
width = max(width, #elem)
|
||||||
|
|
||||||
print "┌─"..string.rep("─",width).."─┐"
|
print "┌─"..string.rep("─",width).."─┐"
|
||||||
for idx,box in ipairs(col)
|
for idx,box in ipairs(col)
|
||||||
|
if type(box)!="table" then box={box}
|
||||||
last = idx==#col
|
last = idx==#col
|
||||||
for elem in *box
|
for elem in *box
|
||||||
io.write "│ "
|
io.write "│ "
|
||||||
|
@ -58,4 +61,8 @@ draw = ->
|
||||||
print table.concat(line, " ")
|
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$
|
nnoremap Y y$
|
||||||
|
|
||||||
" --- VISUAL EXECUTE ---
|
" --- 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 $LUA_PATH = $LUA_PATH.";".expand("<sfile>:p:h")."/lua/?.lua"
|
||||||
let g:mooncompile = "!moonc ".expand("<sfile>:p:h")."/lua"
|
let g:mooncompile = "!moonc ".expand("<sfile>:p:h")."/lua"
|
||||||
command! Mooncompile silent exec g:mooncompile
|
command! Mooncompile silent exec g:mooncompile
|
||||||
let g:exe_prg = "moonc -- | lua -l vim -"
|
let g:exe_prg = "moonc -- | lua -l vim -"
|
||||||
vnoremap <CR> :<C-U>exec "'<,'>!".g:exe_prg<CR>
|
vnoremap <CR> :<C-U>exec "'<,'>!".g:exe_prg<CR>
|
||||||
vnoremap <C-CR> ""y<CR>
|
inoremap <C-Space> <C-[>0v$:<C-U>exec "'<,'>!".g:exe_prg<CR>
|
||||||
\ :call setreg("\"", substitute(getreg("\""), "\n", "", ""), "v")<CR>
|
|
||||||
\ :<C-r>"<CR>`<
|
|
||||||
|
|
||||||
" --- OTHER ---
|
" --- OTHER ---
|
||||||
" Don't exit visual mode when "shifting"
|
" Don't exit visual mode when "shifting"
|
||||||
|
|
Loading…
Reference in a new issue