Skip to content

Instantly share code, notes, and snippets.

@Qambar
Forked from arnaudsj/Clojure.sublime-settings
Created April 28, 2017 08:02
Show Gist options
  • Save Qambar/3afe51be82a0c82828dcbf1c78888120 to your computer and use it in GitHub Desktop.
Save Qambar/3afe51be82a0c82828dcbf1c78888120 to your computer and use it in GitHub Desktop.
Sublime Text 3: Clojure
// installed Clojure packages:
//
// * BracketHighlighter
// * lispindent
// * SublimeREPL
// * sublime-paredit
{
"word_separators": "/\\()\"',;!@$%^&|+=[]{}`~?",
"paredit_enabled": true,
"paredit_dont_match_single_quotes": true
}
# ClojureHelpers.py for Sublime Text 3
# originally by James MacCaulley
# https://gist.github.com/jamesmacaulay/5457344
import re
import sublime
import sublime_plugin
import SublimeREPL.sublimerepl
import SublimeREPL.text_transfer
class RefreshNamespacesInReplCommand(SublimeREPL.text_transfer.ReplTransferCurrent):
def run(self, edit):
text = "(clojure.tools.namespace.repl/refresh)"
self.view.window().run_command("repl_send", {"external_id": self.repl_external_id(), "text": text})
class SwitchToCurrentNamespaceInReplCommand(SublimeREPL.text_transfer.ReplTransferCurrent):
def run(self, edit):
if SublimeREPL.sublimerepl.manager.repl_view(self.view):
return
ns = re.sub("ns\s*", "", self.view.substr(self.view.find("ns\s*\S+",0)))
ns= ns[:-1] if ns[-1] == ")" else ns
text = "(in-ns '" + ns + ")"
self.view.window().run_command("repl_send", {"external_id": self.repl_external_id(), "text": text})
class RunAllClojureTestsFromProjectInReplCommand(SublimeREPL.text_transfer.ReplTransferCurrent):
def run(self, edit):
form = "(do (clojure.tools.namespace.repl/refresh) (apply clojure.test/run-tests (clojure.tools.namespace.find/find-namespaces-in-dir (clojure.java.io/file \"test\"))))"
self.view.window().run_command("refresh_namespaces_in_repl")
self.view.window().run_command("repl_send", {"external_id": self.repl_external_id(), "text": form})
class RunClojureTestsFromCurrentNamespaceInReplCommand(SublimeREPL.text_transfer.ReplTransferCurrent):
def run(self, edit):
if SublimeREPL.sublimerepl.manager.repl_view(self.view):
return
ns = re.sub("ns\s*", "", self.view.substr(self.view.find("ns\s*\S+",0)))
default_test_ns = re.sub("(.*)(?<!-test)\\Z", "\\1-test", ns, 1)
alt_style_test_ns = re.sub("\A([^\\.]*\\.)(?!test)","\\1test.", ns, 1)
form = "(try (clojure.test/run-tests '" + default_test_ns + ")\n (catch Exception e\n (clojure.test/run-tests '" + alt_style_test_ns + ")))"
self.view.window().run_command("refresh_namespaces_in_repl")
self.view.window().run_command("repl_send", {"external_id": self.repl_external_id(), "text": form})
[
{ "keys": ["escape"], "command": "auto_complete", "context":
[
{ "key": "auto_complete_visible", "operator": "equal", "operand": false },
{ "key": "overlay_visible", "operator": "equal", "operand": false },
{ "key": "panel_visible", "operator": "equal", "operand": false },
{ "key": "num_selections", "operator": "equal", "operand": 1 }
]
},
{ "keys": ["super+shift+t"], "command": "reopen_last_file" },
{ "keys": ["ctrl+super+r"], "command": "reveal_in_side_bar" },
// SublimeREPL bindings:
// =====================
{ "keys": ["alt+super+b"], "command": "repl_transfer_current", "args": {"scope": "block"}},
{ "keys": ["alt+super+r"], "command": "refresh_namespaces_in_repl"},
{ "keys": ["alt+super+i"], "command": "switch_to_current_namespace_in_repl"},
{ "keys": ["alt+super+x"], "command": "run_clojure_tests_from_current_namespace_in_repl"},
{ "keys": ["alt+super+a"], "command": "run_all_clojure_tests_from_project_in_repl"},
// BracketHighlighter bindings:
// ===========================
// Swap bracket type
{ "keys": ["ctrl+shift+]"],
"command": "swap_brackets"},
// Swap quotes (only goes boths ways in supported languages...)
{ "keys": ["ctrl+shift+'"],
"command": "bh_key", "args": {"lines" : true, "plugin": {"type": ["single_quote", "double_quote", "py_single_quote", "py_double_quote"], "command": "bh_modules.swapquotes"} }},
// Select text between brackets
{ "keys": ["ctrl+alt+a"],
"command": "bh_key", "args": {"lines" : true, "plugin": {"type": ["__all__"], "command": "bh_modules.bracketselect"} } },
// Select tag name of HTML/XML tag (both opening name and closing)
{ "keys": ["ctrl+alt+t"],
"command": "bh_key", "args": {"plugin": {"type": ["cfml", "html", "angle"], "command": "bh_modules.tagnameselect"} } },
// Toggle high visibility mode
{ "keys": ["alt+super+="],
"command": "bh_toggle_high_visibility"},
// sublime-paredit fixes:
// ======================
// Don't constrain close-parens unless we're in paredit mode:
{ "keys": [")"], "command": "insert_snippet", "args": {"contents": ")"}, "context":
[{ "key": "setting.paredit_enabled", "operator": "equal", "operand": false }]},
{ "keys": [")"], "command": "run_macro_file", "args": {"file": "Packages/sublime-paredit/Paredit Closing Bracket.sublime-macro_"}, "context":
[{ "key": "setting.paredit_enabled", "operator": "equal", "operand": true }]},
{ "keys": [")"], "command": "move", "args": {"by": "characters", "forward": true}, "context":
[
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^\\)", "match_all": true }
]
}
]
// If you need to customize the SublimeREPL settings for Clojure, you can copy Main.sublime-menu
// from Packages/SublimeREPL/config/Clojure into Packages/User and edit as necessary. This will
// change the behaviour of the REPL when selected from the menu (Tools > SublimeREPL > Clojure >
// Clojure) but if you launch the REPL from the default shortcut or the command palette, it will
// use the original unedited settings from the package.
// This is the edited file from the version of SublimeREPL I have right now:
[
{
"id": "tools",
"children":
[{
"caption": "SublimeREPL",
"mnemonic": "r",
"id": "SublimeREPL",
"children":
[
{"caption": "Clojure",
"id": "Clojure",
"children":[
{"command": "repl_open",
"caption": "Clojure",
"id": "repl_clojure",
"args": {
"type": "subprocess",
"encoding": "utf8",
"cmd": {"windows": ["lein.bat", "repl"],
"linux": ["lein", "repl"],
"osx": ["lein", "repl"]},
"soft_quit": "\n(. System exit 0)\n",
"cwd": {"windows":"c:/Clojure", // where the lein.bat lives!
"linux": "$project_path",
"osx": "$project_path"},
"syntax": "Packages/Clojure/Clojure.tmLanguage",
"external_id": "clojure",
"extend_env": {"INSIDE_EMACS": "1"}
}
},
{"command": "clojure_auto_telnet_repl",
"id": "repl_clojure_telnet",
"caption": "Clojure-Telnet"}]}
]
}]
}
]
{
"always_prompt_for_file_reload": false,
"always_show_minimap_viewport": false,
"animation_enabled": true,
"atomic_save": true,
"auto_close_tags": true,
"auto_complete": true,
"auto_complete_commit_on_tab": true,
"auto_complete_delay": 50,
"auto_complete_selector": "source - comment, meta.tag - punctuation.definition.tag.begin",
"auto_complete_size_limit": 4194304,
"auto_complete_triggers": [{
"characters": "<",
"selector": "text.html"
}],
"auto_complete_with_fields": false,
"auto_find_in_selection": false,
"auto_indent": true,
"auto_match_enabled": true,
"binary_file_patterns": [
"*.jpg",
"*.jpeg",
"*.png",
"*.gif",
"*.ttf",
"*.tga",
"*.dds",
"*.ico",
"*.eot",
"*.pdf",
"*.swf",
"*.jar",
"*.zip"
],
"bold_folder_labels": false,
"caret_style": "wide",
"close_windows_when_empty": false,
"color_scheme": "Packages/User/Django (SL).tmTheme",
"copy_with_empty_selection": true,
"create_window_at_startup": true,
"default_encoding": "UTF-8",
"default_line_ending": "system",
"detect_indentation": true,
"dictionary": "Packages/Language - English/en_US.dic",
"drag_text": true,
"draw_centered": false,
"draw_indent_guides": true,
"draw_minimap_border": false,
"draw_white_space": "selection",
"enable_hexadecimal_encoding": true,
"enable_telemetry": "auto",
"ensure_newline_at_eof_on_save": true,
"fade_fold_buttons": true,
"fallback_encoding": "Western (Windows 1252)",
"file_exclude_patterns": [
"*.pyc",
"*.pyo",
"*.exe",
"*.dll",
"*.obj",
"*.o",
"*.a",
"*.lib",
"*.so",
"*.dylib",
"*.ncb",
"*.sdf",
"*.suo",
"*.pdb",
"*.idb",
".DS_Store",
"*.class",
"*.psd",
"*.db",
"*.sublime-workspace"
],
"find_selected_text": true,
"fold_buttons": true,
"folder_exclude_patterns": [
".svn",
".git",
".hg",
"CVS"
],
"font_face": "Inconsolata",
"font_options": [],
"font_size": 12,
"gpu_window_buffer": "auto",
"gutter": true,
"highlight_line": true,
"highlight_modified_tabs": false,
"hot_exit": true,
"ignored_packages": [
"Vintage", "PHP"
],
"indent_guide_options": [
"draw_normal"
],
"indent_subsequent_lines": true,
"indent_to_bracket": false,
"index_files": true,
"line_numbers": true,
"line_padding_bottom": 0,
"line_padding_top": 0,
"margin": 4,
"match_brackets": false,
"match_brackets_angle": false,
"match_brackets_braces": true,
"match_brackets_content": true,
"match_brackets_square": true,
"match_selection": true,
"match_tags": true,
"move_to_limit_on_up_down": false,
"open_files_in_new_window": true,
"overlay_scroll_bars": "system",
"preview_on_click": true,
"remember_open_files": true,
"rulers": [],
"save_on_focus_lost": false,
"scroll_past_end": true,
"scroll_speed": 1.0,
"shift_tab_unindent": false,
"show_full_path": true,
"show_panel_on_build": true,
"show_tab_close_buttons": true,
"smart_indent": true,
"spell_check": true,
"tab_completion": true,
"tab_size": 2,
"tern_command": [
"node",
"/usr/local/share/npm/lib/node_modules/tern/bin/tern"
],
"theme": "Default.sublime-theme",
"translate_tabs_to_spaces": true,
"tree_animation_enabled": true,
"trim_automatic_white_space": true,
"trim_trailing_white_space_on_save": true,
"use_simple_full_screen": false,
"use_tab_stops": true,
"word_separators": "./\\()\"'-:,.;<>~!@#$%^&*|+=[]{}`~?",
"word_wrap": "auto",
"wrap_width": 0
}
{
"default_extend_env": {
"PATH": "{PATH}:~/bin"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment