Commit graph

318 commits

Author SHA1 Message Date
Aleksey Kladov
26bd7a896b Drop support for legacy colorization 2019-12-31 14:11:25 +01:00
Aleksey Kladov
6c1d92d6c5 Rename file 2019-12-31 14:06:40 +01:00
Aleksey Kladov
519bd0deb5 Fix #2700 2019-12-31 11:44:52 +01:00
Aleksey Kladov
f984ef2652 Switch impure functional style to pure imperative 2019-12-31 03:33:00 +01:00
Aleksey Kladov
cfb0865929 Reduce scope 2019-12-31 02:30:43 +01:00
Aleksey Kladov
96de8076ff Use optional value shortcut 2019-12-31 02:27:26 +01:00
Aleksey Kladov
6561634c68 Remove trivial helpers 2019-12-31 02:21:57 +01:00
Aleksey Kladov
8346bdc04d Rearrange code 2019-12-31 02:17:50 +01:00
Aleksey Kladov
68b7d84974 Restore internal applySourceChange command 2019-12-30 23:46:13 +01:00
Aleksey Kladov
c65e90f7b8 Use Ctx in highlighter 2019-12-30 23:46:13 +01:00
Aleksey Kladov
04f0f5077a Reformat with tsfmt 2019-12-30 23:30:35 +01:00
Aleksey Kladov
323ad13c8a Add tsfmt 2019-12-30 23:28:13 +01:00
Aleksey Kladov
9fae4f4b99 Remove prettier 2019-12-30 23:27:13 +01:00
Aleksey Kladov
233f1dd2a8 Privatize highlighting 2019-12-30 23:17:56 +01:00
Aleksey Kladov
cdd7118cbf Don't request inline hints repeatedly 2019-12-30 22:53:21 +01:00
Aleksey Kladov
23bac12062 Retry inlay hints on content modified error 2019-12-30 22:20:04 +01:00
Aleksey Kladov
08c5d157f9 Thoughtlessly copy-paste a fix to a problem I don't understand 2019-12-30 21:39:34 +01:00
Aleksey Kladov
ac8a142ddd Refactor inlay hints 2019-12-30 21:32:04 +01:00
Aleksey Kladov
efbbc903e6 Add config to Ctx 2019-12-30 21:32:04 +01:00
Aleksey Kladov
7646dc046e Encapsulate highlighting activation 2019-12-30 21:32:04 +01:00
Aleksey Kladov
9ead314005 Encapsulate inlay hints activation 2019-12-30 20:24:30 +01:00
Aleksey Kladov
b8368f09b4 Dead code 2019-12-30 20:16:57 +01:00
Aleksey Kladov
6cc55e4c5c status is not a command 2019-12-30 20:16:07 +01:00
Aleksey Kladov
7b199f6a4b Hints are not commands 2019-12-30 20:10:40 +01:00
Aleksey Kladov
3d008a78d0 Move all commands to ctx 2019-12-30 20:07:04 +01:00
Aleksey Kladov
da80b6c1e1 Minor refactor 2019-12-30 20:00:46 +01:00
Aleksey Kladov
6b118c9b8d Refactor runables 2019-12-30 19:58:44 +01:00
Aleksey Kladov
94be27fc44 Move expand macro to the new context 2019-12-30 19:31:07 +01:00
Aleksey Kladov
68f47a5b10 Cleanup 2019-12-30 19:12:49 +01:00
Aleksey Kladov
260df66b77 Cleanup imports 2019-12-30 19:07:59 +01:00
Aleksey Kladov
ca5c59507f Refactor show syntax tree action 2019-12-30 19:07:59 +01:00
Aleksey Kladov
ac3d0e8340 Run prettier on all files 2019-12-30 19:07:59 +01:00
Aleksey Kladov
9bfeac708d Move parentModule to the new Ctx 2019-12-30 19:07:59 +01:00
Aleksey Kladov
5aebf1081d Refactor applySourceChange 2019-12-30 19:07:59 +01:00
Aleksey Kladov
83d2527880 Move joinLines to the new Ctx 2019-12-30 19:07:59 +01:00
Emil Lauridsen
2d3ebc3406 Fix server config mispell in vscode extension 2019-12-30 18:22:06 +01:00
Aleksey Kladov
5dd9edaeaf Move matching brace to new Ctx 2019-12-30 15:23:55 +01:00
Aleksey Kladov
57df9bed70 Run prettier 2019-12-30 15:11:30 +01:00
Aleksey Kladov
a0c0350960 Add prettier 2019-12-30 15:10:59 +01:00
Aleksey Kladov
29e86c0c72 More second command to Ctx 2019-12-30 14:53:43 +01:00
Aleksey Kladov
e53ccb6e99 Start new ctx module 2019-12-30 14:42:59 +01:00
Aleksey Kladov
2008f9e0b9 Simplify 2019-12-30 12:29:33 +01:00
Aleksey Kladov
dc559dbe1c Rename extension.ts -> main.ts 2019-12-30 12:29:33 +01:00
Aleksey Kladov
1f8719ee87 Minimize typescript CI 2019-12-30 11:33:01 +01:00
Aleksey Kladov
e0fa096bbb Add rollup 2019-12-30 11:20:45 +01:00
Aleksey Kladov
5846221a39 Minimize TypeScript build 2019-12-30 02:22:52 +01:00
Aleksey Kladov
7192ee842d Trim down launch configurations 2019-12-30 00:16:11 +01:00
bors[bot]
232785251b
Merge #2061
2061: Theme loading and "editor.tokenColorCustomizations" support. r=matklad a=seivan

Fixes: [Issue#1294](https://github.com/rust-analyzer/rust-analyzer/issues/1294#issuecomment-497450325)

TODO: 
- [x] Load themes
- [x] Load existing `ralsp`-prefixed overrides from `"workbench.colorCustomizations"`.
- [x] Load overrides from `"editor.tokenColorCustomizations.textMateRules"`.
- [x] Use RA tags to load `vscode.DecorationRenderOptions` (colors) from theme & overrides.
- [x] Map RA tags to common TextMate scopes before loading colors.
- [x] Add default scope mappings in extension.
- [x] Cache mappings between settings updates. 
- [x] Add scope mapping configuration manifest in `package.json`
- [x] Load configurable scope mappings from settings.
- [x] Load JSON Scheme for text mate scope rules in settings.
- [x] Update [Readme](https://github.com/seivan/rust-analyzer/blob/feature/themes/docs/user/README.md#settings).

Borrowed the theme loading (`scopes.ts`) from `Tree Sitter` with some modifications to reading `"editor.tokenColorCustomizations"` for merging with loaded themes and had to remove the async portions to be able to load it from settings updates. 

~Just a PoC and an idea I toyed around with a lot of room for improvement.~
For starters, certain keywords aren't part of the standard TextMate grammar, so it still reads colors from the `ralsp` prefixed values in `"workbench.colorCustomizations"`. 

But I think there's more value making the extension work with existing themes by maping some of the decoration tags to existing key or keys. 

<img width="453" alt="Screenshot 2019-11-09 at 17 43 18" src="https://user-images.githubusercontent.com/55424/68531968-71b4e380-0318-11ea-924e-cdbb8d5eae06.png">
<img width="780" alt="Screenshot 2019-11-09 at 17 41 45" src="https://user-images.githubusercontent.com/55424/68531950-4b8f4380-0318-11ea-8f85-24a84efaf23b.png">
<img width="468" alt="Screenshot 2019-11-09 at 17 40 29" src="https://user-images.githubusercontent.com/55424/68531952-51852480-0318-11ea-800a-6ae9215f5368.png">


These will merge with the default ones coming with the extension, so you don't have to implement all of them and works well with overrides defined in settings. 

```jsonc
    "editor.tokenColorCustomizations": {
        "textMateRules": [
            {
                "scope": "keyword",
                "settings": {
                    "fontStyle": "bold",
                }
            },
        ]
    },
```


Edit: The idea is to work with 90% of the themes out there by working within existing scopes available that are generally styled. It's not to say I want to erase the custom Rust scopes - those should still remain and eventually worked into a custom grammar bundle for Rust specific themes that target those, I just want to make it work with generic themes offered on the market place for now. 

A custom grammar bundle and themes for Rust specific scopes is out of... scope for this PR. 
We'll make another round to tackle those issues. 


Current fallbacks implemented

```typescript
    [
        'comment',
        [
            'comment',
            'comment.block',
            'comment.line',
            'comment.block.documentation'
        ]
    ],
    ['string', ['string']],
    ['keyword', ['keyword']],
    ['keyword.control', ['keyword.control', 'keyword', 'keyword.other']],
    [
        'keyword.unsafe',
        ['storage.modifier', 'keyword.other', 'keyword.control', 'keyword']
    ],
    ['function', ['entity.name.function']],
    ['parameter', ['variable.parameter']],
    ['constant', ['constant', 'variable']],
    ['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', ['variable']],
    ['variable.mut', ['variable', 'storage.modifier']],
    [
        'field',
        [
            'variable.object.property',
            'meta.field.declaration',
            'meta.definition.property',
            'variable.other'
        ]
    ],
    ['module', ['entity.name.section', 'entity.other']]
```


Co-authored-by: Seivan Heidari <seivan.heidari@icloud.com>
2019-12-29 16:49:40 +00:00
Emil Lauridsen
0cdbd08149 Keep VSCode config mostly backwards compatible 2019-12-25 20:26:06 +01:00
Emil Lauridsen
b9c10ed97f Re-format VSCode extension changes 2019-12-25 19:10:30 +01:00