Error on hovering over variable
I am able to use the completion when I type a trigger character, however, when I hover over a variable, the console displays the following output:
INFO:EasyClangComplete.plugin.view_config: init completer based on libclang ERROR:concurrent.futures:exception calling callback for <Future at 0x7f288d91ff10 state=finished raised ArgumentError> Traceback (most recent call last): File "./python3.3/concurrent/futures/_base.py", line 296, in _invoke_callbacks File "/home/avidbots/.config/sublime-text-3/Packages/EasyClangComplete/EasyClangComplete.py", line 261, in info_finished (tooltip_request, result) = future.result() File "./python3.3/concurrent/futures/_base.py", line 394, in result File "./python3.3/concurrent/futures/_base.py", line 353, in __get_result File "./python3.3/concurrent/futures/thread.py", line 54, in run File "/home/avidbots/.config/sublime-text-3/Packages/EasyClangComplete/plugin/completion/lib_complete.py", line 242, in info self.tu, self.tu.get_location(view.file_name(), (row, col))) File "/home/avidbots/.config/sublime-text-3/Packages/EasyClangComplete/plugin/clang/cindex35.py", line 2346, in get_location f = self.get_file(filename) File "/home/avidbots/.config/sublime-text-3/Packages/EasyClangComplete/plugin/clang/cindex35.py", line 2335, in get_file return File.from_name(self, filename) File "/home/avidbots/.config/sublime-text-3/Packages/EasyClangComplete/plugin/clang/cindex35.py", line 2531, in from_name return File(conf.lib.clang_getFile(translation_unit, file_name)) ctypes.ArgumentError: argument 2: <class 'TypeError'>: wrong type
These are the settings I am using:
{
"flags_sources": [
{"file": ".clang_complete"},
{"file": "compile_commands.json"},
{"file": "CMakeLists.txt"},
],
"common_flags" : [
// some example includes
"-I/usr/include",
// this is needed to include the correct headers for clang
"-I/usr/lib/clang/$clang_version/include",
"-I/opt/ros/indigo/include",
"-I/opt/ros/indigo/include/roscpp",
"-I/usr/include/x86_64-linux-gnu/c++/4.8",
"-I/home/avidbots/Dev/avidbots/ros_indigo/src/avidbots_library/"
],
// C specific flags. Prepend common_flags for C files.
"c_flags" : [
"-std=c11"
],
// C++ specific flags. Prepend common_flags for C++ files.
"cpp_flags" : [
"-std=c++11"
],
"clang_binary" : "clang-3.5"
}
I'm only using the .clang_complete file. It is quite large since I am developing a robotics project with ROS and a large amount of nodes (each with different include directories).
The first 9 lines of this file is:
-I/usr/include -I/usr/include/eigen3 -I/usr/lib/clang/$clang_version/include -I/opt/ros/indigo/include -I/opt/ros/indigo/include/roscpp -I/usr/include/x86_64-linux-gnu/c++/4.8 -I/home/avidbots/Dev/avidbots/ros_indigo/src/avidbots_library -I/home/avidbots/Dev/avidbots/ros_indigo -I/home/avidbots/Dev/avidbots/ros_indigo/devel/include
I'll have a look at it as soon as I find some time. Meantime, is it possible for you to update libclang to something not so ancient?
Actually, there have always been problems with clang 3.5 and I have no idea why :) The plugin works nicely with 3.4, 3.6, 3.8, 3.9. Other can have strange issues because of some subtle differences in the python bindings that I don't know how to trace
Ok. Oh, I forgot to mention! I'm on Ubuntu 14.04 running Sublime Text 3. I'll see if Clang 3.6 is available for me.
I updated to Clang 3.8 and now I get the following error:
INFO:EasyClangComplete.plugin.clang.utils: found libclang library file: '/usr/lib/x86_64-linux-gnu/libclang.so.1' ERROR:EasyClangComplete.plugin.completion.lib_complete: error: /usr/lib/x86_64-linux-gnu/libclang.so.1: undefined symbol: clang_CXXField_isMutable. Please ensure that your python bindings are compatible with your libclang.so version. ERROR:EasyClangComplete.plugin.view_config: cannot initialize completer with libclang. INFO:EasyClangComplete.plugin.view_config: falling back to using clang in a subprocess. INFO:EasyClangComplete.plugin.view_config: init completer based on clang from cmd
I think I can fix it. There are multiple libclang files in my directory and it should be using libclang-3.8.so.1, but it is erroneously trying to use libclang.so.1. How can I make it use libclang-3.8.so.1?
Also, I believe this might have been what was causing the issue earlier. Since I have a libclang-3.5.so.1 file in the directory but it was using libclang.so.1
Ok, so I don't get the error anymore. The problem seems to be from the way that the name is formed for searching for the library. In Packages/EasyClangComplete/plugin/clang/utils.py the function "find_libclang_dir" on line 68.
However--and I'm not sure if this is the intended effect--nothing happens when I hover over variables. I thought it would be different and provide information on the struct/class etc.
I have "show_type_info" set to true in my settings now, but there is still no effect. Am I missing something? I get no errors now though.
So... do you have correct clang_binary setting set? Does completions work for you? If both yest we'll keep looking :)
I "think" my clang_binary settings are correct (I'm not an expert on its usage). Completion works for me and I'm no longer getting any errors in the console. Could someone explain the intended behaviour of the hover? I would like to compare with what I get. I only receive a popup once I hover over a function and it is from Sublime telling me which files contain a function that match that name.
Here is a picture where my cursor is hovering over the function "AngleWrap()"

Oh it works now. I cleared my cache with EasyClangComplete: Clean current CMake cache.
I can now see the types of variables once I hover over them and I get information on functions as well. Excellent! I think this solves it. So I guess this could be wrapped up. The problem was that the wrong libclang library was being used.
Suggestion:
I would suggest that for Linux, after receiving the binary you could parse the input produced by "
Then for Linux systems attempt to search first for a libclang file that has the form: libclang-<parsed_version_string>.so.1
A quick fix would be to accept an input in the settings file for the libclang library name; perhaps a good fallback.
Yeah, looking for libclang-x.x.so.1 seems reasonable. The problem is that it is not guaranteed that they will have .1 index in the end. Also, I believe it is not a good idea to have multiple clang installations on your system as there is no way to control which one is currently used. I think your problems were caused by having multiple installations. Every version overrides libclang.so as far as I remember, so even if you provide a correct clang_binary setting it will still try to find a wrong libclang.
I'm not sure the significance of the '.1' index. But the way your code works is that it searches until it finds something. So it does iterate by first checking the '.so' and then the '.so.1'. I've made a patch to the code for my copy so that it will always look for the appropriate libclang-x.x.so(.1) version first and then if it's not available, it will check for libclang. You already have a lot of the structure needed to do this. I added maybe 6 lines to do this.
It would be good if there was a way to confirm that the library is correct or not. I.e. to call a function from libclang.so that will tell you if the versions match up. It's probably not a good idea to have multiple clang versions, but other users will make the same mistake. It would be helpful to an actionable error message. Anyway, I enjoy the plugin very much!
Feel free to submit a pull request for the patch you propose. I will be happy to merge it.
There you go :)
Closed with the pull request.