Fork me on GitHub
#vim
<
2018-03-22
>
Michael Fiano06:03:53

Hi...is there a plugin that provides function signature as you type, so you can know the parameters something expects?

dominicm07:03:33

Async clj omni, with deoplete, and with preview in completeopt on (default, I think). @mfiano

Michael Fiano07:03:17

@dominicm Yes I am using that, however as soon as I type a space after the operator it goes away and I am forced to remember all the arguments

dominicm07:03:45

@mfiano that's not the default behaviour of preview. Generally, you have to do something special to make that happen. PClose I think is the aucmd.

Michael Fiano07:03:53

I come from emacs where the signature stays on the bottom of the screen, even for multiple arity functions

dominicm07:03:05

Unless deoplete does that automatically, which would really annoy me.

Michael Fiano07:03:46

I'm not sure what you mean

dominicm07:03:13

@mfiano just to be clear, which bits of what I described are you doing? I'm on mobile so can't type what I mean.

Michael Fiano07:03:13

Oh I forgot, I'm not using deoplete, but nvim-completion-manager. I was confusing it with denite

Michael Fiano07:03:05

Then i type space and it all goes away

dominicm07:03:29

NCM doesn't support preview normally because reasons. If you go into :help there's an option for ncm which you can set to modify the completeopt.

dominicm07:03:47

Right, preview otwns at the top

Michael Fiano07:03:24

I do have preview in completeopts

Michael Fiano07:03:15

I searched ncm help for 'preview' and didn't find anything

Michael Fiano07:03:05

Ok I set g:cm_completeopt to have preview too, and it resizes my existing windows to make a large preview window...and it never goes away

Michael Fiano07:03:12

That is horrible 🙂

dominicm07:03:06

You could bind pclose to something I guess. I don't know of anything like eldoc for vim, but it may exist.

dominicm08:03:22

@mfiano let me know if echodoc works, it looks pretty cool :)

dominicm08:03:16

The highlighting part is awesome :o

Michael Fiano08:03:24

At least not with NCM

dominicm08:03:57

It will need to be enabled, if you haven't done that.

dominicm08:03:12

:EchodocEnable

Michael Fiano08:03:30

Not an editor command

Michael Fiano08:03:31

Yeah...it's installed but I don't have that command

dominicm08:03:38

I probably got it wrong a bit, maybe capital D

Michael Fiano08:03:22

Ok it's enabled but I see nothing

dominicm08:03:19

It might need to be enabled per file type, it's probably buried in the docs

Michael Fiano08:03:44

Or it only works with his specific completion plugin

Michael Fiano08:03:42

Interestingly, it doesn't even work with deoplete

dominicm08:03:50

I don't think so, it uses a standard vim thing.

dominicm08:03:39

Did you set cmdheight or noshowcmd?

Michael Fiano08:03:12

Yeah, I tried both

dominicm08:03:13

I think this is your only path. I'm gonna try this out later I think. Seems pretty cool.

dominicm09:03:07

@mfiano trying it from the train station, I'm getting "No pattern found", same for you?

Michael Fiano09:03:19

No I don't get that

dominicm09:03:32

Sorry, that's "Pattern not found"

Michael Fiano09:03:38

I don't get any output

dominicm09:03:22

I think I just need to write a custom thingy for it

dominicm09:03:09

ah, I get pattern not found always 🙂

Michael Fiano09:03:43

@dominicm Do you use fireplace?

Michael Fiano09:03:12

How do I remap that hard to type goto definition binding of [-C-d

dominicm09:03:46

--- after/ftplugin/clojure.vim
nmap <buffer> gs <Plug>FireplaceDjump
nmap <buffer> gvs <Plug>FireplaceDsplit
---
^^ in the named file

Michael Fiano09:03:24

Is there a command to jump back or do i have to use C-o?

Michael Fiano09:03:22

Nevermind...got it

Michael Fiano09:03:23

My vim config is pretty huge. I'm gonna end up spending all day configuring Clojure

Michael Fiano09:03:11

I'm sick of Emacs...been using it for years, but not as long as Vim which isn't slow on some of my older hardware

Michael Fiano09:03:35

@dominicm Is your vim/clojure config online by any chance?

dominicm09:03:39

It is, yeah SevereOverfl0w/.files on github

Michael Fiano09:03:48

I just found it 🙂

dominicm09:03:10

It's a little bit out of date I'm afraid, but generally holds

Michael Fiano09:03:43

You seem to have some Spacemacs-like layer setup. Interesting

dominicm09:03:28

I did, yeah. I wanted my plugins and respective config nearby

Michael Fiano09:03:56

@dominicm Nice config. You still using ncm?

dominicm09:03:20

I am yep :)

Michael Fiano09:03:51

I have one problem with it I'm not sure how to solve

Michael Fiano09:03:56

sec let me remember

Michael Fiano09:03:21

I guess it relates to using tab as my candidate selection key. doing so prevents me from being able to tab to indent

markwoodhall10:03:55

FWIW, it's not to everyone's taste but I hook into the CompleteDone autocmd and drop the last completion in my status line. https://i.imgur.com/Tz6ttHW.gif

Michael Fiano10:03:41

@markwoodhall Very cool. How did you do that?

markwoodhall10:03:21

I capture the last completion info:

autocmd BufEnter * if !exists('b:last_completion_sig') | let b:last_completion_sig = '' | endif
    autocmd CompleteDone * let b:last_completion_sig = join(split(has_key(v:completed_item, 'info') ? v: : b:last_completion_sig, '\n')[0:1], ' ')
Then I expose that variable in my lightline config.

Michael Fiano10:03:37

Hmm I didn't know you could add custom info in lightline

markwoodhall10:03:58

That is what I do.

Michael Fiano10:03:13

@markwoodhall That works thanks, however vim emits an error when CtrlP is invoked

Michael Fiano10:03:24

Error detected while processing function LightlineCompletion:
E121: Undefined variable: b:last_completion_sig
It only seems to have problems with CtrlP...works for file buffers

markwoodhall10:03:13

Ah, weird, I'm using fzf rather than ctrlp.

markwoodhall10:03:12

I guess you can just check if that variable exists in LightlineCompletion.

Michael Fiano10:03:23

Yeah that works

Michael Fiano10:03:41

Great thanks. Now I just have to solve my tab key problems with ncm

markwoodhall10:03:14

Is that just that you need to do something like inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>" ?

Michael Fiano10:03:56

I actually have that

markwoodhall10:03:08

If you remove that then you can tab as desired with the pum visible, I think, but you will need to use <C-n> to cycle through completions?

Michael Fiano10:03:34

Oh i see. The issue was that I was invoking ncm manually with tab. i disabled the auto popup

Michael Fiano10:03:35

Thanks all. This is good enough as a CIDER replacement now.

markwoodhall10:03:11

If you prefer not to use the status line for the completion info then you can always just change the CompleteDone autocmd to echo rather than capturing a variable. I like the status line approach but for multi-arity functions with lots of arguments, it can sometimes truncate.

Michael Fiano10:03:14

Oh yeah, fair point

Michael Fiano10:03:14

The location list approach to stacktraces is kind of confusing...I never really used the location list before

Michael Fiano10:03:36

echoing is not very persistent though. it disappears as soon as i jump out of a s-expression etc

markwoodhall10:03:38

I probably meant echom.

Michael Fiano10:03:52

Same difference.

Michael Fiano10:03:53

If I type def, select defn completion candidate and then continue so I have (defn foo ...), the echom disappears as soon as I press f in foo.

markwoodhall10:03:19

That does't happen for me with cmdheight=2.

Michael Fiano10:03:57

Same thing huh

markwoodhall11:03:56

I think you can make it better by using autocmd CompleteDone * if has_key(v:completed_item, 'info') | echo join(split(v:, '\n')[0:1]) | endif but can see that it's still not perfect.

Michael Fiano11:03:03

The problem is the other line

dominicm11:03:30

No need to split, you can use v:

dominicm11:03:03

I think echodoc only works if you press <Ctrl-y>, it doesn't for CompleteDone also, it probably should tbh

dominicm11:03:28

I have echodoc working I think, but it's flashing because I have something else causing an error odd enough.

Michael Fiano11:03:50

That doesn't work for me, and reading the issues, it seems to be a regex mess

Michael Fiano11:03:03

I'd rather just extract it out of the pum

dominicm11:03:27

that makes sense to me

Michael Fiano11:03:58

But for some reason, the above snippet from mark blocks...wants me to press enter to continue

markwoodhall11:03:19

Best I can get with echoing, rather than in my status line is using this:

autocmd BufEnter * if !exists('b:last_completion_sig') | let b:last_completion_sig = '' | endif
    autocmd CompleteDone * if has_key(v:completed_item, 'info') && v: != '' | let b:last_completion_sig = join(split(v:, '\n')[0:1]) | endif
    autocmd CompleteDone * echo b:last_completion_sig

markwoodhall11:03:36

Again with cmdheight=2

markwoodhall11:03:44

Or set noshowmode but that isn't as clean.

markwoodhall11:03:43

I think splitting or just using v: is just preference, since the menu includes kind and CLJ/CLJS.

Michael Fiano11:03:59

Yeah I can't get it to not block input without faking the variable

Michael Fiano11:03:06

I accomplished similar

markwoodhall11:03:00

The above works well enough for me.

markwoodhall11:03:18

I'm terrible with vimscript though. 🙈

markwoodhall12:03:44

Did you already rule out completeopt+=preview because it's a bit hideous?

Michael Fiano12:03:18

function! CompletionEcho()
  if !exists('b:last_completion_sig')
    let b:last_completion_sig = ''
  else
    if has_key(v:completed_item, 'info') && v: != ''
      let b:last_completion_sig = join(split(v:, '\n')[0:1])
    endif
    echo b:last_completion_sig
  endif
endfunction

augroup completion_echo
  au!
  au completedone * call CompletionEcho()
augroup end

Michael Fiano12:03:27

My vimscript is horrible too, but that's what I got

Michael Fiano12:03:15

Yeah, preview is hideous...the window keeps growing everytime a docstring is longer to account for it...and if i close it, it annoys me when it pushes my buffers around when it opens

Hukka16:03:31

Hmh. Is there a way to "mirror" a repl connection? So that it's not just the same repl, but also shows the same input and output

Hukka16:03:18

I suppose I could do tricks with screen or tmux, but I was wondering if lein repl or nrepl itself could do some tricks. Or the clojure socket repl

Hukka16:03:01

I'd like a way to send forms from nvim to the repl and see them on the other screen, without having the multiwindow support landed in nvim

dominicm16:03:03

I've not seen this done. It could be, but you'd be in new territory.

Hukka19:03:31

Then I'll go with screen

Hukka19:03:52

It's pretty trivial to set it manually, but I have to figure out how to make it smooth

Hukka19:03:01

Something like opening a clj file would open a hidden :terminal buffer with screen -S project_name lein repl, unless screen with that name already exists, and then just connect to it (still hidden)

Hukka19:03:11

I suppose I'd better make a short shell script that handles the screen start/attach, and google a bit for how to do the nvim side. autocmd something something, I suppose

Hukka19:03:16

That will not work when it's time to do some cljs again, but I'll cross that hurdle when I get there

Hukka20:03:20

autocmd FileType clojure nested split term://~/bin/start-or-attach-to-repl.sh | :hide seems to do it, where my script recurses to parent dirs until it finds where project.lein is, then uses the name of the leaf dir to attach a screen, and if that fails, create a new one

Hukka20:03:43

Hack hack hack 🙂

Michael Fiano22:03:07

Anyone using fireplace that can make sense of the location list stack trace?

Michael Fiano22:03:16

It doesn't even give me an exception message

Michael Fiano22:03:45

How do people even go about debugging on vim? With CIDER I had exceptions being raised

schmee22:03:36

depends on what you mean with debugging

Michael Fiano22:03:33

Anything that doesn't leave me guessing why something doesn't compile

dave23:03:17

@mfiano i'll typically evaluate *e in the repl to see the full stacktrace

dave23:03:51

i haven't bothered to make sense of the location list stacktrace