Integrates VSCode with LFortran's language server. The extension is extremely lightweight and delegates all the heavy lifting to the language server.
Before you install this extension, please be sure to install lfortran
per the
installation instructions. Unless
you intend to develop lfortran
, it is recommended to install it with Conda.
Once you have installed lfortran
, it is recommended to install this extension
via the VSCode
Marketplace.
If you would like to build this extension from source, please install lfortran
as described, above. Then, follow these instructions:
# Clone the repository if you have not already:
git clone https://github.com/lfortran/lfortran-vscode-client.git
cd lfortran-vscode-client
# If you already had it cloned, update your repo:
git checkout main
git pull origin main
# Install the NPM dependencies:
npm install
# Remove old build artifacts:
rm -rf out *.vsix
# Bundle the package:
npx vsce package
# Uninstall any older version of the extension from VSCode:
code --uninstall-extension lcompilers.lfortran
# Install the package you just created:
code --install-extension *.vsix
Once you have installed the extension, it should begin working immediately when
a Fortran file is opened or edited. More specifically, any time a file is opened
or edited with one of the following file extensions, this VSCode extension will
be activated: .f
; .for
; .f90
; .f95
; .f03
.
LFortran will automatically check a document for syntactic and semantic errors
and warn about potential issues. Errors will be highlighted and described in the
Problems
terminal (View -> Problems
).
To jump to a symbol's definition, either place the cursor over it and press
F12
or right-click it and select Go to Definition
from the context menu.
When the cursor hovers over a symbol, a preview of its definition will be placed next to it.
You may configure the extension by clicking the Extensions
tab, followed by
clicking the gear icon on the bottom-right of the LFortran
list item, and
lastly by clicking the Settings
menu item. Most of the settings are common to
all workspaces but the compiler flags may be modified at the resource level.
If you would like to debug the extension, please do the following:
- Open the extension's output terminal by selecting
View -> Terminal
from the menu bar. Then, select theOutput
tab and chooseLFortran
from the combo box near the top-right. - Open the extension's settings and enable at least a
debug
log level. - If you would like trace-level logging, you may set the log level to either
trace
orall
to enable the most granular level of logging within the extension, or leave the log level alone and enable request tracing underLFortran > Trace: Server
. If you enableverbose
request tracing, the JSON payloads will be pretty-printed if you have enabledLFortran > Log: Pretty Print
. - The language server mirrors its logs to a log file. Its default location is a
file named
lfortran-language-server.log
that is located relative to the root of your workspace.