Vim Syntax Highlighting for Turmeric

The Turmeric Vim plugin provides syntax highlighting for .tur files in Vim and Neovim. It lives in vim-syntax/ at the repo root.

Installation

Manual (no plugin manager)

Copy or symlink the two directories into ~/.vim (Vim) or ~/.config/nvim (Neovim):

# Vim
cp -r vim-syntax/syntax   ~/.vim/syntax/
cp -r vim-syntax/ftdetect ~/.vim/ftdetect/

# Neovim
cp -r vim-syntax/syntax   ~/.config/nvim/syntax/
cp -r vim-syntax/ftdetect ~/.config/nvim/ftdetect/

Alternatively, symlink the whole plugin directory so updates are picked up automatically:

# Vim
ln -s "$(pwd)/vim-syntax" ~/.vim/pack/turmeric/start/turmeric

# Neovim
ln -s "$(pwd)/vim-syntax" ~/.config/nvim/pack/turmeric/start/turmeric

vim-plug

Plug '/path/to/turmeric/vim-syntax'

lazy.nvim

{
  dir = "/path/to/turmeric/vim-syntax",
  ft = "tur",
}

packer.nvim

use { "/path/to/turmeric/vim-syntax", ft = "tur" }

Features

Once installed, any .tur file is automatically highlighted:

Add to your ~/.vim/after/ftplugin/turmeric.vim (Vim) or the equivalent Lua config (Neovim):

" Turmeric ftplugin settings
setlocal tabstop=2
setlocal shiftwidth=2
setlocal expandtab
setlocal textwidth=80

" Use ; as the comment leader for commentary.vim / comment operators
setlocal commentstring=;\ %s

" Treat hyphens as part of words for motions (already set by syntax file,
" but explicit here for clarity)
setlocal iskeyword+=45

For Neovim with nvim-treesitter not yet supporting Turmeric, the Vim syntax file is the correct fallback -- no additional configuration is needed.

Highlight groups

Group Default link Matches
turmericDefine Define defn, defmacro, defstruct, etc.
turmericControl Conditional if, cond, match, loop, etc.
turmericType Type type, typeclass, forall, where
turmericEffect Keyword effect, handle, perform, with
turmericExcept Exception try, catch, throw, finally
turmericSpecial Special let, let*, lambda, fn, begin
turmericBuiltin Function Built-in functions and predicates
turmericNil Constant nil, null, none, unit
turmericInt Number Integer literals
turmericFloat Float Floating-point literals
turmericHex Number Hex literals (0xFF)
turmericBin Number Binary literals (0b1010)
turmericBool Boolean #t, #f
turmericChar Character Character literals (#\a, #\newline)
turmericString String String literals
turmericStringEsc SpecialChar Valid escape sequences
turmericBadEsc Error Unrecognized escape sequences
turmericKeyLit Constant Keyword literals (:name)
turmericMeta PreProc Metadata annotations (^linear)
turmericLineComment Comment ; and ;; line comments
turmericDocComment SpecialComment ;;; docstring comments
turmericBlockComment Comment #| ... |# block comments
turmericTodo Todo TODO, FIXME, HACK, NOTE, XXX
turmericQuote Special ', `
turmericUnquote Special ~
turmericSplice Special ~@
turmericOp Operator ::, \|>
turmericCBlock PreProc ```c ... ``` inline C blocks
turmericDelim Delimiter (), [], {}

To override a highlight group, add lines like this to your colorscheme or after/syntax/turmeric.vim:

hi turmericDocComment guifg=#a0c4ff gui=italic
hi turmericDefine     guifg=#ffd166 gui=bold

Rainbow parentheses

The syntax file links turmericDelim to Delimiter. If you use a rainbow parentheses plugin (e.g. rainbow, rainbow_parentheses.vim), add Turmeric to its file type list:

" rainbow_parentheses.vim
au VimEnter * RainbowParenthesesActivate
au Syntax turmeric RainbowParenthesesLoadRound
au Syntax turmeric RainbowParenthesesLoadSquare
au Syntax turmeric RainbowParenthesesLoadBraces

For nvim-ts-rainbow or rainbow-delimiters.nvim in Neovim, no extra configuration is needed once Treesitter supports Turmeric.

Known limitations

See also