|
From: | Anton Curl |
Subject: | Autocompile in Vim |
Date: | Sun, 22 Mar 2015 12:56:05 +0100 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 |
Hi everyone! I share the solution I've found to automatically compile a Lilypond file in Vim. The compilation runs in background after saving the buffer, and errors are added to the quickfix list. I inspired myself from this script: https://github.com/vim-scripts/makebg First you must run Vim in server mode. For this I use an alias in my .bashrc: vim_server () {
vim --servername "$(cat /dev/urandom | tr -dc
'a-zA-Z0-9' | fold -w 32 | head -n 1)" "$@ " }
alias vim='vim_server' Then you have to put this in your .vimrc: function Makebg(make_cmd, make_target, make_filter)
command -nargs=0 Makebg call Makebg(b:make_cmd,
b:make_target, b:make_filter)
autocmd Filetype lilypond call SetLilypondOptions()
function SetLilypondOptions()
if filereadable("Makefile")
let b:make_cmd = "make"
let b:make_target = ""
else
let b:make_cmd = "lilypond"
let b:make_target = expand("%")
endif
let b:make_filter = "lilypond_error_filter"
setlocal efm=%f:%l:%c:%m
autocmd BufWritePost <buffer> Makebg
endfunction Finally you must have the two enclosed scripts in your $PATH. That's all! Note that you can use the Makebg function for other types of files. Anton Curl |
lilypond_error_filter
Description: Text document
makebg
Description: Text document
[Prev in Thread] | Current Thread | [Next in Thread] |