emacs: Replace regexes with rx macro for readability
This commit is contained in:
parent
a7cdc18134
commit
0a6dc9ec8d
1 changed files with 38 additions and 33 deletions
|
@ -716,7 +716,7 @@ Use =corfu= with =dabbrev= (included with emacs)
|
|||
("M-/" 'dabbrev-completion)
|
||||
("C-M-/" 'dabbrev-expand)
|
||||
:custom
|
||||
(dabbrev-ignored-buffer-regexps '("\\.\\(?:pdf\\|jpe?g\\|png\\)\\'")))
|
||||
(dabbrev-ignored-buffer-regexps '((rx ".(?:pdf|jpe?g|png)" eos))))
|
||||
#+end_src
|
||||
|
||||
*** Misc
|
||||
|
@ -1049,17 +1049,13 @@ Automatically use the =<lang>-ts-mode= when it is available
|
|||
(fset #'json--log-event #'ignore) ;; Performance boost by not logging every event
|
||||
(add-to-list 'eglot-server-programs
|
||||
'((toml-mode toml-ts-mode conf-toml-mode) . ("taplo" "lsp" "stdio")))
|
||||
;; (add-to-list 'eglot-server-programs
|
||||
;; `((elixir-mode elixir-ts-mode heex-ts-mode) .
|
||||
;; ,(eglot-alternatives '(("nextls" "--stdio=true"
|
||||
;; :initializationOptions (:experimental (:completions (:enable t))))
|
||||
;; "elixir-ls"))))
|
||||
;;
|
||||
(add-to-list 'eglot-server-programs
|
||||
`((elixir-ts-mode heex-ts-mode) .
|
||||
,(eglot-alternatives '("lexical" "elixir-ls"))))
|
||||
(add-to-list 'eglot-server-programs
|
||||
'(dhall-mode . ("dhall-lsp-server")))
|
||||
(add-to-list 'eglot-server-programs
|
||||
'((html-mode mhtml-mode) . ("superhtml" "lsp")))
|
||||
(add-to-list 'eglot-stay-out-of 'flymake)
|
||||
(setq eglot-autoshutdown t
|
||||
eldoc-echo-area-use-multiline-p 0.1)
|
||||
|
@ -1132,8 +1128,8 @@ Indent 2 spaces
|
|||
(use-package js2-mode
|
||||
:after eglot
|
||||
:mode
|
||||
("\\.mjs\\'" . js2-mode)
|
||||
("\\.jsx?\\'" . js2-jsx-mode)
|
||||
((rx ".mjs" eos) . js2-mode)
|
||||
((rx ".jsx?" eos) . js2-jsx-mode)
|
||||
:hook
|
||||
(js2-mode . eglot-ensure)
|
||||
(js2-jsx-mode . eglot-ensure))
|
||||
|
@ -1154,7 +1150,7 @@ TypeScript stuff
|
|||
(use-package typescript-mode
|
||||
:after eglot
|
||||
:mode
|
||||
("\\.tsx?\\'" . typescript-mode)
|
||||
((rx ".tsx?" eos) . typescript-mode)
|
||||
:hook (typescript-mode . eglot-ensure))
|
||||
#+end_src
|
||||
|
||||
|
@ -1170,7 +1166,7 @@ Prefer local packages from =node_modules= to global ones
|
|||
|
||||
#+begin_src emacs-lisp
|
||||
(use-package web-mode
|
||||
:mode "\\.svelte\\'"
|
||||
:mode (rx ".svelte" eos)
|
||||
:after eglot
|
||||
:config
|
||||
(setq web-mode-markup-indent-offset 2
|
||||
|
@ -1181,12 +1177,12 @@ Prefer local packages from =node_modules= to global ones
|
|||
web-mode-enable-current-element-highlight t
|
||||
web-mode-enable-current-column-highlight t)
|
||||
|
||||
(add-to-list 'web-mode-engines-alist '(("elixir" . "\\.html.heex\\'")
|
||||
("jinja2" . "\\.jinja2\\'")
|
||||
("python" . "\\.pt\\'")
|
||||
("svelte" . "\\.svelte\\'")))
|
||||
(add-to-list 'web-mode-engines-alist '(("elixir" . (rx ".html.heex" eos))
|
||||
("jinja2" . (rx ".jinja2" eos))
|
||||
("python" . (rx ".pt" eos)) ; Chameleon templates
|
||||
("svelte" . (rx ".svelte" eos))))
|
||||
:hook
|
||||
((html-mode css-mode web-mode) . eglot-ensure))
|
||||
((mhtml-mode css-mode web-mode) . eglot-ensure))
|
||||
#+end_src
|
||||
|
||||
*** Markdown
|
||||
|
@ -1197,9 +1193,9 @@ Prefer local packages from =node_modules= to global ones
|
|||
(use-package markdown-mode
|
||||
:after eglot
|
||||
:mode
|
||||
(("README\\.md\\'" . gfm-mode)
|
||||
("\\.md\\'" . markdown-mode)
|
||||
("\\.markdown\\'" . markdown-mode))
|
||||
(((rx "README.md" eos) . gfm-mode)
|
||||
((rx ".md" eos) . markdown-mode)
|
||||
((rx ".markdown" eos) . markdown-mode))
|
||||
:init
|
||||
(setq markdown-command "multimarkdown")
|
||||
:hook
|
||||
|
@ -1234,7 +1230,7 @@ Add support for Elixir with [[https://github.com/elixir-editors/emacs-elixir][el
|
|||
:after eglot
|
||||
:hook ((elixir-mode . eglot-ensure))
|
||||
:config
|
||||
(add-to-list 'auto-mode-alist '("\\.[hl]eex\\'" . elixir-mode)))
|
||||
(add-to-list 'auto-mode-alist '((rx ".[hl]eex") . elixir-mode)))
|
||||
#+end_src
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
|
@ -1256,9 +1252,9 @@ Add a [[https://github.com/ayrat555/mix.el][mix]] minor mode to call =mix= tasks
|
|||
#+begin_src emacs-lisp
|
||||
(use-package erlang
|
||||
:mode
|
||||
("\\.P\\'" . erlang-mode)
|
||||
("\\.E\\'" . erlang-mode)
|
||||
("\\.S\\'" . erlang-mode)
|
||||
((rx ".P" eos) . erlang-mode)
|
||||
((rx ".E" eos) . erlang-mode)
|
||||
((rx ".S" eos) . erlang-mode)
|
||||
:config
|
||||
(require 'erlang-start))
|
||||
#+end_src
|
||||
|
@ -1332,7 +1328,7 @@ Support for TOML files with [[https://github.com/dryman/toml-mode.el][toml-mode]
|
|||
|
||||
#+begin_src emacs-lisp :tangle no
|
||||
(use-package toml-mode
|
||||
:mode ("\\.toml\\'" . conf-toml-mode))
|
||||
:mode ((rx ".toml" eos) . conf-toml-mode))
|
||||
#+end_src
|
||||
|
||||
*** Docker
|
||||
|
@ -1417,7 +1413,7 @@ Add QML mode
|
|||
|
||||
#+begin_src emacs-lisp
|
||||
(use-package qml-mode
|
||||
:mode "\\.qml\\'")
|
||||
:mode (rx ".qml" eos))
|
||||
#+end_src
|
||||
|
||||
Enable and configure =auto-insert-mode= for Horus projects
|
||||
|
@ -1429,7 +1425,7 @@ Enable and configure =auto-insert-mode= for Horus projects
|
|||
|
||||
(when (file-executable-p my/generate-cpp-file-executable)
|
||||
(define-auto-insert
|
||||
"\\.[ch]pp\\'"
|
||||
(rx ".[ch]pp" eos)
|
||||
(lambda nil (call-process my/generate-cpp-file-executable nil t nil buffer-file-name))))
|
||||
|
||||
|
||||
|
@ -1450,7 +1446,7 @@ Add [[https://github.com/NixOS/nix-mode][nix-mode]]
|
|||
#+begin_src emacs-lisp
|
||||
(use-package nix-mode
|
||||
:after eglot
|
||||
:mode "\\.nix\\'"
|
||||
:mode (rx ".nix" eos)
|
||||
:hook (nix-mode . eglot-ensure))
|
||||
#+end_src
|
||||
|
||||
|
@ -1476,7 +1472,7 @@ Common Lisp does not use =lsp-mode=, but has it's own environment: [[https://git
|
|||
:config
|
||||
(slime-setup '(slime-fancy slime-quicklisp slime-asdf))
|
||||
:mode
|
||||
(("\\.cl\\'" . lisp-mode))
|
||||
(((rx ".cl" eos) . lisp-mode))
|
||||
:hook
|
||||
(lisp-mode . (lambda () (slime-mode t)))
|
||||
(inferior-lisp-mode . (lambda () (inferior-slime-mode t))))
|
||||
|
@ -1487,7 +1483,7 @@ Common Lisp does not use =lsp-mode=, but has it's own environment: [[https://git
|
|||
#+begin_src emacs-lisp
|
||||
(use-package sly
|
||||
:mode
|
||||
(("\\.cl\\'" . lisp-mode))
|
||||
(((rx ".cl" eos) . lisp-mode))
|
||||
:config
|
||||
(setq sly-lisp-implementations
|
||||
'((sbcl ("sbcl") :coding-system utf-8-unix))
|
||||
|
@ -1575,7 +1571,7 @@ It's better than nothing.
|
|||
(use-package feature-mode
|
||||
:config
|
||||
(setq feature-use-docker-compose nil)
|
||||
:mode "\\.feature\\'")
|
||||
:mode (rx ".feature" eos))
|
||||
#+end_src
|
||||
|
||||
*** Protobuf
|
||||
|
@ -1636,7 +1632,7 @@ Dhall is a programmable configuration language that you can think of as: JSON +
|
|||
|
||||
#+begin_src emacs-lisp
|
||||
(use-package dhall-mode
|
||||
:mode "\\.dhall\\'")
|
||||
:mode (rx ".dhall" eos))
|
||||
#+end_src
|
||||
|
||||
*** nushell
|
||||
|
@ -1693,7 +1689,16 @@ Gleam has an official emacs mode: [[https://github.com/gleam-lang/gleam-mode][gl
|
|||
|
||||
#+begin_src emacs-lisp
|
||||
(use-package gleam-ts-mode
|
||||
:mode (rx ".gleam" eos))
|
||||
:mode (rx ".gleam" eos)
|
||||
:hook (gleam-ts-mode . eglot-ensure))
|
||||
#+end_src
|
||||
|
||||
Configure eglot to use the Gleam LSP server
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(with-eval-after-load 'eglot
|
||||
(add-to-list 'eglot-server-programs
|
||||
'(gleam-ts-mode . ("gleam" "lsp"))))
|
||||
#+end_src
|
||||
|
||||
* Org
|
||||
|
@ -1761,7 +1766,7 @@ Configuration
|
|||
|
||||
#+name: org-config
|
||||
#+begin_src emacs-lisp :tangle no
|
||||
(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
|
||||
(add-to-list 'auto-mode-alist '((rx ".org" eos) . org-mode))
|
||||
(dolist (face '((org-level-1 . 1.2)
|
||||
(org-level-2 . 1.1)
|
||||
(org-level-3 . 1.05)
|
||||
|
|
Loading…
Reference in a new issue