Maintenance of vscode plugin

As probably many vscode users, I use faustinoaq.crystal-lang. The source code is located at https://github.com/crystal-lang-tools/vscode-crystal-lang .

There are collaborators on that project and organization that had already accepted PR and tagged releases. Yet those were not published at faustinoaq.crystal-lang.

I think it would be important to have an organization vscode publisher that can be shared among maintainers of the repo (and probably automate some aspects). I’ve already reserved the crystal-lang-tools publisher name in https://marketplace.visualstudio.com/.

The work done by faustino and others has been great, since I switched to vscode I’ve been using this plugin. I would not like for it to become unmaintained.

Although I am owner of the github organization, I have not been actively involved in it. I’ve tried to reach faustino by email to organize future efforts to accomplish this.

cc: @Acciaiodigitale @faustinoaq

14 Likes

Faustino says to me that have problem accessing the marketplace account so he cannot add me for releasing new version of the plugin. IMHO the better thing to do, is to fork and create a repository at least for vscode that is mantained by the core organization (like VSCode for Go or Sublime Text for Elixir).

If you can send me your’s and faustino emails of the marketplace I can add you to the crystal-lang-tools publisher.

Is there a channel where vscode plugin conversation happens?

Why do you think is best to fork the source code repo instead of migrating to an orrganization publisher using the same repo?

acciaiodigitale [at] gmail [com] is mine
IDK Faustino email

Also please put me again in crystal-lang-tools (I leave when I see I cannot do all is needed but this change all)

If someone of the core team is in the organization is good to leave the repos under the organization and having an organization publisher.

Today I finally created the crystal-lang-tools updated version of the Crystal Language plugin for VSCode.

The version is v0.5.0 to give continuity to the work of @faustinoaq.

Anyone that want to help with this (or other editors plugins) is more than welcome!!

My next step are a template for submitting issue and close all too old issue and seeing what remain to start working on assuring no big issue are present.
After that I prepare a new test suite and move CI/CD to Github Actions for release a v.1.0.0 at the same time of Crystal Language

Thank you so much for working on this! I’m excited to see proper scry support, mine crashes ALOT, so I just turned it off. Let me know if you need a tester, I have crystal installed on WSL, Ubuntu, and I remote from my Windows machine to my Ubuntu through VSCode’s remote SSH feature, so there’s a lot of ground to cover for potentially bugs between the three options.

Can you please try the new 0.6.1 and eventually Crystalline instead of Scry

Can the other extension be removed? It has the most downloads so it shows up first.

I’m pretty sure the extension is great!

That said, how can I use it? I just installed the extension, I have crystalline in the path (do I have to manually run it?). I used crystal init to create an app called crystal_test. I put this into src/crystal_test.cr:

class Foo
  def foo
    1
  end
end

f = Foo.new
f.

I hit ctrl+space to trigger autocompletion but I only get completions for the words that appear in the file, unrelated to the plugin. I also tried with arrays and some other types.

Am I missing some configuration? Is there an activity log I can see to debug the plugin?

Hey @asterite, thanks for trying it out :smile:!

No need to run it manually, it should be monitored by the VSCode extension after adding the absolute path of the binary to the Server option in the configuration (and restart the editor). There is a screenshot of the configuration option which may be more clear to follow here.

Personally I use the workspace configuration, which creates a .vscode/settings.json file containing:

{
  "crystal-lang.server": "/my/path/to/crystalline"
}

For instance with your example after configuring the plugin I get this (ignore the orange warning, it comes from ameba):

Yes there are (INFO level by default - debug is very noisy), you can acess them by pressing CMD+SHIFT+P then type “dev logs”.

Also keep in mind that this is a work in progress, I’m committing on a daily basis to improve several aspects of the program.

1 Like

Oh, wow, after specifying the path and restarting it’s working great! Congrats! :clap:

When I specify a method with type restrictions, when it’s not called then I don’t get autocompletion for the argument. For example if I have an argument arg : String then I don’t get autocompletion. Let me know if you’d like to work together on making this work.

What I mean with the above is, when triggering a completion inside a method, we can check if the method args are fully typed. If that’s the case we can simulate a call to that method with those types to get semantic information. Then go-to-definition and autocompletion should work, and it should also be relatively fast to do.

Of course it won’t work if some args are not typed, but maybe it’s good because people will feel inclined to type their methods :-)

Or, with an untyped argument we could introduce a new type in the compiler (or, well, the compiler used in the server) that means “untyped”. Any method called on an untyped method succeeds and returns “untyped”. But searching a method on a know type with an untyped argument could actually match all methods with that name, and succeed. That way if calling a method like string.gsub(untyped, untyped) we would know for sure that the return type is String, even though we don’t know the argument types.

Anyway… just some ideas to make the plugin work even better.

I’m really impressed by how it works right now.

No need to reply, though. If I have time I’ll try to make it work first and see if I can send a PR.

2 Likes

Thanks a bunch, that means a lot :smile:!

These are great ideas!

I was also thinking about a permissive parser that would produce a partial AST instead of raising (because right now a single syntax error will stop the world).

Yeah, I saw that “permissive” flag in the code but I’m not sure I understand how it’s currently used.

I think the way other IDEs work is, you create a parser that could produce incomplete/broken ASTs, but you also tell it the line and column where the cursor are at. That way when the parser reaches that point it knows “okay, here comes the broken part” and handles that.

With languages like Ruby and Crystal I feel this is needed because a newline after a dot is valid but it might also be the case that the expression is incomplete. For example:

foo.|
x = 1

(the | is the cursor)

The parser could say “I know the cursor is right after the dot so I’m doing to end the expression right here, assuming it’s a call without a method name”, instead of parsing that as “foo.x = 1” (which is valid, but probably not the expected AST if autocompletion is asked at that point).

1 Like

Hey guys, I’d like to throw down a bounty for fixing an issue I have with syntax highlighting.

$25 for the person who fixes the bug via Venmo, as well as an extra $25 I’ll donate directly to Crystal-lang via bounty-source.

An example of my problem is

It seems when using %Q[] with string interpolation it breaks the syntax highlighting pretty bad. I know this is probably a challenge because there are quite a few kinds of delimiters that can be used with this style of string creation, as well as having to deal with the interpolation, hence the bounty.

I’m currently on 0.4.0 version of the extension on Crystal 0.35.1.

Issue: https://github.com/crystal-lang-tools/vscode-crystal-lang/issues/128

@sol.vin You can submit a PR with this diff:

diff --git a/syntaxes/crystal.json b/syntaxes/crystal.json
index 60073d4..3973143 100644
--- a/syntaxes/crystal.json
+++ b/syntaxes/crystal.json
@@ -224,7 +224,7 @@
 					"name": "punctuation.definition.variable.crystal"
 				}
 			},
-			"match": "(\\%)([a-zA-Z_]\\w*\\.)*[a-zA-Z_]\\w*",
+			"match": "(?!%[QWSR][\\(\\[\\{\\<\\|])(\\%)([a-zA-Z_]\\w*\\.)*[a-zA-Z_]\\w*",
 			"name": "variable.other.readwrite.fresh.crystal"
 		},
 		{

It seems that matches against free variables in macros (stuff like %foo) but it conflicts with the string syntax that also starts with %Q. So here I exclude those specific patterns from matching the “free variable” rule.

1 Like

I sent a PR :slight_smile:

I’ll happily accept those $25 if you still think it’s worth doing so, though I don’t have a Venmo account. Let me know and I’ll create one.

And it’s already released as a new version!

2 Likes

@asterite Dang and here I thought it would take some time because there was a similar bug on the issues unsolved for months. Looks good, verified and tested.

Shoot me your venmo in DM @asterite.

THANK YOU FOR WORKING SO HARD!

I donated to crystal through opencollective, as that was the one listed.

Oh, nevermind, it seems Venmo only works in the US. But I’ll be fine :-)

I can up my donation to $50 on crystal. I can also send it to you any other number of ways. Whatever works.