fatih / vim-go

Go development plugin for Vim
https://www.patreon.com/bhcleek
Other
15.9k stars 1.45k forks source link

Using code completion breaks navigation for arguments placeholders #3601

Closed dunric closed 7 months ago

dunric commented 7 months ago

What did you expect to happen?

Using omni-completion should not affect calculation of function arguments placeholders position.

demonstrating example

What happened instead?

Invoking omni completion menu and selection of an entry did broke navigation & selection between placeholders.

Configuration (MUST fill this out):

vim-go version:

current

vimrc you used to reproduce:

vimrc ```vim let g:go_gopls_use_placeholders = v:true let g:go_snippet_engine = 'ultisnips' ```

Vim version (first three lines from :version):

VIM - Vi IMproved 9.0 (2022 Jun 28, compiled Oct 26 2023 20:39:23)

Go version (go version):

go version go1.21.4 linux/amd64

gopls version

gopls version Output:

golang.org/x/tools/gopls (devel)
    golang.org/x/tools/gopls@(devel)

vim-go configuration:

vim-go configuration
g:go_auto_type_info = 1
g:go_get_update = 0
g:go_doc_balloon = 0
g:go_doc_url = 'http://localhost:6060'
g:go_updatetime = 800
g:go_diagnostics_level = 1
g:go_term_enabled = 1
g:go_fold_enable = ['block', 'varconst', 'import']
g:go_metalinter_command = 'staticcheck'
g:go_doc_keywordprg_enabled = 1
g:go_doc_popup_window = 0
g:go_auto_sameids = 1
g:go_template_file = '/home/dunric/.vim/templates/skeleton.go'
g:go_metalinter_autosave = 1
g:go_gopls_use_placeholders = v:true
g:go_jump_to_error = 1
g:go_loaded_gosnippets = 1
g:go_term_mode = 'vertical botright split'
g:go_fillstruct_mode = 'gopls'
g:go_template_test_file = '/home/dunric/.vim/templates/skeleton_test.go'
g:go_loaded_install = 1

filetype detection configuration:

filetype detection
filetype detection:ON  plugin:ON  indent:ON
bhcleek commented 7 months ago

Ctrl-j works to navigate in the scenario you're describing, not ctrl-y.

dunric commented 7 months ago

Ctrl-j works to navigate in the scenario you're describing, not ctrl-y.

ctrl-y is used to select an entry from a pop-up completion menu. ctrl-j / ctrl-k no longer work, placeholder is misplaced (see the last image).

bhcleek commented 7 months ago

I misread your description. I thought you were trying to use ctrl-y to navigate after manually entering the first argument.

However, I'm unable to duplicate the problem you're describing.

I noticed that your gopls is not an official version. Can you update it with :GoUpdateBinaries gopls?

Also, what version of vim-go are you using? Your bug report says you're using the current version. Does that mean the latest master revision, the latest tagged release, or something else?

bhcleek commented 7 months ago

I can duplicate what you're describing. I'm not sure what the solution is, though šŸ¤”

bhcleek commented 7 months ago

I think I can fix this in the simple case where the completion text does not contain any placeholders, but it will remain for a case where a completion selection is made that contains placeholders, because Ultisnips does not support nested snippets.

dunric commented 7 months ago

I think I can fix this in the simple case where the completion text does not contain any placeholders, but it will remain for a case where a completion selection is made that contains placeholders, because Ultisnips does not support nested snippets.

Again, thanks for the great job and that you are still keep rolling.

I'd find this solution satisfactory, because placeholders require and rely solely on UltiSnips engine and its features anyway.

Take careā€¦