You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
3.1 KiB
EmacsLisp

;;; $DOOMDIR/penguin/lang.el -*- lexical-binding: t; -*-
(require 'impatient-mode)
;; Indenting, formatting, etc
;; Universal (all langs)
;; C/C++
(c-add-style "penguin"
'("stroustrup"
(c-offsets-alist
(innamespace . -)
(inline-open . 0)
(inher-cont . c-lineup-multi-inher)
(arglist-cont-nonempty . +)
(template-args-cont . +))))
(defun penguin-make-hook()
(setq +format-with-lsp nil)
(map!
:leader
:prefix "p"
:desc "Compile project" :n "c" #'helm-make-projectile)
(map!
:leader
:prefix "c"
:desc "Compile project" :n "c" #'helm-make-projectile)
(map!
:leader
:prefix "c"
:desc "List project errors" :n "x" #'lsp-treemacs-errors-list))
(add-hook 'makefile-mode-hook 'penguin-make-hook)
(defun penguin-c-hook()
(setq +format-with-lsp nil)
(map!
:leader
:prefix "p"
:desc "Compile project" :n "c" #'helm-make-projectile)
(map!
:leader
:prefix "c"
:desc "Compile project" :n "c" #'helm-make-projectile)
(map!
:leader
:prefix "c"
:desc "List project errors" :n "x" #'lsp-treemacs-errors-list)
(c-set-style "penguin")
(c-set-offset 'case-label '+)
(c-set-offset 'arglist-intro '+)
(setq lsp-headerline-breadcrumb-enable 't))
(add-hook 'c-mode-hook 'penguin-c-hook)
(add-hook 'c++-mode-hook 'penguin-c-hook)
(add-hook 'after-change-major-mode-hook
(lambda ()
(modify-syntax-entry ?_ "w")))
(defun apply-lang-settings-to-open-buffers ()
"Apply C++ mode settings to open buffers."
(interactive)
(dolist (buffer (buffer-list))
(with-current-buffer buffer
(when (or (eq major-mode 'c-mode) (eq major-mode 'c++-mode))
(penguin-c-hook)))))
(add-hook! 'doom-after-reload-hook #'apply-lang-settings-to-open-buffers)
;; Markdown
(add-hook 'text-mode-hook
#'(lambda ()
(setq indent-tabs-mode nil)
(setq tab-width 4)))
(defun markdown-html (buffer)
(princ (with-current-buffer buffer
(format "<!DOCTYPE html><html><title>Impatient Markdown</title><xmp theme=\"united\" style=\"display:none;\"> %s </xmp><script src=\"http://ndossougbe.github.io/strapdown/dist/strapdown.js\"></script></html>" (buffer-substring-no-properties (point-min) (point-max))))
(current-buffer)))
(imp-set-user-filter 'markdown-html)
;; Rust
(after! rustic
(setq lsp-rust-server 'rust-analyzer))
(setq lsp-rust-analyzer-cargo-watch-command "clippy")
(setq lsp-eldoc-render-all t)
(setq lsp-idle-delay 0.6)
(setq lsp-rust-analyzer-server-display-inlay-hints t)
(setq lsp-rust-analyzer-display-lifetime-elision-hints-enable "skip_trivial")
(setq lsp-rust-analyzer-display-chaining-hints t)
(setq lsp-rust-analyzer-display-lifetime-elision-hints-use-parameter-names nil)
(setq lsp-rust-analyzer-display-closure-return-type-hints t)
(setq lsp-rust-analyzer-display-parameter-hints nil)
(setq lsp-rust-analyzer-display-reborrow-hints nil)
(add-hook 'python-mode-hook
(lambda ()
(setq +format-with-lsp nil)
(setq indent-tabs-mode t)
(setq tab-width 4)
(setq py-indent-tabs-mode t)
(setq python-indent 4)
(setq python-indent-offset 4)
(add-to-list 'write-file-functions 'delete-trailing-whitespace))
(tabify (point-min) (point-max)))