conf-prog.el 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. ;;; Code:
  2. (require 'ispell)
  3. (require 'emr)
  4. (require 'move-dup)
  5. (require 'rainbow-delimiters)
  6. (require 'highlight-symbol)
  7. (require 'whitespace-cleanup-mode)
  8. ;; (require 'aggressive-indent)
  9. (require 'dumb-jump)
  10. ;; Control
  11. (defconst distopico:editorconfig-regexp
  12. (concat "\\`" (regexp-quote ".editorconfig") "\\'"))
  13. ;; Configuration
  14. (setq semanticdb-default-save-directory (in-emacs-d ".cache/semanticdb")
  15. dumb-jump-selector 'ivy)
  16. ;; Exclude some modes fro agressive indent
  17. ;; (dolist (source '(diary-mode css-mode less-css-mode jade-mode))
  18. ;; (add-to-list 'aggressive-indent-excluded-modes source t))
  19. ;; TODO: Check which-func (which-function-mode 1)
  20. ;; Native emacs pair
  21. (electric-pair-mode t)
  22. ;; Define additional/custom keybindings
  23. (define-key prog-mode-map (kbd "C-M-<return>") 'emr-show-refactor-menu)
  24. ;; Functions
  25. (defun distopico:local-comment-auto-fill ()
  26. "Auto-fill just comments."
  27. (setq-local comment-auto-fill-only-comments t)
  28. (auto-fill-mode +1))
  29. (defun distopico:prog-mode-hook ()
  30. "Hook for all modes derivate of `prog-mode'."
  31. ;; Return and indent
  32. (local-set-key [(return)] 'newline-and-indent)
  33. ;; Custom behavior
  34. (distopico:local-comment-auto-fill)
  35. ;; Enable highlight `TODO' comments
  36. (hl-todo-mode +1)
  37. ;; Automatic symbol highlighting
  38. (highlight-symbol-mode +1)
  39. ;; delimiters highlighting
  40. (rainbow-delimiters-mode +1)
  41. ;; Enable docs
  42. (eldoc-mode +1)
  43. ;; Moving and duplicating lines or rectangles
  44. (move-dup-mode +1)
  45. ;; Search references
  46. (dumb-jump-mode +1)
  47. ;; Emacs refactor
  48. (emr-initialize)
  49. ;; If editorconfig not found clean but only
  50. ;; if the whitespace in the buffer was initially clean
  51. (unless (distopico:locate-parent-file distopico:editorconfig-regexp)
  52. (whitespace-cleanup-mode +1))
  53. ;; Enable spell check on comments
  54. (when (executable-find ispell-program-name)
  55. (flyspell-prog-mode)))
  56. ;; Hooks
  57. (add-hook 'prog-mode-hook #'distopico:prog-mode-hook)
  58. (add-hook 'prog-mode-hook 'display-fill-column-indicator-mode)
  59. (provide 'conf-prog)
  60. ;;; conf-prog.el ends here