tonsky / Clojure-Sublimed

Clojure support for Sublime Text 4
MIT License
359 stars 22 forks source link

SublimeREPL integration #2

Closed igoradamenko closed 4 years ago

igoradamenko commented 4 years ago

Hey Nikita!

I'm rolling into Clojure and setting up dev env, and I've heard in your talk on Clojure/north in Toronto the story about this package. That's why I've installed it. But SublimeREPL doesn't work with it by default. It runs lein repl in background, opens new tab for *REPL* [clojure], however when I send any selected code there it says it can't find a REPL for clojurec.

I've fixed this by defining user configs for Sublime REPL inside ~/Library/Application Support/Sublime Text 3/Packages/User/SublimeREPL/config/Clojure. I've added Main.sublime-menu:

[
     {
        "id": "tools",
        "children":
        [{
            "caption": "SublimeREPL",
            "mnemonic": "R",
            "id": "SublimeREPL",
            "children":
            [
                {"caption": "Clojure",
                 "id": "Clojure",
                 "children":[
                    {"command": "repl_open", 
                     "caption": "ClojureC",
                     "id": "repl_clojurec",
                     "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",
                                "linux": "$file_path",
                                "osx": "$file_path"},
                        "syntax": "Packages/sublime-clojure/ClojureC.tmLanguage",
                        "external_id": "clojurec",
                        "extend_env": {"INSIDE_EMACS": "1"}
                        }
                    }]
                }
            ]   
        }]
    }
]

And Default.sublime-commands:

[
    {
        "caption": "SublimeREPL: ClojureC",
        "command": "run_existing_window_command", "args":
        {
            "id": "repl_clojurec",
            "file": "config/Clojure/Main.sublime-menu"
        }
    },
]

They defines new REPL as clojurec and also applies sublime-clojure to it.

Now REPL for ClojureC is available in menu:

Captura de pantalla 2019-09-16 a las 16 48 27

And I've checked the syntax highlighting by testing it with the one of the strings from your testing files. Before:

Captura de pantalla 2019-09-16 a las 16 39 55

Now:

Captura de pantalla 2019-09-16 a las 16 39 28

And of course everything works properly with sending selected code into REPL.

I'm not sure whether it's a big deal or not, because I haven't had any Clojure experience yet, but when I googled plugins for REPL I got an impression that this one is the most popular for this purpose. So maybe you need to improve the docs by adding Troubleshooting section.

tonsky commented 4 years ago

Sublime-clojure does not provide repl. You need a separate plugin for that (like SublimeREPL). What do you think I should change in the documentation?

igoradamenko commented 4 years ago

Yes, of course I understand that it doesn't provide a REPL.

I thought that you could add a note about SublimeREPL's Clojure REPL which breaks because of installing sublime-clojure. And I thought it would be worth to note that sublime-clojure can fix highlighting not only inside Sublime Text but inside SublimeREPL too.

So, it's not an issue “because sublime-clojure doesn't work”, it's “because it can be a bit more friendly”.

But maybe I'm wrong and it doesn't worth to be noted. Feel free to close the issue in this case.

tonsky commented 4 years ago

Sorry, I didn’t understand what you were doing. So you enabled sublime-clojure for SublimeREPL. Now I get it. Yes of course it’s useful

tonsky commented 4 years ago

Added to README. Thanks!