diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-09-29 13:10:47 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-09-29 13:10:47 +0100 |
commit | e813de6cdd53e542bce8d4a554288dc2f17bbf5e (patch) | |
tree | 633e533ce5aa3c10337bafc240e1f4911e4ecb65 /crates/syntax/src/ast/expr_ext.rs | |
parent | 18c62c8a39d95ce3bb10ff5446bb589b1128a090 (diff) | |
parent | e73ee9dfa28e2c093cc79e0e8d729945c43f3c81 (diff) |
Merge #6080
6080: Add hover config `linksInHover` to suppress links r=flw-cn a=flw-cn
This PR solves the problem of using RA under vim8. It should close #6014.
Since vim8's popup-window doesn't capture focus, the URL given by RA is effectively useless. links are neither displayed correctly nor can they be clicked. This makes the hover window ugly and inefficient.
I'm providing this patch so that people who share my confusion (which I'm almost certain vim8 users do) will have a way to remove links from markdown.
I noticed that [gopls has an option](https://github.com/golang/tools/blob/master/gopls/doc/settings.md#linksinhover-bool) for a similar purpose. So I added an option `linksInHover` to enable this behavior. This is a bool value and defaults to `true` to keep the behavior consistent with the master version. But you can suppress the links in the hover text by setting it to `false`.
The name of my option, `linksInHover`, is borrowed from gopls.
Before applying this patch:
<img width="1280" alt="image" src="https://user-images.githubusercontent.com/5546718/93285021-85698a00-f806-11ea-911d-e77fea4a47f0.png">
After applying this patch(with `"rust-analyzer.hoverActions.linksInHover": false,`):
<img width="1280" alt="image" src="https://user-images.githubusercontent.com/5546718/94332256-2e359780-0006-11eb-9724-1aed14130d0d.png">
This is the full test cases:
```
fn main() {
let args: Vec<String> = std::env::args().collect();
test();
println!("args: {:?}", args);
}
/// Test cases:
/// case 1. bare URL: https://rust-lang.org/
/// case 2. inline URL with title: [foo](https://rust-lang.org/)
/// case 3. code refrence: [`Result`]
/// case 4. code refrence but miss footnote: [`String`]
/// case 5. autolink: <http://rust-lang.org/>
/// case 6. email address: <[email protected]>
/// case 7. refrence: [bing][google]
/// case 8. collapsed link: [bing][]
/// case 9. shortcut link: [bing]
/// case 10. inline without URL: [bing]()
/// case 11. refrence: [foo][foo]
/// case 12. refrence: [foo][bar]
/// case 13. collapsed link: [foo][]
/// case 14. shortcut link: [foo]
/// case 15. inline without URL: [foo]()
/// case 16. just escaped text: \[hello]
/// case 17. inline link: [Foo](foo::Foo)
///
/// [`Result`]: ../../std/result/enum.Result.html
/// [^bing]: https://www.bing.com/
/// [^google]: https://www.google.com/
pub fn test() {
println!("Hello");
}
```
screenshot:
<img width="1278" alt="image" src="https://user-images.githubusercontent.com/5546718/94332055-45738580-0004-11eb-9153-707f508d0c4b.png">
Co-authored-by: flw <[email protected]>
Diffstat (limited to 'crates/syntax/src/ast/expr_ext.rs')
0 files changed, 0 insertions, 0 deletions