rune icon indicating copy to clipboard operation
rune copied to clipboard

Custom Include Path

Open SWW13 opened this issue 1 year ago • 3 comments

Currently there is no standardized way of bundling own "std" modules written in Rune.

Adding them as additional source files and wrapping the provided functions in a mod-block works as expected for the user. The source can even be compiled into the binary, which makes shipping easy. However the language server is unable to find these modules and all Rune modules have to be compiled during runtime whether they are used or not.

I'm not sure what would be a fitting implementation for Rune, Rhai for example allows to use a custom module loader with arbitrary logic to locate modules.

SWW13 avatar Sep 05 '22 09:09 SWW13

Could you elaborate? What is it that you want to work and what did you try to do?

The existing mechanism for overriding how sources are loaded can be specified through Build::with_source_loader. The default implementation used is FileSourceLoader.

udoprog avatar Sep 05 '22 10:09 udoprog

Oh, totally missed that SourceLoader is a Trait.

That only leaves the question how to integrate a custom SourceLoader with the language server.

SWW13 avatar Sep 05 '22 11:09 SWW13

I think only standard included source loaders (possibly configurable) would work with a general purpose language server. Else one would need to provide some way to conveniently build-your-own language server, which wouldn't be that hard either but just a bit inconvenient.

For external definitions, the idea is to support them as through a specific kind of syntax #73, like:

extern "Rust" {
    /// Documentation for function `foo`.
    fn foo();

    /// Documentation for opaque external type `Foo`.
    type Foo;

    /// Documentation for external enum `Bar` with variant `Baz`.
    enum Bar {
        Baz,
    }
}

And so forth... And so forth...

udoprog avatar Sep 05 '22 14:09 udoprog