{"action":"created","issue":{"url":"https://api.github.com/repos/SirVer/ultisnips/issues/446","labels_url":"https://api.github.com/repos/SirVer/ultisnips/issues/446/labels{/name}","comments_url":"https://api.github.com/repos/SirVer/ultisnips/issues/446/comments","events_url":"https://api.github.com/repos/SirVer/ultisnips/issues/446/events","html_url":"https://github.com/SirVer/ultisnips/pull/446","id":57818158,"number":446,"title":"Context-aware snippets","user":{"login":"seletskiy","id":674812,"avatar_url":"https://avatars.githubusercontent.com/u/674812?v=3","gravatar_id":"","url":"https://api.github.com/users/seletskiy","html_url":"https://github.com/seletskiy","followers_url":"https://api.github.com/users/seletskiy/followers","following_url":"https://api.github.com/users/seletskiy/following{/other_user}","gists_url":"https://api.github.com/users/seletskiy/gists{/gist_id}","starred_url":"https://api.github.com/users/seletskiy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seletskiy/subscriptions","organizations_url":"https://api.github.com/users/seletskiy/orgs","repos_url":"https://api.github.com/users/seletskiy/repos","events_url":"https://api.github.com/users/seletskiy/events{/privacy}","received_events_url":"https://api.github.com/users/seletskiy/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-02-16T15:35:57Z","updated_at":"2015-04-01T05:40:27Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/SirVer/ultisnips/pulls/446","html_url":"https://github.com/SirVer/ultisnips/pull/446","diff_url":"https://github.com/SirVer/ultisnips/pull/446.diff","patch_url":"https://github.com/SirVer/ultisnips/pull/446.patch"},"body":"Hello again!\r\n\r\nThis PR is a proof-of-concept of snippets, that can be expanded not only by matching prefix/regexp, but by context.\r\n\r\nConsider this example:\r\n\r\n```\r\nif true {\r\n}<TAB>\r\n\r\n// becomes\r\n\r\nif true {\r\n} else {\r\n}\r\n\r\n// but\r\n\r\ntype MyType struct {\r\n}<TAB>\r\n\r\n// becomes\r\n\r\ntype MyData struct {\r\n}\r\n\r\nfunc (data MyData) SomeMethod() {\r\n}\r\n```\r\n\r\nSo, no matter that same trigger is used (`}` in that case), different snippets are chosen for expansion.\r\n\r\nI think it's very powerful mechanism, which will lead to just hitting `<TAB>` in most cases without typing at all.\r\n\r\nIt's not ready-to-go solution, and I'm glad to listen some thoughts.\r\n\r\nIn current implementation snippets use following syntax:\r\n\r\n```\r\nsnippet } \"Description\" \"is_if_bracket(b, l, c)\" xw\r\n} else {\r\n\t$1\r\n}\r\nendsnippet\r\n```\r\n\r\nWhere `is_if_bracket` (note the `x` flag) is a python function that will return `True`, if cursor stands at closing bracket for `if` statement.\r\n\r\nBTW, I've tried to fix syntax file for correct highlighting and found it nearly impossible to comprehend. Is there really solid reason to have triggers which can be defined using multiple nested double-quotes? As far as I understand it makes that patterns so complex."},"comment":{"url":"https://api.github.com/repos/SirVer/ultisnips/issues/comments/88358034","html_url":"https://github.com/SirVer/ultisnips/pull/446#issuecomment-88358034","issue_url":"https://api.github.com/repos/SirVer/ultisnips/issues/446","id":88358034,"user":{"login":"seletskiy","id":674812,"avatar_url":"https://avatars.githubusercontent.com/u/674812?v=3","gravatar_id":"","url":"https://api.github.com/users/seletskiy","html_url":"https://github.com/seletskiy","followers_url":"https://api.github.com/users/seletskiy/followers","following_url":"https://api.github.com/users/seletskiy/following{/other_user}","gists_url":"https://api.github.com/users/seletskiy/gists{/gist_id}","starred_url":"https://api.github.com/users/seletskiy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seletskiy/subscriptions","organizations_url":"https://api.github.com/users/seletskiy/orgs","repos_url":"https://api.github.com/users/seletskiy/repos","events_url":"https://api.github.com/users/seletskiy/events{/privacy}","received_events_url":"https://api.github.com/users/seletskiy/received_events","type":"User","site_admin":false},"created_at":"2015-04-01T05:40:27Z","updated_at":"2015-04-01T05:40:27Z","body":"@SirVer: Any news? I'm using it for a while now and I've satisfied how it works."}}