From d4aa08311f75b7e5938e3e6a59f7b08cce68bb8e Mon Sep 17 00:00:00 2001 From: Sameer Rahmani Date: Sun, 2 May 2021 22:47:01 +0100 Subject: [PATCH] Add necessary cubes to swtich to v3 I've added some cubes including 'selectrum', 'company' 'lsp', 'smart-mode-line', 'mini-modline' and several others which allows me to switch to v3 and continue from there. Some of the cubes are not in the right place but will move them to an appropriate location later on --- core/cubes/autocompletion.el | 73 ++++++++++++++++++++++++++++++++++++ core/cubes/editor.el | 32 +++++++++++++++- core/cubes/modeline.el | 54 ++++++++++++++++++++++++++ core/fg42/flags.el | 2 +- core/fpkg.el | 18 ++++++++- dev.org | 1 + 6 files changed, 177 insertions(+), 3 deletions(-) create mode 100644 core/cubes/autocompletion.el create mode 100644 core/cubes/modeline.el diff --git a/core/cubes/autocompletion.el b/core/cubes/autocompletion.el new file mode 100644 index 0000000..f9164c5 --- /dev/null +++ b/core/cubes/autocompletion.el @@ -0,0 +1,73 @@ +;;; EditorCubes --- The common cubes for FG42 -*- lexical-binding: t; -*- +;; +;; Copyright (c) 2010-2021 Sameer Rahmani & Contributors +;; +;; Author: Sameer Rahmani +;; URL: https://gitlab.com/FG42/FG42 +;; Version: 3.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 . +;; +;;; Commentary: +;;; Code: +(require 'fpkg) +(require 'fg42/cube) + +(defcube fg42/lsp-cube + (:docs "cubes/fg42/lsp-cube.org") + + (fpkg/use lsp-mode + :commands lsp + :init + (setq lsp-headerline-breadcrumb-enable nil)) + + (fpkg/use lsp-ui + :config + (add-hook 'lsp-mode-hook 'lsp-ui-mode))) + +(defcube fg42/c++-cube + (:docs "cubes/fg42/cpp-cube.org") + + (add-hook 'c++-mode-hook (lambda () + (lsp) + (require 'company-capf) + (require 'company-box) + (setq company-backends + '((company-capf + company-keywords)))))) + + +(defcube fg42/company-cube + (:docs "cubes/fg42/company-cube.org") + + (fpkg/use company + :init (global-company-mode) + :config + (progn + ;; Use Company for completion + (bind-key [remap completion-at-point] #'company-complete company-mode-map) + + (setq company-tooltip-align-annotations t + ;; Easy navigation to candidates with M- + company-show-numbers t) + (setq company-dabbrev-downcase nil))) + + (fpkg/use company-box + :after company + :config + (add-hook 'company-mode-hook 'company-box-mode))) + + +(provide 'cubes/autocompletion) +;;; editor.el ends here diff --git a/core/cubes/editor.el b/core/cubes/editor.el index fc4f7bc..9f3f426 100644 --- a/core/cubes/editor.el +++ b/core/cubes/editor.el @@ -1,4 +1,4 @@ -;;; ElispCube --- The elisp cube for FG42 -*- lexical-binding: t; -*- +;;; EditorCubes --- The common cubes for FG42 -*- lexical-binding: t; -*- ;; ;; Copyright (c) 2010-2021 Sameer Rahmani & Contributors ;; @@ -52,8 +52,38 @@ ;; Sets the default font to fg42 font (add-to-list 'default-frame-alist (cons 'font (format "%s-%d" font size))) + (set-face-attribute 'default t :font font))) +(defcube fg42/dracula-theme-cube + (:docs "cubes/fg42/dracula-theme-cube.org") + (fpkg/use dracula-theme + :init + (progn + (load-theme 'dracula t) + (enable-theme 'dracula)))) + + +(defcube fg42/selectrum-cube + (:docs "cubes/fg42/editor-cube.org") + (fpkg/use selectrum + :defer nil + :init + (selectrum-mode +1)) + + (fpkg/use selectrum-prescient + :defer t + :init + (progn + (selectrum-prescient-mode +1) + (prescient-persist-mode +1))) + + ;; TODO: Disbale ctrlf in WM mode + (fpkg/use ctrlf + :defer t + :init + (ctrlf-mode +1))) + (defcube fg42/editor-cube (:docs "cubes/fg42/editor-cube.org") diff --git a/core/cubes/modeline.el b/core/cubes/modeline.el new file mode 100644 index 0000000..f8830dd --- /dev/null +++ b/core/cubes/modeline.el @@ -0,0 +1,54 @@ +;;; ModelineCubes --- The modeline related cubes for FG42 -*- lexical-binding: t; -*- +;; +;; Copyright (c) 2010-2021 Sameer Rahmani & Contributors +;; +;; Author: Sameer Rahmani +;; URL: https://gitlab.com/FG42/FG42 +;; Version: 3.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 . +;; +;;; Commentary: +;;; Code: +(require 'fpkg) +(require 'fg42/cube) + + +(defcube fg42/modeline-cube + (:docs "cubes/fg42/modeline-cube.org") + + (fpkg/use smart-mode-line + :straight (smart-mode-line :source melpa) + :defer nil + :init + (progn + (setq sml/theme 'respectful) + (setq sml/no-confirm-load-theme t) + (sml/setup))) + + + (fpkg/use mini-modeline + :straight (mini-modeline :repo "kiennq/emacs-mini-modeline" + :host github + :type git) + :after smart-mode-line + :init + (setq mini-modeline-enhance-visual t) + :defer nil + :config + (mini-modeline-mode t))) + + +(provide 'cubes/modeline) +;;; modeline.el ends here diff --git a/core/fg42/flags.el b/core/fg42/flags.el index 03c5f05..a9a72e2 100644 --- a/core/fg42/flags.el +++ b/core/fg42/flags.el @@ -84,7 +84,7 @@ For example, `(fg42/merge-flags (list f1 f2 f3) f4 -f2)' will return `(f1 f3 f4) "Define a new flag FLAG-NAME with the given DOCSTRING." (let ((var-name (intern (format "fg42/-flag-%s" flag-name)))) `(if (boundp ',var-name) - (warn (foramt "Flag name `%s' already defined" ,flag-name)) + (warn (format "Flag name `%s' already defined" ,(format "%s" flag-name))) (progn (defvar ,var-name t) (add-to-list 'fg42/available-flags ',flag-name))))) diff --git a/core/fpkg.el b/core/fpkg.el index 9dff9a9..0ab1cff 100644 --- a/core/fpkg.el +++ b/core/fpkg.el @@ -29,12 +29,28 @@ ;;(require 'use-package) +(defun inject-straight (args) + "Inject `:straight t' to ARGS it the key was missing." + (if (member :straight args) + args + (append args '(:straight t)))) + +(defun inject-defer (args) + "Inject `:defer t' to ARGS it the key was missing." + (if (member :defer args) + args + (append args '(:defer t)))) + + (defmacro fpkg/use (pkg &rest details) "Install the given package details PKG via use-package and straight." (declare (indent defun)) (if (and (listp details) (< 0 (length details))) - `(use-package ,pkg :straight ,@details :defer t) + (let ((params (inject-straight (inject-defer details)))) + (progn + (message ">>> %s %s" pkg details) + `(use-package ,pkg ,@params))) `(use-package ,pkg :straight t :defer t))) diff --git a/dev.org b/dev.org index 4704d4f..6ab4f1d 100644 --- a/dev.org +++ b/dev.org @@ -40,6 +40,7 @@ On the first level, I should feel comfortable with it. ** TODO Reformat the modeline ** TODO Create a macro similar to =with-ability= to run a block of code only if the given cube was active ** TODO Enable =straight= and =use-package= integration on compile time. Checout out =fpkg/core.el= +** TODO Check the =dracula= theme settings and configurations * Things that didn't work out - rbenv - helm