Giter Club home page Giter Club logo

language-haml's Introduction

language-haml

Haml language grammar for GitHub's Atom IDE.

screenshot

Supported Filetypes

  • .haml
  • .hamlc (CoffeeScript Haml)

Supported filters

You can switch to another language right in the middle of your Haml file by using a "filter":

screenshot

This Haml bundle currently supports the following filters:

  • :css
  • :coffee
  • :javascript
  • :markdown
  • :php
  • :ruby
  • :ruby2js
  • :sass
  • :scss

The Haml documentation lists the following additional filters:

  • :cdata
  • :erb
  • :escaped
  • :less
  • :plain
  • :preserve
  • :textile

To add more you can simply copy and paste one of the captures in the ruby haml.cson file and make the changes necessary to support your filter of choice:

{
  'begin': '^(\\s*)(:css)'
  'beginCaptures':
    '2':
      'name': 'entity.name.tag.haml'
  'end': '^(?! *$|\\1 )'
  'name': 'source.css.embedded.html'
  'patterns': [
    {
      'include': 'source.css'
    }
  ]
}

language-haml's People

Contributors

abe33 avatar adamrunner avatar aidistan avatar alhadis avatar anomaly256 avatar bastilian avatar cannikin avatar darrenterhune avatar doryphores avatar ezekg avatar guiruiz avatar harlemsquirrel avatar iret avatar jamieorc avatar joseramonc avatar maxbrunsfeld avatar mnquintana avatar pchaigno avatar richrace avatar romaingweb avatar schpet avatar silvenon avatar swrobel avatar weotch avatar zequez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

language-haml's Issues

Multiple #{} blocks are not highlighted correctly when separated by a comma

I have a line that uses multiple interpolation blocks e.g. #{@var}, #{@var2}

The parser takes the second # to be the start of a comment. If I remove the comma then the second block is highlighted properly. When it's highlighted incorrectly all code below it in the document is then not highlighted correctly.

screen shot 2015-05-19 at 10 01 31
screen shot 2015-05-19 at 10 01 41

Filter highlighting only works up to first linebreak

@ezekg You asked for feedback and this is the only odd thing I've noticed since the last release (0.22.2):

This :javascript filter is highlighted properly:
image

While this one isn't:
image

If I remove the new line between the first var declaration and the second, the highlighting turns back on:
image

Installation is failing

OS: Ubuntu 14.04 64 Bit

Atom Version: 0.137.0

Tried to install this extension, and got this message

gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | linux | x64
gyp http GET https://gh-contractor-zcbenz.s3.amazonaws.com/atom-shell/dist/v0.18.0/node-v0.18.0.tar.gz
gyp http 200 https://gh-contractor-zcbenz.s3.amazonaws.com/atom-shell/dist/v0.18.0/node-v0.18.0.tar.gz
gyp WARN install got an error, rolling back install
gyp ERR! install error 
gyp ERR! stack Error: read ECONNRESET
gyp ERR! stack     at errnoException (net.js:904:11)
gyp ERR! stack     at TCP.onread (net.js:558:19)
gyp ERR! System Linux 3.13.0-37-generic
gyp ERR! command "/opt/atom/resources/app/apm/node_modules/atom-package-manager/bin/node" "/opt/atom/resources/app/apm/node_modules/atom-package-manager/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "install" "--target=0.18.0" "--dist-url=https://gh-contractor-zcbenz.s3.amazonaws.com/atom-shell/dist" "--arch=x64"
gyp ERR! cwd /home/likewise-open/ZANECDEV1/karthikeyan.ak/.atom
gyp ERR! node -v v0.10.32
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok 

Pipes (for line continuation) break syntax highlighting

screen shot 2016-04-25 at 9 42 45 am

I took this screenshot with One Dark Syntax so that we'd have a common test ground. The markup:

%span.this#works-fine
%input.uh-oh{               |
  type: 'text',             |
  name: 'oh-no',            |
  title: "what's going on?" |
}                           |
%div.not-highlighted-correctly
  %span.neither-are-children
%a.having-more-brackets{ href: "fixes it" }
%span= "See?"

%span.note {                             |
  this: 'fixes the syntax highlighting'  |
}
%div= "But it will break if you try to render it."

It appears that pipe characters break the syntax highlighting. They also are highlighted differently (under my usual syntax theme, photon syntax) sometimes. Randomly they'll be white or purple, and I can't really figure out why. Also if you have an id before the attribute braces in the anchor tag above, it doesn't fix the highlighting (everything after the # is comment colored)

:scss filter

:scss filter is not recognised and breaks syntax highlighting.

As a best-effort fix, you could make :scss be synonymous with :css. It should also be possible to get actual scss highlighting, which might be worth the effort.

Mixing text and variables hightlighting

I've discovered that you can mix text and variables using Ruby/Haml interpolation like this:

%p Lorem ipsum #{variable} dolor sit amet

I think it would be nice if it were in other color and not white like it is right now:

screen shot 2015-12-07 at 22 36 33

Maybe I'm wrong and I shouldn't be doing that because it's not a good practice or something, so, what do you think guys?

Preserve indentation on newline

When a newline is created in a haml file, the cursor starts with no indentation. It would be nice if the indentation was at least as far as the previous line.

In Atom:

haml indentation bug

In Sublime:

haml indentation sublime

Thanks for the package!

Package.loadSettings is deprecated.

Store package settings files in the settings/ directory instead of scoped-properties/

Package.loadSettings (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app/src/package.js:565:9)
<unknown> (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app/src/package.js:187:43)

Support for :php filter

I use grunt-haml-php that insert a new filter :php, is possible to integrate in this package?

IE conditional comments make nested code sytax-highted as comments

In our app we use some conditional html tags for versions of IE. In the 23.4 version of this plugin I was able to successfully see all correct syntax highlighting, but in the latest version, and at least 23.9, I see everything that's indented in the IE conditional comment as being read by language-haml as a comment.

This makes sense, and is "correct" as the body of the code is technically within the comment, but I don't want that behavior. Perhaps there is a way to ignore these type of IE comments? I will paste screenshots.

ie-comment-highlighting-bug

Thank you! :)

Over-Aggressive Indentation

Trying to type multiple siblings in a row tends to create child elements instead.

Type the following:

.test
.test
.test

and you'll see it come out as:

.test
  .test
    .test

Trying to be smart about indentation might be a bit more trouble than it's worth because there's no way to tell if you want empty elements or nested elements. Even in cases with no ambiguity, such as inline content, it wants to indent everything. I'd rather have to hit the tab key myself than have to realign five tds in a row.

comment

Not working comment in hamlc

Package.loadSettings is deprecated.

Store package settings files in the settings/ directory instead of scoped-properties/

Package.loadSettings (C:\Users\uSide\AppData\Local\atom\app-0.189.0\resources\app\src\package.js:565:9)
<unknown> (C:\Users\uSide\AppData\Local\atom\app-0.189.0\resources\app\src\package.js:187:43)

Looking for new maintainer

I haven't used Atom in a quite a while now so I'm probably not the best person to keep this package up to date. Anyone out there want to take over?

Package.loadSettings is deprecated.

Store package settings files in the settings/ directory instead of scoped-properties/

Package.loadSettings (/opt/atom/share/atom/resources/app/src/package.js:539:9)
<unknown> (/opt/atom/share/atom/resources/app/src/package.js:188:43)

Can't use comment key-binding on version 0.24.4

I'm using the language-haml package to edit haml-coffeescript files in Atom 1.17.0 on my MBP running OSX 10.11.6.
I updated the package yesterday and since then the cmd-/ key binding no longer comments out lines. I used the keybinding resolver panel to make sure that it does resolve to editor:toggle-line-comments but I'm running out of ways to troubleshoot this issue, any idea ?

Thanks

Multiline

multiline code highlighting doesn't work in ruby haml.

=link_to settings_campaign_url(@campaign),
            class: active_page == "settings" ? "active" : "" do

Can't comment javascript in :javascript sections

Not sure what technical limitations you're working with, but attempting to comment javascript using cmd-/ instead prepends the usual -# instead of // to that line. Is this fixable or are you limited to having a single commenting style per filetype?

Adds 'end' when autocompleting blocks

Sorry if I'm misunderstanding something - this could turn out to just be my settings.

It seems like language-haml calls into various autocompletions from the language-ruby.

When a line ends with do, it adds a line below with end, which would be correct in Ruby but not in Haml. The same thing doesn't happen for if-statements so I'm guessing whatever override you have for those should also apply to blocks?

Syntax highlight not working on block comments

Syntax highlight is not showing block comments as comments. It happens either on html and haml comments. Eg on a haml comment:

-#
    .phones
      %ul
        - unless @professional.phone.blank?
          %li= format_phone @professional.phone
        - unless @professional.phone2.blank?
          %li= format_phone @professional.phone2

The hole block above should be shown as a comment.

Unexpected string in ruby haml.cson

I've just updated the package and now I get this one and I think I am not they only one check - atom/atom#8970

Here's a stack trace

SyntaxError: Syntax error on line 241, column 18: evalmachine.<anonymous>:1
"#\\{" "end": "\\}"
       ^^^^^
Unexpected string
  at nodeTransforms.Literal (/usr/share/atom/resources/app/node_modules/season/node_modules/cson-parser/lib/parse.js:100:15)
  at transformNode (/usr/share/atom/resources/app/node_modules/season/node_modules/cson-parser/lib/parse.js:197:12)
  at nodeTransforms.Value (/usr/share/atom/resources/app/node_modules/season/node_modules/cson-parser/lib/parse.js:79:14)
  at transformNode (/usr/share/atom/resources/app/node_modules/season/node_modules/cson-parser/lib/parse.js:197:12)
  at /usr/share/atom/resources/app/node_modules/season/node_modules/cson-parser/lib/parse.js:114:17
  at Array.reduce (native)
  at nodeTransforms.Obj (/usr/share/atom/resources/app/node_modules/season/node_modules/cson-parser/lib/parse.js:107:30)
  at transformNode (/usr/share/atom/resources/app/node_modules/season/node_modules/cson-parser/lib/parse.js:197:12)
  at nodeTransforms.Value (/usr/share/atom/resources/app/node_modules/season/node_modules/cson-parser/lib/parse.js:79:14)
  at transformNode (/usr/share/atom/resources/app/node_modules/season/node_modules/cson-parser/lib/parse.js:197:12)
  at Array.map (native)
  at nodeTransforms.Arr (/usr/share/atom/resources/app/node_modules/season/node_modules/cson-parser/lib/parse.js:104:27)
  at transformNode (/usr/share/atom/resources/app/node_modules/season/node_modules/cson-parser/lib/parse.js:197:12)
  at nodeTransforms.Value (/usr/share/atom/resources/app/node_modules/season/node_modules/cson-parser/lib/parse.js:79:14)
  at transformNode (/usr/share/atom/resources/app/node_modules/season/node_modules/cson-parser/lib/parse.js:197:12)
  at /usr/share/atom/resources/app/node_modules/season/node_modules/cson-parser/lib/parse.js:114:17
  at Array.reduce (native)
  at nodeTransforms.Obj (/usr/share/atom/resources/app/node_modules/season/node_modules/cson-parser/lib/parse.js:107:30)
  at transformNode (/usr/share/atom/resources/app/node_modules/season/node_modules/cson-parser/lib/parse.js:197:12)
  at nodeTransforms.Value (/usr/share/atom/resources/app/node_modules/season/node_modules/cson-parser/lib/parse.js:79:14)
  at transformNode (/usr/share/atom/resources/app/node_modules/season/node_modules/cson-parser/lib/parse.js:197:12)
  at /usr/share/atom/resources/app/node_modules/season/node_modules/cson-parser/lib/parse.js:114:17
  at Array.reduce (native)
  at nodeTransforms.Obj (/usr/share/atom/resources/app/node_modules/season/node_modules/cson-parser/lib/parse.js:107:30)
  at transformNode (/usr/share/atom/resources/app/node_modules/season/node_modules/cson-parser/lib/parse.js:197:12)
  at nodeTransforms.Value (/usr/share/atom/resources/app/node_modules/season/node_modules/cson-parser/lib/parse.js:79:14)
  at transformNode (/usr/share/atom/resources/app/node_modules/season/node_modules/cson-parser/lib/parse.js:197:12)
  at /usr/share/atom/resources/app/node_modules/season/node_modules/cson-parser/lib/parse.js:114:17
  at Array.reduce (native)
  at nodeTransforms.Obj (/usr/share/atom/resources/app/node_modules/season/node_modules/cson-parser/lib/parse.js:107:30)
  at transformNode (/usr/share/atom/resources/app/node_modules/season/node_modules/cson-parser/lib/parse.js:197:12)
  at nodeTransforms.Value (/usr/share/atom/resources/app/node_modules/season/node_modules/cson-parser/lib/parse.js:79:14)
  at transformNode (/usr/share/atom/resources/app/node_modules/season/node_modules/cson-parser/lib/parse.js:197:12)
  at nodeTransforms.Block (/usr/share/atom/resources/app/node_modules/season/node_modules/cson-parser/lib/parse.js:76:14)
  at transformNode (/usr/share/atom/resources/app/node_modules/season/node_modules/cson-parser/lib/parse.js:197:12)
  at Object.parse (/usr/share/atom/resources/app/node_modules/season/node_modules/cson-parser/lib/parse.js:203:12)
  at parseObject (/usr/share/atom/resources/app/node_modules/season/lib/cson.js:42:23)
  at parseContents (/usr/share/atom/resources/app/node_modules/season/lib/cson.js:91:16)
  at /usr/share/atom/resources/app/node_modules/season/lib/cson.js:179:24
  at FSReqWrap.oncomplete (fs.js:100:15)
  at /home/user/.atom/packages/language-haml/grammars/ruby haml.cson:1:1

Ideas ?

Commenting out grey out excess text

atom 0.209
language-haml 0.21

atom_haml_language_bug

= foo
- if link_to "Home", root_path
  %div

I believe that the - and root_path at the 2 line shouldn't be greyed when I comment out the 1st line.

ruby2js filter

I've been using atom + haml in all my rails projects for years, so am basically addicted :-)

Now i am coding more js, mostly snippets in haml, and have got Sam Ruby's excellent ruby2js to work with haml. It basically lets you write ruby syntax but it transforms it one to one to js. So ruby syntax, js semantics.

Basically i would like a ruby2js highlighting. This should not be too difficult as a :ruby filter is already supported. If you want i can try, but i suspect it's almost a one-liner.

Thanks for taking this over (if i understood right)

Fix link_to snippets

I'd like to fix the link_to snippets. Currently they are as follows:

'link_to (route)':
  'prefix': '='
  'body': '= link_to "${1:Anchor Text}", ${2:route}_url'
'link_to (url)':
  'prefix': '='
  'body': '= link_to "${1:Anchor Text}", "${2:#}"'
'link_to (wrap selected text)':
  'prefix': '='
  'body': '= link_to "Anchor text...", ${1:"${2:$0}"}'

But as you can see the prefix is the exact same for all 3 options, so the last takes precedence I think and the others don't actually do anything.

IMO the options aren't well suited to, well suit everyones needs either.

  1. link_to (route) not everyone would use the _url scheme. I personally never use that instead I use _path. I recommend we just change that to ${2:route} and let the user type it out. OR we add a 3rd ${2:route}_${3:path}`
  2. link_to (wrap selected text) would be nice if ${1:Anchor Text} was the first.
  3. Because all of these current snippets are the same we'd need to define how they are triggered by different prefixes and be sure we are not over-riding something else with them.

Thoughts?

Colors seem to be off on Atom Material Dark?

So I'm using this package along with Atom Material theme and Atom Material Dark syntax.

Seems like the colors don't color correctly on classes, ids, and other various things and it blends together too much with regular words.

image

Package.loadSettings is deprecated.

Store package settings files in the settings/ directory instead of scoped-properties/

Package.loadSettings (/Applications/Atom.app/Contents/Resources/app/src/package.js:565:9)
<unknown> (/Applications/Atom.app/Contents/Resources/app/src/package.js:187:43)

Ran into a parsing error with the following code:

Granted, this is a ridiculous line of haml, but looks like it runs into a string parsing bug somewhere near the end of the line:

screen shot 2014-05-06 at 5 43 09 pm

Here is the code:

%table#order-vendor-products-table.table.table-striped.table-bordered.table-hover.table-highlight{"data-ajax" => "true", "data-ajax-source" => products_path(format: :json, vendor_id: @order.vendor.try(:id) || 0), "data-display-rows" => "10", "data-info" => "true", "data-length-change" => "true", "data-paginate" => "true", "data-provide" => "datatable"}
  .not-a-string
    .also-not-a-string

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.