From dabf05f5f74501285abfb367a81a501e0d05264a Mon Sep 17 00:00:00 2001 From: Christopher James Hayward Date: Sun, 8 Oct 2023 22:45:08 -0400 Subject: [PATCH] Add ligature support and typescript formatting --- README.org | 63 +++++++++++++++++++++++++++++++++++++++++++++++ modules/emacs.nix | 1 + modules/x11.nix | 1 + 3 files changed, 65 insertions(+) diff --git a/README.org b/README.org index eaedf9f..4a5932b 100644 --- a/README.org +++ b/README.org @@ -730,6 +730,7 @@ Modules are files combined by [[https://nixos.org/][NixOS]] to produce the full fonts.fonts = with pkgs; [ iosevka-bin + fira-code-symbols emacs-all-the-icons-fonts ]; } @@ -1203,6 +1204,7 @@ let <> <> <> + <> <> <> <> @@ -1286,12 +1288,15 @@ When Emacs is started, it normally tries to load a Lisp program from an ititiali <> <> <> +<> <> <> +<> <> <> <> <> +<> <> <> <> @@ -1803,6 +1808,40 @@ epkgs.hydra "tf" '(hydra-text-scale/body :which-key "Font")) #+END_SRC +*** Ligatures + +#+NAME: emacs-ligatures-package +#+BEGIN_SRC nix +epkgs.ligature +#+END_SRC + +Ligature.el maps ordinary graphmemes (characters) to fancy ligatures, if both the version of [[https://gnu.org/software/emacs/][Emacs]] and the font supports it. It can control where [[https://gnu.org/software/emacs/][Emacs]] must display ligatures, useful if only a subset of the ligatures in certain major modes is required. + +#+NAME: emacs-ligatures-elisp +#+BEGIN_SRC emacs-lisp +(ligature-set-ligatures 't '("www")) +;; Enable traditional ligature support in eww-mode, if the +;; `variable-pitch' face supports it +(ligature-set-ligatures 'eww-mode '("ff" "fi" "ffi")) +;; Enable all Cascadia Code ligatures in programming modes +(ligature-set-ligatures 'prog-mode '("|||>" "<|||" "<==>" "" "---" "-<<" + "<~~" "<~>" "<*>" "<||" "<|>" "<$>" "<==" "<=>" "<=<" "<->" + "<--" "<-<" "<<=" "<<-" "<<<" "<+>" "" "###" "#_(" "..<" + "..." "+++" "/==" "///" "_|_" "www" "&&" "^=" "~~" "~@" "~=" + "~>" "~-" "**" "*>" "*/" "||" "|}" "|]" "|=" "|>" "|-" "{|" + "[|" "]#" "::" ":=" ":>" ":<" "$>" "==" "=>" "!=" "!!" ">:" + ">=" ">>" ">-" "-~" "-|" "->" "--" "-<" "<~" "<*" "<|" "<:" + "<$" "<=" "<>" "<-" "<<" "<+" "" "++" "?:" + "?=" "?." "??" ";;" "/*" "/=" "/>" "//" "__" "~~" "(*" "*)" + "\\\\" "://")) +;; Enables ligature checks globally in all buffers. You can also do it +;; per mode with `ligature-mode'. +(global-ligature-mode t) +#+END_SRC + *** Frames Sometimes it's useful to resize the current frame without using the mouse (always). The default behaviour when calling ~shrink-window~ and ~enlarge-window~ only changes the size by a small margin. I solved this problem with the same method used for scaling text: @@ -2441,6 +2480,15 @@ epkgs.projectile (projectile-mode +1) #+END_SRC +*** Electric Pair + +#+NAME: electric-pair-elisp +#+BEGIN_SRC emacs-lisp +;; Enable smart parenthesis. +(electric-pair-mode 1) +(setq electric-pair-preserve-balance nil) +#+END_SRC + *** LSP Mode #+NAME: emacs-lsp-package @@ -2647,6 +2695,21 @@ epkgs.typescript-mode Typescript.el is a self-contained, lightweight and minimalist major-mode focused on providing basic font-lock/syntax-highlighting and indentation for Typescript syntax, without any external dependencies. +#+NAME: emacs-typescript-elisp +#+BEGIN_SRC emacs-lisp +;; Use spaces instead of tabs. +(setq-default tab-width 4) +(setq-default indent-tabs-mode nil) + +;; Create a custom hook for typescript mode. +(defun dotfiles/typescript-hook () + (add-hook 'before-save-hook #'lsp-format-buffer t t) + (add-hook 'before-save-hook #'lsp-organize-imports t t)) + +;; Apply the hook. +(add-hook 'typescript-mode-hook #'dotfilers/typescript-hook) +#+END_SRC + *** YAML Mode #+NAME: emacs-yaml-mode-package diff --git a/modules/emacs.nix b/modules/emacs.nix index d9b83bc..fe707b9 100644 --- a/modules/emacs.nix +++ b/modules/emacs.nix @@ -43,6 +43,7 @@ let epkgs.vterm epkgs.magit epkgs.hydra + epkgs.ligature epkgs.elfeed epkgs.nix-mode epkgs.projectile diff --git a/modules/x11.nix b/modules/x11.nix index 341552b..acf8339 100644 --- a/modules/x11.nix +++ b/modules/x11.nix @@ -34,6 +34,7 @@ fonts.fonts = with pkgs; [ iosevka-bin + fira-code-symbols emacs-all-the-icons-fonts ]; }