Skip to content

Support HEEx and Surface files #204

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion elixir-language-configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
{ "open": "~C\"", "close": "\"" },
{ "open": "~D\"", "close": "\"" },
{ "open": "~E\"", "close": "\"" },
{ "open": "~F\"", "close": "\"" },
{ "open": "~H\"", "close": "\"" },
{ "open": "~L\"", "close": "\"" },
{ "open": "~N\"", "close": "\"" },
{ "open": "~R\"", "close": "\"" },
Expand All @@ -38,6 +40,8 @@
{ "open": "~C\"\"\"", "close": "\"\"\"" },
{ "open": "~D\"\"\"", "close": "\"\"\"" },
{ "open": "~E\"\"\"", "close": "\"\"\"" },
{ "open": "~F\"\"\"", "close": "\"\"\"" },
{ "open": "~H\"\"\"", "close": "\"\"\"" },
{ "open": "~L\"\"\"", "close": "\"\"\"" },
{ "open": "~N\"\"\"", "close": "\"\"\"" },
{ "open": "~R\"\"\"", "close": "\"\"\"" },
Expand All @@ -63,7 +67,7 @@
"folding": {
"markers": {
"start": "^\\s*(@(moduledoc|typedoc|doc)\\b\\s+(~S)?\"\"\")|(#\\s*region\\b)",
"end": "^\\s+(\"\"\")|(#\\s*endregion\\b)",
"end": "^\\s+(\"\"\")|(#\\s*endregion\\b)"
}
}
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
"activationEvents": [
"onLanguage:elixir",
"onLanguage:eex",
"onLanguage:html-eex"
"onLanguage:html-eex",
"onLanguage:phoenix-heex",
"onLanguage:surface"
],
"main": "./out/extension",
"contributes": {
Expand Down
26 changes: 17 additions & 9 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ function configureExpandMacro(context: ExtensionContext) {
);
panel.webview.html = getExpandMacroWebviewContent(res);
});

context.subscriptions.push(disposable);
}

Expand Down Expand Up @@ -252,7 +252,7 @@ function configureTerminalLinkProvider(context: ExtensionContext) {
if (matches === null) {
return [];
}

return [
{
startIndex: matches.index!,
Expand All @@ -276,7 +276,7 @@ function configureTerminalLinkProvider(context: ExtensionContext) {
if (!selection) {
return;
}

openUri(selection.uri, line);
});
}
Expand Down Expand Up @@ -353,6 +353,10 @@ export function activate(context: ExtensionContext): void {
{ language: "eex", scheme: "untitled" },
{ language: "html-eex", scheme: "file" },
{ language: "html-eex", scheme: "untitled" },
{ language: "phoenix-heex", scheme: "file" },
{ language: "phoenix-heex", scheme: "untitled" },
{ language: "surface", scheme: "file" },
{ language: "surface", scheme: "untitled" }
],
// Don't focus the Output pane on errors because request handler errors are no big deal
revealOutputChannelOn: RevealOutputChannelOn.Never,
Expand All @@ -361,14 +365,14 @@ export function activate(context: ExtensionContext): void {
configurationSection: "elixirLS",
// Notify the server about file changes to Elixir files contained in the workspace
fileEvents: [
workspace.createFileSystemWatcher("**/*.{ex,exs,erl,hrl,yrl,xrl,eex,leex}"),
workspace.createFileSystemWatcher("**/*.{ex,exs,erl,hrl,yrl,xrl,eex,leex,heex,sface}"),
],
},
};

function didOpenTextDocument(document: vscode.TextDocument): void {
// We are only interested in elixir files
if (document.languageId !== "elixir") {
// We are only interested in elixir related files
if (["elixir", "eex", "html-eex", "phoenix-heex", "surface"].indexOf(document.languageId) < 0) {
return;
}

Expand All @@ -394,14 +398,16 @@ export function activate(context: ExtensionContext): void {

// If we have nested workspace folders we only start a server on the outer most workspace folder.
folder = getOuterMostWorkspaceFolder(folder);

if (!clients.has(folder.uri.toString())) {
const pattern = `${folder.uri.fsPath}/**/*`
// open untitled files go to the first workspace
const untitled = folder.index === 0 ? [
{ language: "elixir", scheme: "untitled" },
{ language: "eex", scheme: "untitled" },
{ language: "html-eex", scheme: "untitled"}
{ language: "html-eex", scheme: "untitled"},
{ language: "phoenix-heex", scheme: "untitled"},
{ language: "surface", scheme: "untitled"}
] : [];
const workspaceClientOptions: LanguageClientOptions = Object.assign(
{},
Expand All @@ -412,6 +418,8 @@ export function activate(context: ExtensionContext): void {
{ language: "elixir", scheme: "file", pattern: pattern },
{ language: "eex", scheme: "file", pattern: pattern },
{ language: "html-eex", scheme: "file", pattern: pattern },
{ language: "phoenix-heex", scheme: "file", pattern: pattern },
{ language: "surface", scheme: "file", pattern: pattern },
...untitled
],
workspaceFolder: folder,
Expand Down Expand Up @@ -472,6 +480,6 @@ function getClient(document: vscode.TextDocument): LanguageClient | null {

// If we have nested workspace folders we only start a server on the outer most workspace folder.
folder = getOuterMostWorkspaceFolder(folder);

return clients.get(folder.uri.toString())!;
}