Skip to content

lcompilers/lpython-vscode-extension

Repository files navigation

lpython-vscode-extension

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.

Key Features

  1. Linting: highlights errors and warnings in your LPython code which helps you to identify and correct programming errors.
  2. 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.
  3. Syntax Highlight: Coloring and styling of source code displayed in vscode editor using TextMate grammars.

Language Server

  • 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); 

Usage

  1. Install LPython: Refer to lpython documentation (build as usual, but ensure -DWITH_LSP=yes in cmake).

  2. Install npm, for example via Conda:

conda create -n npm nodejs
conda activate npm
  1. Clone the repository:
git clone https://github.com/lcompilers/lpython-vscode-extension
  1. Build the extension:
cd lpython-vscode-extension && npm install && npm run compile
  1. 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).

Contributing

We welcome contributions from anyone, even if you are new to open source.

  1. To contribute, submit a PR against your repository at: https://github.com/lcompilers/lpython-vscode-extension
  2. 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.

About

LPython extension to VSCode

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published