Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocomplete: show identifier information after completion is done #779

Closed
eduncan911 opened this issue Mar 29, 2016 · 2 comments
Closed

Comments

@eduncan911
Copy link

Actual behavior

Omnicomplete isn't inserting the parameters' of the function.

When browsing the omnicomplete options (arrowing up/down):

  • the Preview window changes to show the selected item in the menu.
  • the current line changes to show the select with an open (.

For example, when typing fmt. and then C-X and C-O, this is what is shown when I arrow-down to the func Fprint(w io.Writer, a ...interface{}) menu item and select it:

fmt.Fprint(

Even though the identifier information is actually shown in the Menu item, as well as the Preview as:

func Fprint(w io.Writer, a ...interface{}) (n int, err error) 

Expected behavior

I tried with various funcs and types.

Once selecting the Menu item from the Omnicomplete menu, I would expect the line of text to read:

fmt.Fprint(w, a...)

...or at least...

fmt.Fprint(w)

(omitting the variadic parameters)

I have seen where the author has created this functionality. See below screenshot from PR #685, which looks like exactly what I am after:

vim-go autocomplete identifer information

You'll see that fmt.Errorf("") inserts the quotation marks (because its required), omitting the variadic parameters. Whereas the selection of fmt.Println() is empty because it has all variadic parameters.

I also tried fmt.Errorf just as the image shows above and all I get is:

`fmt.Errorf(`

It doesn't complete the last ) nor does it insert the quotation marks "".

Steps to reproduce:

Very simple reproduction steps:

  1. Create a new .vimrc-test and load only the vim-go plugin. The .vimrc-test below is configured for vim-plug. Also tried pathogen.
  2. Run vim -u ~/.vimrc-test main.go or nvim -u ~/.vimrc-test main.go to load the minimized config file and start testing.
  3. Test omnicomplete.

(the above assumes you already have vim-go plugin in .vim/plugged. If not, edit the location on line 4)

Configuration

.vimrc-test

set nocompatible

" Change this to your plugin folder. '~/.vim/bunded' perhaps?
call plug#begin('~/.vim/plugged')
  Plug 'fatih/vim-go', { 'do' : 'vim +GoUpdateBinaries +qall && gometalinter --install --update' }
call plug#end()

function! VimGoSetup()
  " vim-go related mappings
  au FileType go nmap <Leader>gi <Plug>(go-info)
  au FileType go nmap <Leader>gI <Plug>(go-install)
  au FileType go nmap <Leader>gs <Plug>(go-implements)
  au FileType go nmap <Leader>gr <Plug>(go-run)
  au FileType go nmap <Leader>gb <Plug>(go-build)
  au FileType go nmap <Leader>gt <Plug>(go-test)
  au FileType go nmap <Leader>gc <Plug>(go-coverage)
  au FileType go nmap <Leader>ge <Plug>(go-rename)
  au FileType go nmap <Leader>gd <Plug>(go-doc)
  au FileType go nmap <Leader>gv <Plug>(go-doc-vertical)
  au FileType go nmap <Leader>gB <Plug>(go-doc-browser)
  au FileType go nmap <Leader>gd <Plug>(go-def-vertical)
  au FileType go nmap <Leader>ds <Plug>(go-def-split)
  au FileType go nmap <Leader>dv <Plug>(go-def-vertical)
  au FileType go nmap <Leader>dt <Plug>(go-def-tab)
  let g:go_highlight_functions = 1
  let g:go_highlight_methods = 1
  let g:go_highlight_structs = 1
  let g:go_highlight_interfaces = 1
  let g:go_highlight_operators = 1
  let g:go_highlight_build_constraints = 1  
endfunction

call VimGoSetup()
$ vim --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Mar 23 2016 14:13:02)
MacOS X (unix) version

$ nvim --version
NVIM 0.1.2

vim-go version (latest)

[eric@zoe][~/.vim/plugged/vim-go][master]
$ git log
commit 3efc952a7fb754b43b4c21474046126562f83efc
Author: Fatih Arslan <ftharsln@gmail.com>
Date:   Mon Mar 28 13:18:04 2016 +0300

    Merge pull request #778 from moorereason/iss777

    syntax: Fix gotexttmpl identifier highlighting

$ go version
go version go1.6 darwin/amd64
@fatih
Copy link
Owner

fatih commented Apr 2, 2016

Hi @eduncan911

This is how the completion is done. For the last ) it depends on which plugin you use (such as neocomplete, deoplete, etc ....). You should configure to add the parentheses or remove them.

Unfortunately there is now way to complete it based on the arguments. The reason is the arguments are something that needs to be changed and Vim doesn't have a snippet based replacement system included. So it's impossible to implement it the way we want. Thanks for opening the issue.

@fatih fatih closed this as completed Apr 2, 2016
@eduncan911
Copy link
Author

Ah, i completely mis-read that PR. I thought you were doing auto-complete. Turns out you were updating the statusline with that info. Yeah, I've had that working.

And yes, I've used neocomplete (vim) and switched to deoplete (neovim) lately (disabled them to try to get the "") to insert like the image). But now I see that was done with one of those plugins, not vim-go. I've also experienced the closing ) with them but never had parameters inserting between it, like full blown IDEs have.

Thanks for the info about the snippet based system. Sounds like you've researched this greatly in the past. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants