ale icon indicating copy to clipboard operation
ale copied to clipboard

Add more useful information in autocompletion results

Open xulongwu4 opened this issue 5 years ago • 10 comments

Ale is a great vim plugin and I have been happily using it for a while. I am experimenting with its code completion functionality recently. One thing I notice is that the popup menu for C-family languages does not have the function signature. The attachment is the result of code completion in a cpp file using Ale's omnifunc and clangd as the linter: Screenshot from 2019-05-26 07:11:33

While I can see the type of the completed keyword, I don't have any information about the function argument list. I also tried vim-lsp with clangd and the result is shown below. Screenshot from 2019-05-26 07:14:19

As can be seen, vim-lsp provides the user with the complete function prototype which could be extremely useful for complicated functions. I am wondering if the same thing can be implemented in ale. If it is already part of ale, can you elaborate a bit how to enable it?

xulongwu4 avatar May 26 '19 11:05 xulongwu4

That's something that can be improved upon later.

w0rp avatar May 26 '19 14:05 w0rp

I came across this also when testing ale, function autocomplete would be useful

That's something that can be improved upon later.

Glad you'll look into this in the future.

hfont avatar May 30 '19 19:05 hfont

Honestly, that's the only feature missing

nova-nowiz avatar Jun 11 '19 17:06 nova-nowiz

+1 would love this too, I found that when using baloons you get the signature, but this is no good to me in nvim and would like to see it as I type the ( or in the list of suggestions.

stefansedich avatar Jun 18 '19 19:06 stefansedich

Same thing with golang. Was looking for the answer in documentation for a long time, but now I've found this issue. Super-important feature which makes completions much more useful.

derlaft avatar Aug 03 '19 19:08 derlaft

Hi As a workaround / quick fix since dev is pretty slow here (tested for C code only with clangd)

you could modify the result dictionary to add the parameter list as follows in this file

 +        let l:parameters = substitute(get(l:item, 'label', ''), l:word, '', 'g')
         call add(l:results, {
         \   'word': l:word,
         \   'kind': ale#completion#GetCompletionSymbols(get(l:item, 'kind', '')),
         \   'icase': 1,
-        \   'menu': get(l:item, 'detail', ''),
+        \   'menu': l:parameters . ' : '. get(l:item, 'detail', ''),

Not bad for a Sunday morning fix, considering that I have no idea how vim script works nor ale.

Of course you could play with the results to tailor the output to your specific liking.

Regards,

Alfred

alfred2g avatar May 03 '20 18:05 alfred2g

@w0rp, would it be reasonable if we added a config to ale that would allow people to override the logic for the autocompletion results from their .vimrc? If so, I might take a stab at a pull request if I have time and no one is planning to work on this.

luizribeiro avatar Sep 02 '20 01:09 luizribeiro

Whats the status on this feature? Any known ways to get it working manually? I have been reading through the docs for a while and have no clue how to add this. I have been using BLAS in my C code lately and trying to remember the long function signatures is a pain, especially because the :ALEHover command only works when the linter is not complaining about missing arguments.

zoj613 avatar Oct 24 '20 11:10 zoj613

Any news?

sivakov512 avatar May 14 '21 16:05 sivakov512

I recommend those who really want this give implementing it and submitting a pull request a try. I think it could be on by default, and we could add a setting to disable it.

w0rp avatar Sep 06 '23 07:09 w0rp