From 41e50cc25eab0f9a81174c92040fc73d9f0844e5 Mon Sep 17 00:00:00 2001 From: Kien Nguyen Date: Sun, 1 Dec 2024 14:50:29 -0800 Subject: [PATCH] lsp-inline-completion: cleanup autoload to make it loads correctly --- lsp-completion.el | 1 + lsp-inline-completion.el | 36 +++--------------------------------- lsp-mode.el | 35 +++++++++++++++++++++++++++-------- 3 files changed, 31 insertions(+), 41 deletions(-) diff --git a/lsp-completion.el b/lsp-completion.el index a362bf8ca00..5df9a67dcf6 100644 --- a/lsp-completion.el +++ b/lsp-completion.el @@ -45,6 +45,7 @@ (define-obsolete-variable-alias 'lsp-enable-completion-at-point 'lsp-completion-enable "lsp-mode 7.0.1") +;;;###autoload (defcustom lsp-completion-enable t "Enable `completion-at-point' integration." :type 'boolean diff --git a/lsp-inline-completion.el b/lsp-inline-completion.el index fffda85bb12..4394584b088 100644 --- a/lsp-inline-completion.el +++ b/lsp-inline-completion.el @@ -28,36 +28,7 @@ ;;; Code: -(require 'lsp-protocol) -(require 'dash) -(require 'cl-lib) -(require 'fringe) - -(if (version< emacs-version "29.1") - ;; Undo macro probably introduced in 29.1 - (defmacro lsp-inline-completion--with-undo-amalgamate (&rest body) - "Like `progn' but perform BODY with amalgamated undo barriers. - -This allows multiple operations to be undone in a single step. -When undo is disabled this behaves like `progn'." - (declare (indent 0) (debug t)) - (let ((handle (make-symbol "--change-group-handle--"))) - `(let ((,handle (prepare-change-group)) - ;; Don't truncate any undo data in the middle of this, - ;; otherwise Emacs might truncate part of the resulting - ;; undo step: we want to mimic the behavior we'd get if the - ;; undo-boundaries were never added in the first place. - (undo-outer-limit nil) - (undo-limit most-positive-fixnum) - (undo-strong-limit most-positive-fixnum)) - (unwind-protect - (progn - (activate-change-group ,handle) - ,@body) - (progn - (accept-change-group ,handle) - (undo-amalgamate-change-group ,handle)))))) - (defalias 'lsp-inline-completion--with-undo-amalgamate 'with-undo-amalgamate)) +(require 'lsp-mode) (defun lsp-inline-completion--params (implicit &optional identifier position) "Returns a InlineCompletionParams instance" @@ -91,7 +62,6 @@ InlineCompletionItem objects" ;;;;;; Default UI -- overlay -;;;###autoload (defvar lsp-inline-completion-active-map (let ((map (make-sparse-keymap))) ;; accept @@ -115,7 +85,6 @@ InlineCompletionItem objects" map) "Keymap active when showing inline code suggestions") -;;;###autoload (defface lsp-inline-completion-overlay-face '((t :inherit shadow)) "Face for the inline code suggestions overlay." @@ -334,7 +303,7 @@ text range that was updated by the completion" (with-no-warnings ;; Compiler does not believes this macro is defined - (lsp-inline-completion--with-undo-amalgamate + (lsp-with-undo-amalgamate (lsp-inline-completion--insert-sugestion text kind start end command?))))) (defun lsp-inline-completion-accept-on-click (event) @@ -422,6 +391,7 @@ text range that was updated by the completion" ;; Inline Completion Mode +;;;###autoload (defcustom lsp-inline-completion-enable t "If non-nil it will enable inline completions on idle." :type 'boolean diff --git a/lsp-mode.el b/lsp-mode.el index 4506436e0cf..58b71ea13e3 100644 --- a/lsp-mode.el +++ b/lsp-mode.el @@ -529,14 +529,6 @@ If this is set to nil, `eldoc' will show only the symbol information." :type 'boolean :group 'lsp-mode) -(define-obsolete-variable-alias 'lsp-enable-completion-at-point - 'lsp-completion-enable "lsp-mode 7.0.1") - -(defcustom lsp-completion-enable t - "Enable `completion-at-point' integration." - :type 'boolean - :group 'lsp-completion) - (defcustom lsp-enable-symbol-highlighting t "Highlight references of the symbol at point." :type 'boolean @@ -1408,6 +1400,33 @@ Symlinks are not followed." (s-prefix? (concat (lsp-f-canonical path-a) (f-path-separator)) (lsp-f-canonical path-b)))) +;; compat +(if (version< emacs-version "29.1") + ;; Undo macro probably introduced in 29.1 + (defmacro lsp-with-undo-amalgamate (&rest body) + "Like `progn' but perform BODY with amalgamated undo barriers. + +This allows multiple operations to be undone in a single step. +When undo is disabled this behaves like `progn'." + (declare (indent 0) (debug t)) + (let ((handle (make-symbol "--change-group-handle--"))) + `(let ((,handle (prepare-change-group)) + ;; Don't truncate any undo data in the middle of this, + ;; otherwise Emacs might truncate part of the resulting + ;; undo step: we want to mimic the behavior we'd get if the + ;; undo-boundaries were never added in the first place. + (undo-outer-limit nil) + (undo-limit most-positive-fixnum) + (undo-strong-limit most-positive-fixnum)) + (unwind-protect + (progn + (activate-change-group ,handle) + ,@body) + (progn + (accept-change-group ,handle) + (undo-amalgamate-change-group ,handle)))))) + (defalias 'lsp-with-undo-amalgamate 'with-undo-amalgamate)) + (defun lsp--merge-results (results method) "Merge RESULTS by filtering the empty hash-tables and merging the lists according to METHOD."