atom / vim-mode

Next generation vim support for atom
MIT License
1.72k stars 250 forks source link

Implement command-line mode #441

Closed astralarya closed 9 years ago

astralarya commented 9 years ago

Also known as colon commands. See command-line-mode.

I propose a design where a binding to : serves as an entry point into the Command Palette Shift+Ctrl+P and Go To Line Ctrl+G depending on arguments (eg. :git commit vs. :42). Vim commands could be added to the Command Palette, or dynamically intercepted to invoke contextual dialogs with backspace reverting back to the Command Palette. These dialogs would include things like the fuzzy file finder for :E or even one day a shell for :sh, :!, and :read !.

@Xe: Full Ex support is probably the right way to go. Perhaps Ex with dynamic responsiveness when appropriate?

Schematic:

User pressed ':'
  |=> [0-9]+:?[0-9]*  # Go To Line
  |=> {<Ex mode hooks>}
  |  |=> Contextual dialog, backspace cancel # fuzzy-finder (:E), terminal (:!)
  |  |=> Ex command  # save/quit (:wq), substitute (:s)
  |
  |=> .*  # Command palette

See #439 #440

lloeki commented 9 years ago

see #50 and #185 (incl. remarks about why, although tempting, it's not necessarily a good idea to open the command palette).

mkhoeini commented 9 years ago

It might be helpful to see how sublime solved the problem.1

I think it might be a good idea to distinguish between strict mode and light mode. For example emacs' EVIL mode, which claims near full compatibility with vim has several different levels of strictness regarding how much you want to experience vim or emacs.2

For example in light mode we can bind : to cmd+shift_P and insert a vim: string in the begining of command palette. Then we can instruct the command palette to behave specially when the command starts with vim:.

Another thing which might come interesting is that neovim guys are developing a vimscript -> lua transpiler with the aim of 99% compatiblity. It might worth investigating if it can be easily enough separated from neovim and be used in atom. Also, some parts of it might come interesting, like the parser.3

Also, as discussed in #436 neovim itself runs as a server and guis are external plugin processes which communicate with it through jsonrpc. With that we would have 100% and seemless integration with the vim world. As it is obviously a superior solution to the vim integration I would argue that that route should be pursued as the official vim-mode plugin for atom.4

What's your thoughts on the matter?

lloeki commented 9 years ago

I'll be trying something soon in lloeki/ex-mode.

lloeki commented 9 years ago

No one was stepping up so, ex-mode here. While there's only w and write, groundwork is done, so adding new commands is easy.

cpadilla commented 9 years ago

Thanks for implementing this. Are you going to keep adding to ex-mode or can we add this functionality to vim-mode?

I'd be more than happy to help, although I've never used coffee script. I can start looking into it though, since this was kind of a big reason I haven't really switched from gVim to Atom. That and Atom still hasn't released version 1.0, yet.

lloeki commented 9 years ago

There's no reason to merge as the functionality is really separate. Only the most advanced functions may require communicating with vim-mode, and there are methods and facilities to do that cleanly (see auto completed plus and its providers, or linter), ultimately making vim-mode extensible.

If you want to help, open an issue at ex-mode and list your most used ex commands, so that I can focus on implementing them.

maxbrunsfeld commented 9 years ago

Closing, as @lloeki's ex-mode package fulfills this need.