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
|
projects
|
||||||
speed-type/
|
speed-type/
|
||||||
var/
|
var/
|
||||||
|
.dap-breakpoints
|
||||||
|
eclipse.jdt.ls/
|
||||||
|
workspace/
|
@ -17,9 +17,9 @@
|
|||||||
:straight t
|
:straight t
|
||||||
:diminish
|
:diminish
|
||||||
:commands (lsp-enable-which-key-integration
|
:commands (lsp-enable-which-key-integration
|
||||||
lsp-format-buffer
|
lsp-format-buffer
|
||||||
lsp-organize-imports
|
lsp-organize-imports
|
||||||
lsp-install-server)
|
lsp-install-server)
|
||||||
:hook ((prog-mode . (lambda ()
|
:hook ((prog-mode . (lambda ()
|
||||||
(unless (derived-mode-p 'emacs-lisp-mode 'lisp-mode 'makefile-mode)
|
(unless (derived-mode-p 'emacs-lisp-mode 'lisp-mode 'makefile-mode)
|
||||||
(lsp-deferred))))
|
(lsp-deferred))))
|
||||||
@ -42,37 +42,37 @@
|
|||||||
|
|
||||||
lsp-enable-indentation nil
|
lsp-enable-indentation nil
|
||||||
lsp-enable-on-type-formatting nil)
|
lsp-enable-on-type-formatting nil)
|
||||||
:config
|
:config
|
||||||
(with-no-warnings
|
(with-no-warnings
|
||||||
;; Disable `lsp-mode' in `git-timemachine-mode'
|
;; Disable `lsp-mode' in `git-timemachine-mode'
|
||||||
(defun my-lsp--init-if-visible (fn &rest args)
|
(defun my-lsp--init-if-visible (fn &rest args)
|
||||||
(unless (bound-and-true-p git-timemachine-mode)
|
(unless (bound-and-true-p git-timemachine-mode)
|
||||||
(apply fn args)))
|
(apply fn args)))
|
||||||
(advice-add #'lsp--init-if-visible :around #'my-lsp--init-if-visible)
|
(advice-add #'lsp--init-if-visible :around #'my-lsp--init-if-visible)
|
||||||
|
|
||||||
;; Enable `lsp-mode' in sh/bash/zsh
|
;; Enable `lsp-mode' in sh/bash/zsh
|
||||||
(defun my-lsp-bash-check-sh-shell (&rest _)
|
(defun my-lsp-bash-check-sh-shell (&rest _)
|
||||||
(and (eq major-mode 'sh-mode)
|
(and (eq major-mode 'sh-mode)
|
||||||
(memq sh-shell '(sh bash zsh))))
|
(memq sh-shell '(sh bash zsh))))
|
||||||
(advice-add #'lsp-bash-check-sh-shell :override #'my-lsp-bash-check-sh-shell)
|
(advice-add #'lsp-bash-check-sh-shell :override #'my-lsp-bash-check-sh-shell)
|
||||||
|
|
||||||
;; Only display icons in GUI
|
;; Only display icons in GUI
|
||||||
(defun my-lsp-icons-get-symbol-kind (fn &rest args)
|
(defun my-lsp-icons-get-symbol-kind (fn &rest args)
|
||||||
(and (icon-displayable-p) (apply fn args)))
|
(and (icon-displayable-p) (apply fn args)))
|
||||||
(advice-add #'lsp-icons-get-by-symbol-kind :around #'my-lsp-icons-get-symbol-kind)
|
(advice-add #'lsp-icons-get-by-symbol-kind :around #'my-lsp-icons-get-symbol-kind)
|
||||||
|
|
||||||
(defun my-lsp-icons-get-by-file-ext (fn &rest args)
|
(defun my-lsp-icons-get-by-file-ext (fn &rest args)
|
||||||
(and (icon-displayable-p) (apply fn args)))
|
(and (icon-displayable-p) (apply fn args)))
|
||||||
(advice-add #'lsp-icons-get-by-file-ext :around #'my-lsp-icons-get-by-file-ext)
|
(advice-add #'lsp-icons-get-by-file-ext :around #'my-lsp-icons-get-by-file-ext)
|
||||||
|
|
||||||
(defun my-lsp-icons-all-the-icons-material-icon (icon-name face fallback &optional feature)
|
(defun my-lsp-icons-all-the-icons-material-icon (icon-name face fallback &optional feature)
|
||||||
(if (and (icon-displayable-p)
|
(if (and (icon-displayable-p)
|
||||||
(lsp-icons--enabled-for-feature feature))
|
(lsp-icons--enabled-for-feature feature))
|
||||||
(all-the-icons-material icon-name
|
(all-the-icons-material icon-name
|
||||||
:face face)
|
:face face)
|
||||||
(propertize fallback 'face face)))
|
(propertize fallback 'face face)))
|
||||||
(advice-add #'lsp-icons-all-the-icons-material-icon
|
(advice-add #'lsp-icons-all-the-icons-material-icon
|
||||||
:override #'my-lsp-icons-all-the-icons-material-icon))
|
:override #'my-lsp-icons-all-the-icons-material-icon))
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -81,7 +81,7 @@
|
|||||||
:defer t
|
:defer t
|
||||||
:straight t
|
:straight t
|
||||||
:bind (:map lsp-mode-map
|
:bind (:map lsp-mode-map
|
||||||
("<f1>" . lsp-ui-doc-glance))
|
("<f1>" . lsp-ui-doc-glance))
|
||||||
:hook (lsp-mode . lsp-ui-mode)
|
:hook (lsp-mode . lsp-ui-mode)
|
||||||
|
|
||||||
:init
|
:init
|
||||||
@ -106,5 +106,111 @@
|
|||||||
(add-hook 'after-load-theme-hook #'my-lsp-ui-doc-set-border t)
|
(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)
|
(provide 'base-lsp)
|
||||||
;;; base-lsp.el ends here
|
;;; base-lsp.el ends here
|
||||||
|
Loading…
Reference in New Issue
Block a user