Fork me on GitHub
#conjure
<
2020-08-26
>
practicalli-johnny20:08:58

I have almost everything working with conjure and neovim. I am stuck on using vim-jack-in from within Neovim. It starts a repl but I am stuck in the REPL log and cannot run any commands. Is this a bug or am I missing something. Running a REPL on the command line and then opening a Clojure file with nvim correctly connects to a running repl, so it only seems vim-jack-in approach is not working for me.

👀 3
Olical20:08:36

That'll probably be because you're in the "terminal" mode, which is different to insert and normal.

practicalli-johnny20:08:27

Yes, it says Terminal at the bottom

Olical20:08:33

To map <Esc> to exit terminal-mode: >
    :tnoremap <Esc> <C-\><C-n>

Olical20:08:48

So terminal mode needs <c-\><c-n> to get out of it

Olical20:08:05

I map my <esc> as well as my jk (personal preference) mapping to that.

Olical20:08:12

That way it's more like a regular mode.

Olical20:08:27

It's a bit jarring at first though if you don't know about terminal mode, I was never a fan of that default 😕

Olical20:08:36

(it caught me out the first time I saw it too)

practicalli-johnny20:08:26

After using Spacemacs I shoud remap Esc to fd - is that in your Github config?

Olical20:08:03

(noremap :i :jk :<esc>)
(noremap :c :jk :<c-c>)
(noremap :t :jk :<c-\><c-n>)
it's in fennel but you can translate that to viml easily enough

Olical20:08:17

inoremap jk <esc>, I think?

Olical20:08:40

Same for cnoremap and tnoremap

Olical20:08:46

But yeah, fd works well too!

practicalli-johnny20:08:11

I find the localleader key combos quick to timeout, so fail because I am typing to slowly. Is there a way to increase that timeout? Or do I just need to type faster 🙂

Olical20:08:29

Nope, there's an option!

Olical20:08:31

I'll grab it

Olical21:08:28

I think it's ttimeoutlen

Olical21:08:05

*'timeoutlen'* *'tm'*
'timeoutlen' 'tm'	number	(default 1000)
			global
	Time in milliseconds to wait for a mapped sequence to complete.

						*'ttimeoutlen'* *'ttm'*
'ttimeoutlen' 'ttm'	number	(default 50)
			global
	Time in milliseconds to wait for a key code sequence to complete. Also
	used for CTRL-\ CTRL-N and CTRL-\ CTRL-G when part of a command has
	been typed.

practicalli-johnny21:08:31

I can escape from the terminal, after running :Clj command in neovim (on a Clojure file) and use :first to switch back to the code buffer. However, when evaluating the popup says no connection. Opening the log with`, l v` says no nREPL port file found. Using top in a separate terminal, a java process is started by :Clj in neovim. So seems conjure is not connecting to the repl vim-jack-in starts.

Olical21:08:07

:thinking_face: if you check your current directory, is there a .nrepl-port file?

Olical21:08:31

(also I think :Clj opens the terminal in a new tab, you can use gt to cycle those)

practicalli-johnny21:08:53

gt works, thanks. An .nrepl-port file was created with a timestamp of when I ran the :Clj command.

Olical21:08:47

Oh, sorry, now hit ,cf to connect to a local port file

Olical21:08:09

This part will be automatic soon (™️), so when you eval it'll try to find a .nrepl-port file, but I haven't added that just yet I'm afraid.

practicalli-johnny21:08:11

Success.. I have a Tonkinese cat 🙂

Olical21:08:20

Excellent!

Olical21:08:33

Sorry for the confusion around the connection

practicalli-johnny21:08:50

Its no different to the early days of Calva and Cider 🙂

Olical21:08:51

It's automatic as you open your first Clojure file but that's all right now. On eval will be the next step

Olical21:08:04

Well that's good to hear!

practicalli-johnny21:08:10

I sometimes get the error E5601: Cannot close window, only floating window would remain and cant close neovim

Olical21:08:31

Oh that's interesting, I've never seen that one.

Olical21:08:54

When is that happening?

practicalli-johnny21:08:29

gt will get rid of it, so it seems to be that the popup isnt going away by itself when I use :Clj

practicalli-johnny21:08:05

Switching tabs is refreshing the source code buffer I assume and forcing the floating window to go

Olical21:08:41

The Conjure floating window vanishes on cursor move

Olical21:08:45

Which can fire when you change tabs etc

practicalli-johnny21:08:56

Yes, just noticed that 🙂

practicalli-johnny21:08:28

That makes sense. Works just like cider inline eval results

practicalli-johnny21:08:24

Thanks for your help with this, much appreciate.

Olical21:08:59

Yep, supposed to be an equivalent but with multiline, history, highlighting and editable

Olical21:08:23

And you're more than welcome, I want to give you a decent experience and learn where the pain points are

Olical21:08:47

I'll make a note to try and get that same error

practicalli-johnny21:08:28

:q when the popup is still displayed should give you the error under the neovim status bar

Olical21:08:57

Yep, I had a feeling it would be that 🙂

Olical21:08:02

I'm sure I can fix it, thanks for spotting it!!!

Olical21:08:48

Ooo looks good!

Olical21:08:48

Thank you so much for writing it!

practicalli-johnny21:08:42

I'll add a nicer version of the write-up to http://practicalli.github.io/clojure/clojure-editors/ and as I'll be doing a lot of videos for the next few months, I'll add a walk-through video of Conjure too (using your ascii cinema syntax guide as inspiration)

❤️ 3
🚀 3
practicalli-johnny21:08:21

The biggest challenge is yet to come though... deciding on a theme and statusbar theme 🙂

😄 3
Olical09:08:03

I had a look into the bug you mentioned but it looks like it's a neovim bug! https://github.com/neovim/neovim/issues/11440 You can avoid it by either closing the HUD first or using :tabclose instead. It only happens when closing tabs with floating windows pinned to them. I can't think of a workaround right now 😭 it think it needs to be fixed in nvim.

👍 3
Olical09:08:48

And a possible fix incoming https://github.com/neovim/neovim/pull/11938 - there's a PR anyway

practicalli-johnny09:08:54

I can just move the cursor too 🙂 I was only really experiencing that issue when I didn't have things working and I was restarting neovim all the time. But good to know as I am sure I'll experience it again on occasion. Thank you.

Olical09:08:07

Yep, that'll do it!

practicalli-johnny09:08:10

I'll spend a bit of time over the weekend getting a bit more comfortable using Neovim and absorbing the Conjure commands. I didnt see a way to evaluate an expression and have the result printed as a comment. Is that part of Conjure? I can raise a feature request if not. I use that a lot in my broadcasts 🙂

practicalli-johnny09:08:19

I did notice the REPL log used more with Conjure (I usually have that hidden in Spacemacs), so maybe that workflow would work just as well. Will let you know.

Olical09:08:29

Yeah, the log would be the first place I'd go to. All results are placed in your c register by default (I've configured mine to go to my default register so I can just hit p after an eval to get the result) You can evaluate something then press "cp to paste the result wherever you want. Or even <c-r>c while in insert mode.

Olical09:08:04

Also <prefix>e! will evaluate the current form and replace it with the result.

practicalli-johnny09:08:12

I have all this neovim magic to learn, thanks 🙂

Olical09:08:02

The only other thing I'd pile on that you may want to check out: * Set an uppercase mark (uppercase go across files and persist between nvim restarts) with mF on some form. * Go to another part of the file or a different file entirely * <prefix>emF - see that marked form get evaluated! Really handy for changing things in one area and repeatedly calling it from elsewhere.

Olical09:08:27

I think vim-iced adopted this feature too, I don't think any other tooling has yet :thinking_face: I think it's pretty fun and unique!