-
Notifications
You must be signed in to change notification settings - Fork 30
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
expose context for cell language #607
Conversation
(@isabelizimm I hope you don't mind I took the liberty to edit your post so the triple ticks render fine! The trick is to use more ticks on the outside than on the inside, |
TIL!!! Thank you so much, that looks much better 😺 |
apps/vscode/src/vdoc/vdoc.ts
Outdated
return languageFromBlock(block); | ||
const language = languageFromBlock(block); | ||
// expose cell language for use in keybindings, etc | ||
commands.executeCommand('setContext', 'quarto.cellLang', language?.extension); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you try using the ids
element? It would be nice if we had the same string here that we can use with editorLangId
, i.e. "python" and not "py".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If so, it would be nice to make this quarto.cellLangId
as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I installed the .vsix
and see the new context key, using "Developer: Inspect Context Keys":
I think it's very unlikely that one of the language keyboard shortcuts would be the first non-whitespace thing you type in a code cell, based on all the examples we currently have. I would rather risk that than have us provide R language shortcuts in a Python cell for knitr/reticulate .qmd
files. Happy to re-evaluate if folks find it surprising!
Notes
This will update the exposed language depending on what language chunk the user's cursor is in. It will expose the language extension (eg. py, r, jl) used to run the chunk.
The language at position does not immediately change when a cursor is placed, you have to delete or type something non-whitespace for the cell language to update. I still think this is the right place; BUT there is an alternative location where we would get feedback immediately with the language of the virtual doc, rather than the chunk. For reticulate documents, that means you'll never have Python exposed, only R.
Trying it out
I've been testing by creating a file something like:
and adding these keybindings via Command Palette ->
Preferences: Open Keyboard Shortcuts (JSON)
:Then I'll go into each chunk, start typing, then do
command+shift+a
.