richard1122 / vscode-youcompleteme

YouCompleteMe for VSCode
https://marketplace.visualstudio.com/items?itemName=RichardHe.you-complete-me
MIT License
53 stars 8 forks source link

Provide identifier completion result by YCM #35

Closed LinSHP closed 7 years ago

LinSHP commented 7 years ago

I installed the youcompleteme and complet configurations like setting "ycmd.path" and "ycmd.global_extra_config". But When I edit .c file..nothing happens. Is there any other configurations I need to set?

PS:English is poor..sorry

richard1122 commented 7 years ago

Could you set ycmd.debug=true in settings and have a look at logs?

PS Chinese is also OK.

LinSHP commented 7 years ago

我设置了ycmd.debug=true,但是不知道去哪里找log file。搜了下发现是输入:YcmDebugInfo,但是在哪里输呢

richard1122 commented 7 years ago

image 在 vscode 里面打开输出面板,选择 ycm 插件的输出,就可以直接在 vscode 里面查看

LinSHP commented 7 years ago

信息是这样的:

[onDidChangeConfiguration settings] {"ycmd":{"confirm_extra_conf":true,"debug":true,"enabled_languages":["cpp","c"],"global_extra_config":"/Users/linsp/Downloads/ycmd-master/ycmd/cpp/ycm/.ycm_extra_conf.py","path":"/Users/linsp/Downloads/ycmd-master/ycmd","python":"python","use_imprecise_get_type":false}} [getInstance] ycm is restarting [onDidOpen] file:///Users/linsp/Dropbox/hw8/hw.c [getInstance] ycm is initializing, delay 200ms... [onDidChangeContent "file:///Users/linsp/Dropbox/hw8/hw.c"] [getInstance] ycm is initializing, delay 200ms... [onCodeAction] {"textDocument":{"uri":"file:///Users/linsp/Dropbox/hw8/hw.c"},"range":{"start":{"line":7,"character":1},"end":{"line":7,"character":1}},"context":{"diagnostics":[]}} [getInstance] ycm is initializing, delay 200ms... [start] unused port: 58989 [start] random secret: 2d4de9e67be5c234864eec3b324a9163 [start] default options: {"filepath_completion_use_working_dir":0,"auto_trigger":1,"min_num_of_chars_for_completion":2,"min_num_identifier_candidate_chars":0,"semantic_triggers":{},"filetype_specific_completion_to_disable":{"gitcommit":1},"seed_identifiers_with_syntax":0,"collect_identifiers_from_comments_and_strings":0,"collect_identifiers_from_tags_files":0,"max_num_identifier_candidates":10,"extra_conf_globlist":[],"global_ycm_extra_conf":"","confirm_extra_conf":1,"complete_in_comments":0,"complete_in_strings":1,"max_diagnostics_to_display":30,"filetype_whitelist":{"":1},"filetype_blacklist":{"tagbar":1,"qf":1,"notes":1,"markdown":1,"netrw":1,"unite":1,"text":1,"vimwiki":1,"pandoc":1,"infolog":1,"mail":1},"auto_start_csharp_server":1,"auto_stop_csharp_server":1,"use_ultisnips_completer":1,"csharp_server_port":0,"hmac_secret":"","server_keep_logfiles":0,"gocode_binary_path":"","godef_binary_path":"","rust_src_path":"","racerd_binary_path":"","python_binary_path":""} [processData: {"filepath_completion_use_working_dir":0,"auto_trigger":1,"min_num_of_chars_for_completion":2,"min_num_identifier_candidate_chars":0,"semantic_triggers":{},"filetype_specific_completion_to_disable":{"gitcommit":1},"seed_identifiers_with_syntax":0,"collect_identifiers_from_comments_and_strings":0,"collect_identifiers_from_tags_files":0,"max_num_identifier_candidates":10,"extra_conf_globlist":[],"global_ycm_extra_conf":"/Users/linsp/Downloads/ycmd-master/ycmd/cpp/ycm/.ycm_extra_conf.py","confirm_extra_conf":true,"complete_in_comments":0,"complete_in_strings":1,"max_diagnostics_to_display":30,"filetype_whitelist":{"":1},"filetype_blacklist":{"tagbar":1,"qf":1,"notes":1,"markdown":1,"netrw":1,"unite":1,"text":1,"vimwiki":1,"pandoc":1,"infolog":1,"mail":1},"auto_start_csharp_server":1,"auto_stop_csharp_server":1,"use_ultisnips_completer":1,"csharp_server_port":0,"hmac_secret":"LU3p5nvlwjSGTuw7MkqRYw==","server_keep_logfiles":0,"gocode_binary_path":"","godef_binary_path":"","rust_src_path":"","racerd_binary_path":"","python_binary_path":"","rustSrcPath":""}] [start] optionsFile: /var/folders/vf/0_kypcd914j_pd5xct2zn_fr0000gp/T/VSCodeYcmOptions-1493466250014 [_start] [ '/Users/linsp/Downloads/ycmd-master/ycmd/ycmd', '--port=58989', '--options_file=/var/folders/vf/0_kypcd914j_pd5xct2zn_fr0000gp/T/VSCodeYcmOptions-1493466250014', '--idle_suicide_seconds=600' ] [_start] process spawn success 97258 [getInstance] ycm is initializing, delay 200ms... [getInstance] ycm is initializing, delay 200ms... [getInstance] ycm is initializing, delay 200ms... [getInstance] ycm is initializing, delay 200ms... [getInstance] ycm is initializing, delay 200ms... [getInstance] ycm is initializing, delay 200ms... [getInstance] ycm is initializing, delay 200ms... [getInstance] ycm is initializing, delay 200ms... [getInstance] ycm is initializing, delay 200ms... [getInstance] ycm is initializing, delay 200ms... [getInstance] ycm is initializing, delay 200ms... [getInstance] ycm is initializing, delay 200ms... [getInstance] ycm is initializing, delay 200ms... [getInstance] ycm is initializing, delay 200ms... [getInstance] ycm is initializing, delay 200ms... [start] ycm started: 97258 [buildRequest] document, /Users/linsp/Dropbox/hw8/hw.c; position: null; event: BufferVisit [_request] {"filepath":"/Users/linsp/Dropbox/hw8/hw.c","working_dir":"/Users/linsp/Dropbox/hw8","file_data":{"/Users/linsp/Dropbox/hw8/hw.c":{"contents":"#include \n\n#define MAXLEN 210\n\nint main() {\n int n, m;\n int favoriteColors[MAXLEN];\n}","filetypes":["c"]}},"line_num":1,"column_num":1,"event_name":"BufferVisit"} [_request] req.end called [buildRequest] document, /Users/linsp/Dropbox/hw8/hw.c; position: [object Object]; event: null [_request] {"filepath":"/Users/linsp/Dropbox/hw8/hw.c","working_dir":"/Users/linsp/Dropbox/hw8","file_data":{"/Users/linsp/Dropbox/hw8/hw.c":{"contents":"#include \n\n#define MAXLEN 210\n\nint main() {\n int n, m;\n int favoriteColors[MAXLEN];\n}","filetypes":["c"]}},"line_num":8,"column_num":2,"command_arguments":["FixIt"],"completer_target":"filetype_default"} [_request] req.end called [ycm stderr] 2017-04-29 19:44:11,281 - INFO - Received event notification

[ycm stderr] 2017-04-29 19:44:11,287 - INFO - Received command request

[_request] status code: 200 [_request] {} [getReady] {} [_request] status code: 200 [_request] {"fixits": []}

richard1122 commented 7 years ago

可能需要继续写一下代码,试图做一下补全?

LinSHP commented 7 years ago
2017-04-29 20 16 59

比如说我这个时候输maxLen,难道它不应该给我自动补全,或者一些提示什么的。但是什么也没发生?

richard1122 commented 7 years ago

有些操作才能触发一些补全。比如说定义一个结构体,然后对 实例输入 . 调用成员变量的时候,你试试?

LinSHP commented 7 years ago

是的,和你说的一样,结构体实例是可以补全成员变量的。 那么变量就不能自动补全吗,或者你有什么推荐的可以自动补全变量名的插件? 十分感谢

richard1122 commented 7 years ago

这是目前 vscode 对补全插件的一些限制,需要用一些按键来触发补全,所以我就预先定义了包括 . -> 等等的几个。 我会看看是否有更好的方式来绕过这部分限制的。

LinSHP commented 7 years ago

好的,非常感谢你的帮助!

richard1122 commented 7 years ago

我打算修改一下这个 issue 的标题让它更符合问题一些,如果你觉得不合适请直接指出~

richard1122 commented 7 years ago

我确认了一下的确没法让 vscode 每次都调用补全的,如果需要的话你可以使用 ctrl + space 来让 vscode 强制进行补全。 https://github.com/Microsoft/vscode-tips-and-tricks#intellisense

michaelHL commented 7 years ago

@richard1122 插件 C/C++ Clang Command Adapter 的补全比较完整(除了那些trigger比如 ., ::, >,字母开头的结构名、函数名也能够提示):

上面关于C/C++的插件仅 C/C++ Clang Command Adapter 一个. 但是vscode-ycm必须通过加上 . 才能「激活」这些功能:

上面的图片删除了前述插件并仅安装vscode-ycm,请问这是ycmd的问题呢还是插件的问题呢?提示补全可否更进一步呢?😃


测试环境各版本如下:

其中的ycmd是利用如下工具在win下编译的(根据官方的安装指南):

VSCode中关于插件的配置如下:

"ycmd.path": "E:\\YouCompleteMe\\third_party\\ycmd",
"ycmd.confirm_extra_conf": true,
"ycmd.global_extra_config": "F:\\WorkingDirectory\\Configuration\\common\\_ycm_extra_conf.py",
"ycmd.python": "D:\\Python\\Python27\\python.exe",

配置中的文件为 _ycm_extra_conf.py

感谢作者的付出!

michaelHL commented 7 years ago

应该是ycmd的机制问题,它仅在特定的trigger之后触发

哈哈我自言自语了! 😄