{"action":"created","issue":{"url":"https://api.github.com/repos/atom/autocomplete-snippets/issues/55","labels_url":"https://api.github.com/repos/atom/autocomplete-snippets/issues/55/labels{/name}","comments_url":"https://api.github.com/repos/atom/autocomplete-snippets/issues/55/comments","events_url":"https://api.github.com/repos/atom/autocomplete-snippets/issues/55/events","html_url":"https://github.com/atom/autocomplete-snippets/issues/55","id":90710591,"number":55,"title":"Complete in strings and comments","user":{"login":"lalomartins","id":1211455,"avatar_url":"https://avatars.githubusercontent.com/u/1211455?v=3","gravatar_id":"","url":"https://api.github.com/users/lalomartins","html_url":"https://github.com/lalomartins","followers_url":"https://api.github.com/users/lalomartins/followers","following_url":"https://api.github.com/users/lalomartins/following{/other_user}","gists_url":"https://api.github.com/users/lalomartins/gists{/gist_id}","starred_url":"https://api.github.com/users/lalomartins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lalomartins/subscriptions","organizations_url":"https://api.github.com/users/lalomartins/orgs","repos_url":"https://api.github.com/users/lalomartins/repos","events_url":"https://api.github.com/users/lalomartins/events{/privacy}","received_events_url":"https://api.github.com/users/lalomartins/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/atom/autocomplete-snippets/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-06-24T15:30:58Z","updated_at":"2015-06-24T18:58:51Z","closed_at":null,"body":"I'd like to be able to write snippets for strings and comments. For example, language-coffee-script has a snippet for \"#{interpolation}\" which doesn't work so it had to hack around it somehow (I'm not quite sure how, couldn't find it in the source). Some snippets, such as `lorem` and `legal`, are clearly only useful (in source code files) inside a string or comment.\r\n\r\nCurrently it's not possible to complete in strings and comments, due to `disableForSelector: '.comment, .string'`. Furthermore, since autocomplete+ hijacks tab from snippets, I can't trigger the snippet by hand with tab either, if there's a symbol (fuzzy-)matching the snippet name.\r\n\r\nI believe that does more harm than good; if the symbol provider works in strings and comments, why not snippets?\r\n\r\nEven if it turns out people *really* don't like them, I'd suggest an alternative implementation is to match only snippets that actually have `.string` or `.comment` in the selector. Hacking around the devtools console, I managed to make that happen by passing only the current scope as the `scope` option to `config.get`. I managed to make that happen with the following code:\r\n\r\n```coffee\r\n  getSuggestions: ({scopeDescriptor, prefix}) ->\r\n    return unless prefix?.length\r\n    isStringOrComment = scopeDescriptor.getScopeChain().match(/\\s([^ ]*\\.(string|comment)\\b[^ ]*)$/)\r\n    if isStringOrComment\r\n      # could also use isStringOrComment[1]\r\n      scopes = scopeDescriptor.getScopesArray()\r\n      scopeDescriptor = [scopes[scopes.length - 1]]\r\n    scopeSnippets = atom.config.get('snippets', {scope: scopeDescriptor})\r\n    @findSuggestionsForPrefix(scopeSnippets, prefix)\r\n```\r\n\r\n(Not very happy with using a regex, but I couldn't find an API to check for a selector match; then again personally I'd rather not have this hack at all, just enable the provider and leave it at that.)"},"comment":{"url":"https://api.github.com/repos/atom/autocomplete-snippets/issues/comments/114980437","html_url":"https://github.com/atom/autocomplete-snippets/issues/55#issuecomment-114980437","issue_url":"https://api.github.com/repos/atom/autocomplete-snippets/issues/55","id":114980437,"user":{"login":"joefitzgerald","id":744740,"avatar_url":"https://avatars.githubusercontent.com/u/744740?v=3","gravatar_id":"","url":"https://api.github.com/users/joefitzgerald","html_url":"https://github.com/joefitzgerald","followers_url":"https://api.github.com/users/joefitzgerald/followers","following_url":"https://api.github.com/users/joefitzgerald/following{/other_user}","gists_url":"https://api.github.com/users/joefitzgerald/gists{/gist_id}","starred_url":"https://api.github.com/users/joefitzgerald/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joefitzgerald/subscriptions","organizations_url":"https://api.github.com/users/joefitzgerald/orgs","repos_url":"https://api.github.com/users/joefitzgerald/repos","events_url":"https://api.github.com/users/joefitzgerald/events{/privacy}","received_events_url":"https://api.github.com/users/joefitzgerald/received_events","type":"User","site_admin":false},"created_at":"2015-06-24T18:58:51Z","updated_at":"2015-06-24T18:58:51Z","body":"> remove the disableForSelector property\r\n\r\nYes, but I'd like to ensure we're only then suggesting snippets that are valid in comments. So it may somewhat invert the code you have and the way it goes about filtering the suggestions and having them displayed."}}