Skip to content

Commit 69addad

Browse files
authored
Merge pull request #720 from emacs-php/feature/workaround-for-lsp-bridge-acm-tabnine
Add workaround for acm-backend-tabnine-candidate-expand
2 parents 2bc4db0 + 2988475 commit 69addad

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Diff for: lisp/php-mode.el

+18
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@
8484
(require 'flymake)
8585
(require 'php-flymake)
8686
(require 'regexp-opt)
87+
(declare-function 'acm-backend-tabnine-candidate-expand "ext:acm-backend-tabnine"
88+
(candidate-info bound-start))
8789
(defvar add-log-current-defun-header-regexp)
8890
(defvar add-log-current-defun-function)
8991
(defvar c-syntactic-context)
@@ -1273,6 +1275,11 @@ After setting the stylevars run hooks according to STYLENAME
12731275
:override 'php-c-looking-at-or-maybe-in-bracelist '(local)))
12741276
(advice-add #'fixup-whitespace :after #'php-mode--fixup-whitespace-after '(local))
12751277

1278+
(when (fboundp #'acm-backend-tabnine-candidate-expand)
1279+
(advice-add #'acm-backend-tabnine-candidate-expand
1280+
:filter-args #'php-acm-backend-tabnine-candidate-expand-filter-args
1281+
'(local)))
1282+
12761283
(when (>= emacs-major-version 25)
12771284
(with-silent-modifications
12781285
(save-excursion
@@ -1576,6 +1583,17 @@ The output will appear in the buffer *PHP*."
15761583
(forward-char -2)
15771584
(looking-at-p "->\\|::")))
15781585
(delete-char 1)))
1586+
1587+
;; Advice for lsp-bridge' acm-backend-tabnine
1588+
;; see https://github.com/manateelazycat/lsp-bridge/issues/402#issuecomment-1305653058
1589+
(defun php-acm-backend-tabnine-candidate-expand-filter-args (args)
1590+
"Adjust to replace bound-start ARGS for Tabnine in PHP."
1591+
(cl-multiple-value-bind (candidate-info bound-start) args
1592+
(save-excursion
1593+
(goto-char bound-start)
1594+
(when (looking-at-p (eval-when-compile (regexp-quote "$")))
1595+
(setq bound-start (1+ bound-start))))
1596+
(list candidate-info bound-start)))
15791597

15801598
;;;###autoload
15811599
(progn

0 commit comments

Comments
 (0)