Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Sublime Text の プラグイン開発の方法

Sublime Text の プラグイン開発の方法

in 大阪 Python ユーザの集まり 2014/10

14901e9e6fa8aa18f46e5fe47e15b600?s=128

astronaughts

October 21, 2014
Tweet

More Decks by astronaughts

Other Decks in Programming

Transcript

  1. Sublime Text ͷ ϓϥάΠϯ։ൃͷํ๏ ͏͑ͷ·͞ͻΖ

  2. ࣗݾ঺հ ͏͑ͷ·͞ͻΖ $IBU8PSLגࣜձࣾϞόΠϧνʔϜϦʔμʔ J04"OESPJE։ൃ !BTUSPOBVHIUT !" +BWB4DSJQU 5JUBOJVN /PEF 1ZUIPO

    0CKFDUJWF$ +BWB
  3. Sublime Text Ͱ։ൃ +BWB4DSJQU 5JUBOJVN /PEF 1ZUIPO

  4. Sublime Text ͷڭՊॻ ͜ΜͳຊΛॻ͖·ͨ͠ ిࢠ൛΋͋Γ·͢

  5. Sublime Text ͷಛ௃ ىಈ͕ૣ͍ɺ͍ܰ 6*͕γϯϓϧɺͰ΋ػೳ͸ڧྗ ๲େͳศརϓϥάΠϯΛඞཁͳ΋ͷ͚ͩνϣΠε ༗ྉ͚ͩͲɺແ੍ݶͰࢼ༻Մೳ ͳΜ͔࢖ͬͯͯΠέͯΔؾ͕͢Δ ࢖͍͸͡Ί͸Ͳ͕͍͍͜ͷ͔ύοͱݟΘ͔Βͳ͍ ϚϧνϓϥοτϑΥʔϜʢ8JO

    .BD -JOVYʣ
  6. Sublime Text ͷۙگ ࿀ʹམͪΔਓ͕ܹ૿ͯ͠͸΍̍೥൒ ͲΜͲΜपΓͷਓͰ΋࢖ͬͯΔਓ͕૿͑ͯΔ Ϣʔβʔ਺. .8JOEPXT ,049 ,-JOVY ग़యɿIUUQTTVCMJNFXCPOEOFUTUBUT

  7. Sublime Text ͷϓϥάΠϯ 45Ͱ͸ʮύοέʔδʯͱݺͿ ύοέʔδ͸1ZUIPOͰॻ͘͜ͱ͕Ͱ͖Δ TIJGU DPOUSPM A ͰίϯιʔϧΛදࣔͤͯ͞1ZUIPO࣮ߦ

  8. ύοέʔδΛ࡞ͬͯΈΔ Sublime Text Menu > Tools > New Plugin… import

    sublime, sublime_plugin ! class ExampleCommand(sublime_plugin.TextCommand): def run(self, edit): self.view.insert(edit, 0, "Hello, World!") αϯϓϧιʔεΛݺͼग़ͤΔ
  9. ύοέʔδΛอଘ Sublime Text Menu > Preferences > Browse Packages… ./Packages/User

    ϑΥϧμʹϑΝΠϧΛอଘ อଘͨ͠λΠϛϯάͰΠϯετʔϧ׬ྃ
  10. ύοέʔδΛ࣮ߦ ύοέʔδͷॲཧ͸Ϋϥεʹఆٛ class ExampleCommand view.run_command(“example”) view.run_command メソッドの引数に小文字で ίϯιʔϧ্Ͱ4VCMJNF5FYUͷ"1*Ͱ͋Δɺ Ϋϥε໊ͷ$PNNBOEΑΓલͷ໊લͰݺͼग़͢

  11. Ҏ֎ʹؾܰʹαΫοͱॻ͚Δ Sublime Text ͷϓϥάΠϯ 1ZUIPOͰͰ͖Δ͜ͱ͸͍͍ͨͯͰ͖Δ "1*%PDVNFOU͕ෆ਌੾͗͢Δ ΄͔ͷύοέʔδͷιʔεಡΊ ࡞Δલʹಉ͡Α͏ͳ΋ͷ͕ͳ͍͔֬ೝ ࡞Γ͍ͨ΋ͷʹࣅͨύοέʔδΛύΫʢ͈́

  12. Package Control https://sublime.wbond.net/

  13. 4VCMJNF$PNCJOF.FEJB2VFSJFT ࡞ͬͨύοέʔδ 4VCMJNF4UZMF4UBUT 4VCMJNF/'%5P/'$1BTUF 4VCMJNF1)1#VJMUJO8FC4FSWFS 4VCMJNF0QFO'SPN1BUI IUUQTHJUIVCDPNBTUSPOBVHIUT "

  14. 1ZUIPO'MBLF-JOU Α͘࢖͏ύοέʔδ #FUUFS$P⒎FF4DSJQU +4)JOU +40/5SFF (JU(VUUFS FUDʜ

  15. ಛʹ4DBMBΤϯδχΞʢαʔόʔαΠυʣ ΤϯδχΞઈࢍେืूத "OESPJEΤϯδχΞʢϞόΠϧʣ $IBU8PSL͕ؾʹͳΔΤϯδχΞͷํ FUDʜ

  16. ͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ɻ