Add grammar scope to EditorView#2996
Add grammar scope to EditorView#2996kevinsawicki merged 7 commits intoatom:masterfrom thomasjo:editorview-grammarscopes
Conversation
|
With the change to using data attributes, an entry in '.editor[data-scope~="python"]':
'ctrl-alt-shift-a': 'something:awesome'and this works even if the |
|
@nathansobo Do the changes to @lee-dohm Was this more or less what you had in mind? If this seems useful to folks, I'll get create a few tests that cover the changes I've made. |
|
Yeah, this seems pretty much like what I was thinking about. Thanks for taking the initiative! |
|
+1 awesome. |
src/editor-view.coffee
Outdated
There was a problem hiding this comment.
What do you think about data-grammar instead of data-scope? It seems a bit more descriptive.
There was a problem hiding this comment.
Agreed, and changed!
|
Should I go ahead and add a few tests that cover the changes? Extremely busy right now, but I'll find time if necessary |
|
@thomasjo tests would be great whenever you get a chance, also this branch does not appear to cleanly merge anymore so please rebase/merge master. |
|
@kevinsawicki I've finally gotten around to add a test that verifies The Happy Path™. Let me know if you'd like me to expand with more tests. I'm unable to actually verify my test though, since I'm still seeing heaps of broken tests on Which results in all calls to Are the any special magic tricks I need to perform to get all specs to pass locally? Since we don't see the build status in your CI environment, I don't know if they are broken for everyone of if there is merely something wrong with my development environment. |
There shouldn't be, you should just be able to put run your spec only using the
Yeah, I really wish we were using Travis for core builds like we do for package builds.
I ran the spec you added locally and it does fail, I will leave some comments on the lines that need to be changed. |
spec/editor-view-spec.coffee
Outdated
There was a problem hiding this comment.
This should be text plain instead of text.plain, and also we usually use toBe instead of toEqual for string comparisons.
Only works when the `grammar-changed` event has been triggered, and only implemented for Space Pen views.
|
Adjusted the spec according to your comments, but I'm still unable to run it locally. Still failing with Doesn't matter if I run it via Atom GUI or via |
|
Really not sure why those are failing for you, I've not seen that exception before and the specs are runnable for me locally. |
Add grammar scope to EditorView
|
Thanks for this, it will be included in the next Atom release, 0.124 |
NOTE: This pull request is still work in progress. I just wanted to open it early to keep my intent and progress public, and discoverable.
The sole purpose of this pull request is to add grammar scope information to
EditorViewinstances, so that e.g. editor key bindings can trigger based on grammar. Useful if you want to invoke different build or formatting commands in various packages, for different types of grammars.Right now I'm solving this by appending CSS classes to the view, but I'm leaning towards adding a
data-scopeattribute instead, to prevent pollution and potential conflicts that might cause all manner of mayhem.