Comments (7)
There isn't currently, but it's a good idea. Not sure when I'd be likely to get to it though, so if you or anyone else would like to have a try at implementing it let me know and I'll try to provide some guidance
from evcxr.
I have tried to read HOW_IT_WORKS.md
and source code several times before, but by lack of familiarity with rust, the command_context.rs
is still like a magic to me for now. Could you give me path of learning how it works? Before I read the source code, should I know the detail of how rust-analyzer
works?
from evcxr.
Yep, I suspect most of the work would likely be figuring out how to get the information out of rust-analyzer.
The evcxr code that uses rust-analyzer is in rust_analyzer.rs
. Having a look through that is probably worthwhile to see how it's working.
Looking at rust-analyzer, I think the code that shows documentation is in hover/render.rs
There's two options I can see.
- Generate some rust code containing the snippet that's after the
:doc
command, then call Analysis::hover - Query the definition of
MyStruct
using something likeSemantics::resolve_path
then call some other methods to get the docs from the definition.
from evcxr.
Another useful thing to look at would be how completions work. In particular, look at the completions
method in eval_context.rs
. I suspect integration with hover could work in a similar way.
If you have any questions, do ask.
from evcxr.
I write a method hover_info
righter after the mothond completions
of RustAnalyzer
in rust_analyzer.rs
:
And then I try print out to find what can I get from this method in eval_context.rs
, like this:
The input code is this:
But the hover_info
can't get anything, while method completion
works fine. I cann't figure it out, can you give me a clue?
from evcxr.
Maybe use code.user_offset_to_output_offset(offset)
like is done in completions
. If you use that for the start and end of the identifier that you're trying to get the hover for, then hopefully you'll end up with offsets that rust-analyzer will be able to make use of.
Have a look at the completions
method in eval_context.rs
, which calls completions
in rust_analyzer.rs
. The one in eval_context.rs
does stuff like calling self.analyzer.set_source(code.code_string())?;
which is important for making sure you're analyzing the code that the user wrote.
from evcxr.
Just wanted to say, nice work implementing this @baiguoname, it's a neat feature! (PR)
from evcxr.
Related Issues (20)
- how to trigger code auto completion HOT 2
- Can't use tch-rs in Jupyter Hub HOT 3
- Can't use tch-rs in Jupyter Hub (Part 2) HOT 3
- Can't use Burn (MNIST example) HOT 6
- Race condition between idle and iopub messages in `evcxr_jupyter`? HOT 4
- Invalid code generation when no tokio dependency is added HOT 2
- Invalid code generation when using the question mark operator directly after `.await` HOT 1
- Trying to include a local package gives a manifest error HOT 7
- Error: cannot open shared object file: No such file or directory. HOT 10
- How can I reuse a target directory from a workspace? HOT 2
- How to add :cache 500 to my ~/.config/evcxr/init.evcxr HOT 3
- shell command in evcxr jupyter HOT 1
- unresolved import `core::unicode` HOT 10
- evcxr works with atom/pulsar hydrogen HOT 2
- Errors not shown HOT 2
- Cargo patch dependency issue HOT 5
- cannot assign a variable to a const/static variable HOT 1
- Problem converting a Vec to a &[] struct HOT 2
- Tab completion on Vectors not working HOT 1
- Autocomplete for :doc does not work
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 evcxr.