DragonKnightOfBreeze / Paradox-Language-Support

IDEA Plugin: Paradox Language Support.
https://windea.icu/Paradox-Language-Support
MIT License
37 stars 4 forks source link

Inline script syntax highlighting inside parameter values for triggers/modifiers etc. #27

Closed adriangaro closed 1 year ago

adriangaro commented 1 year ago

Would it be possible to enhance inline scripts support to syntax highlight inside parameters?

If not automatically, would be neat if some kind of convention could be used to highlight type of parameter, something along the lines (just pseudocode of comment annotations inside the inline):

# $param1$ - trigger
# $param2$ - effect
# $param3$ - boolean (aka yes/no)
# $param4$ - number
# $param5$ - enum[value1, value2, ...]

Perhaps, if somehow could hint at other datatypes the plugin recognized scripted_trigger modifier resource etc would be a big boon in the use of inlines.

Some examples on how i use inlines, where triggers might be passed to the underlying inline:

inline_script = {
  script = jobs/inline_evolved_politician
  count = 1
  mult = 1
  display = with_desc
  trigger = "
     owner = { has_active_tradition = tr_my_tradition }
  "
}

where the $trigger$ is used as such in the inline itself (warning nested inlines):

# jobs/inline_evolved_politician

inline_script = { # Politician
    script = jobs/inline_evolved_job
    trigger = "
        exists = owner

        $trigger$

        owner = {
            is_regular_empire = yes
            is_megacorp = no
        }

    "
    job = politician
    count = $count$
    mult = $mult$
    display = $display$
}
... # vastly longer inline switching for executives etc

Another example for passing modifiers (and an ai_weight sections, if we can hint it is an script_value like section) to the inside of an inline:

inline_script = {
  script = policies/inline_evolved_ethic_option
  ethic = capitalism
  option = tec_competitive_A
  flag = tec_competitive_A
  potential = ""
  valid = "tec_is_dystopian_empire = no"
  modifier = "tec_competitive_A_modifier" 
  extra_modifier = "
      tec_hired_job_trade_add = 1
      pop_lifestyle_trade_mult = 0.25
  "
  extra_modifier_fanatic = "
      tec_hired_job_trade_add = 2
      pop_lifestyle_trade_mult = 0.50               
  "
  ai_weight = "
      factor = 1
      modifier = {
          factor = 10
          OR = {
              has_valid_civic = civic_tec_regular_corporate_politics
          }
      }
  "
}

PS: Found recently the plugin and it is amazing compared to the VSCode one. Kudos!

DragonKnightOfBreeze commented 1 year ago

Until latest plugin version 1.0.6, for script parameter value (including inline script parameter value), advanced language features (e.g. code completion, code highlighting) can be provided, if and only it's used as a entire script expression ($PARAM$, not PREFIX_$PARAM$) and the CWT configs of this script expression can be inferred, with no conflictions. You may check this feature by open one of the script files under common/traits.

For other conditions, like:

PS: Please try not to use such a tricky syntax...

DragonKnightOfBreeze commented 1 year ago

Implemented for parameters as (quoted) full property values and values by Language Injection.