Crates.io | tree-sitter-lammps |
lib.rs | tree-sitter-lammps |
version | 0.0.8 |
source | src |
created_at | 2024-09-23 19:38:36.265597 |
updated_at | 2024-10-13 23:07:49.784493 |
description | lammps grammar for the tree-sitter parsing library |
homepage | |
repository | https://github.com/chappertron/tree-sitter-lammps |
max_upload_size | |
id | 1384403 |
size | 428,161 |
A tree-sitter parser for input scripts for the LAMMPS molecular dynamics simulations package.
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/*.scm
These files describe how the tree should be read and allows for syntax highlighting
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 folder queries/lammps
in the same directory as your init.lua
Presto! Your LAMMPS input scripts should now have pretty colours