Lua + Improved visual-exec = ♥
changes ─┐ ├─ Added a folder for lua / moonscript ├─┬─ VISUAL-EXEC BINDINGS │ ├─ Visual-Enter now tries running as moonscript │ └─ Visual-C-Enter tries running as vim command ├─ Added Mooncompile command (compiles moonscript in lua folder) ├─ Added vim.moon which does nice things :) └─┬─ VIM.MOON ├─ tree: builds a tree like this one ├─ clumn: draws a table-column (useful for class diagrams) └─ draw: prints some drawing symbols
This commit is contained in:
parent
f4d8aae4b1
commit
37bdfddcd7
2 changed files with 74 additions and 8 deletions
61
lua/vim.moon
Normal file
61
lua/vim.moon
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
--vim: set noexpandtab :miv--
|
||||||
|
tree = (tab, level=0, skip="") ->
|
||||||
|
if level==0
|
||||||
|
print "┐"
|
||||||
|
|
||||||
|
pre = (lvl, skip) ->
|
||||||
|
for i=1,lvl
|
||||||
|
if skip\sub(i,i) == "y"
|
||||||
|
io.write " "
|
||||||
|
else
|
||||||
|
io.write "│ "
|
||||||
|
|
||||||
|
for idx, element in ipairs tab
|
||||||
|
last = idx == #tab
|
||||||
|
switch type element
|
||||||
|
when "table"
|
||||||
|
pre level, skip
|
||||||
|
io.write last and "└─" or "├─"
|
||||||
|
print element.title and "┬─ "..element.title or "┐"
|
||||||
|
tree element, level+1, skip .. (last and "y" or "n")
|
||||||
|
else
|
||||||
|
pre level, skip
|
||||||
|
if idx<#tab
|
||||||
|
print "├─ "..element
|
||||||
|
else
|
||||||
|
print "└─ "..element
|
||||||
|
|
||||||
|
import max from math
|
||||||
|
column = (col) ->
|
||||||
|
pad = (str, len) ->
|
||||||
|
str..string.rep(" ", len-#str)
|
||||||
|
width = 0
|
||||||
|
for box in *col
|
||||||
|
for elem in *box
|
||||||
|
width = max(width, #elem)
|
||||||
|
|
||||||
|
print "┌─"..string.rep("─",width).."─┐"
|
||||||
|
for idx,box in ipairs(col)
|
||||||
|
last = idx==#col
|
||||||
|
for elem in *box
|
||||||
|
io.write "│ "
|
||||||
|
io.write pad elem, width
|
||||||
|
io.write " │"
|
||||||
|
print!
|
||||||
|
unless last
|
||||||
|
print "├─"..string.rep("─",width).."─┤"
|
||||||
|
print "└─"..string.rep("─",width).."─┘"
|
||||||
|
|
||||||
|
box = (box) ->
|
||||||
|
column { box }
|
||||||
|
|
||||||
|
draw = ->
|
||||||
|
for line in * {
|
||||||
|
{ "─", "│", "┼" }
|
||||||
|
{ "┌", "┐", "└", "┘" }
|
||||||
|
{"├", "┤", "┬", "┴"}
|
||||||
|
}
|
||||||
|
print table.concat(line, " ")
|
||||||
|
|
||||||
|
|
||||||
|
{:tree, :column, :box, :draw}
|
21
vimrc
21
vimrc
|
@ -368,7 +368,12 @@ command! Snapshot call <sid>snapshot()
|
||||||
|
|
||||||
command! -nargs=? Scratch new | set buftype=nofile | set filetype=<args>
|
command! -nargs=? Scratch new | set buftype=nofile | set filetype=<args>
|
||||||
|
|
||||||
" === GENERAL KEY MAPPINGS ===
|
" ┌──────────────────────────┐
|
||||||
|
" ├─┬──────────────────────┐ │
|
||||||
|
" ├─┤ GENERAL KEY MAPPINGS ├─┤
|
||||||
|
" │ └──────────────────────┴─┤
|
||||||
|
" └──────────────────────────┘
|
||||||
|
|
||||||
let mapleader = "\\"
|
let mapleader = "\\"
|
||||||
|
|
||||||
let g:jmp_dist = 8
|
let g:jmp_dist = 8
|
||||||
|
@ -404,8 +409,13 @@ noremap gk k
|
||||||
nnoremap Y y$
|
nnoremap Y y$
|
||||||
|
|
||||||
" --- VISUAL EXECUTE ---
|
" --- VISUAL EXECUTE ---
|
||||||
vnoremap <C-CR> :<C-U>exec "'<,'>!".g:exe_prg<CR>
|
let $LUA_PATH = $LUA_PATH.";".expand("<sfile>:p:h")."/lua/?.lua"
|
||||||
vnoremap <CR> :<C-U>exec "'<,'>!".b:exe_prg<CR>
|
command! Mooncompile silent exec "!moonc ".expand("<sfile>:p:h")."/lua"
|
||||||
|
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>`<
|
||||||
|
|
||||||
" --- OTHER ---
|
" --- OTHER ---
|
||||||
" Don't exit visual mode when "shifting"
|
" Don't exit visual mode when "shifting"
|
||||||
|
@ -670,7 +680,6 @@ function! s:init_generic_file()
|
||||||
call s:autoClose_AddPair("(", ")")
|
call s:autoClose_AddPair("(", ")")
|
||||||
call s:autoClose_AddPair("{", "}")
|
call s:autoClose_AddPair("{", "}")
|
||||||
call s:autoClose_AddPair('"', '"')
|
call s:autoClose_AddPair('"', '"')
|
||||||
let b:exe_prg = g:exe_prg
|
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" --- VIMSCRIPT STUFF ---
|
" --- VIMSCRIPT STUFF ---
|
||||||
|
@ -685,10 +694,6 @@ function! s:init_vim_file()
|
||||||
command! -buffer Functions lex MatchingLines("^\\s*fun\\(ction\\)\\?\\>!.*$")
|
command! -buffer Functions lex MatchingLines("^\\s*fun\\(ction\\)\\?\\>!.*$")
|
||||||
command! -buffer Commands lex MatchingLines("^\\s*com\\(mand\\)\\?\\>!.*$")
|
command! -buffer Commands lex MatchingLines("^\\s*com\\(mand\\)\\?\\>!.*$")
|
||||||
command! -buffer Autocommands lex MatchingLines("^\\s*au\\(tocmd\\)\\?\\>!\\@!.*$")
|
command! -buffer Autocommands lex MatchingLines("^\\s*au\\(tocmd\\)\\?\\>!\\@!.*$")
|
||||||
|
|
||||||
vnoremap <buffer> <CR> ""y<CR>
|
|
||||||
\ :call setreg("\"", substitute(getreg("\""), "\n", "", ""), "v")<CR>
|
|
||||||
\ :<C-r>"<CR>`<
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" --- C / C++ Stuff ---
|
" --- C / C++ Stuff ---
|
||||||
|
|
Loading…
Reference in a new issue