Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(lsp): add vala language support #2243

Merged
merged 7 commits into from
Apr 24, 2022
Merged

Conversation

ttys3
Copy link
Contributor

@ttys3 ttys3 commented Apr 23, 2022

fix #2224

image

image

image

one question: Vala allows comments to be recorded in code in different ways. but in languages.toml we can only config a single comment-token = "//", how can we to block comment toggle action ?

// Comment continues until end of line

/* Comment lasts between delimiters */

/**
 * Documentation comment
 */

refs:

lang server: https://github.com/vala-lang/vala-language-server

ts: https://github.com/vala-lang/tree-sitter-vala

https://wiki.gnome.org/Projects/Vala/StringSample

https://learnxinyminutes.com/docs/vala/

https://naaando.gitbooks.io/the-vala-tutorial/content/en/3-basics/comments.html


demo vala code to test:

// Single line comment

/* Multiline
Comment */

/**
* Documentation comment
*/

char character = 'a';
unichar unicode_character = 'u'; // 32-bit unicode character

int i = 2; // ints can also have guaranteed sizes (e.g. int64, uint64)
uint j = -6; // Won't compile; unsigned ints can only be positive

class HelloWorld: Object {
    private uint year = 0;

    public HelloWorld () {
    }

    public HelloWorld.with_year (int year) {
        if (year>0)
            this.year = year;
    }

    public void greeting () {
        if (year == 0)
            print ("Hello World\n");
        else
            /* Strings prefixed with '@' are string templates. */
            print (@"Hello World, $(this.year)\n");
    }
}

void main (string[] args) {
    var helloworld = new HelloWorld.with_year (2022);
    helloworld.greeting ();
}

@ttys3 ttys3 force-pushed the vala-lsp branch 2 times, most recently from cc79c6f to 86047c8 Compare April 23, 2022 17:38
languages.toml Outdated Show resolved Hide resolved
languages.toml Outdated Show resolved Hide resolved
Copy link
Member

@the-mikedavis the-mikedavis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some scopes in highlights.scm need to be adjusted to match the list here: https://github.com/helix-editor/helix/blob/6047506ec56787e5a87d0dfe9cb90646004becf5/book/src/themes.md#scopes

For example, @float becomes @constant.numeric.float, @property and @field become @variable.other.member, @parameter becomes @variable.parameter, etc.

@ttys3
Copy link
Contributor Author

ttys3 commented Apr 23, 2022

@variable.parameter

updated, PTAL

@ttys3
Copy link
Contributor Author

ttys3 commented Apr 23, 2022

chore: adjust vala boolean, character, regex

PTAL

@the-mikedavis
Copy link
Member

in languages.toml we can only config a single comment-token = "//", how can we to block comment toggle action?

Toggling block comments is not currently supported (see #1505 and #1937 (comment)). For now, just the line comment will do 👍

Copy link
Member

@the-mikedavis the-mikedavis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these suggested edits make the variable highlights look better, in particular the

(identifier) @variable

highlights variables as they are used (rather than assigned). It's not always different than them being not highlighted depending on the theme - some themes highlight variables the same as the foreground theme.

Also I think it would make sense to replace the @include scope with @namespace based on how it's used.

I haven't used vala before though so I might be wrong about these

runtime/queries/vala/highlights.scm Outdated Show resolved Hide resolved
runtime/queries/vala/highlights.scm Outdated Show resolved Hide resolved
@ttys3
Copy link
Contributor Author

ttys3 commented Apr 24, 2022

rebased and applied suggested changes.

@the-mikedavis
Copy link
Member

Thanks!

@the-mikedavis the-mikedavis merged commit a8cb466 into helix-editor:master Apr 24, 2022
@ttys3 ttys3 deleted the vala-lsp branch April 24, 2022 18:19
@ttys3 ttys3 restored the vala-lsp branch April 24, 2022 18:19
@ttys3 ttys3 deleted the vala-lsp branch April 25, 2022 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add vala language support
3 participants