Switch to DOOM Emacs

This commit is contained in:
2026-04-27 20:55:31 -04:00
parent 6ef95200b7
commit f2653e0cf3
10 changed files with 439 additions and 1571 deletions
+178
View File
@@ -0,0 +1,178 @@
;;; $DOOMDIR/config.el -*- lexical-binding: t; -*-
;; Place your private configuration here! Remember, you do not need to run 'doom
;; sync' after modifying this file!
;; Some functionality uses this to identify you, e.g. GPG configuration, email
;; clients, file templates and snippets. It is optional.
;; (setq user-full-name "John Doe"
;; user-mail-address "john@doe.com")
;; Doom exposes five (optional) variables for controlling fonts in Doom:
;;
;; - `doom-font' -- the primary font to use
;; - `doom-variable-pitch-font' -- a non-monospace font (where applicable)
;; - `doom-big-font' -- used for `doom-big-font-mode'; use this for
;; presentations or streaming.
;; - `doom-symbol-font' -- for symbols
;; - `doom-serif-font' -- for the `fixed-pitch-serif' face
;;
;; See 'C-h v doom-font' for documentation and more examples of what they
;; accept. For example:
;;
(setq doom-font (font-spec :family "Iosevka" :size 15 :weight 'semi-light)
doom-variable-pitch-font (font-spec :family "Iosevka" :size 13))
;;
;; If you or Emacs can't find your font, use 'M-x describe-font' to look them
;; up, `M-x eval-region' to execute elisp code, and 'M-x doom/reload-font' to
;; refresh your font settings. If Emacs still can't find your font, it likely
;; wasn't installed correctly. Font issues are rarely Doom issues!
;; There are two ways to load a theme. Both assume the theme is installed and
;; available. You can either set `doom-theme' or manually load a theme with the
;; `load-theme' function. This is the default:
(setq doom-theme 'gruber-darker)
;; This determines the style of line numbers in effect. If set to `nil', line
;; numbers are disabled. For relative line numbers, set this to `relative'.
(setq display-line-numbers-type 'relative)
;; If you use `org' and don't want your org files in the default location below,
;; change `org-directory'. It must be set before org loads!
(setq org-directory "~/org/")
;; Whenever you reconfigure a package, make sure to wrap your config in an
;; `with-eval-after-load' block, otherwise Doom's defaults may override your
;; settings. E.g.
;;
;; (with-eval-after-load 'PACKAGE
;; (setq x y))
;;
;; The exceptions to this rule:
;;
;; - Setting file/directory variables (like `org-directory')
;; - Setting variables which explicitly tell you to set them before their
;; package is loaded (see 'C-h v VARIABLE' to look them up).
;; - Setting doom variables (which start with 'doom-' or '+').
;;
;; Here are some additional functions/macros that will help you configure Doom.
;;
;; - `load!' for loading external *.el files relative to this one
;; - `add-load-path!' for adding directories to the `load-path', relative to
;; this file. Emacs searches the `load-path' when you load packages with
;; `require' or `use-package'.
;; - `map!' for binding new keys
;;
;; To get information about any of these functions/macros, move the cursor over
;; the highlighted symbol at press 'K' (non-evil users must press 'C-c c k').
;; This will open documentation for it, including demos of how they are used.
;; Alternatively, use `C-h o' to look up a symbol (functions, variables, faces,
;; etc).
;;
;; You can also try 'gd' (or 'C-c c d') to jump to their definition and see how
;; they are implemented.
(defun toggle-window-split ()
(interactive)
(if (= (count-windows) 2)
(let* ((this-win-buffer (window-buffer))
(next-win-buffer (window-buffer (next-window)))
(this-win-edges (window-edges (selected-window)))
(next-win-edges (window-edges (next-window)))
(this-win-2nd (not (and (<= (car this-win-edges)
(car next-win-edges))
(<= (cadr this-win-edges)
(cadr next-win-edges)))))
(splitter
(if (= (car this-win-edges)
(car (window-edges (next-window))))
'split-window-horizontally
'split-window-vertically)))
(delete-other-windows)
(let ((first-win (selected-window)))
(funcall splitter)
(if this-win-2nd (other-window 1))
(set-window-buffer (selected-window) this-win-buffer)
(set-window-buffer (next-window) next-win-buffer)
(select-window first-win)
(if this-win-2nd (other-window 1))))))
(global-set-key (kbd "C-t") 'toggle-window-split)
(setq compile-command "")
;; Comment
(map! "C-;" 'comment-dwim-2)
;; Duplicate line
(defun duplicate-line ()
"Duplicate current line"
(interactive)
(let ((column (- (point) (pos-bol)))
(line (let ((s (thing-at-point 'line t)))
(if s (string-remove-suffix "\n" s) ""))))
(move-end-of-line 1)
(newline)
(insert line)
(move-beginning-of-line 1)
(forward-char column)))
(global-set-key (kbd "C-,") 'duplicate-line)
;; Magit
(map! :leader "m s" 'magit-status)
;; Multi cursors
(map! "C-S-n" 'mc/mark-next-like-this)
(map! "C-S-p" 'mc/mark-previous-like-this)
(setq tramp-auto-save-directory "/tmp")
;; Move text
(map! "M-p" 'move-text-up)
(map! "M-n" 'move-text-down)
;; LSP
(global-set-key (kbd "M-;") 'xref-find-definitions)
(use-package lsp-mode
:hook ((c-mode
c++-mode
python-mode
rust-mode
tsx-ts-mode
typescript-ts-mode
))
:custom
(lsp-keymap-prefix "s-i")
(lsp-keep-workspace-alive nil)
(lsp-enable-xref t)
(lsp-enable-on-type-formatting nil)
)
(setq gc-cons-threshold (* 100 1024 1024)
read-process-output-max (* 1024 1024)
treemacs-space-between-root-nodes nil
company-idle-delay 0.5
company-minimum-prefix-length 1
lsp-idle-delay 0.1)
(with-eval-after-load 'lsp-mode
(add-hook 'lsp-mode-hook #'lsp-enable-which-key-integration)
(yas-global-mode))
;; Dired
;; (setq dired-omit-files
;; (concat dired-omit-files "\\|^\\..+$"))
(setq-default dired-dwim-target t)
(setq dired-listing-switches "-alh")
;; Tree sitter
(after! treesit
(setq treesit-language-source-alist
'((typescript "https://github.com/tree-sitter/tree-sitter-typescript" "master" "typescript/src" nil nil)
(tsx "https://github.com/tree-sitter/tree-sitter-typescript" "master" "tsx/src" nil nil))))
+199
View File
@@ -0,0 +1,199 @@
;;; init.el -*- lexical-binding: t; -*-
;; This file controls what Doom modules are enabled and what order they load
;; in. Remember to run 'doom sync' after modifying it!
;; NOTE: Press 'SPC h d h' (or 'C-h d h' for non-vim users) to access Doom's
;; documentation. There you'll find a link to Doom's Module Index where all of
;; our modules are listed, including what flags they support.
;; NOTE: Move your cursor over a module's name (or its flags) and press 'K' (or
;; 'C-c c k' for non-vim users) to view its documentation. This works on flags
;; as well (those symbols that start with a plus).
;;
;; Alternatively, press 'gd' (or 'C-c c d') on a module to browse its
;; directory (for easy access to its source code).
(doom! :input
;;bidi ; (tfel ot) thgir etirw uoy gnipleh
;;chinese
;;japanese
;;layout ; auie,ctsrnm is the superior home row
:completion
company ; the ultimate code completion backend
;;(corfu +orderless) ; complete with cap(f), cape and a flying feather!
;;helm ; the *other* search engine for love and life
ido ; the other *other* search engine...
;;ivy ; a search engine for love and life
;;vertico ; the search engine of the future
:ui
;;deft ; notational velocity for Emacs
doom ; what makes DOOM look the way it does
dashboard ; a nifty splash screen for Emacs
;;doom-quit ; DOOM quit-message prompts when you quit Emacs
;;(emoji +unicode) ; 🙂
hl-todo ; highlight TODO/FIXME/NOTE/DEPRECATED/HACK/REVIEW
;;indent-guides ; highlighted indent columns
;;ligatures ; ligatures and symbols to make your code pretty again
minimap ; show a map of the code on the side
modeline ; snazzy, Atom-inspired modeline, plus API
;;nav-flash ; blink cursor line after big motions
neotree ; a project drawer, like NERDTree for vim
ophints ; highlight the region an operation acts on
(popup +defaults) ; tame sudden yet inevitable temporary windows
;;smooth-scroll ; So smooth you won't believe it's not butter
;;tabs ; a tab bar for Emacs
;;treemacs ; a project drawer, like neotree but cooler
;;unicode ; extended unicode support for various languages
(vc-gutter +pretty) ; vcs diff in the fringe
vi-tilde-fringe ; fringe tildes to mark beyond EOB
;;window-select ; visually switch windows
workspaces ; tab emulation, persistence & separate workspaces
;;zen ; distraction-free coding or writing
:editor
;; (evil +everywhere); come to the dark side, we have cookies
file-templates ; auto-snippets for empty files
fold ; (nigh) universal code folding
(format +onsave) ; automated prettiness
;;god ; run Emacs commands without modifier keys
;;lispy ; vim for lisp, for people who don't like vim
multiple-cursors ; editing in many places at once
;;objed ; text object editing for the innocent
;;parinfer ; turn lisp into python, sort of
;;rotate-text ; cycle region at point between text candidates
snippets ; my elves. They type so I don't have to
(whitespace +guess +trim) ; a butler for your whitespace
;;word-wrap ; soft wrapping with language-aware indent
:emacs
;;dired ; making dired pretty [functional]
electric ; smarter, keyword-based electric-indent
;;eww ; the internet is gross
;;ibuffer ; interactive buffer management
tramp ; remote files at your arthritic fingertips
undo ; persistent, smarter undo for your inevitable mistakes
vc ; version-control and Emacs, sitting in a tree
:term
;;eshell ; the elisp shell that works everywhere
;;shell ; simple shell REPL for Emacs
;;term ; basic terminal emulator for Emacs
;;vterm ; the best terminal emulation in Emacs
:checkers
syntax ; tasing you for every semicolon you forget
;;(spell +flyspell) ; tasing you for misspelling mispelling
;;grammar ; tasing grammar mistake every you make
:tools
ansible
;;biblio ; Writes a PhD for you (citation needed)
;;collab ; buffers with friends
debugger ; stepping through code, to help you add bugs
;;direnv
docker
editorconfig ; let someone else argue about tabs vs spaces
;;ein ; tame Jupyter notebooks with emacs
(eval +overlay) ; run code, run (also, repls)
lookup ; navigate your code and its documentation
;;llm ; when I said you needed friends, I didn't mean...
(lsp +eglot) ; M-x vscode
magit ; a git porcelain for Emacs
make ; run make tasks from Emacs
;;pass ; password manager for nerds
;;pdf ; pdf enhancements
terraform ; infrastructure as code
tmux ; an API for interacting with tmux
tree-sitter ; syntax and parsing, sitting in a tree...
upload ; map local to remote projects via ssh/ftp
:os
(:if (featurep :system 'macos) macos) ; improve compatibility with macOS
;;tty ; improve the terminal Emacs experience
:lang
;;ada ; In strong typing we (blindly) trust
;;(agda +local) ; types of types of types of types...
;;beancount ; mind the GAAP
(cc +lsp) ; C > C++ == 1
;;clojure ; java with a lisp
;;common-lisp ; if you've seen one lisp, you've seen them all
;;coq ; proofs-as-programs
;;crystal ; ruby at the speed of c
;;csharp ; unity, .NET, and mono shenanigans
data ; config/data formats
;;(dart +flutter) ; paint ui and not much else
;;dhall
;;elixir ; erlang done right
;;elm ; care for a cup of TEA?
emacs-lisp ; drown in parentheses
;;erlang ; an elegant language for a more civilized age
;;ess ; emacs speaks statistics
;;factor
;;faust ; dsp, but you get to keep your soul
;;fortran ; in FORTRAN, GOD is REAL (unless declared INTEGER)
;;fsharp ; ML stands for Microsoft's Language
;;fstar ; (dependent) types and (monadic) effects and Z3
;;gdscript ; the language you waited for
(go +lsp) ; the hipster dialect
;;(graphql +lsp) ; Give queries a REST
;;(haskell +lsp) ; a language that's lazier than I am
;;hy ; readability of scheme w/ speed of python
;;idris ; a language you can depend on
json ; At least it ain't XML
;;janet ; Fun fact: Janet is me!
;;(java +lsp) ; the poster child for carpal tunnel syndrome
(javascript +lsp +tree-sitter) ; all(hope(abandon(ye(who(enter(here))))))
;;julia ; a better, faster MATLAB
;;kotlin ; a better, slicker Java(Script)
latex ; writing papers in Emacs has never been so fun
;;lean ; for folks with too much to prove
;;ledger ; be audit you can be
;;lua ; one-based indices? one-based indices
markdown ; writing docs for people to ignore
;;nim ; python + lisp at the speed of c
;;nix ; I hereby declare "nix geht mehr!"
;;ocaml ; an objective camel
;;odin ; C, minus its footguns
org ; organize your plain life in plain text
;;php ; perl's insecure younger brother
;;plantuml ; diagrams for confusing people more
graphviz ; diagrams for confusing yourself even more
;;purescript ; javascript, but functional
python ; beautiful is better than ugly
;;qt ; the 'cutest' gui framework ever
;;racket ; a DSL for DSLs
;;raku ; the artist formerly known as perl6
rest ; Emacs as a REST client
rst ; ReST in peace
(ruby) ; 1.step {|i| p "Ruby is #{i.even? ? 'love' : 'life'}"}
(rust +lsp) ; Fe2O3.unwrap().unwrap().unwrap().unwrap()
;;scala ; java, but good
;;(scheme +guile) ; a fully conniving family of lisps
sh ; she sells {ba,z,fi}sh shells on the C xor
;;sml
;;solidity ; do you need a blockchain? No.
;;swift ; who asked for emoji variables?
;;terra ; Earth and Moon in alignment for performance.
;;web ; the tubes
yaml ; JSON, but readable
;;zig ; C, but simpler
:email
;;(mu4e +org +gmail)
;;notmuch
;;(wanderlust +gmail)
:app
calendar
;;emms
everywhere ; *leave* Emacs!? You must be joking
irc ; how neckbeards socialize
;;(rss +org) ; emacs as an RSS reader
:config
;;literate
(default +bindings +smartparens))
+61
View File
@@ -0,0 +1,61 @@
;; -*- no-byte-compile: t; -*-
;;; $DOOMDIR/packages.el
;; To install a package:
;;
;; 1. Declare them here in a `package!' statement,
;; 2. Run 'doom sync' in the shell,
;; 3. Restart Emacs.
;;
;; Use 'C-h f package\!' to look up documentation for the `package!' macro.
;; To install SOME-PACKAGE from MELPA, ELPA or emacsmirror:
;; (package! some-package)
;; To install a package directly from a remote git repo, you must specify a
;; `:recipe'. You'll find documentation on what `:recipe' accepts here:
;; https://github.com/radian-software/straight.el#the-recipe-format
;; (package! another-package
;; :recipe (:host github :repo "username/repo"))
;; If the package you are trying to install does not contain a PACKAGENAME.el
;; file, or is located in a subdirectory of the repo, you'll need to specify
;; `:files' in the `:recipe':
;; (package! this-package
;; :recipe (:host github :repo "username/repo"
;; :files ("some-file.el" "src/lisp/*.el")))
;; If you'd like to disable a package included with Doom, you can do so here
;; with the `:disable' property:
;; (package! builtin-package :disable t)
;; You can override the recipe of a built in package without having to specify
;; all the properties for `:recipe'. These will inherit the rest of its recipe
;; from Doom or MELPA/ELPA/Emacsmirror:
;; (package! builtin-package :recipe (:nonrecursive t))
;; (package! builtin-package-2 :recipe (:repo "myfork/package"))
;; Specify a `:branch' to install a package from a particular branch or tag.
;; This is required for some packages whose default branch isn't 'master' (which
;; our package manager can't deal with; see radian-software/straight.el#279)
;; (package! builtin-package :recipe (:branch "develop"))
;; Use `:pin' to specify a particular commit to install.
;; (package! builtin-package :pin "1a2b3c4d5e")
;; Doom's packages are pinned to a specific commit and updated from release to
;; release. The `unpin!' macro allows you to unpin single packages...
;; (unpin! pinned-package)
;; ...or multiple packages
;; (unpin! pinned-package another-pinned-package)
;; ...Or *all* packages (NOT RECOMMENDED; will likely break things)
;; (unpin! t)
(package! gruber-darker-theme)
(package! comment-dwim-2)
(package! move-text)
(package! lsp-mode)
(package! lsp-treemacs)
(package! which-key)
-514
View File
@@ -1,514 +0,0 @@
(setq custom-file "~/.emacs.custom.el")
(package-initialize)
(add-to-list 'load-path "~/.emacs.local/")
(load "~/.emacs.rc/rc.el")
(load "~/.emacs.rc/misc-rc.el")
;;; Appearance
(add-to-list 'default-frame-alist `(font . "Iosevka-12"))
(tool-bar-mode 0)
(menu-bar-mode 0)
(scroll-bar-mode 0)
(column-number-mode 1)
(show-paren-mode 1)
(rc/require-theme 'gruber-darker)
;; (rc/require-theme 'zenburn)
;; (load-theme 'adwaita t)
(rc/require 'all-the-icons 'all-the-icons-dired)
(eval-after-load 'zenburn
(set-face-attribute 'line-number nil :inherit 'default))
(defun toggle-window-split ()
(interactive)
(if (= (count-windows) 2)
(let* ((this-win-buffer (window-buffer))
(next-win-buffer (window-buffer (next-window)))
(this-win-edges (window-edges (selected-window)))
(next-win-edges (window-edges (next-window)))
(this-win-2nd (not (and (<= (car this-win-edges)
(car next-win-edges))
(<= (cadr this-win-edges)
(cadr next-win-edges)))))
(splitter
(if (= (car this-win-edges)
(car (window-edges (next-window))))
'split-window-horizontally
'split-window-vertically)))
(delete-other-windows)
(let ((first-win (selected-window)))
(funcall splitter)
(if this-win-2nd (other-window 1))
(set-window-buffer (selected-window) this-win-buffer)
(set-window-buffer (next-window) next-win-buffer)
(select-window first-win)
(if this-win-2nd (other-window 1))))))
(global-set-key (kbd "C-t") 'toggle-window-split)
(global-set-key (kbd "C-<tab>") 'next-window-any-frame)
(global-set-key (kbd "C-<iso-lefttab>") 'previous-window-any-frame)
;;; ido
(rc/require 'smex 'ido-completing-read+)
(require 'ido-completing-read+)
(ido-mode 1)
(ido-everywhere 1)
(ido-ubiquitous-mode 1)
(setq ido-auto-merge-work-directories-length -1)
(global-set-key (kbd "M-x") 'smex)
(global-set-key (kbd "C-c C-c M-x") 'execute-extended-command)
(setq compile-command "")
;;; comment
(rc/require 'comment-dwim-2)
(global-set-key (kbd "C-;") 'comment-dwim-2)
;;; c-mode
(setq-default c-basic-offset 4
c-default-style '((java-mode . "java")
(awk-mode . "awk")
(other . "bsd")))
(add-hook 'c-mode-hook (lambda ()
(interactive)
(c-toggle-comment-style -1)))
;;; Paredit
(rc/require 'paredit)
(defun rc/turn-on-paredit ()
(interactive)
(paredit-mode 1))
(add-hook 'emacs-lisp-mode-hook 'rc/turn-on-paredit)
(add-hook 'clojure-mode-hook 'rc/turn-on-paredit)
(add-hook 'lisp-mode-hook 'rc/turn-on-paredit)
(add-hook 'common-lisp-mode-hook 'rc/turn-on-paredit)
(add-hook 'scheme-mode-hook 'rc/turn-on-paredit)
(add-hook 'racket-mode-hook 'rc/turn-on-paredit)
;;; Emacs lisp
(add-hook 'emacs-lisp-mode-hook
'(lambda ()
(local-set-key (kbd "C-c C-j")
(quote eval-print-last-sexp))))
(add-to-list 'auto-mode-alist '("Cask" . emacs-lisp-mode))
;;; uxntal-mode
(rc/require 'uxntal-mode)
;;; Haskell mode
(rc/require 'haskell-mode)
(setq haskell-process-type 'cabal-new-repl)
(setq haskell-process-log t)
(add-hook 'haskell-mode-hook 'haskell-indent-mode)
(add-hook 'haskell-mode-hook 'interactive-haskell-mode)
(add-hook 'haskell-mode-hook 'haskell-doc-mode)
(require 'fasm-mode)
(add-to-list 'auto-mode-alist '("\\.asm\\'" . fasm-mode))
(require 'llvm-mode)
(add-to-list 'auto-mode-alist '("\\.ll\\'" . llvm-mode))
(require 'simpc-mode)
;; (add-to-list 'auto-mode-alist '("\\.[hc]\\(pp\\)?\\'" . simpc-mode))
(setq path-to-ctags "/usr/bin/ctags")
(defun create-tags (dir-name)
"Create tags file."
(interactive "Directory: ")
(shell-command
(format "%s -f TAGS -e -R %s" path-to-ctags (directory-file-name dir-name)))
)
(global-set-key (kbd "M-;") 'xref-find-definitions)
(rc/require 'ess)
(rc/require 'polymode)
(rc/require 'poly-R)
;;; Whitespace mode
(defun rc/set-up-whitespace-handling ()
(interactive)
(whitespace-mode 0)
(add-to-list 'write-file-functions 'delete-trailing-whitespace))
(add-hook 'tuareg-mode-hook 'rc/set-up-whitespace-handling)
(add-hook 'c++-mode-hook 'rc/set-up-whitespace-handling)
(add-hook 'c-mode-hook 'rc/set-up-whitespace-handling)
(add-hook 'simpc-mode-hook 'rc/set-up-whitespace-handling)
(add-hook 'emacs-lisp-mode 'rc/set-up-whitespace-handling)
(add-hook 'java-mode-hook 'rc/set-up-whitespace-handling)
(add-hook 'lua-mode-hook 'rc/set-up-whitespace-handling)
(add-hook 'rust-mode-hook 'rc/set-up-whitespace-handling)
(add-hook 'scala-mode-hook 'rc/set-up-whitespace-handling)
(add-hook 'markdown-mode-hook 'rc/set-up-whitespace-handling)
(add-hook 'haskell-mode-hook 'rc/set-up-whitespace-handling)
(add-hook 'python-mode-hook 'rc/set-up-whitespace-handling)
(add-hook 'erlang-mode-hook 'rc/set-up-whitespace-handling)
(add-hook 'asm-mode-hook 'rc/set-up-whitespace-handling)
(add-hook 'fasm-mode-hook 'rc/set-up-whitespace-handling)
(add-hook 'go-mode-hook 'rc/set-up-whitespace-handling)
(add-hook 'nim-mode-hook 'rc/set-up-whitespace-handling)
(add-hook 'yaml-mode-hook 'rc/set-up-whitespace-handling)
(add-hook 'porth-mode-hook 'rc/set-up-whitespace-handling)
;;; display-line-numbers-mode
(when (version<= "26.0.50" emacs-version)
(global-display-line-numbers-mode))
(setq display-line-numbers-type 'relative)
;;; magit
;; magit requres this lib, but it is not installed automatically on
;; Windows.
(rc/require 'cl-lib)
(rc/require 'magit)
(setq magit-auto-revert-mode nil)
(global-set-key (kbd "C-c m s") 'magit-status)
(global-set-key (kbd "C-c m l") 'magit-log)
;;; multiple cursors
(rc/require 'multiple-cursors)
(global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines)
(global-set-key (kbd "C-S-n") 'mc/mark-next-like-this)
(global-set-key (kbd "C-S-p") 'mc/mark-previous-like-this)
(global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this)
(global-set-key (kbd "C-!") 'mc/skip-to-next-like-this)
(global-set-key (kbd "C-:") 'mc/skip-to-previous-like-this)
;;; markdown
(rc/require 'markdown-mode 'impatient-mode 'simple-httpd)
(add-to-list 'auto-mode-alist '("\\.md\\'" . gfm-mode))
(setq markdown-command "pandoc -t html5")
(setq httpd-port 7070)
(setq httpd-host (system-name))
(defun github-markdown-filter (buffer)
(princ
(with-temp-buffer
(let ((tmp (buffer-name)))
(set-buffer buffer)
(set-buffer (markdown tmp))
(format "<!DOCTYPE html><html><title>Markdown preview</title><link rel=\"stylesheet\" href = \"https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/3.0.1/github-markdown.min.css\"/>
<body><article class=\"markdown-body\" style=\"box-sizing: border-box;min-width: 200px;max-width: 980px;margin: 0 auto;padding: 45px;\">%s</article></body></html>" (buffer-string))))
(current-buffer)))
(defun github-markdown-preview ()
"Preview markdown with github style"
(interactive)
(unless (process-status "httpd")
(httpd-start))
(impatient-mode)
(imp-set-user-filter 'github-markdown-filter)
(imp-visit-buffer))
;;; dired
(require 'dired-x)
(setq dired-omit-files
(concat dired-omit-files "\\|^\\..+$"))
(setq-default dired-dwim-target t)
(setq dired-listing-switches "-alh")
(setq dired-mouse-drag-files t)
(global-set-key (kbd "C-d") 'dired)
;;; helmn
(rc/require 'helm)
(global-set-key (kbd "C-c h t") 'helm-cmd-t)
;;; yasnippet
(rc/require 'yasnippet)
(require 'yasnippet)
(setq yas/triggers-in-field nil)
(setq yas-snippet-dirs '("~/.emacs.snippets/"))
(yas-global-mode 1)
;;; word-wrap
(defun rc/enable-word-wrap ()
(interactive)
(toggle-word-wrap 1))
(add-hook 'markdown-mode-hook 'rc/enable-word-wrap)
;;; nxml
(add-to-list 'auto-mode-alist '("\\.html\\'" . nxml-mode))
(add-to-list 'auto-mode-alist '("\\.xsd\\'" . nxml-mode))
(add-to-list 'auto-mode-alist '("\\.ant\\'" . nxml-mode))
;;; Makefile
(add-to-list 'auto-mode-alist '("\\make.config\\'" . makefile-mode))
;;; tramp
;;; http://stackoverflow.com/questions/13794433/how-to-disable-autosave-for-tramp-buffers-in-emacs
(setq tramp-auto-save-directory "/tmp")
;;; powershell
(rc/require 'powershell)
(add-to-list 'auto-mode-alist '("\\.ps1\\'" . powershell-mode))
(add-to-list 'auto-mode-alist '("\\.psm1\\'" . powershell-mode))
;;; eldoc mode
(defun rc/turn-on-eldoc-mode ()
(interactive)
(eldoc-mode 1))
(add-hook 'emacs-lisp-mode-hook 'rc/turn-on-eldoc-mode)
;;; Company
(rc/require 'company)
(require 'company)
(global-company-mode)
;; (add-hook 'tuareg-mode-hook
;; (lambda ()
;; (interactive)
;; (company-mode 0)))
;;; Typescript
(rc/require 'typescript-mode)
(add-to-list 'auto-mode-alist '("\\.ts\\'" . typescript-mode))
(add-to-list 'auto-mode-alist '("\\.tsx\\'" . tsx-ts-mode))
(use-package treesit
:mode (("\\.tsx\\'" . tsx-ts-mode)
("\\.js\\'" . typescript-ts-mode)
("\\.mjs\\'" . typescript-ts-mode)
("\\.mts\\'" . typescript-ts-mode)
("\\.cjs\\'" . typescript-ts-mode)
("\\.ts\\'" . typescript-ts-mode)
("\\.jsx\\'" . tsx-ts-mode)
("\\.json\\'" . json-ts-mode)
("\\.Dockerfile\\'" . dockerfile-ts-mode)
("\\.prisma\\'" . prisma-ts-mode)
;; More modes defined here...
)
:preface
(defun os/setup-install-grammars ()
"Install Tree-sitter grammars if they are absent."
(interactive)
(dolist (grammar
'((css . ("https://github.com/tree-sitter/tree-sitter-css" "v0.20.0"))
(bash "https://github.com/tree-sitter/tree-sitter-bash")
(html . ("https://github.com/tree-sitter/tree-sitter-html" "v0.20.1"))
(javascript . ("https://github.com/tree-sitter/tree-sitter-javascript" "v0.21.2" "src"))
(json . ("https://github.com/tree-sitter/tree-sitter-json" "v0.20.2"))
(python . ("https://github.com/tree-sitter/tree-sitter-python" "v0.20.4"))
(go "https://github.com/tree-sitter/tree-sitter-go" "v0.20.0")
(markdown "https://github.com/ikatyang/tree-sitter-markdown")
(make "https://github.com/alemuller/tree-sitter-make")
(elisp "https://github.com/Wilfred/tree-sitter-elisp")
(cmake "https://github.com/uyha/tree-sitter-cmake")
(toml "https://github.com/tree-sitter/tree-sitter-toml")
(tsx . ("https://github.com/tree-sitter/tree-sitter-typescript" "v0.20.3" "tsx/src"))
(typescript . ("https://github.com/tree-sitter/tree-sitter-typescript" "v0.20.3" "typescript/src"))
(yaml . ("https://github.com/ikatyang/tree-sitter-yaml" "v0.5.0"))
(prisma "https://github.com/victorhqc/tree-sitter-prisma")))
(add-to-list 'treesit-language-source-alist grammar)
;; Only install `grammar' if we don't already have it
;; installed. However, if you want to *update* a grammar then
;; this obviously prevents that from happening.
(unless (treesit-language-available-p (car grammar))
(treesit-install-language-grammar (car grammar)))))
;; Optional, but recommended. Tree-sitter enabled major modes are
;; distinct from their ordinary counterparts.
;;
;; You can remap major modes with `major-mode-remap-alist'. Note
;; that this does *not* extend to hooks! Make sure you migrate them
;; also
(dolist (mapping
'((css-mode . css-ts-mode)
(typescript-mode . typescript-ts-mode)
(js-mode . typescript-ts-mode)
(js2-mode . typescript-ts-mode)
(css-mode . css-ts-mode)
(json-mode . json-ts-mode)
(js-json-mode . json-ts-mode)))
(add-to-list 'major-mode-remap-alist mapping))
:config
(os/setup-install-grammars))
;;; Tide
(rc/require 'tide)
(defun rc/turn-on-tide-and-flycheck () ;Flycheck is a dependency of tide
(interactive)
(tide-setup)
(flycheck-mode 1))
(add-hook 'typescript-mode-hook 'rc/turn-on-tide-and-flycheck)
;;; Proof general
(rc/require 'proof-general)
(add-hook 'coq-mode-hook
'(lambda ()
(local-set-key (kbd "C-c C-q C-n")
(quote proof-assert-until-point-interactive))))
;;; LaTeX mode
(add-hook 'tex-mode-hook
(lambda ()
(interactive)
(add-to-list 'tex-verbatim-environments "code")))
(setq font-latex-fontify-sectioning 'color)
;;; Move Text
(rc/require 'move-text)
(global-set-key (kbd "M-p") 'move-text-up)
(global-set-key (kbd "M-n") 'move-text-down)
;;; Ebisp
(add-to-list 'auto-mode-alist '("\\.ebi\\'" . lisp-mode))
;;; Go
(rc/require 'go-mode)
;(add-to-list 'compilation-error-regexp-alist 'gotest)
;(add-to-list 'compilation-error-regexp-alist-alist '(gotest "^ \\(\\([^:\n]+\\):\\([0-9]+\\)\\)" 2 3 nil nil 1))
;(add-to-list 'compilation-error-regexp-alist 'gotraceback)
;(add-to-list 'compilation-error-regexp-alist-alist '(gotraceback "^\t\\(\\([^\n\t]+\\):\\([0-9]+\\)\\)\\( \\+0x[0-9a-f]+\\)?$" 2 3 nil (nil . 4) 1))
;;; OCaml
(rc/require 'tuareg)
;;; ASM
(defun my-asm-mode-hook ()
(local-unset-key (vector asm-comment-char))
(setq tab-always-indent (default-value 'tab-always-indent))
(setq comment-start "//"))
(add-hook 'asm-mode-hook #'my-asm-mode-hook)
;;; Clang format
(rc/require 'clang-format)
(global-set-key (kbd "C-o") 'clang-format-buffer)
;;; Lsp-mode
(rc/require 'lsp-mode
'lsp-treemacs
'helm-lsp
'projectile
'hydra
'flycheck
'company
'avy
'which-key
'helm-xref)
(which-key-mode)
(use-package lsp-mode
:ensure t
:hook ((c-mode
c++-mode
python-mode
tsx-ts-mode
typescript-ts-mode
))
:custom
(lsp-keymap-prefix "s-i")
(lsp-keep-workspace-alive nil)
(lsp-enable-xref t)
(lsp-enable-on-type-formatting nil)
)
;;; zoxide
(rc/require 'zoxide)
(add-hook 'dired-after-readin-hook 'zoxide-add)
(setq gc-cons-threshold (* 100 1024 1024)
read-process-output-max (* 1024 1024)
treemacs-space-between-root-nodes nil
company-idle-delay 0.5
company-minimum-prefix-length 1
lsp-idle-delay 0.1)
(with-eval-after-load 'lsp-mode
(add-hook 'lsp-mode-hook #'lsp-enable-which-key-integration)
(yas-global-mode))
;;; Packages that don't require configuration
(rc/require
'scala-mode
'd-mode
'yaml-mode
'glsl-mode
'lua-mode
'less-css-mode
'graphviz-dot-mode
'clojure-mode
'cmake-mode
'rust-mode
'csharp-mode
'nim-mode
'jinja2-mode
'purescript-mode
'nix-mode
'dockerfile-mode
'toml-mode
'nginx-mode
'kotlin-mode
'php-mode
'racket-mode
'qml-mode
'ag
'elpy
'typescript-mode
'rfc-mode
'sml-mode
)
(defun astyle-buffer (&optional justify)
(interactive)
(let ((saved-line-number (line-number-at-pos)))
(shell-command-on-region
(point-min)
(point-max)
"astyle --style=kr"
nil
t)
(goto-line saved-line-number)))
(add-hook 'simpc-mode-hook
(lambda ()
(interactive)
(setq-local fill-paragraph-function 'astyle-buffer)))
(require 'compile)
;; pascalik.pas(24,44) Error: Can't evaluate constant expression
compilation-error-regexp-alist-alist
(add-to-list 'compilation-error-regexp-alist
'("\\([a-zA-Z0-9\\.]+\\)(\\([0-9]+\\)\\(,\\([0-9]+\\)\\)?) \\(Warning:\\)?"
1 2 (4) (5)))
(load-file custom-file)
-480
View File
@@ -1,480 +0,0 @@
;;; fasm-mode.el --- Fasm major mode
;; Author: Fanael Linithien <fanael4@gmail.com>
;; URL: https://github.com/Fanael/fasm-mode
;; Version: 0.1.8
;; This file is NOT part of GNU Emacs.
;; Copyright (c) 2013, Fanael Linithien
;; All rights reserved.
;; Redistribution and use in source and binary forms, with or without
;; modification, are permitted provided that the following conditions are
;; met:
;; * Redistributions of source code must retain the above copyright
;; notice, this list of conditions and the following disclaimer.
;; * Redistributions in binary form must reproduce the above copyright
;; notice, this list of conditions and the following disclaimer in the
;; documentation and/or other materials provided with the distribution.
;; * Neither the name of the copyright holder(s) nor the names of any
;; contributors may be used to endorse or promote products derived from
;; this software without specific prior written permission.
;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
;; IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
;; TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
;; PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
;; OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
;; EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
;; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
;; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
;; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;;; Code:
(defvar fasm-mode-syntax-table
(let ((syntaxtable (make-syntax-table)))
(modify-syntax-entry ?_ "_" syntaxtable)
(modify-syntax-entry ?. "_" syntaxtable)
(modify-syntax-entry ?$ "_" syntaxtable)
(modify-syntax-entry ?@ "_" syntaxtable)
(modify-syntax-entry ?~ "_" syntaxtable)
(modify-syntax-entry ?? "_" syntaxtable)
(modify-syntax-entry ?! "_" syntaxtable)
(modify-syntax-entry ?= "." syntaxtable)
(modify-syntax-entry ?+ "." syntaxtable)
(modify-syntax-entry ?- "." syntaxtable)
(modify-syntax-entry ?* "." syntaxtable)
(modify-syntax-entry ?/ "." syntaxtable)
(modify-syntax-entry ?\\ "." syntaxtable)
(modify-syntax-entry ?\; "<" syntaxtable)
(modify-syntax-entry ?\n ">" syntaxtable)
(modify-syntax-entry ?\" "\"" syntaxtable)
(modify-syntax-entry ?\' "\"" syntaxtable)
syntaxtable)
"Syntax table for FASM mode.")
(defvar fasm-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "<return>") (lambda () (interactive) (insert ?\n)))
map)
"Local keymap for FASM mode.")
(defvar fasm-basic-offset 2
"Offset for FASM mode indentation.")
(eval-when-compile
(defun fasm--regexp-from-keywords (&rest keywords)
(regexp-opt keywords 'symbols)))
(defconst fasm-font-lock-keywords
`(;; Numbers
("\\_<[01]+b\\_>" . 'font-lock-constant-face)
("\\_<[0-9][0-9a-fA-F]*h\\_>" . 'font-lock-constant-face)
("\\_<\\(?:0x\\|\\$\\)[0-9a-fA-F]+\\_>" . 'font-lock-constant-face)
("\\_<[0-9]+\\(?:\\.[0-9]*\\)?\\(?:e[+-]?[0-9]+\\)?\\_>"
. 'font-lock-constant-face)
;; Types
(,(eval-when-compile
(fasm--regexp-from-keywords
"xx"
"xxxx"
"preserve"
"byte" "word" "dword" "fword" "pword" "qword" "tbyte" "tword"
"dqword" "xword" "qqword" "yword" "db" "rb" "dw" "du" "rw" "dd" "rd"
"df" "dp" "rf" "rp" "dq" "rq" "dt" "rt")) . 'font-lock-type-face)
;; Directives and operators
(,(eval-when-compile
(fasm--regexp-from-keywords
"labeling"
"mod" "rva" "plt" "align" "as" "at" "defined" "dup" "eq" "eqtype"
"from" "ptr" "relativeto" "used" "binary" "export" "fixups" "import"
"native" "static" "console" "dynamic" "efiboot" "linkinfo" "readable"
"resource" "writable" "shareable" "writeable" "efiruntime"
"executable" "linkremove" "discardable" "interpreter" "notpageable"
"if"
"end"
"tail_call"
"finish" ;; as end
"literal"
"address"
"branch"
"false?branch"
"err" "org" "data" "else" "heap" "load" "align" "break"
"entry" "extrn" "label" "stack" "store" "times" "while" "assert"
"format" "public" "repeat" "display" "section" "segment" "virtual"
"file")) . 'font-lock-keyword-face)
;; Preprocessor directives
(,(eval-when-compile
(fasm--regexp-from-keywords
"define" "include" "irp" "irps" "macro" "match" "purge" "rept"
"restore" "restruc" "struc" "common" "forward" "local" "reverse"
"equ" "fix")) . 'font-lock-preprocessor-face)
;; Registers
(,(eval-when-compile
(fasm--regexp-from-keywords
"al" "bl" "cl" "dl" "spl" "bpl" "sil" "dil" "r8b" "r9b" "r10b" "r11b"
"r12b" "r13b" "r14b" "r15b" "ah" "bh" "ch" "dh" "ax" "bx" "cx" "dx"
"sp" "bp" "si" "di" "r8w" "r9w" "r10w" "r11w" "r12w" "r13w" "r14w"
"r15w" "eax" "ebx" "ecx" "edx" "esp" "ebp" "esi" "edi" "r8d" "r9d"
"r10d" "r11d" "r12d" "r13d" "r14d" "r15d"
"rax" "rbx" "rcx" "rdx" "rsp" "rbp" "rsi" "rdi"
"r8" "r9" "r10" "r11" "r12" "r13" "r14" "r15"
;; "xax" "xbx" "xcx" "xdx" "xsp" "xbp" "xsi" "xdi"
;; "x8" "x9" "x10" "x11" "x12" "x13" "x14" "x15"
"rip" "es" "cs" "ss" "ds" "fs" "gs" "cr0" "cr2" "cr3" "cr4" "dr0"
"dr1" "dr2" "dr3" "st0" "st1" "st2" "st3" "st4" "st5" "st6" "st7"
"mm0" "mm1" "mm2" "mm3" "mm4" "mm5" "mm6" "mm7" "xmm0" "xmm1" "xmm2"
"xmm3" "xmm4" "xmm5" "xmm6" "xmm7" "xmm8" "xmm9" "xmm10" "xmm11"
"xmm12" "xmm13" "xmm14" "xmm15" "ymm0" "ymm1" "ymm2" "ymm3" "ymm4"
"ymm5" "ymm6" "ymm7" "ymm8" "ymm9" "ymm10" "ymm11" "ymm12" "ymm13"
"ymm14" "ymm15")) . 'font-lock-variable-name-face)
;; Instructions
(,(eval-when-compile
(fasm--regexp-from-keywords
"bt" "in" "ja" "jb" "jc" "je" "jg" "jl" "jo" "jp" "js" "jz" "or"
"aaa" "aad" "aam" "aas" "adc" "add" "and" "bsf" "bsr" "btc" "btr"
"bts" "cbw" "cdq" "clc" "cld" "cli" "cmc" "cmp" "cqo" "cwd" "daa"
"das" "dec" "div" "fld" "fst" "hlt" "inc" "ins" "int" "jae" "jbe"
"jge" "jle" "jmp" "jna" "jnb" "jnc" "jne" "jng" "jnl" "jno" "jnp"
"jns" "jnz" "jpe" "jpo" "lar" "lds" "lea" "les" "lfs" "lgs" "lsl"
"lss" "ltr" "mov" "mul" "neg" "nop" "not" "out" "pop" "por" "rcl"
"rcr" "rep" "ret" "rol" "ror" "rsm" "sal" "sar" "sbb" "shl" "shr"
"stc" "std" "sti" "str" "sub" "ud2" "xor" "adcx" "adox" "andn" "arpl"
"blci" "blcs" "blsi" "blsr" "bzhi" "call" "cdqe" "clac" "clgi" "clts"
"cmps" "cwde" "dppd" "dpps" "emms" "fabs" "fadd" "fbld" "fchs" "fcom"
"fcos" "fdiv" "feni" "fild" "fist" "fld1" "fldz" "fmul" "fnop" "fsin"
"fstp" "fsub" "ftst" "fxam" "fxch" "idiv" "imul" "insb" "insd" "insw"
"int1" "int3" "into" "invd" "iret" "jcxz" "jnae" "jnbe" "jnge" "jnle"
"lahf" "lgdt" "lidt" "lldt" "lmsw" "lock" "lods" "loop" "movd" "movq"
"movs" "mulx" "orpd" "orps" "outs" "pand" "pdep" "pext" "popa" "popd"
"popf" "popq" "popw" "push" "pxor" "repe" "repz" "retd" "retf" "retn"
"retq" "retw" "rorx" "sahf" "salc" "sarx" "scas" "seta" "setb" "setc"
"sete" "setg" "setl" "seto" "setp" "sets" "setz" "sgdt" "shld" "shlx"
"shrd" "shrx" "sidt" "sldt" "smsw" "stac" "stgi" "stos" "test" "verr"
"verw" "vpor" "wait" "xadd" "xchg" "xend" "xlat" "addpd" "addps"
"addsd" "addss" "andpd" "andps" "bextr" "blcic" "blsic" "bound"
"bswap" "cmova" "cmovb" "cmovc" "cmove" "cmovg" "cmovl" "cmovo"
"cmovp" "cmovs" "cmovz" "cmppd" "cmpps" "cmpsb" "cmpsd" "cmpsq"
"cmpss" "cmpsw" "cpuid" "crc32" "divpd" "divps" "divsd" "divss"
"enter" "extrq" "f2xm1" "faddp" "fbstp" "fclex" "fcomi" "fcomp"
"fdisi" "fdivp" "fdivr" "femms" "ffree" "fiadd" "ficom" "fidiv"
"fimul" "finit" "fistp" "fisub" "fldcw" "fldpi" "fmulp" "fneni"
"fprem" "fptan" "fsave" "fsqrt" "fstcw" "fstsw" "fsubp" "fsubr"
"fucom" "fwait" "fyl2x" "icebp" "iretd" "iretq" "iretw" "jecxz"
"jrcxz" "lddqu" "leave" "lodsb" "lodsd" "lodsq" "lodsw" "loopd"
"loope" "loopq" "loopw" "loopz" "lzcnt" "maxpd" "maxps" "maxsd"
"maxss" "minpd" "minps" "minsd" "minss" "movbe" "movsb" "movsd"
"movsq" "movss" "movsw" "movsx" "movzx" "mulpd" "mulps" "mulsd"
"mulss" "mwait" "outsb" "outsd" "outsw" "pabsb" "pabsd" "pabsw"
"paddb" "paddd" "paddq" "paddw" "pandn" "pause" "pavgb" "pavgw"
"pf2id" "pf2iw" "pfacc" "pfadd" "pfmax" "pfmin" "pfmul" "pfrcp"
"pfsub" "pi2fd" "pi2fw" "popad" "popaw" "popfd" "popfq" "popfw"
"pslld" "psllq" "psllw" "psrad" "psraw" "psrld" "psrlq" "psrlw"
"psubb" "psubd" "psubq" "psubw" "ptest" "pusha" "pushd" "pushf"
"pushq" "pushw" "rcpps" "rcpss" "rdmsr" "rdpmc" "rdtsc" "repne"
"repnz" "retfd" "retfq" "retfw" "retnd" "retnq" "retnw" "scasb"
"scasd" "scasq" "scasw" "setae" "setbe" "setge" "setle" "setna"
"setnb" "setnc" "setne" "setng" "setnl" "setno" "setnp" "setns"
"setnz" "setpe" "setpo" "stosb" "stosd" "stosq" "stosw" "subpd"
"subps" "subsd" "subss" "tzcnt" "tzmsk" "vdppd" "vdpps" "vmovd"
"vmovq" "vmrun" "vmxon" "vorpd" "vorps" "vpand" "vpxor" "wrmsr"
"xlatb" "xorpd" "xorps" "xsave" "xtest" "aesdec" "aesenc" "aesimc"
"andnpd" "andnps" "blcmsk" "blsmsk" "cmovae" "cmovbe" "cmovge"
"cmovle" "cmovna" "cmovnb" "cmovnc" "cmovne" "cmovng" "cmovnl"
"cmovno" "cmovnp" "cmovns" "cmovnz" "cmovpe" "cmovpo" "comisd"
"comiss" "fcmovb" "fcmove" "fcmovu" "fcomip" "fcompp" "fdivrp"
"ffreep" "ficomp" "fidivr" "fisttp" "fisubr" "fldenv" "fldl2e"
"fldl2t" "fldlg2" "fldln2" "fnclex" "fndisi" "fninit" "fnsave"
"fnstcw" "fnstsw" "fpatan" "fprem1" "frstor" "frstpm" "fsaved"
"fsavew" "fscale" "fsetpm" "fstenv" "fsubrp" "fucomi" "fucomp"
"fxsave" "getsec" "haddpd" "haddps" "hsubpd" "hsubps" "invept"
"invlpg" "lfence" "llwpcb" "looped" "loopeq" "loopew" "loopne"
"loopnz" "loopzd" "loopzq" "loopzw" "lwpins" "lwpval" "mfence"
"movapd" "movaps" "movdqa" "movdqu" "movhpd" "movhps" "movlpd"
"movlps" "movnti" "movntq" "movsxd" "movupd" "movups" "paddsb"
"paddsw" "pextrb" "pextrd" "pextrq" "pextrw" "pfnacc" "pfsubr"
"phaddd" "phaddw" "phsubd" "phsubw" "pinsrb" "pinsrd" "pinsrq"
"pinsrw" "pmaxsb" "pmaxsd" "pmaxsw" "pmaxub" "pmaxud" "pmaxuw"
"pminsb" "pminsd" "pminsw" "pminub" "pminud" "pminuw" "pmuldq"
"pmulhw" "pmulld" "pmullw" "popcnt" "psadbw" "pshufb" "pshufd"
"pshufw" "psignb" "psignd" "psignw" "pslldq" "psrldq" "psubsb"
"psubsw" "pswapd" "pushad" "pushaw" "pushfd" "pushfq" "pushfw"
"rdmsrq" "rdrand" "rdseed" "rdtscp" "setalc" "setnae" "setnbe"
"setnge" "setnle" "sfence" "shufpd" "shufps" "skinit" "slwpcb"
"sqrtpd" "sqrtps" "sqrtsd" "sqrtss" "swapgs" "sysret" "t1mskc"
"vaddpd" "vaddps" "vaddsd" "vaddss" "vandpd" "vandps" "vcmppd"
"vcmpps" "vcmpsd" "vcmpss" "vdivpd" "vdivps" "vdivsd" "vdivss"
"vlddqu" "vmaxpd" "vmaxps" "vmaxsd" "vmaxss" "vmcall" "vminpd"
"vminps" "vminsd" "vminss" "vmload" "vmovsd" "vmovss" "vmread"
"vmsave" "vmulpd" "vmulps" "vmulsd" "vmulss" "vmxoff" "vpabsb"
"vpabsd" "vpabsw" "vpaddb" "vpaddd" "vpaddq" "vpaddw" "vpandn"
"vpavgb" "vpavgw" "vpcmov" "vpcomb" "vpcomd" "vpcomq" "vpcomw"
"vpermd" "vpermq" "vpperm" "vprotb" "vprotd" "vprotq" "vprotw"
"vpshab" "vpshad" "vpshaq" "vpshaw" "vpshlb" "vpshld" "vpshlq"
"vpshlw" "vpslld" "vpsllq" "vpsllw" "vpsrad" "vpsraw" "vpsrld"
"vpsrlq" "vpsrlw" "vpsubb" "vpsubd" "vpsubq" "vpsubw" "vptest"
"vrcpps" "vrcpss" "vsubpd" "vsubps" "vsubsd" "vsubss" "vxorpd"
"vxorps" "wbinvd" "wrmsrq" "xabort" "xbegin" "xgetbv" "xrstor"
"xsetbv" "blcfill" "blendpd" "blendps" "blsfill" "clflush" "cmovnae"
"cmovnbe" "cmovnge" "cmovnle" "cmpeqpd" "cmpeqps" "cmpeqsd" "cmpeqss"
"cmplepd" "cmpleps" "cmplesd" "cmpless" "cmpltpd" "cmpltps" "cmpltsd"
"cmpltss" "cmpxchg" "fcmovbe" "fcmovnb" "fcmovne" "fcmovnu" "fdecstp"
"fincstp" "fldenvd" "fldenvw" "fnsaved" "fnsavew" "fnstenv" "frndint"
"frstord" "frstorw" "fsincos" "fstenvd" "fstenvw" "fucomip" "fucompp"
"fxrstor" "fxtract" "fyl2xp1" "insertq" "invlpga" "invpcid" "invvpid"
"ldmxcsr" "loopned" "loopneq" "loopnew" "loopnzd" "loopnzq" "loopnzw"
"monitor" "movddup" "movdq2q" "movhlps" "movlhps" "movntdq" "movntpd"
"movntps" "movntsd" "movntss" "movq2dq" "mpsadbw" "paddusb" "paddusw"
"palignr" "pavgusb" "pblendw" "pcmpeqb" "pcmpeqd" "pcmpeqq" "pcmpeqw"
"pcmpgtb" "pcmpgtd" "pcmpgtq" "pcmpgtw" "pfcmpeq" "pfcmpge" "pfcmpgt"
"pfpnacc" "pfrsqrt" "phaddsw" "phsubsw" "pmaddwd" "pmulhrw" "pmulhuw"
"pmuludq" "pshufhw" "pshuflw" "psubusb" "psubusw" "roundpd" "roundps"
"roundsd" "roundss" "rsqrtps" "rsqrtss" "stmxcsr" "syscall" "sysexit"
"sysretq" "ucomisd" "ucomiss" "vaesdec" "vaesenc" "vaesimc" "vandnpd"
"vandnps" "vcomisd" "vcomiss" "vfrczpd" "vfrczps" "vfrczsd" "vfrczss"
"vhaddpd" "vhaddps" "vhsubpd" "vhsubps" "vmclear" "vmmcall" "vmovapd"
"vmovaps" "vmovdqa" "vmovdqu" "vmovhpd" "vmovhps" "vmovlpd" "vmovlps"
"vmovupd" "vmovups" "vmptrld" "vmptrst" "vmwrite" "vpaddsb" "vpaddsw"
"vpcomub" "vpcomud" "vpcomuq" "vpcomuw" "vpermpd" "vpermps" "vpextrb"
"vpextrd" "vpextrq" "vpextrw" "vphaddd" "vphaddw" "vphsubd" "vphsubw"
"vpinsrb" "vpinsrd" "vpinsrq" "vpinsrw" "vpmaxsb" "vpmaxsd" "vpmaxsw"
"vpmaxub" "vpmaxud" "vpmaxuw" "vpminsb" "vpminsd" "vpminsw" "vpminub"
"vpminud" "vpminuw" "vpmuldq" "vpmulhw" "vpmulld" "vpmullw" "vpsadbw"
"vpshufb" "vpshufd" "vpsignb" "vpsignd" "vpsignw" "vpslldq" "vpsllvd"
"vpsllvq" "vpsravd" "vpsrldq" "vpsrlvd" "vpsrlvq" "vpsubsb" "vpsubsw"
"vshufpd" "vshufps" "vsqrtpd" "vsqrtps" "vsqrtsd" "vsqrtss" "vtestpd"
"vtestps" "xsave64" "addsubpd" "addsubps" "blendvpd" "blendvps"
"cmpneqpd" "cmpneqps" "cmpneqsd" "cmpneqss" "cmpnlepd" "cmpnleps"
"cmpnlesd" "cmpnless" "cmpnltpd" "cmpnltps" "cmpnltsd" "cmpnltss"
"cmpordpd" "cmpordps" "cmpordsd" "cmpordss" "cvtdq2pd" "cvtdq2ps"
"cvtpd2dq" "cvtpd2pi" "cvtpd2ps" "cvtpi2pd" "cvtpi2ps" "cvtps2dq"
"cvtps2pd" "cvtps2pi" "cvtsd2si" "cvtsd2ss" "cvtsi2sd" "cvtsi2ss"
"cvtss2sd" "cvtss2si" "fcmovnbe" "fnstenvd" "fnstenvw" "fxsave64"
"insertps" "maskmovq" "movmskpd" "movmskps" "movntdqa" "movshdup"
"movsldup" "packssdw" "packsswb" "packusdw" "packuswb" "pblendvb"
"pfrcpit1" "pfrcpit2" "pfrsqit1" "pmovmskb" "pmovsxbd" "pmovsxbq"
"pmovsxbw" "pmovsxdq" "pmovsxwd" "pmovsxwq" "pmovzxbd" "pmovzxbq"
"pmovzxbw" "pmovzxdq" "pmovzxwd" "pmovzxwq" "pmulhrsw" "prefetch"
"rdfsbase" "rdgsbase" "sysenter" "sysexitq" "unpckhpd" "unpckhps"
"unpcklpd" "unpcklps" "vblendpd" "vblendps" "vcmpeqpd" "vcmpeqps"
"vcmpeqsd" "vcmpeqss" "vcmpgepd" "vcmpgeps" "vcmpgesd" "vcmpgess"
"vcmpgtpd" "vcmpgtps" "vcmpgtsd" "vcmpgtss" "vcmplepd" "vcmpleps"
"vcmplesd" "vcmpless" "vcmpltpd" "vcmpltps" "vcmpltsd" "vcmpltss"
"vfmaddpd" "vfmaddps" "vfmaddsd" "vfmaddss" "vfmsubpd" "vfmsubps"
"vfmsubsd" "vfmsubss" "vldmxcsr" "vmlaunch" "vmovddup" "vmovhlps"
"vmovlhps" "vmovntdq" "vmovntpd" "vmovntps" "vmpsadbw" "vmresume"
"vpaddusb" "vpaddusw" "vpalignr" "vpblendd" "vpblendw" "vpcmpeqb"
"vpcmpeqd" "vpcmpeqq" "vpcmpeqw" "vpcmpgtb" "vpcmpgtd" "vpcmpgtq"
"vpcmpgtw" "vpcomeqb" "vpcomeqd" "vpcomeqq" "vpcomeqw" "vpcomgeb"
"vpcomged" "vpcomgeq" "vpcomgew" "vpcomgtb" "vpcomgtd" "vpcomgtq"
"vpcomgtw" "vpcomleb" "vpcomled" "vpcomleq" "vpcomlew" "vpcomltb"
"vpcomltd" "vpcomltq" "vpcomltw" "vphaddbd" "vphaddbq" "vphaddbw"
"vphadddq" "vphaddsw" "vphaddwd" "vphaddwq" "vphsubbw" "vphsubdq"
"vphsubsw" "vphsubwd" "vpmacsdd" "vpmacswd" "vpmacsww" "vpmaddwd"
"vpmulhuw" "vpmuludq" "vpshufhw" "vpshuflw" "vpsubusb" "vpsubusw"
"vroundpd" "vroundps" "vroundsd" "vroundss" "vrsqrtps" "vrsqrtss"
"vstmxcsr" "vucomisd" "vucomiss" "vzeroall" "wrfsbase" "wrgsbase"
"xacquire" "xrelease" "xrstor64" "xsaveopt" "cmpxchg8b" "cvttpd2dq"
"cvttpd2pi" "cvttps2dq" "cvttps2pi" "cvttsd2si" "cvttss2si"
"extractps" "fxrstor64" "pclmulqdq" "pcmpestri" "pcmpestrm"
"pcmpistri" "pcmpistrm" "pmaddubsw" "prefetchw" "punpckhbw"
"punpckhdq" "punpckhwd" "punpcklbw" "punpckldq" "punpcklwd"
"vaddsubpd" "vaddsubps" "vblendvpd" "vblendvps" "vcmpneqpd"
"vcmpneqps" "vcmpneqsd" "vcmpneqss" "vcmpngepd" "vcmpngeps"
"vcmpngesd" "vcmpngess" "vcmpngtpd" "vcmpngtps" "vcmpngtsd"
"vcmpngtss" "vcmpnlepd" "vcmpnleps" "vcmpnlesd" "vcmpnless"
"vcmpnltpd" "vcmpnltps" "vcmpnltsd" "vcmpnltss" "vcmpordpd"
"vcmpordps" "vcmpordsd" "vcmpordss" "vcvtdq2pd" "vcvtdq2ps"
"vcvtpd2dq" "vcvtpd2ps" "vcvtph2ps" "vcvtps2dq" "vcvtps2pd"
"vcvtps2ph" "vcvtsd2si" "vcvtsd2ss" "vcvtsi2sd" "vcvtsi2ss"
"vcvtss2sd" "vcvtss2si" "vfnmaddpd" "vfnmaddps" "vfnmaddsd"
"vfnmaddss" "vfnmsubpd" "vfnmsubps" "vfnmsubsd" "vfnmsubss"
"vinsertps" "vmovmskpd" "vmovmskps" "vmovntdqa" "vmovshdup"
"vmovsldup" "vpackssdw" "vpacksswb" "vpackusdw" "vpackuswb"
"vpblendvb" "vpcomequb" "vpcomequd" "vpcomequq" "vpcomequw"
"vpcomgeub" "vpcomgeud" "vpcomgeuq" "vpcomgeuw" "vpcomgtub"
"vpcomgtud" "vpcomgtuq" "vpcomgtuw" "vpcomleub" "vpcomleud"
"vpcomleuq" "vpcomleuw" "vpcomltub" "vpcomltud" "vpcomltuq"
"vpcomltuw" "vpcomneqb" "vpcomneqd" "vpcomneqq" "vpcomneqw"
"vpermilpd" "vpermilps" "vphaddubd" "vphaddubq" "vphaddubw"
"vphaddudq" "vphadduwd" "vphadduwq" "vpmacsdqh" "vpmacsdql"
"vpmacssdd" "vpmacsswd" "vpmacssww" "vpmadcswd" "vpmovmskb"
"vpmovsxbd" "vpmovsxbq" "vpmovsxbw" "vpmovsxdq" "vpmovsxwd"
"vpmovsxwq" "vpmovzxbd" "vpmovzxbq" "vpmovzxbw" "vpmovzxdq"
"vpmovzxwd" "vpmovzxwq" "vpmulhrsw" "vunpckhpd" "vunpckhps"
"vunpcklpd" "vunpcklps" "aesdeclast" "aesenclast" "cmpunordpd"
"cmpunordps" "cmpunordsd" "cmpunordss" "cmpxchg16b" "loadall286"
"loadall386" "maskmovdqu" "phminposuw" "prefetcht0" "prefetcht1"
"prefetcht2" "punpckhqdq" "punpcklqdq" "vcmptruepd" "vcmptrueps"
"vcmptruesd" "vcmptruess" "vcvttpd2dq" "vcvttps2dq" "vcvttsd2si"
"vcvttss2si" "vextractps" "vgatherdpd" "vgatherdps" "vgatherqpd"
"vgatherqps" "vmaskmovpd" "vmaskmovps" "vpclmulqdq" "vpcmpestri"
"vpcmpestrm" "vpcmpistri" "vpcmpistrm" "vpcomnequb" "vpcomnequd"
"vpcomnequq" "vpcomnequw" "vpcomtrueb" "vpcomtrued" "vpcomtrueq"
"vpcomtruew" "vperm2f128" "vperm2i128" "vpermil2pd" "vpermil2ps"
"vpgatherdd" "vpgatherdq" "vpgatherqd" "vpgatherqq" "vpmacssdqh"
"vpmacssdql" "vpmadcsswd" "vpmaddubsw" "vpmaskmovd" "vpmaskmovq"
"vpunpckhbw" "vpunpckhdq" "vpunpckhwd" "vpunpcklbw" "vpunpckldq"
"vpunpcklwd" "vzeroupper" "xsaveopt64" "pclmulhqhdq" "pclmullqhdq"
"prefetchnta" "vaesdeclast" "vaesenclast" "vcmpeq_ospd" "vcmpeq_osps"
"vcmpeq_ossd" "vcmpeq_osss" "vcmpeq_uqpd" "vcmpeq_uqps" "vcmpeq_uqsd"
"vcmpeq_uqss" "vcmpeq_uspd" "vcmpeq_usps" "vcmpeq_ussd" "vcmpeq_usss"
"vcmpfalsepd" "vcmpfalseps" "vcmpfalsesd" "vcmpfalsess" "vcmpge_oqpd"
"vcmpge_oqps" "vcmpge_oqsd" "vcmpge_oqss" "vcmpgt_oqpd" "vcmpgt_oqps"
"vcmpgt_oqsd" "vcmpgt_oqss" "vcmple_oqpd" "vcmple_oqps" "vcmple_oqsd"
"vcmple_oqss" "vcmplt_oqpd" "vcmplt_oqps" "vcmplt_oqsd" "vcmplt_oqss"
"vcmpord_spd" "vcmpord_sps" "vcmpord_ssd" "vcmpord_sss" "vcmpunordpd"
"vcmpunordps" "vcmpunordsd" "vcmpunordss" "vfmadd132pd" "vfmadd132ps"
"vfmadd132sd" "vfmadd132ss" "vfmadd213pd" "vfmadd213ps" "vfmadd213sd"
"vfmadd213ss" "vfmadd231pd" "vfmadd231ps" "vfmadd231sd" "vfmadd231ss"
"vfmaddsubpd" "vfmaddsubps" "vfmsub132pd" "vfmsub132ps" "vfmsub132sd"
"vfmsub132ss" "vfmsub213pd" "vfmsub213ps" "vfmsub213sd" "vfmsub213ss"
"vfmsub231pd" "vfmsub231ps" "vfmsub231sd" "vfmsub231ss" "vfmsubaddpd"
"vfmsubaddps" "vinsertf128" "vinserti128" "vmaskmovdqu" "vpcomfalseb"
"vpcomfalsed" "vpcomfalseq" "vpcomfalsew" "vpcomtrueub" "vpcomtrueud"
"vpcomtrueuq" "vpcomtrueuw" "vphminposuw" "vpunpckhqdq" "vpunpcklqdq"
"pclmulhqhqdq" "pclmulhqlqdq" "pclmullqhqdq" "pclmullqlqdq"
"vbroadcastsd" "vbroadcastss" "vcmpneq_oqpd" "vcmpneq_oqps"
"vcmpneq_oqsd" "vcmpneq_oqss" "vcmpneq_ospd" "vcmpneq_osps"
"vcmpneq_ossd" "vcmpneq_osss" "vcmpneq_uspd" "vcmpneq_usps"
"vcmpneq_ussd" "vcmpneq_usss" "vcmpnge_uqpd" "vcmpnge_uqps"
"vcmpnge_uqsd" "vcmpnge_uqss" "vcmpngt_uqpd" "vcmpngt_uqps"
"vcmpngt_uqsd" "vcmpngt_uqss" "vcmpnle_uqpd" "vcmpnle_uqps"
"vcmpnle_uqsd" "vcmpnle_uqss" "vcmpnlt_uqpd" "vcmpnlt_uqps"
"vcmpnlt_uqsd" "vcmpnlt_uqss" "vextractf128" "vextracti128"
"vfnmadd132pd" "vfnmadd132ps" "vfnmadd132sd" "vfnmadd132ss"
"vfnmadd213pd" "vfnmadd213ps" "vfnmadd213sd" "vfnmadd213ss"
"vfnmadd231pd" "vfnmadd231ps" "vfnmadd231sd" "vfnmadd231ss"
"vfnmsub132pd" "vfnmsub132ps" "vfnmsub132sd" "vfnmsub132ss"
"vfnmsub213pd" "vfnmsub213ps" "vfnmsub213sd" "vfnmsub213ss"
"vfnmsub231pd" "vfnmsub231ps" "vfnmsub231sd" "vfnmsub231ss"
"vpbroadcastb" "vpbroadcastd" "vpbroadcastq" "vpbroadcastw"
"vpclmulhqhdq" "vpclmullqhdq" "vpcomfalseub" "vpcomfalseud"
"vpcomfalseuq" "vpcomfalseuw" "vpermilmo2pd" "vpermilmo2ps"
"vpermilmz2pd" "vpermilmz2ps" "vpermiltd2pd" "vpermiltd2ps"
"vcmptrue_uspd" "vcmptrue_usps" "vcmptrue_ussd" "vcmptrue_usss"
"vcmpunord_spd" "vcmpunord_sps" "vcmpunord_ssd" "vcmpunord_sss"
"vpclmulhqlqdq" "vpclmullqlqdq" "vbroadcastf128" "vbroadcasti128"
"vcmpfalse_ospd" "vcmpfalse_osps" "vcmpfalse_ossd" "vcmpfalse_osss"
"vfmaddsub132pd" "vfmaddsub132ps" "vfmaddsub213pd" "vfmaddsub213ps"
"vfmaddsub231pd" "vfmaddsub231ps" "vfmsubadd132pd" "vfmsubadd132ps"
"vfmsubadd213pd" "vfmsubadd213ps" "vfmsubadd231pd" "vfmsubadd231ps"
"aeskeygenassist" "vaeskeygenassist")) . 'font-lock-builtin-face)
;; Labels
("^[ \t]*\\([a-z$A-Z0-9.?!@]\\(?:\\sw\\|\\s_\\)*\\):"
. (1 'font-lock-function-name-face))
;; Macro names
("\\(?:macro\\|struc\\)[ \t]+\\([a-zA-Z0-9.?!@]\\(?:\\sw\\|\\s_\\)*\\)"
. (1 'font-lock-function-name-face)))
"Syntax highlighting for FASM mode.")
;; (defun fasm--get-indent-level (lineoffset)
;; (save-excursion
;; (forward-line (1- lineoffset))
;; (back-to-indentation)
;; (current-column)))
(defun empty-line? ()
(save-excursion
(let ((column-a (progn (move-beginning-of-line nil)
(current-column)))
(column-b (progn (back-to-indentation)
(current-column))))
;; 下面这个谓词看似是冗余的 但是没有关系
(and (= column-b column-a)
(eq (following-char) 10))
)))
(defun above-char ()
(interactive)
(save-excursion
(backward-char 1)
(following-char)))
(defun fasm-label? ()
(interactive)
(save-excursion
(and (progn
(whitespace-cleanup)
(not (empty-line?)))
(progn
;; (whitespace-cleanup)
(end-of-line)
(eq 58 ;; 58 -- ":"
(above-char))))))
;; (defun' test-fasm-get-indent ()
;; (interactive)
;; (message "><><><"))
(defun fasm-get-indent (n)
(save-excursion
(forward-line n)
(cond ((empty-line?)
"empty-line")
((fasm-label?)
"fasm-label")
(t
(progn
(back-to-indentation)
(current-column))))))
(defun fasm-indent-line ()
"Indent according to FASM major mode."
(interactive)
;; 可以发现缩进函数根本就写不好 因为emacs不能真正明白文本的语法
(cond
;; 下面是根据当前一行来缩进
((fasm-label?)
(let ()
(back-to-indentation)
(delete-backward-char (current-column))))
;; 下面是根据上一行来缩进
(t;; else
(back-to-indentation)
(let ((prev-indent (fasm-get-indent -1))
(curr-indent (current-column)))
(cond ((equal prev-indent "empty-line")
;; (indent-to 8)
(indent-to 3)
)
((equal prev-indent "fasm-label")
;; (indent-to 0)
;; 上面的那个命令根本不会缩进 这样看似是合理的 所以增加下面这句:
(message "do not indent at all !"))
((< curr-indent prev-indent)
(indent-to prev-indent))
((>= curr-indent prev-indent)
(delete-backward-char (- curr-indent prev-indent)))
((>= curr-indent prev-indent)
(delete-backward-char (- curr-indent prev-indent)))
)))))
;; Emacs < 24 did not have prog-mode
(defalias 'fasm-parent-mode
(if (fboundp 'prog-mode) 'prog-mode 'fundamental-mode))
;;;###autoload
(define-derived-mode fasm-mode fasm-parent-mode
"Fasm"
"Major mode for editing assembly in FASM format."
(set (make-local-variable 'font-lock-defaults)
(list 'fasm-font-lock-keywords nil t))
(set (make-local-variable 'indent-line-function) 'fasm-indent-line)
(set (make-local-variable 'comment-start) ";; "))
(provide 'fasm-mode)
;;; fasm-mode.el ends here
-292
View File
@@ -1,292 +0,0 @@
;;; llvm-mode.el --- Major mode for the LLVM IR language -*- lexical-binding: t; -*-
;;
;; This is free and unencumbered software released into the public domain.
;;
;; Author: Noah Peart <noah.v.peart@gmail.com>
;; URL: https://github.com/nverno/llvm-mode
;; Package-Requires: ((emacs "25.1"))
;; Created: 16 February 2020
;; Version: 0.1.0
;; This file is not part of GNU Emacs.
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 3, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
;; Floor, Boston, MA 02110-1301, USA.
;;; Commentary:
;; Major mode for editing LLVM IR files.
;; Modified from https://github.com/llvm-mirror/llvm//utils/emacs/llvm-mode.el
;; to include
;; - additional syntax
;; - font-lock for globals (vars/declares/defines)
;; - imenu
;; - indentation: `llvm-mode-indent-offset' and `llvm-mode-label-offset'
;; - completion:
;; + global variables
;; + global declares/defines
;; TODO:
;; + keywords / attributes
;; + could add labels / %uids as well
;;
;; - vim syntax => https://github.com/llvm-mirror/llvm/utils/vim/syntax/llvm.vim
;;
;; Reference:
;; https://github.com/llvm-mirror/llvm/docs/LangRef.rst
;;
;;; Installation:
;;
;; Add to `load-path' and generate autoloads or
;; ```lisp
;; (require 'llvm-mode)
;; ```
;;
;;; Code:
(require 'smie)
(defgroup llvm nil
"Major mode for editing llvm assembly source code."
:group 'languages
:prefix "llvm-")
(defcustom llvm-mode-indent-offset 2
"Indentation column following opening braces."
:group 'llvm
:type 'integer)
(defcustom llvm-mode-label-offset 0
"Indentation column for labels."
:group 'llvm
:type 'integer)
(defvar llvm-mode-lookup-instruction-uri
"https://llvm.org/docs/LangRef.html#%s-instruction")
(defvar llvm-mode-syntax-table
(let ((table (make-syntax-table)))
(modify-syntax-entry ?% "_" table)
(modify-syntax-entry ?. "_" table)
(modify-syntax-entry ?\; "< " table)
(modify-syntax-entry ?\n "> " table)
(modify-syntax-entry ?: "." table)
(modify-syntax-entry ?* "." table)
table)
"Syntax table used while in LLVM mode.")
(defconst llvm-mode-font-lock-keywords
(list
;; Attributes
`(,(regexp-opt
'("alwaysinline" "argmemonly" "builtin" "cold" "convergent" "immarg"
"inaccessiblemem_or_argmemonly" "inaccessiblememonly" "inlinehint"
"jumptable" "minsize" "naked" "nobuiltin" "noduplicate"
"noimplicitfloat" "noinline" "nonlazybind" "norecurse" "noredzone"
"noreturn" "nounwind" "optnone" "optsize" "readnone" "readonly"
"returns_twice" "safestack" "sanitize_address" "sanitize_hwaddress"
"sanitize_memory" "sanitize_memtag" "sanitize_thread" "speculatable"
"ssp" "sspreq" "sspstrong" "strictfp" "uwtable" "writeonly")
'symbols)
. font-lock-constant-face)
;; Globals
'("@[[:alnum:]_]+" . font-lock-function-name-face)
;; Variables
'("%[-a-zA-Z$._][-a-zA-Z$._0-9]*" . font-lock-variable-name-face)
;; Labels
'("[-a-zA-Z$._0-9]+:" . font-lock-variable-name-face)
;; Unnamed variable slots
'("%[-]?[0-9]+" . font-lock-variable-name-face)
;; Types
`(,(regexp-opt
'("void" "i1" "i8" "i16" "i32" "i64" "i128" "float" "double" "type"
"label" "opaque")
'symbols)
. font-lock-type-face)
;; Integer literals
'("\\b[-]?[0-9]+\\b" . font-lock-preprocessor-face)
;; Floating point constants
'("\\b[-+]?[0-9]+.[0-9]*\\([eE][-+]?[0-9]+\\)?\\b" . font-lock-preprocessor-face)
;; Hex constants
'("\\b0x[0-9A-Fa-f]+\\b" . font-lock-preprocessor-face)
;; Keywords
`(,(regexp-opt
'(;; Toplevel entities
"declare" "define" "module" "target" "source_filename" "global"
"constant" "const" "attributes" "uselistorder" "uselistorder_bb"
;; Linkage types
"private" "internal" "weak" "weak_odr" "linkonce" "linkonce_odr"
"available_externally" "appending" "common" "extern_weak" "external"
"uninitialized" "implementation" "..."
;; Values
"true" "false" "null" "undef" "zeroinitializer" "none" "c" "asm"
"blockaddress"
;; Calling conventions
"ccc" "fastcc" "coldcc" "webkit_jscc" "anyregcc" "preserve_mostcc"
"preserve_allcc" "cxx_fast_tlscc" "swiftcc" "atomic" "volatile"
"personality" "prologue" "section")
'symbols)
. font-lock-keyword-face)
;; Arithmetic and Logical Operators
`(,(regexp-opt
'("add" "sub" "mul" "sdiv" "udiv" "urem" "srem" "and" "or" "xor" "setne"
"seteq" "setlt" "setgt" "setle" "setge")
'symbols)
. font-lock-keyword-face)
;; Floating-point operators
`(,(regexp-opt '("fadd" "fsub" "fneg" "fmul" "fdiv" "frem") 'symbols)
. font-lock-keyword-face)
;; Special instructions
`(,(regexp-opt
'("phi" "tail" "call" "select" "to" "shl" "lshr" "ashr" "fcmp" "icmp"
"va_arg" "landingpad")
'symbols)
. font-lock-keyword-face)
;; Control instructions
`(,(regexp-opt
'("ret" "br" "switch" "invoke" "resume" "unwind" "unreachable"
"indirectbr")
'symbols)
. font-lock-keyword-face)
;; Memory operators
`(,(regexp-opt
'("malloc" "alloca" "free" "load" "store" "getelementptr" "fence"
"cmpxchg" "atomicrmw")
'symbols)
. font-lock-keyword-face)
;; Casts
`(,(regexp-opt
'("bitcast" "inttoptr" "ptrtoint" "trunc" "zext" "sext" "fptrunc" "fpext"
"fptoui" "fptosi" "uitofp" "sitofp" "addrspacecast")
'symbols)
. font-lock-keyword-face)
;; Vector ops
`(,(regexp-opt '("extractelement" "insertelement" "shufflevector") 'symbols)
. font-lock-keyword-face)
;; Aggregate ops
`(,(regexp-opt '("extractvalue" "insertvalue") 'symbols) . font-lock-keyword-face)
;; Metadata types
`(,(regexp-opt '("distinct") 'symbols) . font-lock-keyword-face)
;; Use-list order directives
`(,(regexp-opt '("uselistorder" "uselistorder_bb") 'symbols)
. font-lock-keyword-face))
"Syntax highlighting for LLVM.")
;; -------------------------------------------------------------------
;;; Indentation
(defconst llvm-mode-smie-grammar
(smie-prec2->grammar
(smie-precs->prec2
'((assoc ":")))))
;; return ":" on label line
(defun llvm-mode--smie-forward-token ()
(let ((tok (smie-default-forward-token)))
(save-match-data
(if (not (looking-at "[ \t]*:")) tok
(goto-char (match-end 0))
":"))))
(defun llvm-mode-smie-rules (kind token)
(pcase (cons kind token)
(`(:elem . basic) llvm-mode-indent-offset)
(`(:elem . args) 0)
(`(:close-all . ,_) t)
(`(:before . ":")
(if (smie-rule-parent-p ":") 0
llvm-mode-label-offset))
(`(:after . ":")
(if (smie-rule-prev-p ":") llvm-mode-indent-offset
(- llvm-mode-indent-offset llvm-mode-label-offset)))
(`(:list-intro . ,(or ":" "")) t)))
;; -------------------------------------------------------------------
;;; Completion
(defconst llvm-mode-global-regexp
(concat "^\\s-*" (regexp-opt '("declare" "define")) "\\s-*"
"[^@\n]+@\\([[:alnum:]_]+\\)"
"\\|^\\s-*@\\([[:alnum:]_]+\\) *="))
(defun llvm-mode--globals ()
(let (res)
(save-excursion
(goto-char (point-min))
(while (re-search-forward llvm-mode-global-regexp nil t)
(push (or (match-string-no-properties 1)
(match-string-no-properties 2))
res)))
res))
;; basic completion at point
(defun llvm-mode-completion-at-point ()
(when-let* ((bnds (bounds-of-thing-at-point 'symbol)))
(let ((table
(cond
((eq ?@ (char-before (car bnds)))
(list
(completion-table-with-cache
(lambda (_string) (llvm-mode--globals)))
:annotation-function (lambda (_s) " <g>"))))))
(when table
(nconc (list (car bnds) (cdr bnds))
table
(list :exclusive 'no))))))
(defun llvm-mode-lookup-instruction-online (instr)
"Lookup help for INSTR, default to thing at point, in online manual.
With prefix, query for INSTR."
(interactive
(list
(or (and (not current-prefix-arg) (thing-at-point 'symbol))
(read-from-minibuffer "LLVM help for: "))))
(browse-url
(format llvm-mode-lookup-instruction-uri instr)))
;; Imenu: defines / declares / labels
;; XXX: remove duplicate labels??
(defvar llvm-mode-imenu-regexp
`((nil
,(concat (regexp-opt '("declare" "define")) "[^@\n]+@\\([[:alnum:]_]+\\)")
1)
("Label" "^\\s-*\\([[:alpha:]][[:alnum:]_]*\\):" 1)))
(defvar llvm-mode-map
(let ((km (make-sparse-keymap)))
(define-key km (kbd "M-?") #'llvm-mode-lookup-instruction-online)
km))
;;;###autoload
(define-derived-mode llvm-mode prog-mode "LLVM"
"Major mode for editing LLVM source files.
\\{llvm-mode-map}
Runs `llvm-mode-hook' on startup."
(setq font-lock-defaults `(llvm-mode-font-lock-keywords))
(setq-local comment-start ";")
(setq-local imenu-generic-expression llvm-mode-imenu-regexp)
(add-hook 'completion-at-point-functions #'llvm-mode-completion-at-point nil t)
(smie-setup llvm-mode-smie-grammar #'llvm-mode-smie-rules
:forward-token #'llvm-mode--smie-forward-token
:backward-token #'smie-default-backward-token))
;; Associate .ll files with llvm-mode
;;;###autoload
(add-to-list 'auto-mode-alist (cons "\\.ll\\'" 'llvm-mode))
(provide 'llvm-mode)
;;; llvm-mode.el ends here
-111
View File
@@ -1,111 +0,0 @@
(require 'subr-x)
(defvar simpc-mode-syntax-table
(let ((table (make-syntax-table)))
;; C/C++ style comments
(modify-syntax-entry ?/ ". 124b" table)
(modify-syntax-entry ?* ". 23" table)
(modify-syntax-entry ?\n "> b" table)
;; Preprocessor stuff?
(modify-syntax-entry ?# "." table)
;; Chars are the same as strings
(modify-syntax-entry ?' "\"" table)
;; Treat <> as punctuation (needed to highlight C++ keywords
;; properly in template syntax)
(modify-syntax-entry ?< "." table)
(modify-syntax-entry ?> "." table)
(modify-syntax-entry ?& "." table)
(modify-syntax-entry ?% "." table)
table))
(defun simpc-types ()
'("char" "int" "long" "short" "void" "bool" "float" "double" "signed" "unsigned"
"char16_t" "char32_t" "char8_t"
"int8_t" "uint8_t" "int16_t" "uint16_t" "int32_t" "uint32_t" "int64_t" "uint64_t"
"uintptr_t"
"size_t"))
(defun simpc-keywords ()
'("auto" "break" "case" "const" "continue" "default" "do"
"else" "enum" "extern" "for" "goto" "if" "register"
"return" "sizeof" "static" "struct" "switch" "typedef"
"union" "volatile" "while" "alignas" "alignof" "and"
"and_eq" "asm" "atomic_cancel" "atomic_commit" "atomic_noexcept" "bitand"
"bitor" "catch" "class" "co_await"
"co_return" "co_yield" "compl" "concept" "const_cast" "consteval" "constexpr"
"constinit" "decltype" "delete" "dynamic_cast" "explicit" "export" "false"
"friend" "inline" "mutable" "namespace" "new" "noexcept" "not" "not_eq"
"nullptr" "operator" "or" "or_eq" "private" "protected" "public" "reflexpr"
"reinterpret_cast" "requires" "static_assert" "static_cast" "synchronized"
"template" "this" "thread_local" "throw" "true" "try" "typeid" "typename"
"using" "virtual" "wchar_t" "xor" "xor_eq"))
(defun simpc-font-lock-keywords ()
(list
`("# *[#a-zA-Z0-9_]+" . font-lock-preprocessor-face)
`("#.*include \\(\\(<\\|\"\\).*\\(>\\|\"\\)\\)" . (1 font-lock-string-face))
`(,(regexp-opt (simpc-keywords) 'symbols) . font-lock-keyword-face)
`(,(regexp-opt (simpc-types) 'symbols) . font-lock-type-face)))
(defun simpc--previous-non-empty-line ()
(save-excursion
(forward-line -1)
(while (and (not (bobp))
(string-empty-p
(string-trim-right
(thing-at-point 'line t))))
(forward-line -1))
(thing-at-point 'line t)))
(defun simpc--indentation-of-previous-non-empty-line ()
(save-excursion
(forward-line -1)
(while (and (not (bobp))
(string-empty-p
(string-trim-right
(thing-at-point 'line t))))
(forward-line -1))
(current-indentation)))
(defun simpc--desired-indentation ()
(let* ((cur-line (string-trim-right (thing-at-point 'line t)))
(prev-line (string-trim-right (simpc--previous-non-empty-line)))
(indent-len 4)
(prev-indent (simpc--indentation-of-previous-non-empty-line)))
(cond
((string-match-p "^\\s-*switch\\s-*(.+)" prev-line)
prev-indent)
((and (string-suffix-p "{" prev-line)
(string-prefix-p "}" (string-trim-left cur-line)))
prev-indent)
((string-suffix-p "{" prev-line)
(+ prev-indent indent-len))
((string-prefix-p "}" (string-trim-left cur-line))
(max (- prev-indent indent-len) 0))
((string-suffix-p ":" prev-line)
(if (string-suffix-p ":" cur-line)
prev-indent
(+ prev-indent indent-len)))
((string-suffix-p ":" cur-line)
(max (- prev-indent indent-len) 0))
(t prev-indent))))
;;; TODO: customizable indentation (amount of spaces, tabs, etc)
(defun simpc-indent-line ()
(interactive)
(when (not (bobp))
(let* ((desired-indentation
(simpc--desired-indentation))
(n (max (- (current-column) (current-indentation)) 0)))
(indent-line-to desired-indentation)
(forward-char n))))
(define-derived-mode simpc-mode prog-mode "Simple C"
"Simple major mode for editing C files."
:syntax-table simpc-mode-syntax-table
(setq-local font-lock-defaults '(simpc-font-lock-keywords))
(setq-local indent-line-function 'simpc-indent-line)
(setq-local comment-start "// "))
(provide 'simpc-mode)
-137
View File
@@ -1,137 +0,0 @@
(require 'ansi-color)
(global-set-key (kbd "C-c p") 'find-file-at-point)
(global-set-key (kbd "C-c i m") 'imenu)
(setq-default inhibit-splash-screen t
make-backup-files nil
tab-width 4
indent-tabs-mode nil
compilation-scroll-output t
visible-bell (equal system-type 'windows-nt))
(defun rc/colorize-compilation-buffer ()
(read-only-mode 'toggle)
(ansi-color-apply-on-region compilation-filter-start (point))
(read-only-mode 'toggle))
(add-hook 'compilation-filter-hook 'rc/colorize-compilation-buffer)
(defun rc/buffer-file-name ()
(if (equal major-mode 'dired-mode)
default-directory
(buffer-file-name)))
(defun rc/parent-directory (path)
(file-name-directory (directory-file-name path)))
(defun rc/root-anchor (path anchor)
(cond
((string= anchor "") nil)
((file-exists-p (concat (file-name-as-directory path) anchor)) path)
((string-equal path "/") nil)
(t (rc/root-anchor (rc/parent-directory path) anchor))))
(defun rc/clipboard-org-mode-file-link (anchor)
(interactive "sRoot anchor: ")
(let* ((root-dir (rc/root-anchor default-directory anchor))
(org-mode-file-link (format "file:%s::%d"
(if root-dir
(file-relative-name (rc/buffer-file-name) root-dir)
(rc/buffer-file-name))
(line-number-at-pos))))
(kill-new org-mode-file-link)
(message org-mode-file-link)))
;;; Taken from here:
;;; http://stackoverflow.com/questions/2416655/file-path-to-clipboard-in-emacs
(defun rc/put-file-name-on-clipboard ()
"Put the current file name on the clipboard"
(interactive)
(let ((filename (rc/buffer-file-name)))
(when filename
(kill-new filename)
(message filename))))
(defun rc/put-buffer-name-on-clipboard ()
"Put the current buffer name on the clipboard"
(interactive)
(kill-new (buffer-name))
(message (buffer-name)))
(defun rc/kill-autoloads-buffers ()
(interactive)
(dolist (buffer (buffer-list))
(let ((name (buffer-name buffer)))
(when (string-match-p "-autoloads.el" name)
(kill-buffer buffer)
(message "Killed autoloads buffer %s" name)))))
(defun rc/start-python-simple-http-server ()
(interactive)
(shell-command "python -m SimpleHTTPServer 3001 &"
"*Simple Python HTTP Server*"))
(global-set-key (kbd "C-x p s") 'rc/start-python-simple-http-server)
;;; Taken from here:
;;; http://blog.bookworm.at/2007/03/pretty-print-xml-with-emacs.html
(defun bf-pretty-print-xml-region (begin end)
"Pretty format XML markup in region. You need to have nxml-mode
http://www.emacswiki.org/cgi-bin/wiki/NxmlMode installed to do
this. The function inserts linebreaks to separate tags that have
nothing but whitespace between them. It then indents the markup
by using nxml's indentation rules."
(interactive "r")
(save-excursion
(nxml-mode)
(goto-char begin)
(while (search-forward-regexp "\>[ \\t]*\<" nil t)
(backward-char) (insert "\n"))
(indent-region begin end))
(message "Ah, much better!"))
;;; Stolen from http://ergoemacs.org/emacs/emacs_unfill-paragraph.html
(defun rc/unfill-paragraph ()
"Replace newline chars in current paragraph by single spaces.
This command does the inverse of `fill-paragraph'."
(interactive)
(let ((fill-column 90002000)) ; 90002000 is just random. you can use `most-positive-fixnum'
(fill-paragraph nil)))
(global-set-key (kbd "C-c M-q") 'rc/unfill-paragraph)
(defun rc/load-path-here ()
(interactive)
(add-to-list 'load-path default-directory))
(defconst rc/frame-transparency 85)
(defun rc/toggle-transparency ()
(interactive)
(let ((frame-alpha (frame-parameter nil 'alpha)))
(if (or (not frame-alpha)
(= (cadr frame-alpha) 100))
(set-frame-parameter nil 'alpha
`(,rc/frame-transparency
,rc/frame-transparency))
(set-frame-parameter nil 'alpha '(100 100)))))
(defun rc/duplicate-line ()
"Duplicate current line"
(interactive)
(let ((column (- (point) (point-at-bol)))
(line (let ((s (thing-at-point 'line t)))
(if s (string-remove-suffix "\n" s) ""))))
(move-end-of-line 1)
(newline)
(insert line)
(move-beginning-of-line 1)
(forward-char column)))
(global-set-key (kbd "C-,") 'rc/duplicate-line)
;;; A little hack which fixes a problem with meta key in fluxbox under VNC.
(setq x-alt-keysym 'meta)
;(setq confirm-kill-emacs 'y-or-n-p)
-34
View File
@@ -1,34 +0,0 @@
;; (add-to-list 'package-archives
;; '("melpa" . "https://melpa.org/packages/") t)
(add-to-list 'package-archives
'("melpa-stable" . "https://stable.melpa.org/packages/") t)
(defvar rc/package-contents-refreshed nil)
(defun rc/package-refresh-contents-once ()
(when (not rc/package-contents-refreshed)
(setq rc/package-contents-refreshed t)
(package-refresh-contents)))
(defun rc/require-one-package (package)
(when (not (package-installed-p package))
(rc/package-refresh-contents-once)
(package-install package)))
(defun rc/require (&rest packages)
(dolist (package packages)
(rc/require-one-package package)))
(defun rc/require-theme (theme)
(let ((theme-package (->> theme
(symbol-name)
(funcall (-flip #'concat) "-theme")
(intern))))
(rc/require theme-package)
(load-theme theme t)))
(rc/require 'dash)
(require 'dash)
(rc/require 'dash-functional)
(require 'dash-functional)
+1 -3
View File
@@ -1,6 +1,4 @@
.emacs|symlink|
.emacs.local|symlink|
.emacs.rc|symlink|
.config/doom|symlink|
.config/kitty|symlink|
.config/i3|symlink|
.config/i3status|symlink|