[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master fdde3d1 27/38: Merge pull request #946 from company-mode/c
From: |
Dmitry Gutov |
Subject: |
[elpa] master fdde3d1 27/38: Merge pull request #946 from company-mode/company-tng-with-post-completion |
Date: |
Sat, 25 Jul 2020 19:51:15 -0400 (EDT) |
branch: master
commit fdde3d112ba85d034f83f95deafa24fd13be36e4
Merge: db0596b 56a846c
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: GitHub <noreply@github.com>
Merge pull request #946 from company-mode/company-tng-with-post-completion
Stop overriding post-completion
---
NEWS.md | 10 ++++++++++
company-tng.el | 39 +++++++++++++++++++++------------------
2 files changed, 31 insertions(+), 18 deletions(-)
diff --git a/NEWS.md b/NEWS.md
index 45ab42a..7c1f292 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,5 +1,15 @@
# History of user-visible changes
+## Next
+
+* `company-tng` stops disabling `post-completion` in backends
+ ([#946](https://github.com/company-mode/company-mode/pull/946)). Instead,
+ `company-tng-configure-default` disables snippet expansion in most popular
+ backends. If a backend you use needs this and is not covered, and you use
+ `company-tng`, disable snippet insertion by customizing a relevant option
+ provided by the backend. The result is better compatibility with LSP backends
+ because they currently depend on `post-completion` in all cases.
+
## 2020-02-07 (0.9.12)
* Tooltip rendering bugfix.
diff --git a/company-tng.el b/company-tng.el
index 9b495c6..404d436 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-2020 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 1c7a872 31/38: Merge pull request #983 from qhuyduong/make-post-completion-command-dedicated-function, (continued)
- [elpa] master 1c7a872 31/38: Merge pull request #983 from qhuyduong/make-post-completion-command-dedicated-function, Dmitry Gutov, 2020/07/25
- [elpa] master 6a39f31 38/38: Merge commit '656ad10670512e135a0a5881f127bb7a789ef8ca' from company, Dmitry Gutov, 2020/07/25
- [elpa] master 955f80e 19/38: company-doc-buffer: Make sure to reset the major mode, Dmitry Gutov, 2020/07/25
- [elpa] master db0596b 26/38: Merge branch 'master' of github.com:company-mode/company-mode, Dmitry Gutov, 2020/07/25
- [elpa] master 1f56bec 36/38: company-diag: Print out completion-at-point-functions too, Dmitry Gutov, 2020/07/25
- [elpa] master 6333fc4 29/38: Mention when, Dmitry Gutov, 2020/07/25
- [elpa] master f24b794 32/38: Make sure the error text is present before trying to use it, Dmitry Gutov, 2020/07/25
- [elpa] master 7d9d72c 33/38: Set tooltip background color for terminals with less than 88 colors, Dmitry Gutov, 2020/07/25
- [elpa] master 8ec972b 17/38: Defer company-reformat a little, Dmitry Gutov, 2020/07/25
- [elpa] master 61ddd9a 21/38: Merge pull request #968 from condy0919/master, Dmitry Gutov, 2020/07/25
- [elpa] master fdde3d1 27/38: Merge pull request #946 from company-mode/company-tng-with-post-completion,
Dmitry Gutov <=
- [elpa] master 21f3b0f 28/38: Revert "company-input-noop still seems to be needed in the terminal", Dmitry Gutov, 2020/07/25
- [elpa] master b94ab88 34/38: Merge pull request #986 from hanazuki/default-tooltip-bg, Dmitry Gutov, 2020/07/25
- [elpa] master 36e650a 35/38: Fix company-tooltip definition in Emacs < 28, Dmitry Gutov, 2020/07/25
- [elpa] master 656ad10 37/38: Release 0.9.13, Dmitry Gutov, 2020/07/25