diff options
author | Seivan Heidari <[email protected]> | 2019-10-27 16:57:11 +0000 |
---|---|---|
committer | Seivan Heidari <[email protected]> | 2019-10-27 16:57:11 +0000 |
commit | 0ddf47a7ab9d0f616e7296fa9a0b0eb786e4ee59 (patch) | |
tree | 80234db0e3af0d5f0b428a18f1b66f8fa2ba3bea /editors/code/src/highlighting.ts | |
parent | 5957b851e4451050151722598fa1ff9d41ccf0ff (diff) |
Introducing a Scopes Mapper to map from RA scopes to TextMate scopes with fallbacks.
Current scopes defined:
```
['keyword.unsafe', ['storage.modifier', 'keyword.other', 'keyword.control']],
['function', ['entity.name.function']],
['parameter', ['variable.parameter']],
['type', ['entity.name.type']],
['builtin', ['variable.language', 'support.type', 'support.type']],
['text', ['string', 'string.quoted', 'string.regexp']],
['attribute', ['keyword']],
['literal', ['string', 'string.quoted', 'string.regexp']],
['macro', ['support.other']],
['variable.mut', ['variable']],
['field', ['variable.object.property']],
['module', ['entity.name.section']]
```
Need to complement with further fallbacks as some themes fail.
Diffstat (limited to 'editors/code/src/highlighting.ts')
-rw-r--r-- | editors/code/src/highlighting.ts | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/editors/code/src/highlighting.ts b/editors/code/src/highlighting.ts index 4b961170b..bc19fae2f 100644 --- a/editors/code/src/highlighting.ts +++ b/editors/code/src/highlighting.ts | |||
@@ -2,7 +2,7 @@ import seedrandom = require('seedrandom'); | |||
2 | import * as vscode from 'vscode'; | 2 | import * as vscode from 'vscode'; |
3 | import * as lc from 'vscode-languageclient'; | 3 | import * as lc from 'vscode-languageclient'; |
4 | import * as scopes from './scopes' | 4 | import * as scopes from './scopes' |
5 | 5 | import * as scopesMapper from './scopes_mapper'; | |
6 | 6 | ||
7 | import { Server } from './server'; | 7 | import { Server } from './server'; |
8 | 8 | ||
@@ -65,10 +65,13 @@ export class Highlighter { | |||
65 | tag: string, | 65 | tag: string, |
66 | textDecoration?: string | 66 | textDecoration?: string |
67 | ): [string, vscode.TextEditorDecorationType] => { | 67 | ): [string, vscode.TextEditorDecorationType] => { |
68 | const scope = scopes.find(tag) | ||
69 | 68 | ||
70 | if (scope) { | 69 | const foundRule = scopesMapper.toRule(tag, scopes.find) || scopes.find(tag) |
71 | const decor = createDecorationFromTextmate(scope); | 70 | |
71 | |||
72 | |||
73 | if (foundRule) { | ||
74 | const decor = createDecorationFromTextmate(foundRule); | ||
72 | return [tag, decor]; | 75 | return [tag, decor]; |
73 | } | 76 | } |
74 | else { | 77 | else { |