0

autocomplete in vim doesn't work when I hit ENTER and the cursor go to the next line.

this is my .vimrc configuration: https://github.com/marcosvidolin/dotfiles/blob/master/.vimrc

Popup example:

enter image description here

Thanks

romainl
  • 186,200
  • 21
  • 280
  • 313
Marcos Vidolin
  • 186
  • 4
  • 21

2 Answers2

2

you need to add this to your .vimrc

inoremap <silent><expr> <cr> coc#pum#visible() ? coc#_select_confirm() : "\<C-g>u\<CR>"

source : Completion with sources

Rahmat Fathoni
  • 1,272
  • 1
  • 2
  • 8
1

I am using vim and using Coc module for language server configuration. Try to run these following steps:

  • Install gopls GO111MODULE=on go get golang.org/x/tools/gopls@latest
  • Open you vim and type :CocConfig and setting up go language configuration like the following bellow. (note: feel free to customize the value, especially in field rootPatterns)
{
    "languageserver": {
        "golang": {
            "command": "gopls",
            "rootPatterns": ["go.mod", "main.go", ".vim/", ".git/", ".hg/"],
            "filetypes": ["go"],
            "initializationOptions": {
                "usePlaceholders": true
      }
    }
  }
}
  • Save File and Reload your vim configuration
giyuu
  • 99
  • 4