Hi!
I've recently started to work with SMT32 microcontrollers, and I discovered that standard Code::Blocks's code completion plugin doesn't work very well in some specific cases like this one:
#define GPIOA ((GPIO_TypeDef *) GPIOA_BASE)
GPIOA_BASE is not recognized correctly as a pointer to the structure of type
GPIO_TypeDef, and Code::Blocks doesn't give any autocomplete suggestions after I type "
GPIOA_BASE->" (see
https://forums.codeblocks.org/index.php/topic,21823.0.html). So I decided to try this plugin.
So I installed the latest nightly build (06 May 2023 build (13268)) of C::B and clangd 16.0.2. Then I disabled the original code completion plugin, enabled clang_client and set the path to the clang executable. But when I tried to open my STM32 project, I got an error message (see the attached screenshot). It is obvious that there was some encoding problem caused by Cyrillic characters in the project path. Usually in such cases I create symbolic links/directory junctions with appropriate English-only directory names, but in this case I can't fix the problem this way because clangd doesn't work great with symlinks.
I decided to download the sources of C::B and plugins and try to fix the problem myself. And I think I managed to get it to work correctly. I've changed the file plugins/contrib/clangd_client/src/LSPclient/client.cpp. Here is the diff output:
Index: client.cpp
===================================================================
--- client.cpp (revision 13268)
+++ client.cpp (working copy)
@@ -1890,7 +1890,7 @@
writeClientLog(StdString_Format("<<< Initialize(): %s", stdDirName.c_str()) );
// Set the project folder as the folder containing the commands file. //(ollydbg 2022/10/19) Ticket #75
- try { Initialize(string_ref(fileUtils.FilePathToURI(dirname)), string_ref(dirname.ToUTF8())); } //(ollydbg 2022/10/19) ticket #75
+ try { Initialize(string_ref(fileUtils.FilePathToURI(dirname.ToUTF8())), string_ref(dirname.ToUTF8())); } //(ollydbg 2022/10/19) ticket #75
catch(std::exception &err)
{
//printf("read error -> %s\nread -> %s\n ", e.what(), read.c_str());
I'm not sure if I've done it right, but it seems that the plugin is working fine. Maybe this information will be helpful for the further development of the clangd-client plugin.
Best regards,
Arseniy.
P.S. Thank you @Pecan and the other developers who works on this plugin. It's a great idea to integrate C::B with clangd!