This repository contains a working tree-sitter parser for the CMDL language, with syntax highlighting implemented.
Following are som screenshots of the syntax highlighting using different colorschemes.
TokyoDark (flavor night)
![](https://private-user-images.githubusercontent.com/37225272/335807040-9b3a06f5-5ccb-4206-b433-86824c7474c7.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2MjgxNTksIm5iZiI6MTczOTYyNzg1OSwicGF0aCI6Ii8zNzIyNTI3Mi8zMzU4MDcwNDAtOWIzYTA2ZjUtNWNjYi00MjA2LWI0MzMtODY4MjRjNzQ3NGM3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE1VDEzNTczOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWU0NTQ4MzczZjVlZWYyZGZmNjhhMWJhNjI0YmY2MjY2NmY3YzAzZDRkMWM0ZGIxY2QzMDRiNjFhMTJkNDFhMWEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.ezg7R_4tXyKDSTMtQQQKohuhEqMpxvXrVYkRq_e9yoU)
![](https://private-user-images.githubusercontent.com/37225272/335807045-2da58718-9121-44bb-9ffc-f399defe3f6b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2MjgxNTksIm5iZiI6MTczOTYyNzg1OSwicGF0aCI6Ii8zNzIyNTI3Mi8zMzU4MDcwNDUtMmRhNTg3MTgtOTEyMS00NGJiLTlmZmMtZjM5OWRlZmUzZjZiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE1VDEzNTczOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTM5NTFjMzJiZTA1NTg2MzliMTY5NGUzODljM2QwM2QzODNlODQ0OTFjZTQ2ZDk2ZGZmNDFmYjhlYmE0YTkxNjcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.czjcG3t0Np9a0D54KxSa83APgYsdINEtJVvzZ5O56HE)
To integrate syntax highlighting with NeoVim using the plugin nvim-treesitter, add the following to your init.lua
:
vim.api.nvim_create_autocmd(
{
"BufNewFile",
"BufRead",
},
{
pattern = "*.cmdl",
callback = function()
print("cmdl file")
local buf = vim.api.nvim_get_current_buf()
vim.api.nvim_buf_set_option(buf, "filetype", "cmdl")
end
}
)
local parser_config = require "nvim-treesitter.parsers".get_parser_configs()
parser_config.cmdl = {
install_info = {
url = "https://github.com/lyktstolpe/tree-sitter-cmdl"
files = { "src/parser.c" },
branch = "main",
generate_reqires_npm = false,
requires_generate_from_grammar = false,
},
filetype = "cmdl",
}
You also need to tell nvim-treesitter where to find the highlight queries, since these files are not automatically fetched for custom languages. For this you need the following:
- The directory
queries/
from this repository. - The path to your nvim install location, usually
~/.local/nvim/
.
Run the command
ln -s <path_to_repo>/tree-sitter-cmdl/queries/ <nvim_install_path>/queries/cmdl
to link the directories, or copy the contents directly if you prefer.