updated emacs configs

This commit is contained in:
2024-02-29 12:19:00 +01:00
parent a312a5dd34
commit 5acb369b6c
97 changed files with 249 additions and 1632 deletions

103
.emacs
View File

@@ -11,10 +11,16 @@
(setq use-package-always-ensure t (setq use-package-always-ensure t
use-package-expand-minimally t)) use-package-expand-minimally t))
(load "~/.emacs.rc/rc.el") (unless (package-installed-p 'benchmark-init)
(load "~/.emacs.rc/misc-rc.el") (package-refresh-contents)
(load "~/.emacs.rc/org-mode-rc.el") (package-install 'benchmark-init))
(load "~/.emacs.rc/autocommit-rc.el")
(require 'benchmark-init)
;; To disable collection of benchmark data after init is done.
(add-hook 'after-init-hook 'benchmark-init/deactivate)
;; shell
(global-set-key (kbd "C-c RET") (lambda () (interactive) (ansi-term "/bin/zsh")))
;; Look ;; Look
(tool-bar-mode 0) (tool-bar-mode 0)
@@ -23,6 +29,7 @@
(column-number-mode 1) (column-number-mode 1)
(show-paren-mode 1) (show-paren-mode 1)
(electric-pair-mode 1) (electric-pair-mode 1)
(global-font-lock-mode 0)
(global-display-line-numbers-mode 1) (global-display-line-numbers-mode 1)
(setq display-line-numbers-type 'relative) (setq display-line-numbers-type 'relative)
(set-face-attribute 'default nil :height 200) (set-face-attribute 'default nil :height 200)
@@ -37,33 +44,6 @@
(setq-default display-fill-column-indicator-column 79) ; 80 column indicator - Emacs columns are 0-based... (setq-default display-fill-column-indicator-column 79) ; 80 column indicator - Emacs columns are 0-based...
(global-display-fill-column-indicator-mode 1) (global-display-fill-column-indicator-mode 1)
(unless (package-installed-p 'lsp-mode)
(package-install 'lsp-mode))
(use-package lsp-mode
:init
:config
:hook (;; replace XXX-mode with concrete major-mode(e. g. python-mode)
(c-mode . lsp)
(c++-mode . lsp)
(python-mode . lsp))
:commands lsp)
;; company
(unless (package-installed-p 'company)
(package-install 'company))
(use-package company
:after lsp-mode
:hook (prog-mode . company-mode)
:bind (:map company-active-map
("<tab>" . company-complete-selection))
(:map lsp-mode-map
("<tab>" . company-indent-or-complete-common))
:custom
(company-minimum-prefix-length 1)
(company-idle-delay 0.0))
(setq neo-theme (if (display-graphic-p) 'icons)) (setq neo-theme (if (display-graphic-p) 'icons))
;; Use keybindings ;; Use keybindings
@@ -72,18 +52,6 @@
:bind (:map markdown-mode-command-map :bind (:map markdown-mode-command-map
("g" . grip-mode))) ("g" . grip-mode)))
;; emacs gdb
(fmakunbound 'gdb)
(fmakunbound 'gdb-enable-debug)
(unless (package-installed-p 'gdb-mi)
(package-install 'gdb-mi))
(use-package gdb-mi
:init
(fmakunbound 'gdb)
(fmakunbound 'gdb-enable-debug))
;; neotree ;; neotree
(unless (package-installed-p 'neotree) (unless (package-installed-p 'neotree)
(package-install 'neotree) (package-install 'neotree)
@@ -108,6 +76,10 @@
(require 'evil) (require 'evil)
(evil-mode 1) (evil-mode 1)
;; exwm
(unless (package-installed-p 'exwm)
(package-install 'exwm))
(defun my-untabify-all-lines () (defun my-untabify-all-lines ()
"Select all lines in the buffer and run 'untabify' on them." "Select all lines in the buffer and run 'untabify' on them."
(interactive) (interactive)
@@ -124,56 +96,15 @@
(add-to-list 'load-path "~/.emacs.d/lisp") (add-to-list 'load-path "~/.emacs.d/lisp")
(load "site-start.d/epitech-init.el") (load "site-start.d/epitech-init.el")
;; example configuration for mu4e
(require 'mu4e)
;; use mu4e for e-mail in emacs
(setq mail-user-agent 'mu4e-user-agent)
;; the next are relative to the root maildir
;; (see `mu info`).
;; instead of strings, they can be functions too, see
;; their docstring or the chapter 'Dynamic folders'
(setq mu4e-sent-folder "/sent"
mu4e-drafts-folder "/drafts"
mu4e-trash-folder "/trash")
;; the maildirs you use frequently; access them with 'j' ('jump')
(setq mu4e-maildir-shortcuts
'((:maildir "/archive" :key ?a)
(:maildir "/inbox" :key ?i)
(:maildir "/work" :key ?w)
(:maildir "/sent" :key ?s)))
;; the headers to show in the headers list -- a pair of a field
;; and its width, with `nil' meaning 'unlimited'
;; (better only use that for the last field.
;; These are the defaults:
(setq mu4e-headers-fields
'( (:date . 25) ;; alternatively, use :human-date
(:flags . 6)
(:from . 22)
(:subject . nil))) ;; alternatively, use :thread-subject
(add-to-list 'mu4e-bookmarks
;; ':favorite t' i.e, use this one for the modeline
'(:query "maildir:/inbox" :name "Inbox" :key ?i :favorite t))
;; program to get mail; alternatives are 'fetchmail', 'getmail'
;; isync or your own shellscript. called when 'U' is pressed in
;; main view.
;; don't keep message buffers around
(setq message-kill-buffer-on-exit t)
(setq-default indent-tabs-mode nil) (setq-default indent-tabs-mode nil)
(custom-set-variables (custom-set-variables
;; custom-set-variables was added by Custom. ;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful. ;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance. ;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right. ;; If there is more than one, they won't work right.
'(inhibit-startup-screen t)
'(package-selected-packages '(package-selected-packages
'(company simpleclip rust-mode org-cliplink neotree magit gruber-darker-theme go-mode evil dash-functional all-the-icons))) '(benchmark-init company simpleclip rust-mode org-cliplink neotree magit gruber-darker-theme go-mode evil dash-functional all-the-icons)))
(custom-set-faces (custom-set-faces
;; custom-set-faces was added by Custom. ;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful. ;; If you edit it by hand, you could mess it up, so be careful.

View File

View File

@@ -1,75 +0,0 @@
;;; basm-mode.el --- Major Mode for editing BASM Assembly Code -*- lexical-binding: t -*-
;; Copyright (C) 2021 Alexey Kutepov <reximkut@gmail.com>
;; Author: Alexey Kutepov <reximkut@gmail.com>
;; URL: http://github.com/tsoding/bm
;; Permission is hereby granted, free of charge, to any person
;; obtaining a copy of this software and associated documentation
;; files (the "Software"), to deal in the Software without
;; restriction, including without limitation the rights to use, copy,
;; modify, merge, publish, distribute, sublicense, and/or sell copies
;; of the Software, and to permit persons to whom the Software is
;; furnished to do so, subject to the following conditions:
;; The above copyright notice and this permission notice shall be
;; included in all copies or substantial portions of the Software.
;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
;; BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
;; ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
;; CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
;; SOFTWARE.
;;; Commentary:
;;
;; Major Mode for editing BASM Assembly Code. The language for a
;; simple Virtual Machine.
(defconst basm-mode-syntax-table
(with-syntax-table (copy-syntax-table)
(modify-syntax-entry ?\; "<")
(modify-syntax-entry ?\n ">")
(modify-syntax-entry ?\" "\"")
(modify-syntax-entry ?\' "\"")
(syntax-table))
"Syntax table for `basm-mode'.")
(eval-and-compile
(defconst basm-instructions
'("nop" "push" "drop" "dup"
"plusi" "minusi" "multi" "divi" "modi"
"multu" "divu" "modu"
"plusf" "minusf" "multf" "divf"
"jmp" "jmp_if" "halt" "swap" "not"
"eqi" "gei" "gti" "lei" "lti" "nei"
"equ" "geu" "gtu" "leu" "ltu" "neu"
"eqf" "gef" "gtf" "lef" "ltf" "nef"
"ret" "call" "native"
"andb" "orb" "xor" "shr" "shl" "notb"
"read8u" "read16u" "read32u" "read64u"
"read8i" "read16i" "read32i" "read64i"
"write8" "write16" "write32" "write64"
"i2f" "u2f" "f2i" "f2u")))
(defconst basm-highlights
`(("%[[:word:]_]+" . font-lock-preprocessor-face)
("[[:word:]_]+\\:" . font-lock-constant-face)
(,(regexp-opt basm-instructions 'symbols) . font-lock-keyword-face)))
;;;###autoload
(define-derived-mode basm-mode fundamental-mode "basm"
"Major Mode for editing BASM Assembly Code."
(setq font-lock-defaults '(basm-highlights))
(set-syntax-table basm-mode-syntax-table))
;;;###autoload
(add-to-list 'auto-mode-alist '("\\.\\(b\\|h\\)asm\\'" . basm-mode))
(provide 'basm-mode)
;;; basm-mode.el ends here

View File

@@ -1,214 +0,0 @@
;; jai-mode.el - very basic jai mode
(require 'cl)
(require 'rx)
(require 'js)
(require 'compile)
(defconst jai-mode-syntax-table
(let ((table (make-syntax-table)))
(modify-syntax-entry ?\" "\"" table)
(modify-syntax-entry ?\\ "\\" table)
;; additional symbols
(modify-syntax-entry ?_ "w" table)
(modify-syntax-entry ?' "." table)
(modify-syntax-entry ?: "." table)
(modify-syntax-entry ?+ "." table)
(modify-syntax-entry ?- "." table)
(modify-syntax-entry ?% "." table)
(modify-syntax-entry ?& "." table)
(modify-syntax-entry ?| "." table)
(modify-syntax-entry ?^ "." table)
(modify-syntax-entry ?! "." table)
(modify-syntax-entry ?$ "/" table)
(modify-syntax-entry ?= "." table)
(modify-syntax-entry ?< "." table)
(modify-syntax-entry ?> "." table)
(modify-syntax-entry ?? "." table)
;; Modify some syntax entries to allow nested block comments
(modify-syntax-entry ?/ ". 124b" table)
(modify-syntax-entry ?* ". 23n" table)
(modify-syntax-entry ?\n "> b" table)
(modify-syntax-entry ?\^m "> b" table)
table))
(defconst jai-builtins
'("cast" "it" "type_info" "size_of"))
(defconst jai-keywords
'("if" "ifx" "else" "then" "while" "for" "switch" "case" "struct" "enum"
"return" "new" "remove" "continue" "break" "defer" "inline" "no_inline"
"using" "SOA"))
(defconst jai-constants
'("null" "true" "false"))
(defconst jai-typenames
'("int" "u64" "u32" "u16" "u8"
"s64" "s32" "s16" "s8" "float"
"float32" "float64" "string"
"bool"))
(defun jai-wrap-word-rx (s)
(concat "\\<" s "\\>"))
(defun jai-keywords-rx (keywords)
"build keyword regexp"
(jai-wrap-word-rx (regexp-opt keywords t)))
(defconst jai-hat-type-rx (rx (group (and "^" (1+ word)))))
(defconst jai-dollar-type-rx (rx (group "$" (or (1+ word) (opt "$")))))
(defconst jai-number-rx
(rx (and
symbol-start
(or (and (+ digit) (opt (and (any "eE") (opt (any "-+")) (+ digit))))
(and "0" (any "xX") (+ hex-digit)))
(opt (and (any "_" "A-Z" "a-z") (* (any "_" "A-Z" "a-z" "0-9"))))
symbol-end)))
(defconst jai-font-lock-defaults
`(
;; Keywords
(,(jai-keywords-rx jai-keywords) 1 font-lock-keyword-face)
;; single quote characters
("\\('[[:word:]]\\)\\>" 1 font-lock-constant-face)
;; Variables
(,(jai-keywords-rx jai-builtins) 1 font-lock-variable-name-face)
;; Constants
(,(jai-keywords-rx jai-constants) 1 font-lock-constant-face)
;; Hash directives
("#\\w+" . font-lock-preprocessor-face)
;; At directives
("@\\w+" . font-lock-preprocessor-face)
;; Strings
("\\\".*\\\"" . font-lock-string-face)
;; Numbers
(,(jai-wrap-word-rx jai-number-rx) . font-lock-constant-face)
;; Types
(,(jai-keywords-rx jai-typenames) 1 font-lock-type-face)
(,jai-hat-type-rx 1 font-lock-type-face)
(,jai-dollar-type-rx 1 font-lock-type-face)
("---" . font-lock-constant-face)
))
;; add setq-local for older emacs versions
(unless (fboundp 'setq-local)
(defmacro setq-local (var val)
`(set (make-local-variable ',var) ,val)))
(defconst jai--defun-rx "\(.*\).*\{")
(defmacro jai-paren-level ()
`(car (syntax-ppss)))
(defun jai-line-is-defun ()
"return t if current line begins a procedure"
(interactive)
(save-excursion
(beginning-of-line)
(let (found)
(while (and (not (eolp)) (not found))
(if (looking-at jai--defun-rx)
(setq found t)
(forward-char 1)))
found)))
(defun jai-beginning-of-defun (&optional count)
"Go to line on which current function starts."
(interactive)
(let ((orig-level (jai-paren-level)))
(while (and
(not (jai-line-is-defun))
(not (bobp))
(> orig-level 0))
(setq orig-level (jai-paren-level))
(while (>= (jai-paren-level) orig-level)
(skip-chars-backward "^{")
(backward-char))))
(if (jai-line-is-defun)
(beginning-of-line)))
(defun jai-end-of-defun ()
"Go to line on which current function ends."
(interactive)
(let ((orig-level (jai-paren-level)))
(when (> orig-level 0)
(jai-beginning-of-defun)
(end-of-line)
(setq orig-level (jai-paren-level))
(skip-chars-forward "^}")
(while (>= (jai-paren-level) orig-level)
(skip-chars-forward "^}")
(forward-char)))))
(defalias 'jai-parent-mode
(if (fboundp 'prog-mode) 'prog-mode 'fundamental-mode))
;; imenu hookup
(add-hook 'jai-mode-hook
(lambda ()
(setq imenu-generic-expression
'(
("type" "^\\(.*:*.*\\) : " 1)
("function" "^\\(.*\\) :: " 1)
("struct" "^\\(.*\\) *:: *\\(struct\\)\\(.*\\){" 1)
)
)
)
)
;; NOTE: taken from the scala-indent package and modified for Jai.
;; Still uses the js-indent-line as a base, which will have to be
;; replaced when the language is more mature.
(defun jai--indent-on-parentheses ()
(when (and (= (char-syntax (char-before)) ?\))
(= (save-excursion (back-to-indentation) (point)) (1- (point))))
(js-indent-line)))
(defun jai--add-self-insert-hooks ()
(add-hook 'post-self-insert-hook
'jai--indent-on-parentheses)
)
;;;###autoload
(define-derived-mode jai-mode jai-parent-mode "Jai"
:syntax-table jai-mode-syntax-table
:group 'jai
(setq bidi-paragraph-direction 'left-to-right)
(setq-local require-final-newline mode-require-final-newline)
(setq-local parse-sexp-ignore-comments t)
(setq-local comment-start-skip "\\(//+\\|/\\*+\\)\\s *")
(setq-local comment-start "/*")
(setq-local comment-end "*/")
(setq-local indent-line-function 'js-indent-line)
(setq-local font-lock-defaults '(jai-font-lock-defaults))
(setq-local beginning-of-defun-function 'jai-beginning-of-defun)
(setq-local end-of-defun-function 'jai-end-of-defun)
;; add indent functionality to some characters
(jai--add-self-insert-hooks)
(font-lock-fontify-buffer))
;;;###autoload
(add-to-list 'auto-mode-alist '("\\.jai\\'" . jai-mode))
(defconst jai--error-regexp
"^\\([^ :]+\\):\\([0-9]+\\),\\([0-9]+\\):")
(push `(jai ,jai--error-regexp 1 2 3 2) compilation-error-regexp-alist-alist)
(push 'jai compilation-error-regexp-alist)
(provide 'jai-mode)

View File

@@ -1,86 +0,0 @@
;;; noq-mode.el --- Major Mode for editing Noq source code -*- lexical-binding: t -*-
;; Copyright (C) 2021 Alexey Kutepov <reximkut@gmail.com>
;; Author: Alexey Kutepov <reximkut@gmail.com>
;; URL: https://github.com/tsoding/noq
;; Permission is hereby granted, free of charge, to any person
;; obtaining a copy of this software and associated documentation
;; files (the "Software"), to deal in the Software without
;; restriction, including without limitation the rights to use, copy,
;; modify, merge, publish, distribute, sublicense, and/or sell copies
;; of the Software, and to permit persons to whom the Software is
;; furnished to do so, subject to the following conditions:
;; The above copyright notice and this permission notice shall be
;; included in all copies or substantial portions of the Software.
;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
;; BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
;; ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
;; CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
;; SOFTWARE.
;;; Commentary:
;;
;; Major Mode for editing Noq source code
(defconst noq-mode-syntax-table
(with-syntax-table (copy-syntax-table)
;; Python-style comments
(modify-syntax-entry ?# "<")
(modify-syntax-entry ?\n ">")
;; C/C++ style comments
(modify-syntax-entry ?/ ". 124b")
(modify-syntax-entry ?* ". 23")
(modify-syntax-entry ?\n "> b")
;; (modify-syntax-entry ?/ ". 124b")
;; (modify-syntax-entry ?* ". 23")
;; (modify-syntax-entry ?\n "> b")
;; Chars are the same as strings
(modify-syntax-entry ?' "\"")
(syntax-table))
"Syntax table for `noq-mode'.")
(eval-and-compile
(defconst noq-apply-strategies
'("all" "deep")))
(eval-and-compile
(defconst noq-keywords
'("undo" "quit" "delete" "load" "save")))
(defconst noq-highlights
`((
;; Keywords
,(regexp-opt noq-keywords 'words) . 'font-lock-keyword-face)
;; `Apply` strategies
(,(format "\\(%s\\)[\t ]*|" (mapconcat 'regexp-quote noq-apply-strategies "\\|"))
1 'font-lock-type-face)
("\\([0-9]+\\)[\t ]*|" 1 'font-lock-type-face)
;; Variables
("\\(^\\|[^a-zA-Z0-9_]\\)\\([_A-Z][_a-zA-Z0-9]*\\)" 2 'font-lock-variable-name-face)
;; Functor names
("\\([^\n\| ]*\\)[\t ]*::" 1 'font-lock-function-name-face)
))
;;;###autoload
(define-derived-mode noq-mode prog-mode "noq"
"Major Mode for editing Noq source code."
:syntax-table noq-mode-syntax-table
(setq font-lock-defaults '(noq-highlights))
(setq-local comment-start "// "))
;;;###autoload
(add-to-list 'auto-mode-alist '("\\.noq\\'" . noq-mode))
(provide 'noq-mode)
;;; noq-mode.el ends here

View File

@@ -1,26 +0,0 @@
(require 'subr-x)
(defvar nothings-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)
table))
(defun nothings-font-lock-keywords ()
(list
`("# *[a-zA-Z0-9_]+" . font-lock-preprocessor-face)
`("#.*include \\(\\(<\\|\"\\).*\\(>\\|\"\\)\\)" . (1 font-lock-string-face))))
(define-derived-mode nothings-mode prog-mode "Nothings"
"Simple major mode for editing C files."
:syntax-table nothings-mode-syntax-table
(setq-local font-lock-defaults '(nothings-font-lock-keywords))
(setq-local comment-start "//"))
(provide 'nothings-mode)

View File

@@ -1,70 +0,0 @@
;;; porth-mode.el --- Major Mode for editing Porth source code -*- lexical-binding: t -*-
;; Copyright (C) 2021 Alexey Kutepov <reximkut@gmail.com>
;; Author: Alexey Kutepov <reximkut@gmail.com>
;; URL: https://github.com/tsoding/porth
;; Permission is hereby granted, free of charge, to any person
;; obtaining a copy of this software and associated documentation
;; files (the "Software"), to deal in the Software without
;; restriction, including without limitation the rights to use, copy,
;; modify, merge, publish, distribute, sublicense, and/or sell copies
;; of the Software, and to permit persons to whom the Software is
;; furnished to do so, subject to the following conditions:
;; The above copyright notice and this permission notice shall be
;; included in all copies or substantial portions of the Software.
;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
;; BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
;; ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
;; CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
;; SOFTWARE.
;;; Commentary:
;;
;; Major Mode for editing Porth source code. It's Forth but written in Python.
;; TODO: jump to the opposite side of the blocks with C-M-f and C-M-b
;; I think tuareg-mode can do that with similar end-like block, we try
;; to steal their approach
;; TODO: color the names of definitions in const, memory, proc, etc differently
(defconst porth-mode-syntax-table
(with-syntax-table (copy-syntax-table)
;; C/C++ style comments
(modify-syntax-entry ?/ ". 124b")
(modify-syntax-entry ?* ". 23")
(modify-syntax-entry ?\n "> b")
;; Chars are the same as strings
(modify-syntax-entry ?' "\"")
(syntax-table))
"Syntax table for `porth-mode'.")
(eval-and-compile
(defconst porth-keywords
'("if" "else" "while" "do" "include" "memory" "proc"
"const" "end" "offset" "reset" "assert" "in" "inline"
"here" "addr-of" "call-like" "let" "peek" "return"
"var" "cast" "struct")))
(defconst porth-highlights
`((,(regexp-opt porth-keywords 'symbols) . font-lock-keyword-face)))
;;;###autoload
(define-derived-mode porth-mode prog-mode "porth"
"Major Mode for editing Porth source code."
:syntax-table porth-mode-syntax-table
(setq font-lock-defaults '(porth-highlights))
(setq-local comment-start "// "))
;;;###autoload
(add-to-list 'auto-mode-alist '("\\.porth\\'" . porth-mode))
(provide 'porth-mode)
;;; porth-mode.el ends here

View File

@@ -1,99 +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)))
;;; TODO: try to replace simpc--space-prefix-len with current-indentation
(defun simpc--space-prefix-len (line)
(- (length line)
(length (string-trim-left line))))
(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--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))
(cond
((and (string-suffix-p "{" prev-line)
(string-prefix-p "}" (string-trim-left cur-line)))
(simpc--space-prefix-len prev-line))
((string-suffix-p "{" prev-line)
(+ (simpc--space-prefix-len prev-line) indent-len))
((string-prefix-p "}" (string-trim-left cur-line))
(max (- (simpc--space-prefix-len prev-line) indent-len) 0))
(t (simpc--space-prefix-len prev-line)))))
;;; TODO: customizable indentation (amount of spaces, tabs, etc)
(defun simpc-indent-line ()
(interactive)
(when (not (bobp))
(let* ((current-indentation
(simpc--space-prefix-len (thing-at-point 'line t)))
(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)

View File

@@ -1,149 +0,0 @@
;;; TODO(c3bdae31-4329-4217-98a0-743b9dcbb6d2): extract autocommit into a separate package
;;;
;;; Once e266bfaa-2a01-4881-9e7f-ce2c592f7cdd is done, I think we can do that.
(defvar rc/autocommit-local-locks
(make-hash-table :test 'equal))
(defun rc/file-truename-nilable (filename)
(when filename
(file-truename filename)))
(defun rc/autocommit--id ()
(let ((id (-> default-directory
(locate-dominating-file ".git")
(rc/file-truename-nilable))))
(when (not id)
(error "%s is not inside of a git repository" default-directory))
(unless (gethash id rc/autocommit-local-locks)
(puthash id nil rc/autocommit-local-locks))
id))
(defun rc/autocommit--get-lock (lock)
(-> (rc/autocommit--id)
(gethash rc/autocommit-local-locks)
(plist-get lock)))
(defun rc/autocommit--set-lock (lock value)
(puthash (rc/autocommit--id)
(-> (rc/autocommit--id)
(gethash rc/autocommit-local-locks)
(plist-put lock value))
rc/autocommit-local-locks))
(defun rc/autocommit--toggle-lock (lock)
(-> lock
(rc/autocommit--get-lock)
(not)
(rc/autocommit--set-lock)))
(defun rc/autocommit--create-dir-locals (file-name)
(write-region "((nil . ((eval . (rc/autocommit-dir-locals)))))"
nil file-name))
(defun rc/y-or-n-if (predicate question action)
(when (or (not (funcall predicate))
(y-or-n-p question))
(funcall action)))
;;; TODO(4229cf9a-4768-4f5e-aca1-865256c64a23): rc/autocommit-init-dir should modify dir locals file on AST level
;;;
;;; Right know it just overrides .dir-locals file on text level. I
;;; want it to
;;; - read .dir-locals,
;;; - parse the assoc list,
;;; - check if there is already autocommit stuff
;;; - add autocommit stuff to the assoc list if needed
;;; - and write it back to the file
;;;
;;; That will enable us with modifying dir locals that contains custom
;;; stuff unrelated to autocommit
(defun rc/autocommit-init-dir (&optional dir)
"Initialize autocommit folder."
(interactive "DAutocommit directory: ")
(let* ((autocommit-dir (if dir dir default-directory))
(file-name (concat autocommit-dir
dir-locals-file)))
(rc/y-or-n-if (-partial #'file-exists-p file-name)
(format "%s already exists. Replace it?" file-name)
(-partial #'rc/autocommit--create-dir-locals file-name))))
(defun rc/autocommit-dir-locals ()
"The function that has to be put into the .dir-locals.el file
of the autocommit folder as evaluated for any mode."
(interactive)
(auto-revert-mode 1)
(rc/autopull-changes)
(add-hook 'after-save-hook
'rc/autocommit-changes
nil 'make-it-local))
;;; TODO: rc/toggle-autocommit-offline doesn't work correctly
;;;
;;; It should toggle offline for all of the folders at once
(defun rc/toggle-autocommit-offline ()
"Toggle between OFFLINE and ONLINE modes.
Autocommit can be in two modes: OFFLINE and ONLINE. When ONLINE
rc/autocommit-changes does `git commit && git push'. When OFFLINE
rc/autocommit does only `git commit'."
(interactive)
(rc/autocommit--toggle-lock 'autocommit-offline)
(if (rc/autocommit--get-lock 'autocommit-offline)
(message "[OFFLINE] Autocommit Mode")
(message "[ONLINE] Autocommit Mode")))
(defun rc/autopull-changes ()
"Pull the recent changes.
Should be invoked once before working with the content under
autocommit. Usually put into the dir locals file."
(interactive)
(when (not (rc/autocommit--get-lock 'autopull-lock))
(rc/autocommit--set-lock 'autopull-lock t)
(if (rc/autocommit--get-lock 'autocommit-offline)
(message "[OFFLINE] NOT Syncing the Agenda")
(if (y-or-n-p (format "Sync the Agenda? [%s]" (rc/autocommit--id)))
(progn
(message (format "Syncing the Agenda [%s]" (rc/autocommit--id)))
(shell-command "git pull"))
(progn
(rc/autocommit--set-lock 'autocommit-offline t)
(message (format "[OFFLINE] NOT Syncing the Agenda [%s]"
(rc/autocommit--id))))))))
(defun rc/autocommit-changes ()
"Commit all of the changes under the autocommit folder.
Should be invoked each time a change is made. Usually put into
dir locals file."
(interactive)
(if (rc/autocommit--get-lock 'autocommit-lock)
(rc/autocommit--set-lock 'autocommit-changed t)
(rc/autocommit--set-lock 'autocommit-lock t)
(rc/autocommit--set-lock 'autocommit-changed nil)
(set-process-sentinel (rc/run-commit-process (rc/autocommit--id))
(-partial 'rc/autocommit-beat (rc/autocommit--id)))))
(defun rc/run-commit-process (autocommit-directory)
(let ((default-directory autocommit-directory))
(let ((autocommit-message (format-time-string "Autocommit %s")))
(start-process-shell-command
(format "Autocommit-%s" autocommit-directory)
(format "*Autocommit-%s*" autocommit-directory)
(format (if (rc/autocommit--get-lock 'autocommit-offline)
"git add -A && git commit -m \"%s\""
"git add -A && git commit -m \"%s\" && git push origin master")
autocommit-message)))))
(defun rc/autocommit-beat (autocommit-directory process event)
(let ((default-directory autocommit-directory))
(message (if (rc/autocommit--get-lock 'autocommit-offline)
"[OFFLINE] Autocommit: %s"
"Autocommit: %s")
event)
(if (not (rc/autocommit--get-lock 'autocommit-changed))
(rc/autocommit--set-lock 'autocommit-lock nil)
(rc/autocommit--set-lock 'autocommit-changed nil)
(set-process-sentinel (rc/run-commit-process autocommit-directory)
(-partial 'rc/autocommit-beat autocommit-directory)))))

View File

@@ -1,134 +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
compilation-scroll-output t
visible-bell (equal system-type 'windows-nt))
(defun rc/colorize-compilation-buffer ()
(toggle-read-only)
(ansi-color-apply-on-region compilation-filter-start (point))
(toggle-read-only))
(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)

View File

@@ -1,68 +0,0 @@
(global-set-key (kbd "C-x a") 'org-agenda)
(global-set-key (kbd "C-c C-x j") #'org-clock-jump-to-current-clock)
(setq org-agenda-files (list "~/Documents/Agenda/"))
(setq org-export-backends '(md))
(defun rc/org-increment-move-counter ()
(interactive)
(defun default (x d)
(if x x d))
(let* ((point (point))
(move-counter-name "MOVE_COUNTER")
(move-counter-value (-> (org-entry-get point move-counter-name)
(default "0")
(string-to-number)
(1+))))
(org-entry-put point move-counter-name
(number-to-string move-counter-value)))
nil)
(defun rc/org-get-heading-name ()
(nth 4 (org-heading-components)))
(defun rc/org-kill-heading-name-save ()
(interactive)
(let ((heading-name (rc/org-get-heading-name)))
(kill-new heading-name)
(message "Kill \"%s\"" heading-name)))
(global-set-key (kbd "C-x p w") 'rc/org-kill-heading-name-save)
(setq org-agenda-custom-commands
'(("u" "Unscheduled" tags "+personal-SCHEDULED={.+}-DEADLINE={.+}/!+TODO"
((org-agenda-sorting-strategy '(priority-down))))
("p" "Personal" ((agenda "" ((org-agenda-tag-filter-preset (list "+personal"))))))
("w" "Work" ((agenda "" ((org-agenda-tag-filter-preset (list "+work"))))))
))
;;; org-cliplink
(rc/require 'org-cliplink)
(global-set-key (kbd "C-x p i") 'org-cliplink)
(defun rc/cliplink-task ()
(interactive)
(org-cliplink-retrieve-title
(substring-no-properties (current-kill 0))
'(lambda (url title)
(insert (if title
(concat "* TODO " title
"\n [[" url "][" title "]]")
(concat "* TODO " url
"\n [[" url "]]"))))))
(global-set-key (kbd "C-x p t") 'rc/cliplink-task)
;;; org-capture
(setq org-capture-templates
'(("p" "Capture task" entry (file "~/Documents/Agenda/Tasks.org")
"* TODO %?\n SCHEDULED: %t\n")
("K" "Cliplink capture task" entry (file "~/Documents/Agenda/Tasks.org")
"* TODO %(org-cliplink-capture) \n SCHEDULED: %t\n" :empty-lines 1)))
(define-key global-map "\C-cc" 'org-capture)

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)

View File

@@ -1 +0,0 @@
c-mode

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# name: catch (...) { ... }
# key: catch
# --
catch ($1) {
$0
}

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# name: for (...: ...) { ... }
# key: fore
# --
for ($1: $2) {
$0
}

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# name: namespace Namespace
# key: ns
# --
namespace ${1:Namespace} {
$0
} // namespace $1

View File

@@ -1,10 +0,0 @@
# -*- mode: snippet -*-
# name: #ifndef XXX; #define XXX; #endif
# key: once
# --
#ifndef ${1:`(upcase (replace-regexp-in-string "\\." "_" (file-name-nondirectory (buffer-file-name))))`_}
#define $1
$0
#endif // $1

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# name: qdebug
# key: qdebug
# --
qDebug() << "----------------------------------------";
qDebug() << "$0";
qDebug() << "----------------------------------------";

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# name: try { ... }
# key: try
# --
try {
$0
}

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: using namespace std;
# key: uns
# --
using namespace std;

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: std::vector<T>
# key: vec
# --
std::vector<$1> $2;$0

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# name: { ... }
# key: {
# --
{
$0
}

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# name: else if (...) { ... }
# key: elif
# --
else if (${1:condition}) {
$0
}

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# name: else { ... }
# key: else
# --
else {
$0
}

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# name: for (...; ...; ...) { ... }
# key: for
# --
for (${1:init}; ${2:condition}; ${3:increment}) {
$0
}

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# name: if (...) { ... }
# key: if
# --
if (${1:condition}) {
$0
}

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# name: while (...) { ... }
# key: while
# --
while (${1:condition}) {
$0
}

View File

@@ -1 +0,0 @@
c-like-syntax

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: #include <...>
# key: inc
# --
#include <$0>

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: #include "..."
# key: incq
# --
#include "$0"

View File

@@ -1,9 +0,0 @@
# -*- mode: snippet -*-
# name: int main(argc, argv) { ... }
# key: main
# --
int main(int argc, char *argv[])
{
$0
return 0;
}

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: background-color: ...
# key: bg
# --
background-color: #${1:DDD};

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: background-image: ...
# key: bgi
# --
background-image: url($1);

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: border size style color
# key: bor
# --
border: ${1:1px} ${2:solid} #${3:999};

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: clear: ...
# key: cl
# --
clear: $1;

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: display: block
# key: dispb
# --
display: block;

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: display: inline
# key: dispi
# --
display: inline;

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: display: none
# key: dispn
# --
display: none;

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: font-family: ...
# key: ff
# --
font-family: $1;

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: font-size: ...
# key: fs
# --
font-size: ${12px};

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: margin: ...
# key: mar
# --
margin: $1;

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: margin-bottom: ...
# key: marb
# --
margin-bottom: $1;

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: margin-left: ...
# key: marl
# --
margin-left: $1;

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: margin-right: ...
# key: marr
# --
margin-right: $1;

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: margin-top: ...
# key: mart
# --
margin-top: $1;

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: padding: ...
# key: pad
# --
padding: $1;

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: padding-bottom: ...
# key: padb
# --
padding-bottom: $1;

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: padding-left: ...
# key: padl
# --
padding-left: $1;

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: padding-right: ...
# key: padr
# --
padding-right: $1;

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: padding-top: ...
# key: padt
# --
padding-top: $1;

View File

@@ -1 +0,0 @@
c-like-syntax

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: immutable
# key: imm
# --
immutable $0

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: import <...>;
# key: imp
# --
import $0;

View File

@@ -1,42 +0,0 @@
# -*- mode: snippet -*-
# name: emacs lisp module skeleton
# key: emacs-lisp-module
# --
;;; ${1:`(file-name-nondirectory (buffer-file-name))`} --- ${2:Package Description} -*- lexical-binding: t -*-
;; Copyright (C) `(format-time-string "%Y" (current-time))` ${3:Alexey Kutepov <reximkut@gmail.com>}
;; Author: $3
;; URL: $4
;; Permission is hereby granted, free of charge, to any person
;; obtaining a copy of this software and associated documentation
;; files (the "Software"), to deal in the Software without
;; restriction, including without limitation the rights to use, copy,
;; modify, merge, publish, distribute, sublicense, and/or sell copies
;; of the Software, and to permit persons to whom the Software is
;; furnished to do so, subject to the following conditions:
;; The above copyright notice and this permission notice shall be
;; included in all copies or substantial portions of the Software.
;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
;; BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
;; ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
;; CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
;; SOFTWARE.
;;; Commentary:
;; $5
;;; Code:
$0
(provide '${6:`(file-name-sans-extension (file-name-nondirectory (buffer-file-name)))`})
;;; $1 ends here

View File

@@ -1,41 +0,0 @@
# -*- mode: snippet -*-
# name: pacmacs module skeleton
# key: pacmacs-module
# --
;;; ${1:`(file-name-nondirectory (buffer-file-name))`} --- Pacman for Emacs -*- lexical-binding: t -*-
;; Copyright (C) `(format-time-string "%Y" (current-time))` Codingteam
;; Author: Codingteam <codingteam@conference.jabber.ru>
;; Maintainer: Alexey Kutepov <reximkut@gmail.com>
;; URL: http://github.com/rexim/pacmacs.el
;; Permission is hereby granted, free of charge, to any person
;; obtaining a copy of this software and associated documentation
;; files (the "Software"), to deal in the Software without
;; restriction, including without limitation the rights to use, copy,
;; modify, merge, publish, distribute, sublicense, and/or sell copies
;; of the Software, and to permit persons to whom the Software is
;; furnished to do so, subject to the following conditions:
;; The above copyright notice and this permission notice shall be
;; included in all copies or substantial portions of the Software.
;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
;; BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
;; ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
;; CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
;; SOFTWARE.
;;; Commentary:
;; $2
;;; Code:
$0
;;; $1 ends here

View File

@@ -1 +0,0 @@
c-like-syntax

View File

@@ -1,24 +0,0 @@
# -*- mode: snippet -*-
# name: mit
# key: mit
# --
Copyright `(format-time-string "%Y")` Alexey Kutepov <reximkut@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# name: sb
# key: sb
# expand-env: ((yas-indent-line 'fixed))
# --
${1:$(make-string (+ 2 (string-width yas-text)) ? )}SMOL
${1:$(make-string (+ 2 (string-width yas-text)) ? )}BREK
($1 minutes)

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# name: tag
# key: tag
# --
<$1>
$0
</$1>

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: tagi
# key: tagi
# --
<$1>$0</$1>

View File

@@ -1 +0,0 @@
c-like-syntax

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: public static
# key: ps
# --
public static

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: public static void
# key: psv
# --
public static void

View File

@@ -1 +0,0 @@
c-like-syntax

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# name: item
# key: item
# --
${1:Item} {
$0
} // $1

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# name: \begin{environment} ... \end{environment}
# key: begin
# --
\begin{${1:environment}}
$0
\end{$1}

View File

@@ -1,10 +0,0 @@
# -*- mode: snippet -*-
# name: make
# key: make
# expand-env: ((yas-indent-line 'fixed))
# --
CFLAGS=-Wall -Wextra -std=c11 -pedantic
LIBS=
$1: $2
$(CC) $(CFLAGS) -o $1 $2 $(LIBS)

View File

@@ -1,9 +0,0 @@
# -*- mode: snippet -*-
# name: todo
# key: todo
# type: command
# binding: C-x t
# --
(if (region-active-p)
(yas-expand-snippet "<!--TODO:-->`yas-selected-text`<!--$0-->")
(yas-expand-snippet "<!--TODO: $0 -->"))

View File

@@ -1 +0,0 @@
c-like-syntax

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# name: <body>...</body>
# key: body
# --
<body>
$0
</body>

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# name: <div class="...">\n...\n</div>
# key: div
# --
<div class="$1">
$0
</div>

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# name: <head>...</head>
# key: head
# --
<head>
$0
</head>

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# name: <html xmlns="...">...</html>
# key: html
# --
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="${1:en}" lang="${2:en}">
$0
</html>

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: <link stylesheet="..." />
# key: link
# --
<link rel="${1:stylesheet}" href="${2:url}" type="${3:text/css}" media="${4:screen}" />

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: <meta http-equiv="..." content="..." />
# key: meta
# --
<meta http-equiv="${1:Content-Type}" content="${2:text/html; charset=UTF-8}" />

View File

@@ -1,17 +0,0 @@
# -*- mode: snippet -*-
# name: <project>...</project>
# key: pom
# --
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>${1:me.rexim}</groupId>
<artifactId>${2:artifactId}</artifactId>
<version>${3:0.0.1-SNAPSHOT}</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: <script type="text/javascript" src="..."></title>
# key: script
# --
<script type="text/javascript" src="$1"></script>

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: <span class="...">\n...\n</span>
# key: span
# --
<span class="$1">$0</span>

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# name: <tag>\n...\n</tag>
# key: tag
# --
<${1:tag}$2>
$0
</$1>

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: <tag>...</tag>
# key: tag
# --
<${1:tag}$2>$0</$1>

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: <tag />
# key: tag
# --
<${1:tag} $2/>$0

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: <title>...</title>
# key: title
# --
<title>$0</title>

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
# key: xml
# --
<?xml version="1.0" encoding="UTF-8" ?>

View File

@@ -1,43 +0,0 @@
# -*- mode: snippet -*-
# name: pomo table
# key: pomo
# --
|-------+-------+----------|
| start | type | duration |
|-------+-------+----------|
| | work | 20m |
| | break | 10m |
| | work | 20m |
| | break | 10m |
| | work | 20m |
| | break | 10m |
| | work | 20m |
| | break | 20m |
|-------+-------+----------|
| | work | 20m |
| | break | 10m |
| | work | 20m |
| | break | 10m |
| | work | 20m |
| | break | 10m |
| | work | 20m |
| | break | 20m |
|-------+-------+----------|
| | work | 20m |
| | break | 10m |
| | work | 20m |
| | break | 10m |
| | work | 20m |
| | break | 10m |
| | work | 20m |
| | break | 20m |
|-------+-------+----------|
| | work | 20m |
| | break | 10m |
| | work | 20m |
| | break | 10m |
| | work | 20m |
| | break | 10m |
| | work | 20m |
| | break | 20m |
|-------+-------+----------|

View File

@@ -1 +0,0 @@
c-like-syntax

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# name: foreach (...) { ... }
# key: fore
# --
foreach ($1) {
$0
}

View File

@@ -1,9 +0,0 @@
# -*- mode: snippet -*-
# name: main
# key: main
# --
include "std.porth"
proc main in
$0
end

View File

@@ -1,6 +0,0 @@
# -*- mode: snippet -*-
# name: ras
# key: ras
# --
here eputs ": Assertion Failed: $0" eputs
1 exit

View File

@@ -1,6 +0,0 @@
# -*- mode: snippet -*-
# name: todo
# key: todo
# --
here eputs ": TODO: $0" eputs
1 exit

View File

@@ -1,6 +0,0 @@
# -*- mode: snippet -*-
# name: unreach
# key: unreach
# --
here eputs ": unreachable: $0" eputs
69 exit

View File

@@ -1 +0,0 @@
c-like-syntax

View File

@@ -1 +0,0 @@
c-like-syntax

View File

@@ -1,9 +0,0 @@
# -*- mode: snippet -*-
# name: snippet snippet
# key: snip
# --
# -*- mode: snippet -*-
# name: $1
# key: ${2:`(file-name-nondirectory (file-name-sans-extension (buffer-file-name)))`}
# --
$0

View File

@@ -1 +0,0 @@
c-like-syntax

196
.emacs_lsp Executable file
View File

@@ -0,0 +1,196 @@
(require 'package)
(add-to-list 'package-archives '("gnu" . "https://elpa.gnu.org/packages/"))
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(add-to-list 'load-path "/usr/local/share/emacs/site-lisp/mu4e")
(package-initialize)
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(eval-and-compile
(setq use-package-always-ensure t
use-package-expand-minimally t))
(unless (package-installed-p 'benchmark-init)
(package-refresh-contents)
(package-install 'benchmark-init))
(require 'benchmark-init)
;; To disable collection of benchmark data after init is done.
(add-hook 'after-init-hook 'benchmark-init/deactivate)
;; shell
(global-set-key (kbd "C-c RET") (lambda () (interactive) (ansi-term "/bin/zsh")))
;; Look
(tool-bar-mode 0)
(menu-bar-mode 0)
(scroll-bar-mode 0)
(column-number-mode 1)
(show-paren-mode 1)
(electric-pair-mode 1)
(global-display-line-numbers-mode 1)
(setq display-line-numbers-type 'relative)
(set-face-attribute 'default nil :height 200)
(global-set-key (kbd "<escape>") 'keyboard-escape-quit)
;; Auto-refresh dired on file change
(add-hook 'dired-mode-hook 'auto-revert-mode)
(unless (package-installed-p 'gruvbox-theme)
(package-install 'gruvbox-theme))
(load-theme 'gruvbox-dark-soft t)
(setq-default display-fill-column-indicator-column 79) ; 80 column indicator - Emacs columns are 0-based...
(global-display-fill-column-indicator-mode 1)
(unless (package-installed-p 'lsp-mode)
(package-install 'lsp-mode))
(use-package lsp-mode
:init
:config
(add-hook 'lsp-mode-hook 'lsp-ui-mode)
:custom
;; what to use when checking on-save. "check" is default, I prefer clippy
(lsp-rust-analyzer-cargo-watch-command "clippy")
(lsp-eldoc-render-all t)
(lsp-idle-delay 0.6)
;; enable / disable the hints as you prefer:
(lsp-inlay-hint-enable t)
;; These are optional configurations. See https://emacs-lsp.github.io/lsp-mode/page/lsp-rust-analyzer/#lsp-rust-analyzer-display-chaining-hints for a full list
(lsp-rust-analyzer-display-lifetime-elision-hints-enable "skip_trivial")
(lsp-rust-analyzer-display-chaining-hints t)
(lsp-rust-analyzer-display-lifetime-elision-hints-use-parameter-names nil)
(lsp-rust-analyzer-display-closure-return-type-hints t)
(lsp-rust-analyzer-display-parameter-hints nil)
(lsp-rust-analyzer-display-reborrow-hints nil)
:hook (;; replace XXX-mode with concrete major-mode(e. g. python-mode)
(c-mode . lsp)
(python-mode . lsp))
:commands lsp)
(use-package lsp-ui
:ensure
:commands lsp-ui-mode
:custom
(lsp-ui-peek-always-show t)
(lsp-ui-sideline-show-hover t)
(lsp-ui-doc-enable nil))
;;https://robert.kra.hn/posts/rust-emacs-setup/
(use-package rustic
:ensure
:bind (:map rustic-mode-map
("M-j" . lsp-ui-imenu)
("M-?" . lsp-find-references)
("C-c C-c l" . flycheck-list-errors)
("C-c C-c a" . lsp-execute-code-action)
("C-c C-c r" . lsp-rename)
("C-c C-c q" . lsp-workspace-restart)
("C-c C-c Q" . lsp-workspace-shutdown)
("C-c C-c s" . lsp-rust-analyzer-status))
:config
;; uncomment for less flashiness
;; (setq lsp-eldoc-hook nil)
;; (setq lsp-enable-symbol-highlighting nil)
;; (setq lsp-signature-auto-activate nil)
;; comment to disable rustfmt on save
(setq rustic-format-on-save t)
(add-hook 'rustic-mode-hook 'rk/rustic-mode-hook))
(defun rk/rustic-mode-hook ()
;; so that run C-c C-c C-r works without having to confirm, but don't try to
;; save rust buffers that are not file visiting. Once
;; https://github.com/brotzeit/rustic/issues/253 has been resolved this should
;; no longer be necessary.
(when buffer-file-name
(setq-local buffer-save-without-query t))
(add-hook 'before-save-hook 'lsp-format-buffer nil t))
;; company
(unless (package-installed-p 'company)
(package-install 'company))
(use-package company
:after lsp-mode
:hook (prog-mode . company-mode)
:bind (:map company-active-map
("<tab>" . company-complete-selection))
(:map lsp-mode-map
("<tab>" . company-indent-or-complete-common))
:custom
(company-minimum-prefix-length 1)
(company-idle-delay 0.0))
(setq neo-theme (if (display-graphic-p) 'icons))
;; Use keybindings
(use-package grip-mode
:ensure t
:bind (:map markdown-mode-command-map
("g" . grip-mode)))
;; neotree
(unless (package-installed-p 'neotree)
(package-install 'neotree)
(package-install 'all-the-icons))
(setq neo-theme (if (display-graphic-p) 'icons))
(setq neo-smart-open t)
(global-set-key [f8] 'neotree-toggle)
;; Simpleclip
(unless (package-installed-p 'simpleclip)
(package-install 'simpleclip))
(global-set-key (kbd "C-c C-c") 'simpleclip-copy)
(global-set-key (kbd "C-c C-v") 'simpleclip-paste)
;; Download Evil
(unless (package-installed-p 'evil)
(package-install 'evil))
;; Enable Evil
(require 'evil)
(evil-mode 1)
;; exwm
(unless (package-installed-p 'exwm)
(package-install 'exwm))
(require 'exwm)
(require 'exwm-config)
;;(exwm-config-example)
(defun my-untabify-all-lines ()
"Select all lines in the buffer and run 'untabify' on them."
(interactive)
(save-excursion
(goto-char (point-min))
(push-mark (point-max) t t)
(untabify (region-beginning) (region-end))))
(global-set-key (kbd "C-c C-x") 'my-untabify-all-lines)
;;
;; Epitech configuration
;;
(add-to-list 'load-path "~/.emacs.d/lisp")
(load "site-start.d/epitech-init.el")
(setq-default indent-tabs-mode nil)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(inhibit-startup-screen t)
'(package-selected-packages
'(benchmark-init company simpleclip rust-mode org-cliplink neotree magit gruber-darker-theme go-mode evil dash-functional all-the-icons)))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)

View File

@@ -1,6 +1,7 @@
(require 'package) (require 'package)
(add-to-list 'package-archives '("gnu" . "https://elpa.gnu.org/packages/")) (add-to-list 'package-archives '("gnu" . "https://elpa.gnu.org/packages/"))
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/")) (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(add-to-list 'load-path "/usr/local/share/emacs/site-lisp/mu4e")
(package-initialize) (package-initialize)
(unless (package-installed-p 'use-package) (unless (package-installed-p 'use-package)
@@ -10,10 +11,16 @@
(setq use-package-always-ensure t (setq use-package-always-ensure t
use-package-expand-minimally t)) use-package-expand-minimally t))
(load "~/.emacs.rc/rc.el") (unless (package-installed-p 'benchmark-init)
(load "~/.emacs.rc/misc-rc.el") (package-refresh-contents)
(load "~/.emacs.rc/org-mode-rc.el") (package-install 'benchmark-init))
(load "~/.emacs.rc/autocommit-rc.el")
(require 'benchmark-init)
;; To disable collection of benchmark data after init is done.
(add-hook 'after-init-hook 'benchmark-init/deactivate)
;; shell
(global-set-key (kbd "C-c RET") (lambda () (interactive) (ansi-term "/bin/zsh")))
;; Look ;; Look
(tool-bar-mode 0) (tool-bar-mode 0)
@@ -22,15 +29,16 @@
(column-number-mode 1) (column-number-mode 1)
(show-paren-mode 1) (show-paren-mode 1)
(electric-pair-mode 1) (electric-pair-mode 1)
(global-display-line-numbers-mode 1)
(global-font-lock-mode 0) (global-font-lock-mode 0)
(global-display-line-numbers-mode 1)
(setq display-line-numbers-type 'relative) (setq display-line-numbers-type 'relative)
(set-face-attribute 'default nil :height 200) (set-face-attribute 'default nil :height 200)
(global-set-key (kbd "<escape>") 'keyboard-escape-quit) (global-set-key (kbd "<escape>") 'keyboard-escape-quit)
;; Auto-refresh dired on file change
(add-hook 'dired-mode-hook 'auto-revert-mode)
(unless (package-installed-p 'gruvbox-theme) (unless (package-installed-p 'gruvbox-theme)
(package-install 'gruvbox-theme)) (package-install 'gruvbox-theme))
(load-theme 'gruvbox-dark-soft t) (load-theme 'gruvbox-dark-soft t)
(setq-default display-fill-column-indicator-column 79) ; 80 column indicator - Emacs columns are 0-based... (setq-default display-fill-column-indicator-column 79) ; 80 column indicator - Emacs columns are 0-based...
@@ -38,6 +46,21 @@
(setq neo-theme (if (display-graphic-p) 'icons)) (setq neo-theme (if (display-graphic-p) 'icons))
;; Use keybindings
(use-package grip-mode
:ensure t
:bind (:map markdown-mode-command-map
("g" . grip-mode)))
;; neotree
(unless (package-installed-p 'neotree)
(package-install 'neotree)
(package-install 'all-the-icons))
(setq neo-theme (if (display-graphic-p) 'icons))
(setq neo-smart-open t)
(global-set-key [f8] 'neotree-toggle)
;; Simpleclip ;; Simpleclip
(unless (package-installed-p 'simpleclip) (unless (package-installed-p 'simpleclip)
(package-install 'simpleclip)) (package-install 'simpleclip))
@@ -53,6 +76,10 @@
(require 'evil) (require 'evil)
(evil-mode 1) (evil-mode 1)
;; exwm
(unless (package-installed-p 'exwm)
(package-install 'exwm))
(defun my-untabify-all-lines () (defun my-untabify-all-lines ()
"Select all lines in the buffer and run 'untabify' on them." "Select all lines in the buffer and run 'untabify' on them."
(interactive) (interactive)
@@ -75,8 +102,9 @@
;; If you edit it by hand, you could mess it up, so be careful. ;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance. ;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right. ;; If there is more than one, they won't work right.
'(inhibit-startup-screen t)
'(package-selected-packages '(package-selected-packages
'(company simpleclip rust-mode org-cliplink neotree magit gruber-darker-theme go-mode evil dash-functional all-the-icons))) '(benchmark-init company simpleclip rust-mode org-cliplink neotree magit gruber-darker-theme go-mode evil dash-functional all-the-icons)))
(custom-set-faces (custom-set-faces
;; custom-set-faces was added by Custom. ;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful. ;; If you edit it by hand, you could mess it up, so be careful.

View File

@@ -1,7 +1,4 @@
.emacs|symlink| .emacs|symlink|
.emacs.rc|symlink|
.emacs.snippets|symlink|
.emacs.local|symlink|
.gitconfig|symlink| .gitconfig|symlink|
.rexim|symlink| .rexim|symlink|
.npmrc|symlink| .npmrc|symlink|