Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- events.connect(events.LEXER_LOADED, function(lang)
- if lang == 'python' then
- buffer.tab_width = 4
- snippets['#!'] = '#!/usr/bin/env python\n%0'
- snippets['***'] = '*args, **kwargs'
- snippets['///'] = '""" %1(Docstring text) """'
- snippets['_'] = '__%1(init)__%2'
- snippets['class'] = 'class %1(ClassName)(%2(object)):\n\t""" %3(Docstring for class %1) """\n\tdef __init__(self%4):\n\t\t%5(pass)'
- snippets['def'] = 'def %1(function)(%2(args)):\n\t%3(pass)'
- snippets['defd'] = 'def %1(function)(%2(args)):\n\t""" %3(Docstring for function %1) """\n\t%4(pass)'
- snippets['defs'] = 'def %1(method)(self,%2):\n\t%3(pass)'
- snippets['defsd'] = 'def %1(method)(self,%2):""" %3(Docstring for method %1) """\n\t%4(pass)'
- snippets['elif'] = 'elif %1(condition):\n\t%2(pass)'
- snippets['for'] = 'for %1(item) in %2(iterable):\n\t%3(pass)'
- snippets['from'] = 'from %1(sys) import %2(*)'
- snippets['if'] = 'if %1(condition):\n\t%2(pass)'
- snippets['ife'] = 'if %1(condition):\n\t%2(pass)\nelse:\n\t%3(pass)'
- snippets['ifee'] = 'if %1(condition):\n\t%2(pass)\nelif %3(condition):\n\t%4(pass)\nelse:\n\t%5(pass)'
- snippets['ifmain'] = 'if __name__ == \'__main__\':\n\t%3(main())'
- snippets['join'] = 'str.join(%1(", "), %2(iterable))'
- snippets['prt'] = 'print(%1)'
- snippets['prts'] = 'print("%1")'
- snippets['try'] = 'try:\n\t%1(pass)\nexcept %2(Exception) as %3(e):\n\t%4(pass)'
- snippets['tryee'] = 'try:\n\t%1(pass)\nexcept %2(Exception) as %3(e):\n\t%4(pass)\nelse:\n\t%5(pass)'
- snippets['tryeef'] = 'try:\n\t%1(pass)\nexcept %2(Exception) as %3(e):\n\t%4(pass)\nelse:\n\t%5(pass)\nfinally:\n\t%6(pass)'
- snippets['tryef'] = 'try:\n\t%1(pass)\nexcept %2(Exception) as %3(e):\n\t%4(pass)\nfinally:\n\t%5(pass)'
- snippets['while'] = 'while %1(condition):\n\t%2(pass)'
- snippets['with'] = 'with %1(exp) as %2(target):\n\t%3(pass)'
- -- unit testing
- snippets['aae'] = 'self.assertAlmostEqual(%1(first), %2(second))'
- snippets['ae'] = 'self.assertEqual(%1(first), %2(second))'
- snippets['af'] = 'self.assertFalse(%1(exp))'
- snippets['an'] = 'self.assertIsNone(%1(exp))'
- snippets['ann'] = 'self.assertIsNotNone(%1(exp))'
- snippets['at'] = 'self.assertTrue(%1(exp))'
- snippets['clt'] = 'class Test%1(Class)(%2(unittest.TestCase)):\n\t""" %3(Docstring for testclass) """\n\tdef setUp(self):\n\t\t%4(pass)\n\n\tdef tearDown(self):\n\t\t%5(pass)\n\n\tdef test_%6(name)(self):\n\t\t%7(pass)'
- snippets['tst'] = 'def test_%1(name)(self):\n\t\t%2(pass)'
- elseif lang == 'ruby' then
- buffer.tab_width = 2
- snippets['#!'] = '#!/usr/bin/env ruby\n%0'
- snippets['Do'] = 'do\n\t%1(# TODO)\nend'
- snippets['For'] = '(%1(from)..%2(to)).each { |%3(i)| %4(# TODO) }'
- snippets['If'] = '%1(command) if %2(exp)'
- snippets['Unl'] = '%1(command) unless %2(exp)'
- snippets['Until'] = 'begin\n\t%1(# TODO)\nend until %2(exp)'
- snippets['While'] = 'begin\n\t%1(# TODO)\nend while %2(exp)'
- snippets['bre'] = 'begin\n\t%1(# TODO)\nrescue %2(Exception)%3( => e)\n\t%4(# TODO)\nend'
- snippets['cas'] = 'case %1(object)\nwhen %2(condition)\n\t%3(# TODO)\nend'
- snippets['class'] = 'class %1(ClassName)\n\tdef initialize(%2(args))\n\t\t%3(# TODO)\n\tend\nend'
- snippets['def'] = 'def %1(function)(%2(args))\n\t%3(# TODO)\nend'
- snippets['do'] = 'do |%1(var)|\n\t%2(# TODO)\nend'
- snippets['elsif'] = 'elsif %1(condition)\n\t%2(# TODO)'
- snippets['for'] = '(%1(from)..%2(to)).each do |%3(i)|\n\t%4(# TODO)\nend'
- snippets['if'] = 'if %1(condition)\n\t%2(# TODO)\nend'
- snippets['ife'] = 'if %1(condition)\n\t%2(# TODO)\nelse\n\t%3(# TODO)\nend'
- snippets['ifee'] = 'if %1(condition)\n\t%2(# TODO)\nelsif %3(condition)\n\t%4(# TODO)\nelse\n\t%5(# TODO)\nend'
- snippets['unl'] = 'unless %1(condition)\n\t%2(# TODO)\nend'
- snippets['unle'] = 'unless %1(condition)\n\t%2(# TODO)\nelse\n\t%3(# TODO)\nend'
- snippets['unlee'] = 'unless %1(condition)\n\t%2(# TODO)\nelsif %3(condition)\n\t%4(# TODO)\nelse\n\t%5(# TODO)\nend'
- snippets['until'] = 'until %1(condition)\n\t%2(# TODO)\nend'
- snippets['when'] = 'when %1(condition)\n\t%2(# TODO)'
- snippets['while'] = 'while %1(condition)\n\t%2(# TODO)\nend'
- -- attribute access
- snippets['r'] = 'attr_reader :%1(attr_names)'
- snippets['w'] = 'attr_writer :%1(attr_names)'
- snippets['rw'] = 'attr_accessor :%1(attr_names)'
- else
- buffer.tab_width = 2
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement