Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Not working "Goto definition" in sublime text 3 #15

Open
Sinled opened this Issue · 18 comments

5 participants

@Sinled

I am missing this feature in sass, it works fine with less bundle https://github.com/danro/LESS-sublime but not in sass, i tried to modify Symbol List - Selectors.tmPreferences file, but no avail. May be i am missing something?

@Sinled

Make it work by adding such lines in Symbol List - Selectors.tmPreferences

        <key>showInIndexedSymbolList</key>
        <integer>1</integer>
        <key>symbolIndexTransformation</key>
        <string>/[#.]([A-Za-z0-9_~]+)/$1/;</string>
@P233
Owner

Thank you very much. I will do some research and add this feature shortly.

Sorry for my later reply :(

@sorahn

Any progress on this?

@P233
Owner

Hi @Sinled and @drbrts

I've added two new features in this package:

  1. By using {{ and }} to wrap a keyword in any comment, you can create a Comment Tag and it can be indexed by 'Goto Symbol' and 'Goto Symbol in Project'.

  2. Added support for Sublime Text 3 'Goto Symbol in Project'. Now 'Goto Symbol' will list all HTML tags, ID selectors, Class selectors, and Comment Tags in current file, and 'Goto Symbol in Project' will list all @mixin, @function, and Comment Tags in current project.

Unfortunately, 'Goto Definition' still not works. Because we need to select @mixin something then press super+alt+down to find the exactly same string in current project which is not possible because @mixin or @function will only defined once. I suppose Comment Tag is the best alternative.

If you have any suggestions please feel free to let me know. Thank you.

@sorahn

Thanks, this looks super great!

Re: Goto Definition, I wonder if you could open a bug with ST about not being able that.

@P233
Owner

Sorry @drbrts , I didn't explain clearly enough. It's not a bug. Syntax highlighting packages tell ST which string is a symbol, then ST searches the whole project and builds a symbol index which is the Goto Symbol in Project list. If you select a specific string and do Goto Definition, ST will search this index and return a more specific list or redirect to a file if only one match.

In fact, it is possible to pass tags, id/class selectors, and almost everything to the symbol index and the Goto Definition. I am personally not sure if this is the most efficient way to manage a Sass project, so I didn't enable it but introduced the Comment Tag. However, if you think it is important, just let me know :)

Currently, I intend to only pass @mixin and @function to the symbol index. When we selected a mixin name or function name, goto definition, then we get the original code. That is really cool. I've found a way to deal with this. Maybe need the ST author to make a little bit change, or maybe there is an another way. Need more test...

@sorahn

Is it reasonable to say that all #ids and .classes (and %placeholders) should be indexed, because any one of them could be @extended?

@P233
Owner

yse @drbrts you are right, I'll do some test tomorrow morning and let you know :)

@sorahn

Awesome! I'm working with the most complicated SASS project I've done to date, so let me know If I can help :)

@P233
Owner

Thank you @drbrts. I've updated this package this morning. Now all HTML tags, ID/Class/Placeholder selectors, @mixin, @function and Comment Tags will works with Goto Symbol in Project and Goto Definition.

There are also some problems:

  1. #id:pseudo-class can find #id, but can't do it in an opposite way. This is because of the syntax match rule.
  2. In SCSS syntax, if two words are joined by hyphen, like this two-word. Goto Definition will only work if ( { [ : (space) behind it such as two-word() two-word{} two-word[] two-word: two-word, but won't work if ; or line feed \n behind it. Add a space behind to make it work.
  3. In Sass syntax, need to add a space behind everything to make it work :(
  4. Mixin and Function name will not display @mixin or @function in front in Goto Symbol in Project list.

I'm going to report a bug to ST author.

If you found any problems no matter how small it is, or any suggestions, please let me know :)

@sorahn

All of this looks awesome! Thanks so much.

In Sass syntax, need to add a space behind everything to make it work :(

Is that for all the #ids and .classes or just for things with hyphens?

@P233
Owner

@drbrts I am afraid that is for all #ids .classes and almost everything, but it is traceable. If a word is at the very end of a line ( just in front \n), ST will not recognise it. I've posted on ST forum http://www.sublimetext.com/forum/viewtopic.php?f=4&t=14515. Hope they could solve this bug soon.

@devatrox

Is it intended to not work with underscores in front of mixins? ( like so: @include _mixin(); ) It does on functions. I know it is not common to do that (maybe I'm the only one) but it would be nice if it would be recognized as a definition.

@P233
Owner

@devatrox It seems working in the Sass 3.3 branch https://github.com/P233/Syntax-highlighting-for-Sass/tree/sass-3.3 , can you give it a try? I will properly merge it next week :)

@devatrox

Tried it, does not work. Maybe this helps: When I'm not selecting it (just putting the cursor in), it searches for the name without the underscore, if I select the whole name, it searches for that but still doesn't find it.

But please don't hold back your release plans because of that! When I started using underscores to prevent conflicts and to stand out from other libraries, I never considered trying Goto Definition at all. Kind of regretting this decision now :/

@P233
Owner

@devatrox
It seems works fine for me. that's weird.

2014-05-02 22_02_47

Please try to completely delete this package, relaunch Sublime Text and manually install the sass-3.3 branch :)

@devatrox

I did all that. Even tried disabling other SCSS packages, nothing works :(
It might be some weird setting in my ST preventing it. Well it's getting late. Will play around some more tomorrow. Thanks so far!

@Fipo

In my case for some mixins work but for others not ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.