Vim syntax highlighting for WML
Moderator: Forum Moderators
Forum rules
- Please use [code] BBCode tags in your posts for embedding WML snippets.
- To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Vim syntax highlighting for WML
Hi!
I wrote a (basic) Vim syntax file for WML. It is far from perfect, but it is better than nothing. :)
Features
Highlighting of:
Install
Even if there already exist a syntax highlighting for
The most recent version of
Lua code is highlighted only when it is in a String value with the key "code" (even outside a [lua] tag) and when it is the sole attribute of the line. The highlighting of "" in double quoted string, variable ($...|) and formula ($(...)) is rarely (read never) working in Lua code. There is certainly others bugs… I let you hunt them. :)
I am not a Vim syntax wizard, my goal was to make a (more or less) working syntax file, so the code is not very elegant. However, the file is under 3-clause BSD license, so do not hesitate to improve it. If you have any remark or problem, please let me know (here or on IRC).
I suppose Vim is not widely used across UMC author, but I hope this will be useful to some of you. :)
I wrote a (basic) Vim syntax file for WML. It is far from perfect, but it is better than nothing. :)
Features
Highlighting of:
- Standard tags (copied from here)
- Lua
- Formula (basic)
- Syntax error (basic)
Install
- Download
vim-wml.tar.gz
- Extract it in your vim syntax directory
On Linux/Unix:Code: Select all
$ mkdir -p ~/.vim/syntax && tar xzvf vim-wml.tar.gz -C ~/.vim/syntax
- You can enable wml highlighting for the current buffer by typing
:set syn=wesml
To enable it automatically for all.cfg
files add the following line to your.vimrc
:Code: Select all
au BufNewFile,BufRead *.cfg setf wesml
Even if there already exist a syntax highlighting for
.cfg
files, it is very generic, I tried to match WML syntax more closely. Since the name wml is already taken (Website MetaLanguage), I named the syntax file wesml.The most recent version of
lua.vim
(Vim syntax file for Lua) is using TOP everywhere, this cause some bugs with the definition of Lua blocks. To fix this, I included a file named wmllua.vim
which is a 2006 version of lua.vim
. This version of Lua highlighting is only for Lua 4.0 to Lua 5.1. Since r52914, Lua 5.2 is included in Wesnoth so the highlighting is not perfect. You may try your local lua.vim
file by editing wesml.vim
(read the comment before the syn include
line).Lua code is highlighted only when it is in a String value with the key "code" (even outside a [lua] tag) and when it is the sole attribute of the line. The highlighting of "" in double quoted string, variable ($...|) and formula ($(...)) is rarely (read never) working in Lua code. There is certainly others bugs… I let you hunt them. :)
I am not a Vim syntax wizard, my goal was to make a (more or less) working syntax file, so the code is not very elegant. However, the file is under 3-clause BSD license, so do not hesitate to improve it. If you have any remark or problem, please let me know (here or on IRC).
I suppose Vim is not widely used across UMC author, but I hope this will be useful to some of you. :)
- Attachments
-
vim-wml.tar.gz
- Vim syntax highlight for WML
- (7.15 KiB) Downloaded 367 times
Pardon my English.
Re: Vim syntax highlighting for WML
I have been using vim so this will be very nice. Thank you!
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
Re: Vim syntax highlighting for WML
I'm having trouble with the autocmd setf, here's part of my .vimrc:
The echo happens, regardless of the order of the two au lines. Using :setf wesml or :set syn=wesml after vim has started also works, but the automatic setf doesn't seem to do anything.
Code: Select all
augroup vimrc_autocmds
au!
au BufNewFile,BufRead *.cfg setf wesml
au BufNewFile,BufRead *.cfg echo "setf wesml"
augroup END
Re: Vim syntax highlighting for WML
maybe it is setting it correctly but then something later is setting it to a different value
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
Re: Vim syntax highlighting for WML
Code: Select all
au BufRead,BufNewFile *.cfg set syn=wesml
Thank you ejls!
Re: Vim syntax highlighting for WML
Please commit it to data/tools.
Hopefully it will not fight with the emacs mode there
Hopefully it will not fight with the emacs mode there

Re: Vim syntax highlighting for WML
It works for me now, so I've committed it.