Use dap mode layer for python debugging

- I had to remove the "db" keybinding manually before setting the dap bindings.
  An alternative approach is to use a different binding for it.
This commit is contained in:
Ivan Yonchovski 2019-04-14 13:15:21 +03:00 committed by smile13241324
parent cf498b01dc
commit 59c4f1f283
3 changed files with 61 additions and 1 deletions

View File

@ -1881,6 +1881,7 @@ Other:
- Fixed conflict between pipenv directory .venv and pyvenv file .venv (thanks to
rgb-24bit)
- Added diminish for importmagic (thanks to Loys Ollivier)
- Added debugger integration via =dap= layer
**** Racket
- Restore smart closing paren behavior in racket-mode (thanks to Don March)
**** Ranger

View File

@ -18,6 +18,7 @@
- [[#automatic-save-of-buffer-when-testing][Automatic save of buffer when testing]]
- [[#autoflake][autoflake]]
- [[#pylookup][pylookup]]
- [[#dap-mode-debuggeronly-for-lsp-backend][dap-mode debugger(only for lsp backend)]]
- [[#configuration][Configuration]]
- [[#fill-column][Fill column]]
- [[#sort-imports][Sort imports]]
@ -33,6 +34,7 @@
- [[#pip-package-management][Pip package management]]
- [[#live-coding][Live coding]]
- [[#other-python-commands][Other Python commands]]
- [[#debugger][Debugger]]
* Description
This layer adds support for the Python language.
@ -191,6 +193,11 @@ To be able to suppress unused imports easily, install [[https://github.com/myint
To use =pylookup= on ~SPC m h H~, make sure you update the database first, using
~SPC SPC pylookup-update~.
** dap-mode debugger(only for lsp backend)
To use =dap-mode= for debugging do:
#+BEGIN_SRC bash
pip install "ptvsd>=4.2"
#+END_SRC
* Configuration
** Fill column
If you want to customize the fill column value, use something like this inside
@ -377,3 +384,49 @@ Live coding is provided by the [[https://github.com/donkirkby/live-py-plugin][li
| ~SPC m v p o~ | open pipenv module in buffer |
| ~SPC m v p s~ | launch pipenv shell in current project |
| ~SPC m v p u~ | uninstall module from pipenv environment |
** Debugger
| Key binding | Description |
|---------------+---------------------------------|
| ~SPC m d d d~ | start debugging |
| ~SPC m d d l~ | debug last configuration |
| ~SPC m d d r~ | debug recent configuration |
|---------------+---------------------------------|
| ~SPC m d c~ | continue |
| ~SPC m d i~ | step in |
| ~SPC m d o~ | step out |
| ~SPC m d s~ | next step |
| ~SPC m d v~ | inspect value at point |
| ~SPC m d r~ | restart frame |
|---------------+---------------------------------|
| ~SPC m d .~ | debug transient state |
|---------------+---------------------------------|
| ~SPC m d a~ | abandon current session |
| ~SPC m d A~ | abandon all process |
|---------------+---------------------------------|
| ~SPC m d e e~ | eval |
| ~SPC m d e r~ | eval region |
| ~SPC m d e t~ | eval value at point |
|---------------+---------------------------------|
| ~SPC m d S s~ | switch session |
| ~SPC m d S t~ | switch thread |
| ~SPC m d S f~ | switch frame |
|---------------+---------------------------------|
| ~SPC m d I i~ | inspect |
| ~SPC m d I r~ | inspect region |
| ~SPC m d I t~ | inspect value at point |
|---------------+---------------------------------|
| ~SPC m d b b~ | toggle a breakpoint |
| ~SPC m d b c~ | change breakpoint condition |
| ~SPC m d b l~ | change breakpoint log condition |
| ~SPC m d b h~ | change breakpoint hit count |
| ~SPC m d b a~ | add a breakpoint |
| ~SPC m d b d~ | delete a breakpoint |
| ~SPC m d b D~ | clear all breakpoints |
|---------------+---------------------------------|
| ~SPC m d '_~ | Run debug REPL |
|---------------+---------------------------------|
| ~SPC m d w l~ | list local variables |
| ~SPC m d w o~ | goto output buffer if present |
| ~SPC m d w s~ | list sessions |
| ~SPC m d w b~ | list breakpoints |

View File

@ -69,7 +69,13 @@ when this mode is enabled since the minibuffer is cleared all the time."
"Setup lsp backend."
(if (configuration-layer/layer-used-p 'lsp)
(lsp)
(message "`lsp' layer is not installed, please add `lsp' layer to your dotfile.")))
(message "`lsp' layer is not installed, please add `lsp' layer to your dotfile."))
(if (configuration-layer/layer-used-p 'dap)
(progn
(require 'dap-python)
(spacemacs/set-leader-keys-for-major-mode 'python-mode "db" nil)
(spacemacs/dap-bind-keys-for-mode 'python-mode))
(message "`dap' layer is not installed, please add `dap' layer to your dotfile.")))
(defun spacemacs//python-setup-lsp-company ()
"Setup lsp auto-completion."