Fork me on GitHub
#conjure
<
2021-06-11
>
dave13:06:22

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?

Olical13:06:16

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

Olical13:06:24

Try rolling back one or two versions?

Olical13:06:28

Just to confirm

Olical13:06:42

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.

dave13:06:51

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

dave13:06:03

So it does seem related to the auto bb REPL.

emilaasa15:06:35

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

Olical15:06:32

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...

Olical15:06:52

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

Olical15:06:29

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.

dave15:06:28

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

dave15:06:45

Yep:

" 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

Olical15:06:26

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

Olical15:06:42

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

dave15:06:09

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

dave15:06:39

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

Olical15:06:43

: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.

Olical15:06:56

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)

dave15:06:47

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:

Olical15:06:16

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

dave15:06:19

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

dave15:06:01

Yeah! There is a TermLeave. Trying it.

dave15:06:13

Didn't work 😑

Olical15:06:14

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
dave15:06:42

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.

dave15:06:31

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

Olical16:06:00

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 😞

dave17:06:01

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.

Olical15:06:18

But maybe that's a bit much

Olical15:06:28

We should probably thread, sorry everyone

2
❤️ 2