Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Many (La)TeX editors support the LuaTeX engine. However, which one offers the best support for writing LuaTeX? Which editor or plugin supports features such as syntax highlighting and auto-completion for both Lua and (La)TeX?

Common useful features of LaTeX focused IDEs such as integrated viewer, forward and inverse search, structure browser and spell checking are still important, though supplemented by some Lua syntax support.

share|improve this question

This question had a bounty worth +50 reputation from Masi that ended 3 hours ago. Grace period ends in 20 hours

The current answers do not contain enough detail.

I want to have better overview of different IDEs in different OSs. I can use Vim but like to use OSX's TexPad for basic typing, but in the same time, I take a risk that TexPad has itself some bug. So better preview about different editors and IDEs would be nice. What are the most active users here using and why?

5  
There's a huge list of editors with Lua support here: Lua Editor Support. Crossing this with your favourite LaTeX editor shouldn't be too hard. Perhaps the question is do any of the editors support two language syntaxes at once? –  Alan Munn May 23 '11 at 20:47
    
@Alan: thanks for the link! A capable editor supporting two languages at the same time may do, though I'm mainly focused on LaTeX and I like forward and inverse search, integrated viewers and further features of classical LaTeX IDEs - combined with integrated Lua syntax support - I'll edit the question. –  Stefan Kottwitz May 23 '11 at 21:12
    
Not having an IDE and not being free: I really like textmate (macromates.com) because you can (like vim - see Aditya's answer) define regions where the editor switches from LaTeX to Lua syntax. –  topskip May 24 '11 at 5:09
    
Does anyone have an opinion here on OSX's TexPad for LuaTeX? I am particularly interested in its limitations, since the staff team is working on its problems but some are unfortunately in OSX itself. –  Masi Dec 15 at 21:06
1  
Note: the Lua syntax used in a Lua script and the Lua syntax used by Lua code embedded in (La)TeX code are different. It is best to keep Lua code and LaTeX code in separate files. So, any decent editor is enough. –  Paul Gaborit Dec 15 at 22:51

4 Answers 4

up vote 19 down vote accepted

Vim supports embedding syntax highlighting of one language in another. I use that to support both MP and Lua syntax highlighting in ConTeXt regions. The basic trick is do define a syntax region as follows:

unlet b:current_syntax
syn include @LUA syntax/lua.vim

syn region luatex matchgroup=contextIdentifier
      \ start='\\startluacode'
      \ end='\\stopluacode'
      \ contains=@LUA

Then everything inside \startluacode ... \stopluacode will have Lua syntax highlighting. Here is a screenshot showing code from one of my modules (not that the lua comments and the function os.remove inside the \startluacode environment are syntax highlighted)

enter image description here

For completeness, here is a screenshot showing highlighted Metapost code inside a tex file

enter image description here

The same idea will also work in LaTeX, as follows:

unlet b:current_syntax
syn include @LUA syntax/lua.vim

syn region luatexSnip matchgroup=Snip
    \ start='\\begin{\z(luacode\|luacode*\)}'
    \ end='\\end{\z1}'
    \ contains=@LUA

syn region luatexSnip matchgroup=Snip
    \ start='\\\(directlua\|luadirect\){'
    \ end='}'
    \ contains=@LUA


highlight link Snip SpecialComment

Vim also supports auto-completion, but I don't use that feature so I don't know if language dependent auto-completion is possible or not.

Other requirements, like forward/backward search, spell checking, structure browser, are straight forward, but even then, vim is not what you will call an IDE.

share|improve this answer
    
This does not work for me anyway. I use LaTeX and it may be the reason. Anyway, inspired by your answer I got it works for LuaLaTeX but putting the following in the 'tex.vim' ft plugin file. ... it i too long in a comment, I put it in an answer –  Yan Zhou Aug 22 '11 at 11:03
    
@Yan Zhou: I include them in the syntax/context.vim rather than the ft plugin. For LaTeX, you can consider adapting the default syntax highlighting plugin. –  Aditya Aug 22 '11 at 16:45
    
I did try to include your code (modified for latex) in /after/syntax/tex.vim and that is where the problem happens. My method does not actually require they to be included in specific file, fttype file or even .vimrc will do. –  Yan Zhou Aug 22 '11 at 17:05

Emacs as well offers syntax highlighting for Lua and LaTeX. I do not know whether there is something like "embedded syntax highlighting" for lua-chunks inside a *.tex-file. Usually you do that by opening the file into an indirect buffer: in the base buffer you get LaTeX-highlighting, in the indirect buffer you change the major mode to lua-mode.

But: this doesn't work with lua-mode yet, at least for me. Independently from changing the mode to lua-mode, Emacs keeps highlighting LaTeX-keywords in the indirect buffer.

Emacs with AucTEX is great for LaTeX, the lua-mode is by far less convenient.

Alexander

share|improve this answer
4  
I wonder if this will be addressed in future versions of AUCTeX? –  emacsomancer May 29 '11 at 1:36
    
Good question. I opened a thread on the auctex-mailinglist, see here: mail-archive.com/auctex@gnu.org , title: »Lua commands in TeX-buffers: highlighting by using indirect buffers?« We will see if more people are interested. A. –  Keks Dose May 29 '11 at 19:29
1  
Thread address: mail-archive.com/auctex@gnu.org/msg04305.html –  Keks Dose May 29 '11 at 19:35
2  
I don't know the status of the mailing lists, but I've actually been able to solve this one: tex.stackexchange.com/a/128724/17423 –  Sean Allred Aug 18 '13 at 2:01
2  
github.com/vspinu/polymode –  student Dec 17 at 11:21

Aditya's answer does not work for me anyway. I use LaTeX and it may be the reason. Anyway, inspired by your answer I got it works for LuaLaTeX by putting the following in the 'tex.vim' ft plugin file.

autocmd BufWinEnter * if exists("b:current_syntax") && b:current_syntax == "tex"
autocmd BufWinEnter * unlet b:current_syntax
autocmd BufWinEnter * syntax include @TEX syntax/tex.vim
autocmd BufWinEnter * unlet b:current_syntax
autocmd BufWinEnter * syntax include @LUA syntax/lua.vim
autocmd BufWinEnter * syntax region luatex matchgroup=Snip start="%--beginlua--" end="%--endlua--" containedin=@TEX contains=@LUA
autocmd BufWinEnter * syntax region luatex matchgroup=Snip start="--beginlua--" end="--endlua--" containedin=@TEX contains=@LUA
autocmd BufWinEnter * highlight link Snip SpecialComment
autocmd BufWinEnter * let b:current_syntax="luatex"
autocmd BufWinEnter * endif

It should worked by simply put these codes without autocmd BufWinEnter in to the after/syntax/tex.vim file. But in my case that causes some problems and got vim halted. So I use the au to get them executed at the very end of file loading process.

After doing these, everything marked by --beginlua-- and --endlua-- are highlighted as lua code. One can use the version with % in \directlua or luaexec where TeX line comment is allowed but not lua line comment. And the version without % in the \begin{luacode}, etc.

share|improve this answer

I like very much Sublime Text. His multi cursor editing is simply fantastic (I know that now other editors has it too, but it was the first one). It has the possibility to have different highlights inside the same document depending on the context. But I don't know if somebody has created a setting for Lua(La)TeX.

share|improve this answer
    
This would be an even better answer if you could find or create such a plugin :) –  Sean Allred Dec 17 at 21:58
    
In this document, dated 2001, is described multiple selection in Lapis. The initial release of Sublime TeXt has been done seven years later. –  giordano Dec 17 at 21:59
    
WOOT! I like some features of this editor. It is easy and similar keyboard-shortcuts as in Vim. I would like to have a section -drawer to the left-hand-side like in TexPad. Do you know if it is possible? –  Masi Dec 18 at 8:20
    
@Masi I don't think so :( No answer here stackoverflow.com/questions/27231801/… –  Kpym Dec 18 at 9:57
    
@giordano ouah ! I should probably correct to "the first beautiful one" ;) –  Kpym Dec 18 at 9:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.