Skip to content

Add scopes for function and variable references #149

Closed

Description

From Gregory (@chmln) on April 15, 2016 20:18

  • VSCode Version: 1.0.0-insider
  • OS Version: Windows 10

Steps to Reproduce:

  1. Open any js file with abundant variables and functions
  2. Compare with any other popular editor e.g. sublime, atom, brackets, etc

VS Code is a fantastic editor. However, for an editor that accentuates support for JavaScript, the syntax highlighting is less than sub-par.

To illustrate, here's VS Code and Sublime using the same color scheme:
vsc_
subl3

The color scheme isn't at fault since the default (dark+) theme is not much better
vsc

Here's the code in screenshot:

init = function () {

        navigationCurrentMonth.className = 'flatpickr-current-month';
        calendarContainer.className = 'flatpickr-calendar';
        calendar.className = "flatpickr-days";

        instanceConfig = instanceConfig || {};

        self.config = {};
        self.element = element;

        for (var config in self.defaultConfig)
            self.config[config] =
                instanceConfig[config] ||
                self.element.dataset&&self.element.dataset[config.toLowerCase()] ||
                self.element.getAttribute("data-"+config)||
                self.defaultConfig[config];


        self.input = (self.config.wrap) ? element.querySelector("[data-input]") : element;    

        if(self.config.defaultDate){
            self.config.defaultDate = uDate(self.config.defaultDate);
        }

        if ( self.input.value || self.config.defaultDate )
            self.selectedDateObj = uDate(self.config.defaultDate||self.input.value);

       self.config.minDate =
            uDate(self.config.minDate === "today" ? new Date() : self.config.minDate, true);

       self.config.maxDate = uDate(self.config.maxDate, true);

        self.jumpToDate(self.selectedDateObj||self.config.minDate||currentDate);

        wrap();        
        buildCalendar();
        bind();

        if (!self.config.noCalendar)
            updateValue();
    };

Significant and absolutely necessary enhancements can be brought in by highlighting:

  • Variables
  • Function names
  • Methods

Copied from original issue: microsoft/vscode#5361

Activity

  1. aeschli commented on Apr 21, 2016

    @aeschli
    Author

    The build-in default themes do - by design- not highlight variable, method and function references.
    The dark/light theme colorize however declarations.

    Gregory (@chmln) Which custom theme do you use?

  2. aeschli commented on Apr 21, 2016

    @aeschli
    Author

    From Gregory (@chmln) on April 20, 2016 21:12

    Which custom theme to you use?

    One Dark

    I have tried all the popular color themes, and not a single one has colored variables, methods, etc.

    Logically, that can be explained by two scenarios:

    • It is impossible to color variables, methods, and function references
    • All the color scheme authors are closet notepad fans
  3. aeschli commented on Apr 21, 2016

    @aeschli
    Author

    From Gregory (@chmln) on April 20, 2016 21:12

    1
    2
    3
    5
    4

  4. aeschli commented on Apr 21, 2016

    @aeschli
    Author

    From Daniel Imms (@Tyriar) on April 20, 2016 21:51

    The root issue here is that https://github.com/Microsoft/TypeScript-TmLanguage does not scope variables and method calls.

  5. aeschli commented on Apr 21, 2016

    @aeschli
    Author

    From Gregory (@chmln) on April 20, 2016 22:2

    That explains it.
    I see issues like #72 so I surely can't be the first one to notice those shortcomings.

  6. aeschli commented on Apr 21, 2016

    @aeschli
    Author

    Looking at Atom JS grammar it seems they use the support.function scope for function references.
    For variable references it's variables.other.object.
    We would still need a scope that stands for just the variable declaration.
    Moving this to the TM/JS grammar team for consideration. I personally think we should stick to what we have.

  7. gaui commented on May 15, 2016

    @gaui

    👍 I was shocked to see how poor JavaScript syntax highlighting is compared to Sublime and Atom. Hope this gets taken care of.

  8. changed the title [-]JavaScript syntax highlighting[/-] [+]Add scopes for function and variable references[/+] on Jun 16, 2016
  9. adamreisnz commented on Jun 22, 2016

    @adamreisnz

    It was indeed rather shocking to see the sub-par syntax highlighting for typescript when compared to javascript.

    I might add that syntax highlighting in Atom for TypeScript files is bad too, as the atom-typescript package uses the grammar files from this repository. As such, comparing .ts code to .js code results in something like this (ignore the color differences, just see how much more detail there is):

    TS:
    image

    JS:
    image

    Over the past few months, syntax highlighting in the language-javascript package has improved significantly, with good support for ES6 features and much improved highlighting of variables, properties, methods calls, etc.

    Maybe it's possible to convert/copy some of the improved grammar rules from JS and use them for TS as well?

  10. wclr commented on Aug 21, 2016

    @wclr

    +1

  11. glen-84 commented on Aug 21, 2016

    @glen-84

    Renamed in favour of (@whitecolor) Please don't post +1 comments. Use reactions instead.

  12. sheetalkamat commented on Sep 27, 2016

    @sheetalkamat
    Member

    Fixed with #270

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

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions