Search code examples
ruby-on-railsvimctagsslim-langexuberant-ctags

Vim plugin that allows to follow css class from a slim file to a SASS file


I've searched everywhere but couldn't find a ctag language definition for slim (for Ruby on Rails).

It would be great if someone can point me in the right direction :-)


Solution

  • This is the .less section of my ~/.ctags file:

    --langdef=less
    --langmap=less:.less
    --regex-less=/^[ \t&]*#([A-Za-z0-9_-]+)/\1/i,id,ids/
    --regex-less=/^[ \t&]*\.([A-Za-z0-9_-]+)/\1/c,class,classes/
    --regex-less=/^[ \t]*(([A-Za-z0-9_-]+[ \t\n,]+)+)\{/\1/t,tag,tags/
    --regex-less=/^[ \t]*@media\s+([A-Za-z0-9_-]+)/\1/m,media,medias/
    --regex-less=/^[ \t]*(@[A-Za-z0-9_-]+):/\1/v,variable,variables/
    

    the .scss section:

    --langdef=scss
    --langmap=scss:.scss
    --regex-scss=/^[ \t]*@mixin ([A-Za-z0-9_-]+)/\1/m,mixin,mixins/
    --regex-scss=/^[ \t]*\$([A-Za-z0-9_-]+)/\1/v,variable,variables/
    --regex-scss=/^([A-Za-z0-9_-]*)*(\.[A-Za-z0-9_-]+) *[,{]/\2/c,class,classes/
    --regex-scss=/^[ \t]+(\.[A-Za-z0-9_-]+) *[,{]/\1/c,class,classes/
    --regex-scss=/^(.*)*\#([A-Za-z0-9_-]+) *[,{]/\2/i,id,ids/
    --regex-scss=/^[ \t]*#([A-Za-z0-9_-]+)/\1/i,id,ids/
    --regex-scss=/(^([A-Za-z0-9_-])*([A-Za-z0-9_-]+)) *[,|\{]/\1/t,tag,tags/
    --regex-scss=/(^([^\/\/])*)[ \t]+([A-Za-z0-9_-]+)) *[,|\{]/\3/t,tag,tags/
    --regex-scss=/(^(.*, *)([A-Za-z0-9_-]+)) *[,|\{]/\3/t,tag,tags/
    --regex-scss=/(^[ \t]+([A-Za-z0-9_-]+)) *[,|\{]/\1/t,tag,tags/
    --regex-scss=/^[ \t]*@media\s+([A-Za-z0-9_-]+)/\1/d,media,media/
    

    and the .html section:

    --regex-html=/id="([A-Za-z0-9_-]+)"/\1/i,id,ids/
    --regex-html=/class="([A-Za-z0-9_-]+)"/\1/c,class,classes/
    

    You will probably get something workable if you start with these.