Skip to content

Commit

Permalink
feat: provide a method to inhibit inline completion mode
Browse files Browse the repository at this point in the history
Add a list of predicates that can inhibit triggering inline completions --
e.g.:

    ```elisp
    (defun lsp-inline-completion-inhibit-if-company-active ()
        (and (bound-and-true-p company-mode) (company--active-p)))

      (push 'lsp-inline-completion-inhibit-if-company-active lsp-inline-completion-inhibit-predicates)
    ```
  • Loading branch information
kassick committed Nov 26, 2024
1 parent 3bab211 commit da2d8c2
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lsp-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -9976,15 +9976,23 @@ string."

(remove-hook 'lsp-on-change-hook #'lsp-inline-completion--after-change t))))

(defcustom lsp-inline-completion-inhibit-predicates nil
"When a function of this list returns non nil, lsp-inline-completion-mode will not show the completion"
:type '(repeat function)
:group 'lsp-mode)

(defun lsp-inline-completion--maybe-display ()
(unless (--any (funcall it) lsp-inline-completion-inhibit-predicates)
(lsp-inline-completion-display 'implicit)))

(defun lsp-inline-completion--after-change (&rest _)
(when (and lsp-inline-completion-mode lsp--buffer-workspaces)
(when lsp-inline-completion--idle-timer
(cancel-timer lsp-inline-completion--idle-timer))
(setq lsp-inline-completion--idle-timer
(run-with-timer lsp-inline-completion-idle-delay
nil
#'lsp-inline-completion-display
'implicit))))
#'lsp-inline-completion--maybe-display))))



Expand Down

0 comments on commit da2d8c2

Please sign in to comment.