I integrated luacheck
in vim
with the following simple function:
function! LuaCheck()
let errors=system("luacheck " . expand("%"))
cexpr errors
cwindow 5
endfunction
autocmd FileType lua nnoremap <buffer> <c-f> :call LuaCheck()<cr>
autocmd FileType lua set efm=%f:%l:%c:\ %m
It is working, but here is a problem: luacheck
doesn't have interactive mode, it works only with files. So I have to use expand("%")
instead of getline(1, "$")
. When I changed something in buffer I need to save it before checking - it is bad practice. I want to create a temporary file, save content of buffer to it, check temporary file and remove it. But I don't know how to create the temporary file in vimscript
. Is this possible? Or I need use external tools for it?