Skip to content

Provides syntax checking and fixing, highlighting, autocompletion, hints, symbol outline, identifier recognition and renaming and other features for the OScript language in Visual Studio Code.

License

Notifications You must be signed in to change notification settings

prantlf/vscode-oscript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OScript Language for Visual Studio Code

Logo Build Status Dependency Status devDependency Status license

Provides syntax checking and fixing, highlighting, autocompletion, hints, symbol outline, identifier recognition and renaming and other features for the OScript language in Visual Studio Code.

Installation

Install this extension to your Visual Studio Code from the marketplace, or download a specific version of a released package and install it from the file.

Features

Except for the first four features below, the others depend on the OScript language server, which will be started in the background automatically.

Syntax Highlighting

The source code is broken down to tokens like keyword, identifier or literal, which are recognised by the highlighter. You just choose a visual theme to colourise them.

An example of the syntax highlighting in the Dark+ theme:

Dark highlighting

An example of the syntax highlighting in the Light+ theme:

Light highlighting

Scope Folding

Foldable scopes are comments, preprocessor directive blocks, objects, scripts and functions. The scope-closing token (the end keyword, the #else or #endif directives, or the multiline-commend ending */) will be included in the folded code.

Folded function

Code Commenting / Uncommenting

Commands "Toggle Line Comment" (Cmd+/) and "Toggle Block Comment" (Shift+Alt+A) can be used to enclose a code block in a comment, or undo this operation.

Commented-out code

Bracket Matching

Parentheses, square brackets and curly braces are recognised as pairs, so that you can navigate between them or emphasize them. You can make use of it using commands like "Go to Bracket" (Shift+Cmd+\) or extensions like Bracket Pair Colorizer 2.

Highlighted brackets

Syntax Checking

Static source code analysis can point to syntax errors, which would make the later compilation fail. Parsing of the source code will stop after the first error is encountered. Problems that the compiler can recover from are reported as warnings.

You can see all problems in the Problems sidebar:

Syntax error and warning in a sidebar

You can also show details about a problem that you focused in-place by the command "Peek Problem" (Alt-F8):

Peek problem details

Quick Fixes

Some problems encountered during the syntax check can be corrected automatically. They are reported as warnings. If you hover above the problem location, you will be able to click on "Quick Fix..." (Cmd+.):

Problem when hovered above

When executing the command, you will be able to pick a kind of the fix to perform on the source code:

Quick fixes for a problem

Autocompletion

Autocompletion with details collapsed:

Autocompletion with details collapsed

Autocompletion with details expanded:

Autocompletion with details expanded

The autocompletion works currently only for the built-in global functions and object methods.

Hints on Hover

A hint about the usage of a keyword or an identifier will be displayed when hovering the mouse cursor above it. The information is the same as for the autocompletion.

Hover hint

The hover hints work currently only for the built-in global functions and object methods.

Symbol Outline

Symbols that introduce scopes to the code, like objects, functions or script are displayed in the Outline sidebar or in the document breadcrumb area to help you orientate yourself in the source file.

Symbol outline and breadcrumb

Definition and References

You can jump to the definition of a variable or a function by the command "Go to Definition" (F12):

Go to definition

You can cycle over references of a variable or a function one-by-one by the command "Go to References" (Shift+F12):

Go to references

You can also list all references of a variable or a function by the command "Find All References" (Shift+Alt+F12):

Find all references

The support for definitions and references works currently only for the locally declared variables and functions.

Renaming

You can rename a variable or a function by the command "Rename Symbol" (F2).

Rename symbol after hitting F2

Rename symbol result

Identifier renaming works currently only for the locally declared variables and functions.

Run Script

You can run a script (ending with .e or .lxe) and watch the progress on the console. For example:

Echo("Hello, world!")

Will print "Hello, world!" to the console output.

This feature is in the development and depended on the state of oscript-interpreter.

Settings

This extension contributes the following settings. Names of the properties in table are shortened not to occupy so much space. They have to be prefixed by "oscript." to get the full name:

Name Type Description Default
languageServer.enabled boolean enable/disable the language server true
validation.enabled boolean enable/disable syntax validation true
completion.enabled boolean enable/disable typing completion true
hover.enabled boolean enable/disable the hover hints true
symbols.enabled boolean enable/disable the symbol outline true
definition.enabled boolean enable/disable locating definitions true
references.enabled boolean enable/disable finding references true
rename.enabled boolean enable/disable identifier renaming true
quickFixes.enabled boolean enable/disable quick-fixes for problems true
whatIsNew.change string limit the "What Is New" announcement "minor"
logging.level string level of console diagnostics messages "error"

Expected values for the oscript.whatIsNew.change property are "none", "major" , "minor" or "patch". They refer to a change in the version format major.minor.patch.

Expected values for the oscript.logging.level property are "error", "warning" or "debug".

If oscript.languageServer.enabled is set to false, all features will be disabled, which need the OScript language server.

Planned

  • Autocompletion and hover hints for user code
  • Go to definition
  • Renaming of other than local identifiers and files
  • Snippets
  • WebLingo support

Notes

If you keep to the official OScript coding standard, use tabs and set the visual tab size to 4 in settings.json:

"[oscript]": {
  "editor.tabSize": 4,
  "editor.insertSpaces": false,
  "editor.detectIndentation": false
}

Troubleshooting

If you encounter an unexpected behaviour, inspecting the debug output may help to pinpoint the problem. Diagnostic messages can be enabled by:

"oscript.logging.level": "debug"

If you encounter problems with features supplied by the OScript language server, you can disable them by boolean flags described above. If you encounter performance problems, you can disable all features using the language server and retain just features supplied by the static language description like syntax highlighting:

"oscript.languageServer.enabled": false

If you do encounter such problems, file a bug report about it, please. Thank you!

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Run npm test to validate your changes. Use the examples in the pkg/examples directory to check the effect of your changes.

Others

Users of TextMate can install the OScript Bundle. Other editors with the syntax highlighting for OScript are based on Scintilla, for example. SciTE, Geany, Nodepad++ and others include a colourful theme for the OScript lexer.

Web pages can highlight the OScript syntax of a code example using JavaScript.

License

Copyright (c) 2020-2022 Ferdinand Prantl

The logo was based on an original icon published among vscode by Roberto Huertas under the Creative Commons Attribution 4.0 International (CC BY 4.0) license. Thank you!

Licensed under the MIT license.

About

Provides syntax checking and fixing, highlighting, autocompletion, hints, symbol outline, identifier recognition and renaming and other features for the OScript language in Visual Studio Code.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published