Skip to content

NuCoMP/mcnp-language-server-vscode

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
out
 
 
src
 
 
 
 
 
 
 
 

MCNP Language Server from NuCoMP

This extension is for anyone working with (or just reading) input files for Los Alamos
National Laboratory's MCNP Code. MCNP presents a complex and expansive input
format that can often be troublesome for both new and experienced users.
The MCNP Language Server addresses these issues by providing error-checking
and other common IDE functions.

Features

  1. Editor services for MCNP6.2 via the MCNP Language Server.
    • Input validation.
    • Outline view.
    • Syntax highlighting supported by a Textmate grammar.
    • Auto-completion.
    • Reference finding.
  2. Customizable Run and Plot context menus and titlebar buttons.

Installation

Manual Install

Until this is published on the VS Code Marketplace, it needs to be manually installed.

  1. Download the latest release.
    • Only the .vsix file is necessary.
  2. Run code --install-extension nucomp-mcnp-VERSION.vsix.
    • Or use Ctrl+Shift+P in VS Code and search Install from VSIX.
  3. Activate the extension is VS Code (if necessary).

This will install the extension to your VS Code extensions folder.

  • Windows: %USERPROFILE%\.vscode\extensions.
  • Linux: ~/.vscode/extensions.
  • Mac: ~/.vscode/extensions.

Configuring MCNP Line Limit and Indents

The default line limit in MCNP is 128 characters. An indent of 5 or more spaces is
treated as a line continuation. To have VS Code assist with these specifications,
add the following to your settings.json.

"[mcnp]": {
  "editor.rulers": [128],
  "editor.tabSize": 5
  } 

Updating

Full Extension

  • Download and install the latest version. You might have to manually delete the old
    version(s) from your VS Code extensions folder.

Language Server Only

  • Build or download a new MCNP language server.
  • Replace the bin and lib directories found in .../mcnp-server.

Input Validation

Format Requirements

For the language server to work properly, all MCNP inputs are required to:

  • Use the .mcnp file extension (or validation messages will not display).
  • Begin with a $ comment on the first line.
  • End with exactly one blank line.
  • Not have any extra blank lines at the start or end of a file.

MCNP is insensitive to these requirements, but they are necessary for validation.

Known Issues

There are some syntaxes that can be used in MCNP, but are treated as invalid by the
Language Server.

  • Deprecated formats are not necessarily supported. The Language Server was designed
    for the current MCNP6.2 syntax.
  • Having a line continuation character & at the end of the last line on a multi-line card.
  • Exponent notations that do not use the E.
  • The multiplier operator xM is not accepted on every card.
    • It will work on cards where it is commonly used like IMP.
  • Using excess parentheses on FM cards. Only use the required amount. Examples:
    • Error: fm4 ((-1 5 -1))
    • Good: fm4 (-1 5 -1)
  • Ordering of mixed numeric and symbolic particle types on SI. Symbols must come
    before number. Examples:
    • Error: SI14 L 1 2 H
    • Error: SI14 L 1 H 2
    • Good: SI14 L H 1 2
  • A blank line with 5+ spaces followed by an indented line. To avoid this error, simply:
    • Remove all spaces on the lines between deck sections.
    • Or avoid indenting the first card of a section.

Tips for Troubleshooting

  • The easiest way to cause numerous errors is with a broken reference.
    • For example, expect errors on your Cell cards until all Surfaces and Materials
      have been defined.
    • Note that VS Code will track references between files in your working directory.
      Easily check for this by using the Go to References and Go to Definition
      options.
  • Ensure that your deck has Cell, Surface, and Data card sections.
    • The language server expects a full deck (unless the CONTINUE card is used).
  • Using the READ card will not invoke cross-file validation.
    • The entire deck is expected to be in the same file.
    • READ is supported only as a data card.
  • Try inputting all optional parameters for a card.
    • The language server might be expecting the full card specification.
  • Double-check the syntax described in the MCNP6.2 manual.

Run and Plot Options

These features need to be configured through the Extension Settings menu.
The custom plot and run commands can be used for executing user-developed
scripts and take priority over the other run/plot options.

Options

  • Custom Plot Command - Used for custom plotting scripts.
    • E.g. - bash .../my_run_script.
  • Custom Run Command - Used for custom run scripts.
    • E.g. - bash .../my_plot_script.
  • Executable - The absolute path to the MCNP executable.
    • E.g. - .../MCNP620/MCNP_CODE/bin/mcnp6.
  • Data_path - The absolute path to MCNP's data directory.
    • E.g. - .../MCNP620/MCNP_DATA.
  • Run_args - Additional arguments for MCNP execution.
    • E.g. - TASKS 6.
  • Plot_args - Additional arguments for MCNP Plotter execution.
  • Xsdir - The absolute path to MCNP's cross section directory file.
    • E.g. - .../MCNP620/MCNP_DATA/xsdir_mcnp6.2.

Note that the file currently being run or plotted from the editor will be
supplied as an argument to MCNP or any custom scripts.

About

MCNP VS Code extension with syntax highlighting

Resources

License

Stars

Watchers

Forks

Packages

No packages published