Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development
Code completion using LSP and clangd
ollydbg:
Hi, I try to debug this plugin, but I have always have this line hit:
--- Code: ---// ----------------------------------------------------------------------------
void CodeCompletion::OnAttach()
// ----------------------------------------------------------------------------
{
AppVersion appVersion;
appVersion.m_AppName = "clangd_client";
// Set current plugin version
PluginInfo* pInfo = (PluginInfo*)(Manager::Get()->GetPluginManager()->GetPluginInfo(this));
pInfo->version = appVersion.GetVersion();
// ccmanager's config obtained from Menu=>Settings=>Editor=>Code Completion (sub panel)
// Get the CB config item that enables CodeCompletion
ConfigManager* ccmcfg = Manager::Get()->GetConfigManager(_T("ccmanager"));
m_CodeCompletionEnabled = ccmcfg->ReadBool(_T("/code_completion"), false);
if (not m_CodeCompletionEnabled)
{
pInfo->version = pInfo->version.BeforeFirst(' ') + " Inactive";
return;
}
--- End code ---
I have always get the m_CodeCompletionEnabled is false, and I have no idea how to enable it.
What I did is like below:
1, I have build a normal cbp:
--- Code: ---D:\code\cb\cb_sf_git\cccrash2019\src\CodeBlocks_wx31_64.cbp
--- End code ---
I just build it.
2, I just open the downloaded clangd_client project, and I changed some build options:
In the build option custom variables, I set the variable: TARGET_DEVEL_DIR
as the value: D:\code\cb\cb_sf_git\cccrash2019, which is the root folder of my local C::B git/svn
3, I changed the output filename as:
--- Code: ---$(TARGET_DEVEL_DIR)\src\devel31_64\share\CodeBlocks\plugins\clangd_client.dll
--- End code ---
which means the build target(clangd_client.dll) will be put in the same folder as the other core plugins.
4, I set the Execution working dir as:
--- Code: ---$(TARGET_DEVEL_DIR)\src\devel31_64
--- End code ---
Which is the folder where codeblocks.exe locates.
5, I change the post build script as:
--- Code: ---cmd /c if not exist $(TARGET_DEVEL_DIR)\src\devel31_64\share\CodeBlocks mkdir $(TARGET_DEVEL_DIR)\src\devel31_64\share\CodeBlocks
zip -jq9 $(TARGET_DEVEL_DIR)\src\devel31_64\share\CodeBlocks\clangd_client.zip src/resources/manifest.xml src/resources/*.xrc
zip -r9 $(TARGET_DEVEL_DIR)\src\devel31_64\share\CodeBlocks\clangd_client.zip src/resources/images > nul
--- End code ---
This means I make a clangd_client.zip, and put it in the destination devel31_64 folder.
Pecan:
--- Quote from: ollydbg on January 15, 2022, 02:15:44 pm ---Hi, I try to debug this plugin, but I have always have this line hit:
I have always get the m_CodeCompletionEnabled is false, and I have no idea how to enable it.
What I did is like below:
1, I have build a normal cbp:
--- Code: ---D:\code\cb\cb_sf_git\cccrash2019\src\CodeBlocks_wx31_64.cbp
--- End code ---
I just build it.
2, I just open the downloaded clangd_client project, and I changed some build options:
In the build option custom variables, I set the variable: TARGET_DEVEL_DIR
as the value: D:\code\cb\cb_sf_git\cccrash2019, which is the root folder of my local C::B git/svn
3, I changed the output filename as:
--- Code: ---$(TARGET_DEVEL_DIR)\src\devel31_64\share\CodeBlocks\plugins\clangd_client.dll
--- End code ---
which means the build target(clangd_client.dll) will be put in the same folder as the other core plugins.
4, I set the Execution working dir as:
--- Code: ---$(TARGET_DEVEL_DIR)\src\devel31_64
--- End code ---
Which is the folder where codeblocks.exe locates.
5, I change the post build script as:
--- Code: ---cmd /c if not exist $(TARGET_DEVEL_DIR)\src\devel31_64\share\CodeBlocks mkdir $(TARGET_DEVEL_DIR)\src\devel31_64\share\CodeBlocks
zip -jq9 $(TARGET_DEVEL_DIR)\src\devel31_64\share\CodeBlocks\clangd_client.zip src/resources/manifest.xml src/resources/*.xrc
zip -r9 $(TARGET_DEVEL_DIR)\src\devel31_64\share\CodeBlocks\clangd_client.zip src/resources/images > nul
--- End code ---
This means I make a clangd_client.zip, and put it in the destination devel31_64 folder.
--- End quote ---
The variable m_CodeCompletionEnabled should,in fact, be false.
Note that the line: m_CodeCompletionEnabled = ccmcfg->ReadBool(_T("/code_completion"), false);
is asking if the old code_completion is enabled. It not asking if "/clangd_client" is enabled.
"/code_completion" must be disabled for clangd_client to run.
I'll change the comments to make that clearer.
Edit: 2022/01/15 10:30
I might be wrong about this. I'll do more checking.
The .cbp you've created look good.
Just a little more information.
Run or debug the CB you created the plugin for.
In the menu for the running debugged/run CB
Go to MainMenu=>Plugins=>Manage Plugins and tell us what the clangd_client plugin version is:
Pecan:
@ollydbg
When you run the debugger, CB ordinary uses the personality "default" which, for you, I'm guessing has CodeCompletion plugin enabled.
You should use a separate personality for debugging so that you can disable CodeCompletion in the debugged CB without disabling it in your production CB.
For me, in CB main menu/project/SetProgramArgument I have:
--debug-log --no-dde --no-check-associations --multiple-instance --no-splash-screen --verbose /p cbDebug315
Then I can disable CodeCompletion in the debugged CB MainMenu/plugins/managePlugins without it affecting the main CB personality "default".
I'd still like to see the "manage plugins" status of both clangd_client and Code Completion plugins to determine why your m_CodeCompletionEnabled variable is false.
Pecan:
@ollydbg
m_CodeCompletionEnabled variable refers to Settings/Editor/Code completion checkbox.
For your debugged CB, it must be currently unchecked which means neither Code completion nor clangd_client can run.
ollydbg:
--- Quote from: Pecan on January 15, 2022, 10:32:40 pm ---@ollydbg
m_CodeCompletionEnabled variable refers to Settings/Editor/Code completion checkbox.
For your debugged CB, it must be currently unchecked which means neither Code completion nor clangd_client can run.
--- End quote ---
I have screen shots, see below as in attachment.
I have Settings/Editor/Code completion checkbox checked. If I member correctly this checkbox does not mean we should "disable" the plugin, instead, it means we don't show the suggestion prompt when we are editing.
The other screen shot shows the version latest version I'm using.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version