langserver icon indicating copy to clipboard operation
langserver copied to clipboard

Suggestion doesn't work in templates defined outside the file

Open faldor20 opened this issue 2 years ago • 2 comments

When doing a suggestion in a template defined outside a file it doesn't suggest correctly. mainFile.nim

import other

type TestData* = object
  testVal*:int

var state=TestData(testVal:100)

when isMainModule:
  echo("Hello, World!")

template template2*(blk: untyped): untyped =
  proc template2*()  =
    blk

proc procTest():int =
  #This works fine
  let otherState=state
  template2():
    let a=otherState.testVal
  template_outside():
    let a=otherState.testVal

  return state.testVal+1 


template_outside():
  #This doesn't complete correctly
  let a=state.testVal

other.nim

template template_outside*(blk: untyped): untyped =
  proc app_main*()  =
    blk

When inside template2(): state. provides the appropriate completion state.testVal When inside template_outside completion doesn't work for state. or for otherState. the completion list simply shows all symbols image image

faldor20 avatar Jun 17 '23 06:06 faldor20

This sounds more like something to be reported in Nim repo as it is more likely nimsuggest bug/limitaiton.

yyoncho avatar Jun 17 '23 07:06 yyoncho

I thought I'd start here, but I'll report it there too

faldor20 avatar Jun 17 '23 08:06 faldor20