No description
  • JavaScript 36.4%
  • C 34%
  • Tree-sitter Query 29.6%
Find a file
2026-04-08 19:20:18 +02:00
bindings First release, still need a lot of work 2024-12-26 20:06:18 +01:00
queries added more tests 2026-03-12 19:10:50 +01:00
src fix tag parsing in content and add comprehensive tests 2026-01-28 20:53:09 +01:00
test/corpus added more tests 2026-03-12 19:10:50 +01:00
tree-sitter-npf-misc@27f664a75e added new tests 2025-07-01 22:47:16 +02:00
.editorconfig First release, still need a lot of work 2024-12-26 20:06:18 +01:00
.gitattributes First release, still need a lot of work 2024-12-26 20:06:18 +01:00
.gitignore adding venv to gitignore 2025-01-02 21:44:11 +01:00
.tmuxp.yaml First release, still need a lot of work 2024-12-26 20:06:18 +01:00
binding.gyp First release, still need a lot of work 2024-12-26 20:06:18 +01:00
Cargo.lock Adding parsing for tags in js sections 2025-01-10 21:56:22 +01:00
Cargo.toml First release, still need a lot of work 2024-12-26 20:06:18 +01:00
CMakeLists.txt First release, still need a lot of work 2024-12-26 20:06:18 +01:00
go.mod First release, still need a lot of work 2024-12-26 20:06:18 +01:00
grammar.js add inline comment support inside sections 2026-01-28 20:45:39 +01:00
helix.md Add instructions for helix editor 2026-04-08 19:12:04 +02:00
Makefile First release, still need a lot of work 2024-12-26 20:06:18 +01:00
package-lock.json rewrite grammar with proper section types and test reorganization 2026-01-28 20:23:12 +01:00
package.json First release, still need a lot of work 2024-12-26 20:06:18 +01:00
Package.swift First release, still need a lot of work 2024-12-26 20:06:18 +01:00
pyproject.toml First release, still need a lot of work 2024-12-26 20:06:18 +01:00
README.md Updated TODO 2026-04-08 19:20:18 +02:00
setup.py First release, still need a lot of work 2024-12-26 20:06:18 +01:00
tree-sitter.json First release, still need a lot of work 2024-12-26 20:06:18 +01:00

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.)
  • %file sections 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