Skip to content

Add Definition Files for Steamodded - #399

Merged
Aurelius7309 merged 89 commits into
mainfrom
lsp_definitions
Mar 1, 2025
Merged

Add Definition Files for Steamodded#399
Aurelius7309 merged 89 commits into
mainfrom
lsp_definitions

Conversation

@GauntletGames-2086

@GauntletGames-2086 GauntletGames-2086 commented Jan 12, 2025

Copy link
Copy Markdown
Member

Currently, Steamodded is not written in a way that allows you to comfortably run Lua LSP. A massive majority of functions do not have any indications of what they do besides name along with lacking any typing on their parameters. the LSP fails completely at finding API functions since they're either not defined in the workspace itself or are created inside tables which the LSP doesn't recognize. Lower-end computers may also run into performance issues if they throw the whole repo + Balatro + any mods into the workspace.

These definition files are the fix. The files are picked up by the LSP allowing auto-complete during object creation, typing for SMODS function parameters, and any additional warning (e.x. deprecated) required. Ideally with these files already set up, keeping them up-to-date with the repo is relatively simple and mostly low-maintenance.

How to Set Up / Test

  • Ensure that this branch (especially the lsp_def folder) is downloaded.
  • Have Lua LSP running on your preferred IDE/Emac
    • This is usually through downloading the "Lua" extension or add-on. This may vary.
  • Put a .luarc.json settings file into your directory.
  • Add Steamodded into to the workspace via the code below:
  {
    "workspace.library": [
      "path\\to\\Steamodded\\lsp_def\\folder",
      "path\\to\\Balatro\\Source\\folder", // Suggested, vast majority of vanilla function and classes are not fully annotated for the purpose of this PR
      "path\\to\\love2d\\annotation\\folder" // Suggested, LÖVE has it's own annotations to download. https://github.com/LuaCATS/love2d
    ],
  }
  • These are some additional suggested LSP settings. Some diagnostic warnings are generally unavoidable and very spammy, due to how Balatro and SMODS is written:
{
  "diagnostics.disable": [
      "undefined-global",
      "lowercase-global",
      "need-check-nil",
      "duplicate-set-field",
      "inject-field",
      "undefined-field"
  ],
  "runtime.version": "LuaJIT",
  "type.weakUnionCheck": true,
  "type.weakNilCheck": true
}

This should make the definition files inside lsp_def a part of the workspace, making any .lua file have autocomplete for Steamodded params/functions that have been added into lsp_def.

Currently written files:

Classes:

  • GameObject
  • Center
  • Joker
  • Consumable
  • Voucher
  • Booster
  • Back
  • Enhancement
  • Blind
  • Atlas
  • Achievement
  • Challenge
  • ObjectType
  • ConsumableType
  • DeckSkin
  • Edition
  • Keybind
  • Language
  • PokerHand
  • Rank
  • Suit
  • Rarity
  • Seal
  • Shader
  • Sound
  • Stake
  • Sticker
  • Tag
  • UndiscoveredSprite

Other

  • Core/Loader
  • Utils
  • Overrides/Edited Vanilla Functions. Specifically, any function present in Balatro that Steamodded adds args to (e.x. generate_card_UI, poll_edition, etc.). This is to ensure that mod devs don't run into errors from function params going missing because the vanilla code is heavily modified.
  • UI (ui.lua file specifically)

Note that these completions may still be missing fields tied to their classes, or have incomplete/missing descriptions.

@GauntletGames-2086 GauntletGames-2086 added the enhancement New feature or request label Jan 12, 2025
@GauntletGames-2086 GauntletGames-2086 self-assigned this Jan 12, 2025
@GauntletGames-2086 GauntletGames-2086 changed the title Add Definition Files for Steamodded Functions/Parameters Add Definition Files for Steamodded Jan 12, 2025
Comment thread lsp_def/utils.lua Outdated
Comment thread lsp_def/utils.lua Outdated

@Aurelius7309 Aurelius7309 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good i totally checked everything no cap frfr

@Aurelius7309
Aurelius7309 merged commit a2915ad into main Mar 1, 2025
@GauntletGames-2086
GauntletGames-2086 deleted the lsp_definitions branch March 2, 2025 00:38
@CraftedCart

Copy link
Copy Markdown

Oh heh, I guess if you're providing type definitions for vanilla stuff to, I might drop what I have in case it helps y'all
It's not much, but I have a handful of stuff here https://gitlab.com/CraftedCart/jimbos_metrics/-/blob/master/src/meta/balatro_meta.lua?ref_type=heads

@GauntletGames-2086

Copy link
Copy Markdown
Member Author

Oh heh, I guess if you're providing type definitions for vanilla stuff to, I might drop what I have in case it helps y'all It's not much, but I have a handful of stuff here https://gitlab.com/CraftedCart/jimbos_metrics/-/blob/master/src/meta/balatro_meta.lua?ref_type=heads

Looked through it, I already have a general structure idea but this also has a ton of the Game class globals annotated which is great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants