Comments (15)
This will probably require changes in the indexer so it indexes comments. It may also be possible to do try to find the cursor in an active code completion translation unit and lookup documentation from there.
from cquery.
+1
from cquery.
+1
from cquery.
So, I tried a quick hack to see how far I can get.
It turned out that with only a small change in the indexer.cc you can get pretty far:
src/indexer.cc | 17 ++++++++++-------
The idea is the prepend the documentation comment right before the existing hover text. Almost all of the changes look like:
- var->def.hover = type_name;
+ var->def.hover = decl_cursor.get_comments() + "\n" + type_name;
It works, though the formatting may need to be improved.
One thing, that is kind of annoying, is the fact that only certain kind of comments reported. E.g. /* */
and ///
. But it does not report any //
comments that are often used for local variables, etc. And the reason for this is that ClangCursor::get_comments()
uses clang_Cursor_getRawCommentText
, which does not report this type of comments. The only related discussion I've found is here. It talks about using getRawCommentForDeclNoCache
, but this is a method on ASTContext
which cquery does not seem to use.
Anyone has ideas how to add support for all types of comments? Is it important at all? IMHO, it is useful for local declarations. All functions, methods and types usually use the supported Doxygen-style comments anyways.
from cquery.
Comment support is very useful! I'd like to know how clients will display them.
Emacs lsp-mode curently displays textDocument/hover responses via eldoc-documentation-function
:
With comments spanning a lot of lines, this may need improving.
from cquery.
I'll try to submit a PR later today or tomorrow, so that others can have a look and experiment with it.
And yes, with comments spanning a lot of lines, some additional formatting to make them look nice may be required.
from cquery.
@romix Add a new field for comments instead of prepending/appending them to hover
. Then the behavior can be controlled with some command line option / other knob as clients are not generally ready for the UI challenge..
from cquery.
@MaskRay Yes, that could be a good idea.
from cquery.
Yea, please add a new field instead of prepending to hover.
from cquery.
If it is a new field, where/how do I return it back to the client? With hover it was easy, as it is handled already.
from cquery.
src/messages/text_document_hover.cc:GetHoverForSymbol
but I'm not sure how to access command line option / initializationOptions there
Filed feature requests for some editors.
from cquery.
@MaskRay @jacobdufault I created a PR #183, so that other can try it out, propose improvements, etc.
from cquery.
Created #187, which improves the formatting of comments in hover pop-ups
from cquery.
Updated https://github.com/jacobdufault/cquery/wiki
from cquery.
Hover
reports documentation with cquery --enable-comments --language-server
See #187 for discussion.
from cquery.
Related Issues (20)
- Failed normalize path
- Is this project dead? HOT 17
- unterminated conditional directive
- build err on windows 10 HOT 1
- cquery build issue with CMAKE_INSTALL_PREFIX option HOT 1
- [Question] Is there any solution that cquery can work with makefile? HOT 2
- Allow multiple compile_commands.json HOT 1
- [LC] sending on a disconnected channel
- Could cquery listen on a port?
- Delete previously removed/currently broken wiki page
- Suggestion: apt repository
- Suggestion: cquery cannot parse `includePath` with space
- Why does cquery build download clang 7 when it is already installed? HOT 1
- Install on RPi tries to download and run x86_64 clang HOT 2
- build failed in mac 10.14.6
- Failed to parse --init as JSON: Missing a name for object member. (1) HOT 1
- Suggesting alternative projects due to development inactivity
- Two folders in the cache directory for the same project root
- Checksums fail on Fedora 30 HOT 1
- Demo link on readme page is not working
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cquery.