Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Definition Files for Steamodded #399

Draft
wants to merge 37 commits into
base: main
Choose a base branch
from
Draft

Conversation

GauntletGames-2086
Copy link
Collaborator

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

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 the lua_def folder (or this whole branch) is downloaded.
  • Have Lua LSP running on your preferred IDE/Emac
    • For VSCode, download and enable the Lua extension.
    • For Neovim, ensure that neovim/nvim-lspconfig add-on (or equivalent) is installed and configured to run the lua_ls server.
    • For the rest, idk just look it up or something.
  • Create a directory with a .lua file and .luarc.json settings file for the lua LSP.
    • Required code code is the minimum:
    {
      "workspace.library": ["path\\to\\Steamodded\\lsp_def\\folder"],
    }
    • These are some additonal suggested diagnostic warns to disable. These are generally unavoidable if you have the Balatro source directory and/or SMODS lsp_def folders in this directory:
    {
      "workspace.disable": [
          "undefined-global",
          "lowercase-global",
          "need-check-nil",
          "duplicate-set-field",
          "inject-field",
          "undefined-field"
      ]
    }

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
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.

1 participant