make nimsuggest go up in the directory tree in order to determine the main .nim file
This commit is contained in:
parent
1d63a8fe4a
commit
7e2418bd22
1 changed files with 16 additions and 12 deletions
|
|
@ -600,18 +600,22 @@ proc findModule*(conf: ConfigRef; modulename, currentModule: string): string =
|
||||||
proc findProjectNimFile*(conf: ConfigRef; pkg: string): string =
|
proc findProjectNimFile*(conf: ConfigRef; pkg: string): string =
|
||||||
const extensions = [".nims", ".cfg", ".nimcfg", ".nimble"]
|
const extensions = [".nims", ".cfg", ".nimcfg", ".nimble"]
|
||||||
var candidates: seq[string] = @[]
|
var candidates: seq[string] = @[]
|
||||||
for k, f in os.walkDir(pkg, relative=true):
|
var dir = pkg
|
||||||
if k == pcFile and f != "config.nims":
|
while true:
|
||||||
let (_, name, ext) = splitFile(f)
|
for k, f in os.walkDir(dir, relative=true):
|
||||||
if ext in extensions:
|
if k == pcFile and f != "config.nims":
|
||||||
let x = changeFileExt(pkg / name, ".nim")
|
let (_, name, ext) = splitFile(f)
|
||||||
if fileExists(x):
|
if ext in extensions:
|
||||||
candidates.add x
|
let x = changeFileExt(dir / name, ".nim")
|
||||||
for c in candidates:
|
if fileExists(x):
|
||||||
# nim-foo foo or foo nfoo
|
candidates.add x
|
||||||
if (pkg in c) or (c in pkg): return c
|
for c in candidates:
|
||||||
if candidates.len >= 1:
|
# nim-foo foo or foo nfoo
|
||||||
return candidates[0]
|
if (pkg in c) or (c in pkg): return c
|
||||||
|
if candidates.len >= 1:
|
||||||
|
return candidates[0]
|
||||||
|
dir = parentDir(dir)
|
||||||
|
if dir == "": break
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
proc canonDynlibName(s: string): string =
|
proc canonDynlibName(s: string): string =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue