conf-prog.el 2.1 KB

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