ycm-core / YouCompleteMe

A code-completion engine for Vim
http://ycm-core.github.io/YouCompleteMe/
GNU General Public License v3.0
25.41k stars 2.81k forks source link

How to change YCM to display documentation for function/method instead of the signature help #3911

Closed xjvs closed 3 years ago

xjvs commented 3 years ago

Issue Prelude

Please complete these steps and check these boxes (by putting an x inside the brackets) before filing your issue:

Thank you for adhering to this process! It ensures your issue is resolved quickly and that neither your nor our time is needlessly wasted.

Issue Details

I have been using YCM for a while, and it was displaying documentation for me after I typed function name + (, and today after some uncertain changes, YCM is now displaying the signature help for me.

YCM is displaying signature help:

# vim main.rs
use rand::Rng;

fn main() {                  fn thread_rng() -> ThreadRng
    let s = rand::thread_rng(|
} 

| is where the cursor while typing. I want YCM to display the documentation for me, which means YCM should display the content of :YcmCompleter GetDoc instead of the fn thread_rng() -> ThreadRng.

I have read the documents, and seems displaying signature help is the default behavior of YCM, not sure how I made it work with displaying the documentation for me before, I tried re-installing YCM from fresh together with a minimal vimrc, but failed to figure out the solution, so I'm trying to ask for help here.

set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin()

Plugin 'gmarik/Vundle.vim' Plugin 'vim-syntastic/syntastic' Plugin 'rust-lang/rust.vim' Plugin 'ycm-core/YouCompleteMe'

call vundle#end() " required filetype plugin indent on " required

2. `vim -Nu /tmp/vimrc`
3. `:edit main.rs`

use rand::Rng;

fn main() { fn thread_rng() -> ThreadRng let s = rand::thread_rng(| }


* What did you expect to happen?

when I typed `function_name(`, YCM should display the function documentation in popup instead of the signature help. Documentation is the content of `:YcmCompleter GetDoc`. When I select the `thread_rng` from the autocomplete popup list, the documentation can be displayed in preview window, but it's not what I'm expecting, I want the documentation show up after I **typed** `thread_rng(`. 

* What actually happened?

The signature help of `rand::thread_rng` is displayed in popup.

# Diagnostic data

## Output of `vim --version`

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Jun 10 2021 00:00:00) Included patches: 1-2956


## Output of `YcmDebugInfo`

Printing YouCompleteMe debug information... -- Resolve completions: Up front -- Client logfile: /tmp/ycm_vt9ppz7x.log -- Server Python interpreter: /usr/bin/python3 -- Server Python version: 3.9.5 -- Server has Clang support compiled in: False -- Clang version: None -- No extra configuration file found -- Rust completer debug information: -- Rust Language Server running -- Rust Language Server process ID: 35719 -- Rust Language Server executable: ['/home/xjvs/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/rust-analyzer/bin/rust-analyzer'] -- Rust Language Server logfiles: -- /tmp/rust_language_server_stderrvwrktjzw.log -- Rust Language Server Server State: Initialized -- Rust Language Server Project Directory: /home/xjvs/workspace/rust/hello -- Rust Language Server Settings: {} -- Rust Language Server Project State: ready -- Rust Language Server Version: 2021-04-05 -- Rust Language Server Rust Root: /home/xjvs/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/rust-analyzer -- Server running at: http://127.0.0.1:60523 -- Server process ID: 35705 -- Server logfiles: -- /tmp/ycmd_60523_stdout_vvpwcfn1.log -- /tmp/ycmd_60523_stderr_9bwb_bkz.log


## Output of `git rev-parse HEAD` in YouCompleteMe installation directory

4df6f35f0c9f9aec21a3f567397496b5dee6acc7



## Contents of YCM, ycmd and completion engine logfiles

https://gist.github.com/xjvs/e67c0a404ed493bfdfc5739c85b127ba

## OS version, distribution, etc.

Fedora 34 x86_64
bstaletic commented 3 years ago

Check out :h 'completeopt' and :h g:ycm_add_preview_to_completeopt.

puremourning commented 3 years ago

not sure how I made it work with displaying the documentation for me before

Nor me. As this has never been a supported feature.

puremourning commented 3 years ago

If you’re looking for a way to disable signature help then there is an undocumented option for that. Maybe come to Gitter to discuss.

xjvs commented 3 years ago

Check out :h 'completeopt' and :h g:ycm_add_preview_to_completeopt.

I believe g:ycm_add_preview_to_completeopt doesn't work for displaying documentation in popup while typing. And I tested the completeopt with several possible values, like

let g:ycm_add_preview_to_completeopt=1
set completeopt=preview,menuone,popup

I still see signature help popup when just typed function_name( in insert mode.

xjvs commented 3 years ago

If you’re looking for a way to disable signature help then there is an undocumented option for that. Maybe come to Gitter to discuss.

Actually disabling signature help is documented:

" Disable signature help
let g:ycm_disable_signature_help = 1

However what I want is showing documentation (the content of :YcmCompleter GetDoc) instead of the signature help.