Implemented autocompletion for files, env vars, and symbols.
h3rald h3rald@h3rald.com
Sun, 04 Sep 2016 13:49:45 +0200
1 files changed,
17 insertions(+),
1 deletions(-)
jump to
M
minim.nim
→
minim.nim
@@ -50,8 +50,24 @@ var w = if words.len > 0: words.pop else: ""
var sep = "" if words.len > 0: sep = " " + if w.startsWith("'"): + for s in CURRSCOPE.symbols.keys: + if startsWith("'$1"%s, w): + linenoiseAddCompletion completions, words.join(" ") & sep & "'" & s + return + if w.startsWith("$"): + for s,v in envPairs(): + if startsWith("$$1"%s, w): + linenoiseAddCompletion completions, words.join(" ") & sep & "$" & s + return + if w.startsWith("\""): + let w1 = w[1..w.len-1] + for c,s in walkDir(getCurrentDir(), true): + if startsWith("\"$1"%s, w): + linenoiseAddCompletion completions, words.join(" ") & sep & "\"" & s & "\"" + return for s in CURRSCOPE.symbols.keys: - if startsWith(s, w): + if s.startsWith(w): linenoiseAddCompletion completions, words.join(" ") & sep & s proc prompt(s: string): string =