Vim Syntax Highlighting for Turmeric

The Turmeric Vim plugin provides syntax highlighting for .tur files in Vim and Neovim. It lives in its own repo, turmeric-lang/vim-turmeric.

Installation

vim-plug

Plug 'turmeric-lang/vim-turmeric'

lazy.nvim

{ "turmeric-lang/vim-turmeric", ft = "turmeric" }

packer.nvim

use { "turmeric-lang/vim-turmeric", ft = "turmeric" }

Native packages (no plugin manager)

# Vim
git clone https://github.com/turmeric-lang/vim-turmeric ~/.vim/pack/turmeric/start/vim-turmeric

# Neovim
git clone https://github.com/turmeric-lang/vim-turmeric ~/.local/share/nvim/site/pack/turmeric/start/vim-turmeric

Manual

Clone the repo, then copy its syntax, ftdetect and ftplugin directories into ~/.vim (Vim) or ~/.config/nvim (Neovim). ftplugin sets the comment string, two-space indent and Lisp indentation words.

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.

Color schemes

The plugin's colors/ directory carries the two themes turmeric-lang.com uses, ported from the Try Turmeric editor: turmeric-dark and turmeric-light. Both need a true-color terminal. A plugin manager or native package puts them on the runtimepath for you, so just pick one:

set termguicolors
colorscheme turmeric-light   " or turmeric-dark

Each scheme sets background itself. To follow the terminal's own setting instead, choose by it:

execute 'colorscheme turmeric-' . (&background ==# 'light' ? 'light' : 'dark')

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