From d9150880d3f220b313f1aa5a3c13330c5f5c31a4 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Mon, 24 Feb 2025 12:17:32 -0500 Subject: [PATCH] Fix org-mode shift-arrow keys and add cmake support. --- .../roles/emacs/files/elisp/base-extensions.el | 13 +++++++++++-- ansible/roles/emacs/files/elisp/lang-cmake.el | 18 ++++++++++++++++++ ansible/roles/emacs/files/elisp/lang-nix.el | 16 ++++++++-------- ansible/roles/emacs/files/elisp/lang-org.el | 17 +++++++++++++---- ansible/roles/emacs/files/init.el | 2 ++ 5 files changed, 52 insertions(+), 14 deletions(-) create mode 100644 ansible/roles/emacs/files/elisp/lang-cmake.el diff --git a/ansible/roles/emacs/files/elisp/base-extensions.el b/ansible/roles/emacs/files/elisp/base-extensions.el index 3c346c9..3d8927b 100644 --- a/ansible/roles/emacs/files/elisp/base-extensions.el +++ b/ansible/roles/emacs/files/elisp/base-extensions.el @@ -51,6 +51,7 @@ ;; Persist history over Emacs restarts. Vertico sorts by history position. (use-package savehist ;; This is an emacs built-in but we're pulling the latest version + :pin gnu :config (savehist-mode)) @@ -60,8 +61,16 @@ (which-key-mode)) (use-package windmove - :config - (windmove-default-keybindings)) + ;; This is an emacs built-in but we're pulling the latest version + :pin gnu + :bind + ( + ("S-" . windmove-up) + ("S-" . windmove-right) + ("S-" . windmove-down) + ("S-" . windmove-left) + ) + ) (setq tramp-default-method "ssh") diff --git a/ansible/roles/emacs/files/elisp/lang-cmake.el b/ansible/roles/emacs/files/elisp/lang-cmake.el new file mode 100644 index 0000000..885449b --- /dev/null +++ b/ansible/roles/emacs/files/elisp/lang-cmake.el @@ -0,0 +1,18 @@ +(require 'common-lsp) + +(use-package cmake-mode + :commands cmake-mode + :hook ( + (cmake-mode . (lambda () + (eglot-ensure) + (defclass my/eglot-cmake (eglot-lsp-server) () + :documentation + "Own eglot server class.") + + (add-to-list 'eglot-server-programs + '(cmake-mode . (my/eglot-cmake "cmake-language-server"))) + )) + ) + ) + +(provide 'lang-cmake) diff --git a/ansible/roles/emacs/files/elisp/lang-nix.el b/ansible/roles/emacs/files/elisp/lang-nix.el index 9ba0abd..a817024 100644 --- a/ansible/roles/emacs/files/elisp/lang-nix.el +++ b/ansible/roles/emacs/files/elisp/lang-nix.el @@ -7,15 +7,15 @@ :commands nix-mode :hook ( (nix-mode . (lambda () - ;; (eglot-ensure) - ;; (defclass my/eglot-nix (eglot-lsp-server) () - ;; :documentation - ;; "Own eglot server class.") + (eglot-ensure) + (defclass my/eglot-nix (eglot-lsp-server) () + :documentation + "Own eglot server class.") - ;; (add-to-list 'eglot-server-programs - ;; '(nix-mode . (my/eglot-nix "nixd"))) - ;; (add-hook 'before-save-hook 'eglot-format-buffer nil 'local) - )) + (add-to-list 'eglot-server-programs + '(nix-mode . (my/eglot-nix "nixd"))) + (add-hook 'before-save-hook 'eglot-format-buffer nil 'local) + )) ) ) diff --git a/ansible/roles/emacs/files/elisp/lang-org.el b/ansible/roles/emacs/files/elisp/lang-org.el index 4a9166d..120b364 100644 --- a/ansible/roles/emacs/files/elisp/lang-org.el +++ b/ansible/roles/emacs/files/elisp/lang-org.el @@ -1,16 +1,23 @@ (use-package org :ensure nil :commands org-mode - :bind ( + :bind (:map org-mode-map ("C-c l" . org-store-link) ("C-c a" . org-agenda) - ("C--" . org-timestamp-down) - ("C-=" . org-timestamp-up) + ("S-" . org-shiftup) + ("S-" . org-shiftright) + ("S-" . org-shiftdown) + ("S-" . org-shiftleft) ) :hook ( (org-mode . (lambda () (org-indent-mode +1) - )) + )) + ;; Make windmove work in Org mode: + (org-shiftup-final . windmove-up) + (org-shiftleft-final . windmove-left) + (org-shiftdown-final . windmove-down) + (org-shiftright-final . windmove-right) ) :config (require 'org-tempo) @@ -38,6 +45,8 @@ ;; TODO: There is an option to set the compiler, could be better than manually doing this here https://orgmode.org/manual/LaTeX_002fPDF-export-commands.html ;; (setq org-latex-compiler "lualatex") + ;; TODO: nixos latex page recommends this line, figure out what it does / why its needed: + ;; (setq org-preview-latex-default-process 'dvisvgm) (setq org-latex-pdf-process '("lualatex -shell-escape -interaction nonstopmode -output-directory %o %f" "lualatex -shell-escape -interaction nonstopmode -output-directory %o %f" diff --git a/ansible/roles/emacs/files/init.el b/ansible/roles/emacs/files/init.el index 68b1a11..ad9ff8b 100644 --- a/ansible/roles/emacs/files/init.el +++ b/ansible/roles/emacs/files/init.el @@ -38,4 +38,6 @@ (require 'lang-nix) +(require 'lang-cmake) + (load-directory autoload-directory)