Skip to content
This repository was archived by the owner on Jan 3, 2025. It is now read-only.

add support for globs in nim.project setting #90

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ The following Visual Studio Code settings are available for the Nim extension.
}
```
* `nim.lintOnSave` - perform the project check for errors on save
* `nim.project` - optional array of projects file, if nim.project is not defined then all nim files will be used as separate project
* `nim.project` - optional array of projects file/glob paths, if nim.project is not defined then all nim files will be used as separate project
* `nim.licenseString` - optional license text that will be inserted on nim file creation


Expand All @@ -58,7 +58,7 @@ The following Visual Studio Code settings are available for the Nim extension.
"nim.buildOnSave": false,
"nim.buildCommand": "c",
"nim.lintOnSave": true,
"nim.project": ["project.nim", "project2.nim"],
"nim.project": ["project.nim", "project2.nim", "src/**/*.nim"],
"nim.licenseString": "# Copyright 2017.\n\n"
}
```
Expand Down
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,25 @@
},
"bugs": {
"url": "https://github.com/pragmagic/vscode-nim/issues"
},
},
"scripts": {
"vscode:prepublish": "tsc -p ./",
"compile": "tsc -watch -p ./",
"postinstall": "node ./node_modules/vscode/bin/install",
"lint": "node ./node_modules/tslint/bin/tslint ./src/*.ts ./test/*.ts"
},
"dependencies": {
"nedb": "1.8.0"
"nedb": "1.8.0",
"glob": "^7.1.2"
},
"devDependencies": {
"typescript": "^2.0.3",
"vscode": "^1.0.0",
"mocha": "^2.3.3",
"tslint": "^4.3.1",
"@types/node": "^6.0.40",
"@types/mocha": "^2.2.32"
"@types/mocha": "^2.2.32",
"@types/glob": "^5.0.35"
},
"engines": {
"vscode": "^1.7.0"
Expand Down Expand Up @@ -154,4 +156,4 @@
}
]
}
}
}
15 changes: 12 additions & 3 deletions src/nimUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import path = require('path');
import os = require('os');
import cp = require('child_process');
import vscode = require('vscode');
import glob = require('glob');
import { showNimStatus, hideNimStatus } from './nimStatus';

let _pathesCache: { [tool: string]: string; } = {};
Expand Down Expand Up @@ -72,17 +73,25 @@ export function getProjects(): string[] {
return _projects;
}

export function parsePath(p: string): string[] {
if (path.isAbsolute(p)) return [p];
if (glob.hasMagic(p)) {
return glob.sync(p, {cwd: vscode.workspace.rootPath});
}
return [path.resolve(vscode.workspace.rootPath, p)];
}

export function prepareConfig(): void {
let config = vscode.workspace.getConfiguration('nim');
let projects = config['project'];
_projects = [];
if (projects) {
if (projects instanceof Array) {
projects.forEach((project) => {
_projects.push(path.isAbsolute(project) ? project : path.resolve(vscode.workspace.rootPath, project));
_projects.push(...parsePath(project));
});
} else {
_projects.push(path.isAbsolute(projects) ? projects : path.resolve(vscode.workspace.rootPath, projects));
_projects.push(...parsePath(projects));
}
}
}
Expand Down Expand Up @@ -137,4 +146,4 @@ export function removeDirSync(p: string): void {
});
fs.rmdirSync(p);
}
};
};