[elixir] layer improevements

- declare lsp layer dependency if elixir-backind is lsp
- "C-j" now properly indents line
- add toggle breakpoint for elixir-mode

update CHANGELOG.develop
This commit is contained in:
mpanarin 2019-09-06 11:00:51 +03:00 committed by smile13241324
parent 0cec3d0a69
commit 135a1fd460
5 changed files with 58 additions and 4 deletions

View File

@ -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)

View File

@ -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]].

View File

@ -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)))))

View File

@ -0,0 +1,14 @@
;;; layers.el --- Elixir Layer declarations File for Spacemacs
;;
;; Copyright (c) 2012-2019 Sylvain Benner & Contributors
;;
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
;; 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))

View File

@ -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)))