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

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2507
Re: Code completion using LSP and clangd
« Reply #255 on: November 14, 2022, 06:08:10 pm »
Cool.
I see that clangd_client plugin is now included in contrib plugins.
Three details :
  • within contrib, it's version 87 though on your svn site it's version 88;
  • CodeBlocks_wx32_64.workspace has not been updated to include the clangd_client but all other workspaces are OK;
  • the documentation-install folder is not there.

gd_on

I don't know how to control that header version number, but the code for rev 88 is included with the contrib commit.

CodeBlocks_wx32_64.workspace corrected; Thanks.

The documentation-install folder was left out on purpose and will be included in the CB wiki for Clangd_client so we can just refer to the wiki url to answer questions. A new section will be added for just "using" the plugin vs "compiling from source.

Thanks
« Last Edit: November 14, 2022, 06:24:04 pm by Pecan »

Online gd_on

  • Lives here!
  • ****
  • Posts: 767
Re: Code completion using LSP and clangd
« Reply #256 on: November 14, 2022, 06:49:53 pm »
OK.
Nevertheless I see at least four differences :
- in version.h, probably not very important (svn version number)
- in manifest.xml, here too not very important (svn version number)
- in codecompletion.cpp, here too not very important (revision number in the headers)
- in LSP_symbolsparser.cpp, small differences near line 2200. I don't know if it's important
There are other differences but only in $HeadURL lines, so no problems.
« Last Edit: November 14, 2022, 06:56:10 pm by gd_on »
Windows 10 64 bits (22H2), svn C::B (last version or almost!), wxWidgets 3.2.1, Msys2 Compilers 12.2.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\msys64\mingw64) or 32 bits (dwarf2, posix  in C:\msys64\mingw32).

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2507
Re: Code completion using LSP and clangd
« Reply #257 on: November 14, 2022, 06:57:11 pm »
File clangd_client_wx31.cbp has this linker option:
Code
<Add option="-m64" />
but it is a 32-bit project.
Fixed rev 13031. Thanks

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2507
Re: Code completion using LSP and clangd
« Reply #258 on: November 14, 2022, 06:58:10 pm »
Conversely, clangd_client_wx32.cbp is missing although CodeBlocks_wx32.workspace includes it (ticket #1327).
Fixed rev 13031. Thanks

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1203
Re: Code completion using LSP and clangd
« Reply #259 on: November 14, 2022, 07:12:12 pm »
Thank you for the fix. The new clangd_client_wx32.cbp has some issues:

<Add option="-m64" /> and <Add option="-D_WIN64" /> in compiler options.

References to devel32_64 and .objs32_64

Global variables use #WX32_64

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1203
Re: Code completion using LSP and clangd
« Reply #260 on: November 14, 2022, 07:46:55 pm »
[r12032] fixed most issues, but this compiler options are still invalid for a 32-bit project.
Code
<Add option="-m64" />
<Add option="-D_WIN64" />

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2507
Re: Code completion using LSP and clangd
« Reply #261 on: November 14, 2022, 09:08:37 pm »
[r12032] fixed most issues, but this compiler options are still invalid for a 32-bit project.
Code
<Add option="-m64" />
<Add option="-D_WIN64" />

Thanks, fixed in rev 13033

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1203
Re: Code completion using LSP and clangd
« Reply #262 on: November 15, 2022, 12:09:48 pm »
*.depend and *.layout files should be added to svn:ignore

The MSW project creates a clangd_client.zip file in the project folder; If this is OK, it should be added also to svn:ignore

The unix_30 project creates .obj30 and devel30 under the project folder, is this OK?.

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2507
Re: Code completion using LSP and clangd
« Reply #263 on: November 15, 2022, 07:16:00 pm »
*.depend and *.layout files should be added to svn:ignore

The MSW project creates a clangd_client.zip file in the project folder; If this is OK, it should be added also to svn:ignore

The unix_30 project creates .obj30 and devel30 under the project folder, is this OK?.

Fixed in commit CB rev 13035
.depend was already in the ignore list.
Added .layout to ignore list.
Added clangd_client.zip to the ignore list
Made corrections to clangd_client_wx30.cbp

Thanks

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1203
Re: Code completion using LSP and clangd
« Reply #264 on: November 16, 2022, 11:45:10 am »
The .depend is still "active", after compiling the plugin:
Code
c:\Codeblocks>svn status
X       src\plugins\contrib\FortranProject
X       src\plugins\contrib\PythonPlugins
?       src\plugins\contrib\clangd_client\clangd_client_wx32.depend

c:\Codeblocks\src\plugins\contrib\clangd_client>svn proplist -v
Properties on '.':
  svn:ignore
    *.layout
    clangd_client.zip
so *.depends is missing. Other folders (p.e. src/src) add also *_build_log.html, because saving build log to HTML leaves this files around.

IMHO the ignore list should be:
Code
Properties on '.':
  svn:ignore
    *.depend
    *.layout
    *_build_log.html
    clangd_client.zip

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2507
Re: Code completion using LSP and clangd
« Reply #265 on: November 16, 2022, 09:37:36 pm »
The .depend is still "active", after compiling the plugin:
Code
c:\Codeblocks>svn status
X       src\plugins\contrib\FortranProject
X       src\plugins\contrib\PythonPlugins
?       src\plugins\contrib\clangd_client\clangd_client_wx32.depend

c:\Codeblocks\src\plugins\contrib\clangd_client>svn proplist -v
Properties on '.':
  svn:ignore
    *.layout
    clangd_client.zip
so *.depends is missing. Other folders (p.e. src/src) add also *_build_log.html, because saving build log to HTML leaves this files around.

IMHO the ignore list should be:
Code
Properties on '.':
  svn:ignore
    *.depend
    *.layout
    *_build_log.html
    clangd_client.zip

Please go ahead and change them as you see fit.
I've read "svn propset -h" three times now, and I still can't figure out how to set ignores.

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1203
Re: Code completion using LSP and clangd
« Reply #266 on: November 17, 2022, 07:46:57 am »
Quote
Please go ahead and change them as you see fit.
Done. Just go to the plugin directory and write:
Code
svn propedit svn:ignore .

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2507
Re: Code completion using LSP and clangd
« Reply #267 on: November 17, 2022, 10:14:53 pm »
Quote
Please go ahead and change them as you see fit.
Done. Just go to the plugin directory and write:
Code
svn propedit svn:ignore .

The result of this is:
Code
F:\usr\Proj\cbHead\trunk\src\plugins>svn propedit svn:ignore .
svn: E205007: None of the environment variables SVN_EDITOR, VISUAL or EDITOR are set, and no 'editor-cmd' run-time configuration option was found
It wants me to set some editor like:
Code
set SVN_EDITOR=notepad.exe

Then, running the svn command brings up notepad with the svn:ignore file settings.

I suppose I'm suppose to save it. But who knows....

[rant]Some day I hope to trash svn. It trades intuitiveness for utter confusion plus hours and hours to try and understand it.
[/rant]
« Last Edit: November 17, 2022, 10:17:15 pm by Pecan »

Online ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5720
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Code completion using LSP and clangd
« Reply #268 on: November 18, 2022, 05:10:46 am »
....

The code is trying to parse out the ancestor of a class to add to the symbols tree. Clangd has no protocol msg to achieve that, so I was trying to use the old CodeCompletion code to parse it from the source line.

Do you have any steps you can give me to re-create the situation.

Thanks

Code
/// comment

class A
{
    int m_X;
    int m_Y;
};

To reproduce this issue, you can

first put the caret after the line "/// comment", and just continuously hit the Enter key several times.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline sodev

  • Regular
  • ***
  • Posts: 470
Re: Code completion using LSP and clangd
« Reply #269 on: November 18, 2022, 06:38:08 pm »
@Pecan

You are using Windows, you simply don't use cli tools on Windows :P. Install https://tortoisesvn.net/ for your SVN needs.