Skip to content
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

Syntax highlighting in doctest comments? #1535

Open
konn opened this issue Sep 19, 2020 · 5 comments
Open

Syntax highlighting in doctest comments? #1535

konn opened this issue Sep 19, 2020 · 5 comments
Labels
component: lsp status: blocked Not actionable, because blocked by upstream/GHC etc. type: enhancement New feature or request

Comments

@konn
Copy link
Collaborator

konn commented Sep 19, 2020

I've been using the Eval Plugin of HLS, which provides us with a pleasant alternative for REPL.
That plugin provides a way to evaluate (or execute some simple ghci-like commands such as type) codes in doctest style comment: -- >>>.
The result is appended as line comments right after the doctest comments.

In some situation, both of the inputs and outputs of doctest comments can be relatively long.
I think it might be useful if VSCode also highlights the contents inside the doctest comments and comments that immediately follow.

In short: currently, we have the following:

スクリーンショット 2020-09-20 0 15 20

And it might be good if this becomes (with a less bright colour than in the standard code block):

スクリーンショット 2020-09-20 0 15 20-high

If I understand correctly, there is a VSCode API to change text-decorations dynamically.
Or, perhaps this should be resolved upstream, i.e. might be reported to JustusAdam/language-haskell?

@konn
Copy link
Collaborator Author

konn commented Dec 4, 2020

It seems that the upcoming LSP 3.16 specification includes semantic highlighting.
If this is once released and implemented in lsp-types, we will be able to implement this feature upstream; i.e. in HLS, in an editor-agnostic manner (provided that the editor being used supports that spec, of course)!

So, it might be preferrable to close this issue or transfer to HLS once the situation get ready.

@jneira jneira transferred this issue from haskell/vscode-haskell Mar 9, 2021
@jneira
Copy link
Member

jneira commented Mar 9, 2021

this is blocked upstream on semantic highlighting support in lsp (lsp 3.16 spec was released)

@jneira jneira added component: lsp status: blocked Not actionable, because blocked by upstream/GHC etc. type: enhancement New feature or request labels Mar 9, 2021
@michaelpj
Copy link
Collaborator

We have semantic highlighting now. However, I suspect a major problem would be figuring out what the elements in the comment actually are!

@Anrock
Copy link
Contributor

Anrock commented Jan 11, 2024

Haddock has inline code markup, so maybe we can wrap the output in that and let LSP (or even treesitter) do the highlighting. It also should be morally correct since lawful Show should produce correct Haskell expressions.

@soulomoon
Copy link
Collaborator

soulomoon commented Jan 16, 2024

Semantic tokens currently picks identifier(mostly names) from hieAst.
The cheapest way is to figure out how to get the identifiers in the doctest comment into hieast, then highlight would be automatically supported.
The same way as the semantic highlights in the code section of doc is automatically supportted now.

image

Any know where the token of code section of doc is inserted into the hieast ? maybe we can do the same thing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: lsp status: blocked Not actionable, because blocked by upstream/GHC etc. type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants