tree-sitter parser and syntax highlighter for the Dwarf Fortress raw language
Go to file
JellyApple102 97aaf65805 update REAME 2021-10-07 00:47:34 -04:00
bindings initial commit 2021-09-23 17:22:14 -04:00
images update images 2021-09-23 23:38:33 -04:00
queries update regex 2021-09-29 01:20:28 -04:00
src update regex 2021-09-29 11:01:10 -04:00
test/corpus update regex 2021-09-29 01:20:28 -04:00
.gitignore update .gitignore 2021-09-23 17:42:40 -04:00
Cargo.toml initial commit 2021-09-23 17:22:14 -04:00
LICENSE add LICENSE 2021-09-27 13:15:50 -04:00
README.md update REAME 2021-10-07 00:47:34 -04:00
binding.gyp initial commit 2021-09-23 17:22:14 -04:00
grammar.js update regex 2021-09-29 11:01:10 -04:00
package.json initial commit 2021-09-23 17:22:14 -04:00

tree-sitter-dfraw

A simple language parser and highlighter made with tree-sitter

tokyonight tokyonight one tokyonight two

nightfly nightfly one nightfly two

Using with nvim-treesitter

Please refer to the adding parsers section on the nvim-treesitter page for more information.

Example config:

local parser_config = require'nvim-treesitter.parsers'.get_parser_configs()
parser_config.dfraw = {
	install_info = {
		url = 'https://github.com/JellyApple102/tree-sitter-dfraw',
		files = { 'src/parser.c' },
		branch = 'main'
	},
	filetype = 'text',
	used_by = { 'dfraw' }
}

Wrap in lua << EOF and EOF to use in init.vim.
Then run :TSInstall dfraw to install the parser.

In order for syntax highlighting to work you copy queries/highlights.scm file from this repo to your nvim-treesitter location queries/dfraw/highlights.scm. More information can be found on the nvim-treesitter page.

By default it is setup to start for any file of type 'text' or 'dfraw'. If you would not like to use it for all text files you can add a custom filetype to neovim. Example .config/nvim/scripts.vim:

if did_filetype()
	finish
endif
if getline(1) =~# '[a-z_]'
	setfiletype dfraw
endif

This will match any file whose first line is just lowercase letters_and_underscores, and set the filetype to 'dfraw'. Than change the config option filetype = 'dfraw' and remove the used_by option to only use 'dfraw' type files.

More information on custom filetypes here.

Highlight Colors

Feel free to change the highlight groups set by highlights.scm. I have found that some colors schemes use the same or similar colors for different groups. I have set them to what I like best using the tokyonight theme.

Use :highlight to view your current highlight groups and colors.