eranif / codelite

A multi purpose IDE specialized in C/C++/Rust/Python/PHP and Node.js. Written in C++
https://codelite.org
GNU General Public License v2.0
2.08k stars 444 forks source link

Code Completion Not Appearing (Codelite 1.16.0) #3030

Closed python3xdev closed 2 years ago

python3xdev commented 2 years ago

Code Completion not working. I have reinstalled, reset my codelite IDE and re-ran the setup wizard, nothing helps. Here is a screenshot of my Workspace Settings > Code Completion and of Plugins > Language Server > Settings > clangd/ctagsd :

image

image

image

eranif commented 2 years ago

Do you have little red arrows from clangd (in the editor margin view)?

python3xdev commented 2 years ago

He is what is looks like after doing that:

image

eranif commented 2 years ago

where is the build output?

python3xdev commented 2 years ago

image

eranif commented 2 years ago
python3xdev commented 2 years ago

1) Yes, the compile_commands.json is there. 3) I checked my antivirus and nothing is quarantined or blocked. (I use AVG) And its running in Task Manager:

image

2)

[01:42:23:839 SYS] [Main] Restarting CodeLite: C:\Program Files\CodeLite\codelite.exe
[01:43:28:342 SYS] [Main] Found template project: C:\Program Files\CodeLite\templates\projects\CMake_Executable\CMake_Executable.project . CMake Executable
[01:43:28:346 SYS] [Main] Found template project: C:\Program Files\CodeLite\templates\projects\cobra-executableU\cobra-executableU.project . cobra-executable
[01:43:28:349 SYS] [Main] Found template project: C:\Program Files\CodeLite\templates\projects\cobra-libraryU\cobra-library.project . cobra-library
[01:43:28:352 SYS] [Main] Found template project: C:\Program Files\CodeLite\templates\projects\cobra-staticU\cobra-staticU.project . cobra-embedded-RT
[01:43:28:355 SYS] [Main] Found template project: C:\Program Files\CodeLite\templates\projects\ConsoleClang\ConsoleClang.project . Simple executable (clang)
[01:43:28:360 SYS] [Main] Found template project: C:\Program Files\CodeLite\templates\projects\ConsoleClang++\ConsoleClang++.project . Simple executable (clang++)
[01:43:28:363 SYS] [Main] Found template project: C:\Program Files\CodeLite\templates\projects\cpp_gtkmm24_template\cpp_gtkmm24_template.project . Executable GUI GTKMM 2.4/C++
[01:43:28:367 SYS] [Main] Found template project: C:\Program Files\CodeLite\templates\projects\cpp_gtkmm3_template\cpp_gtkmm3_template.project . Executable GUI GTKMM 3.0/C++
[01:43:28:370 SYS] [Main] Found template project: C:\Program Files\CodeLite\templates\projects\custom-makefile\custom-makefile.project . Custom Makefile
[01:43:28:374 SYS] [Main] Found template project: C:\Program Files\CodeLite\templates\projects\c_gtk24_template\c_gtk24_template.project . Executable GUI GTK 2.4/C
[01:43:28:378 SYS] [Main] Found template project: C:\Program Files\CodeLite\templates\projects\c_gtk3_template\c_gtk3_template.project . Executable GUI GTK 3.0/C
[01:43:28:397 SYS] [Main] Found template project: C:\Program Files\CodeLite\templates\projects\executable\executable.project . Simple executable (g++)
[01:43:28:400 SYS] [Main] Found template project: C:\Program Files\CodeLite\templates\projects\executable-cobra\executable-cobra.project . Simple executable (Cobra)
[01:43:28:403 SYS] [Main] Found template project: C:\Program Files\CodeLite\templates\projects\executable-console-wx-enabled\executable-console-wx-enabled.project . Simple executable (wxWidgets enabled)
[01:43:28:407 SYS] [Main] Found template project: C:\Program Files\CodeLite\templates\projects\executable-gcc\executable-gcc.project . Simple executable (gcc)
[01:43:28:411 SYS] [Main] Found template project: C:\Program Files\CodeLite\templates\projects\executable-qt-enabled\executable-qt-enabled.project . Executable (Qt enabled)
[01:43:28:415 SYS] [Main] Found template project: C:\Program Files\CodeLite\templates\projects\executable-qt-qmake-enabled\executable-qt-qmake-enabled.project . Executable (Qt with qmake enabled)
[01:43:28:419 SYS] [Main] Found template project: C:\Program Files\CodeLite\templates\projects\executable-wx-dialog\executable-wx-dialog.project . Executable (wxWidgets + wxFB dialog)
[01:43:28:423 SYS] [Main] Found template project: C:\Program Files\CodeLite\templates\projects\executable-wx-enabled\executable-wx-enabled.project . Executable (wxWidgets enabled)
[01:43:28:427 SYS] [Main] Found template project: C:\Program Files\CodeLite\templates\projects\executable-wx-frame\executable-wx-frame.project . Executable (wxWidgets + wxFB frame)
[01:43:28:431 SYS] [Main] Found template project: C:\Program Files\CodeLite\templates\projects\executable-wx-xrc\executable-wx-xrc.project . Executable (wxWidgets + XRC frame)
[01:43:28:435 SYS] [Main] Found template project: C:\Program Files\CodeLite\templates\projects\executable-wxcrafter-dialog\wxCrafter_MainDialog.project . wxWidgets GUI Application (wxDialog, using wxCrafter)
[01:43:28:439 SYS] [Main] Found template project: C:\Program Files\CodeLite\templates\projects\executable-wxcrafter-frame\wxCrafter_MainFrame.project . wxWidgets GUI Application (wxFrame, using wxCrafter)
[01:43:28:443 SYS] [Main] Found template project: C:\Program Files\CodeLite\templates\projects\non-code-project\non-code.project . Non-code project
[01:43:28:447 SYS] [Main] Found template project: C:\Program Files\CodeLite\templates\projects\static-library\static-library.project . Static library
[01:43:28:450 SYS] [Main] Found template project: C:\Program Files\CodeLite\templates\projects\static-library-wx-enabled\static-library-wx-enabled.project . Static library (wxWidgets enabled)
[01:43:28:454 SYS] [Main] Found template project: C:\Program Files\CodeLite\templates\projects\UnitTest++\UnitTest++.project . UnitTest++
[01:43:28:458 SYS] [Main] Found template project: C:\Program Files\CodeLite\templates\projects\vc-dynamic-library\vc-dynamic-library.project . Dynamic library (MSVC)
[01:43:28:462 SYS] [Main] Found template project: C:\Program Files\CodeLite\templates\projects\vc-executable\vc-executable.project . Simple executable (MSVC)
[01:43:28:466 SYS] [Main] Found template project: C:\Program Files\CodeLite\templates\projects\vc-static-lib\vc-static-lib.project . Static library (MSVC)
[01:43:28:469 SYS] [Main] Found template project: C:\Program Files\CodeLite\templates\projects\wxWidgets_ConsoleApp\wxWidgets_ConsoleApp.project . wxWidgets Console Application (with wxEvent loop)
[01:43:28:473 SYS] [Main] Found template project: C:\Program Files\CodeLite\templates\projects\Dynamic Library.project . Dynamic Library
[01:43:28:476 SYS] [Main] Found template project: C:\Program Files\CodeLite\templates\projects\Executable.project . Executable
[01:43:28:480 SYS] [Main] Found template project: C:\Program Files\CodeLite\templates\projects\Static Library.project . Static Library
[14:16:47:534 SYS] [Main] Log verbosity is now set to: Debug
[14:17:52:279 DBG] [Main] [clangd] Sending semantic tokens request...
[14:17:52:280 DBG] [Main] [clangd] Success
[14:17:52:282 DBG] [Main] [clangd] Sending document symbols request..
[14:17:52:283 DBG] [Main] [clangd] Success
[14:17:52:300 DBG] [Main] Received data from LSP: 190 bytes
[14:17:52:301 DBG] [Main] [clangd] received an error message: {"error":{"code":-32001,"message":"invalid AST"},"id":55,"jsonrpc":"2.0"}
[14:17:52:302 DBG] [Main] [clangd] received an error message: {"error":{"code":-32001,"message":"invalid AST"},"id":56,"jsonrpc":"2.0"}
[14:18:00:113 DBG] [Main] Generating Makefile...

[14:18:00:120 DBG] [Main] Generating Makefile...is completed

[14:18:00:654 DBG] [Main] Active compiler is set to: MinGW ( C:\Program Files\mingw-w64\bin\ )
[14:18:00:658 DBG] [Main] Build started
[14:18:03:333 DBG] [Main] Command to execute: D:\---my-path---\Section4\Project1\Debug\Project1.exe
[14:18:03:334 DBG] [Main] Working directory: D:\---my-path---\Section4\Project1
[14:18:03:338 DBG] [Main] Command to execute: D:\---my-path---\Section4\Project1\Debug\Project1.exe
[14:18:03:339 DBG] [Main] Working directory: D:\---my-path---\Section4\Project1
[14:18:03:361 DBG] [Main] Run started
[14:18:03:451 DBG] [Main] Build ended
[14:18:03:453 DBG] [Main] Executing: "C:\Program Files\CodeLite\codelite-make.exe" --workspace=D:\---my-path---\Section4\Section4.workspace --compile-flags  --config=Debug --settings=C:\Users\User\AppData\Roaming\codelite\config\build_settings.xml
[14:18:04:093 DBG] Checking paths for changes: [D:\---my-path---\Section4\Project1\compile_flags.txt]
[14:18:04:097 DBG] New checksum is: [ 3096447244259353C7EE0D662AFD64A7 ]
[14:18:04:100 DBG] Old checksum is: [ 3096447244259353C7EE0D662AFD64A7 ]
[14:18:04:102 DBG] File: D:\---my-path---\Section4\Project1\compile_flags.txt exists: 1
[14:18:04:104 DBG] No changes detected for paths: [D:\---my-path---\Section4\Project1\compile_flags.txt]
[14:18:08:116 DBG] [Main] Run ended
python3xdev commented 2 years ago

I just started typing #include <ios & this happened

[14:21:37:421 DBG] [Main] Checking line: 
 for #include statement...
[14:21:37:556 DBG] [Main] Checking line: 
 for #include statement...
[14:21:39:052 DBG] [Main] Checking line: 
 for #include statement...
[14:21:39:244 DBG] [Main] Checking line: 
 for #include statement...
[14:21:39:391 DBG] [Main] Checking line: 
 for #include statement...
[14:21:39:618 DBG] [Main] Checking line: 
 for #include statement...
[14:21:39:690 DBG] [Main] Checking line: 
 for #include statement...
[14:21:39:883 DBG] [Main] Checking line: 
 for #include statement...
[14:21:39:938 DBG] [Main] Checking line: 
 for #include statement...
[14:21:43:787 DBG] [Main] Checking line: 
 for #include statement...
[14:21:43:955 DBG] [Main] Checking line: 
 for #include statement...
[14:21:44:115 DBG] [Main] Checking line: 
 for #include statement...
[14:21:46:756 DBG] [Main] Checking line: 
 for #include statement...
[14:21:46:907 DBG] [Main] Checking line: 
 for #include statement...
[14:21:47:844 DBG] [Main] Checking line: 
 for #include statement...
[14:21:48:092 DBG] [Main] Checking line: 
 for #include statement...
[14:21:48:251 DBG] [Main] Checking line: 
 for #include statement...
[14:21:48:479 DBG] [Main] Checking line: 
 for #include statement...
[14:21:48:583 DBG] [Main] Checking line: 
 for #include statement...
[14:21:49:966 DBG] [Main] Checking line: 
 for #include statement...
[14:21:50:124 DBG] [Main] Checking line: 
 for #include statement...
[14:21:50:291 DBG] [Main] Checking line: 
 for #include statement...
[14:21:50:427 DBG] [Main] Checking line: 
 for #include statement...
[14:28:09:519 DBG] [Main] [clangd] Sending semantic tokens request...
[14:28:09:521 DBG] [Main] [clangd] Success
[14:28:09:522 DBG] [Main] [clangd] Sending document symbols request..
[14:28:09:524 DBG] [Main] [clangd] Success
[14:28:09:544 DBG] [Main] [clangd] Sending semantic tokens request...
[14:28:09:546 DBG] [Main] [clangd] Success
[14:28:09:547 DBG] [Main] [clangd] Sending document symbols request..
[14:28:09:548 DBG] [Main] [clangd] Success
[14:28:09:552 DBG] [Main] Received data from LSP: 190 bytes
[14:28:09:553 DBG] [Main] [clangd] received an error message: {"error":{"code":-32001,"message":"invalid AST"},"id":57,"jsonrpc":"2.0"}
[14:28:09:554 DBG] [Main] [clangd] received an error message: {"error":{"code":-32001,"message":"invalid AST"},"id":58,"jsonrpc":"2.0"}
[14:28:09:564 DBG] [Main] Received data from LSP: 190 bytes
[14:28:09:565 DBG] [Main] [clangd] received an error message: {"error":{"code":-32001,"message":"invalid AST"},"id":59,"jsonrpc":"2.0"}
[14:28:09:567 DBG] [Main] [clangd] received an error message: {"error":{"code":-32001,"message":"invalid AST"},"id":60,"jsonrpc":"2.0"}
[14:28:11:991 DBG] [Main] Console: running command: ` cmd `
[14:28:15:646 DBG] [Main] Console: running command: ` cmd `
python3xdev commented 2 years ago

The IDE has been sitting idle for quite a while now and the file has been populated with more logs. should this happen? (440 lines ) Here is some of the latest ones at the bottom:

[15:26:04:571 DBG] [Main] Checking line: 
 for #include statement...
[16:34:38:767 DBG] [Main] [clangd] Sending ChangeRequest
[16:34:39:110 DBG] [Main] Received data from LSP: 206 bytes
[16:35:32:487 DBG] [Main] [clangd] Sending semantic tokens request...
[16:35:32:489 DBG] [Main] [clangd] Success
[16:35:32:490 DBG] [Main] [clangd] Sending document symbols request..
[16:35:32:491 DBG] [Main] [clangd] Success
[16:35:32:509 DBG] [Main] Received data from LSP: 188 bytes
[16:35:32:510 DBG] [Main] [clangd] received an error message: {"error":{"code":-32001,"message":"invalid AST"},"id":7,"jsonrpc":"2.0"}
[16:35:32:512 DBG] [Main] [clangd] received an error message: {"error":{"code":-32001,"message":"invalid AST"},"id":8,"jsonrpc":"2.0"}
eranif commented 2 years ago

looks like a problem with clangd You can download a different one from the internet and configure it? https://github.com/llvm/llvm-project/releases/tag/llvmorg-14.0.0

Pick the windows one and install it. Once installed change the command line from:

plugins -> language server -> settings -> clangd

python3xdev commented 2 years ago

Here is the updated path to the new clangd exe

image

This is what I'm supposed to do, correct? I think I entered the correct path. After clicking Ok and testing it, I still get the following errors:

[22:37:33:439 DBG] [Main] Checking line: 
 for #include statement...
[22:37:34:217 DBG] [Main] [clangd] Sending ChangeRequest
[22:37:34:219 DBG] [Main] [clangd] Sending semantic tokens request...
[22:37:34:220 DBG] [Main] [clangd] Success
[22:37:34:221 DBG] [Main] [clangd] Sending document symbols request..
[22:37:34:223 DBG] [Main] [clangd] Success
[22:37:34:784 DBG] [Main] Received data from LSP: 397 bytes
[22:37:34:785 DBG] [Main] [clangd] received an error message: {"error":{"code":-32001,"message":"invalid AST"},"id":36,"jsonrpc":"2.0"}
[22:37:34:787 DBG] [Main] [clangd] received an error message: {"error":{"code":-32001,"message":"invalid AST"},"id":37,"jsonrpc":"2.0"}
[22:37:54:488 DBG] [Main] [clangd] Sending semantic tokens request...
[22:37:54:490 DBG] [Main] [clangd] Success
[22:37:54:491 DBG] [Main] [clangd] Sending document symbols request..
[22:37:54:492 DBG] [Main] [clangd] Success
[22:37:54:516 DBG] [Main] Received data from LSP: 190 bytes
[22:37:54:518 DBG] [Main] [clangd] received an error message: {"error":{"code":-32001,"message":"invalid AST"},"id":38,"jsonrpc":"2.0"}
[22:37:54:519 DBG] [Main] [clangd] received an error message: {"error":{"code":-32001,"message":"invalid AST"},"id":39,"jsonrpc":"2.0"}
eranif commented 2 years ago

iirc, clangd creates a cache folder in a folder called .cache/clangd under your workspace folder, what happens if you delete it? (close codelite, delete the folder and try it again)

and no, this is not what is supposed to happen... this message is an error:

received an error message: {"error":{"code":-32001,"message":"invalid AST"},"id":38,"jsonrpc":"2.0"}
eranif commented 2 years ago

If this does not work:

python3xdev commented 2 years ago

Nothing worked. I looked through the log file and found these lines, are they of any use?:

[22:50:18:605 DBG] [Main] OpenEditor: server is still not initialized. server: clangd , file: C:\Users\User\AppData\Roaming\codelite\codelite.log
[22:50:18:606 DBG] [Main] OpenEditor: server is still not initialized. server: clangd , file: C:\Users\User\AppData\Roaming\codelite\codelite.log
[22:50:18:608 DBG] [Main] OpenEditor: server is still not initialized. server: clangd , file: C:\Users\User\AppData\Roaming\codelite\codelite.log

Some other stuff that just keeps repeating:

[22:50:19:013 DBG] [Main] [clangd] Starting...
[22:50:19:014 DBG] [Main] [clangd] Command: [C:\Program Files\LLVM\bin\clangd.exe, -limit-results=500, -header-insertion-decorators=0]
[22:50:19:015 DBG] [Main] [clangd] Root folder: D:\School\Udemy\2_Beginning_CPP_Frank_M\Section4
[22:50:19:016 DBG] [Main] [clangd] Language: cpp
[22:50:19:016 DBG] [Main] [clangd] Language: c
[22:50:19:029 DBG] [Main] LSP clangd is already running
[22:50:19:030 DBG] [Main] LSP: Success
[22:50:19:040 DBG] [Main] [clangd] Sending initialize request...
[22:50:19:157 DBG] [Main] Received data from LSP: 1861 bytes
[22:50:19:158 DBG] [Main] [clangd] Server semantic tokens are: [variable, variable, parameter, function, method, function, property, variable, class, interface, enum, enumMember, type, type, unknown, namespace, typeParameter, concept, type, macro, comment]
[22:50:19:159 DBG] [Main] [clangd] Sending InitializedNotification
[22:50:19:160 DBG] [Main] [clangd] initialization completed
[22:51:57:663 DBG] [Main] [clangd] Sending semantic tokens request...
[22:51:57:665 DBG] [Main] [clangd] Success
[22:51:57:666 DBG] [Main] [clangd] Sending document symbols request..
[22:51:57:667 DBG] [Main] [clangd] Success
[22:51:57:723 DBG] [Main] [clangd] Sending semantic tokens request...
[22:51:57:724 DBG] [Main] [clangd] Success
[22:51:57:726 DBG] [Main] [clangd] Sending document symbols request..
[22:51:57:727 DBG] [Main] [clangd] Success
[22:51:57:744 DBG] [Main] Received data from LSP: 193 bytes
[22:51:57:974 DBG] [Main] Received data from LSP: 582 bytes
[22:51:57:975 DBG] [Main] [clangd] received an error message: {"error":{"code":-32001,"message":"invalid AST"},"id":3,"jsonrpc":"2.0"}
[22:51:57:976 DBG] [Main] [clangd] received an error message: {"error":{"code":-32001,"message":"invalid AST"},"id":4,"jsonrpc":"2.0"}
[22:51:57:977 DBG] [Main] [clangd] received an error message: {"error":{"code":-32001,"message":"invalid AST"},"id":5,"jsonrpc":"2.0"}
[22:51:57:978 DBG] [Main] [clangd] received an error message: {"error":{"code":-32001,"message":"invalid AST"},"id":6,"jsonrpc":"2.0"}
[22:52:00:171 DBG] [Main] Checking line: 
 for #include statement...
eranif commented 2 years ago

Terminate clangd, switch to ctagsd.

ctagsd log is located under %appdata%\ctagsd\ctagsd.log

To set ctagsd debug level:

plugins -> language server -> settings -> ctagsd change the command line from ... --log-level ERR -> ... --log-level DBG

then parse the workspace: main menu bar: workspace -> parse workspace

python3xdev commented 2 years ago

What you told me to do with ctagsd made Code Completion work, so I tried doing the same to the Codelite clangd:

I killed the clangd task in Task Manager and changed the Command Line back to the default C:\Program Files\CodeLite\lsp\clangd.exe. Then I Parsed the Workspace. Now its working, all the settings are the same though. Maybe restarting the clangd task fixed it?

Is the Code Completion supposed to auto complete things like #include <iostream> & return 0;, because its not working with these. (both ways, same results)

eranif commented 2 years ago

Whenever you change a settings in the language server dialog, it is supposed to restart the process. Maybe this was the problem and it failed to restart it...

can you run a small test?

If the PID is the same, then this was the problem: CodeLite failed to terminate this process

python3xdev commented 2 years ago

The clangd.exe had PID 11492 then after the changes it was 14160.

eranif commented 2 years ago

thanks, i think we can close the discussion - it works now

about your question:

#include // << CC is supposed to show here list of known files to the parser
python3xdev commented 2 years ago

When I type #include ios nothing shows. Do I need to manually update it somehow? Also, shouldn't return be suggested by the CC without any problems? I type retu, and nothing.

Also I set Settings > Code Completion > Minimum chars to type to 1

eranif commented 2 years ago

it should suggest keywords as well check under settings -> code completion

and adjust the number of chars to type to show code completion also, does Ctrl-SPACE helps?

python3xdev commented 2 years ago

CC:

image

Ctrl + Space works on everything else except #include and return.

python3xdev commented 2 years ago

I guess this is not so important, so this issue can be closed. I am going to open another issue right now about text color scheme.

Edit: I changed back to Error from Debug in Settings > Preferences > Misc > Log and this made the #include and returnCC work. I have no idea why that fixed it, but it did.