This vim syntax works, but I have started to maintain tree-sitter-luau with queries that bind to nvim-treesitter. It is more powerful, works for large files with nested syntax, and much more performant. I have a small guide on how I set it up in Neovim. There's currently no plans to integrate it into Vim.
Vimscript syntax plugin for Luau and Roblox Luau. This plugin intends to provide good support for Luau and Roblox Luau in Vim, Neovim, and other flavors of Vim.
It's still experimental.
Head to the github pages for screenshots.
Installing is as simple as pulling the repo with your preferred plugin manager.
If you're new, the quickest way to get set up is by first installing plug.vim.
Make sure to read how to use the manager.
After that, you write Plug 'polychromatist/luau-vim'
in the critical section of your vimrc.
There is also minpac, which boasts minimalism.
If you don't want a plugin manager, please see a guide on how to install vim plugins natively.
Modify these variables in the head of your vimrc, before the plugin is loaded.
Example: let g:luauRobloxIncludeAPIDump = 1
. Note that a value of 1 means on, or set, similarly with 0 and off, or unset.
var | info |
---|---|
luauHighlightAll = 0 | 1 |
Setting to control all highlighting settings. When this is defined, all subordinate luauHighlight* variables will take on the value that is given, no matter what. Note that this does not control highlighting for syntax clusters that don't have settings, such as Luau keywords, expressions, etc. |
luauHighlightBuiltins = 0 | 1 |
default 1. If set, Luau builtins will take on luauFunction highlight group. |
luauHighlightTypes = 0 | 1 |
default 1. If set, syntax groups will be modified to try to match types in cases like binding lists or after function headers, and will fully realize top/block-level type definitions. If not, such definitions are treated like tables, and type annotations may appear strange. Not recommended as off when dealing with strictly typed code. |
luauHighlightRoblox = 0 | 1 |
default 1. If set, Luau builtins will be extended by Roblox datatypes as they appear on the docs. None of these datatypes are generated in the plugin by fetching the Roblox API - they are manually defined. However, any applicable Roblox API fetched syntax rules are impossible unless this is setting is on. |
luauRobloxIncludeAPIDump = 0 | 1 |
Experimental default 0. If set, and as long as luauHighlightRoblox is set, luau.vim (v0.3.1+) will attempt to grab Roblox APIs from a continuously refreshed, user-defined API endpoint. The APIs are, for now, parsed using regex on the compact, raw text format specified in the linked repo rather than JSON. |
luauRobloxAPIDumpURL = [string_url] |
default 'https://raw.githubusercontent.com/MaximumADHD/Roblox-Client-Tracker/roblox/API-Dump.txt' . This setting cannot be used on a JSON endpoint for now. |
luauRobloxAPIDumpDirname = [string_fname] |
default 'robloxapi' . This string specifies the path where any fetched Roblox API data lives, within the plugin root directory. |
glyph | meaning |
---|---|
y | implemented |
y* | implemented, but still experimental |
m | planned next minor version |
n | unsupported / not yet implemented |
category | item | status |
---|---|---|
syntax | literals | y |
continue | y | |
compoundop | y | |
type annotations | y* | |
exp: if-then-else | y* | |
linting | linter | n1 |
directives | y | |
grammar | exp | y* |
stat | y* | |
Type | y* | |
library | globals | y |
math , etc | y | |
roblox | globals | y |
datatype | y* | |
types | y*2 | |
Enum | y*2 |
(1) A lightweight interface to a Roblox linter/LSP is planned. I recommend ALE which supports the (Roblox) Luau linter selene
(2) An experimental API fetch to syntax rule pipeline is now being staged on the main branch.