nim-lang / vscode-nim

A VS Code plugin for the Nim language
Other
63 stars 5 forks source link

Plugin stops detecting compiler flags after changing source files #54

Closed Spirarel closed 3 months ago

Spirarel commented 3 months ago

Here's a small example

include prelude

type GraphNode[T] = ref object
  value: T
  neighbors: seq[GraphNode[T]]

iterator items[T](graphNode: GraphNode[T]): GraphNode[T] =
  var
    s = @[graphNode]
    seen = initHashSet[GraphNode[T]]()
    curr: GraphNode[T]
  while s.len > 0:
    curr = s.pop
    yield curr
    seen.incl curr
    for e in curr.neighbors:
      if e notin seen:
        s.add e

let nodes = GraphNode[int](value: 1, neighbors: @[GraphNode[int](value: 2, neighbors: @[])])

for i in nodes:
  echo i.value

compile with -d:nimPreviewHashRef

Restarting vscode and building on save. The code compiles and runs, there are no problems highlighted:

Screenshot 2024-03-22 at 8 56 27 AM

Add a few newlines to the end and build & run again. The code compiles and runs fine, but the plugin shows problems:

Screenshot 2024-03-22 at 8 57 01 AM

This greatly limits the plugin's usefulness.


extension: v0.9.0 vscode: 1.87.2 nim: 2.0.2

jmgomez commented 3 months ago

Sounds like the issue is that nimsuggest doesnt know about -d:nimPreviewHashRef. Create a config.nims and --d:nimPreviewHashRef to it Reopen if it doenst fix it.

Spirarel commented 3 months ago

Hmm I added this file with the entry to the directory; it's getting picked up by the build task, but the plugin is still showing issues. Does the extension require extra configuration?

jmgomez commented 3 months ago

No, it doesnt require extra configuration. Can you share your file structure? config.nims should be near the entry point

Spirarel commented 2 months ago

Essentially flat,

Screenshot 2024-03-31 at 6 11 26 PM Screenshot 2024-03-31 at 6 12 05 PM
jmgomez commented 2 months ago

I mean the actual files with a minimal repro