Skip to content

Commit cfeb160

Browse files
author
Ravi Chande
authored
Merge pull request #2576 from SteveSandersonMS/stevesa/initial-razor-support-updated
Initial Razor support
2 parents abb6c5b + b45c2f3 commit cfeb160

File tree

9 files changed

+292
-15
lines changed

9 files changed

+292
-15
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ out
55
.omnisharp-*/
66
.debugger
77
.vscode-test
8+
.razor
89

910
install.*
1011

package-lock.json

Lines changed: 76 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 132 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
"http-proxy-agent": "2.1.0",
7474
"https-proxy-agent": "2.2.1",
7575
"jsonc-parser": "1.0.0",
76+
"microsoft.aspnetcore.razor.vscode": "https://download.visualstudio.microsoft.com/download/pr/273c49f3-fc9b-4140-bc65-b47b9ac61267/84c3319bc81e794e873cb931084cb6c8/microsoft.aspnetcore.razor.vscode-1.0.0-alpha1-20181003.5.tgz",
7677
"mkdirp": "0.5.1",
7778
"node-filter-async": "0.0.4",
7879
"open": "*",
@@ -84,7 +85,7 @@
8485
"tmp": "0.0.33",
8586
"vscode-debugprotocol": "1.6.1",
8687
"vscode-extension-telemetry": "0.0.15",
87-
"yauzl": "2.9.1"
88+
"yauzl": "2.10.0"
8889
},
8990
"devDependencies": {
9091
"@types/archiver": "2.1.1",
@@ -268,6 +269,56 @@
268269
"./vsdbg"
269270
],
270271
"installTestPath": "./.debugger/vsdbg-ui"
272+
},
273+
{
274+
"description": "Razor Language Server (Windows / x64)",
275+
"url": "https://download.visualstudio.microsoft.com/download/pr/273c49f3-fc9b-4140-bc65-b47b9ac61267/f14ac3d133fbd3ec940741c7e5ea270a/razorlanguageserver-win-x64-1.0.0-alpha1-20181003.5.zip",
276+
"installPath": ".razor",
277+
"platforms": [
278+
"win32"
279+
],
280+
"architectures": [
281+
"x86_64"
282+
]
283+
},
284+
{
285+
"description": "Razor Language Server (Windows / x86)",
286+
"url": "https://download.visualstudio.microsoft.com/download/pr/273c49f3-fc9b-4140-bc65-b47b9ac61267/2650922e18baf2470fa1e7eb3b7fcd6a/razorlanguageserver-win-x86-1.0.0-alpha1-20181003.5.zip",
287+
"installPath": ".razor",
288+
"platforms": [
289+
"win32"
290+
],
291+
"architectures": [
292+
"x86"
293+
]
294+
},
295+
{
296+
"description": "Razor Language Server (Linux / x64)",
297+
"url": "https://download.visualstudio.microsoft.com/download/pr/273c49f3-fc9b-4140-bc65-b47b9ac61267/90ec9047fa008298d85e3abc15866818/razorlanguageserver-linux-x64-1.0.0-alpha1-20181003.5.zip",
298+
"installPath": ".razor",
299+
"platforms": [
300+
"linux"
301+
],
302+
"architectures": [
303+
"x86_64"
304+
],
305+
"binaries": [
306+
"./rzls"
307+
]
308+
},
309+
{
310+
"description": "Razor Language Server (macOS / x64)",
311+
"url": "https://download.visualstudio.microsoft.com/download/pr/273c49f3-fc9b-4140-bc65-b47b9ac61267/ef4d3d9d01cd5cffd41095de48e466a8/razorlanguageserver-osx-x64-1.0.0-alpha1-20181003.5.zip",
312+
"installPath": ".razor",
313+
"platforms": [
314+
"darwin"
315+
],
316+
"architectures": [
317+
"x86_64"
318+
],
319+
"binaries": [
320+
"./rzls"
321+
]
271322
}
272323
],
273324
"engines": {
@@ -276,6 +327,7 @@
276327
"activationEvents": [
277328
"onDebug",
278329
"onLanguage:csharp",
330+
"onLanguage:aspnetcorerazor",
279331
"onCommand:o.restart",
280332
"onCommand:o.pickProjectAndStart",
281333
"onCommand:o.showOutput",
@@ -602,6 +654,39 @@
602654
"type": "boolean",
603655
"default": false,
604656
"description": "Specifies whether notifications should be shown if OmniSharp encounters warnings or errors loading a project. Note that these warnings/errors are always emitted to the OmniSharp log"
657+
},
658+
"razor.disabled": {
659+
"type": "boolean",
660+
"default": false,
661+
"description": "Specifies whether to disable Razor language features."
662+
},
663+
"razor.languageServer.directory": {
664+
"type": [
665+
"string",
666+
"null"
667+
],
668+
"default": null,
669+
"description": "Overrides the path to the Razor Language Server directory."
670+
},
671+
"razor.languageServer.debug": {
672+
"type": "boolean",
673+
"default": false,
674+
"description": "Specifies whether to wait for debug attach when launching the language server."
675+
},
676+
"razor.languageServer.trace": {
677+
"type": "string",
678+
"default": "Off",
679+
"enum": [
680+
"Off",
681+
"Messages",
682+
"Verbose"
683+
],
684+
"enumDescriptions": [
685+
"Does not log messages from Razor Language Server",
686+
"Logs only some messages from Razor Language Server",
687+
"Logs all messages from Razor Language Server"
688+
],
689+
"description": "Specifies whether to output all messages [Verbose], some messages [Messages] or not at all [Off]."
605690
}
606691
}
607692
},
@@ -660,6 +745,16 @@
660745
"command": "csharp.reportIssue",
661746
"title": "Start authoring a new issue on GitHub",
662747
"category": "CSharp"
748+
},
749+
{
750+
"command": "extension.showRazorCSharpWindow",
751+
"title": "Show Razor CSharp",
752+
"category": "Razor"
753+
},
754+
{
755+
"command": "extension.showRazorHtmlWindow",
756+
"title": "Show Razor Html",
757+
"category": "Razor"
663758
}
664759
],
665760
"keybindings": [
@@ -682,7 +777,8 @@
682777
"enableBreakpointsFor": {
683778
"languageIds": [
684779
"csharp",
685-
"razor"
780+
"razor",
781+
"aspnetcorerazor"
686782
]
687783
},
688784
"variables": {
@@ -1749,7 +1845,8 @@
17491845
"enableBreakpointsFor": {
17501846
"languageIds": [
17511847
"csharp",
1752-
"razor"
1848+
"razor",
1849+
"aspnetcorerazor"
17531850
]
17541851
},
17551852
"variables": {
@@ -2712,6 +2809,37 @@
27122809
}
27132810
}
27142811
}
2715-
]
2812+
],
2813+
"languages": [
2814+
{
2815+
"id": "aspnetcorerazor",
2816+
"extensions": [
2817+
".cshtml"
2818+
],
2819+
"mimetypes": [
2820+
"text/x-cshtml"
2821+
],
2822+
"configuration": "./src/razor/language-configuration.json"
2823+
}
2824+
],
2825+
"grammars": [
2826+
{
2827+
"language": "aspnetcorerazor",
2828+
"scopeName": "text.aspnetcorerazor",
2829+
"path": "./src/razor/syntaxes/aspnetcorerazor.tmLanguage.json"
2830+
}
2831+
],
2832+
"menus": {
2833+
"editor/title": [
2834+
{
2835+
"command": "extension.showRazorCSharpWindow",
2836+
"when": "resourceLangId == aspnetcorerazor"
2837+
},
2838+
{
2839+
"command": "extension.showRazorHtmlWindow",
2840+
"when": "resourceLangId == aspnetcorerazor"
2841+
}
2842+
]
2843+
}
27162844
}
27172845
}

src/main.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import { ShowOmniSharpConfigChangePrompt } from './observers/OptionChangeObserve
3737
import createOptionStream from './observables/CreateOptionStream';
3838
import { CSharpExtensionId } from './constants/CSharpExtensionId';
3939
import { OpenURLObserver } from './observers/OpenURLObserver';
40+
import { activateRazorExtension } from './razor/razor';
4041

4142
export async function activate(context: vscode.ExtensionContext): Promise<CSharpExtensionExports> {
4243

@@ -134,6 +135,10 @@ export async function activate(context: vscode.ExtensionContext): Promise<CSharp
134135
coreClrDebugPromise = coreclrdebug.activate(extension, context, platformInfo, eventStream);
135136
}
136137

138+
if (!optionProvider.GetLatestOptions().razorDisabled) {
139+
await activateRazorExtension(context, extension.extensionPath, eventStream);
140+
}
141+
137142
return {
138143
initializationFinished: async () => {
139144
let omniSharp = await omniSharpPromise;

src/omnisharp/options.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ export class Options {
2323
public minFindSymbolsFilterLength: number,
2424
public maxFindSymbolsItems: number,
2525
public defaultLaunchSolution?: string,
26-
public monoPath?: string) { }
26+
public monoPath?: string,
27+
public razorDisabled?: boolean) { }
2728

2829

2930
public static Read(vscode: vscode): Options {
@@ -36,6 +37,7 @@ export class Options {
3637

3738
const omnisharpConfig = vscode.workspace.getConfiguration('omnisharp');
3839
const csharpConfig = vscode.workspace.getConfiguration('csharp');
40+
const razorConfig = vscode.workspace.getConfiguration('razor');
3941

4042
const path = Options.readPathOption(csharpConfig, omnisharpConfig);
4143
const useGlobalMono = Options.readUseGlobalMonoOption(omnisharpConfig, csharpConfig);
@@ -68,6 +70,8 @@ export class Options {
6870
const minFindSymbolsFilterLength = omnisharpConfig.get<number>('minFindSymbolsFilterLength', 0);
6971
const maxFindSymbolsItems = omnisharpConfig.get<number>('maxFindSymbolsItems', 1000); // The limit is applied only when this setting is set to a number greater than zero
7072

73+
const razorDisabled = !!razorConfig && razorConfig.get<boolean>('disabled', false);
74+
7175
return new Options(
7276
path,
7377
useGlobalMono,
@@ -86,6 +90,7 @@ export class Options {
8690
maxFindSymbolsItems,
8791
defaultLaunchSolution,
8892
monoPath,
93+
razorDisabled
8994
);
9095
}
9196

0 commit comments

Comments
 (0)