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

Editor option to run the language server from cargo project #493

Merged
merged 1 commit into from
May 3, 2023

Conversation

udoprog
Copy link
Collaborator

@udoprog udoprog commented May 3, 2023

This introduces another editor extension option which allows you to set a cargo package that should be used as the CLI entrypoint.

It tries to build the entrypoint (currently in debug mode) and capture the build artifact to use as a language server. This is then called:

  • <bin> --version - to see if it can be executed.
  • <bin> languageserver - to run the languageserver.

The latter is supported by anything that implements a CLI entrypoint. This allows (among other things) to more easily specify a server which uses a custom context. All you really need to do is set up a package which looks like this (and add your own modules of course):

rune::cli::Entry::new()
    .about(format_args!("The Rune Language Interpreter {VERSION}"))
    .context(&mut |opts| {
        let mut c = rune_modules::with_config(opts.capture.is_none())?;

        if opts.experimental {
            c.install(rune_modules::experiments::module(opts.capture.is_none())?)?;
        }

        Ok(c)
    })
    .run();

If something goes wrong, an error like this is displayed:

image

Note that I had to rewrite parts of the CLI because suprisingly we did not support a --version option.

Another side effect is that this makes it super easy to work on the language server since it can be both reloaded and rebuilt in the editor as needed.

@udoprog udoprog force-pushed the extension-local-cli branch from fdcbbc2 to de72a40 Compare May 3, 2023 08:30
@udoprog udoprog merged commit 963790a into main May 3, 2023
@udoprog udoprog deleted the extension-local-cli branch May 3, 2023 09:41
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.

1 participant