mirror of
https://github.com/nim-lang/Nim.git
synced 2026-07-30 12:17:56 +00:00
nimsuggest: when invoked with a directory, detect the main nim file on its own
This commit is contained in:
@@ -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, {'(', ')', '.'})
|
||||
|
||||
Reference in New Issue
Block a user