Home » Developing U++ » U++ Developers corner » clangd
|
|
| Re: clangd [message #57522 is a reply to message #57515] |
Thu, 16 September 2021 18:42   |
Novo
Messages: 1431 Registered: December 2006
|
Ultimate Contributor |
|
|
When I open a project and Core was changed, it takes ~70 sec. to reindex a project (~16 min. of total CPU time).
When there is nothing to reindex, then opening (checking and loading of indexes) a project takes ~10 sec.
Regards,
Novo
[Updated on: Thu, 16 September 2021 19:04] Report message to a moderator
|
|
|
|
| Re: clangd [message #57523 is a reply to message #57522] |
Thu, 16 September 2021 19:02   |
Novo
Messages: 1431 Registered: December 2006
|
Ultimate Contributor |
|
|
Links:
ccls - C/C++/ObjC language server supporting cross references, hierarchies, completion and semantic highlighting
Tree-sitter is a parser generator tool and an incremental parsing library. It can build a concrete syntax tree for a source file and efficiently update the syntax tree as the source file is edited.
NeoVim.
NeoVim plugins:
Navigator - Navigate codes like a breeze. Exploring LSP and Tree-sitter symbols a piece of cake.
completion-nvim - A async completion framework aims to provide completion to neovim's built in LSP written in Lua.
Regards,
Novo
|
|
|
|
|
|
|
|
| Re: clangd [message #57526 is a reply to message #57525] |
Fri, 17 September 2021 00:19   |
Novo
Messages: 1431 Registered: December 2006
|
Ultimate Contributor |
|
|
I checked performance on a non-gui app.
Completely reindex: 5 min. of total CPU time.
Load an already indexed project: 1:30 min. of total CPU time.
This is acceptable on a 8-core (16 threads) cpu.
Basically, this is speed of compilation.
Regards,
Novo
|
|
|
|
| Re: clangd [message #57527 is a reply to message #57526] |
Fri, 17 September 2021 00:20   |
Novo
Messages: 1431 Registered: December 2006
|
Ultimate Contributor |
|
|
Well, this non-gui app uses a lot of complicated templates.
So, compilation speed can be slow.
Regards,
Novo
|
|
|
|
| Re: clangd [message #57528 is a reply to message #57527] |
Fri, 17 September 2021 00:25   |
Novo
Messages: 1431 Registered: December 2006
|
Ultimate Contributor |
|
|
The project itself opens up immediately. Language Server loads info in background asynchronously.
Navigation is disabled till LS finishes its job.
Regards,
Novo
|
|
|
|
| Re: clangd [message #57535 is a reply to message #57528] |
Fri, 17 September 2021 16:15   |
Novo
Messages: 1431 Registered: December 2006
|
Ultimate Contributor |
|
|
You can check performance by yourself.
clangd:
--compile-commands-dir=<string> - Specify a path to look for compile_commands.json. If path is invalid, clangd will look in the current directory and parent paths of each source file
ccls:
--index=<root> - standalone mode: index a project and exit
Do not forget to run "umk -j" to create a compile_commands.json file.
Regards,
Novo
|
|
|
|
|
|
| Re: clangd [message #57537 is a reply to message #57536] |
Fri, 17 September 2021 21:09   |
Novo
Messages: 1431 Registered: December 2006
|
Ultimate Contributor |
|
|
mirek wrote on Fri, 17 September 2021 12:49
Could you do that for theide?
I do not really understand what you mean by that.
Quote:
BTW, that could mean that BLITZ could still work in that context, right?
Mirek
Correct. Everything that can be compiled with Clang can work in this context.
Just instead of real compilation you need to log Clang commands into a compile_commands.json file.
Current implementation of a "-j" option is not using BLITZ. Most likely, I did that because I couldn't figure out how to do that in umk, and after initial version begun to work I switched to another "let's make it work" project.
Regards,
Novo
|
|
|
|
|
|
| Re: clangd [message #57539 is a reply to message #57538] |
Fri, 17 September 2021 23:55   |
Novo
Messages: 1431 Registered: December 2006
|
Ultimate Contributor |
|
|
mirek wrote on Fri, 17 September 2021 16:52Novo wrote on Fri, 17 September 2021 21:09mirek wrote on Fri, 17 September 2021 12:49
Could you do that for theide?
I do not really understand what you mean by that.
Can you test how long it takes to process theide project (complete, like after Core change)?
Mirek
I'll try. Time should be similar to compilation in Debug configuration (optimization is disabled).
Regards,
Novo
|
|
|
|
|
|
|
|
|
|
| Re: clangd [message #57543 is a reply to message #57541] |
Sat, 18 September 2021 00:43   |
Novo
Messages: 1431 Registered: December 2006
|
Ultimate Contributor |
|
|
Clang-based indexers are good when you do not have anything else, but they are very slow and memory-hungry.
Theoretically, they should have an ideal quality, but I often have problems with them, starting with inability to compile code from time to time (actually, quite often).
In case, when Clang fails, I just use regular search in project's folders.
But when it works, it is pretty good
A trick is not to save a file very often to prevent reindexing ...
Regards,
Novo
|
|
|
|
| Re: clangd [message #57544 is a reply to message #57542] |
Sat, 18 September 2021 13:46   |
Novo
Messages: 1431 Registered: December 2006
|
Ultimate Contributor |
|
|
mirek wrote on Fri, 17 September 2021 18:31
Needs BLITZ...
A catch: you have to add all used h-files to compile_commands.json explicitly.
Regards,
Novo
|
|
|
|
|
|
|
|
| Re: clangd [message #57594 is a reply to message #57573] |
Mon, 04 October 2021 21:58   |
Novo
Messages: 1431 Registered: December 2006
|
Ultimate Contributor |
|
|
mirek wrote on Thu, 30 September 2021 02:18Novo wrote on Sat, 18 September 2021 13:46mirek wrote on Fri, 17 September 2021 18:31
Needs BLITZ...
A catch: you have to add all used h-files to compile_commands.json explicitly.
If you send me compile_commands with h-files, I can fix that I think (I mean, add them during compile_commands generation).
Mirek
You can easily generate them by yourself. For example for umk:
In case this doesn't work for you I've attached one generated on my machine.
Regards,
Novo
|
|
|
|
|
|
| Re: clangd [message #57596 is a reply to message #57595] |
Mon, 04 October 2021 23:39   |
Novo
Messages: 1431 Registered: December 2006
|
Ultimate Contributor |
|
|
mirek wrote on Mon, 04 October 2021 17:18Novo wrote on Mon, 04 October 2021 21:58mirek wrote on Thu, 30 September 2021 02:18Novo wrote on Sat, 18 September 2021 13:46mirek wrote on Fri, 17 September 2021 18:31
Needs BLITZ...
A catch: you have to add all used h-files to compile_commands.json explicitly.
If you send me compile_commands with h-files, I can fix that I think (I mean, add them during compile_commands generation).
Mirek
You can easily generate them by yourself. For example for umk:
In case this doesn't work for you I've attached one generated on my machine.
Then I do not understand "have to add explicitely"... 
Mirek
When you compile a cpp-project, you compile only cpp/c files. h-files are compiled implicitly via #include directive.
In case of compile_commands.json you need to add them to compile_commands explicitly.
Basically, you need to "compile" h-files as well.
Regards,
Novo
|
|
|
|
| Re: clangd [message #57597 is a reply to message #57596] |
Tue, 05 October 2021 00:18   |
 |
mirek
Messages: 14290 Registered: November 2005
|
Ultimate Member |
|
|
Novo wrote on Mon, 04 October 2021 23:39mirek wrote on Mon, 04 October 2021 17:18Novo wrote on Mon, 04 October 2021 21:58mirek wrote on Thu, 30 September 2021 02:18Novo wrote on Sat, 18 September 2021 13:46mirek wrote on Fri, 17 September 2021 18:31
Needs BLITZ...
A catch: you have to add all used h-files to compile_commands.json explicitly.
If you send me compile_commands with h-files, I can fix that I think (I mean, add them during compile_commands generation).
Mirek
You can easily generate them by yourself. For example for umk:
In case this doesn't work for you I've attached one generated on my machine.
Then I do not understand "have to add explicitely"... 
Mirek
When you compile a cpp-project, you compile only cpp/c files. h-files are compiled implicitly via #include directive.
In case of compile_commands.json you need to add them to compile_commands explicitly.
Basically, you need to "compile" h-files as well.
So I cannot generate them by umk only, right? I was wondering what you needed to add to make it work...
Mirek
|
|
|
|
| Re: clangd [message #57598 is a reply to message #57597] |
Tue, 05 October 2021 06:24   |
Novo
Messages: 1431 Registered: December 2006
|
Ultimate Contributor |
|
|
Sorry, I do not get your question.
My version of compile_commands.json works. It is not optimal because it doesn't use BLITZ.
Otherwise it is fine. Everything works.
Regards,
Novo
[Updated on: Thu, 14 October 2021 21:54] Report message to a moderator
|
|
|
|
|
|
| Re: clangd [message #57606 is a reply to message #57600] |
Tue, 05 October 2021 17:21   |
Novo
Messages: 1431 Registered: December 2006
|
Ultimate Contributor |
|
|
mirek wrote on Tue, 05 October 2021 03:09Novo wrote on Tue, 05 October 2021 06:24Sorry, I do not get your question.
Is the file you have sent me exactly the same as produced by umk or did you need to edit it to add header files to it?
Mirek
Attached file is 100% automatically generated. I didn't alter it.
Regards,
Novo
|
|
|
|
|
|
| Re: clangd [message #58384 is a reply to message #57574] |
Mon, 16 May 2022 10:38   |
 |
mirek
Messages: 14290 Registered: November 2005
|
Ultimate Member |
|
|
mirek wrote on Thu, 30 September 2021 12:57After thinking about it for a while, I decided that I am not going to add clangd to TheIDE _myself_:
- it is quite a lot of work
- it does not meet my requirements for speed
- most importantly, I believe that people that want this would actually be even happier with Visual Studio Code (or some other "normal" IDE/editor). To integrate U++ with it seems to be much less work that to add clangd to TheIDE.
- U++ semiheuristic parser is work in progress, but it is MUCH faster than "real compiler" and the current architecture is fine in regards of what it can achieve. I believe that adding missing features to it is in the end less work that to integrate clangd. And much more fun too 
That said, if somebody wants to have a try at this, I will be more that happy to watch the progress!
Mirek
OK, I am reconsidering and willing to give clang a try. However, not clangd - clang ast seems pretty reasonable and I think I can do better using blitz and stuff for performance.
That said, if I run clang for anything nontrivial with dump-ast (that dumps ast in human readable form), it takes 20s to generate 400MB file. Meanwhile, emit-ast is fast and creates 40MB of binary file. Has anybody any experience in parsing this binary data or willing to give it a try?
The ideal solution should at max use what is already in win32 release (- I mean, it is ok to use any .dll from clang). I believe libclang-cpp.dll in fact contains whole clang api, so that should be doable.
Mirek
|
|
|
|
|
|
| Re: clangd [message #59217 is a reply to message #59216] |
Sun, 27 November 2022 22:30   |
Novo
Messages: 1431 Registered: December 2006
|
Ultimate Contributor |
|
|
shawnx wrote on Sun, 27 November 2022 12:48I use bear to generate compile_commands.json then launch vim, seems both clangd and vim are working.
There is no need to use bear with U++. umk has an option "-j" to do that.
Example: "umk MyApps {dirname} CLANG -j"
shawnx wrote on Sun, 27 November 2022 12:48would be great if I can do u++ under vscode somehow, or with vim+clangd, are there some tutorials?
vim+clangd/ccls.
Redefine "make" as "umk MyApps {dirname} CLANG -bsu", so regular ":make" will use umk.
nnoremap <silent> <F7> :make<CR>
You could take a look at tpope/vim-projectionist which allows moving of all configuration settings out of vimrc and creation of per project configurations.
ccls seems to work better than clangd.
Attached image shows my vim session.
Regards,
Novo
[Updated on: Sun, 27 November 2022 22:32] Report message to a moderator
|
|
|
|
|
|
| Re: clangd [message #59220 is a reply to message #59219] |
Sun, 27 November 2022 22:59   |
Novo
Messages: 1431 Registered: December 2006
|
Ultimate Contributor |
|
|
I'm glad you like it.
Below is a list of vim plugins I use with language server.
Pack 'm-pilia/vim-ccls', {'type': 'opt'}
" LSC
Pack 'natebosch/vim-lsc', {'type': 'opt'}
" LSP
Pack 'prabirshrestha/asyncomplete.vim', {'type': 'opt'}
Pack 'prabirshrestha/vim-lsp', {'type': 'opt'}
Pack 'jackguo380/vim-lsp-cxx-highlight', {'type': 'opt'}
I use LSC at this time although I have configuration settings for both of them.
Interesting reading: LSP in Vim with the LSC Plugin
Regards,
Novo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Re: clangd [message #59301 is a reply to message #59216] |
Tue, 13 December 2022 01:26  |
Novo
Messages: 1431 Registered: December 2006
|
Ultimate Contributor |
|
|
shawnx wrote on Sun, 27 November 2022 12:48would be great if I can do u++ under vscode somehow, or with vim+clangd, are there some tutorials?
I forgot to mention that you need to create a file ~/.vim/compiler/umk.vim which should contain text below.
source $VIMRUNTIME/compiler/gcc.vim
Regards,
Novo
[Updated on: Tue, 13 December 2022 13:17] Report message to a moderator
|
|
|
|
Goto Forum:
Current Time: Sat Apr 25 12:13:19 GMT+2 2026
Total time taken to generate the page: 0.01628 seconds
|