From 5dd8daf46052c83ed53d357f5586bc71cc14a31e Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Wed, 25 Jul 2018 10:11:54 +0200 Subject: [PATCH] Add automoon feature Automatically compile moonscript into lua when a .moon file is saved and a global and/or buffer-local variable is defined. --- vimrc | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/vimrc b/vimrc index 7844cde..999016e 100644 --- a/vimrc +++ b/vimrc @@ -1005,3 +1005,37 @@ function! s:init_html_file() inoremap ""ciw<""p>m'""p>`'l inoremap ""diw"_cc<""p>o""p>O endfunction + +" --- Moonscript Stuff --- + +augroup MOON + au! + au FileType moon nnoremap :ToggleAutoMoonLocal + au BufWritePost *.moon call automoon() +augroup END +com! ToggleAutoMoon echo toggleautomoon() +com! ToggleAutoMoonLocal echo toggleautomoonlocal() +function! s:automoon() + if exists('g:automoon') || exists('b:automoon') + silent !moonc % + redraw + end +endfun +function! s:toggleautomoon() + if exists('g:automoon') + unlet g:automoon + return 'Automoon: off' + else + let g:automoon=1 + return 'Automoon: on' + end +endfun +function! s:toggleautomoonlocal() + if exists('b:automoon') + unlet b:automoon + return 'Local Automoon: off' + else + let b:automoon=1 + return 'Local Automoon: on' + end +endfun