mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-01 02:42:05 +00:00
make nimsuggest go up in the directory tree in order to determine the main .nim file
This commit is contained in:
@@ -600,18 +600,22 @@ proc findModule*(conf: ConfigRef; modulename, currentModule: string): string =
|
||||
proc findProjectNimFile*(conf: ConfigRef; 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]
|
||||
var dir = pkg
|
||||
while true:
|
||||
for k, f in os.walkDir(dir, relative=true):
|
||||
if k == pcFile and f != "config.nims":
|
||||
let (_, name, ext) = splitFile(f)
|
||||
if ext in extensions:
|
||||
let x = changeFileExt(dir / 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]
|
||||
dir = parentDir(dir)
|
||||
if dir == "": break
|
||||
return ""
|
||||
|
||||
proc canonDynlibName(s: string): string =
|
||||
|
||||
Reference in New Issue
Block a user