dotfiles/home-manager/modules/emacs/.emacs.d/org/base.org
magic_rb 42513fe6cc
emacs: fix X11 frames
Signed-off-by: magic_rb <magic_rb@redalder.org>
2024-10-26 12:34:24 +02:00

7.4 KiB

Magic_RB's Emacs configuration

#

Stuff That Needs Work

TODO Spell checking

TODO Calc mode

TODO Org Agenda

Make it work on my phone

TODO Org Roam

TODO org-evil moving stuff, left, right with M-j M-; instead of M-h M-l

Stuff

  (use-package pdf-tools
    :straight t
    :hook (('TeX-mode-hook . visual-line-mode))
    :init
    (set-variable 'pdf-info-epdfinfo-program (shell-command-to-string "printf ~/.emacs.d/profile/share/emacs/site-lisp/elpa/pdf-tools-*/epdfinfo"))
    ;; initialise
    (pdf-tools-install)
    (setq TeX-PDF-mode 1)
    ;; open pdfs scaled to fit page
    (setq-default pdf-view-display-size 'fit-page)
    ;; automatically annotate highlights
    (setq pdf-annot-activate-created-annotations t))

Enable all-the-icons, it's used by treemacs and doom-modeline.

  (use-package all-the-icons
    :straight t)

Set ispell program to hunspell, this is very much a TODO, since the spelling configuration is rather minimal at this point in time.

  (setq ispell-program-name "hunspell")

Fetch the SSH_AUTH_PATH from .profile.

  (setenv "SSH_AUTH_SOCK" (shell-command-to-string ". ~/.profile && printf $SSH_AUTH_SOCK"))

Language

SCAD Programming Language

Enable scad-mode

  (use-package scad-mode
    :straight t)

Rust Programming Language

Enable rustic and more feature-full alternative to rust-mode, actually a rather distant fork of it. Also hook lsp-mode on it.

  (use-package rustic
    :straight t
    :hook (rustic-mode . lsp-mode)
    :mode ("\\.rs\\'" . rustic-mode))

LSP

envrc

Enable envrc, which changes ENVs on a per buffer basis.

  (use-package envrc
    :straight t
    :init
    (envrc-global-mode))

lsp-mode

Switch completion provider to capf, even though it should be the default, but just to make sure it. company-lsp is what lsp-mode switched away from.

  (setq lsp-completion-provider :capf)

Setup rustic to prefer rust-analyzer instead of rls and also don't format on save, it's really annoying.

  (setq rustic-lsp-server 'rust-analyzer)
  (setq rustic-compile-command "cargo build")
  (setq rustic-format-trigger nil);'on-save

Enable inline type hints and disable chaining and parameter hints for Rust.

  (setq lsp-rust-analyzer-display-chaining-hints nil)
  (setq lsp-rust-analyzer-display-parameter-hints nil)
  (setq lsp-rust-analyzer-server-display-inlay-hints t)

Finally enable lsp-mode.

  (use-package lsp-mode
    :straight t
    :after (envrc)
    :config
    (setq lsp-prefer-flymake nil)
    (setq lsp-ui-doc-enable nil)
    :config
    <<lsp-rustic>>
    ;; <<lsp-rust-analyzer>>

    <<lsp-completion-provider>>
    <<lsp-typescript-tramp>>
    <<lsp-scala-tramp>>)

lsp-ui

Enable lsp-ui, it adds doc frames, code actions at the side and other cool things, some of them are annoying and need disabling.

  (use-package lsp-ui
    :straight t
    :after (company-box)
    :config
    ;; disable focus on mouse over
    (push '(no-accept-focus . t) lsp-ui-doc-frame-parameters)
    (push '(no-accept-focus . t) company-box-frame-parameters)

    (add-to-list 'lsp-ui-doc-frame-parameters '(no-accept-focus . t))
    (add-to-list 'company-box-frame-parameters '(no-accept-focus . t))
    (setq mouse-autoselect-window nil))

flycheck

Enable flycheck for in-buffer hints and errors and warning and things.

  (use-package flycheck
    :straight t
    :init (global-flycheck-mode))

Projectile

Enable projectile.

  (use-package projectile
    :straight t
    :config
    (projectile-mode +1)
    (define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map))

Random Bits and Bobs

Set keystrokes echo to something really low, it's useful to know what you're typing.

  (setq echo-keystrokes 0.01)

Set default major mode to org mode, it's much more useful than fundamental.

  (setq-default major-mode 'org-mode)

Delete files by moving to trash.

  (setq-default delete-by-moving-to-trash t)

Equalize windows after split.

  (setq-default window-combination-resize t)

Increase undo limit to 80MB and enable fine undo, Evil will no longer chunk all edits in INSERT mode into one big undo blob.

  (setq undo-limit 80000000
        evil-want-fine-undo t)

For now, don't autosave. Because editing on remote disks, not TRAMP, but just NFS or CIFS, becomes extremely painful.

  (setq auto-save-default t)

Enable line numbers for both programming buffers (Rust, C, and such) and configuration buffers (Nix, Yaml, Json, and such) and Org mode.

  (add-hook 'conf-mode-hook 'display-line-numbers-mode)
  (add-hook 'prog-mode-hook 'display-line-numbers-mode)

Improve scrolling by:

  1. disabling acceleration
  2. making it so that the window under the pointer is scroller no matter the focused window
  3. changing default scroll amount to 5 lines and 1 when shift is pressed

      (setq mouse-wheel-scroll-amount '(5 ((shift) . 1)))
      (setq mouse-wheel-progressive-speed nil)
      (setq mouse-wheel-follow-mouse 't)

    Enable perentheses highlighting and pairing.

      (show-paren-mode 1)
      (electric-pair-mode)

    Set fill colum, horizontal indicator, for both fill-paragraph=(=M-q) and the visual horizontal indicator.

      (setq-default display-fill-column-indicator-column 120
                    fill-column 120)

    Start Emacs server, unless it's already running. Starting a new Emacs instance while debugging and getting an error about a server already running can be a bit annoying.

      (load "server")
      (unless (server-running-p) (server-start))
      (setq backup-directory-alist
            `(("." . ,(concat user-emacs-directory "backups"))))

Windows

As tecosaur has it in his configuration, I was to be asked which window to should be brought up when I split a window in Emacs. So create a new advice which will run after evil split commands and brings up the buffer selector.

  (defadvice evil-window-vsplit (after activate compile)
    (counsel-switch-buffer))
  (defadvice evil-window-split (after activate compile)
    (counsel-switch-buffer))

PGTK neo2 fix

  (put 'none 'modifier-value 0)
  (setq x-hyper-keysym 'none)