add lspmode

doesnt really work
This commit is contained in:
Lucas Barbieri 2024-04-17 10:32:25 -03:00
parent 4fb36dc65b
commit da1183b9fc
2 changed files with 86 additions and 40 deletions

View File

@ -5,7 +5,7 @@
;; If there is more than one, they won't work right. ;; If there is more than one, they won't work right.
'(helm-minibuffer-history-key "M-p") '(helm-minibuffer-history-key "M-p")
'(package-selected-packages '(package-selected-packages
'(projectile yasnippet-snippets which-key powerline-evil magit helm go-mode evil-collection doom-themes corfu company-fuzzy beacon))) '(golint helm-xref yasnippet-snippets which-key vue-mode projectile powerline-evil paredit magit lsp-ui lsp-pyright helm flycheck flx evil-collection doom-themes dap-mode corfu company-go company-fuzzy beacon all-the-icons)))
(custom-set-faces (custom-set-faces
;; custom-set-faces was added by Custom. ;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful. ;; If you edit it by hand, you could mess it up, so be careful.

View File

@ -7,6 +7,9 @@
(require 'package) (require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-initialize) (package-initialize)
(when (not (package-installed-p 'use-package))
(package-refresh-contents)
(package-install 'use-package))
(require 'use-package) (require 'use-package)
(setq-default (setq-default
@ -81,6 +84,7 @@
:ensure t :ensure t
:init :init
(setq evil-want-C-u-scroll t) (setq evil-want-C-u-scroll t)
(setq evil-want-C-i-jump nil)
:config :config
(evil-mode 1)) (evil-mode 1))
@ -102,58 +106,104 @@
(use-package company (use-package company
:ensure t :ensure t
:init :init
(setq company-require-match nil ; Don't require match, so you can still move your cursor as expected. (setq company-require-match nil ; Don't require match, so you can still move your cursor as expected.
company-tooltip-align-annotations t ; Align annotation to the right side. company-tooltip-align-annotations t ; Align annotation to the right side.
company-eclim-auto-save nil ; Stop eclim auto save. company-eclim-auto-save nil ; Stop eclim auto save.
company-dabbrev-downcase nil) ; No downcase when completion. company-dabbrev-downcase nil
) company-idle-delay 0.2) ; No downcase when completion.
:config
(global-company-mode t))
(use-package which-key (use-package which-key
:config :config
(setq which-key-idle-delay 0.3) (setq which-key-idle-delay 0.3)
(setq which-key-popup-type 'frame) (setq which-key-popup-type 'frame)
(which-key-mode) (which-key-mode)
(which-key-setup-minibuffer) (which-key-setup-minibuffer)
(set-face-attribute 'which-key-local-map-description-face nil (set-face-attribute 'which-key-local-map-description-face nil
:weight 'bold) :weight 'bold)
:ensure t) :ensure t)
(use-package magit
:ensure t
:bind ("C-x g" . magit-status))
(use-package eglot (use-package paredit
:ensure t) :ensure t
:init
(add-hook 'clojure-mode-hook #'enable-paredit-mode)
(add-hook 'cider-repl-mode-hook #'enable-paredit-mode)
(add-hook 'emacs-lisp-mode-hook #'enable-paredit-mode)
(add-hook 'eval-expression-minibuffer-setup-hook #'enable-paredit-mode)
(add-hook 'ielm-mode-hook #'enable-paredit-mode)
(add-hook 'lisp-mode-hook #'enable-paredit-mode)
(add-hook 'lisp-interaction-mode-hook #'enable-paredit-mode)
(add-hook 'scheme-mode-hook #'enable-paredit-mode)
:config
(show-paren-mode t)
:bind (("M-[" . paredit-wrap-square)
("M-{" . paredit-wrap-curly))
:diminish nil)
(use-package yasnippet (use-package yasnippet
:ensure t :ensure t
:config :config
(yas-global-mode 1)) (yas-global-mode 1))
;; setup go (use-package flycheck
(require 'project) :ensure t
:config
(add-hook 'after-init-hook #'global-flycheck-mode))
(defun project-find-go-module (dir) ;; setup lsp
(when-let ((root (locate-dominating-file dir "go.mod"))) (use-package lsp-mode
(cons 'go-module root))) :init
;; set prefix for lsp-command-keymap (few alternatives - "C-l", "C-c l")
(setq lsp-keymap-prefix "C-c l")
:hook (;; replace XXX-mode with concrete major-mode(e. g. python-mode)
(go-mode . lsp)
(vue-mode . lsp)
;; if you want which-key integration
(lsp-mode . lsp-enable-which-key-integration))
:commands lsp)
(cl-defmethod project-root ((project (head go-module))) (use-package lsp-pyright
(cdr project)) :ensure t
:hook (python-mode . (lambda ()
(require 'lsp-pyright)
(lsp))))
(add-hook 'project-find-functions #'project-find-go-module) ;; Go - lsp-mode
;; Set up before-save hooks to format buffer and add/delete imports.
(defun lsp-go-install-save-hooks ()
(add-hook 'before-save-hook #'lsp-format-buffer t t)
(add-hook 'before-save-hook #'lsp-organize-imports t t))
(add-hook 'go-mode-hook #'lsp-go-install-save-hooks)
(require 'go-mode) (lsp-register-custom-settings
(require 'eglot) '(("gopls.completeUnimported" t t)
(add-hook 'go-mode-hook 'eglot-ensure) ("gopls.staticcheck" t t)))
;; Optional: install eglot-format-buffer as a save hook. ;; Start LSP Mode and YASnippet mode
;; The depth of -10 places this before eglot's willSave notification, (add-hook 'go-mode-hook #'lsp-deferred)
;; so that that notification reports the actual contents that will be saved. (add-hook 'go-mode-hook #'yas-minor-mode)
(defun eglot-format-buffer-on-save ()
(add-hook 'before-save-hook #'eglot-format-buffer -10 t))
(add-hook 'go-mode-hook #'eglot-format-buffer-on-save)
(add-hook 'before-save-hook
(lambda () ;; optionally
(call-interactively 'eglot-code-action-organize-imports)) (use-package lsp-ui :commands lsp-ui-mode
nil t) :ensure t
:config
(lsp-ui-peek-enable 1))
;; if you are helm user
(use-package helm-lsp :commands helm-lsp-workspace-symbol)
;; optionally if you want to use debugger
(use-package dap-mode
:ensure t)
(use-package all-the-icons
:if (display-graphic-p)
:ensure t)
(use-package company-fuzzy (use-package company-fuzzy
:hook (company-mode . company-fuzzy-mode) :hook (company-mode . company-fuzzy-mode)
@ -166,9 +216,9 @@
(global-hl-line-mode t) ;; This highlights the current line in the buffer (global-hl-line-mode t) ;; This highlights the current line in the buffer
(use-package beacon ;; This applies a beacon effect to the highlighted line (use-package beacon ;; This applies a beacon effect to the highlighted line
:ensure t :ensure t
:config :config
(beacon-mode 1)) (beacon-mode 1))
(use-package doom-themes (use-package doom-themes
:ensure t :ensure t
@ -229,7 +279,3 @@
(global-set-key (kbd "C-h a") 'helm-apropos) (global-set-key (kbd "C-h a") 'helm-apropos)
(setq helm-split-window-in-side-p t (setq helm-split-window-in-side-p t
helm-move-to-line-cycle-in-source t)) helm-move-to-line-cycle-in-source t))
(message "%s" company-backends) ; '(company-fuzzy-all-other-backends)
(message "%s" company-fuzzy--backends) ; .. backends has been handed over to `company-fuzzy`