diff --git a/lisp/fg42/autocomplete.el b/lisp/fg42/autocomplete.el new file mode 100644 index 0000000..ea1d8b0 --- /dev/null +++ b/lisp/fg42/autocomplete.el @@ -0,0 +1,56 @@ +;;; FG42 --- The mighty editor for the emacsians -*- lexical-binding: t; -*- +;; +;; Copyright (c) 2010-2024 Sameer Rahmani & Contributors +;; +;; Author: Sameer Rahmani +;; URL: https://devheroes.codes/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: +(eval-when-compile + (require 'fpkg)) + + +(use! company + "Company is a modular text completion framework for GNU Emacs." + :commands 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 + (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)) + + +(provide 'fg42/autocomplete) +;;; autocomplete.el ends here diff --git a/lisp/fg42/deps.el b/lisp/fg42/deps.el index 5999161..844b5d5 100644 --- a/lisp/fg42/deps.el +++ b/lisp/fg42/deps.el @@ -120,7 +120,9 @@ pkg-info envrc vertico - orderless) + orderless + eglot +) (provide 'fg42/deps) ;;; deps.el ends here diff --git a/lisp/fg42/editor.el b/lisp/fg42/editor.el index 47db633..0c476e7 100644 --- a/lisp/fg42/editor.el +++ b/lisp/fg42/editor.el @@ -21,21 +21,27 @@ ;; ;;; Commentary: ;;; Code: -(require 'server) - (eval-when-compile - (require 'fpkg)) - + (require 'fpkg) + ;; Language support +) +(require 'server) (require 'fg42/modeline) +(require 'fg42/autocomplete) +(require 'fg42/langs/cpp) + ;; (require 'fg42/utils) ;; (require 'fg42/modeline) ;; (require 'fg42/cubes/modeline) ;; (require 'fg42/themes) ;; (require 'fg42/project) +(defvar fg42/font '("Fira Mono" 12) + "Font name and size to be used with FG42. (Default (\"Fira Mono\" 12).") -(defvar fg42/font '("Fira Mono" 12)) +(defvar fg42/snippet-dir nil + "Where to find user's snippets.") (defun fg42/setup-font () @@ -48,6 +54,7 @@ (set-face-attribute 'default t :font name))) + (defun fg42/setup-editor () "Setup the overall functionality of FG42." (use! origami @@ -107,12 +114,21 @@ contextual information." :init (setq epa-pinentry-mode 'loopback)) + (use! imenu + "The Imenu facility offers a way to find the major definitions in a file by name." + :bind (("M-i" . imenu))) + (use! imenu-list "his Emacs minor-mode creates an automatically updated buffer called `Ilist' that is populated with the current buffer's imenu entries. The `Ilist' buffer is typically shown as a sidebar (Emacs vertically splits the window)." :bind (("C-'" . imenu-list-smart-toggle))) + (use! display-line-numbers + "The builtin replacement of linum. It's is pretty fast." + :config + (global-display-line-numbers-mode 1)) + (use! emojify "Adds support for emojis to `FG42'" :hook (emacs-startup . global-emojify-mode)) @@ -154,6 +170,7 @@ data. The typical example of this would be Lisp or Scheme source code." "This cube controls the different aspect of buffer navigation" :bind ("C-" . ace-window)) + ;; Minibuffer related stuff (use! vertico "Vertico provides a performant and minimalistic vertical completion UI based on the default completion system. The focus of Vertico is to provide @@ -190,6 +207,35 @@ match all of the components in any order." Emacs." :if (display-graphic-p)) + (use! yasnippet + "ASnippet is a template system for Emacs. " + :config + (let* ((snippet-home + (expand-file-name + "snippets" + (file-name-directory (locate-library "yasnippet-snippets")))) + (local-snippet (expand-file-name "snippets" fg42-home)) + (user-snippets (or fg42/snippet-dir local-snippet))) + + (setq yas-snippet-dirs `(,user-snippets ,local-snippet ,snippet-home)) + (yas-global-mode 1))) + + (use! yasnippet-snippets + "Yasnippet's snippets." + :after yasnippet) + + ;; Language Servers and friends + (use! eglot + "Eglot is a minimalistic yet powerful LSP replacement +shipped with Emacs." + :commands eglot + :autoload eglot-ensure) + + + (use! flycheck + "Flycheck is a modern on-the-fly syntax checking extension for GNU Emacs." + :config (global-flycheck-mode)) + ;; In the following section we're setting some default behavior of FG42. ;; Most of these configuration are opiniated and I think most of people ;; shared the same opinion or don't care at all. @@ -218,16 +264,24 @@ Emacs." ;; Support opening new minibuffers from inside existing minibuffers. (setq enable-recursive-minibuffers t) + + (setq tooltip-use-echo-area t) + (setq x-gtk-use-system-tooltips nil) + ;; Global configurations (tool-bar-mode -1) + (tooltip-mode nil) (menu-bar-mode -1) (when (display-graphic-p) + ;; Smoother scrolling + (pixel-scroll-precision-mode) (scroll-bar-mode -1)) (column-number-mode t) (show-paren-mode t) (electric-pair-mode 1) + (global-company-mode) ;; Rectangular select (cua-selection-mode t) diff --git a/lisp/fg42/lang-servers.el b/lisp/fg42/lang-servers.el deleted file mode 100644 index 15ca9e0..0000000 --- a/lisp/fg42/lang-servers.el +++ /dev/null @@ -1,30 +0,0 @@ -;;; Flags --- Flags library of FG42 -*- lexical-binding: t; -*- -;; -;; Copyright (c) 2010-2024 Sameer Rahmani & Contributors -;; -;; Author: Sameer Rahmani -;; URL: https://devheroes.codes/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 'fg42/flags) - - - -(provide 'lang-servers) -;;; lang-servers.el ends here diff --git a/lisp/fg42/langs/#cpp.el# b/lisp/fg42/langs/#cpp.el# deleted file mode 100644 index 35a6c25..0000000 --- a/lisp/fg42/langs/#cpp.el# +++ /dev/null @@ -1,63 +0,0 @@ -;;; FG42 --- The mighty editor for the emacsians -*- lexical-binding: t; -*- -;; -;; Copyright (c) 2010-2024 Sameer Rahmani & Contributors -;; -;; Author: Sameer Rahmani -;; URL: https://devheroes.codes/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/utils) -(require 'fg42/language-servers) - -;; (use! cmake-ts-mode) -(use! eldoc-cmake - :hook (cmake-ts-mode . eldoc-cmake-enable)) - - -(use! ninja-mode - "This cube enables Ninja integration with FG42. For more info checkout: -https://github.com/ninja-build/ninja/blob/master/misc/ninja-mode.el") - - -(use! c++-ts-mode - "C++ setup. We're using treesitter version of c++ mode." - :mode ("\\.h\\'" . c++-ts-mode) - :mode ("\\.hpp\\'" . c++-ts-mode) - :mode ("\\.cpp\\'" . c++-ts-mode) - - :hook ((c++-ts-mode-hook . fg42/ls-run) - (c++-ts-mode-hook . fg42/cpp-autocomplete)) - ) - - -(add-hook 'c++-ts-mode-hook (setq-local company-backends - '((company-dabbrev company-ispell :separate) - company-files)) - (lambda () - - (require 'company-capf) - (require 'company-box) - - - (setq company-backends - '((company-capf - company-keywords))))) - -(provide 'fg42/langs/cpp) -;;; cpp.el ends here diff --git a/lisp/fg42/langs/.#cpp.el b/lisp/fg42/langs/.#cpp.el deleted file mode 120000 index a7fda75..0000000 --- a/lisp/fg42/langs/.#cpp.el +++ /dev/null @@ -1 +0,0 @@ -lxsameer@majin.3221106:1710087423 \ No newline at end of file diff --git a/lisp/fg42/langs/cpp.el b/lisp/fg42/langs/cpp.el index 3f8aafd..480f1d9 100644 --- a/lisp/fg42/langs/cpp.el +++ b/lisp/fg42/langs/cpp.el @@ -21,12 +21,27 @@ ;; ;;; Commentary: ;;; Code: -(require 'fpkg) -(require 'fg42/utils) -(require 'fg42/language-servers) +(eval-when-compile + (require 'fpkg)) + +(defvar fg42/clangd-args + (list + (format "-j=%s" (- (num-processors) 2)) + "--clang-tidy" + "--header-insertion=iwyu" + "--pch-storage=memory" + "--background-index" + "--cross-file-rename" + "--completion-style=detailed" + "--malloc-trim" + ) + "Arguments to pass to clangd.") + +(use! cmake-ts-mode + "Enable cmake-ts-mode instead of the non-TS version.") -;; (use! cmake-ts-mode) (use! eldoc-cmake + "ElDoc and cmake integration" :hook (cmake-ts-mode . eldoc-cmake-enable)) @@ -35,29 +50,36 @@ https://github.com/ninja-build/ninja/blob/master/misc/ninja-mode.el") -(use! c++-ts-mode +(defun fg42/c-ts-mode-setup () + "A hook handler to setup cpp related configurations." + (message "[FG42][C/C++]: Make sure to setup clangd to fit your needs. For more info: https://clangd.llvm.org/config") + (setq-local company-backends + '((company-capf :with company-yasnippet) :separate + (company-keywords company-dabbrev company-ispell) :separate + company-files))) + + +(use! c-ts-mode "C++ setup. We're using treesitter version of c++ mode." - :mode ("\\.h\\'" . c++-ts-mode) - :mode ("\\.hpp\\'" . c++-ts-mode) - :mode ("\\.cpp\\'" . c++-ts-mode) + :init + ;; Remap the standard C/C++ modes + (add-to-list 'major-mode-remap-alist '(c-mode . c-ts-mode)) + (add-to-list 'major-mode-remap-alist '(c++-mode . c++-ts-mode)) + (add-to-list 'major-mode-remap-alist '(c-or-c++-mode . c-or-c++-ts-mode)) - :hook ((c++-ts-mode-hook . fg42/ls-run) - (c++-ts-mode-hook . fg42/cpp-autocomplete)) - ) + :config + ;; Set the default lang server for C/C++ to clangd + (with-eval-after-load 'eglot + (add-to-list + 'eglot-server-programs + `(c-mode c++-mode c-ts-mode c++-ts-mode . ("clangd" ,@fg42/clangd-args)))) + :hook + (c++-ts-mode . eglot-ensure) + (c++-ts-mode . company-mode) + (c++-ts-mode . fg42/c-ts-mode-setup) + (c++-ts-mode . flyspell-prog-mode)) -(add-hook 'c++-ts-mode-hook (setq-local company-backends - '((company-dabbrev company-ispell :separate) - company-files)) - (lambda () - - (require 'company-capf) - (require 'company-box) - - - (setq company-backends - '((company-capf - company-keywords))))) (provide 'fg42/langs/cpp) ;;; cpp.el ends here diff --git a/nix/fg42.nix b/nix/fg42.nix index b13ae86..c7bbac6 100644 --- a/nix/fg42.nix +++ b/nix/fg42.nix @@ -40,6 +40,7 @@ vazir-fonts, fira-code, nerdfonts, + noto-fonts, gcc, ltex-ls, bash, @@ -108,8 +109,10 @@ in stdenv.mkDerivation (final: rec{ LISPDIR=$out/share/fg42/ mkdir -p $out/bin install -d $LISPDIR + cp -rv ${src}/lisp/ $LISPDIR cp -rv ${src}/share $out/ + cp -rv ${src}/snippets $LISPDIR/snippets runHook preBuild @@ -172,6 +175,7 @@ in stdenv.mkDerivation (final: rec{ ${vazir-fonts} ${fira-code} ${nerdfonts} + ${noto-fonts} ${lib.strings.concatLines paths} EOF diff --git a/lisp/fg42/cubes/snippets/c++-mode/section b/snippets/c++-mode/section similarity index 100% rename from lisp/fg42/cubes/snippets/c++-mode/section rename to snippets/c++-mode/section diff --git a/lisp/fg42/cubes/snippets/org-mode/align b/snippets/org-mode/align similarity index 100% rename from lisp/fg42/cubes/snippets/org-mode/align rename to snippets/org-mode/align diff --git a/lisp/fg42/cubes/snippets/org-mode/begin b/snippets/org-mode/begin similarity index 100% rename from lisp/fg42/cubes/snippets/org-mode/begin rename to snippets/org-mode/begin diff --git a/lisp/fg42/cubes/snippets/org-mode/block b/snippets/org-mode/block similarity index 100% rename from lisp/fg42/cubes/snippets/org-mode/block rename to snippets/org-mode/block diff --git a/lisp/fg42/cubes/snippets/org-mode/equation b/snippets/org-mode/equation similarity index 100% rename from lisp/fg42/cubes/snippets/org-mode/equation rename to snippets/org-mode/equation diff --git a/lisp/fg42/cubes/snippets/org-mode/frac b/snippets/org-mode/frac similarity index 100% rename from lisp/fg42/cubes/snippets/org-mode/frac rename to snippets/org-mode/frac diff --git a/lisp/fg42/cubes/snippets/org-mode/infobox b/snippets/org-mode/infobox similarity index 100% rename from lisp/fg42/cubes/snippets/org-mode/infobox rename to snippets/org-mode/infobox diff --git a/lisp/fg42/cubes/snippets/org-mode/prod b/snippets/org-mode/prod similarity index 100% rename from lisp/fg42/cubes/snippets/org-mode/prod rename to snippets/org-mode/prod diff --git a/lisp/fg42/cubes/snippets/org-mode/sum b/snippets/org-mode/sum similarity index 100% rename from lisp/fg42/cubes/snippets/org-mode/sum rename to snippets/org-mode/sum diff --git a/lisp/fg42/cubes/snippets/org-mode/tw b/snippets/org-mode/tw similarity index 100% rename from lisp/fg42/cubes/snippets/org-mode/tw rename to snippets/org-mode/tw