Skip to content

Commit

Permalink
chore: avoid linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
kassick committed Nov 25, 2024
1 parent 5ee78c1 commit bf4ab0a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 25 deletions.
13 changes: 9 additions & 4 deletions lsp-inline-completion.el
Original file line number Diff line number Diff line change
Expand Up @@ -106,20 +106,24 @@

(defcustom lsp-before-inline-completion-hook nil
"Hooks run before starting code suggestions"
:type 'hook)
:type 'hook
:group 'lsp-mode)

(defcustom lsp-after-inline-completion-hook nil
"Hooks executed after asking for code suggestions."
:type 'hook)
:type 'hook
:group 'lsp-mode)

;; TODO: Add parameters to the hooks!
(defcustom lsp-inline-completion-accepted-hook nil
"Hooks executed after accepting a code suggestion."
:type 'hook)
:type 'hook
:group 'lsp-mode)

(defcustom lsp-inline-completion-shown-hook nil
"Hooks executed after showing a suggestion."
:type 'hook)
:type 'hook
:group 'lsp-mode)

(defsubst lsp-inline-completion--overlay-visible ()
"Return whether the `overlay' is avaiable."
Expand Down Expand Up @@ -276,6 +280,7 @@
;; hooks
(run-hook-with-args-until-failure 'lsp-inline-completion-accepted-hook text text-insert-start text-insert-end)))

;;;###autoload
(defun lsp-inline-completion-cancel ()
"Close the suggestion overlay"
(interactive)
Expand Down
46 changes: 25 additions & 21 deletions lsp-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@
(declare-function yas-expand-snippet "ext:yasnippet")
(declare-function dap-mode "ext:dap-mode")
(declare-function dap-auto-configure-mode "ext:dap-mode")
(declare-function lsp-inline-completion-display "lsp-inline-completion" (&optional implicit))
(declare-function lsp-inline-completion-cancel "lsp-inline-completion")

(defvar yas-inhibit-overlay-modification-protection)
(defvar yas-indent-line)
Expand Down Expand Up @@ -3693,6 +3695,19 @@ and expand the capabilities section"
:group 'lsp-mode
:package-version '(lsp-mode . "9.0.0"))

(defcustom lsp-inline-completion-enable t
"If non-nil it will enable inline completions on idle."
:type 'boolean
:group 'lsp-mode
:package-version '(lsp-mode . "9.0.1"))

(defcustom lsp-inline-completion-idle-delay 2
"The number of seconds before trying to fetch inline completions, when
lsp-inline-completion-mode is active"
:type 'number
:group 'lsp-mode
:package-version '(lsp-mode . "9.0.1"))

(defun lsp--uninitialize-workspace ()
"Cleanup buffer state.
When a workspace is shut down, by request or from just
Expand Down Expand Up @@ -9944,30 +9959,9 @@ string."


;; Inline Completions
(defcustom lsp-inline-completion-enable t
"If non-nil it will enable inline completions on idle."
:type 'boolean
:group 'lsp-mode
:package-version '(lsp-mode . "9.0.1"))

(defcustom lsp-inline-completion-idle-delay 2
"The number of seconds before trying to fetch inline completions, when
lsp-inline-completion-mode is active"
:type 'number)

(defvar-local lsp-inline-completion--idle-timer nil
"The idle timer used by lsp-inline-completion-mode")

(defun lsp-inline-completion--after-change (&rest args)
(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))))

(define-minor-mode lsp-inline-completion-mode
"Mode automatically displaying inline completions."
:lighter nil
Expand All @@ -9982,6 +9976,16 @@ lsp-inline-completion-mode is active"

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

(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))))



;;;###autoload
Expand Down

0 comments on commit bf4ab0a

Please sign in to comment.