From 94a067fe558ba9d31fcb8d81761f798f545873e5 Mon Sep 17 00:00:00 2001 From: pupbrained Date: Sat, 5 Oct 2024 20:26:18 -0400 Subject: [PATCH] switch to lsp-bridge --- config.org | 90 +++++++++++++++++++++------------- lsp-bridge/codeium_api_key.txt | 1 + 2 files changed, 57 insertions(+), 34 deletions(-) create mode 100644 lsp-bridge/codeium_api_key.txt diff --git a/config.org b/config.org index 64a2281..dfefc2a 100644 --- a/config.org +++ b/config.org @@ -178,7 +178,13 @@ (setq-local indent-tabs-mode nil)) (add-hook 'prog-mode-hook 'my-set-indent-width) - (add-hook 'org-mode-hook 'my-set-indent-width) + (defun my-org-src-edit-hook () + "Set indent width for Org source blocks." + (setq indent-tabs-mode nil) ;; Use spaces instead of tabs + (setq tab-width 2)) ;; Set tab width to your desired value + + (add-hook 'org-src-mode-hook 'my-org-src-edit-hook) + (setq-default whitespace-style '(face spaces empty tabs trailing space-mark tab-mark)) (add-hook 'prog-mode-hook 'whitespace-mode) @@ -191,9 +197,7 @@ :ensure t :config (general-define-key - :states '(normal visual emacs) - :keymaps 'override - "K" '(eldoc-box-help-at-point :wk "Hover"))) + :states '(normal visual emacs))) (use-package evil-collection :ensure t @@ -205,10 +209,11 @@ :config (global-evil-leader-mode) (setq evil-leader/leader "") - (evil-leader/set-key "a" #'eglot-code-actions) (evil-leader/set-key "bb" #'switch-to-buffer) (evil-leader/set-key "bd" #'kill-this-buffer) - (evil-leader/set-key "e" #'dirvish-side)) + (evil-leader/set-key "e" #'dirvish-side) + (evil-leader/set-key "N" #'lsp-bridge-diagnostic-jump-prev) + (evil-leader/set-key "n" #'lsp-bridge-diagnostic-jump-next)) (use-package catppuccin-theme :ensure t @@ -222,35 +227,51 @@ ** LSP -*** Eglot +*** LSP-Bridge #+begin_src emacs-lisp - (use-package eglot - :hook - (prog-mode . eglot-ensure) - :config - (add-hook 'emacs-lisp-mode-hook 'eglot-ensure) - (add-hook 'c-mode-hook 'hide-ifdef-mode) - (add-hook 'c++-mode-hook 'hide-ifdef-mode)) - - (setq-default eglot-workspace-configuration - '((haskell - (plugin - (stan - (globalOn . :json-false)))))) ;; disable stan - - (defun my/eglot-format-buffer-on-save () - "Format the current buffer if Eglot is active." - (when (bound-and-true-p eglot--managed-p) - (eglot-format-buffer))) - - (add-hook 'before-save-hook #'my/eglot-format-buffer-on-save) - - (use-package eldoc-box + (use-package yasnippet :ensure t - :config - (setq eldoc-idle-delay 0 - eldoc-message-function #'ignore)) + :init + (yas-global-mode 1)) + + (use-package lsp-bridge + :ensure '(lsp-bridge :type git :host github :repo "manateelazycat/lsp-bridge" :files (:defaults "*")) + :init + (defun my/lsp-bridge-find-def () + (interactive) + (let ((prev-marker (point-marker))) + (lsp-bridge-find-def) + (xref-push-marker-stack prev-marker))) + + (defun lsp-bridge-mode-hook-func () + (with-eval-after-load 'corfu (corfu-mode -1)) + + (local-set-key (kbd "M-[") #'lsp-bridge-return-from-def) + (local-set-key (kbd "M-]") #'lsp-bridge-find-def) + (local-set-key [remap xref-find-definitions] #'lsp-bridge-find-def) + (local-set-key [remap xref-find-definitions-other-window] #'lsp-bridge-find-def-other-window) + (local-set-key [remap xref-find-references] #'lsp-bridge-find-references) + + (evil-define-key 'normal 'local (kbd "gd") #'lsp-bridge-find-def) + (evil-define-key 'normal 'local (kbd "gD") #'lsp-bridge-find-def-other-window) + (evil-define-key 'normal 'local (kbd "gi") #'lsp-bridge-find-impl) + (evil-define-key 'normal 'local (kbd "gI") #'lsp-bridge-find-impl-other-window) + (evil-define-key 'normal 'local (kbd "gr") #'lsp-bridge-find-references) + (evil-define-key 'normal 'local (kbd "K") #'lsp-bridge-popup-documentation)) + + (setq lsp-bridge-enable-log nil + acm-enable-icon t + acm-enable-doc t + acm-enable-tabnine nil + acm-enable-quick-access t) + + (require 'lsp-bridge) + (evil-set-initial-state 'lsp-bridge-ref-mode 'insert) + (add-hook 'lsp-bridge-mode-hook #'lsp-bridge-mode-hook-func) + + ;; Enable lsp-bridge. + (add-hook 'c++-mode-hook #'lsp-bridge-mode)) #+end_src *** TreeSitter @@ -396,9 +417,10 @@ ** Direnv #+begin_src emacs-lisp - (use-package direnv + (use-package envrc + :ensure t :config - (direnv-mode)) + (envrc-global-mode)) #+end_src ** Better M-x diff --git a/lsp-bridge/codeium_api_key.txt b/lsp-bridge/codeium_api_key.txt new file mode 100644 index 0000000..17787da --- /dev/null +++ b/lsp-bridge/codeium_api_key.txt @@ -0,0 +1 @@ +f6ce1f9f-ddcf-4fc8-a7a0-7fd5b5d44d62 \ No newline at end of file