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

Make custom grammar + restrict key combination to this grammar #26

Open
KoltesDigital opened this issue Nov 9, 2019 · 10 comments
Open

Comments

@KoltesDigital
Copy link

Like for the Atom plugin, I suggest making your own grammar, which would merely extends Haskell. It also gives the opportunity to add autocompletion (#11).

My real issue: I regularly use Ctrl+Enter to make new lines, and I'm frustrated that this plugin squats this key combination for all languages.

@kkeri
Copy link

kkeri commented Feb 19, 2021

My real issue: I regularly use Ctrl+Enter to make new lines, and I'm frustrated that this plugin squats this key combination for all languages.

My issue too. Is it possible to make the shortcut conditional or language specific, so I could use Ctrl+Enter in my normal workflow to insert new lines?

@yaxu
Copy link
Member

yaxu commented Feb 19, 2021

This plugin is short of maintainers, but PRs are very welcome.

@kkeri
Copy link

kkeri commented Feb 19, 2021

The same request goes for Shift+Enter too, what is used for multiline search and commit messages.

As @KoltesDigital suggested, you probably have to define your own language ID so you can make use of the editorLangId when clause context.

@kkeri
Copy link

kkeri commented Feb 21, 2021

@yaxu this seems to be a low hanging fruit. AFAIK adding a language ID to package.json then scoping relevant keyboard shortcuts to the language ID would resolve this issue. (Not the custom grammar part, but the OP noticed that his "real issue" is with keyboard shortcuts and solving it doesn't require a custom grammar.)

Although I found an unrelated problem. I checked out the code, ran tests and one of them failed. It leads to a rather complex constructor and is eventually related to the VS Code extension API. I'm not ready to dig into it at the moment. Will you accept a PR even if I don't fix the failing test case?

@yaxu
Copy link
Member

yaxu commented Feb 21, 2021

I've not looked at the code at all, @kindohm might have a view on that

@kindohm
Copy link

kindohm commented Feb 21, 2021

@kkeri I would be happy to take a look at a PR, regardless of the state of the tests. I will take a look at the tests in the meantime.

I also want to make sure I understand the feature. Would this allow you to use the Tidal keyboard shortcuts in a .tidal file, and use the same keyboard shortcuts for a different purpose in a different type of file?

@kkeri
Copy link

kkeri commented Feb 21, 2021

@kindohm thanks for your feedback.

Yes, this feature would restrict shortcuts like Ctrl+Enter to .tidal files. Anywhere else, including editors for other languages, the source control view, the global search view etc. key bindings wouldn't be affected. Of course we should apply the restriction only to editor specific shortcuts.

Although there is something you should know about. I wrongly assumed that this can be done without making a custom grammar. However defining a new language ID for Tidal files conflicts with the suggested user setting that associates *.tidal files with Haskell. Ergo users have to choose between keyboard shortcuts and syntax highlight. It would be an undesirable side effect.

I can't invest into writing a full fledged Haskell syntax, but I can try to find one whose license is compatible with this project.

@kindohm
Copy link

kindohm commented Feb 21, 2021

@kkeri thanks for digging in to this.

I don't think we want to lose the syntax highlighting.

One workaround is to define your own keyboard shortcut to eval Tidal code. e.g. remap the "Eval Multiline" command to something other than Ctrl-Enter.

@kkeri
Copy link

kkeri commented Feb 21, 2021

@kindohm I agree, losing syntax highlight is not an option. I keep exploring, including filing an issue to the VS Code project. Possibly there are other embedded DSLs that could benefit from using the syntax highlighter of the parent language.

Until then I'll be using my own keyboard shortcuts.

@kkeri
Copy link

kkeri commented Feb 21, 2021

I found a possible workaround. It would allow for using Haskell highlighters as before, but it doesn't work as expected. I reported the issue to Microsoft.
microsoft/vscode#117190

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

No branches or pull requests

4 participants