No description
- JavaScript 36.4%
- C 34%
- Tree-sitter Query 29.6%
| bindings | ||
| queries | ||
| src | ||
| test/corpus | ||
| tree-sitter-npf-misc@27f664a75e | ||
| .editorconfig | ||
| .gitattributes | ||
| .gitignore | ||
| .tmuxp.yaml | ||
| binding.gyp | ||
| Cargo.lock | ||
| Cargo.toml | ||
| CMakeLists.txt | ||
| go.mod | ||
| grammar.js | ||
| helix.md | ||
| Makefile | ||
| package-lock.json | ||
| package.json | ||
| Package.swift | ||
| pyproject.toml | ||
| README.md | ||
| setup.py | ||
| tree-sitter.json | ||
tree-sitter-npf
Simple tree-sitter parser for the NPF configuration file format.
Description
The goal of this project is to provide a simple parser aimed at syntax highlighting. Exact parsing is not the primary goal. The parser should work with any editor that supports tree-sitter.
Neovim Installation
1. Register the parser with nvim-treesitter
Add this to your nvim-treesitter config (works with lazy.nvim, packer, etc.):
-- In your nvim-treesitter setup
local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
parser_config.npf = {
install_info = {
url = "https://github.com/ntyunyayev/tree-sitter-npf",
files = { "src/parser.c", "src/scanner.c" },
branch = "main",
generate_requires_npm = false,
requires_generate_from_grammar = false,
},
filetype = "npf",
}
2. Add filetype detection
Add this to your init.lua:
vim.filetype.add({
extension = {
npf = "npf",
},
})
-- Optional: set comment format for npf files
vim.api.nvim_create_autocmd("FileType", {
pattern = "npf",
callback = function()
vim.bo.commentstring = "// %s"
end,
})
3. Install query files
Copy the query files to your Neovim config:
mkdir -p ~/.config/nvim/queries/npf
cp queries/highlights.scm ~/.config/nvim/queries/npf/
cp queries/injections.scm ~/.config/nvim/queries/npf/
4. Install the parser
Run in Neovim:
:TSInstall npf
Uninstall / Clean Previous Installation
To remove a previous installation:
# Remove the query files
rm -rf ~/.config/nvim/queries/npf
# Remove the installed parser
rm -f ~/.local/share/nvim/lazy/nvim-treesitter/parser/npf.so
# Or if using a different plugin manager:
rm -f ~/.local/share/nvim/site/parser/npf.so
# Clear nvim-treesitter cache (if it exists)
rm -rf ~/.cache/nvim/treesitter
You can also run in Neovim:
:TSUninstall npf
Helix Installation
Instructions for installing the parser in the Helix editor are provided in helix.md.
Supported features
- All section types (
%script,%file,%variables,%config,%init,%exit, etc.) %filesections correctly inject syntax highlighting based on file extension- Inline Python expressions
$(( ... ))in bash content - Tags (
%tag1,tag2:section) and negative tags (%-tag:section) - Roles with multipliers (
@role,@role-*,@role-0) - Jinja template flag support
- Comments inside and outside sections
TODO
- Add folds.scm for section folding
- Zed editor configuration examples