autocomplete in vim doesn't work when I hit ENTER and the cursor go to the next line.
this is my .vimrc configuration:
Thanks
CodePudding user response:
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
CodePudding user response:
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