Giter VIP home page Giter VIP logo

Comments (7)

nobodywasishere avatar nobodywasishere commented on June 25, 2024 1

Ah alright good to know, thank you for testing that! I also started on Ruby before finding Crystal, let me know if you have any questions about the language.

It's a limitation of the compiler currently, it removes anything not included in an executable (methods defined but never used, for example). Also due to type inference, the types can change depending on what's using the method (unless you've explicitly typed it like with your foo method). Specs are executables though, so that should work.

from vscode-crystal-lang.

wJoenn avatar wJoenn commented on June 25, 2024 1

Yes that was it 🙌
I installed crystalline's binary with the command found in the repo's README, wrote the absolute path to that binary as the server's path in the Crystal Language vscode extension's settings and reloaded VSCode.
Everything works fine as far as Types on hover and type errors go now.

Thank you @nobodywasishere

I could probably open a PR within the next couple of days to update the README if you'd like

from vscode-crystal-lang.

nobodywasishere avatar nobodywasishere commented on June 25, 2024

Thank you for the bug report! Currently type information can only be provided for methods / etc that are included in the final executable. Can you try doing this, and seeing if the hover works over the foo method call?

def foo : String
  "hello"
end

puts foo # <-- here

It is weird though that there were no messages after "getting context...", I'll try to get a WSL2 system setup soon to see if I can reproduce.

from vscode-crystal-lang.

wJoenn avatar wJoenn commented on June 25, 2024

Thanks for the quick response 🙌
Printing doesn't seem to work either
Another detail is that the loading tooltip only appear on the first hover after reloading vscode but if I unhover and hover again then no tooltip ever appear again until I reload vscode again

image

Currently type information can only be provided for methods / etc that are included in the final executable.

Is that something that is planned to be improved later on or a limitation coming from Crystal ? 🤔
I started using the language today so I was planning on making a bunch of small methods and test just to get to know the syntax and the differences with Ruby.
It'd be a bummer if I couldn't get type hints when doing something simple like

require "spec"

def foo : String
  "hello"
end

describe "#foo" do
  it "should return 'hello'" do
    foo.should eq "hello"
  end
end

from vscode-crystal-lang.

wJoenn avatar wJoenn commented on June 25, 2024

let me know if you have any questions about the language.

It's a bit early but I'll be sure to take you on that offer soon 👀 Thank you very much

from vscode-crystal-lang.

wJoenn avatar wJoenn commented on June 25, 2024

I just realized but it seems I'm not getting any type error either
Like on this screenshot, I assume I should have an error showing up in vscode saying that 1 is not of type String right ?
Might be related to the LSP not loading properly.

image

LSP which btw no prints an additional error: undefined line when hovering a value (this wasn't the case yesterday)

[Crystal] extension loaded
[Hover] getting context...
[Hover] error: undefined
[Hover] getting context...
[Hover] error: undefined

from vscode-crystal-lang.

nobodywasishere avatar nobodywasishere commented on June 25, 2024

So currently, you're not utilizing an LSP but instead wrappers for several compiler tools. I should provide better documentation but you need to install https://github.com/elbywan/crystalline somewhere and point the server setting at it, then restart vscode.

You should be seeing type error information, looks like the problems tool isn't running for some reason. It's supposed to run every time you save or open a new file.

from vscode-crystal-lang.

Related Issues (20)

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.