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

Terminal enhancements #27

Closed
Tehnix opened this issue Sep 27, 2017 · 1 comment
Closed

Terminal enhancements #27

Tehnix opened this issue Sep 27, 2017 · 1 comment

Comments

@Tehnix
Copy link
Owner

Tehnix commented Sep 27, 2017

Moved from original issue Tehnix/spaceneovim#11, opened by @alexanderjeurissen.

Whilst testing spaceneovim I came across several terminal related issues. Most of these issues are rather easily fixed and will drastically improve the experience of using terminal splits in spaceneovim.

  1. Using WinCmd's in neovim terminal splits
  2. Entering insertmode when entering a terminal split using WinCmd's
  3. closing the terminal split when the terminal process exits (or when a user manually types exit in the prompt)

Regarding the first issue, I've had this issue at first in my own neovim config aswel. The problem is that the terminal doesn't execute vim commands unless you have specific tnoremap bindings. as the documentation states:

Navigating to other windows is only possible by exiting to normal mode, which
can be cumbersome with <C-> keys.

I solved this in my own config using:

 " Window navigation between terminal and nonterminal {{{
    tnoremap <silent> <leader>wh <C-\><C-n><C-w>h
    tnoremap <silent> <leader>wj <C-\><C-n><C-w>j
    tnoremap <silent> <leader>wk <C-\><C-n><C-w>k
    tnoremap <silent> <leader>wl <C-\><C-n><C-w>l

    tnoremap <silent> <leader>wv <C-\><C-n>:vs<cr>:startinsert<cr>
    tnoremap <silent> <leader>ws <C-\><C-n>:split<cr>:startinsert<cr>
"}}}

The second issue can be solved with a single autocmd

au BufEnter * if &buftype == 'terminal' | :startinsert | endif

The third issue, I'm not sure how and if we can fix that..


When looking into this some more I discovered that there are terminal bindings defined in layers/+nav/windows/config.vim however they make use of wincmd command which isn't executed correctly when you are in insertmode in the terminal.

So replacing these with the approach I've outlined above should remedy this. I'll create a PR for this tonight.

ytang added a commit to ytang/spaceneovim-layers that referenced this issue Nov 16, 2017
This, together with Tehnix/spaceneovim/Tehnix#27, would fix Tehnix#31
@Tehnix Tehnix closed this as completed in 146254e Dec 5, 2017
@Tehnix
Copy link
Owner Author

Tehnix commented Dec 5, 2017

With the commit above I've added a few of these suggestions.

  1. Ctrl-[hjkl] now works for navigating around windows in the terminal while in insert mode (and normal mode in other buffers).

  2. You will now automatically enter insert mode whenever you enter a terminal buffer.

  3. Not entirely sure here, there are some scenarios where you'll be running a script that exists itself, and you'll want to keep the output. Currently after exit you can simply press q and the window will close. I think this is fine for now, although having it close on user inputted exit would be perhaps a bit nicer (no idea how to hook into that though).

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

No branches or pull requests

1 participant