rhaiscript / lsp

Language server for Rhai.
Apache License 2.0
43 stars 4 forks source link

Running on Windows #45

Closed schungx closed 2 years ago

schungx commented 2 years ago

These are some of the issues I found running the LSP on Windows:

  1. src/ast/rhai.ungram must have LF line ending. Windows CR+LF line ending is not supported by Rowan. Git for Windows automatically converts all line endings to Windows-style when cloning.

  2. All Windows CR+LF line endings in Rhai scripts throw an invalid input error.

  3. print seems to be unresolved, and it gives a hint saying maybe it should be print.

  4. It no longer works once you start editing the code. Before edit, popup's work fine. After editing anything, no longer.

schungx commented 2 years ago

In Windows, expressions within strings interpolation does not seem to be processed.

For example:

const HELLO = 42;

let x = HELLO;    // <- press F12 on HELLO to jump to definition

let s = `Hello = ${HELLO}`;   // <- press F12 on HELLO does nothing
tamasfe commented 2 years ago

Yeah interpolated code is not yet processed, I opened an issue for it (#46).

schungx commented 2 years ago

image

in statements not working.

image

Also throw statements.

schungx commented 2 years ago

Strange behavior in VScode:

  1. Open examples/main.rhai (probably external.d.rhai not yet indexed)

image

  1. Click on examples/external.d.rhai (probably indexing it)

  2. Open examples/main.rhai again

image

schungx commented 2 years ago

BTW, I see that you need a definition file just to put comments in modules.

Should I, say, add the //! doc-comments style to Rhai scripts? They should, like Rust, go to the top of the script, and be taken as that script file's documentation.

So, bar.rhai can actually be simplified to:

//! Definition for "bar.rhai".
//!
//! Omitting the module path is the same as `module "./bar.rhai"`.

/// Some constant.
export const X = 10;

/// This function is private.
private fn cant_touch_this() {

}

/// This function is exported.
fn hello() {
    print("hello");
}
tamasfe commented 2 years ago

(probably external.d.rhai not yet indexed)

That's weird, we should traverse the entire workspace after initialization and load all the files.

Should I, say, add the //! doc-comments style to Rhai scripts?

I'm not sure if they're worth the hassle, but yes, it'd make sense imo.

schungx commented 2 years ago

I'm not sure if they're worth the hassle, but yes, it'd make sense imo.

Adding a definition file is good in the sense that we can add all sorts of nice things to it later on.

However, if scripts always need another file just to attach module docs, that will be a chore...

schungx commented 2 years ago

That's weird, we should traverse the entire workspace after initialization and load all the files.

bar.rhai has an error (print again), so I'm not sure if that is tripping up all later files?

tamasfe commented 2 years ago

bar.rhai has an error (print again), so I'm not sure if that is tripping up all later files?

There are still issues with adding/removing sources to the HIR (#52), if you open the LSP logs, you should see a lot of panics probably. I want to hunt these down and write reproducible tests.

schungx commented 2 years ago

@tamasfe I'm pinning this repo to the top as this is going to be a material addition.

BTW, are you on Discord? If so, I can open up a channel for the LSP.

tamasfe commented 2 years ago

BTW, are you on Discord?

I don't normally use it, but sure, good idea, I'll join to make communication faster.

schungx commented 2 years ago

The Windows-specific issues are all resolved, and so I'll close this.