Giter VIP home page Giter VIP logo

vscode-as's Introduction

NOTE

Please note: This repository is currently unmaintained. If you'd like to add features or fix issues, consider creating a fork. Please be aware that we are not going to be updating issues or pull requests on this repository.

AssemblyScript for VSCode

Build

VSCode Language Client for AssemblyScript

Requirements

  • AssemblyScript 0.10.0+

Usage

  • Install the extension from the VSCode Marketplace.
  • The extension support Linux, Mac and Windows via WSL.

By default the language server will report diagnostics for files located under the assembly/ directory. The configuration can be changed under the extension settings to include other files.

The default configuration values are:

"asls.include": {
  "description": "AssemblyScript sources to analyze",
  "type": "array",
  "default": [
    "assembly/**/*.ts",
    "assembly/*.ts"
  ]
},
"asls.port": {
  "description": "Port in which the language server will be listening",
  "type": "number",
  "default": 0
},
"asls.debug": {
  "description": "Start the language server in debug mode",
  "type": "boolean",
  "default": false
}

Development

If you want to develop the extension using a development version of the language server, you need to:

  1. Build the langue server binary (mix release)

  2. Symlink the language server binary into this directory ln -s path/to/language/server/asls/_build/dev/rel/asls/bin/asls asls

  3. Run npm install and npm run compile

  4. Make sure to have Erlang 22+ installed, if you're using nix you can do so by running nix-env -iA nixpkgs.erlang

  5. Under the debug section in VSCode click on Run extension

  6. Once the extension is runing, in VSCode's output console, verify that the logs specify that the language server was started from the relative symlink, it looks something like:

    Starting the AssemblyScript Language Server from: /path/to/extension/vscode-as/asls
    

To release a new version

  1. Bump the version in the package.json
  2. Package the extension by running yarn && npx vsce package --yarn
  3. Test the packaged extension by running code --install-extension ./asls-x.x.x.vsix
  4. Publish via npx vsce publish
  5. Publish to open-vsx via npx ovsx publish ./asls-x.x.x.vsix -p <token>

vscode-as's People

Contributors

dependabot[bot] avatar dphm avatar saulecabrera avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vscode-as's Issues

asls not found

In my package.json I have the required asbuild command:

{
  "scripts": {
    "asbuild": "asc --extension as",
  }
}

When I run yarn asbuild it perfectly builds, and shows me errors:

image

I use Windows so I installed alpine-linux via WSL, installed Nix there, and started the language server in Terminal:

image

But still I'm getting this asls not found error in VSCode:

image

In console where I run asls I see no errors or anything when starting VSCode, though if I manually try to access localhost:7658 in browser and then close the tab, it shut downs with error:

image

So therefore it's not the issue with port forwarding or anything, but the extension itself, it seems. The version:

asls --version
v0.5.1

VSCode saulecabrera.asls version: v0.3.3

Installation issues

This extension installs the ERTS for Darwin on Linux and is thus unable to start the language server:

$ uname -a
Linux psi3-pc 5.15.4-zen1-1-zen #1 ZEN SMP PREEMPT Sun, 21 Nov 2021 21:34:35 +0000 x86_64 GNU/Linux
$ file .vscode/extensions/saulecabrera.asls-0.4.0/bin/asls/erts-11.1.8/bin/erlexec
.vscode/extensions/saulecabrera.asls-0.4.0/bin/asls/erts-11.1.8/bin/erlexec: Mach-O 64-bit x86_64 executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|PIE>

In addition to that, asls/releases/0.6.0/elixir links to /bin/sh in a weird way that doesn't work:

$ head --lines=1 .vscode/extensions/saulecabrera.asls-0.4.0/bin/asls/releases/0.6.0/elixir
#!/nix/store/kl013dwzxf67l4pfrx6x2d5q6pq9gf36-bash-4.4-p23/bin/sh

I'm not sure if this is an issue with this extension or asls, and I'm frankly not familiar with the AssemblyScript ecosystem yet.

Add extension configuration

The AssemblyScript compiler allows the usage of multiple extensions with

asc --extension <extension>

The compiler only understands a single extension at a time, for constraint purposes initially the plugin will only allow setting the extension to either .asc or .ts

AssemblyScript Language Server not found for platform: darwin

On an apple silicon system I can't use this extension:

The AssemblyScript Language Server not found for platform: darwin. The supported platforms are: MacOS x64 and Linux x64 If you're on Windows try starting the VSCode Extension from VScode Windows Subsystem for Linux (WSL)

I have installed asls and it looks like it's working, I can start it manually -- but there seems to be no way to either tell the extension "run this binary for asls" or "assume it's running, connect to the port I told you".

Kinda disappointed, hoped this would work :/

Add build configuration

Right now the language server assumes that all projects are built through npm run asbuild, the build command should be configurable:

  • npm run asbuild command might not be the default for all projects
  • The default npm run asbuild builds the optimized and unoptmized wasm for the source files, which can result in delays for diagnostic reporting, minimizing the build command to a single command will reduce latency between diagnostic reports.

Elixir not found

When I install or enable the extension VS code gives me the error:

"AssemblyScript Language Server not started. The server returned: /home/user/.vscode/extensions/saulecabrera.asls-0.4.0/bin/asls/bin/asls: 108: exec: /home/user/.vscode/extensions/saulecabrera.asls-0.4.0/bin/asls/releases/0.6.0/elixir: not found"

I've checked the folder, but elixir is there and can be executed in the terminal.

Language server crashes with locale error

In an attempt to fix #42 (#47) I updated the asls to the latest release, followed the instructions in the README and repackaged the extension as v0.4.1, finally installing the vsix locally. Then it fails in a different way:

AssemblyScript Language Server not started. The server returned: warning: the VM is running with native name encoding of latin1 which may cause Elixir to malfunction as it expects utf8. Please ensure your locale is set to UTF-8 (which can be verified by running "locale" in your shell)

I'm sure why that is happening, or where to start fixing it. I can't see "latin1" anywhere in the environment.

I force LC_ALL=en_US.UTF-8 in the environment, and there's a new error:


  AssemblyScript Language Server not started.
  The server returned:

  ** (UndefinedFunctionError) function AssemblyScriptLS.CLI.start_with_options/1 is undefined or private
    AssemblyScriptLS.CLI.start_with_options([port: 0])
    (stdlib 3.14.2) erl_eval.erl:680: :erl_eval.do_apply/6
    (elixir 1.11.4) lib/code.ex:341: Code.eval_string_with_error_handling/3

I don't know where to even start with that one.

Improve update instructions when the server minimum version is not met.

As of today, the error message reads:

 The AssemblyScript Language Server CLI is outdated.
 The currrent version is ${current}.
 The current version of the language client requires v${MINIMUM_SERVER_VERSION}.
 Please update the AssemblyScript Language Server.

The error message should also point devs to the language server update instructions.

Bad interpreter

I can't start the language server. After some dig, got the log below.

Note : I'm using linux, and tried to install elixir natively.

xsp➜  bin  ᐅ  bash -x asls start
+ set -e
++ readlink asls
++ true
+ SELF=
+ '[' -z '' ']'
+ SELF=asls
+++ dirname asls
++ cd ./..
++ pwd -P
+ RELEASE_ROOT=/home/alsan/Templates/assemblyscript/extensions/saulecabrera.asls-0.4.0/bin/asls
+ export RELEASE_ROOT
+ export RELEASE_NAME=asls
+ RELEASE_NAME=asls
++ cut '-d ' -f2 /home/alsan/Templates/assemblyscript/extensions/saulecabrera.asls-0.4.0/bin/asls/releases/start_erl.data
+ export RELEASE_VSN=0.6.0
+ RELEASE_VSN=0.6.0
+ export RELEASE_COMMAND=start
+ RELEASE_COMMAND=start
+ export RELEASE_MODE=embedded
+ RELEASE_MODE=embedded
+ REL_VSN_DIR=/home/alsan/Templates/assemblyscript/extensions/saulecabrera.asls-0.4.0/bin/asls/releases/0.6.0
+ . /home/alsan/Templates/assemblyscript/extensions/saulecabrera.asls-0.4.0/bin/asls/releases/0.6.0/env.sh
++ cat /home/alsan/Templates/assemblyscript/extensions/saulecabrera.asls-0.4.0/bin/asls/releases/COOKIE
+ export RELEASE_COOKIE=C7RIIBBF44SCHHZ2PWNPKXMDDHGHI6FBODNZFPSARHLXNQFCNMZA====
+ RELEASE_COOKIE=C7RIIBBF44SCHHZ2PWNPKXMDDHGHI6FBODNZFPSARHLXNQFCNMZA====
+ export RELEASE_NODE=asls
+ RELEASE_NODE=asls
+ export RELEASE_TMP=/home/alsan/Templates/assemblyscript/extensions/saulecabrera.asls-0.4.0/bin/asls/tmp
+ RELEASE_TMP=/home/alsan/Templates/assemblyscript/extensions/saulecabrera.asls-0.4.0/bin/asls/tmp
+ export RELEASE_VM_ARGS=/home/alsan/Templates/assemblyscript/extensions/saulecabrera.asls-0.4.0/bin/asls/releases/0.6.0/vm.args
+ RELEASE_VM_ARGS=/home/alsan/Templates/assemblyscript/extensions/saulecabrera.asls-0.4.0/bin/asls/releases/0.6.0/vm.args
+ export RELEASE_DISTRIBUTION=sname
+ RELEASE_DISTRIBUTION=sname
+ export RELEASE_BOOT_SCRIPT=start
+ RELEASE_BOOT_SCRIPT=start
+ export RELEASE_BOOT_SCRIPT_CLEAN=start_clean
+ RELEASE_BOOT_SCRIPT_CLEAN=start_clean
+ case $1 in
+ start elixir --no-halt
+ set +x
asls: /home/alsan/Templates/assemblyscript/extensions/saulecabrera.asls-0.4.0/bin/asls/releases/0.6.0/elixir: /nix/store/kl013dwzxf67l4pfrx6x2d5q6pq9gf36-bash-4.4-p23/bin/sh: bad interpreter: No such file or directory
asls: line 60: /home/alsan/Templates/assemblyscript/extensions/saulecabrera.asls-0.4.0/bin/asls/releases/0.6.0/elixir: Success
xsp➜  bin  ᐅ  

Please publish to open-vsx for open source distributions of VS Code.

This extension is not available for VS Code that ships with various open source Linux distributions.

Screenshot from 2021-02-08 16-51-34

To make it available, you can publish to https://open-vsx.org, which is a place that host VS Code extensions that open source distributions connect their versions of VS Code to (in OSS distros, the name VS Code can't be used, so they change it. F.e. in Manjaro Linux the VS Code app is called "Code - OSS").

Here's the result for "assemblyscript" on open-vsx:

https://open-vsx.org/?search=assemblyscript&category=&sortBy=relevance&sortOrder=desc

That explains why I don't see it in my "Code - OSS" app. I just found out about open-vsx. Thought there was a bug.

Add enable configuration option

Given that AssemblyScript supports many extensions and one of them being ts it would be ideal to have an enable configuration key so that consumers can decide when should the extension be available. The only way to achieve this right now is to manually disable the extension in TypeScript projects.

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.