renpy / vscode-language-renpy

Ren'Py extension for Visual Studio Code
Other
107 stars 22 forks source link

[Feature] Support for new _ren.py format used in Renpy 8 #342

Open Tristimdorion opened 1 year ago

Tristimdorion commented 1 year ago

All objects defined in _ren.py files are not recognized by the code analysis, so IntelliSense and autocomplete won't work for anything defined in these files. Could this be resolved by treating _ren.py files the same as .rpy?

duckdoom4 commented 1 year ago

Thanks for the suggestion. I'll have a look at the renpy 8 documentation on this file type and see what I can do. I'm not sure if vscode will allow me to override the default python extensions for this specific file only.

In the meantime, you can simply force this file to be treated as renpy by clicking the 'file language' button in the status bar and selecting the Renpy language extension

duckdoom4 commented 1 year ago

So reading up on the documentation, it seems that *_ren.py files are basically python files, with some doc strings that 'inject' renpy code.

Assuming this is the case and no renpy code is allowed outside of these doc strings; I could add an injection grammar, that adds renpy syntax highlighting in docstrings that start with """renpy. This grammar would be injected into the default python extensions you use for .py files

duckdoom4 commented 1 year ago

This will be added in the next update. I'll let you know when a new update will be released

Tristimdorion commented 1 year ago

I'm not looking for syntax highlighting in the _ren.py file (python extension do that perfectly), what would be nice if the objects in the _ren.py files would be available in the .rpy files, giving autocomplete and intellisense in the renpy files, I'm guessing this is done in the static parser that goes over the rpy files to find classes, so adding these files to the 'parser' should add this for usage in the renpy files? Right?

duckdoom4 commented 1 year ago

What I added was syntax highlighting for the renpy code that is injected: image

If you're looking for any other features you'll have to wait. (Probably quite a while)

We don't currently have a parser, not even for the renpy files. The way it's done currently, is through the navigation.json file that is produced by the renpy SDK when you compile a project.

I'm currently working on a fully fledged parser, but it will take a while before it's complete. See #335 for more info

Tristimdorion commented 1 year ago

Just had time to look this over, the _ren.py info is contained in the navigation.json file, it just isn't picked up by the extension.