diff options
Diffstat (limited to 'cider.el')
-rw-r--r-- | cider.el | 118 |
1 files changed, 65 insertions, 53 deletions
@@ -1,7 +1,7 @@ ;;; cider.el --- Clojure Interactive Development Environment that Rocks -*- lexical-binding: t -*- ;; Copyright © 2012-2013 Tim King, Phil Hagelberg, Bozhidar Batsov -;; Copyright © 2013-2018 Bozhidar Batsov, Artur Malabarba and CIDER contributors +;; Copyright © 2013-2019 Bozhidar Batsov, Artur Malabarba and CIDER contributors ;; ;; Author: Tim King <kingtim@gmail.com> ;; Phil Hagelberg <technomancy@gmail.com> @@ -11,8 +11,8 @@ ;; Steve Purcell <steve@sanityinc.com> ;; Maintainer: Bozhidar Batsov <bozhidar@batsov.com> ;; URL: http://www.github.com/clojure-emacs/cider -;; Version: 0.18.0 -;; Package-Requires: ((emacs "25") (clojure-mode "5.9") (pkg-info "0.4") (queue "0.2") (spinner "1.7") (seq "2.16") (sesman "0.3")) +;; Version: 0.19.0 +;; Package-Requires: ((emacs "25") (clojure-mode "5.9") (pkg-info "0.4") (queue "0.2") (spinner "1.7") (seq "2.16") (sesman "0.3.2")) ;; Keywords: languages, clojure, cider ;; This program is free software: you can redistribute it and/or modify @@ -67,7 +67,7 @@ :prefix "cider-" :group 'applications :link '(url-link :tag "GitHub" "https://github.com/clojure-emacs/cider") - :link '(url-link :tag "Online Manual" "http://docs.cider.mx") + :link '(url-link :tag "Online Manual" "https://docs.cider.mx") :link '(emacs-commentary-link :tag "Commentary" "cider")) (require 'cider-client) @@ -86,12 +86,12 @@ (require 'seq) (require 'sesman) -(defconst cider-version "0.18.0" +(defconst cider-version "0.19.0" "Fallback version used when it cannot be extracted automatically. Normally it won't be used, unless `pkg-info' fails to extract the version from the CIDER package or library.") -(defconst cider-codename "Saigon" +(defconst cider-codename "Raleigh" "Codename used to denote stable releases.") (defcustom cider-lein-command @@ -108,7 +108,7 @@ version from the CIDER package or library.") :safe #'stringp) (defcustom cider-lein-parameters - "repl :headless :host ::" + "repl :headless :host localhost" "Params passed to Leiningen to start an nREPL server via `cider-jack-in'." :type 'string :group 'cider @@ -130,7 +130,7 @@ version from the CIDER package or library.") :package-version '(cider . "0.14.0")) (defcustom cider-boot-parameters - "cider.tasks/nrepl-server -b :: wait" + "cider.tasks/nrepl-server -b localhost wait" "Params passed to boot to start an nREPL server via `cider-jack-in'." :type 'string :group 'cider @@ -156,7 +156,7 @@ it using rlwrap." :package-version '(cider . "0.17.0")) (defcustom cider-clojure-cli-parameters - "-e '(require (quote cider-nrepl.main)) (cider-nrepl.main/init %s)'" + "-m nrepl.cmdline --middleware '%s'" "Params passed to clojure to start an nREPL server via `cider-jack-in'. This is evaluated using `format', with the first argument being the Clojure vector of middleware variables as a string." @@ -374,14 +374,16 @@ Throws an error if PROJECT-TYPE is unknown." (defvar cider-jack-in-dependencies nil "List of dependencies where elements are lists of artifact name and version.") (put 'cider-jack-in-dependencies 'risky-local-variable t) +;; We inject the newest known version of nREPL just in case +;; your version of Boot or Leiningen is bundling an older one. (cider-add-to-alist 'cider-jack-in-dependencies - "org.clojure/tools.nrepl" "0.2.13") + "nrepl" "0.5.3") (defvar cider-jack-in-cljs-dependencies nil "List of dependencies where elements are lists of artifact name and version. Added to `cider-jack-in-dependencies' when doing `cider-jack-in-cljs'.") (put 'cider-jack-in-cljs-dependencies 'risky-local-variable t) -(cider-add-to-alist 'cider-jack-in-cljs-dependencies "cider/piggieback" "0.3.9") +(cider-add-to-alist 'cider-jack-in-cljs-dependencies "cider/piggieback" "0.3.10") (defvar cider-jack-in-dependencies-exclusions nil "List of exclusions for jack in dependencies. @@ -402,7 +404,7 @@ Elements of the list are artifact name and list of exclusions to apply for the a (defconst cider-required-middleware-version "0.18.0" "The minimum CIDER nREPL version that's known to work properly with CIDER.") -(defconst cider-latest-middleware-version "0.18.0" +(defconst cider-latest-middleware-version "0.19.0" "The latest CIDER nREPL version that's known to work properly with CIDER.") (defcustom cider-jack-in-auto-inject-clojure nil @@ -650,12 +652,12 @@ Generally you should not disable this unless you run into some faulty check." (defun cider-verify-clojurescript-is-present () "Check whether ClojureScript is present." (unless (cider-library-present-p "clojure/clojurescript") - (user-error "ClojureScript is not available. See http://docs.cider.mx/en/latest/clojurescript for details"))) + (user-error "ClojureScript is not available. See https://docs.cider.mx/en/latest/clojurescript for details"))) (defun cider-verify-piggieback-is-present () "Check whether the piggieback middleware is present." (unless (cider-library-present-p "cider/piggieback") - (user-error "Piggieback is not available. See http://docs.cider.mx/en/latest/clojurescript for details"))) + (user-error "Piggieback 0.3.x (aka cider/piggieback) is not available. See https://docs.cider.mx/en/latest/clojurescript for details"))) (defun cider-check-nashorn-requirements () "Check whether we can start a Nashorn ClojureScript REPL." @@ -671,19 +673,19 @@ Generally you should not disable this unless you run into some faulty check." "Check whether we can start a Figwheel ClojureScript REPL." (cider-verify-piggieback-is-present) (unless (cider-library-present-p "figwheel-sidecar/figwheel-sidecar") - (user-error "Figwheel-sidecar is not available. Please check http://docs.cider.mx/en/latest/clojurescript"))) + (user-error "Figwheel-sidecar is not available. Please check https://docs.cider.mx/en/latest/clojurescript"))) (defun cider-check-figwheel-main-requirements () "Check whether we can start a Figwheel ClojureScript REPL." (cider-verify-piggieback-is-present) (unless (cider-library-present-p "bhauman/figwheel-main") - (user-error "Figwheel-main is not available. Please check http://docs.cider.mx/en/latest/clojurescript"))) + (user-error "Figwheel-main is not available. Please check https://docs.cider.mx/en/latest/clojurescript"))) (defun cider-check-weasel-requirements () "Check whether we can start a Weasel ClojureScript REPL." (cider-verify-piggieback-is-present) (unless (cider-library-present-p "weasel/weasel") - (user-error "Weasel in not available. Please check http://docs.cider.mx/en/latest/clojurescript/#browser-connected-clojurescript-repl"))) + (user-error "Weasel in not available. Please check https://docs.cider.mx/en/latest/clojurescript/#browser-connected-clojurescript-repl"))) (defun cider-check-boot-requirements () "Check whether we can start a Boot ClojureScript REPL." @@ -697,7 +699,7 @@ Generally you should not disable this unless you run into some faulty check." (user-error "The shadow-cljs ClojureScript REPL is not available"))) (defun cider-normalize-cljs-init-options (options) - "Normalize the OPTIONS string used for initializing a CLJS REPL." + "Normalize the OPTIONS string used for initializing a ClojureScript REPL." (if (or (string-prefix-p "{" options) (string-prefix-p "(" options) (string-prefix-p "[" options) @@ -807,10 +809,12 @@ relatively unlikely you'd like to use the same type of REPL in each project you're working on." :type '(choice (const :tag "Nashorn" nashorn) (const :tag "Figwheel" figwheel) + (const :tag "Figwheel Main" figwheel-main) (const :tag "Node" node) (const :tag "Weasel" weasel) (const :tag "Boot" boot) (const :tag "Shadow" shadow) + (const :tag "Shadow w/o Server" shadow-select) (const :tag "Custom" custom)) :group 'cider :safe #'symbolp @@ -823,7 +827,7 @@ you're working on." (defvar cider--select-cljs-repl-history nil) (defun cider-select-cljs-repl (&optional default) "Select the ClojureScript REPL to use with `cider-jack-in-cljs'. -DEFAULT is the default CLJS REPL to offer in completion." +DEFAULT is the default ClojureScript REPL to offer in completion." (let ((repl-types (mapcar #'car cider-cljs-repl-types))) (intern (completing-read "Select ClojureScript REPL type: " repl-types nil nil nil 'cider--select-cljs-repl-history @@ -847,11 +851,12 @@ Return REPL-TYPE if requirements are met." (let ((repl-type (or repl-type cider-default-cljs-repl (cider-select-cljs-repl)))) - (when-let* ((fun (nth 2 (seq-find - (lambda (entry) - (eq (car entry) repl-type)) - cider-cljs-repl-types)))) - (funcall fun)) + (when cider-check-cljs-repl-requirements + (when-let* ((fun (nth 2 (seq-find + (lambda (entry) + (eq (car entry) repl-type)) + cider-cljs-repl-types)))) + (funcall fun))) repl-type)) (defun cider--check-cljs (&optional cljs-type no-error) @@ -865,7 +870,7 @@ nil." (cider-verify-clojurescript-is-present) (cider-verify-cljs-repl-requirements cljs-type)) (error - (message "Invalid CLJS dependency: %S" ex) + (message "Invalid ClojureScript dependency: %S" ex) nil)) (cider-verify-clojurescript-is-present) (cider-verify-cljs-repl-requirements cljs-type))) @@ -884,6 +889,7 @@ nil." ;;; User Level Connectors +;;;###autoload (autoload 'cider-start-map "cider" "CIDER jack-in and connect keymap." t 'keymap) (defvar cider-start-map (let ((map (define-prefix-command 'cider-start-map))) (define-key map (kbd "x") #'cider) @@ -1002,7 +1008,7 @@ server is created." (cider--update-do-prompt) (append other-params) (plist-put :repl-init-function nil) - (plist-put :repl-type "clj") + (plist-put :repl-type 'clj) (plist-put :session-name ses-name))))) ;;;###autoload @@ -1024,11 +1030,11 @@ server buffer, in which case a new session for that server is created." (cider--update-cljs-type) (cider--update-cljs-init-function) (plist-put :session-name ses-name) - (plist-put :repl-type "pending-cljs"))))) + (plist-put :repl-type 'pending-cljs))))) ;;;###autoload (defun cider-connect-clj (&optional params) - "Initialize a CLJ connection to an nREPL server. + "Initialize a Clojure connection to an nREPL server. PARAMS is a plist optionally containing :host, :port and :project-dir. On prefix argument, prompt for all the parameters." (interactive "P") @@ -1039,11 +1045,11 @@ prefix argument, prompt for all the parameters." (cider--check-existing-session) (plist-put :repl-init-function nil) (plist-put :session-name nil) - (plist-put :repl-type "clj")))) + (plist-put :repl-type 'clj)))) ;;;###autoload (defun cider-connect-cljs (&optional params) - "Initialize a CLJS connection to an nREPL server. + "Initialize a ClojureScript connection to an nREPL server. PARAMS is a plist optionally containing :host, :port, :project-dir and :cljs-repl-type (e.g. Node, Figwheel, etc). On prefix, prompt for all the parameters regardless of their supplied or default values." @@ -1056,11 +1062,11 @@ parameters regardless of their supplied or default values." (cider--update-cljs-type) (cider--update-cljs-init-function) (plist-put :session-name nil) - (plist-put :repl-type "pending-cljs")))) + (plist-put :repl-type 'pending-cljs)))) ;;;###autoload (defun cider-connect-clj&cljs (params &optional soft-cljs-start) - "Initialize a CLJ and CLJS connection to an nREPL server.. + "Initialize a Clojure and ClojureScript connection to an nREPL server. PARAMS is a plist optionally containing :host, :port, :project-dir and :cljs-repl-type (e.g. Node, Figwheel, etc). When SOFT-CLJS-START is non-nil, don't start if ClojureScript requirements are not met." @@ -1229,7 +1235,7 @@ canceled the action, signal quit." (equal port (plist-get ses-params :port))) (or (null host) (equal host (plist-get ses-params :host)))))) - (sesman-linked-sessions 'CIDER '(project))))) + (sesman-current-sessions 'CIDER '(project))))) (when session (unless (y-or-n-p (concat @@ -1321,6 +1327,12 @@ Tramp version starting 26.1 is using a `cl-defstruct' rather than vanilla VEC." (make-tramp-file-name :method (elt vec 0) :host (elt vec 2))))) +(defcustom cider-infer-remote-nrepl-ports nil + "When true, cider will use ssh to try to infer nREPL ports on remote hosts." + :type 'boolean + :safe #'booleanp + :package-version '(cider . "0.19.0")) + (defun cider--infer-ports (host ssh-hosts) "Infer nREPL ports on HOST. Return a list of elements of the form (directory port). SSH-HOSTS is a list @@ -1332,14 +1344,15 @@ of remote SSH hosts." (let* ((change-dir-p (file-remote-p default-directory)) (default-directory (if change-dir-p "~/" default-directory))) (cider-locate-running-nrepl-ports (unless change-dir-p default-directory))) - (let ((vec (vector "sshx" nil host "" nil)) - ;; change dir: user might want to connect to a different remote - (dir (when (file-remote-p default-directory) - (with-parsed-tramp-file-name default-directory cur - (when (string= cur-host host) default-directory))))) - (tramp-maybe-open-connection (cider--tramp-file-name vec)) - (with-current-buffer (tramp-get-connection-buffer (cider--tramp-file-name vec)) - (cider-locate-running-nrepl-ports dir)))))) + (when cider-infer-remote-nrepl-ports + (let ((vec (vector "sshx" nil host "" nil)) + ;; change dir: user might want to connect to a different remote + (dir (when (file-remote-p default-directory) + (with-parsed-tramp-file-name default-directory cur + (when (string= cur-host host) default-directory))))) + (tramp-maybe-open-connection (cider--tramp-file-name vec)) + (with-current-buffer (tramp-get-connection-buffer (cider--tramp-file-name vec)) + (cider-locate-running-nrepl-ports dir))))))) (defun cider--completing-read-port (host ports) "Interactively select port for HOST from PORTS." @@ -1429,18 +1442,17 @@ assume the command is available." (shell-quote-argument command))) ;;;###autoload -(eval-after-load 'clojure-mode - '(progn - (define-key clojure-mode-map (kbd "C-c M-x") #'cider) - (define-key clojure-mode-map (kbd "C-c M-j") #'cider-jack-in-clj) - (define-key clojure-mode-map (kbd "C-c M-J") #'cider-jack-in-cljs) - (define-key clojure-mode-map (kbd "C-c M-c") #'cider-connect-clj) - (define-key clojure-mode-map (kbd "C-c M-C") #'cider-connect-cljs) - (define-key clojure-mode-map (kbd "C-c C-x") 'cider-start-map) - (define-key clojure-mode-map (kbd "C-c C-s") 'sesman-map) - (require 'sesman) - (sesman-install-menu clojure-mode-map) - (add-hook 'clojure-mode-hook (lambda () (setq-local sesman-system 'CIDER))))) +(with-eval-after-load 'clojure-mode + (define-key clojure-mode-map (kbd "C-c M-x") #'cider) + (define-key clojure-mode-map (kbd "C-c M-j") #'cider-jack-in-clj) + (define-key clojure-mode-map (kbd "C-c M-J") #'cider-jack-in-cljs) + (define-key clojure-mode-map (kbd "C-c M-c") #'cider-connect-clj) + (define-key clojure-mode-map (kbd "C-c M-C") #'cider-connect-cljs) + (define-key clojure-mode-map (kbd "C-c C-x") 'cider-start-map) + (define-key clojure-mode-map (kbd "C-c C-s") 'sesman-map) + (require 'sesman) + (sesman-install-menu clojure-mode-map) + (add-hook 'clojure-mode-hook (lambda () (setq-local sesman-system 'CIDER)))) (provide 'cider) |