Emacs konfiguráció
Table of Contents
1 Preferenciák beállítása
(add-to-list 'default-frame-alist '(font . "Hack 11")) (setq visible-bell 1) (setq inhibit-startup-screen t) (setq debug-on-error t)
2 Csomagok betöltése
2.1 Melpa
;;(require 'init-security) (require 'package) (let* ((no-ssl (and (memq system-type '(windows-nt ms-dos)) (not (gnutls-available-p)))) (proto (if no-ssl "http" "https"))) (when no-ssl (warn "\ Your version of Emacs does not support SSL connections, which is unsafe because it allows man-in-the-middle attacks. There are two things you can do about this warning: 1. Install an Emacs version that does support SSL and be safe. 2. Remove this warning from your init file so you won't see it again.")) (add-to-list 'package-archives (cons "melpa" (concat proto "://melpa.org/packages/")) t) ;; Comment/uncomment this line to enable MELPA Stable if desired. See `package-archive-priorities` ;; and `package-pinned-packages`. Most users will not need or want to do this. ;;(add-to-list 'package-archives (cons "melpa-stable" (concat proto "://stable.melpa.org/packages/")) t) ) (package-initialize) (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. ;;'(custom-enabled-themes 'doom-solarized-dark) '(package-selected-packages (quote (nyan-mode neotree flycheck)))) ;;(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. ;; )
2.2 Cask
;;(package-initialize) ;;(require 'cask "~/.cask/cask.el") ;;(cask-initialize)
2.3 Plugin-ok betöltése
2.3.1 Neotree
;;(add-to-list 'load-path "/some/path/neotree") (require 'neotree) (global-set-key [f8] 'neotree-toggle)
2.3.2 Nyan-mode
(nyan-mode)
2.3.3 ORG-bullets
(require 'org-bullets) (add-hook 'org-mode-hook (lambda () (org-bullets-mode 1)))
2.3.4 RTags
(require 'rtags) (require 'company-rtags) (setq rtags-completions-enabled t) (eval-after-load 'company '(add-to-list 'company-backends 'company-rtags)) (setq rtags-autostart-diagnostics t) (rtags-enable-standard-keybindings)
2.3.5 Irony-mode
(add-hook 'c++-mode-hook 'irony-mode) (add-hook 'c-mode-hook 'irony-mode) (add-hook 'objc-mode-hook 'irony-mode) (defun my-irony-mode-hook () (define-key irony-mode-map [remap completion-at-point] 'irony-completion-at-point-async) (define-key irony-mode-map [remap complete-symbol] 'irony-completion-at-point-async)) (add-hook 'irony-mode-hook 'my-irony-mode-hook) (add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options)
2.3.6 Comany-irony
(add-hook 'irony-mode-hook 'company-irony-setup-begin-commands) (setq company-backends (delete 'company-semantic company-backends)) (eval-after-load 'company '(add-to-list 'company-backends 'company-irony)) (setq company-idle-delay 0) (define-key c-mode-map [(tab)] 'company-complete) (define-key c++-mode-map [(tab)] 'company-complete)
2.3.7 Flycheck
(add-hook 'c++-mode-hook 'flycheck-mode) (add-hook 'c-mode-hook 'flycheck-mode) (require 'flycheck-rtags) (defun my-flycheck-rtags-setup () (flycheck-select-checker 'rtags) (setq-local flycheck-highlighting-mode nil) ;; RTags creates more accurate overlays. (setq-local flycheck-check-syntax-automatically nil)) ;; c-mode-common-hook is also called by c++-mode (add-hook 'c-mode-common-hook #'my-flycheck-rtags-setup) ;;Integrate to irony (eval-after-load 'flycheck '(add-hook 'flycheck-mode-hook #'flycheck-irony-setup))
2.3.8 Flycheck-clang-tidy
;(eval-after-load 'flycheck ; '(add-hook 'flycheck-mode-hook #'flycheck-clang-tidy-setup))
2.3.9 Cmake-ide
(cmake-ide-setup)
2.3.10 Highlight beállítások
(add-hook 'irony-mode-hook 'highlight-numbers-mode) (add-hook 'irony-mode-hook 'preproc-font-lock-mode)
2.3.11 Srefactor
(require 'srefactor) (require 'srefactor-lisp) ;; OPTIONAL: ADD IT ONLY IF YOU USE C/C++. (semantic-mode 1) ;; -> this is optional for Lisp (define-key c-mode-map (kbd "M-RET") 'srefactor-refactor-at-point) (define-key c++-mode-map (kbd "M-RET") 'srefactor-refactor-at-point) (global-set-key (kbd "M-RET o") 'srefactor-lisp-one-line) (global-set-key (kbd "M-RET m") 'srefactor-lisp-format-sexp) (global-set-key (kbd "M-RET d") 'srefactor-lisp-format-defun) (global-set-key (kbd "M-RET b") 'srefactor-lisp-format-buffer)
3 Makró beállítások
3.1 Rtags
(define-key c-mode-base-map (kbd "M-.") (function rtags-find-symbol-at-point)) (define-key c-mode-base-map (kbd "M-,") (function rtags-find-references-at-point)) (define-key c-mode-base-map (kbd "M-;") (function rtags-find-file)) (define-key c-mode-base-map (kbd "C-.") (function rtags-find-symbol)) (define-key c-mode-base-map (kbd "C-,") (function rtags-find-references)) (define-key c-mode-base-map (kbd "C-<") (function rtags-find-virtuals-at-point)) (define-key c-mode-base-map (kbd "M-i") (function rtags-imenu))
3.2 Open config
(global-set-key (kbd "C-c o") (lambda () (interactive) (find-file "/home/balazs/.emacs.d/conf.org") (message "Opened: %s" (buffer-name)))) (global-set-key (kbd "C-c r") (lambda () (interactive) (kill-buffer (buffer-name)) (load-file "/home/balazs/.emacs.d/init.el") (message "Configuration reloaded") ))
3.3 Cmake build and run
(defun cmake-build-and-run () "Asks for cmake target, then compiles and runs it." (interactive) (let ((target (ido-completing-read "Choose build target: " (remove "" (split-string (shell-command-to-string "cmake --build ./cmake-build-debug --target help | awk '{if($2 != \"all\" && $2!= \"clean\" && $2 != \"following\" && $2 != \"edit_cache\" && $2 != \"rebuild_cache\" && $2 != \"depend\" && $2 !~ /\\./){print $2}}'") "\n"))))) (setq cmake-last-target target) (async-shell-command (format "cmake --build ./cmake-build-debug --target %s && ./cmake-build-debug/%s" target target)))) (defun cmake-build-last-target () (interactive) (if (not (null cmake-last-target)) (async-shell-command (format "cmake --build ./cmake-build-debug --target %s && ./cmake-build-debug/%s" cmake-last-target cmake-last-target)) (cmake-build-and-run)) ) (define-key c-mode-base-map (kbd "C-c C-r") (function cmake-build-and-run)) (define-key c-mode-base-map [f5] 'cmake-build-last-target)
3.4 Kód indentálás
(defun indent-buffer () (interactive) (save-excursion (indent-region (point-min) (point-max) nil))) (global-set-key [f6] 'indent-buffer)
4 Saját változók
4.1 Csomag változók
4.2 Minibuffer
(setq minibuffer-completion-confirm nil)
4.3 Spellcheck
(setq ispell-local-dictionary "/home/balazs/.local/hu_HU.dic")
4.4 Téma betöltése
;;(load-theme "humanoid-dark" t) ;;(add-hook 'after-init-hook (lambda () (load-theme "humanoid-dark")))
4.5 Org-mode
(setq org-todo-keywords '((squence "TODO" "WAITING" "|" "DONE(!)"))) (setq org-highlight-latex-and-related '(latex script entities)) (setq org-src-fontify-natively t org-src-tab-acts-natively t org-confirm-babel-evaluate nil org-edit-src-content-indentation 0)
4.6 Teszt
;;(setq cmake-ide-build-dir "cmake-build-test") (cd "~/CLionProjects/prog2/")