Closed pvaibhav closed 7 years ago
I'm not familiar with objective-c. Could you give me an code snippet for me to test?
Also will this work on fedora or Windows? I don't have a mac for test.
@richard1122 objective-c is a superset of C, so you can just set the filetype of any C file in VScode as "Objective C" file type. Clang by default supports C/C++/ObjC/ObjC++ so it should work just fine also on Linux.
As soon as I change VScode filetype to ObjC, I don't get any kind of completion anymore (e.g. hovering over a symbol shows no type info). When I change back to C it works. The usual extension for ObjC files is *.m for autodetection, which also doesn't work.
E.g. here's a simple (Obj)C source file:
struct Test {
int k;
float b;
};
int main(void) {
struct Test pp;
pp.
}
When filetype is set to "C" and I press the .
key at pp.
I get nice completion:
But changing the filetype to "Objective C" in VScode, pressing .
at the same place results in no completion. Also hovering over the pp
symbol doesn't show any tooltip with type info.
Here's a YCMD log (last line relevant):
[ycm stderr] Traceback (most recent call last):
File "/Users/pvaibhav/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/bottle/bottle.py", line 861, in _handle
return route.call(**args)
File "/Users/pvaibhav/.vim/plugged/YouCompleteMe/third_party/ycmd/third_party/bottle/bottle.py", line 1734, in wrapper
rv = callback(*a, **ka)
File "/Users/pvaibhav/.vim/plugged/YouCompleteMe/third_party/ycmd/ycmd/../ycmd/watchdog_plugin.py", line 108, in wrapper
return callback( *args, **kwargs )
File "/Users/pvaibhav/.vim/plugged/YouCompleteMe/third_party/ycmd/ycmd/../ycmd/hmac_plugin.py", line 70, in wrapper
body = callback( *args, **kwargs )
File "/Users/pvaibhav/.vim/plugged/YouCompleteMe/third_party/ycmd/ycmd/../ycmd/handlers.py", line 81, in RunCompleterCommand
completer = _GetCompleterForRequestData( request_data )
File "/Users/pvaibhav/.vim/plugged/YouCompleteMe/third_party/ycmd/ycmd/../ycmd/handlers.py", line 289, in _GetCompleterForRequestData
return _server_state.GetFiletypeCompleter( request_data[ 'filetypes' ] )
File "/Users/pvaibhav/.vim/plugged/YouCompleteMe/third_party/ycmd/ycmd/../ycmd/server_state.py", line 89, in GetFiletypeCompleter
current_filetypes ) )
ValueError: No semantic completer exists for filetypes: [u'objective-c']
@richard1122 I changed line 150 in ycmRequest.js to this:
filetypes: [it.languageId === 'objective-c' ? 'objc' : it.languageId]
just as a quick check. This actually worked:
and from ycmd log I can see filetype set to what Vim/YCM expects ("filetypes":["objc"]
):
[_request] {"filepath":"/Users/pvaibhav/Work/app-vegas/Source Code/Utility/CommonMath.c","working_dir":"/Users/pvaibhav/Work/app-vegas","file_data":{"/Users/pvaibhav/Work/app-vegas/Source Code/Utility/CommonMath.c":{"contents":"struct Test {\n int k;\n float b;\n};\n\nint main(void) {\n struct Test pp;\n pp.\n}","filetypes":["objc"]}},"line_num":8,"column_num":6,"command_arguments":["FixIt"],"completer_target":"filetype_default"}
I guess there should be a mapping to convert VScode filetypes <--> Vim filetypes.
I'm not modifying the code and sending a pull request myself because I know nothing about Javascript or VScode extensions! I'm sure you can code this better. :)
Hi, I've add support for objc and it works fine.
I will release a new version soon and please have a try.
Thanks!
Thank you for the fix! Might I also suggest adding a mapping of objective-cpp
-> objcpp
.
It seems YCM expects the filetype to be
objc
but VScode sets the filetype toobjective-c
, causing code completion for ObjC files to fail, even ifycmd.enabled_languages
is set (neitherobjc
norobjective-c
work).