Fork me on GitHub

I've noticed recently that when I open a .clj file on load (i.e. vim /path/to/something.clj) I am immediately in insert mode. Is it possible that Conjure is doing this somehow?


Shouldn't be, I never attempt to put you in insert mode :thinking_face:


Try rolling back one or two versions?


Just to confirm


I wonder if @dave and @rafaeldelboni's issues are related and both related to the auto repl / babashka functionality :thinking_face: obviously "works on my machine" but maybe there's a setting to do with unsaved buffers or something that's confusing things when I swap to the bb REPL buffer and back.


I temporarily took bb out of my PATH and the problem went away.


So it does seem related to the auto bb REPL.


The beautiful auto-bb ! Surely it's not to blame its so precious


Haha, it's probably just the way I'm creating the terminal. I create a new buffer or window and open a terminal running bb inside that new one. Then close it or swap back to what was there before, I can't remember the process exactly. I'm guessing there's some vim setting that makes this behave weirdly in some setups though...


Maybe I can do something simpler :thinking_face: like rephrasing the operation may be enough to fix it.


I haven't had the time or energy to do another batch of fix-y/feature work, but should get a window this weekend! I need to do short sprints where I fix a few things and add a few features then release it the same day I think.


Aha! I think I do have a hack in place that puts me directly into insert mode when a terminal buffer opens.



" When I open a terminal buffer, I want it to feel like I'm in the terminal. I
" don't want to still be in normal mode.
autocmd TermOpen * startinsert


Oooo yeah! That'll do it! Still doesn't explain why @rafaeldelboni's Clojure highlighting vanished... that one has me stumped.


I'll see if I can somehow open the term without causing any autocmds maybe? Although not sure how I get around that.


I'm wondering what the right solution is. Maybe there is something I can do on my side. :thinking_face:


Would it make sense for you to switch back to normal mode explicitly when you move back away from the terminal buffer?


:thinking_face: I mean, you shouldn't be in normal mode after that, it's your custom autocmd that does that. So I'd like to find a way to say "just open a terminal but don't trigger anything custom since it's a background process". Patching around the insert mode part seems too narrow to me tbh, I'd like to find a broader fix.


I could maybe not open a terminal and just start the process completely hidden not attached to a buffer. But then you can't interact with it to <c-c> it or type into it. Which will be useful with some REPL setups (not bb sadly, you can't have nREPL and stdio because single thread)


I think I agree. It might actually be worse to switch to normal mode explicitly because maybe someone else's weird setup relies on you putting them back into whatever mode they were in before :man-shrugging:


So I will see if there's anything I can set to say "just open a buffer, don't do anything clever"


Maybe there is a TermLeave event or something that I can respond to by putting me back into normal mode.


Yeah! There is a TermLeave. Trying it.


Didn't work 😑


If you condition your autocmd to say "only do this if the current window is a terminal" then you'll only run i when you actually have the terminal in focus, rather than a sort of background thing

💡 2

I took a stab at this:

" When I open a terminal buffer, I want it to feel like I'm in the terminal. I
" don't want to still be in normal mode.
autocmd TermOpen * if &buftype ==# 'terminal'
      \ | startinsert
      \ | endif
Doesn't seem to have any effect, sadly.


OK, I've solved it! 😄

" When I open a terminal buffer, I want it to feel like I'm in the terminal. I
" don't want to still be in normal mode.
autocmd TermOpen * startinsert

" This doesn't play nice with Conjure, which will sometimes open a terminal
" buffer to start a REPL server and then switch back to the previous
" buffer.
" As a workaround, I explicitly switch to normal mode when entering any
" Clojure buffer.
autocmd BufEnter *.clj,*.cljs,*.edn stopinsert
" (This doesn't work, for some reason.)
" autocmd FileType clojure stopinsert


Haha, well I'm glad you have something but sorry you had to do extra things! Not sure how I can avoid triggering autocmds like this 😞


Don't feel bad about it. I realize that I'm probably an outlier here in that I'm monkeying with the default behavior of terminal buffers.


But maybe that's a bit much


We should probably thread, sorry everyone

❤️ 2