Author Topic: Code completion using LSP and clangd  (Read 172063 times)

Offline kakas

  • Multiple posting newcomer
  • *
  • Posts: 20
  • potatoes are tasty(not the raw ones)
Re: Code completion using LSP and clangd
« Reply #405 on: April 10, 2024, 11:23:55 pm »
I should be the one thanking you for this amazing plugin ;D

In the coming Nightly, you will also be able to Alt-LeftMouseClick on the red/green warning/error box in the margin to apply any suggested fix.
Hmmm... I might have to keep an eye out for nightly build after this.

Offline MaxGaspa

  • Multiple posting newcomer
  • *
  • Posts: 33
Re: Code completion using LSP and clangd
« Reply #406 on: April 16, 2024, 12:02:56 pm »
Hi,

I'm writing to submit a (passible) bug report of the Code Completion plugin (LSP and Clangd).

When I load a project the plugin starts to parse all the project's files. I observe the log of parsing in the Code::Blocks  panel of the Logs window. In the meantime  I open a file, Application.cpp for example,  and  I select "Application:" to use the plugin (see image attached)...but...as soon as a new file is parsed the selection disappears....so I can't use the code completion till the full parsing of the projects. As soon as a new file parsing is completed the selection becomes blank.

Is this behavior expected?

Windows 10 , latest nightly , latest Mys2 clang 18.1.3-1

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2773
Re: Code completion using LSP and clangd
« Reply #407 on: April 16, 2024, 06:37:58 pm »
Hi,

I'm writing to submit a (passible) bug report of the Code Completion plugin (LSP and Clangd).

When I load a project the plugin starts to parse all the project's files. I observe the log of parsing in the Code::Blocks  panel of the Logs window. In the meantime  I open a file, Application.cpp for example,  and  I select "Application:" to use the plugin (see image attached)...but...as soon as a new file is parsed the selection disappears....so I can't use the code completion till the full parsing of the projects. As soon as a new file parsing is completed the selection becomes blank.

Is this behavior expected?

Windows 10 , latest nightly , latest Mys2 clang 18.1.3-1

Would you please give steps to re-create and trace the problem, i.e.,
1) do this
2) now do that

Offline MaxGaspa

  • Multiple posting newcomer
  • *
  • Posts: 33
Re: Code completion using LSP and clangd
« Reply #408 on: April 16, 2024, 08:05:51 pm »

Would you please give steps to re-create and trace the problem, i.e.,
1) do this
2) now do that

1) open a project with multiple source file, so the whole parsing process takes time (more than few seconds)
2) During the parsing process open a source file
3) Select in the box (shown in the attached e-mail) a choice
4) When the parsing of a file is completed the box is cleared (made empty).

In case I can make a video....

Max

Offline MaxGaspa

  • Multiple posting newcomer
  • *
  • Posts: 33
Re: Code completion using LSP and clangd
« Reply #409 on: April 16, 2024, 10:43:40 pm »

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2773
Re: Code completion using LSP and clangd
« Reply #410 on: Yesterday at 07:09:19 pm »
Hi,

I'm writing to submit a (passible) bug report of the Code Completion plugin (LSP and Clangd).

When I load a project the plugin starts to parse all the project's files. I observe the log of parsing in the Code::Blocks  panel of the Logs window. In the meantime  I open a file, Application.cpp for example,  and  I select "Application:" to use the plugin (see image attached)...but...as soon as a new file is parsed the selection disappears....so I can't use the code completion till the full parsing of the projects. As soon as a new file parsing is completed the selection becomes blank.

Is this behavior expected?

Windows 10 , latest nightly , latest Mys2 clang 18.1.3-1

Thanks for the video. It cleared up (in my head) what box you were trying to point out.

That box is called the Clangd_client (or CodeCompletion) toolbar.

It is only active when an editor has been activated. It shows the classes and the functions that the editors cursor is positioned within. I.e., the cursor must have clicked in an
editor at least once (activate) to fill in the choice boxes.

The left hand side (the one you were clicking in) displays the classes in an active editor file, and the right hand choice box shows all functions within the class.

You can cause the editor to position on a class/function by clicking in the left hand choice box to choose the class, then click in the right choice box and choosing what function to position to.

What's happening in your video is that you never activated the editor by clicking into it. So the choice boxes were never populated.

Regards

« Last Edit: Yesterday at 07:21:01 pm by Pecan »

Offline MaxGaspa

  • Multiple posting newcomer
  • *
  • Posts: 33
Re: Code completion using LSP and clangd
« Reply #411 on: Yesterday at 11:28:29 pm »

It is only active when an editor has been activated. It shows the classes and the functions that the editors cursor is positioned within. I.e., the cursor must have clicked in an
editor at least once (activate) to fill in the choice boxes.

What's happening in your video is that you never activated the editor by clicking into it. So the choice boxes were never populated.


Thank you for your answer but....

...it seems that the issue is still the same even if I'm clicking the editor.

Hereafter another video in which it should be very clear that I'm activating (clicking) the editor but the "left choice" still disapperar.

If I'm so quick (very quick) to select something in the "right choice" before the "left choice" is blanked .... then the "left choice" is no longer disappearing. But it's difficult...I need to be very quick. Basically I need to wait for the parsing completion before using the plugin.

https://drive.google.com/file/d/1ntVkrxRg9YccNJBByNuHaBKE-SgX3Xwn/view?usp=sharing

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2773
Re: Code completion using LSP and clangd
« Reply #412 on: Today at 01:03:08 am »

It is only active when an editor has been activated. It shows the classes and the functions that the editors cursor is positioned within. I.e., the cursor must have clicked in an
editor at least once (activate) to fill in the choice boxes.

What's happening in your video is that you never activated the editor by clicking into it. So the choice boxes were never populated.


Thank you for your answer but....

...it seems that the issue is still the same even if I'm clicking the editor.

Hereafter another video in which it should be very clear that I'm activating (clicking) the editor but the "left choice" still disapperar.

If I'm so quick (very quick) to select something in the "right choice" before the "left choice" is blanked .... then the "left choice" is no longer disappearing. But it's difficult...I need to be very quick. Basically I need to wait for the parsing completion before using the plugin.

https://drive.google.com/file/d/1ntVkrxRg9YccNJBByNuHaBKE-SgX3Xwn/view?usp=sharing

I cannot reproduce this. So would you start CB with the -d or /d parameter so that the Code::Blocks Debug log is produced.

Before you load your project be sure that the "CodeBlocks Debut" log tab is focused.

Do as you have done to cause the bug, then right-click the Code::Blocks Debug tab and choose copy "contents to clipboard", Paste it into a message here between code tags (the # icon above a forum reply box).

Thanks for your patience with this.
It's really peculiar.

BTW: after the new file is parsed and clicked into, can you even perform a Mainmenu/Search/goto function, (Ctrl-Shift-G for me.)
It tells me if if the bug is in the plugin interface to the editor code or the toobar code.

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2773
Re: Code completion using LSP and clangd
« Reply #413 on: Today at 01:18:54 am »

It is only active when an editor has been activated. It shows the classes and the functions that the editors cursor is positioned within. I.e., the cursor must have clicked in an
editor at least once (activate) to fill in the choice boxes.

What's happening in your video is that you never activated the editor by clicking into it. So the choice boxes were never populated.


Thank you for your answer but....

...it seems that the issue is still the same even if I'm clicking the editor.

Hereafter another video in which it should be very clear that I'm activating (clicking) the editor but the "left choice" still disapperar.

If I'm so quick (very quick) to select something in the "right choice" before the "left choice" is blanked .... then the "left choice" is no longer disappearing. But it's difficult...I need to be very quick. Basically I need to wait for the parsing completion before using the plugin.

https://drive.google.com/file/d/1ntVkrxRg9YccNJBByNuHaBKE-SgX3Xwn/view?usp=sharing

I just watched the video again.
I see that you're not clicking either inside a class or a function.
Do this, after the clicked file has parsed, click inside a function, not at the top of an editor file.
Tell me if you still get the bug.

If you get the bug, send me the Code::Blocks Debug log as specified in the previous messgage.

Thanks
« Last Edit: Today at 06:20:24 am by Pecan »

Offline kakas

  • Multiple posting newcomer
  • *
  • Posts: 20
  • potatoes are tasty(not the raw ones)
Re: Code completion using LSP and clangd
« Reply #414 on: Today at 08:17:02 am »
hey @Pecan
sorry to bother you again but I have encounter an unusual behavior.
I was trying to use a large single file libraryhttps://github.com/mackron/miniaudio.
It has a single headerfile: miniaudio.h <--- 62k lines

when I try to open the header file or search for declaration through the main.c, whole code blocks freezes for solid 1-2 mins, weanwhile the mouse gradually becomes unresponsive until it's completely frozen and the screen turns black. Throws an error that Clangd_Cliet has stopped at the end.

I not sure if it's because my laptop isn't powerful enough. because the plugin usually worked smooth with other large libraries.

Apart from this single instance the plugin works fine and it has been very helpful.