LPython extension for VSCode
There are no pre-packaged versions of this extension, but will be packaging the extension to VS Code market place very soon.
- Linting: highlights errors and warnings in your LPython code which helps you to identify and correct programming errors.
- Document Symbol Lookup: You can navigate symbols inside a file with
Ctrl + Shift + O
. By typing:
the symbols are grouped by category. Press Up or Down and navigate to the place you want. - Syntax Highlight: Coloring and styling of source code displayed in vscode editor using TextMate grammars.
- The Language Server is written in TypeScript, which uses Microsoft’s official language server module.
- Communication between the language server and LPython Compiler is done with
const stdout = await runCompiler(text, "<flags>", settings);
-
Install LPython: Refer to lpython documentation (build as usual, but ensure
-DWITH_LSP=yes
in cmake). -
Install npm, for example via Conda:
conda create -n npm nodejs
conda activate npm
- Clone the repository:
git clone https://github.com/lcompilers/lpython-vscode-extension
- Build the extension:
cd lpython-vscode-extension && npm install && npm run compile
- Create the package locally:
npm install vsce -g
vsce package
Say "Y" to the question "Using *
activation is usually a bad idea as it impacts performance. Do you want to continue?".
This will generate a lpython-1.0.0.vsix
file in your current directory, which
can then be imported as an extension in VSCode:
- Go to extensions (on the left)
- Click on the
...
on the top right - Click on "Install from VSIX" and select the
lpython-1.0.0.vsix
If you have the lpython
binary in your $PATH
then everything should just
work. If you do not, then you have to tell the extension where to find it:
- Select the
lpython
extension in your installed extensions - Click on the Settings button -> Extension Settings
- Search for "lpython"
- Change "LPython Language Server › Compiler: Executable Path" to the correct
path to the
lpython
binary on your system
The extension should now work. Create a new file a.py
and put x = 5
in
there. The x
should get highlighted with an error message that x
is not
declared (you have to change it to x: i32 = 5
to work).
We welcome contributions from anyone, even if you are new to open source.
- To contribute, submit a PR against your repository at: https://github.com/lcompilers/lpython-vscode-extension
- Please report any bugs you may find at our issue tracker: https://github.com/lcompilers/lpython-vscode-extension/issues
We welcome all changes, big or small!
Here is how to develop this extension:
conda create -n npm nodejs
conda activate npm
git clone https://github.com/lcompilers/lpython-vscode-extension
cd lpython-vscode-extension && npm install && npm run compile
The go to VSCode and:
- Ctrl-Shift-D (Command-Shift-D on macOS)
- Click on "Run and Debug"
- Select "VSCode Extension Development"; a new VSCode window will pop up with the extension already running in it.