Hi I'd love to have TextMate like snippets. I started something similar in my own yi.hs config file, but didn't continue it due to lack of time :(
In my config i overloaded the Tab-key to do auto completion, insert tabs or if symbol before pointer is a snippet keyword expand its snippet. My snippets even allow to set markers which one can jump to later. When jumping to a marker - depending on ones configuration - the marker will be deleted or put to the end of the list of (buffer specific) know snippet markers. Writing snippets is fairly simple too using the '&'-Operator. e.g. my test case i was playing with: > > testSnippet :: SnippetCmd () > testSnippet = > "if ( " & (cursorWith 1 "...") & " ) {\n" & > "\t" & (cursorWith 2 "/* code */") & > "\n}\n" & (cursor 3) This will insert the Text if ( ... ) { /* code */ } and 3 markers. Depending on your config Tabs will be expanded + the expansion is kinda indent aware. Meaning indentation of following snippet lines depends on column the snippet was triggered on. the text associated with the markers is deleted when jumping to a marker (currently in my keymap Ctrl-S), but it would be fine just to highlight it and delete it only if buffer gets modified whereas if user chooses to jump to next marker the associated text is not modified. I planed to use the post-modified-buffer hook to do this and to add dependent regions (positions with same cursor id in snippet)... So, if you are interested you can reuse some of my code. Unfortunately i have no time to hack on this right now, but still some discussions will be fine :) http://pastie.org/458506 I'm Sorry the code is kinda dirty. But i used this file to play a little with yi and haven't had time to clean it up. You will find the main snippets-functionality at about line 280. cheers Steffen On 26 Apr., 06:56, Jeff Wheeler <j...@nokrev.com> wrote: > On Sat, 2009-04-25 at 10:00 -0500, Jeff Wheeler wrote: > > Sat Apr 25 09:53:40 CDT 2009 Jeff Wheeler <jeffwhee...@gmail.com> > > * Start basic template-expansion keymap > > I'd love to hear some feedback on this before I commit it. I've been > running into problems deleting the pre-tab trigger, using deleteNAt > among other things. > > I used this to add the keymap to my configuration [1] (line 35 is the > important one). > > My ultimate goal is something like TextMate's snippet handling, where > you can then tab between fields in the expansion (it has some other nice > features too). Making this aware of its location in the parse tree could > also be neat. > > Jeff Wheeler > > [1]http://pastie.org/458437 --~--~---------~--~----~------------~-------~--~----~ Yi development mailing list yi-devel@googlegroups.com http://groups.google.com/group/yi-devel -~----------~----~----~----~------~----~------~--~---