NeoVim integration
I have gotten used to using alt+hjkl or alt+jkil for navigation instead of the arrow keys. Would it be possible to add keybindings for these actions? Next/previous word and beginning/end of line would also be appreciated. :)
Maybe this is adjustable through some Gtk-settings? Gtk is quite customizable so I guess it should be possible to change these keys for all your Gtk applications.
Hmm.. I'm struggeling with finding any Gtk-settings at all, but came somewhat close by messing with the xkb settings. However, it is now sending Alt+<left,up,down,right> instead of just the directions, so it doesn't have the desired behaviour. I'll research some more and report back here if I find something.
You might be able to set this through the file ~/.config/gtk-3.0/settings.ini. However, could not immediately find any good documentation on this. Think you can change theme variables here though, maybe you can find additional info when searching for gtk3 theme settings.
Found this, maybe it will help: http://vim.wikia.com/wiki/Vi_key_bindings_in_gtk
I didn't figure out the gtk settings in the end, but I pulled the juCipp source and added the features. Right now it's hard coded to how I like it, but if there is interest I could clean it up, add some preferences for it and submit a pull request.
I still think the best way would be to adjust the gtk settings, and thus get the wanted bindings throughout all gtk applications. But glad you found a workaround!
I'll got some motivation figuring this out, I really miss emacs navigation. I'll reopen and report.
Nice! I've forked and committed my hack, so if it is of interest, see https://github.com/Istarnion/jucipp
Good job, figuring this out! However, the reason other IDE's has these various modes is because they do not use Gtk which has built-in support for altering these keys. http://vim.wikia.com/wiki/Vi_key_bindings_in_gtk is a good starting point for this I guess. We could ship such settings files though for Vim and emacs users, but without altering juCi++ source code (hopefully).
Also, then these key bindings (through gtk settings) would work not only on the source view (like now), but in for instance autocomplete and selection dialogs, and entry fields as well.
I think we might need to supply the config by calling something like get_default in gtk. I'm investigating now.
It's possible to just start using emacs configuration. In /usr/share/themes/Emacs/gtk-3.0/gtk-keys.css you can find definitions for emacs. For vim checkout the one @eidheim linked. Include this css file into gtk-init-file or to your theme.
I added it to the end of /usr/share/themes/<my-theme>/gtk-3.0/gtk.css like this
// (...)
@import url("../../Emacs/gtk-3.0/gtk-keys.css");
The shortcuts defined in config.json will overwrite these settings.
@eidheim We might want to change our signal names in config.json to correspond with gtk-signals so that configs like this works out of the box, even on search, save, etc. which we have overridden.
@zalox That might lead to more confusion than what is gained. Most users will not bother with the gtk settings I think. Not sure, but the gtk settings search for instance, might also correspond to default search behaviour, which we have customised/improved.
I guess we have to program some of the modes and functions commonly used in vim. Gnome-builder has a vim mode, and it might be that we can reuse something they have done (although then we might need to change the license).
Implementing it ourselves is also an option, and it should be doable. If someone starts on this, make sure to create a separate class for vim mode in for instance vim_mode.h and vim_mode.cc. The code should not all be in source.cc. The VimMode class should also be a singleton I guess to keep track of the current mode (same mode for all tabs I take it).
Someone also mentioned neovim with respect to vim support. I have not studied this project, and do not know how this would work.
Neovim might be the most general approach: https://github.com/neovim/neovim/wiki/Plugin-UI-architecture, using stdin and stdout through a process running nvim.
I'll look into this in the next few days. I'm not sure if I can integrate it correctly, but I could provide a sample application at least.
That would be great, thank you.
After doing some tests in https://gitlab.com/eidheim/neovim-embed-test I conclude that the NeoVim API is not yet ready for efficient integration with an outside text buffer. The main issue is that the API is missing buffer insert and deletion events that can be efficiently used by a graphical UI application.
There are several neovim issues and pull requests related this problem. The most relevant ones are the issue https://github.com/neovim/neovim/issues/2224 and the pull request https://github.com/neovim/neovim/pull/5269
edit: migrated neovim-embed-test to gitlab