Skip to content

Commit

Permalink
fix: language server hover/completions are too verbose (#6562)
Browse files Browse the repository at this point in the history
The LSP currently shows a lot of information at once. This can be useful when you want to reference information, but it is way too overwhelming to see it everywhere all the time.
The general goal of this PR was to improve the overwhelming nature of the provided information and fix some other bugs along the way.

- Types are now rendered entirely in a highlighted code block (no more markdown headers for members)
- Typeclasses are limited to showing 6 members at once
- Less depth of information is shown in general
  - This along with some other tweaks fixes #4853
- Typeclass members are sorted by more factors
- members inherited from `constructs.Construct` (and related primitives) are hidden in completions (no more `node` and `toString` showing up everwhere)
- If a typeclass is empty the completion/hover will say so
  - Fixes #5575
- Links in markdown that look like `{@link URL LABEL}` are now rendered as regular markdown links (Common in cdktf provider libs)
- Struct expansion completions are fixed in multiple places
  - Notably, if you start typing a struct field you'll see relevant completions. Previously the completions only showed correctly if you triggered completions with before attempting to type anything. Fixes #4983

## Before (cursor kept in the middle to make it look even worse)

https://github.com/winglang/wing/assets/1237390/c13c6680-ec78-4cb0-a7cc-601dc6462b9e

<img width="761" alt="image" src="https://github.com/winglang/wing/assets/1237390/cd622055-7aa2-4433-8fbc-097ecce1f28b">


## After

https://github.com/winglang/wing/assets/1237390/befca5be-18fd-4111-8e9b-2fd1cf6e1f34

<img width="1079" alt="image" src="https://github.com/winglang/wing/assets/1237390/1aaee0e9-82f4-4b68-8429-bfb432613336">

<img width="1098" alt="image" src="https://github.com/winglang/wing/assets/1237390/3093585f-d316-4222-a2d6-4d60b86d056f">
  • Loading branch information
MarkMcCulloh authored May 26, 2024
1 parent a9b20a0 commit 1018284
Show file tree
Hide file tree
Showing 89 changed files with 1,196 additions and 1,050 deletions.
4 changes: 4 additions & 0 deletions libs/wingc/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,10 @@ impl Display for IntrinsicKind {
}

impl Documented for IntrinsicKind {
fn docs(&self) -> Option<&crate::docs::Docs> {
None
}

fn render_docs(&self) -> String {
match self {
IntrinsicKind::Dirname => r#"Get the normalized absolute path of the current source file's directory.
Expand Down
4 changes: 4 additions & 0 deletions libs/wingc/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@ impl WingSpan {
}
}

pub fn byte_size(&self) -> usize {
self.end_offset - self.start_offset
}

/// Checks if this span is the default span. This means the span is covers nothing by ending at (0,0).
pub fn is_default(&self) -> bool {
self.end == WingLocation::default()
Expand Down
Loading

0 comments on commit 1018284

Please sign in to comment.