Clojure via buck in fbcode
This commit is contained in:
parent
2b6ffefcc8
commit
459115d2a0
3 changed files with 83 additions and 1 deletions
|
|
@ -11,6 +11,9 @@
|
|||
'(c-indent-level 4)
|
||||
'(c-label-minimum-indentation 0)
|
||||
'(c-label-offset -4)
|
||||
'(clojure-build-tool-files
|
||||
(quote
|
||||
("project.clj" "build.boot" "build.gradle" "build.gradle.kts" "deps.edn" "shadow-cljs.edn" "TARGETS")))
|
||||
'(comint-input-ignoredups t)
|
||||
'(comint-prompt-read-only t)
|
||||
'(comint-scroll-to-bottom-on-input t)
|
||||
|
|
@ -58,7 +61,7 @@
|
|||
((sequence "TODO" "|" "DONE" "ABANDONED" "DEFERRED"))))
|
||||
'(package-selected-packages
|
||||
(quote
|
||||
(lsp-hack hack-mode rust-mode filladapt vc-hgcmd lsp-ui yaml-mode wgrep fsharp-mode company-lsp cquery mustache-mode clang-format projectile dash-functional mocha add-node-modules-path rjsx-mode xref-js2 js2-refactor company omnisharp geiser cider clojure-mode graphviz-dot-mode multi-term xterm-color thrift markdown-mode tuareg merlin ag use-package flycheck dockerfile-mode js2-mode web-mode zencoding-mode tss switch-window python-mode paredit magit lua-mode go-mode go-autocomplete exec-path-from-shell csharp-mode color-theme-monokai auto-complete auto-complete-nxml flymake flyspell json-mode popup ruby-mode company-jedi tide ahg elm-mode monky)))
|
||||
(xah-lookup lsp-hack hack-mode rust-mode filladapt vc-hgcmd lsp-ui yaml-mode wgrep fsharp-mode company-lsp cquery mustache-mode clang-format projectile dash-functional mocha add-node-modules-path rjsx-mode xref-js2 js2-refactor company omnisharp geiser cider clojure-mode graphviz-dot-mode multi-term xterm-color thrift markdown-mode tuareg merlin ag use-package flycheck dockerfile-mode js2-mode web-mode zencoding-mode tss switch-window python-mode paredit magit lua-mode go-mode go-autocomplete exec-path-from-shell csharp-mode color-theme-monokai auto-complete auto-complete-nxml flymake flyspell json-mode popup ruby-mode company-jedi tide ahg elm-mode monky)))
|
||||
'(reb-re-syntax (quote string))
|
||||
'(rmail-mail-new-frame t)
|
||||
'(safe-local-variable-values
|
||||
|
|
|
|||
|
|
@ -882,5 +882,17 @@
|
|||
:config
|
||||
(setq rust-format-on-save t))
|
||||
|
||||
;; =================================================================
|
||||
;; Clojure
|
||||
;; =================================================================
|
||||
(use-package cider :ensure
|
||||
:config
|
||||
;; I guess this is a bit wacky, but it's hard to imagine cider without
|
||||
;; clojure-mode right now.
|
||||
;;
|
||||
;; Put TARGETS in clojure-build-tool-files so that directories with TARGETS
|
||||
;; get identified as projects.
|
||||
(unless (member "TARGETS" clojure-build-tool-files)
|
||||
(setq clojure-build-tool-files (append clojure-build-tool-files '("TARGETS")))))
|
||||
|
||||
;;; init.el ends here
|
||||
|
|
|
|||
67
site-lisp/cider-buck.el
Normal file
67
site-lisp/cider-buck.el
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
;;; cider-buck.el --- Cider + Buck = Love -*- lexical-binding: t; -*-
|
||||
|
||||
;; Copyright (C) 2019 John Doty
|
||||
|
||||
;; Author: doty <doty@fb.com>
|
||||
;; Keywords: languages, clojure, cider
|
||||
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; This is just a bunch of funcitons to make cider work well with a buck
|
||||
;; project.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(defun cider-buck--nrepl-target ()
|
||||
"Get the nrepl buck target of the specified file name."
|
||||
(let ((src-file (buffer-file-name (current-buffer))))
|
||||
(with-temp-buffer
|
||||
(let ((status (call-process "buck" nil (current-buffer) nil
|
||||
"query" "owner('%s')" src-file)))
|
||||
(unless (eq status 0)
|
||||
(error (buffer-string)))
|
||||
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "__source-java[0-9]+$" nil t)
|
||||
(replace-match "_nrepl"))
|
||||
|
||||
(goto-char (point-min))
|
||||
(buffer-substring (point-min) (line-end-position))))))
|
||||
|
||||
(defun cider-buck--jack-in-cmd ()
|
||||
"Get it."
|
||||
(concat "buck run " (cider-buck--nrepl-target) " -- --middleware '["
|
||||
(mapconcat (apply-partially #'format "\"%s\"")
|
||||
(cider-jack-in-normalized-nrepl-middlewares)
|
||||
", ")
|
||||
"]'"))
|
||||
|
||||
(defun cider-buck--project-dir ()
|
||||
"Get the project dir by looking for a targets file."
|
||||
(locate-dominating-file (buffer-file-name (current-buffer)) "TARGETS"))
|
||||
|
||||
(defun cider-buck-jack-in ()
|
||||
"Start an nREPL server for the current file and connect to it."
|
||||
(interactive)
|
||||
(nrepl-start-server-process
|
||||
(cider-buck--project-dir)
|
||||
(cider-buck--jack-in-cmd)
|
||||
(lambda (server-buffer)
|
||||
(cider-connect-sibling-clj () server-buffer))))
|
||||
|
||||
|
||||
(provide 'cider-buck)
|
||||
;;; cider-buck.el ends here
|
||||
Loading…
Add table
Add a link
Reference in a new issue