Coder Social home page Coder Social logo

renpy / vscode-language-renpy Goto Github PK

View Code? Open in Web Editor NEW
90.0 8.0 19.0 1.98 MB

Ren'Py extension for Visual Studio Code

License: Other

TypeScript 95.11% Python 4.89%
renpy vscode code snippets syntax-highlighting open-vsx visual-studio-code vscode-extension completion providers

vscode-language-renpy's Introduction

Ren'Py Language for Visual Studio Code

An extension that adds rich support for the Ren'Py programming language to Visual Studio Code.

  • Visual Studio Marketplace Version Visual Studio Marketplace Rating Visual Studio Marketplace Installs
  • Open VSX Version Open VSX Rating Open VSX Downloads

Snippets converted from Ren'Py language support in Atom

Feel free to contribute, fork this and send a pull request. ๐Ÿ˜„

Features

Syntax Highlighting

syntax

The syntax highlight depending on the syntax theme used. In this case One Dark Pro.

Snippets

snippets

Completion

completion

Displays a pop-up auto-complete menu with context-appropriate choices as you type your script or enter screen properties.

Document Color

colors

Displays a color block next to detected colors in your script and allows you to pick new colors with a click.

Hover

hover

Hovering over a Ren'Py or user-defined keyword will display the selected item's source file/location as well as documentation if available. Clicking the filename location will jump to that document and position.

Go To Definition

Adds support for right-click Go To Definition (F12), which will jump to the selected keyword's source.

Signature Help

Shows the documentation pop-up as you enter a function's arguments.

Diagnostics

diagnostics

Adds support for detection of issues with indentation or invalid filenames/variable names and marks them as errors or warnings in the editor.

Document Symbols

Document Symbols are displayed in the Outline window in the sidebar.

Integrate VSCode as code editor in Ren'Py (Ren'Py 7.4 and older)

Note: In Ren'py 7.5/8.0 VSCode is already included by default in the list of text editors

You can copy the Visual Studio Code.edit.py file that is available at the root of this repository to the root of your project directory. This will add VSCode (or VSCodium) to the list of text editors in Ren'Py.

Thanks To

vscode-language-renpy's People

Contributors

a2937 avatar booplicate avatar dependabot[bot] avatar duckdoom4 avatar joe69-96 avatar kilooscarsix avatar luquedaniel avatar multimokia avatar pjpollina avatar rdurfee avatar renpytom avatar seanj29 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vscode-language-renpy's Issues

Support annotations

Hello! As we're getting closer to finally being able to use Python 3+, any plans to update the regex to account for new syntax like annotations? Right now it breaks the highlighting, so can't use the extension at all.

One example:
Capture

Enhancements to rich editor support

Rich Editor Support Feature Tracking Issue:

  • docstring support for base python functions
  • docstring support for user-defined functions, methods, and classes #26
  • hover support for python and user-defined const values to quickly view them
  • semantic tokenization on the fly to update navigation.json
  • python blocks using the python linter
  • docstrings from python-package imports
  • Allow outline to be sorted using VScode's sort order, instead of forced category
  • Show init blocks in outline
  • Add highlights for labels #41
  • Add highlights for function calls
  • Add highlights for label calls
  • Add special highlighting for constants (all cap varname)
  • Add special highlighting for classnames and class constructor calls
  • Add intellisense for local variables and store variable across all files in the workspace
  • Add builtin highlighting for tags such as TODO or FIXME, etc.
  • Anything extra can be added here

[Suggestion] Allow exceptions for setting renpy vars

For some features in games, users might need to change internal renpy behaviour somewhat

image

For example these two vars must both be set, however the extension treats the _window_subtitle var as a new custom defined one rather than an existing one. A config to disable errors (or change them to warnings) for variables that are internal ones would be nice

(Basically so that _window_subtitle or other similar internal vars could be given a warning that it's an internal renpy var)

[BUG] - Defaulted persistent variables are reported as not defaulted

In the case of this persistent variable, it's defined in another file, however it seems only the current file is checked for a default statement on the persistent variable.
image

I'm unsure how to change it without a large change which may be rather performance intensive due to needing to look over all files in the workspace, but I am unfamiliar with the extensions api so there might be a better way to go about it than I know

Add ` delimiter for strings

Ren'Py supports the use of `...` for strings. This extension does not highlight text like this correctly as a string, however.

[Feature Request] Ability to fold if statements, menu etc in the editor

Hi there,
I recently upgraded from 1.1.0 to 2.0.5.
Overall it's way nicer, but I miss the ability to fold almost everything that was indented.
For reference, here is a picture from 1.1.0
1 1 0
and one from 2.0.5
2 0 5
In 2.0.5 I can only fold the label and nothing else in it.
I gave it a shot and dug through the code a little. As I understand it (keep in mind that I do not understand typescript or regex), the strings that the extension is using for folding are in the const rxFolding variable. I changed it to this,
const rxFolding = /^\s*(screen|label|class|layeredimage|def|init|if|elif|else|menu)\s+([a-zA-Z0-9_.]+)\((.*)\)\s*:|^\s*(screen|label|class|layeredimage|def|init|if|elif|else|menu)\s+([a-zA-Z0-9_.]+)\s*:/; just to mess around and now it gives me this:
Capture
The ifs are found and it misses the else and the menu. I think it has something to do with the regular expression, but I cannot pinpoint it.

I don't expect it to be fixed tbh, but could someone that knows what they're doing please just point me to the right direction (assuming it's feasible)?

Bundle using esbuild/webpack

The documentation recommends to bundle the extension. This reduces loading time and increases performance by minifying the source code.

Let's look into getting this setup. I have experience with webpack, but if esbuild is preferred that can be used.

Do we really need the folding provider?

While working on PR #68, the following question has come to my mind: Do we really need to apply our own rules for folding?

According to the VSCode documentation, there are two ways to define holding:

In VS Code, folding is defined either indentation-based, or defined by contributed folding range providers:

  • Indentation-based folding with markers: If no folding range provider is available for the given language or if the user has set editor.foldingStrategy to indentation, indentation-based folding is used. A folding region starts when a line has a smaller indent than one or more following lines and ends when there is a line with the same or smaller indent. Empty lines are ignored. Additionally, the language configuration can define start and end markers. These are defined as start and end regexes in folding.markers. When matching lines are found, a folding range inside the pair is created. Folding markers must be non-empty and typically look like //#region and //#endregion.
  • Language server folding: The Language Server responds to the textDocument/foldingRange request with a list of folding ranges, and VS Code would render the ranges as folding markers. Learn more about the folding support in Language Server Protocol at the Programmatic Language Feature topic.

Since both Python and Ren'Py use indentation in the code blocks, what is the need to define it through the provider?

Indentation

imagen
imagen
imagen

Provider

imagen
imagen
imagen

What is your opinion about this?

[BUG] - Default warnings on classes and functions

image

I've noticed this also happens on functions, but I've also seen that function highlighting is inconsistent.

For example:
image

Which is a function defined in another file but isn't recognized even after a compile via the extension. (This also applies to constants and variables defined in python blocks)

Also a small feature request, mainly the classes/functions are the issue as they can't be defaulted. As well would it be possible to provide semantic tokenization for func calls or class constructs? Would really help with readability.

Settings: "Renpy Warn On" radio button toggles don't refresh open file(s)

Settings: "Renpy Warn On" radio button toggles (On or Off) don't take effect until manual file(s) close/load or via VSC restart

Possible VSC technical limitation but if not it would be fantastic if the settings took immediate effect OR otherwise the code calls to bring up the VSC reload request info box like some theme settings currently do:
image

[Bug] - class at the end of init python block isn't getting terminated correctly

First of all, sorry for my bad terminology. That really isn't my forte. But now onto the issue

Steps to reproduce are pretty straight forward. All you need are two init python blocks and a class like so:
image

Now if you try to hide the class' content, second init statement gets hidden as well
image

Same thing happens if you use a function instead of a class.

[Feature Request] - Character expressions have their own scope

Making a request to give expressions used in dialogue their own tm scope or semantic highlighing so they can be a consistent color.

For example:
image

Which uses the normal number colors and text color, which makes it a little awkward, especially when expression codes containing something like 1l get highlighted as a number as well.
image

Looking at the scopes, expression codes are handled under source.renpy, so they have no scope associated. Having them on their own scope which could provide custom highlighting -- or a point to change it via custom textmate rules -- would be super handy!

Support python 3 syntax

Given the release of renpy 8 nightly, we now have python 3 at our disposal meaning some new syntaxes to take care of

#71 already covers type annotations, but there's also some more such as f-strings, among others.

Would love to see this supported

Is this ready?

I've been using vscode-language-renpy exclusively when I edit Ren'Py, both as part of games and as part of the engine. It's the best tool for edting Ren'Py that I know of.

Is this extension mature enough to be installed automatically by Ren'Py? What I'm thinking is having Ren'Py automatically download vs code from the Microsoft servers, then tell code to install vscode-language-renpy, and then executing code to edit a project. If that makes sense, then I'd hope to add this is 7.5/8.0.

[Suggestion] Clear existing *rpyc button

Dunno if it's in the scope of what this plugin is going for but an easy button to clear out old rpyc files since they're hidden by default would be nice. In bash its as simple as running find . -type f -name '*.rpyc' -delete, which on one hand makes it kinda redundant but hey, why not?

Running renpy through the editor

Edit: As stated in the comments below, it isn't quite supported. I'd like to look into the possibility of running renpy directly from VS Code.
Maybe with some help from the Ren'Py team we could even get debugging to work directly from VSCode.

This would require some back and forth with the Ren'Py team, as I'm not sure if this is something they agree with. This might cause issues because it would require going around the launcher.

So I saw some code that allows renpy to execute directly.
How does this work/ what is is for exactly? Might be nice to document it somewhere.

afbeelding

[BUG] - Outline provider sets all ranges to 0 and ignores user sort order

image
Despite being sorted by position, the outline provider always categorizes and only orders inners by position. I think it'd be best to avoid categorizing entirely, as with other languages as well, no explicit categories are made, the icon alone is typically the distinction for type.

Additionally, the outline provider only uses a 0 range for all blocks:
image

This isn't ideal as it means breadcrumbs have no positional data to invorm the user where they are in the document. It also means the outline is unaware of where the user is in the file.

Functions which can properly block out portions of the file for formal outline providing and potential re-use in the discussed init block handling in #76 (a system to properly handle the starts/ends of blocks is needed) could be built to help.

[Suggestion] Script Word Count Feature

Was wondering if there was any interest in adding something like other VSCode word counter extensions but specifically for Ren'Py scripts, since the more general ones count keywords, character names, etc., and Ren'Py linting only counts the project total (AFAIK). I'm willing to do it, but since I'm not personally familiar with TypeScript or extension development I wanna make sure it's feasible/desired before I start investing the time into it.

Bug when loading extensions on renpy project

An error occurs due to a negative value in semantics.js:136:74

Suggested fix check, don't pass negative value to new vscode_1.Position() function:

line 136:

            const context = i - 1 < 0 ? undefined : navigation_1.getCurrentContext(document, new vscode_1.Position(i - 1, indent_level));

Execption log message:

[2021-12-18 15:25:25.895] [exthost] [error] [LuqueDaniel.languague-renpy] provider FAILED
[2021-12-18 15:25:25.896] [exthost] [error] Error: Illegal argument: line must be non-negative
at P (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:5:1232)
at new p (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:86:17906)
at new p (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:86:17301)
at Object.getSemanticTokens (c:\Users\omega.vscode\extensions\luquedaniel.languague-renpy-2.0.4\out\semantics.js:136:74)
at Object.provideDocumentSemanticTokens (c:\Users\omega.vscode\extensions\luquedaniel.languague-renpy-2.0.4\out\extension.js:118:40)
at B.provideDocumentSemanticTokens (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:95:98728)
at c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:95:120980
at We._withAdapter (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:95:111974)
at We.$provideDocumentSemanticTokens (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:95:120958)
at t._doInvokeHandler (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:99:13802)
at t._invokeHandler (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:99:13486)
at t._receiveRequest (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:99:12097)
at t._receiveOneMessage (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:99:10826)
at c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:99:8922
at u.fire (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:66:1712)
at r.fire (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:74:18942)
at c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:114:34341
at u.fire (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:66:1712)
at r.fire (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:74:18942)
at n._receiveMessage (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:74:23523)
at c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:74:21057
at u.fire (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:66:1712)
at w.acceptChunk (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:74:15770)
at c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:74:14900
at Socket.T (c:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:114:13813)
at Socket.emit (events.js:315:20)
at addChunk (internal/streams/readable.js:309:12)
at readableAddChunk (internal/streams/readable.js:284:9)
at Socket.Readable.push (internal/streams/readable.js:223:10)
at Pipe.onStreamRead (internal/stream_base_commons.js:188:23)

Refresh images autocompletion when adding/removing files

Hi!

It appears that the autocompletion when typing scene or with is not showing the images in the images directory, not until I refresh VSCode. Then if I add/remove a file, the autocompletion remembers the completion before the modification.

Maybe I'm using it wrong. Let me know.

Thank you in advance!

[BUG] - Commands not found

Just installed the new update for the plugin and wanted to note an issue, not quite sure why it's happening though as the code looks right in how it provides them:

When trying to compile navigation data:
image

Refresh diagnostics:
image

And refreshing navigation data:
image

Additionally my tests on #21, interestingly only seemed to run from the extension host window, but loading up a general rpy file does not seem to provide any highlighting or renpy info.

Especially for the repository linked on that PR, this would be amazing if it could be fixed!

Fully Programmatic Language Features

Would anyone be interested in expanding the VS Code Ren'py language support extension into a fully programmatic Ren'py debugger with me? I am tired of not having go-to-definition, but I am fairly new to Ren'py.
References:

File icon for .rpy files? [Suggestion/Feature Request/Volunteering]

Bugs me to no end that .rpy files just use the default plaintext file icon. I could absolutely draw up a custom VSCode-style icon for Ren'Py and set it all up, all that jazz. I probably will anyway for my own personal use but I figured y'all might be interested in adding it to the main plugin. Lemme know what you think.

New 7.4 keywords are not supported.

New keywords and properties added in the 7.4 series are not supported.

For example, the blur ATL property is not colored correctly a transform:

transform chapter_transform:
    alpha 1.0
    blur None
    linear 0.10 blur 10.0

"blur" should appear the same color as the "alpha" property.

Missing collapse for variables

The fold arrow for the default and define variables is missing.
image
I've checked with the most recent version of vs (I use vscodium portable) and only one extension to make sure it's not from something else.
Thank you for this awesome extension^^

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.