-
Notifications
You must be signed in to change notification settings - Fork 148
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
Formalize and extend language transclusion #191
Comments
Pros:
Cons:
|
+100 |
Overall I agree that this is the right direction, as it would allow anyone who writes a |
typescript extensions are easier to install and update (and as already
mentioned allow for more than regexpr)
Disagreed. So long as npm, nodejs, and webpack are in the mix, this is
peril-fraught. Putting a json file in a place (even checked into you're
project) is about as low effort as you can get. Also the overlap of kernel
authors and js/ts people is relatively small, while most packagers will
suffer through a little Json munging.
…On Sat, Feb 8, 2020, 05:50 Michał Krassowski ***@***.***> wrote:
Overall I agree that this is the right direction, as it would allow anyone
who writes a LanguageServerManager to appreciate the potential
configuration options; having them try to go with regexpr and only then
fall-back to typescript extension is reasonable - we will need the
LanguageServerManager anyways.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<https://github.com/krassowski/jupyterlab-lsp/issues/191?email_source=notifications&email_token=AAALCRHNI425GTOT5MWDGW3RB2FBHA5CNFSM4KRXXNK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELFPECY#issuecomment-583725579>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAALCRHRBTJ6X3LYASGPO5TRB2FBHANCNFSM4KRXXNKQ>
.
|
While thinking about #201, another interesting one: LanguageServerManager:
language_servers: ...
transclusions:
ipython-shell-magics:
host:
mime_types:
- text/x-dockerfile
languages:
- dockerfile
file_extensions:
- Dockerfile
guest:
mime_types:
- application/x-sh
languages:
- sh
file_extensions:
- .sh
patterns:
RUN:
regex: "^\\sRUN\\s+(.*)$"
extract: $1
isolate: true The wrinkle here is getting the |
IPython includes some other magics as well, see https://ipython.readthedocs.io/en/stable/interactive/reference.html#automatic-parentheses-and-quotes I do think it could be useful to expose an API on the kernel where you can ask for some code to be transformed into the underlying language then receive back the transformed code and a source map of the transformations. This is an established pattern for code transformations that can also be used for lint/format as well as highlighting appropriate locations of code errors from the runtime reported location. This could even be done extensibly, so nested syntaxes could report their transformations- an embedded SQL query could use it to map SQL errors back to the original source code locations. |
Probably deserves a JEP. |
Hi, Does this use case fits the the Jupyterlab-LSP enhancement described in this thread? Assuming I could find some time to contribute, what has to be done to add this functionality? We would be 100% happy only with ability to reuse already existing Highlight modes. |
Thanks for the interest! There's actually several ways this could go down.
Either way: On the backend (python): we'd need a new handler that lightly wrapped a new member of the manager. Much like the manager currently finds These would be handy, perhaps, for a custom site deployer or packager, and might be able to accept our simplest examples. To schema: we've updated the one in design ideas a few times, but it's still rather rough. For example, we might want to break it down even further, perhaps, e.g. hoisting Briefly, back to python: at some later date, we'd probably then also define a new On the front end (typescript): this would either be a new plugin, or a new extension. It would implement something like the example extractor, except that it would first fetch all of the transclusions from the server route, and then add each of them. It would probably need a way to refresh its list of transclusions, as well, and unregister/updated ones it created that had disappeared. And, here might be another place of configuration: loading transclusions from JupyterLab user settings. These would be handy for trying stuff out interactively, without having to restart the (lab) server. Initially, just with Advanced Settings, but eventually with a dedicated UI with preview, one could build up that same Schema. One final thing (python+?, typescript, schema): definitely in the "nice to have" category, but a MIME renderer for
Yep: I think defining new modes is important, and could indeed fit in here. I don't remember whether I've built a schema for code mirror simple modes, but that would certainly be possible.... but just saying "whatever codemirror does with it" is also a reasonable stance. The only real issue I've encountered there is using regular expression flags is hard... but maybe i wasn't trying hard enough. On top of the above changes, there would be:
Happy to help move this forward! |
This might be easiest to start with. Maybe adding a mapping from host-language to Also cross-referencing #347 (to highlight that in the future, we will want to add transclusions defined by some grammars/token parsing, in addition to the current regular expression based approach). |
Easiest to start with, sure, but is not composable/shippable... it's basically no fun to have to tell someone to crack open Advanced Settings and paste in some rando JSON after doing a In a binder setting, sure: one can overload settings with with
Yeah, sounds rad... so in light of that, perhaps As for what that might be: dunno, maybe jison or nearlyjs? Either way, we'd have to ship a parser generator runtime to work directly with the data, or once again, we're back in the "you have to build a labextension to play". |
Thank You both for answers. In our use case we would like to have the ability to reuse existing functionalities of code highlight to our custom magic. I see you have a clear view and expectations how this feature should look like and how it should be implemented to fit your road map and product vision. However this might be to much for our time capacity so we (I mean me) need to find some fast path that would help us to get the result without breaking the product vision. Can I use my custom exxtractor.spec.ts, extractor.ts and index.ts files that I created based on SQL/BigQuery as a JupyterLab extension (https://jupyterlab.readthedocs.io/en/stable/extension/extension_dev.html) ? In other words, I would not want to have a need to keep a for of JupyterLab-lsp and build the whole thing just to add few files. BTW, |
Yep, we've tried to avoid fast paths on this repo if they're going to be painful/insoluble in the future (hence why this hasn't happened yet).
Yes, here's an example I helped set up for shipping python-wrapped-js language servers (which you don't need, perhaps) along with some extractors, etc. https://github.com/jupyrdf/graph-lsp You can then offer a pre-built extension on PyPI, or a source extension on
Also: please don't worry about the length of the thread: it's far worse to have to dig through many, many different ones! |
Hi @bollwyvl I managed to modify it to my use case, build using doit (as mentioned in manual) and it seems to work. However it does not build when using bash .binder/postBuild and so I cannot build it as extension package.
when running I would not want to use this thread for this so maybe we could use some other channel? |
Yeah, it's a rather opinionated project. I don't mean one should use that repo directly but rather the pattern for publishing it. You might get more leverage from https://github.com/jupyterlab/extension-cookiecutter-ts |
Elevator Pitch
Allow a user to define rules for finding parts of files in a host language that embed other languages. Additionally support referring to the outer language within the inner language. Language servers, libraries, and other things a user might have installed should be easily and robustly able to ship and activate these on installation.
Motivation
Much like with #190 for #189, there are more languages that embed other languages than we'll be able to (or want to) define/maintain. The existing list includes things from IPython built-ins, but doesn't fully capture the scope of other magics, much less what other languages do, especially extremely crazy things like allthekernels, sos or metakernel.
A number of these kinds of things also allow for referring to the outer language, such as
{variable}
references, up to full-blown templating languages, and having access to completion/diagostics/reference/hover for these nested scopes would be very valuable.Design Ideas
Add a separate spec to the JSON schema, e.g.
transclusions
which can be defined/modified without re-compiling lab by traitlets config orentry_points
. Move the existing "simple" ones from the hard-coded typescript into defaults on the python side, or simple JSON.Notional "Simple" Example
More complex things
These would be insufficient for complicated tricks like what's happening in the some of the r-in-python with declaring variables, and for this case being able to
register
these from an extension that depends on the to-beILanguageServerManager
(or a dedidcatedITransclusionManager
) would be required.User-serviceable and discoverable
Probably need to be configurable in the frontend, e.g.
The text was updated successfully, but these errors were encountered: