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

Lua new syntax suggestion - too many things are highlighted as variables currently #1899

Closed
RheingoldRiver opened this issue Mar 14, 2019 · 4 comments

Comments

@RheingoldRiver
Copy link

I fixed this for myself with this change:

  variable:
    - match: '{{identifier}}{{function_assignment_ahead}}'
      scope: entity.name.function.lua
      pop: true

    - match: '{{identifier}}{{function_call_ahead}}'
      scope: variable.function.lua
      pop: true

    - match: '{{identifier}}'
      scope: meta.property.lua
      pop: true

The scope in the third item is by default variable.other.lua. This way most text is defaulted to the normal color, and actual function names are much more easily distinguished (behavior is also more similar to the LuaExtended).

@FichteFoll
Copy link
Collaborator

FichteFoll commented Mar 15, 2019

I agree with your assessment that coloring everything in the file, especially all variables, produces very colorful code and means you likely end up having no white text at all (which is why I modfified my color scheme not to do that).

However, from a syntax definition perspective it is correct to scope all variables as, well, variable and it's the color scheme's job to decide whether to colorize that or not. There is ongoing discussion in #1842 (comment) for example where we are trying to find a general solution that can be applied to most or all syntaxes that will also support color scheme authors with their decisions.

@RheingoldRiver
Copy link
Author

Hm, maybe the issue for me then isn't that everything is colored as a variable, but rather that there isn't a separate scope for table entries which are also functions. I tried changing my variable color to white, but it was a lot harder to read the highlighting when functions weren't highlighted. I'm not sure which scope is which but could "variable" functions be colored the same as built-in functions? Or alternatively is there another available scope that could be used to separate variables-that-are-functions from variables-that-aren't-functions for Lua?

For reference, here is a screenshot of code highlighted how I want it to look. Here is that same snippet with everything as a variable, and finally here is variables highlighted white. IMO the first one is obviously the most "correct" way to have functions distinguished from things that aren't functions.

As an aside, I use ST as my Lua IDE because I work on wikis, and the Mediawiker package is unparalleled in utility for this purpose. Maybe include Scribunto's libraries as defaults? I'm not sure how widespread this use is though

@michaelblyons
Copy link
Collaborator

michaelblyons commented Mar 15, 2019

function h.makeTogglerButtons(togglers, n)
    local tbl = {}
    tbl[1] = h.makeToggler(n, 1)
    for i, _ in ipairs(togglers) do
        if i == #togglers then
            tbl[ftb1+1] = h.makeLastToggler(n)
        else
            -- first add 1 because we already did 1 from the default bracket
            tbl[#tbl+1] = h.makeToggler(n, i + 1)
        end
    end
    return tbl
end

My slightly-tweaked Mariana looks kind of like your desired output:

Screen Shot 2019-03-15 at 8 26 45 AM

I think you need to modify your color scheme to set variable to white and then variable.function back to pink, or use variable.other for the white rule.

@RheingoldRiver
Copy link
Author

Oh thanks! I didn't realize that was possible. Yeah, this is fine as-is then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants