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

CoffeeScript Syntax Highlighting #3011

Closed
marcelgerber opened this issue Dec 29, 2014 · 5 comments
Closed

CoffeeScript Syntax Highlighting #3011

marcelgerber opened this issue Dec 29, 2014 · 5 comments

Comments

@marcelgerber
Copy link
Contributor

(adobe/brackets#9797) (I don't know anything about CoffeeScript, I'm just cross-filing this issue)

Apparently, the CoffeeScript syntax highlight in CM is really basic. Would be cool if you could improve it.

Code:

app.getUrlParams = (url = location.href)->
  args = {}
  query = url.substr(url.lastIndexOf('?')+1)
  pairs = query.split("&")
  for item in pairs
    pos = item.indexOf '='
    if pos == -1 then continue
    key = item.substring 0 , pos
    value = item.substring pos + 1
    args[key] = decodeURIComponent value
  return args

app.isLogined = ->
  if appConfig.userName then return true else return false

@View =
  render : (id,datta,tmpl_id)->
    tmpl_id = if !tmpl_id then id + '-template' else tmpl_id
    tmpl = $("##{tmpl_id}").html()
    html = _.template(tmpl,data)
    $("##{id}").html html

  info : (selector,message,type) ->
    if type
      $(selector).show().removeClass(alertType.join(' ')).addClass("alert-#{type}").html(message)
    else
      $(selector).show().removeClass(alertType.join(' ')).html(message)

  hideInfo : (selector)->
    $(selector).hide()

CodeMirror:
image

Sublime Text 3:
image

@marijnh
Copy link
Member

marijnh commented Dec 29, 2014

The CoffeeScript mode was contributed, and isn't something I personally wrote. I'm aware that it is not the most high-quality mode, but fundamentally improving or rewriting it is not something that's covered under Adobe's support contract. If you have very specific, clearly defined issues feel free to note them, and I can take a look to see how easy they are to implement.

@marcelgerber
Copy link
Contributor Author

This issue was mostly meant as kind of a "tracking" issue, so if any contributor wants to improve something in CM, he could take a look at the CoffeeScript code.
For specific issues, better ask @mingzepeng, @Owumaro or @dzannotti.

Things outstanding to me (while comparing the screenshot with GitHubs syntax highlight):

  • No highlighting of variables
  • No highlight for ->
  • No highlight for classes, like @View
  • No highlight for for ... *in*

@marcelgerber
Copy link
Contributor Author

Oh, I actually just noticed that variables, -> and classes are actually given the correct classes, but these are all black in the default stylesheet, which makes syntax highlighting pretty much senseless.
I wonder if we should change cm-variable to cm-def, which is the class the JS mode applies for variables (but why?).

So the only issue that still exists is the missing highlight of for ... *in*.

@marijnh
Copy link
Member

marijnh commented Jan 1, 2015

I wonder if we should change cm-variable to cm-def, which is the class the JS mode applies for variables (but why?).

It only does so for variable definitions. (It also styles local variables as variable-2, which requires more precise parsing than the CoffeeScript mode does.)

@marijnh
Copy link
Member

marijnh commented Sep 2, 2015

There were some improvements to the CoffeeScript mode recently. They solved the low-hanging fruit issues, such as property highlighting. Please open specific new issues for other problems you find.

@marijnh marijnh closed this as completed Sep 2, 2015
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

2 participants