Skip to content

PlasmaFAIR/fortitude-vscode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fortitude extension for Visual Studio Code

Fortitude image image image Actions status

A Visual Studio Code extension for Fortitude, an extremely fast Fortran linter and code formatter, written in Rust. Available on the Visual Studio Marketplace.

Fortitude can be used to replace Flake8 (plus dozens of plugins), Black, isort, pyupgrade, and more, all while executing tens or hundreds of times faster than any individual tool.

The extension ships with fortitude==0.8.0.

Warning

This is in preview while we develop the Fortitude server

This will be properly released, alongside the new version of Fortitude in early January 2026!

Installing the extension

While this is in development, you'll have to do a manual install:

$ npm install --global vscode/vsce
$ uv pip sync --require-hashes ./requirements.txt --target ./bundled/libs
$ npm run vsce-package

This creates fortitude.vsix which you can install manually in VS Code from the Extensions tab > ... > Install from VSIX....

Usage

Once installed in Visual Studio Code, fortitude will automatically execute when you open or edit a Fortran file.

If you want to disable Fortitude, you can disable this extension per workspace in Visual Studio Code.

Fix safety

Fortitude's automatic fixes are labeled as "safe" and "unsafe". By default, the "Fix all" action will not apply unsafe fixes. However, unsafe fixes can be applied manually with the "Quick fix" action. Application of unsafe fixes when using "Fix all" can be enabled by setting unsafe-fixes = true in your Fortitude configuration file or adding --unsafe-fixes flag to the "Lint args" setting.

See the Fortitude fix docs for more details on how fix safety works.

Untrusted Workspace

The extension supports loading in an untrusted workspace. When the workspace is untrusted, the extension will always use the bundled executable of the fortitude binary regardless of any other settings. This is because finding other versions uses a Python interpreter, which is not available in untrusted workspaces.

The following settings are not supported in an untrusted workspace:

Settings

Refer to the Fortitude Language Server documentation for a full list of settings available in the extension.

Configuring VS Code

You can configure Fortitude to fix lint violations on-save by enabling the source.fixAll action in settings.json:

{
  "[fortran]": {
    "editor.codeActionsOnSave": {
      "source.fixAll": "explicit"
    }
  }
}

Configuring Fortitude

The Fortitude VS Code extension will respect any Fortitude configuration as defined in your project's fpm.toml, fortitude.toml, or .fortitude.toml file (see: Configuring Fortitude in the Fortitude documentation). In general, we recommend configuring Fortitude via fpm.toml or fortitude.toml so that your configuration is shared between the VS Code extension and the command-line tool, and between all contributors to the project.

You can also configure some common settings in VS Code directly, like fortitude.lineLength fortitude.check.select (to configure the enabled check rules):

{
  "fortitude.lineLength": 88,
  "fortitude.check.select": ["C", "E", "F", "W"]
}

To use a custom configuration file, set the fortitude.configuration setting to the path of your fortitude.toml or fpm.toml file:

{
  "fortitude.configuration": "/path/to/fortitude.toml"
}

Finally, to use a common Fortitude configuration across all projects, consider creating a user-specific fpm.toml or fortitude.toml file as described in the FAQ.

Fortran-based language server (fortitude-lsp)

Warning

fortitude-lsp is deprecated and will be removed in a future release. Please switch to the Rust-based language server (fortitude server) instead.

If you're using the default Fortran-based language server, you can use the fortitude.lint.args and fortitude.format.args settings in settings.json to pass command-line arguments to Fortitude.

For example, to enable the pyupgrade rule set in VS Code, add the following to settings.json:

{
  "fortitude.lint.args": ["--extend-select=UP"]
}

To override the VS Code extension's Fortitude configuration entirely, and override any local fpm.toml file or similar, you can pass a custom --config argument to the Fortitude CLI, again using the fortitude.lint.args and fortitude.format.args options in settings.json:

{
  "fortitude.lint.args": ["--config=/path/to/fortitude.toml"],
  "fortitude.format.args": ["--config=/path/to/fortitude.toml"]
}

Finally, to use a common Fortitude configuration across all projects, consider creating a user-specific fpm.toml or fortitude.toml file as described in the FAQ.

Commands

Command Description
Fortitude: Fix all auto-fixable problems Fix all auto-fixable problems
Fortitude: Restart Server Force restart the linter server
Fortitude: Print debug information Print debug information about the native server
Fortitude: Show client logs Open the Fortitude output channel
Fortitude: Show server logs Open the Fortitude Language Server output channel

Requirements

This extension requires a version of the VSCode Python extension that supports Python 3.7+. Fortitude itself is compatible with Python 3.7 to 3.15.

Troubleshooting

If you encounter any issues with the extension or the language server, please refer to the logs in the corresponding output channel in VS Code. The extension logs are in the "Fortitude" output channel and the language server logs are in the "Fortitude Language Server" output channel.

To open the output panel, use the Output: Show Output Channels command in the command palette (Ctrl+Shift+P or Cmd+Shift+P), then select "Fortitude" or "Fortitude Language Server". Alternatively, you can use the Fortitude: Show client logs and Fortitude: Show server logs command to open the "Fortitude" and "Fortitude Language Server" output channel respectively. The Fortitude: Print debug information command can be used to print debug information which can include details about the current open file.

The default log level for the extension is info which can be changed from the output panel using the settings icon in the top right corner of the panel.

The default log level for the language server is info which can be changed using the fortitude.logLevel setting in your settings.json:

{
  "fortitude.logLevel": "info"
}

The language server logs can be directed to a file by setting the fortitude.logFile setting in your settings.json:

{
  "fortitude.logFile": "/path/to/fortitude.log"
}

To capture the LSP messages between the editor and the server, set the fortitude.trace.server setting to either messages or verbose in your settings.json:

{
  "fortitude.trace.server": "messages"
}

This will be visible in the "Fortitude Language Server Trace" output channel. The difference between messages and verbose is that messages only logs the method name for both the request and response, while verbose also logs the request parameters sent by the client and the response result sent by the server.

The extension also displays certain information in the status bar. This can be pinned to the status bar as a permanent item.

License

MIT

About

Fast Fortran linting in VS Code

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published