forked from FG42/FG42
Add corfu as the main completion framework
This commit is contained in:
parent
a9b7a40473
commit
a163cdc33e
15
flake.nix
15
flake.nix
|
@ -58,20 +58,6 @@
|
|||
};
|
||||
|
||||
fg42 = app.drv;
|
||||
# fg42-wm = pkgs.callPackage ./nix/fg42
|
||||
# {
|
||||
# inherit nixpkgs;
|
||||
# modules = [
|
||||
# ./nix/modules/editor
|
||||
# ./nix/modules/elisp
|
||||
# ./nix/modules/graphics
|
||||
# ./nix/modules/noether
|
||||
# ./nix/modules/wm
|
||||
# ];
|
||||
# extraPackages = {
|
||||
# noether = inputs.noether.outputs.packages.${system}.default;
|
||||
# };
|
||||
# }.drv;
|
||||
|
||||
run-test-wm = pkgs.writeShellApplication {
|
||||
name = "run-test-wm";
|
||||
|
@ -103,6 +89,7 @@
|
|||
type = "app";
|
||||
program = "${test-x}/bin/test-x";
|
||||
};
|
||||
|
||||
apps.default = {
|
||||
type = "app";
|
||||
program = "${fg42}/bin/fg42";
|
||||
|
|
|
@ -1,71 +0,0 @@
|
|||
;;; FG42 --- The mighty editor for the emacsians -*- lexical-binding: t; -*-
|
||||
;;
|
||||
;; Copyright (c) 2010-2024 Sameer Rahmani & Contributors
|
||||
;;
|
||||
;; Author: Sameer Rahmani <lxsameer@gnu.org>
|
||||
;; URL: https://devheroes.codes/FG42/FG42
|
||||
;; Version: 4.0.0
|
||||
;;
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
;;
|
||||
;;; Commentary:
|
||||
;;; Code:
|
||||
(eval-when-compile
|
||||
(require 'fpkg)
|
||||
(require 'fg42/config))
|
||||
|
||||
|
||||
(use! company
|
||||
"Company is a modular text completion framework for GNU Emacs."
|
||||
:hook (emacs-startup . global-company-mode)
|
||||
:bind (:map company-active-map
|
||||
("M-n" . company-select-next)
|
||||
("M-p" . company-select-previous)
|
||||
("TAB" . company-complete-common-or-cycle)
|
||||
("M-d" . company-show-doc-buffer))
|
||||
|
||||
:init
|
||||
;; Use Company for completion
|
||||
(setq company-show-numbers t)
|
||||
(setq company-idle-delay 0)
|
||||
(setq company-tooltip-limit 20)
|
||||
(setq company-echo-delay 0)
|
||||
(setq company-tooltip-align-annotations t)
|
||||
(setq company-dabbrev-downcase nil)
|
||||
|
||||
:config
|
||||
(setq-default company-backends
|
||||
'(company-capf (company-keywords :separate) company-files))
|
||||
(bind-key [remap completion-at-point] #'company-complete company-mode-map))
|
||||
|
||||
|
||||
(use! company-box
|
||||
"A company front-end with icons."
|
||||
:after company
|
||||
:hook (company-mode . company-box-mode))
|
||||
|
||||
|
||||
;;;###autoload
|
||||
(defun fg42/autocomplete ()
|
||||
"Initialize FG42's auto complete.
|
||||
This function is meant to be used with hooks."
|
||||
;; Why? because if we end up with more auto completion alternatives
|
||||
;; to company mode, then we can setup them here rather than walking
|
||||
;; around fixing downstream modules.
|
||||
(interactive)
|
||||
(company-mode t))
|
||||
|
||||
|
||||
(provide 'fg42/autocomplete)
|
||||
;;; autocomplete.el ends here
|
|
@ -22,30 +22,45 @@
|
|||
{ lib, config, pkgs, makeFG42Drv, ... }:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.fg42.auto-complete;
|
||||
cfg = config.fg42.completion;
|
||||
|
||||
deps =
|
||||
(with pkgs.emacsPackages; [
|
||||
(with pkgs.emacsPackages;
|
||||
optionals (cfg.backend == "corfu") [
|
||||
corfu
|
||||
cape
|
||||
] ++ optionals (cfg.backend == "company") [
|
||||
company
|
||||
company-box
|
||||
]);
|
||||
|
||||
drv = makeFG42Drv {
|
||||
pname = "autocomplete";
|
||||
pname = "completion";
|
||||
version = config.fg42.version;
|
||||
buildInputs = deps;
|
||||
src = ./.;
|
||||
};
|
||||
backendDesc = ''
|
||||
The backend to use for the completion. (default corfu)
|
||||
'';
|
||||
in
|
||||
{
|
||||
options.fg42.auto-complete.enable = mkAndEnableOption "auto-complete";
|
||||
options.fg42.completion = {
|
||||
enable = mkAndEnableOption "completion";
|
||||
backend = mkOption {
|
||||
type = types.str;
|
||||
default = "corfu";
|
||||
description = backendDesc;
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
fg42.elispPackages = [ drv ] ++ deps;
|
||||
|
||||
fg42.requires = [ drv.pname ];
|
||||
fg42.vars = [
|
||||
(defVar "auto-complete" cfg.enable "Auto completion for FG42.")
|
||||
(defVar "completion" cfg.enable "Completion for FG42.")
|
||||
(defVar "completion-backend" cfg.backend backendDesc)
|
||||
];
|
||||
};
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
;;; FG42 --- The mighty editor for the emacsians -*- lexical-binding: t; -*-
|
||||
;;
|
||||
;; Copyright (c) 2010-2024 Sameer Rahmani & Contributors
|
||||
;;
|
||||
;; Author: Sameer Rahmani <lxsameer@gnu.org>
|
||||
;; URL: https://devheroes.codes/FG42/FG42
|
||||
;; Version: 4.0.0
|
||||
;;
|
||||
;; This program is free software; you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
;;
|
||||
;; This program is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
;;
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
;;
|
||||
;;; Commentary:
|
||||
;;; Code:
|
||||
(eval-when-compile
|
||||
(require 'fpkg)
|
||||
(require 'fg42/config))
|
||||
|
||||
(fg42/config-when "completion-backend" "company"
|
||||
(use! company
|
||||
"Company is a modular text completion framework for GNU Emacs."
|
||||
:hook (emacs-startup . global-company-mode)
|
||||
:bind (:map company-active-map
|
||||
("M-n" . company-select-next)
|
||||
("M-p" . company-select-previous)
|
||||
("TAB" . company-complete-common-or-cycle)
|
||||
("M-d" . company-show-doc-buffer))
|
||||
|
||||
:init
|
||||
;; Use Company for completion
|
||||
(setq company-show-numbers t)
|
||||
(setq company-idle-delay 0)
|
||||
(setq company-tooltip-limit 20)
|
||||
(setq company-echo-delay 0)
|
||||
(setq company-tooltip-align-annotations t)
|
||||
(setq company-dabbrev-downcase nil)
|
||||
|
||||
:config
|
||||
(setq-default company-backends
|
||||
'(company-capf (company-keywords :separate) company-files))
|
||||
(bind-key [remap completion-at-point] #'company-complete company-mode-map))
|
||||
|
||||
|
||||
(use! company-box
|
||||
"A company front-end with icons."
|
||||
:after company
|
||||
:hook (company-mode . company-box-mode)))
|
||||
|
||||
|
||||
(fg42/config-when "completion-backend" "corfu"
|
||||
(use! corfu
|
||||
"Corfu enhances in-buffer completion with a small completion popup.
|
||||
The current candidates are shown in a popup below or above the point. The candidates
|
||||
can be selected by moving up and down. Corfu is the minimalistic in-buffer completion
|
||||
counterpart of the Vertico minibuffer UI."
|
||||
:custom
|
||||
(corfu-cycle t) ;; Enable cycling for `corfu-next/previous'
|
||||
(corfu-auto t) ;; Enable auto completion
|
||||
(corfu-separator ?\s) ;; Orderless field separator
|
||||
(corfu-quit-at-boundary nil) ;; Never quit at completion boundary
|
||||
;; (corfu-quit-no-match nil) ;; Never quit, even if there is no match
|
||||
(corfu-preview-current nil) ;; Disable current candidate preview
|
||||
(corfu-preselect 'prompt) ;; Preselect the prompt
|
||||
(corfu-on-exact-match nil) ;; Configure handling of exact matches
|
||||
(corfu-scroll-margin 5) ;; Use scroll margin
|
||||
:hook (emacs-startup . global-corfu-mode)))
|
||||
|
||||
|
||||
;;;###autoload
|
||||
(defun fg42/setup-completion ()
|
||||
"Initialize FG42's completion system.
|
||||
This function is meant to be used with hooks."
|
||||
;; Why? because if we end up with more auto completion alternatives
|
||||
;; to corfu or company mode, then we can setup them here rather than walking
|
||||
;; around fixing downstream modules.
|
||||
(interactive)
|
||||
|
||||
(fg42/config-when "completion-backend" "company"
|
||||
(company-mode t)))
|
||||
|
||||
|
||||
(provide 'fg42/completion)
|
||||
;;; completion.el ends here
|
|
@ -28,7 +28,7 @@ let
|
|||
./minibuffer-vertico
|
||||
./graphics
|
||||
./noether
|
||||
./autocomplete
|
||||
./completion
|
||||
./language-server
|
||||
./nix
|
||||
./c-family
|
||||
|
|
|
@ -242,6 +242,12 @@ contextual information."
|
|||
(setq tooltip-use-echo-area t)
|
||||
(setq x-gtk-use-system-tooltips nil)
|
||||
|
||||
;; Emacs 30 and newer: Disable Ispell completion function.
|
||||
(setq text-mode-ispell-word-completion nil)
|
||||
;; Enable indentation+completion using the TAB key.
|
||||
;; `completion-at-point' is often bound to M-TAB.
|
||||
(setq tab-always-indent 'complete)
|
||||
|
||||
;; Global configurations
|
||||
(tool-bar-mode -1)
|
||||
(tooltip-mode nil)
|
||||
|
|
|
@ -37,6 +37,22 @@
|
|||
`,default)))
|
||||
|
||||
|
||||
(defmacro fg42/config= (key value)
|
||||
"Check whether config name KEY has the VALUE or not."
|
||||
`(string= (fg42/config-get-or ,key) ,value))
|
||||
|
||||
|
||||
(defmacro fg42/config-when (key value &rest body)
|
||||
"Run the BODY only if config KEY has the VALUE."
|
||||
(declare (indent defun))
|
||||
(message ">> %s %s %s" key value (string= (fg42/config-get-or key) value))
|
||||
(if (fg42/config= key value)
|
||||
`(progn
|
||||
,@body)
|
||||
`(progn
|
||||
(message "nooooo"))))
|
||||
|
||||
|
||||
(defmacro with-config (name &rest body)
|
||||
"Run the BODY only if the config NAME is set to t."
|
||||
(declare (indent defun))
|
||||
|
|
Loading…
Reference in New Issue