Mypyc DSL grammar for tree-sitter

Overview

tree-sitter-mypyc

Mypyc DSL grammar for tree-sitter.

Mypyc DSL with syntax highlighting

Installing (Neovim)

This is based on the Neovim Tree-sitter docs for adding new parsers. Basically you will want to clone this repository and add the following to your init.lua Neovim config. It assumes you use Lua to configure your Neovim config, and that you use Vim Plug as your package manager. You might have to change things if your setup is different!

-- Add the plugin which was cloned locally to your computer. Because this repo actually contains
-- 2 plugins in one, you have to have 2 separate entries.
--
-- Replace "~/git" with the directory you installed this repo to
Plug('~/git/tree-sitter-mypyc', {rtp = 'mypyc_test_cases'})
Plug('~/git/tree-sitter-mypyc', {rtp = 'mypyc_ir'})

-- Create an auto command to change the filetype whenever a ".test" file is opened.
create_autocmd({'BufNewFile', 'BufRead'}, {pattern = '*.test', command = 'set syntax=mypyc_test_cases filetype=mypyc_test_cases'})

-- Optionally you can update/add this section which will guarantee that the mypyc grammar(s) are always installed
require('nvim-treesitter.configs').setup {
  ensure_installed = { 'mypyc_test_cases', 'mypyc_ir' },
  highlight = {
    enable = true
  }
}

-- Add this if you don't have it already
local parser_config = require('nvim-treesitter.parsers').get_parser_configs()

parser_config.mypyc_test_cases = {
  install_info = {
    -- Replace "~/git" with the directory you installed this repo to
    url = "~/git/tree-sitter-mypyc",
    files = {"mypyc_test_cases/src/parser.c"},
    generate_requires_npm = false,
    requires_generate_from_grammar = false,
  },
  filetype = "test",
}
parser_config.mypyc_ir = {
  install_info = {
    -- Replace "~/git" with the directory you installed this repo to
    url = "~/git/tree-sitter-mypyc",
    files = {"mypyc_ir/src/parser.c"},
    generate_requires_npm = false,
    requires_generate_from_grammar = false,
  },
}

See my init.lua config file for a full example.

Then, you will need to copy the queries that actually style everything. To do this, you must:

  1. Find your "runtime path" for Neovim. This is usually in ~/.cache/nvim. See :h rtp for more info.
  2. Create the query folders by running: mkdir -p ~/.cache/nvim/nvim-treesitter/queries/{mypyc_ir,mypyc_test_cases}
  3. Copy the queries to their corresponding files:
# while in this repository:

cp mypyc_ir/queries/* ~/.cache/nvim/nvim-treesitter/queries/mypyc_ir
cp mypyc_test_cases/queries/* ~/.cache/nvim/nvim-treesitter/queries/mypyc_test_cases

Finally, open nvim and execute :TSInstall mypyc_ir and :TSInstall mypyc_test_cases. Close and re-open Neovim, and you should now have syntax highlighting for .test files!

You might also like...
Count your code by tokens, types of syntax tree nodes, and patterns in the syntax tree. A tokei/scc/cloc alternative.

tcount (pronounced "tee-count") Count your code by tokens, types of syntax tree nodes, and patterns in the syntax tree. Quick Start Simply run tcount

As-tree - Print a list of paths as a tree of paths 🌳

as-tree Print a list of paths as a tree of paths. For example, given: dir1/foo.txt dir1/bar.txt dir2/qux.txt it will print: . ├── dir1 │ ├── foo.tx

languagetool-code-comments integrates the LanguageTool API to parse, spell check, and correct the grammar of your code comments!
languagetool-code-comments integrates the LanguageTool API to parse, spell check, and correct the grammar of your code comments!

languagetool-code-comments integrates the LanguageTool API to parse, spell check, and correct the grammar of your code comments! Overview Install MacO

Simple grammar-based test case generator

tree-splicer tree-splicer is a simple grammar-based test case generator. It parses a number of input files using tree-sitter grammars, and produces ne

Non-Recursive Inverting of Binary Tree in Rust

Non-Recursive Inverting of Binary Tree in Rust The idea is to implement the classical Inverting of Binary Tree but without using recursion. Quick Star

Prefix tree implemented in Rust.

Prefix tree implemented in rust. A simple library that provides a prefix tree (trie) implementation. It uses generic types for both keys and values. p

Basic template for an out-of-tree Linux kernel module written in Rust.

Rust out-of-tree module This is a basic template for an out-of-tree Linux kernel module written in Rust. Please note that: The Rust support is experim

k-dimensional tree

kd-tree k-dimensional tree in Rust. Fast, simple, and easy to use. Usage // construct kd-tree let kdtree = kd_tree::KdTree::build_by_ordered_float(vec

An Rust implementation of the Modified Merkle Patricia Tree described by ETH Yellow Paper

Merkle Patricia Tree的Rust实现 博客文章:https://dere.press/2022/01/24/eth-trie/ 本实现参考下列项目: https://ethereum.github.io/yellowpaper/paper.pdf https://github.co

Owner
dosisod
Open Source Wizard
dosisod
Like grep, but uses tree-sitter grammars to search

tree-grepper Works like grep, but uses tree-sitter to search for structure instead of strings. Installing This isn't available packaged anywhere. That

Brian Hicks 219 Dec 25, 2022
A syntax highlighter for Node powered by Tree Sitter. Written in Rust.

tree-sitter-highlight A syntax highlighter for Node.js powered by Tree Sitter. Written in Rust. Usage The following will output HTML: const treeSitter

Devon Govett 211 Dec 20, 2022
Tree-sitter - An incremental parsing system for programming tools

tree-sitter Tree-sitter is a parser generator tool and an incremental parsing library. It can build a concrete syntax tree for a source file and effic

null 10.6k Jan 9, 2023
A tree-sitter based AST difftool to get meaningful semantic diffs

diffsitter Disclaimer diffsitter is very much a work in progress and nowhere close to production ready (yet). Contributions are always welcome! Summar

Afnan Enayet 1.3k Jan 8, 2023
Semantic find-and-replace using tree-sitter-based macro expansion

Semantic find-and-replace using tree-sitter-based macro expansion

Isaac Clayton 15 Nov 10, 2022
tree-sitter meets Kakoune

kak-tree-sitter This is a binary server that interfaces tree-sitter with kakoune. Features Install Usage Design Credits Features Semantic highlighting

Dimitri Sabadie 5 May 3, 2023
rehype plugin to use tree-sitter to highlight code in pre code blocks

rehype-tree-sitter rehype plugin to use tree-sitter to highlight code in <pre><code> blocks Contents What is this? When should I use this? Install Use

null 5 Jul 25, 2023
Dragonfly, POC full-stack web app DSL

Dragonfly Dragonfly is a toy DSL that explores ways to describe the structure of full-stack web applications. You should not use it in production. For

Bas Dirks 9 Mar 15, 2023
Noir, Circom, and Halo2 exercises for DSL workshop at ZKSummit10

ZKSummit10 - Exploring Noir, Circom, halo2 Workshop Prompt Write Noir, Halo2 and Circom circuits that constrain integer division i.e decimals are trun

Richard Liang 4 Sep 21, 2023
A high level DSL for Simplicity. This is a work in progress and is not yet ready for production use

A high level DSL for Simplicity. This is a work in progress and is not yet ready for production use. The language is designed to be simple and easy to use. It is inspired by rust syntax and is statically typed. The syntax will be extended in the future to support more features.

null 13 Oct 28, 2023