-
Notifications
You must be signed in to change notification settings - Fork 93
Add MarkupContent to HoverResponse #148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
3a28088
WIP
alanz 7f1e0d1
Merge branch 'master' into hover-reply
alanz d40c3e7
Add MarkupContent to HoverResponse
alanz 9da98fd
Add Semigroup instance for MarkupContent
alanz 78309b5
Bump version to 0.9.0.0, HoverContents is an API change
alanz 98469ce
Fix Semigroup backward compatiblity
alanz 5b68861
Trying again
alanz 9b1352d
Clean up HoverContents JSON instance slightly
alanz 7c5f4ee
Remove warning
alanz 55196c1
Update ChangeLog.md
lukel97 3004608
Introduce sectionSeparator for use in clients
alanz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ module Language.Haskell.LSP.Types.MarkupContent where | |
|
||
import Data.Aeson | ||
import Data.Aeson.TH | ||
import Data.Semigroup | ||
import Data.Text (Text) | ||
import Language.Haskell.LSP.Types.Constants | ||
|
||
|
@@ -23,15 +24,15 @@ import Language.Haskell.LSP.Types.Constants | |
* are reserved for internal usage. | ||
*/ | ||
export namespace MarkupKind { | ||
/** | ||
* Plain text is supported as a content format | ||
*/ | ||
export const PlainText: 'plaintext' = 'plaintext'; | ||
|
||
/** | ||
* Markdown is supported as a content format | ||
*/ | ||
export const Markdown: 'markdown' = 'markdown'; | ||
/** | ||
* Plain text is supported as a content format | ||
*/ | ||
export const PlainText: 'plaintext' = 'plaintext'; | ||
|
||
/** | ||
* Markdown is supported as a content format | ||
*/ | ||
export const Markdown: 'markdown' = 'markdown'; | ||
} | ||
export type MarkupKind = 'plaintext' | 'markdown'; | ||
-} | ||
|
@@ -78,15 +79,15 @@ instance FromJSON MarkupKind where | |
* remove HTML from the markdown to avoid script execution. | ||
*/ | ||
export interface MarkupContent { | ||
/** | ||
* The type of the Markup | ||
*/ | ||
kind: MarkupKind; | ||
|
||
/** | ||
* The content itself | ||
*/ | ||
value: string; | ||
/** | ||
* The type of the Markup | ||
*/ | ||
kind: MarkupKind; | ||
|
||
/** | ||
* The content itself | ||
*/ | ||
value: string; | ||
} | ||
-} | ||
|
||
|
@@ -120,3 +121,25 @@ data MarkupContent = | |
deriving (Read, Show, Eq) | ||
|
||
deriveJSON lspOptions ''MarkupContent | ||
|
||
-- --------------------------------------------------------------------- | ||
|
||
-- | Create a 'MarkupContent' containing a quoted language string only. | ||
markedUpContent :: Text -> Text -> MarkupContent | ||
markedUpContent lang quote | ||
= MarkupContent MkMarkdown ("```" <> lang <> "\n" <> quote <> "\n```\n") | ||
|
||
-- --------------------------------------------------------------------- | ||
|
||
-- | Create a 'MarkupContent' containing unquoted text | ||
unmarkedUpContent :: Text -> MarkupContent | ||
unmarkedUpContent str = MarkupContent MkPlainText str | ||
|
||
-- --------------------------------------------------------------------- | ||
|
||
instance Semigroup MarkupContent where | ||
MarkupContent MkPlainText s1 <> MarkupContent MkPlainText s2 = MarkupContent MkPlainText (s1 <> s2) | ||
MarkupContent MkMarkdown s1 <> MarkupContent _ s2 = MarkupContent MkMarkdown (s1 <> s2) | ||
MarkupContent _ s1 <> MarkupContent MkMarkdown s2 = MarkupContent MkMarkdown (s1 <> s2) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice touch 😃 |
||
|
||
-- --------------------------------------------------------------------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.