5 releases
0.0.8 | Oct 13, 2024 |
---|---|
0.0.6 | Oct 10, 2024 |
0.0.5 | Oct 8, 2024 |
0.0.4 | Sep 23, 2024 |
0.0.3 | Sep 23, 2024 |
#112 in Text editors
209 downloads per month
Used in lammps-analyser
330KB
12K
SLoC
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
-
Install nvim-treesitter plugin to Neovim
-
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', }, }
-
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')
-
run
:TSInstallFromGrammar lammps
to install the tree-sitter grammar. -
Copy the files from
queries
in this repo to a folderqueries/lammps
in the same directory as yourinit.lua
-
Presto! Your LAMMPS input scripts should now have pretty colours
Dependencies
~2–285KB