Skip to content

Merge semantic and syntax highlighting#1401

Merged
dzhou121 merged 6 commits intolapce:masterfrom
camc314:cam/dev/combing-highlights
Oct 1, 2022
Merged

Merge semantic and syntax highlighting#1401
dzhou121 merged 6 commits intolapce:masterfrom
camc314:cam/dev/combing-highlights

Conversation

@camc314
Copy link
Copy Markdown
Contributor

@camc314 camc314 commented Sep 29, 2022

semantic token highlighting from the lsp does not return all the highlights, instead we can combine it with the highlighting from tree sitter for a more complete experience

Before:

Screenshot 2022-09-29 at 14 51 30

After:

Screenshot 2022-09-29 at 14 50 25

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Sep 29, 2022

Codecov Report

Merging #1401 (9fe1554) into master (e760dce) will decrease coverage by 0.00%.
The diff coverage is 0.00%.

@@            Coverage Diff            @@
##           master   #1401      +/-   ##
=========================================
- Coverage    6.16%   6.16%   -0.01%     
=========================================
  Files         122     122              
  Lines       49341   49355      +14     
=========================================
  Hits         3041    3041              
- Misses      46300   46314      +14     
Impacted Files Coverage Δ
lapce-data/src/document.rs 0.00% <0.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more


match (semantic_styles, syntactic_styles) {
(Some(semantic), Some(syntax)) => {
Some(Arc::new(syntax.merge(semantic, |a, b| match b {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this merge needs to be happening when semantic styles and tree sitter styles get updated.

And we can just replace semantic styles with the merged styles.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are those changes alright for now?

If we notice perf issues, we can use https://github.com/xi-editor/xi-editor/blob/master/rust/rope/src/spans.rs#L193-L287

As a more efficient solution (that way we only build the spans once instead of 3x. The reason it would be a pain to do now is that the spans have to be added sequentially which isn't the easiest to do

@MinusGix MinusGix added A-lsp Area: LSP, assists and code completion A-syntax Area: syntax highlighting labels Sep 30, 2022
@camc314 camc314 marked this pull request as draft September 30, 2022 21:25
@camc314 camc314 force-pushed the cam/dev/combing-highlights branch from 5500360 to 5c80440 Compare October 1, 2022 11:14
@camc314 camc314 marked this pull request as ready for review October 1, 2022 11:20

if let Some(syntactic_styles) = syntactic_styles {
for (interval, style) in syntactic_styles.iter() {
syntactic_styles_spans
Copy link
Copy Markdown
Collaborator

@dzhou121 dzhou121 Oct 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason you want to rebuild the styles spans here?

syntactic_styles is Spans<Style> already

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, didn't realise that.

No reason... just an oversight

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-lsp Area: LSP, assists and code completion A-syntax Area: syntax highlighting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants