开发者

Lua jump to right line

开发者 https://www.devze.com 2022-12-29 00:09 出处:网络
I have a makefile that looks开发者_运维技巧 like: default: lua blah.lua Now, in Vim, I type \":make\".

I have a makefile that looks开发者_运维技巧 like:

default:
  lua blah.lua

Now, in Vim, I type ":make".

There's an error in my Lua code; it gives a file name + line number. I would like Vim to jump to the right file/line. How do I make this happen?


You can set the error-format string to recognise the lua interpreter's output. For example, add this to your .vimrc file:

autocmd BufRead *.lua setlocal efm=%s:\ %f:%l:%m

That assumes the errors in your version of Lua look like this:

lua: blah.lua:2: '=' expected near 'var'

Bonus tip: rather than use a makefile, you can use the makeprg setting:

autocmd BufRead *.lua setlocal makeprg=lua\ %

That will run the current file through lua when you type :make.

0

精彩评论

暂无评论...
验证码 换一张
取 消