diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2017-03-14 12:28:15 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-03-14 12:28:15 +0100 |
commit | f7d760cb94ffef99b596d167fc517284e5a6a757 (patch) | |
tree | bb6177e4731a54e87774fe6b5ab70f13e843cc30 /compiler/options.nim | |
parent | b414806e66efbf37c8e7edf832cb9a266f433d60 (diff) | |
download | Nim-f7d760cb94ffef99b596d167fc517284e5a6a757.tar.gz |
nimsuggest: when invoked with a directory, detect the main nim file on its own
Diffstat (limited to 'compiler/options.nim')
-rw-r--r-- | compiler/options.nim | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/compiler/options.nim b/compiler/options.nim index 349f9dae1..6372cddac 100644 --- a/compiler/options.nim +++ b/compiler/options.nim @@ -392,6 +392,23 @@ proc findModule*(modulename, currentModule: string): string = result = findFile(m) patchModule() +proc findProjectNimFile*(pkg: string): string = + const extensions = [".nims", ".cfg", ".nimcfg", ".nimble"] + var candidates: seq[string] = @[] + for k, f in os.walkDir(pkg, relative=true): + if k == pcFile and f != "config.nims": + let (_, name, ext) = splitFile(f) + if ext in extensions: + let x = changeFileExt(pkg / name, ".nim") + if fileExists(x): + candidates.add x + for c in candidates: + # nim-foo foo or foo nfoo + if (pkg in c) or (c in pkg): return c + if candidates.len >= 1: + return candidates[0] + return "" + proc canonDynlibName(s: string): string = let start = if s.startsWith("lib"): 3 else: 0 let ende = strutils.find(s, {'(', ')', '.'}) |