company: Ctrl x bindings (#558)

* Added Ctrl-X Keybindings for Company Mode

* Linting Changes

* Added custom variable , removed company-dict function

* Added type to defcustom

* Fixed variable name

* Added declare-function and changed custom variable name

* Added declare-function and changed custom variable name

* Added declare-function for company-begin-backend
This commit is contained in:
pspiagicw 2021-12-18 15:22:31 +05:30 committed by GitHub
parent 76157b95dd
commit 6d08edc318
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 33 additions and 0 deletions

View File

@ -31,6 +31,8 @@
(require 'evil-collection)
(declare-function company-tng-mode "company-tng")
(declare-function company-grab-line "company")
(declare-function company-begin-backend "company")
(defgroup evil-collection-company nil
"Evil bindings for `company-mode'."
@ -39,6 +41,9 @@
(defcustom evil-collection-company-supported-states '(insert replace emacs)
"The `evil-state's which `company' function can be requested."
:type '(repeat symbol))
(defcustom evil-collection-want-company-extended-keybindings nil
"The 'evil-company-extended' keybindings shoould be requested"
:type 'boolean)
(defvar company-active-map)
(defvar company-search-map)
@ -53,6 +58,26 @@
(memq evil-state evil-collection-company-supported-states))
(t t)))
;;;###autoload
(defun evil-collection-company-whole-lines (command &optional arg &rest ignored)
"`company-mode' completion backend that completes whole-lines, akin to vim's
C-x C-l."
(interactive (list 'interactive))
(require 'company)
(pcase command
(`interactive (company-begin-backend 'evil-collection-company-whole-lines))
(`prefix (company-grab-line "^[\t\s]*\\(.+\\)" 1))
(`candidates
(all-completions
arg
(delete-dups
(split-string
(replace-regexp-in-string
"^[\t\s]+" ""
(concat (buffer-substring-no-properties (point-min) (line-beginning-position))
(buffer-substring-no-properties (line-end-position) (point-max))))
"\\(\r\n\\|[\n\r]\\)" t))))))
;;;###autoload
(defun evil-collection-company-setup ()
"Set up `evil' bindings for `company'."
@ -64,6 +89,14 @@
(kbd "M-j") 'company-select-next
(kbd "M-k") 'company-select-previous)
(when evil-collection-want-company-extended-keybindings
(evil-collection-define-key nil 'company-active-map
(kbd "C-l") 'evil-collection-company-whole-lines
(kbd "C-]") 'company-etags
(kbd "C-f") 'company-files
(kbd "C-o") 'company-capf
(kbd "C-s") 'company-ispell))
(when evil-want-C-u-scroll
(evil-collection-define-key nil 'company-active-map
(kbd "C-u") 'company-previous-page))