Add dap mode for debug and lsp for java.
This commit is contained in:
parent
6dbf0e9746
commit
cb445f95c0
3
.gitignore
vendored
3
.gitignore
vendored
@ -15,3 +15,6 @@ amx-items
|
||||
projects
|
||||
speed-type/
|
||||
var/
|
||||
.dap-breakpoints
|
||||
eclipse.jdt.ls/
|
||||
workspace/
|
@ -106,5 +106,111 @@
|
||||
(add-hook 'after-load-theme-hook #'my-lsp-ui-doc-set-border t)
|
||||
)
|
||||
|
||||
;; Integración con ivy
|
||||
(use-package lsp-ivy
|
||||
:defer t
|
||||
:straight t
|
||||
:after lsp-mode
|
||||
:bind (:map lsp-mode-map
|
||||
([remap xref-find-apropos] . lsp-ivy-workspace-symbol)
|
||||
("C-s-." . lsp-ivy-global-workspace-symbol))
|
||||
:config
|
||||
(with-no-warnings
|
||||
(when (icon-displayable-p)
|
||||
(defvar lsp-ivy-symbol-kind-icons
|
||||
`(,(all-the-icons-material "find_in_page" :height 0.9 :v-adjust -0.15) ; Unknown - 0
|
||||
,(all-the-icons-faicon "file-o" :height 0.9 :v-adjust -0.02) ; File - 1
|
||||
,(all-the-icons-material "view_module" :height 0.9 :v-adjust -0.15 :face 'all-the-icons-lblue) ; Module - 2
|
||||
,(all-the-icons-material "view_module" :height 0.95 :v-adjust -0.15 :face 'all-the-icons-lblue) ; Namespace - 3
|
||||
,(all-the-icons-octicon "package" :height 0.9 :v-adjust -0.15) ; Package - 4
|
||||
,(all-the-icons-material "settings_input_component" :height 0.9 :v-adjust -0.15 :face 'all-the-icons-orange) ; Class - 5
|
||||
,(all-the-icons-faicon "cube" :height 0.9 :v-adjust -0.02 :face 'all-the-icons-purple) ; Method - 6
|
||||
,(all-the-icons-faicon "wrench" :height 0.8 :v-adjust -0.02) ; Property - 7
|
||||
,(all-the-icons-octicon "tag" :height 0.95 :v-adjust 0 :face 'all-the-icons-lblue) ; Field - 8
|
||||
,(all-the-icons-faicon "cube" :height 0.9 :v-adjust -0.02 :face 'all-the-icons-lpurple) ; Constructor - 9
|
||||
,(all-the-icons-material "storage" :height 0.9 :v-adjust -0.15 :face 'all-the-icons-orange) ; Enum - 10
|
||||
,(all-the-icons-material "share" :height 0.9 :v-adjust -0.15 :face 'all-the-icons-lblue) ; Interface - 11
|
||||
,(all-the-icons-faicon "cube" :height 0.9 :v-adjust -0.02 :face 'all-the-icons-purple) ; Function - 12
|
||||
,(all-the-icons-octicon "tag" :height 0.95 :v-adjust 0 :face 'all-the-icons-lblue) ; Variable - 13
|
||||
,(all-the-icons-faicon "cube" :height 0.9 :v-adjust -0.02 :face 'all-the-icons-purple) ; Constant - 14
|
||||
,(all-the-icons-faicon "text-width" :height 0.9 :v-adjust -0.02) ; String - 15
|
||||
,(all-the-icons-material "format_list_numbered" :height 0.95 :v-adjust -0.15) ; Number - 16
|
||||
,(all-the-icons-octicon "tag" :height 0.9 :v-adjust 0.0 :face 'all-the-icons-lblue) ; Boolean - 17
|
||||
,(all-the-icons-material "view_array" :height 0.95 :v-adjust -0.15) ; Array - 18
|
||||
,(all-the-icons-octicon "tag" :height 0.9 :v-adjust 0.0 :face 'all-the-icons-blue) ; Object - 19
|
||||
,(all-the-icons-faicon "key" :height 0.9 :v-adjust -0.02) ; Key - 20
|
||||
,(all-the-icons-octicon "tag" :height 0.9 :v-adjust 0.0) ; Null - 21
|
||||
,(all-the-icons-material "format_align_right" :height 0.95 :v-adjust -0.15 :face 'all-the-icons-lblue) ; EnumMember - 22
|
||||
,(all-the-icons-material "settings_input_component" :height 0.9 :v-adjust -0.15 :face 'all-the-icons-orange) ; Struct - 23
|
||||
,(all-the-icons-octicon "zap" :height 0.9 :v-adjust 0 :face 'all-the-icons-orange) ; Event - 24
|
||||
,(all-the-icons-material "control_point" :height 0.9 :v-adjust -0.15) ; Operator - 25
|
||||
,(all-the-icons-faicon "arrows" :height 0.9 :v-adjust -0.02) ; TypeParameter - 26
|
||||
))
|
||||
|
||||
(lsp-defun my-lsp-ivy--format-symbol-match
|
||||
((sym &as &SymbolInformation :kind :location (&Location :uri))
|
||||
project-root)
|
||||
"Convert the match returned by `lsp-mode` into a candidate string."
|
||||
(let* ((sanitized-kind (if (< kind (length lsp-ivy-symbol-kind-icons)) kind 0))
|
||||
(type (elt lsp-ivy-symbol-kind-icons sanitized-kind))
|
||||
(typestr (if lsp-ivy-show-symbol-kind (format "%s " type) ""))
|
||||
(pathstr (if lsp-ivy-show-symbol-filename
|
||||
(propertize (format " · %s" (file-relative-name (lsp--uri-to-path uri) project-root))
|
||||
'face font-lock-comment-face)
|
||||
"")))
|
||||
(concat typestr (lsp-render-symbol-information sym ".") pathstr)))
|
||||
(advice-add #'lsp-ivy--format-symbol-match :override #'my-lsp-ivy--format-symbol-match))))
|
||||
|
||||
;; Debug
|
||||
(use-package dap-mode
|
||||
:defer t
|
||||
:straight t
|
||||
:defines dap-python-executable
|
||||
:functions dap-hydra/nil
|
||||
:diminish
|
||||
:bind (:map lsp-mode-map
|
||||
("<f5>" . dap-debug)
|
||||
("M-<f5>" . dap-hydra))
|
||||
:hook ((after-init . dap-auto-configure-mode)
|
||||
(dap-stopped . (lambda (_args) (dap-hydra)))
|
||||
(dap-terminated . (lambda (_args) (dap-hydra/nil)))
|
||||
|
||||
(python-mode . (lambda () (require 'dap-python)))
|
||||
(ruby-mode . (lambda () (require 'dap-ruby)))
|
||||
(go-mode . (lambda () (require 'dap-go)))
|
||||
(java-mode . (lambda () (require 'dap-java)))
|
||||
((c-mode c++-mode objc-mode swift-mode) . (lambda () (require 'dap-lldb)))
|
||||
(php-mode . (lambda () (require 'dap-php)))
|
||||
(elixir-mode . (lambda () (require 'dap-elixir)))
|
||||
((js-mode js2-mode) . (lambda () (require 'dap-chrome)))
|
||||
(powershell-mode . (lambda () (require 'dap-pwsh))))
|
||||
:init
|
||||
(setq dap-auto-configure-features '(sessions locals breakpoints expressions controls))
|
||||
(when (executable-find "python3")
|
||||
(setq dap-python-executable "python3")))
|
||||
|
||||
;; Python debug
|
||||
(use-package lsp-pyright
|
||||
:defer t
|
||||
:straight t
|
||||
:preface
|
||||
;; Use yapf to format
|
||||
(defun lsp-pyright-format-buffer ()
|
||||
(interactive)
|
||||
(when (and (executable-find "yapf") buffer-file-name)
|
||||
(call-process "yapf" nil nil nil "-i" buffer-file-name)))
|
||||
:hook (python-mode . (lambda ()
|
||||
(require 'lsp-pyright)
|
||||
(add-hook 'after-save-hook #'lsp-pyright-format-buffer t t)))
|
||||
:init (when (executable-find "python3")
|
||||
(setq lsp-pyright-python-executable-cmd "python3")))
|
||||
|
||||
;; Java LSP
|
||||
(use-package lsp-java
|
||||
:defer t
|
||||
:straight t
|
||||
:hook (java-mode . (lambda () (require 'lsp-java))))
|
||||
|
||||
|
||||
(provide 'base-lsp)
|
||||
;;; base-lsp.el ends here
|
||||
|
Loading…
Reference in New Issue
Block a user