<@U02TSJJT9DJ>’s VS Code plugin got my gears spinn...
# general
b
@wide-midnight-78598’s VS Code plugin got my gears spinning VERY hard. I completely neglected all obligations until I could get this PoC for a Pants
BUILD
file LSP. Still hand-waivey, but 🎉
🤯 3
🤩 3
⚙️ 1
It's actually quite simple: • Extend Pyright as an LSP server, with the main customization points just disabling incorrect features (like auto-import) • Have Pants generate
__builtins__.pyi
containing a definition for each target, CAOF, and object (Haven't done, the PoC just hand-wrote it for
python_sources
) • VS Code extension to wire it up
It's not perfect by any means. The biggest irk to me will be that builtins are registered definitions of
BUILD
, so it'll try and suggest
str
and
dict
.
Also, still need to figure out macros: • Tell Pyright about them for builtins sake I think if we came up with a special extension for them, linting/LSPing them wouldn't collide with Python
h
Also, still need to figure out macros:
I think this would be https://github.com/pantsbuild/pants/issues/14832
b
How so?
For macros definitions in
BUILD
files, I was thinking of just inlining them into the builtins generated pyi
h
That PR will result in macros integrating into
help
, so we can export it to
__builtins__
. Same with our special objects like
parametrize()
b
Oh sorry, by macros I meant
build_file_prelude_globs
h
Ah yeah, rest of the thread gets into how to handle those
🤔 1
b
I'd love if
build_file_prelude_globs
weren't preluded, but were collected and things marked for re-exposing are done
w
Neglect FTW!
🙌 2