Code Monkey home page Code Monkey logo

vscode-janet-plus-plus's Introduction

Janet language support for Visual Studio Code

This extension adds language support and some IDE-lite editor features for the Janet programming language to VS Code.

Just starting with Janet? See the official language introduction here.

Features

  • .janet file type support and syntax highlighting for Janet files
  • Create a Janet REPL session in the integrated terminal (Janet: Start REPL in the Command Palette)
    • Evaluate expressions from any open .janet file (with alt+e) or load the entire open file into the REPL (with alt+l), creating a new one if none is currently active
  • Auto-format Janet code while typing, or format current form on command (with Tab)
  • Structural editing and navigation using ParEdit-style Sexp commands
    • Ctrl+Left/Right to move cursor by S-Exp
    • Alt+Up/Down to drag S-Exp forward/backward
    • "Slurp" (extend parentheses), "Barf" (shrink parentheses), and other PareEdit commands (see this visual guide to ParEdit on the Calva website for more info, most of which applies without modification to this extension too)
  • Language Server Protocol via embedded Janet LSP
    • Inline compiler error underlining
    • Function and macro autocomplete
    • On-hover symbol definitions

More coming soon!

Usage

Janet LSP and startup.janet

Janet LSP works by running a copy of the Janet runtime and flychecking (that is, compiling but not fully evaluating) the code in your active editor window using that runtime instance. This allows for on-hover documentation and compiler warnings to be provided by Janet itself.

Sometimes, you may need to pre-load modules or modify the environment table in other ways in order for the LSP's runtime to correctly recognize the code in your editor. In such cases, you can create a .janet-lsp/ directory in your project's root and add a startup.janet file to that folder. If such a startup script is detected, the LSP will fully execute it prior to initiating the startup handshake with your editor.

The code in startup.janet is normal Janet source code that is executed by the server's runtime. Don't put any code you don't completely trust in startup.janet.

Contributing

Issues and PRs are welcome!

Prior Art

Huge portions of this extension are remixed from other open source projects, including:

vscode-janet-plus-plus's People

Contributors

bakpakin avatar cfiggers avatar chrisfougner avatar dependabot[bot] avatar foges avatar honix avatar lpedrosa avatar pyrmont avatar quan-nh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

jangler turbohz

vscode-janet-plus-plus's Issues

Wrong indentation for many macros with `& body` args

The following macros from the core API currently indent like normal tuples rather than like do:

  • compwhen
  • coro
  • defer
  • edefer
  • ev/do-thread
  • ev/spawn
  • ev/span-thread
  • ev/with-deadline
  • ffi/defbind
  • fiber-fn
  • forever
  • for
  • forv
  • generate
  • label
  • prompt
  • protect
  • repeat
  • when-with
  • with

TODO: Handle Anonymous functions correctly

Currently will re-format Janet's anonymous function macro, which should look like this:

|(fn args)

to this instead:

| (fn args

Fortunately doesn't cause anonymous function to break (Janet ignores the whitespace) but should still fix.

Probably as simple as adding | to a regex somewhere that handles prefixes (like # or @ in other places).

TODO: Add support for long strings

Currently the lexer recognizes only "regular" (short?) strings (i.e., those wrapped with " regular quotation marks). Janet supports long strings, which currently is not recognized by the lexer.

This causes the janet:cursorInString flag to be false even when the cursor is inside of a long string.

This causes structural editing features to misbehave when the cursor is inside a long string.

Also, auto indentation inside long strings is unpredictable.

New local imports not picked up by the LSP

I added a new module to my local code during a session. Janet++ told me the imported bindings didn't exist. Restarting VS Code fixed the problem.

I'm using the v.1.1.2 prerelease.

TODO: Add support to set your own path to the janet language server in the system

feature request
You should have the possibility to set the path in the plugins settings to your own language server version. Default should be the language server, which is delivered with the extension.

Maybe the user can also set an environment variable to the path of the language server in his operating system. If this is set, this can also be selected as default.

It is important that the extension handles the path differently in operating systems like linux or windows.

TODO: Fix Ctrl + Arrow key movement while in a comment

Currently, Ctrl + Arrow key invokes Janet Paredit: Move Cursor [Forward | Backward or Up] Sexp/Form (aka janet.paredit.backwardSexp). That's good in code, but really annoying in a comment (where it would be better to only do cursorWordLeft/cursorWordRight).

LSP fails to start

I'm attempting to use Janet++ in a small project and see this error when the LSP attempts to start:

error: nil called with 2 arguments, possibly expected 1
  in <anonymous> [src/main.janet] on line 212, column 13
  in map [boot.janet] on line 998, column 3
  in find-unique-paths [src/main.janet] on line 212, column 8
  in main [src/main.janet] (tailcall) on line 228, column 14
  in run-main [boot.janet] on line 3936, column 16
  in cli-main [boot.janet] on line 4076, column 13

I'm running Janet 1.32.1-meson on Mac OS and VSCode 1.83.1

Completion suggests incomplete versions of private identifiers

Create a new Janet file. Type a top-level def- binding. Start typing the bound identifier. Incomplete versions of the name appear in the completion list. For instance, if the identifier is circumference, completion will suggest ci, cir, circ, circu, etc.

Error when I import a module (e.g. json)

Hi,

when i import the janet json module i get the following error.
(import json :prefix "")

"could not load native /usr/local/lib/janet/json.so: config mismatch - host 1.31.0(0001) vs. module 1.32.1(0001)".

i reinstalled janet 1.32.1, recompiled json, changed the language server etc.
which config is meant? or where does this error come from?
System:
Distributor ID: Ubuntu
release: 22.04

thanks, Felix

Issues with "evaluate expression" behavior

The "evaluate expression" command in Janet++ has a few peculiarities compared with pretty much every other evaluate-in-editor plugin I've used:

  1. Evaluating an expression also selects the expression for some reason.
  2. The command doesn't really evaluate expressions; it evaluates top-level forms. If it's supposed to be "evaluate expression", you should be able to put the cursor after a subform or literal or whatever and evaluate just that.
  3. Top-level forms that aren't enclosed in parens/brackets/etc. can't be evaluated (it looks like just a newline is sent to the REPL).

I'm using v1.1.1 pre-release. Thanks for this project; I was really pleased to see that someone was working on this sort of thing.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.