Hacker News new | ask | show | jobs
by fao_ 3337 days ago
Honestly for me the main reason was that it finally has builtin `:terminal`. The plugins for use with vim have always been slightly buggy for me.
1 comments

Can you please elaborate how you make use of the built in terminal emulation of neovim? Whenever I see a mention I think "neat" but have yet to integrate it into my workflow.
Not parent, but I use Neovim and Ranger [1] filemanager and I have a shortcut to open Ranger in a split or full window from which I can browse and open a file. You can do this only because Neovim has a built-in terminal. This may end up replacing vinegar [2] as my in-VIM filemanager.

[1] https://github.com/ranger/ranger

[2] https://github.com/tpope/vim-vinegar

So the nesting you have is Shell -> Nvim -> Ranger, so ranger is contained inside of a vim split?

Mind sharing some docs on how to do that?

Lazy version would be `:vsplit | lcd %:h | term ranger<cr>`.

`vsplit` splits the window vertically. `lcd` sets the bufferlocal working directory which is a new feature in neovim. `term ranger` launches the terminal emulator. If you wanted to be fancy you could add a toggle that reuses the same ranger instance which'd add an additional ~10 loc.

I use a plugin ranger.vim [1]. Although it works for plain VIM, it is very clunky, since ranger is opened with a !command you get a blocking terminal.

The nesting really is tmux -> Shell -> Nvim -> Ranger.

https://github.com/francoiscabrol/ranger.vim

Stuff like fzf (https://github.com/junegunn/fzf) works nicer with terminal emulation.
I use it a lot when doing exploratory SQL work or writing queries. I can tinker with my query in one pane and send it over to the `psql` repl in the other.

I do use psql's `\e` command to open the previous query in your `$EDITOR`, but that only lets me get the single previous query, and throws out any comments.

Like a lot of other IDEs, it is convenient to have a console to focus over to then run ad-hoc cmdline stuff or run tests for the currently active project. This is what I use :terminal for the most. It was helpful for me to setup the below keybingds for focusing back/forth between a :terminal split and my "editing" splits:

    tnoremap <C-h> <c-\><c-n><c-w>h
    tnoremap <C-j> <C-\><C-n><C-w>j
    tnoremap <C-k> <C-\><C-n><C-w>k
    tnoremap <C-l> <C-\><C-n><C-w>l
    nnoremap <C-h> <c-w>h
    nnoremap <C-j> <c-w>j
    nnoremap <C-k> <c-w>k
    nnoremap <C-l> <c-w>l
I use it to either run microservices for testing, or for testing code in the erlang shell. It's MUCH easier to copy and paste inside vim and be able to copy logs out into a buffer to run sed expressions on it, than if I were using another terminal.