def select_project(window, on_selected): ps = autocompletion.projects.items() def run_selected(psel): on_selected(psel[0], psel[1]['dir']) if len(ps) == 0: return if len(ps) == 1: # There's only one project, build it run_selected(ps[0]) return cabal_project_dir, cabal_project_name = get_cabal_project_dir_and_name_of_view(window.active_view()) # Show current project first def compare(l, r): res = cmp(not (l[0] == cabal_project_name), not (r[0] == cabal_project_name)) if res == 0: res = cmp(l[0], r[0]) return res ps.sort(compare) def on_done(idx): if idx != -1: run_selected(ps[idx]) window.show_quick_panel(map(lambda m: [m[0], m[1]['dir']], ps), on_done)
def run(self): self.executables = [] ps = [] for p, info in autocompletion.projects.items(): for e in info['executables']: ps.append((p + ": " + e['name'], { 'dir': info['dir'], 'name': e['name'] })) # Nothing to run if len(ps) == 0: sublime.status_message('SublimeHaskell: Nothing to run') return cabal_project_dir, cabal_project_name = get_cabal_project_dir_and_name_of_view(self.window.active_view()) # Show current project first def compare(l, r): res = cmp(not l[0].startswith(cabal_project_name), not r[0].startswith(cabal_project_name)) if res == 0: res = cmp(l[0], r[0]) return res ps.sort(compare) self.executables = map(lambda m: m[1], ps) self.window.show_quick_panel(map(lambda m: m[0], ps), self.on_done)
def run_build_commands_with(msg, cmds): """Run general build commands""" window, view, file_shown_in_view = get_haskell_command_window_view_file_project() if not file_shown_in_view: return syntax_file_for_view = view.settings().get('syntax').lower() if 'haskell' not in syntax_file_for_view: return cabal_project_dir, cabal_project_name = get_cabal_project_dir_and_name_of_view(view) if not cabal_project_dir: return run_chain_build_thread(view, cabal_project_dir, msg(cabal_project_name), cmds)
def on_post_save(self, view): auto_build_enabled = get_setting('enable_auto_build') auto_check_enabled = get_setting('enable_auto_check') auto_lint_enabled = get_setting('enable_auto_lint') cabal_project_dir, cabal_project_name = get_cabal_project_dir_and_name_of_view(view) # auto build enabled and file within a cabal project if auto_build_enabled and cabal_project_dir is not None: view.window().run_command('sublime_haskell_build_auto') # try to ghc-mod check elif auto_check_enabled and auto_lint_enabled: view.window().run_command('sublime_haskell_ghc_mod_check_and_lint') elif auto_check_enabled: view.window().run_command('sublime_haskell_ghc_mod_check') elif auto_lint_enabled: view.window().run_command('sublime_haskell_ghc_mod_lint')
def run(self): current_project_dir, current_project_name = get_cabal_project_dir_and_name_of_view(self.window.active_view()) if current_project_name and current_project_dir: build_mode = get_setting('auto_build_mode') build_command = { 'normal': 'build', 'normal-then-warnings': 'build_then_warnings', 'typecheck': 'typecheck', 'typecheck-then-warnings': 'typecheck_then_warnings', }.get(build_mode) if not build_command: output_error(self.window, "SublimeHaskell: invalid auto_build_mode '%s'" % build_mode) run_build(self.window.active_view(), current_project_name, current_project_dir, build_command, None)
def on_post_save(self, view): auto_build_enabled = get_setting('enable_auto_build') auto_check_enabled = get_setting('enable_auto_check') auto_lint_enabled = get_setting('enable_auto_lint') cabal_project_dir, cabal_project_name = get_cabal_project_dir_and_name_of_view(view) # auto build enabled and file within a cabal project if auto_build_enabled and cabal_project_dir is not None: view.window().run_command('sublime_haskell_build_auto') # try to ghc-mod check elif get_setting('enable_ghc_mod'): if auto_check_enabled and auto_lint_enabled: view.window().run_command('sublime_haskell_ghc_mod_check_and_lint') elif auto_check_enabled: view.window().run_command('sublime_haskell_ghc_mod_check') elif auto_lint_enabled: view.window().run_command('sublime_haskell_ghc_mod_lint')
def on_post_save(self, view): auto_build_enabled = get_setting('enable_auto_build') auto_check_enabled = get_setting('enable_auto_check') auto_lint_enabled = get_setting('enable_auto_lint') cabal_project_dir, cabal_project_name = get_cabal_project_dir_and_name_of_view( view) # don't flycheck self.fly_agent.nofly() # auto build enabled and file within a cabal project if auto_build_enabled and cabal_project_dir is not None: view.window().run_command('sublime_haskell_build_auto') elif auto_check_enabled and auto_lint_enabled: view.window().run_command('sublime_haskell_check_and_lint') elif auto_check_enabled: view.window().run_command('sublime_haskell_check') elif auto_lint_enabled: view.window().run_command('sublime_haskell_lint')
def on_post_save(self, view): auto_build_enabled = get_setting('enable_auto_build') auto_check_enabled = get_setting('enable_auto_check') auto_lint_enabled = get_setting('enable_auto_lint') cabal_project_dir, cabal_project_name = get_cabal_project_dir_and_name_of_view(view) # don't flycheck self.fly_agent.nofly() # auto build enabled and file within a cabal project if auto_build_enabled and cabal_project_dir is not None: view.window().run_command('sublime_haskell_build_auto') elif auto_check_enabled and auto_lint_enabled: view.window().run_command('sublime_haskell_check_and_lint') view.window().run_command('sublime_haskell_get_types') elif auto_check_enabled: view.window().run_command('sublime_haskell_check') view.window().run_command('sublime_haskell_get_types') elif auto_lint_enabled: view.window().run_command('sublime_haskell_lint')