emacs: Set font according to screen DPI
This commit is contained in:
parent
7ad29c469c
commit
5f351fe376
4 changed files with 51 additions and 64 deletions
|
@ -55,11 +55,11 @@ Setting =lexical-binding= to =t= can improve startup time. This has to be first!
|
||||||
This sets some variables with my personal preferences for easy customization
|
This sets some variables with my personal preferences for easy customization
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(defvar my/default-font "Monaspace Argon-16")
|
(defvar my/default-font "Monaspace Neon")
|
||||||
(defvar my/variable-width-font "Iosevka Aile-16")
|
(defvar my/variable-width-font "Iosevka Aile")
|
||||||
(defvar my/comment-font "Monaspace Radon-16")
|
(defvar my/comment-font "Monaspace Radon")
|
||||||
(defvar my/default-font-height 13)
|
(defvar my/default-font-height 120)
|
||||||
(defvar my/default-font-weight 'normal)
|
(defvar my/default-font-weight 'light)
|
||||||
(defvar my/default-font-width 'normal)
|
(defvar my/default-font-width 'normal)
|
||||||
(defvar my/variable-width-font-height 1.1)
|
(defvar my/variable-width-font-height 1.1)
|
||||||
(defvar my/config-file-path (expand-file-name "config.org" user-emacs-directory))
|
(defvar my/config-file-path (expand-file-name "config.org" user-emacs-directory))
|
||||||
|
@ -366,7 +366,7 @@ Prefer to open frames in a horizontal split and make sure they're of a decent wi
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(setq split-height-threshold nil
|
(setq split-height-threshold nil
|
||||||
window-min-width 120)
|
window-min-width 100)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
Set fill column to 80
|
Set fill column to 80
|
||||||
|
@ -423,16 +423,30 @@ I prefer the [[https://draculatheme.com][dracula theme]]
|
||||||
Set fonts.
|
Set fonts.
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
|
(defun my/set-font-size (&optional frame)
|
||||||
|
(let* ((frame (or frame (selected-frame)))
|
||||||
|
(geometry (frame-monitor-attribute 'geometry frame))
|
||||||
|
(mm-size (frame-monitor-attribute 'mm-size frame))
|
||||||
|
(width-px (caddr geometry))
|
||||||
|
(width-mm (car mm-size))
|
||||||
|
(width-in (/ width-mm 25.4))
|
||||||
|
(display-dpi (/ width-px width-in))
|
||||||
|
(font-height (cond
|
||||||
|
((< display-dpi 110) 120)
|
||||||
|
((< display-dpi 130) 140)
|
||||||
|
((< display-dpi 160) 160)
|
||||||
|
(t 160))))
|
||||||
|
(set-face-attribute 'default frame :height font-height)))
|
||||||
|
|
||||||
|
(add-hook 'server-after-make-frame-hook 'my/set-font-size)
|
||||||
|
|
||||||
(defun my/setup-fonts ()
|
(defun my/setup-fonts ()
|
||||||
; Monospace
|
(set-face-attribute 'default nil :family my/default-font :weight 'light)
|
||||||
(set-face-attribute 'default nil :font my/default-font)
|
|
||||||
(set-face-attribute 'font-lock-comment-face nil :font my/comment-font)
|
(set-face-attribute 'font-lock-comment-face nil :font my/comment-font)
|
||||||
; Variable pitch
|
|
||||||
(set-face-attribute 'variable-pitch nil
|
(set-face-attribute 'variable-pitch nil
|
||||||
:font my/variable-width-font
|
:font my/variable-width-font
|
||||||
:height my/variable-width-font-height))
|
:height my/variable-width-font-height))
|
||||||
(add-hook 'after-init-hook 'my/setup-fonts)
|
(add-hook 'after-init-hook 'my/setup-fonts)
|
||||||
(add-hook 'server-after-make-frame-hook 'my/setup-fonts)
|
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
Emoji support
|
Emoji support
|
||||||
|
@ -1469,15 +1483,15 @@ Tell =nil= to use =nixpkgs-fmt= for formatting nix files.
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(with-eval-after-load 'eglot
|
(with-eval-after-load 'eglot
|
||||||
(add-to-list 'eglot-server-programs
|
(add-to-list 'eglot-server-programs
|
||||||
'(nix-mode . ("nil" :initializationOptions
|
`(nix-mode . ("nil" :initializationOptions
|
||||||
`(:nil (:formatting (:command ["nixpkgs-fmt"])))))))
|
(:formatting (:command ["nixpkgs-fmt"]))))))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
*** Common Lisp
|
*** Common Lisp
|
||||||
|
|
||||||
Common Lisp does not use =lsp-mode=, but has it's own environment: [[https://github.com/slime/slime][SLIME]] or Superior Lisp Interaction Mode for Emacs.
|
Common Lisp does not use =lsp-mode=, but has it's own environment: [[https://github.com/slime/slime][SLIME]] or Superior Lisp Interaction Mode for Emacs.
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp :tangle no
|
||||||
(use-package slime
|
(use-package slime
|
||||||
:init
|
:init
|
||||||
(setq slime-lisp-implementations
|
(setq slime-lisp-implementations
|
||||||
|
@ -1491,6 +1505,13 @@ Common Lisp does not use =lsp-mode=, but has it's own environment: [[https://git
|
||||||
(lisp-mode . (lambda () (slime-mode t)))
|
(lisp-mode . (lambda () (slime-mode t)))
|
||||||
(inferior-lisp-mode . (lambda () (inferior-slime-mode t))))
|
(inferior-lisp-mode . (lambda () (inferior-slime-mode t))))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
[[https://github.com/joaotavora/sly][SLY]] is a fork of SLIME, by the same author as =eglot=, with improved UX
|
||||||
|
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(use-package sly)
|
||||||
|
#+end_src
|
||||||
|
|
||||||
*** Clojure
|
*** Clojure
|
||||||
|
|
||||||
Similar to =lisp=, there is [[https://github.com/clojure-emacs/cider][CIDER]] (Clojure Interactive Development Environment that Rocks) for Clojure(Script)
|
Similar to =lisp=, there is [[https://github.com/clojure-emacs/cider][CIDER]] (Clojure Interactive Development Environment that Rocks) for Clojure(Script)
|
||||||
|
|
|
@ -142,7 +142,6 @@ in
|
||||||
(nil.overrideAttrs (_: { doCheck = false; }))
|
(nil.overrideAttrs (_: { doCheck = false; }))
|
||||||
nixpkgs-fmt
|
nixpkgs-fmt
|
||||||
python3
|
python3
|
||||||
# (tree-sitter.withPlugins builtins.attrValues)
|
|
||||||
] ++
|
] ++
|
||||||
(with aspellDicts; [ en en-computers en-science fy nl ]);
|
(with aspellDicts; [ en en-computers en-science fy nl ]);
|
||||||
|
|
||||||
|
|
|
@ -22,5 +22,4 @@ _final: prev: {
|
||||||
patches = (prevAttrs.patches or [ ]) ++ [ ./ddccontrol-db/0001-add-del41d9.patch ];
|
patches = (prevAttrs.patches or [ ]) ++ [ ./ddccontrol-db/0001-add-del41d9.patch ];
|
||||||
});
|
});
|
||||||
|
|
||||||
monaspace = prev.pkgs.callPackage ../pkgs/monaspace { };
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
{ lib, stdenvNoCC, fetchzip }:
|
|
||||||
|
|
||||||
stdenvNoCC.mkDerivation rec {
|
|
||||||
pname = "monaspace";
|
|
||||||
version = "1.000";
|
|
||||||
|
|
||||||
src = fetchzip {
|
|
||||||
url = "https://github.com/githubnext/monaspace/releases/download/v${version}/monaspace-v${version}.zip";
|
|
||||||
hash = "sha256-H8NOS+pVkrY9DofuJhPR2OlzkF4fMdmP2zfDBfrk83A=";
|
|
||||||
stripRoot = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
outputs = [ "out" ];
|
|
||||||
|
|
||||||
installPhase = ''
|
|
||||||
runHook preInstall
|
|
||||||
mkdir -p $out/share/fonts/monaspace
|
|
||||||
mkdir -p $out/share/fonts/monaspace-variable
|
|
||||||
cp monaspace-v${version}/fonts/otf/*.otf $out/share/fonts/monaspace
|
|
||||||
cp monaspace-v${version}/fonts/variable/*.ttf $out/share/fonts/monaspace-variable
|
|
||||||
runHook postInstall
|
|
||||||
'';
|
|
||||||
|
|
||||||
meta = with lib; {
|
|
||||||
description = "Monaspace";
|
|
||||||
longDescription = "An innovative superfamily of fonts for code.";
|
|
||||||
homepage = "https://monaspace.githubnext.com/";
|
|
||||||
license = licenses.ofl;
|
|
||||||
platforms = platforms.all;
|
|
||||||
maintainers = with maintainers; [ AndersonTorres ];
|
|
||||||
};
|
|
||||||
}
|
|
Loading…
Reference in a new issue