MCNP6 syntax highlighting and snippetsAn extension providing syntax highlighting and code snippets for MCNP input decks Cards, keywords, and constants were taken from the MCNPv6.3.0 user manual but is compatible with most version 6.x input files. By default this applies to files with the Syntax highlightingAll the expected syntax rules are implemented for cards, keywords, constants, and comments. Syntax highlighting rules are case insesnitive, and apply across multiple lines where appropriate, such as with the Highlighting rules are contextualised and will generally not apply to incorrect syntax or invalid states. In the following example:
Note that while this is a useful indication of problems, it guarantees nothing for runtime. There are plans to implement a fully featured language server with detailed error reporting, linting, etc... but this is not a trivial task and will take time. Autocomplete code snippetsLines may be commented out with the usual Code snippets are defined for input cards where appropriate. Simply start typing and hit For example, selecting will generate the following: For productivity, keywords and values are set to default or a simple hint where ambiguous. A comprehensive guide for most cards would take up the entire screen. As a compromise, every line simply has a small comment for context. This is still very useful for cards such as The template above is far easier than trying to remember whatever Of course, card snippets are fairly subjective in their usefulness. Any feedback on what defaults, flags, or comments should be used for certain cards would be appreciated. Customising syntax coloursThe textmate naming conventions are used for tokenisation to support most themes. MCNP specific syntax highlighting colours are customisable by overwriting the theme in your Expand example settings.json template```json "editor.tokenColorCustomizations": { "textMateRules": [ { "scope": "comment.line.mcnp", "settings": { "foreground": "#676767" } }, { "scope": "keyword.cellnumber.mcnp", "settings": { "foreground": "#82AAFF" } }, { "scope": "constant.numeric.cellmaterial.mcnp", "settings": { "foreground": "#E74856" } }, { "scope": "constant.numeric.celldensity.mcnp", "settings": { "foreground": "#2AB5CA" } }, { "scope": "keyword.surfacenumber.mcnp", "settings": { "foreground": "#ea82ff" } }, { "scope": "constant.language.surfacetype.mcnp", "settings": { "foreground": "#4ecc86" } }, { "scope": "constant.language.zaidlib.mcnp", "settings": { "foreground": "#e88e96" } }, { "scope": "keyword.mcnp", "settings": { "foreground": "#82AAFF" } }, { "scope": "constant.numeric.mcnp", "settings": { "foreground": "#B987E1" } }, { "scope": "variable.mcnp", "settings": { "foreground": "#a3d3fb" } }, { "scope": "constant.language.mcnp", "settings": { "foreground": "#4ecc86" } }, { "scope": "string.mcnp", "settings": { "foreground": "#ea6cc7" } } ] } ```Expand table of scopesValues for the MCNP syntax
Issues and bugsIt is guaranteed that there are missing cards or rules that are not working as intended, so if you find anything please raise an issue. Suggestions for improvements and features are also welcome. Notes for developersThe JSON files quickly spiral out of control with all the nuances of the various input cards and their edge cases. The YAML file format is much easier to deal with, so it is suggested that you just install
The included |