summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--user/emacs/init.el30
-rw-r--r--user/settings/emacs.nix2
2 files changed, 27 insertions, 5 deletions
diff --git a/user/emacs/init.el b/user/emacs/init.el
index f4995688..3aeb816c 100644
--- a/user/emacs/init.el
+++ b/user/emacs/init.el
@@ -1038,7 +1038,6 @@ _C-k_: prev  _u_pper              _=_: upper/lower       _s_mart resolve
 (use-package eglot
   :defer 3
   :general (:states 'normal :keymaps 'eglot-mode-map
-                    "gd" #'xref-find-definitions
                     "gr" #'xref-find-references
                     "C-t" #'xref-pop-marker-stack)
   :ghook ('(typescript-mode-hook
@@ -1066,8 +1065,7 @@ _C-k_: prev  _u_pper              _=_: upper/lower       _s_mart resolve
                           '( :yaml (:keyOrdering nil)
                              :nix (:autoArchive t)
                              :gopls ( :staticcheck t
-                                      :usePlaceholders t))
-                          eglot-ignored-server-capabilities '(:documentHighlightProvider))
+                                      :usePlaceholders t)))
             (defun my/eglot-capf ()
               (setq-local completion-at-point-functions
                           (list (cape-capf-super
@@ -1090,11 +1088,22 @@ _C-k_: prev  _u_pper              _=_: upper/lower       _s_mart resolve
   :ghook ('(go-mode-hook)
           #'lsp-deferred)
   ('lsp-mode-hook #'lsp-enable-which-key-integration)
+  ('lsp-completion-mode-hook #'my/lsp-mode-setup-completion)
+  :general (:states 'normal :keymaps 'lsp-mode-map
+                    "gr" #'xref-find-references
+                    "C-t" #'xref-pop-marker-stack)
   :config (progn
             (setq lsp-auto-guess-root t
                   lsp-auto-execute-action nil
                   lsp-headerline-breadcrumb-enable nil
-                  lsp-enable-suggest-server-download nil)
+                  lsp-enable-suggest-server-download nil
+                  lsp-completion-provider :none ; value `:capf' is actually for company :(
+                  lsp-diagnostics-provider t     ; this means prefer flymake over flycheck, why‽
+                  )
+
+            (defun my/lsp-mode-setup-completion ()
+              (setf (alist-get 'styles (alist-get 'lsp-capf completion-category-defaults))
+                    '(flex)))
 
             (lsp-register-custom-settings
              '(("golangci-lint.command"
@@ -1113,6 +1122,16 @@ _C-k_: prev  _u_pper              _=_: upper/lower       _s_mart resolve
                                                         (gethash "golangci-lint"
                                                                  (lsp-configuration-section "golangci-lint")))))))
 
+(use-package yasnippet
+  :after lsp-mode
+  :ghook ('lsp-completion-mode-hook #'yas-minor-mode))
+
+(defun my/ls-rename ()
+  (interactive)
+  (if lsp-mode
+      (call-interactively #'lsp-rename)
+    (call-interactively #'eglot-rename)))
+
 ;; Inside a javascript project, it's common to install tools locally to
 ;; the project.  This will allows emacs to find their executables.
 
@@ -1134,7 +1153,7 @@ _C-k_: prev  _u_pper              _=_: upper/lower       _s_mart resolve
           (advice-add 'format-all-ensure-formatter
                       :around #'quiet)
           (defun turn-off-format-all-mode ()
-            (when format-all-mode
+            (when (bound-and-true-p format-all-mode)
               (format-all-mode -1))))
   :config (progn
             (setq format-all-show-errors nil)))
@@ -1171,6 +1190,7 @@ _C-k_: prev  _u_pper              _=_: upper/lower       _s_mart resolve
   "x" '(:keymap ctl-x-map)
   "c" (general-simulate-key "C-c")
   "j" #'consult-eglot-symbols
+  "r" #'my/ls-rename
   "q" #'evil-delete-buffer
   "p" '(:keymap project-prefix-map :package project)
   "v" #'split-window-right
diff --git a/user/settings/emacs.nix b/user/settings/emacs.nix
index 9615f9d1..a65f8d8c 100644
--- a/user/settings/emacs.nix
+++ b/user/settings/emacs.nix
@@ -155,6 +155,8 @@ in
         wgrep-ag
         ws-butler
         which-key
+        yasnippet
+        yasnippet-capf
       ]);
     overrides = self: super: {
       apheleia = self.melpaPackages.apheleia.overrideAttrs