summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md4
-rw-r--r--server/src/server.ts34
2 files changed, 38 insertions, 0 deletions
diff --git a/README.md b/README.md
index d2b9009..ec09cd5 100644
--- a/README.md
+++ b/README.md
@@ -88,11 +88,15 @@ Sublime Text requires the following minimum settings under LSP settings (modify
"selector": "source.perl",
},
"settings": {
+ // "perlnavigator.perltidyProfile": "~/.perltidyrc",
+ // "perlnavigator.perlcriticProfile": "~/.perlcriticrc",
// "perlnavigator.perlEnvAdd": false, // default: true
// "perlnavigator.perlEnv": {
// "KOHA_CONF": "/home/user/git/KohaCommunity/t/data/koha-conf.xml",
// },
+ // "perlnavigator.perlPath": "~/perl5/perlbrew/perls/perl-5.38.2/bin",
// "perlnavigator.perlcriticSeverity": 1,
+ // "perlnavigator.includePaths": [ "~/git/KohaCommunity", "~/git/KohaCommunity/lib" ],
// "perlnavigator.perlcriticEnabled": true,
// "perlnavigator.enableWarnings": true,
},
diff --git a/server/src/server.ts b/server/src/server.ts
index 5803b81..5d99ca3 100644
--- a/server/src/server.ts
+++ b/server/src/server.ts
@@ -17,6 +17,7 @@ import {
TextEdit,
} from "vscode-languageserver/node";
import { basename } from "path";
+import { homedir } from "os";
import { TextDocument } from "vscode-languageserver-textdocument";
import { PublishDiagnosticsParams } from "vscode-languageserver-protocol";
@@ -192,6 +193,19 @@ async function getWorkspaceFoldersSafe(): Promise<WorkspaceFolder[]> {
}
}
+function expandTildePaths(paths: string, settings: NavigatorSettings): string {
+ const path = paths;
+ // Consider that this not a Windows feature,
+ // so, Windows "%USERPROFILE%" currently is ignored (and rarely used).
+ if (path.startsWith("~/")) {
+ const newPath = homedir() + path.slice(1);
+ nLog("Expanding tilde path '" + path + "' to '" + newPath + "'", settings);
+ return newPath;
+ } else {
+ return path;
+ }
+}
+
async function getDocumentSettings(resource: string): Promise<NavigatorSettings> {
if (!hasConfigurationCapability) {
return globalSettings;
@@ -204,6 +218,26 @@ async function getDocumentSettings(resource: string): Promise<NavigatorSettings>
});
if (!result) return globalSettings;
const resolvedSettings = { ...globalSettings, ...result };
+
+ if(resolvedSettings.includePaths) {
+ resolvedSettings.includePaths = resolvedSettings.includePaths.map((path: string) => expandTildePaths(path, resolvedSettings));
+ }
+ if(resolvedSettings.perlPath) {
+ resolvedSettings.perlPath = expandTildePaths(resolvedSettings.perlPath, resolvedSettings);
+ }
+ if(resolvedSettings.perlimportsProfile) {
+ resolvedSettings.perlimportsProfile = expandTildePaths(resolvedSettings.perlimportsProfile, resolvedSettings);
+ }
+ if(resolvedSettings.perltidyProfile) {
+ resolvedSettings.perltidyProfile = expandTildePaths(resolvedSettings.perltidyProfile, resolvedSettings);
+ }
+ if(resolvedSettings.perlcriticProfile) {
+ resolvedSettings.perlcriticProfile = expandTildePaths(resolvedSettings.perlcriticProfile, resolvedSettings);
+ }
+ if(resolvedSettings.perlEnv) {
+ resolvedSettings.perlEnv = Object.fromEntries(Object.entries(resolvedSettings.perlEnv).map(([key, value]) => [key, expandTildePaths(value, resolvedSettings)]));
+ }
+
documentSettings.set(resource, resolvedSettings);
return resolvedSettings;
}