mizlan / vim-and-cp

Some helpful bits and pieces for your vimrc
42 stars 12 forks source link

shows number/relative number in terminal_cmd when loses focus #2

Closed j0k4rX closed 3 years ago

j0k4rX commented 3 years ago

Suppose, i am writing on A.cpp file I've triggered CompileAndRun command

As per your cp.vim termwrapper function, (1) it opens terminal_cmd inside nvim (2) the numbers, relative numbers don't show in that terminal_cmd

But when i click the A.cpp file from terminal_cmd (terminal_cmd open & running) and then again click the terminal_cmd the numbers, relative numbers appear like the video in that terminal_cmd

https://user-images.githubusercontent.com/71499522/124482809-7ec6f600-ddcb-11eb-97c6-389a6fdaf049.mp4


Expected Behavior

  1. never show numbers/relative number in terminal_cmd
  2. always stay in terminal (insert) mode
  3. after inserting input, terminal_cmd should work normally
mizlan commented 3 years ago

Thank you for filing an issue. I can't view the video, but I suspect I know what the issue is.

I believe you have these lines from tmwilliamlin168's vimrc:

set nu
augroup numbertoggle
    autocmd!
    autocmd BufEnter,FocusGained,InsertLeave * set rnu
    autocmd BufLeave,FocusLost,InsertEnter * set nornu
augroup END

What you are observing is the buffer in normal mode instead of insert mode when you re-enter it. Fortunately I know of a fix for this.

mizlan commented 3 years ago

Please see if adding this line (from my commit just now) fixes the issue:

https://github.com/mizlan/vim-and-cp/blob/e13010c0160d01aade8cd57ffcf64fdb892bd1c7/cp.vim#L33

j0k4rX commented 3 years ago

what if i wanted the terminal_cmd always in insert/terminal mode?

mizlan commented 3 years ago

What do you mean by that? When you enter (and re-enter) the terminal window it should automatically enter insert mode.

j0k4rX commented 3 years ago

yes, I prefer it automatically enter into insert mode

mizlan commented 3 years ago

But it does already do that, I just added that line.

j0k4rX commented 3 years ago

When i am in a contest, I am coding in a file then i trigger CompileAndRun

While I copy the input from browser, terminal_cmd loses focus (insert mode vanishes) for that reason, I have to type i to go into insert mode and paste that input

Expected Solution

  • I wanted to re-enter the terminal_cmd in insert mode
  • if the terminal_cmd loses focus while i am copying input it should regain insert mode

if you watch the video carefully, you'll see --terminal-- is gone in the status bar when I re-enter that terminal_cmd

https://user-images.githubusercontent.com/71499522/124562992-78835900-de61-11eb-8ada-a4ebca7be470.mp4

j0k4rX commented 3 years ago

@mizlan I found a solution here

if has('nvim')
    augroup terminal_setup | au!
        autocmd TermOpen * nnoremap <buffer><LeftRelease> <LeftRelease>i
        " more stuff
    augroup end
endif
mizlan commented 3 years ago

Ah, more details would have been nice. I'm glad you found the fix. If you'd like, I would love to have a PR adding that functionality.

ghost commented 11 months ago

You and I have long history my friend. I'm this guy @j0k4rX. And this is my working id.

I was not familiar with PRs back then. Okay, new PR is coming up.