Skip to content

User script and a backing service for Language Server Protocol support for Codewars.

Notifications You must be signed in to change notification settings

hobovsky/cw-lsp

Repository files navigation

cw-lsp - Language Server Integration for Codewars Code Editors

cw-lsp is a browser-side extension (implemented as a Tampermonkey userscript) that turns Codewars code editors into Language Server Protocol clients and enriches them with some basic IDE-like functionality. It currently supports:

  • Language Server Protocol features: code completions, callable signatures, code diagnostics, documentation;
  • Languages: JavaScript, Python, PHP, Rust;
  • Codewars editors: currently, the only supported editor is the Solution editor in kata trainer.

Client

To use code completion when training on a Codewars kata, only the client userscript is required:

  • Install Tampermonkey extension for your browser.
  • Install the user script with client side implementation. It can be found in client/cw-lsp.user.js, and installed by clicking this link. Read TamperMonkey FAQ for help. Remember about enabling userscript permissions and/or Development Mode if your browser requires it!
  • Open kata trainer for one of supported languages.
  • Start typing code in the Solution editor. Use one of following key combinations:
    • Shift-Space to trigger completion suggestions.
    • Alt-A to trigger signature hints.
    • Alt-H to present documentation help.
  • Click the blue LSP button to show or hide the floating LSP panel. The panel can be moved around and resized, and it will remember its position.

Known issues

  • cw-lsp can see only code from the user solution editor in the kata trainer. It does not work in other code editors (sample tests, translations, kata editor), and it does not see code from preloaded snippet. If user solution references symbols from preloaded, cw-lsp will not see them, and can report errors related to them.
  • Currently, backend LSP process shuts down after 30 minutes of inactivity. It can be restarted by hard reload of the kata trainer.
  • PHP: Snippets must start with <?php directive. Old kata may be missing the directive in the solution setup, and it has to be added manually for LSP to work correctly.
  • Rust: Startup of language servers for Rust can take some time. Usually, it is ~10-20 seconds until it starts returning completion suggestions. Until the language server fully initializes, it may return no responses, or incomplete responses. It can also feel sluggish and responses can be returned with a noticeable delay. Readiness of Rust Analyzer can be roughly estimated by tracking the "Initializing" progress message in the log panel, and waiting until it gets marked with a green check mark.

Server

Server does not have to be run locally to use cw-lsp. Client script is configured to use a publicly available service. However, anyone who wants to run it locally to get more resources for their language server, tinker with backend, or run it for development purposes, can follow instructions below.

Build

With npm:

npm ci
npm run build

With Docker:

docker build -t cw-lsp-app .

Run

With npm:

# make sure that LSP_TEMPLATES_DIR is set
npm start

With Docker:

docker run -p 3000:3000 cw-lsp-app

Guarantees

cw-lsp is an experimental tool under active development.

  • Features, behavior, and supported languages may change at any time.
  • Backward compatibility is not guaranteed.
  • The publicly available server is provided on a best-effort basis, has limited capacity, and may be unavailable, slow, or reset without notice.
  • No uptime, performance, or data persistence guarantees are provided.

Use the tool with the expectation that occasional breakage or downtime may occur.

About

User script and a backing service for Language Server Protocol support for Codewars.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors