It is really working!
Araq wrote 11-05-2016 IRC
dus is 'def or use' chk is the same that 'nim check' does highlight outputs semantic highlighting information, like 'this identifier over there is a type/proc/const' outline # no idea, cannot remember lol. the v2 mode adds more information and should always be used for new developments
First a question. We launch nimsuggest with an initial module (project) name, later we give it commands names followed by filename and optional dirtyfilename. Problem is, when I have an editor with multiple files (tabs) and I switch from one file to another one. Is it sufficient to give changed filename and dirtyfilename as command parameter, or may it be necessary to kill nimsuggest server and restart with new project file? I hope that no restart is needed -- but when it is not needed, why do we have to give a initial file name at all?
First problem: For tiny modules without larger imports sug command works well, for example when I type "12.3." I get a few proc suggests like
sug skProc system.toInt proc (f: float): int{.noSideEffect.}
But when I import glib.nim, which itself does not import other modules, I get hundreds of suggestions, mostly templates not related with floats:
sug skTemplate glib.gArrayIndex proc (a: expr, t: expr, i: expr): expr /home/stefan/ngtk3/nim-glib/src/glib.nim
That one refers to
template gArrayIndex*(a, t, i: expr): expr = ((cast[ptr T](cast[pointer](a.data)))[(i)])
I don't know for what that template may be useful, but there is no float involved. OK, I can filter out all these suggestions starting with skTemplate. But have I really to do that?
sug skProc system.abs proc (x: float): float{.noSideEffect, gcsafe, locks: 0.} /home/stefan/Nim/lib/system.nim 1944 5 "" sug skProc system.max proc (x: float, y: float): float{.noSideEffect, gcsafe, locks: 0.} /home/stefan/Nim/lib/system.nim 1948 5 "" sug skProc system.min proc (x: float, y: float): float{.noSideEffect, gcsafe, locks: 0.} /home/stefan/Nim/lib/system.nim 1946 5 "" sug skTemplate algorithm.sortedByIt proc (seq1: expr, op: expr): expr /home/stefan/Nim/lib/pure/algorithm.nim 209 9 "" sug skProc system.toBiggestInt proc (f: BiggestFloat): BiggestInt{.noSideEffect.} /home/stefan/Nim/lib/system.nim 1552 5 "" sug skProc system.toInt proc (f: float): int{.noSideEffect.} /home/stefan/Nim/lib/system.nim 1546 5 ""
The template is garbage! So I have to filter the skTemplate entrys out.
nimsuggest has really interesting behaviour :-(
While my GTK3 editor worked really not bad with small test files, it always failed for the editor source itself. So I thought it must be a time consuming task to debug that. But the reason is very simple: nim c file.nim as well as nim chk file.nim expands macro code to the console window, and nimsuggest does the same for console invocation and when communication with socket. This is for a bug free code, which compiles fine to an executable. So maybe we have to read from the nimsuggest socket all that garbage, before we can send commands? May that work? Really filtering that garbage will not work, because it is undefined. Here is the output:
$ nimsuggest --stdin main.nim
proc nimEdAppWindowInit(self: NimEdAppWindow) {.cdecl.}
proc nimEdAppWindowClassInit(klass: NimEdAppWindowClass) {.cdecl.}
var nimEdAppWindowParentClass: Gpointer = nil
var NimEdAppWindowPrivateOffset: cint
[EDIT]
OK, that was easy to fix, in the macro definition there was a "echo" left from debugging. Of course it would be nice if nimsuggest would not send these macro expansion.