Code editor: code completion (jedi optional) - #298
enriquevelmai wants to merge 1 commit into
Conversation
New nxt_editor.completion package (context / model / sources / hosts /
controller / popup). Completes Python code, the implicit nxt runtime
globals (STAGE, self, nxt_path, ...), host modules before they are
imported (maya.cmds, pyfbsdk, pymxs, unreal) and ${} tokens (node paths
and attribute names from the stage model). Uses jedi when installed
(pip install nxt-editor[completion]) and falls back to keywords,
builtins and buffer identifiers otherwise. Ctrl+Space requests it
explicitly; Tab/Enter accept, Esc dismisses.
|
I've been itching for code completion in NXT for a WHILE now. I'll definitely give this a test today. |
|
Great, thanks for trying it. A few notes to get the most out of it: Standalone pip install -e . # from this branch
pip install jedi # optional, enables the rich completion
nxt uiWithout jedi it still works, but only offers keywords, builtins, nxt runtime globals and names already in the buffer. In Maya mayapy -m pip install jedior, if you use the module folder from the release zip, just drop the What to try
If it misbehaves, the interesting bits to report are the DCC + python version and whether |
|
works well so far! I have noticed a few things.
Overall great work. We'll be cherry picking this for our pipeline's custom build of nxt-editor. |
|
Thanks for the PR. We have a version of this functioning, so we will need to test this PR against the new release we plan on creating before we accept this PR. We will get back to this asap. |
Adds a completion popup to the code editor, as a small MVC package
nxt_editor.completion:pip install nxt-editor[completion]). Without jedi it falls back to keywords, builtins and identifiers already in the buffer, so nothing changes for existing installs.STAGE,self,nxt_path,ExitNode,ExitGraph… complete as they do inside a compute, and liveSTAGE/selfare picked up from the runtime layer console after a run.cmds,mel,om,pm(Maya),pyfbsdk(MotionBuilder),pymxs(3ds Max),unrealcomplete before the import is typed. Host is detected fromNXT_DCCor by probing imports; adding a DCC is one small subclass inhosts.py. Dynamically populated modules likemaya.cmdsuse a runtimedir()since jedi only sees them statically.file::/path::/contents::prefixes.Behaviour: pops while typing (debounced for the jedi path),
Ctrl+Spaceforces it,Tab/Enteraccept,Escdismisses, arrows navigate. The popup is a plain child of the viewport so it never steals focus. Tab/Enter are only claimed while the popup is visible; the indent / new line actions are untouched otherwise.Tokens are replaced by same-length string literals before handing the buffer to jedi so line/column positions stay valid. parso's on-disk cache is disabled because it collides across DCC python versions.