-
Notifications
You must be signed in to change notification settings - Fork 300
Feature/syntax highlight hover #1443
Feature/syntax highlight hover #1443
Conversation
switch to string replacement method
use token names to generate classes
split out quickInfo container and pass it its own version of the theme
}> = this._configuration.getValue("editor.tokenColors") | ||
|
||
// FIXME: Specify Highlights to check by differentiating vim highlights as no having "." | ||
const tokens = Object.keys(configurationColors).filter(c => !c.includes(".")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we move this logic to NeovimInstance
as getHighlights
? This way, we don't need a public getVimHighlights
method, as I'm hoping to keep the Editor
interface as agnostic of Vim as possible.
Once we have that, we could change below to:
const vimHighlights = await this._neovimInstance.getHighlights()
}> = this._configuration.getValue("editor.tokenColors") | ||
|
||
// FIXME: Specify Highlights to check by differentiating vim highlights as no having "." | ||
const tokens = Object.keys(configurationColors).filter(c => !c.includes(".")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder why we need to look up editor.tokenColors
here? Could we use a fixed array of `["Function", "Identifier", "String", "Character", etc], and then convert them to scopes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might've had the reverse in mind - we get all the Vim highlights, convert them to scopes + colors, and then use those for setting syntax highlights.
@@ -319,6 +484,19 @@ export class ThemeManager { | |||
return this._themeLoader.getAllThemes() | |||
} | |||
|
|||
public async getVimHighlightColors(tokenColors: IVimHighlight[]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like we're actually setting the token colors here, so we might want to rename this to setTokenColors
instead.
}, | ||
} | ||
|
||
export interface IVimHighlight { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, we could make the ThemeManager agnostic of Vim. The highlight group
is really an implementation detail - it'd be great if we could make this care about color/bold/italic/background-color, and then leave it up to the setHighlights
in Buffer
to rationalize highlight groups from that. It sounded like there might be challenges here though - let me know what sort of hurdles you ran into.
@@ -3,6 +3,79 @@ import * as os from "os" | |||
import * as React from "react" | |||
import styled, { boxShadowInset, css, fontSizeSmall, withProps } from "./common" | |||
|
|||
const markedCss = css` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes for the rendering look great to me! Thanks for all your work here. I wonder if we could split this up into two changes? It seems like the synchronizing highlight groups has some challenges, but we could at least bring in the rendering with the editor.tokenColors
we have today
"editor.tokenColors": { | ||
"meta.import": { | ||
scope: "meta-import", | ||
settings: "Define", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ya, this is where I was hoping we could specify color/background color/bold/italic etc (and in the user's config / theme as well) instead of the vim highlight group. The vim highlight group was really just a crutch to implement.
"highlight.mode.visual.foreground": "#282c34", | ||
"editor.tokenColors": { | ||
"variable.parameter": { | ||
"color": "#d19a66" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! 😄
browser/src/Editor/BufferManager.ts
Outdated
@@ -295,6 +295,9 @@ export class Buffer implements IBuffer { | |||
} | |||
|
|||
const getToken = (lineContents: string, character: number): Oni.IToken => { | |||
if (!lineContents || !character) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, I wonder if this is related to an issue in my PR #1298... perhaps I'm hitting this too!
it requires setting up moving json files around as grammar loader is a dependecy and cant be used without a valid textmate json file can look into adding this functionality separately to test grammar loader
Codecov Report
@@ Coverage Diff @@
## master #1443 +/- ##
==========================================
- Coverage 45.63% 45.62% -0.01%
==========================================
Files 112 112
Lines 4111 4114 +3
Branches 589 590 +1
==========================================
+ Hits 1876 1877 +1
- Misses 2105 2107 +2
Partials 130 130
Continue to review full report at Codecov.
|
This is because hover rendering now involves slightly more processing and without it it appearance is noticeably janky looking
remove unadvisable display table css rule
Further update managed to fix the outstanding bug (that I'm aware of tm) which was that code blocks weren't highlighting which was actually not a commonly encountered issue as most of the markup is being rendered in |
also remove styling as this is actually unnecessary
lack of rule causes weird at a glance issue with larger code blocks
this is not ideal as hover then has missing keys plus some functionality can be achieved without sets
marked dumps html into the out put which is less preferable and its sanitizer option breaks highlighting
|
||
describe("Markdown Conversion Functions", () => { | ||
it("Scopes to string fn should correctly convert scopes to classnames", () => { | ||
const className = markdown.scopesToString(["token.scope.extension"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the tests here! 👍
) | ||
|
||
return ( | ||
<TokenThemeProvider |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool idea to separate the logic of getting the token colors from the logic of rendering
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for all the work with this, @akin909 ! I just pulled the latest and it looks awesome 💯
This PR adds syntax highlighting to the hover tool tip other changes include:
json
theme, user config and set defaults based on available vim highlights.Todo
Set highlight colors for various tokens or so tokens such as
variable.other.object
render with a colorFix failing test due to config changes
Fix Regex quirks re .
|
charactersAdd unit tests
resize hover container
Screenshots
Discussed below:
Fix formatting for code block and add highlighting to code blocks in tooltip