diff --git a/CHANGELOG.develop b/CHANGELOG.develop index 569efcba4..a040649f0 100644 --- a/CHANGELOG.develop +++ b/CHANGELOG.develop @@ -1419,10 +1419,14 @@ Other: - Added ~SPC m o R~ to macroexpand print region - Added elixir format keybind (thanks to Perry Fraser) - ~SPC m =~ to format current buffer -- Change binding of =alchemist-project-find-test= from - ~SPC m p t~ to ~SPC m t F~ (thanks to Lyuben Petrov) +- Change binding of =alchemist-project-find-test= from + ~SPC m p t~ to ~SPC m t F~ (thanks to Lyuben Petrov) - Mark alchemist jump handler as async (thanks to Lukasz Czaplinski) - Added elixir-ls backend (thanks to mpanarin) +- Added breakpoint toggle to alchemist binds (thanks to mpanarin) + - Added ~SPC m d b~ to toggle IEx.pry breakpoint +- lsp layer is a dependency when backend is set to 'lsp (thanks to mpanarin) +- "C-j" indents line properly (thanks to mpanarin) **** Elm - Fixed flycheck initialization (thanks to Kevin W. van Rooijen) - Added =elm-test-runner= (thanks to Juan Edi) diff --git a/layers/+lang/elixir/README.org b/layers/+lang/elixir/README.org index 141df8636..dd20067fb 100644 --- a/layers/+lang/elixir/README.org +++ b/layers/+lang/elixir/README.org @@ -33,6 +33,7 @@ - [[#hex-packages][Hex (packages)]] - [[#macro-expand][Macro expand]] - [[#formatting][Formatting]] + - [[#debugging][Debugging]] - [[#lsp][LSP]] * Description @@ -333,5 +334,11 @@ Hex is the package manager for Elixir & Erlang ecosystem. See [[https://hex.pm]] |-------------+---------------------------| | ~SPC m =~ | Format the current buffer | +*** Debugging + +| Key binding | Description | +|-------------+---------------------------| +| ~SPC m d b~ | Toggle IEx.pry breakpoint | + ** LSP You find and overview of all the key bindings on the [[https://github.com/syl20bnr/spacemacs/tree/develop/layers/%2Btools/lsp#key-bindings][lsp layer description]]. diff --git a/layers/+lang/elixir/funcs.el b/layers/+lang/elixir/funcs.el index 4327f85ad..2f1df024e 100644 --- a/layers/+lang/elixir/funcs.el +++ b/layers/+lang/elixir/funcs.el @@ -65,6 +65,14 @@ ;; others +(defun spacemacs//elixir-default () + "Default settings for elixir buffers" + + ;; highlight all breakpoints + (spacemacs/elixir-annotate-pry) + ;; make C-j work the same way as RET + (local-set-key (kbd "C-j") 'newline-and-indent)) + (defun spacemacs//elixir-looking-back-special-p (expr) (save-excursion (when (or (looking-back " ") @@ -93,3 +101,20 @@ (flycheck-mix-setup) ;; enable credo only if there are no compilation errors (flycheck-add-next-checker 'elixir-mix '(warning . elixir-credo)))) + +(defun spacemacs/elixir-annotate-pry () + "Highlight breakpoint lines." + (interactive) + (highlight-lines-matching-regexp "require IEx; IEx.pry")) + +(defun spacemacs/elixir-toggle-breakpoint () + "Add a breakpoint line or clear it if line is already a breakpoint." + (interactive) + (let ((trace "require IEx; IEx.pry") + (line (thing-at-point 'line))) + (if (and line (string-match trace line)) + (kill-whole-line) + (progn + (back-to-indentation) + (insert trace) + (newline-and-indent))))) diff --git a/layers/+lang/elixir/layers.el b/layers/+lang/elixir/layers.el new file mode 100644 index 000000000..189eb7c3d --- /dev/null +++ b/layers/+lang/elixir/layers.el @@ -0,0 +1,14 @@ +;;; layers.el --- Elixir Layer declarations File for Spacemacs +;; +;; Copyright (c) 2012-2019 Sylvain Benner & Contributors +;; +;; Author: Sylvain Benner +;; URL: https://github.com/syl20bnr/spacemacs +;; +;; This file is not part of GNU Emacs. +;; +;;; License: GPLv3 + +(when (and (boundp 'elixir-backend) + (eq elixir-backend 'lsp)) + (configuration-layer/declare-layer 'lsp)) diff --git a/layers/+lang/elixir/packages.el b/layers/+lang/elixir/packages.el index be1c330cf..bc5c0f943 100644 --- a/layers/+lang/elixir/packages.el +++ b/layers/+lang/elixir/packages.el @@ -53,6 +53,7 @@ (spacemacs/declare-prefix-for-mode 'elixir-mode "ms" "iex") (spacemacs/declare-prefix-for-mode 'elixir-mode "mt" "test") (spacemacs/declare-prefix-for-mode 'elixir-mode "mx" "execute") + (spacemacs/declare-prefix-for-mode 'elixir-mode "md" "debug") (spacemacs/set-leader-keys-for-major-mode 'elixir-mode "el" 'alchemist-eval-current-line "eL" 'alchemist-eval-print-current-line @@ -130,7 +131,9 @@ "oi" 'alchemist-macroexpand-once-region "oI" 'alchemist-macroexpand-once-print-region "or" 'alchemist-macroexpand-region - "oR" 'alchemist-macroexpand-print-region) + "oR" 'alchemist-macroexpand-print-region + + "db" 'spacemacs/elixir-toggle-breakpoint) (dolist (mode (list alchemist-compile-mode-map alchemist-eval-mode-map @@ -165,7 +168,8 @@ (use-package elixir-mode :defer t :init (spacemacs/add-to-hook 'elixir-mode-hook - '(spacemacs//elixir-setup-backend)) + '(spacemacs//elixir-setup-backend + spacemacs//elixir-default)) :config (spacemacs/set-leader-keys-for-major-mode 'elixir-mode "=" 'elixir-format)))