tree-sitter-lammps

Crates.iotree-sitter-lammps
lib.rstree-sitter-lammps
version0.0.8
sourcesrc
created_at2024-09-23 19:38:36.265597
updated_at2024-10-13 23:07:49.784493
descriptionlammps grammar for the tree-sitter parsing library
homepage
repositoryhttps://github.com/chappertron/tree-sitter-lammps
max_upload_size
id1384403
size428,161
Aidan Chapman (chappertron)

documentation

README

Tree-Sitter LAMMPS

A tree-sitter parser for input scripts for the LAMMPS molecular dynamics simulations package.

Tree-sitter

Grammar: grammar.js

This file contains code that is transpiled to the parser. It is a DSL that is described in the tree-sitter docs

Queries queries/*.scm

These files describe how the tree should be read and allows for syntax highlighting

Using with Neovim

  1. Install nvim-treesitter plugin to Neovim

  2. Add the following to your init.lua to define lammps file types:

    -- LAMMPS File type
    vim.filetype.add {
    extension = {
    lmp = 'lammps',
      },
    
      pattern = {
        -- These are lua matching patterns, not regex
        ['.*%.lmp'] = 'lammps',
        ['in%..*'] = 'lammps',
        ['.*%.in'] = 'lammps',
      },
    }
    
    
  3. Add the following to your init.lua to tell tree-sitter how to access this parser:

    
    local parser_config = require('nvim-treesitter.parsers').get_parser_configs()
    parser_config.lammps = {
      install_info = {
        url = 'https://github.com/chappertron/tree-sitter-lammps', -- local path or git repo
        files = { 'src/parser.c', 'src/scanner.c' }, -- note that some parsers also require src/scanner.c or src/scanner.cc
        -- optional entries:
        branch = 'main', -- default branch in case of git repo if different from master
        generate_requires_npm = false, -- if stand-alone parser without npm dependencies
        requires_generate_from_grammar = false, -- if folder contains pre-generated src/parser.c
      },
      filetype = 'lammps', -- if filetype does not match the parser name
    }
    
    vim.treesitter.language.register('lammps', 'lammps')
    
    
  4. run :TSInstallFromGrammar lammps to install the tree-sitter grammar.

  5. Copy the files from queries in this repo to a folder queries/lammps in the same directory as your init.lua

  6. Presto! Your LAMMPS input scripts should now have pretty colours

Commit count: 0

cargo fmt