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

Write major modes bindings #98

Open
9 of 18 tasks
MarcoIeni opened this issue Sep 6, 2020 · 27 comments
Open
9 of 18 tasks

Write major modes bindings #98

MarcoIeni opened this issue Sep 6, 2020 · 27 comments

Comments

@MarcoIeni
Copy link
Task lists! Give feedback
Member

@MarcoIeni MarcoIeni commented Sep 6, 2020

Is your feature request related to a problem? Please describe.

As I said here:

In spacemacs you have major-modes, like "python", "markdown", and so on. So for example if you open a .md file, spacemacs will use Markdown mode in that buffer.

When you are using a mode, key bindings under <spc> m or under , will be unique to that mode.

This means that when you are editing a markdown, <spc> m b could be assigned to "make bold", while in python <spc> m b could be assigned to "toggle breakpoint" (I am just inventing).

Describe the solution you'd like

In vscode-which-key/#14 we have enabled the possibility to have major mode key bindings. Now it's time to write them!

These are some of the most important programming languages where a major mode is missing:

  • javascript - nodeselector is on it
  • python
  • java
  • go
  • cpp
  • typescript - nodeselector is on it
  • php
  • c#
  • c
  • shell
  • scala
  • rust
  • clojure
  • ruby
  • F#
  • R

markup languages:

  • markdown
  • org mode

If you want to start working on a major mode that is (or isn't) listed here, please leave a comment.
In this way we don't overlap with each other.

Additional context

@stevenguh
Copy link
Member

@stevenguh stevenguh commented Sep 21, 2020

Took this out the v0.8.0 because this might take a bit more brewing.

@macintacos
Copy link
Contributor

@macintacos macintacos commented Sep 28, 2020

I was thinking about tackling the Markdown major mode, however I have to ask - can I assume that Markdown All in One would be a "dependency"? It's by far the most popular Markdown extension, but I'm not sure if you want to limit the amount of extensions that VSpaceCode relies on.

Edit: I'm actually trying to set this up for testing now in my vspacecode.bindingOverrides and can't quite figure it out. The docs only call out relatively "straightforward" overrides, I wonder if conditional overrides have a different way? nevermind, figured it out! I have a bunch of keybindings set up now with Markdown All in One commands, just waiting to see it that's "okay" for a PR.

@stevenguh
Copy link
Member

@stevenguh stevenguh commented Sep 28, 2020

Thank you for taking an interest in implementing major modes :)

Since not everyone is going to need/want to install the extension required by a specific default major mode, our thought is to not bundle the extension (required by major modes) and require manual installation for now. Follow #84 (comment) for the context.

Since the engineering for a major mode bundle system is not here yet (refer to #84 (comment)), we plan to do something simple here. We will ship a default major bindings that require user to manually install the missing extension if needed.

In short, I am open to have a default markdown bindings that require manually installation of an extension. @MarcoIeni What do you think?

EDIT: I am also open to bundle that markdown extension for now since it seems to more common than specific programming languages?

@MarcoIeni
Copy link
Member Author

@MarcoIeni MarcoIeni commented Sep 28, 2020

Macintacos, you can assume that the extension is there.

At the moment we need to document that it requires manual installation.
In the future we might decide to boundle it.

EDIT: I am also open to bundle that markdown extension for now since it seems to more common than specific programming languages?

For this issue it doesn't matter, right? We might decide this once the markdown mode is "complete"

@stevenguh
Copy link
Member

@stevenguh stevenguh commented Sep 28, 2020

For this issue it doesn't matter, right? We might decide this once the markdown mode is "complete"

I was thinking markdown is probably a little bit special, so we can bundle the extension needed directly to this extension. But thinking it more, it's good to not bundle any extensions required by major mode for now to be consistent (until we have the system mentioned perviously)

@macintacos
Copy link
Contributor

@macintacos macintacos commented Sep 28, 2020

@MarcoIeni @stevenguh awesome, I'll get started on a proper PR soon, I'll link it to this issue when I open it.

@stevenguh
Copy link
Member

@stevenguh stevenguh commented Oct 6, 2020

Released v0.8.2 that contains the new markdown mode. Thank you @macintacos for contributing :)

@willnevillain
Copy link

@willnevillain willnevillain commented Oct 9, 2020

Hello, was very pleased to stumble across this project. I'd love to help out and take a stab at a major mode binding.

It's not on the list, but one that I was wishing for today is HTTP support for the REST Client extension.

The Spacemacs bindings for the relevant Emacs package are pretty sparse, and some of them aren't relevant. The REST Client extension in VSCode pulls focus away from the editor on sending a request and the HTTP response appears to be in a readonly webview by default, which prevents invoking followup commands with keystrokes (as far as I'm currently aware).

Regardless, there are a number of commands that would be useful to be exposed via <spc> m when in an HTTP language buffer - see screenshot below. Would this one make sense to add to the list of major modes?

image

@stevenguh
Copy link
Member

@stevenguh stevenguh commented Oct 10, 2020

Thank you for taking an interest in contributing. Although, this is not in the list, I am open to it. As far as to activate the menu from the readonly WebViews, we will have to target it as a shortcut with keybindings.json and its corresponding context like

{
"key": "space",
"command": "vspacecode.space",
"when": "activeEditorGroupEmpty && focusedView == '' && !whichkeyActive && !inQuickOpen"
},

You can use inspect context command with and developer prompt to see what can be used to target.
image
e.g. activeEditor == 'WebviewEditor' might be one of the when/context condition you can used to activate on that readonly view.

@MarcoIeni
Copy link
Member Author

@MarcoIeni MarcoIeni commented Oct 10, 2020

It's fine for me to support this extension, even if I haven't used it in spacemacs.
Anyway, maybe it would be better to not limit this key bindings to the html major mode, because it could be useful also in all the other modes I think.

Spacemacs has <spc> a which stands for "applications". We could have something like <spc> a c (for client) or <spc> a r (for rest client).
What do you think?

Of course the approach is the same as major modes, i.e. we don't bundle this extension, user have to install it manually.

The Spacemacs bindings for the relevant Emacs package are pretty sparse, and some of them aren't relevant.

If users are used to the spacemacs key bindings for this functionality and if they make sense for vs code we can copy them here, otherwise we can ignore them.

Anyway, can you create another issue, so we move the conversation there?

@stevenguh
Copy link
Member

@stevenguh stevenguh commented Oct 10, 2020

Anyway, maybe it would be better to not limit this key bindings to the html major mode, because it could be useful also in all the other modes I think.

I think that extension uses http language file, but so I think it make sense to be in major mode. The second part is the extension creates a read-only WebViews editor. We have to find the right context/when to target specific that window, and we might not able to do that; therefore, I am fine with the additional of http language mode major mode only.

Spacemacs has a which stands for "applications". We could have something like a c (for client) or a r (for rest client).
What do you think?

I will be a little bit hesitant to bundle commands that required other extensions outside of major mode for now.

Anyway, can you create another issue, so we move the conversation there?

+1

@Muscaw
Copy link
Contributor

@Muscaw Muscaw commented Dec 17, 2020

Hey, I wanted to know if I could contribute to the extension by working on the Python major mode.

@MarcoIeni
Copy link
Member Author

@MarcoIeni MarcoIeni commented Dec 17, 2020

Hi Muscaw, sure! I will reserve it to you in the first comment :)

@practicalli-john
Copy link
Contributor

@practicalli-john practicalli-john commented Jan 1, 2021

@MarcoIeni I am interested in adding Major mode key bindings for the Clojure programming language, using the popular Calva plugin for VS Code.

It seems to test changes I edit the package.json file that is extracted to my $HOME/.vscode/extensions/vspacecode.vspacecode-0.8.5 directory, restarting VS Code for changes to take effect.

I just copied some of the go configuration and changed it to use languageId:clojure and this does give a menu under SPC m and , when I have a Clojure file open.

@stevenguh
Copy link
Member

@stevenguh stevenguh commented Jan 2, 2021

Feel free to open an issue to track it if you want to work on it :)

It seems to test changes I edit the package.json file that is extracted to my
$HOME/.vscode/extensions/vspacecode.vspacecode-0.8.5 directory, restarting VS Code for changes to take effect.

That's a very interesting way to test it. You are modifying the built-in default from in extension directly I think. You can follow the CONTRIBUTING to run a test instance with the updated default config.

@MarcoIeni
Copy link
Member Author

@MarcoIeni MarcoIeni commented Jan 2, 2021

Thanks jr0cket! I just updated the first comment/

@mayanez
Copy link
Contributor

@mayanez mayanez commented Feb 20, 2021

I'd be happy to try my hand at the C++ major mode.

@stevenguh
Copy link
Member

@stevenguh stevenguh commented Feb 20, 2021

I'd be happy to try my hand at the C++ major mode.

Awesome! Please open an issue to track that work :)

@mayanez
Copy link
Contributor

@mayanez mayanez commented Mar 10, 2021

Any interest in a Latex mode?

@stevenguh
Copy link
Member

@stevenguh stevenguh commented Mar 10, 2021

Go for it :)

@nodeselector
Copy link

@nodeselector nodeselector commented May 8, 2021

Working on a javascript and typescript implementation. For now they are essentially identical PRs.

@cimentadaj
Copy link

@cimentadaj cimentadaj commented May 10, 2021

Any interest in an R major mode?

@stevenguh
Copy link
Member

@stevenguh stevenguh commented May 11, 2021

Working on a javascript and typescript implementation. For now they are essentially identical PRs.

Awesome!! Thanks for working on them. I will take a look :)

Any interest in an R major mode?

Let's try it :) Seems like a very popular data science language.

@basus
Copy link

@basus basus commented Jun 18, 2021

I'm interested in helping add an OCaml major mode. Since the VS Code OCaml Platform plugin is not very feature-rich at the moment, I would like to develop it locally for a while, until I can get some changes into that plugin. Is there some way to experiment with a major mode locally without putting it into packages.json? I tried something like this, but it doesn't seem to work:

"vspacecode.bindingOverrides": [
        {
            "keys": "m.languageId:ocaml",
            "name": "OCaml",
            "type": "bindings",
            "bindings": [... ]
        } ]
@The-Compiler
Copy link
Contributor

@The-Compiler The-Compiler commented Jun 18, 2021

@basus Does "keys": ["m", "languageId:ocaml"], work? Here's an example of what works for me:

https://github.com/The-Compiler/dotfiles/blob/f1778cc2565c1cfc975b601b8e398012f5b26b24/vscode/settings.jsonc#L621-L642

@basus
Copy link

@basus basus commented Jun 18, 2021

Looks like @The-Compiler's suggestion worked. Thanks!

Now the issue is, I want the same keybindings to work for both languageId.ocaml and languageId.ocaml.interface, but I can't tell if there is a straightforward way to do that?

@The-Compiler
Copy link
Contributor

@The-Compiler The-Compiler commented Jun 18, 2021

You'll need to duplicate them for now, see VSpaceCode/vscode-which-key#42

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet