how to search where a symbol foo is declared using cmd line?
for a proc, template, etc we can search for 'proc foo` (using rg, grep or nimgrep)
for a symbol marked with foo* we can also get by with rg, grep or nimgrep
But what about something like fgGreen that's public, yet doesn't show a * next to it?
it's exported in lib/pure/terminal.nim but doesn't show up with * (the * is only used for ForegroundColor but fgGreen is public, as can be seen with from terminal import fgGreen): here's the where it's defined:
type
ForegroundColor* = enum ## terminal's foreground colors
fgBlack = 30, ## black
fgRed, ## red
fgGreen, ## green
....
Likewise with other cases:
can nimsuggest be used for that?
how can I use nimsuggest ON THE COMMAND LINE ? (nimsuggest integration sublimetext (with nimlime) has been broken on OSX for a while; plus, I really need it to work on command line)
The old description is still available -- I started with that one years ago.
https://nim-lang.org/docs/idetools.html
List of recent commands you get if you launch nimsuggest like
$ nimsuggest --stdin board.nim
Hint: used config file '/home/stefan/Nim/config/nim.cfg' [Conf]
Hint: used config file '/home/stefan/nim-chess4/nim.cfg' [Conf]
usage: sug|con|def|use|dus|chk|mod|highlight|outline|known file.nim[;dirtyfile.nim]:line:col
type 'quit' to quit
type 'debug' to toggle debug mode on/off
type 'terse' to toggle terse mode on/off
Unfortunately not for all options it is clear what they mean, I had to ask Araq some years ago for it, but can not really remember details. But NimSuggest generally works fine and reliable, I am using it in my NEd editor for years. Well, when syntax is too wrong it may crash, for example when I load a Ruby file to convert it to Nim it may crash. I had a private local version of NEd which even did syntax highlighting based on nimsuggest, was working fine and nice, but CPU load was high, so I am not using that, as plain regexp highlighting offered by GtkSourceView is not bad.
But what about something like fgGreen that's public, yet doesn't show a * next to it?
Search using a regex, something like: enum(.+)fgGreen (untested). You could easily write a command-line utility that makes searching for this super easy.
Search using a regex, something like: enum(.+)fgGreen (untested). You could easily write a command-line utility that makes searching for this super easy.
I very highly doubt the easy part in combination with robust. That would require a full nim parser to understand comments, to understand where a type section ends, etc.
type
ForegroundColor1* = enum ## terminal's foreground colors
fgBlack = 30, ## black: don't confuse with fgGreen
echo "fgGreen"
proc bar():auto=
var fgGreen = 1
type
ForegroundColor2* = enum
fgGreen # <<<<<<<<<<<<< HERE IT IS, not the other 4 false positives
I think nimsuggest must grow some nice command line features. It's simple to do and you get a precise analysis not some whacky regex stuff.
couldn't agree more. Moved discussion to https://github.com/nim-lang/Nim/issues/8747