2016-03-28 9 views
0

私はhaskellファイルをコンパイルするために構築システムを作りたいと思います。 STウィンドウで現在のファイルを実行する一般的な "CTRL + B"ショートカットを置き換えたくないことに注意してください。崇高なテキスト3 ubuntu:howkell build systemを作る方法?

ので、this messagesに続いて、私はこのファイル、ディレクトリにある "は/ opt/sublime_text" 作成:

:その後、

import sublime, sublime_plugin 

class MakeHaskellCommand(sublime_plugin.TextCommand): 
    def run(self, edit): 
     self.view.window().run_command('exec', {"working_dir":"${project_path:${folder}}",'cmd': ["ghc","$file"]}) 

を、私は崇高-Haskellのパッケージの結合のユーザーキーを変更しました

[ 
    { 
     "keys": ["f1"], 
     "context": [ 
      { "key": "haskell_source" }, 
      { "key": "scanned_source" } ], 
     "command": "MakeHaskellCommand" 
    } 
] 

STの再起動後、FN + F1を押すと何も起こりません。

お手伝いできますか?

EDIT 最初のメッセージに感謝します。 これはうまくいきましたが、今は別の問題があります。ソースファイルとバイナリを除いて、ディレクトリ内のすべてのファイルを削除したいと思います。 私はこのプラグインを起動することができます

import sublime 
import sublime_plugin 


class MakeHaskell2Command(sublime_plugin.WindowCommand): 
    def run(self): 
     variables = self.window.extract_variables() 
     args = sublime.expand_variables({ 
      "working_dir": "${project_path:${file_path}}", 
      "cmd": ["rm", "*.hi"], 
      "cmd": ["rm", "*.o"] 
     }, variables) 
     self.window.run_command('exec', args) 

を、それはファイルを削除しません。あなたはもう一度これを手伝ってくれますか?

答えて

1

ただ、いくつかのポイント:

  1. あなたは、例えば、パッケージのサブフォルダにプラグインを作成しますユーザーフォルダ
  2. キーマップのコマンド名は、あなたがf1ないfn+f1
  3. にEXECコマンドを押す必要がありますWindowCommandの代わりに、ビルドシステム
  4. ためTextCommandを使用する必要があります
  5. を剥奪終了Commandでsnake_caseされています、あなたの行動のプレスTools >>> New Plugin...を作成して貼り付け、保存するには、変数

を展開しません:

import sublime 
import sublime_plugin 


class MakeHaskellCommand(sublime_plugin.WindowCommand): 
    def run(self): 
     variables = self.window.extract_variables() 
     args = sublime.expand_variables({ 
      "working_dir": "${project_path:${file_path}}", 
      "cmd": ["ghc", "$file"] 
     }, variables) 
     self.window.run_command('exec', args) 

は、その後、あなたのキーマップを開き、キーバインドを挿入します。

{ 
    "keys": ["f1"], 
    "command": "make_haskell", 
    "context": 
    [ 
     { "key": "selector", "operator": "equal", "operand": "source.haskell" } 
    ] 
}, 

編集: あなたはシェルrmコマンドを使用して、後でクリーンアップを行いたい場合は、あなたがshell_cmd代わりのcmdを使用する必要があります。 (execshell_cmdはアレイ(why)に文字列とcmdであることが前提) Iは少し後のクリーンアップにプラグインを修飾:

import sublime 
import sublime_plugin 


class MakeHaskellCommand(sublime_plugin.WindowCommand): 
    def run(self): 
     variables = self.window.extract_variables() 
     args = sublime.expand_variables({ 
      "working_dir": "$file_path", 
      "shell_cmd": "ghc $file && rm $file_base_name.o $file_base_name.hi" 
     }, variables) 
     self.window.run_command('exec', args) 
関連する問題