[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master ec1a742 01/38: Stop overriding post-completion
From: |
Dmitry Gutov |
Subject: |
[elpa] master ec1a742 01/38: Stop overriding post-completion |
Date: |
Sat, 25 Jul 2020 19:51:10 -0400 (EDT) |
branch: master
commit ec1a742cf1e41070956336ce574297bb39c51f52
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>
Stop overriding post-completion
Disable args insertion in individual backends instead.
Fixes #943.
Fixes #881.
---
company-tng.el | 39 +++++++++++++++++++++------------------
1 file changed, 21 insertions(+), 18 deletions(-)
diff --git a/company-tng.el b/company-tng.el
index 9b495c6..56c6c98 100644
--- a/company-tng.el
+++ b/company-tng.el
@@ -1,6 +1,6 @@
;;; company-tng.el --- company-mode configuration for single-button interaction
-;; Copyright (C) 2017 Free Software Foundation, Inc.
+;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
;; Author: Nikita Leshenko
@@ -64,15 +64,19 @@
;; We recommend to disable `company-require-match' to allow free typing at any
;; point.
;;
-;; By default, company-tng doesn't work well with backends that use
-;; `post-completion' (for actions such as expanding snippets in
-;; company-yasnippet or company-template). In company-tng, completion
candidates
+;; By default, company-tng doesn't work well with backends that insert function
+;; arguments into the buffer and (optionally) expand them into a snippet
+;; (usually performed in `post-completion' using yasnippet or
company-template).
+;; In company-tng, completion candidates
;; are inserted into the buffer as the user selects them and the completion is
;; finished implicitly when the user continues typing after selecting a
;; candidate. Modifying the buffer (by expanding a snippet) when the user
;; continues typing would be surprising and undesirable, since the candidate
was
-;; already inserted into the buffer. For this reason company-tng disables
-;; `post-completion' in all backends.
+;; already inserted into the buffer.
+;;
+;; For this reason `company-tng-configure-default' disables arguments insertion
+;; for a number of popular backends. If the backend you are using is not among
+;; them, you might have to configure it not to do that yourself.
;;
;; YASnippet and company-tng both use TAB, which causes conflicts. The
;; recommended way to use YASnippet with company-tng is to choose a different
@@ -122,8 +126,12 @@ confirm the selection and finish the completion."
(when (and company-selection-changed
(not (company--company-command-p (this-command-keys))))
(company--unread-this-command-keys)
- (setq this-command 'company-complete-selection)
- (advice-add 'company-call-backend :before-until
'company-tng--supress-post-completion)))))
+ (setq this-command 'company-complete-selection)))))
+
+(defvar company-clang-insert-arguments)
+(defvar company-semantic-insert-arguments)
+(defvar company-rtags-insert-arguments)
+(defvar lsp-enable-snippet)
;;;###autoload
(defun company-tng-configure-default ()
@@ -132,6 +140,11 @@ confirm the selection and finish the completion."
(setq company-frontends '(company-tng-frontend
company-pseudo-tooltip-frontend
company-echo-metadata-frontend))
+ (setq company-clang-insert-arguments nil
+ company-semantic-insert-arguments nil
+ company-rtags-insert-arguments nil
+ lsp-enable-snippet nil)
+ (advice-add #'eglot--snippet-expansion-fn :override #'ignore)
(let ((keymap company-active-map))
(define-key keymap [return] nil)
(define-key keymap (kbd "RET") nil)
@@ -180,15 +193,5 @@ made explicitly (i.e. `company-selection-changed' is true)"
(setf (nth 3 args) nil))
args)
-(defun company-tng--supress-post-completion (command &rest args)
- "Installed as a :before-until advice on `company-call-backend' and
-prevents the 'post-completion command from being delivered to the backend
-for the next iteration. post-completion do things like expand snippets
-which are undesirable because completions are implicit in company-tng and
-visible side-effects after the completion are surprising."
- (when (eq command 'post-completion)
- (advice-remove 'company-call-backend 'company-tng--supress-post-completion)
- t))
-
(provide 'company-tng)
;;; company-tng.el ends here
- [elpa] master updated (e58daf7 -> 6a39f31), Dmitry Gutov, 2020/07/25
- [elpa] master ec1a742 01/38: Stop overriding post-completion,
Dmitry Gutov <=
- [elpa] master d40bcfc 06/38: add the docbuffer on company-yasnippet, Dmitry Gutov, 2020/07/25
- [elpa] master cdd2c00 10/38: use eq instead of string-equal, Dmitry Gutov, 2020/07/25
- [elpa] master 4af1ea2 12/38: company-yasnippet: Make annotation more customizable, Dmitry Gutov, 2020/07/25
- [elpa] master d091704 13/38: Update copyright years, Dmitry Gutov, 2020/07/25
- [elpa] master fdbdff3 15/38: catch yas-expand-snippet error, Dmitry Gutov, 2020/07/25
- [elpa] master 265eb38 16/38: Merge pull request #967 from taigacute/master, Dmitry Gutov, 2020/07/25
- [elpa] master e3d7d60 02/38: company-bbdb: Support more headers like From:, Dmitry Gutov, 2020/07/25
- [elpa] master 94e22c4 03/38: Merge pull request #958 from OGAWAHirofumi/company-bbdb-add-more-header, Dmitry Gutov, 2020/07/25
- [elpa] master f275ee6 04/38: Fix Travis CI Build config, Dmitry Gutov, 2020/07/25
- [elpa] master 872b14c 05/38: add the docbuffer on company-yasnippet, Dmitry Gutov, 2020/07/25