General refactor of modules

General code and comment improvements.

Also, removed the :desc's for csv-mode because map! is currently unable
to set which-key descriptions mode-locally, and should be avoided for
anything but global keybinds. This will be fixed when General is
introduced into Doom.
This commit is contained in:
Henrik Lissner 2018-09-07 22:08:11 -04:00
parent 89b83f2457
commit c58077810d
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
15 changed files with 59 additions and 57 deletions

View file

@ -2,7 +2,7 @@
;;;###if (featurep! :feature evil)
;;;###autoload (autoload '+format:region "editor/format/autoload/evil" nil t)
(evil-define-operator +format:region (beg end type)
(evil-define-operator +format:region (beg end)
"Evil ex interface to `+format/region'."
(interactive "<R>")
(interactive "<r>")
(+format/region beg end))

View file

@ -22,8 +22,9 @@ ignored. This makes it easy to override built-in snippets with private ones."
(let* ((gc-cons-threshold doom-gc-cons-upper-limit)
(choices (cl-remove-duplicates choices :test #'+snippets--remove-p)))
(if (cdr choices)
(let ((prompt-functions (remq '+snippets-prompt-private yas-prompt-functions)))
(run-hook-with-args-until-success 'prompt-functions prompt choices fn))
(cl-loop for fn in (cdr (memq '+snippets-prompt-private yas-prompt-functions))
if (funcall prompt choices fn)
return it)
(car choices)))))
;;;###autoload

View file

@ -27,14 +27,14 @@
;;;###autoload
(defun +cc-c++-lineup-inclass (langelem)
"Indent inclass lines one level further than access modifier keywords."
(when (and (eq major-mode 'c++-mode)
(or (assoc 'access-label c-syntactic-context)
(save-excursion
(save-match-data
(re-search-backward
"\\(?:p\\(?:ublic\\|r\\(?:otected\\|ivate\\)\\)\\)"
(c-langelem-pos langelem) t)))))
'++))
(and (eq major-mode 'c++-mode)
(or (assoc 'access-label c-syntactic-context)
(save-excursion
(save-match-data
(re-search-backward
"\\(?:p\\(?:ublic\\|r\\(?:otected\\|ivate\\)\\)\\)"
(c-langelem-pos langelem) t))))
'++))
;;;###autoload
(defun +cc-lineup-arglist-close (langlem)
@ -55,10 +55,9 @@ preceded by the opening brace or a comma (disregarding whitespace in between)."
(re-search-forward regexp magic-mode-regexp-match-limit t)))))
;;;###autoload
(defun +cc-c-c++-objc-mode (&optional file)
(defun +cc-c-c++-objc-mode ()
"Sets either `c-mode', `objc-mode' or `c++-mode', whichever is appropriate."
(let ((base (file-name-sans-extension buffer-file-name))
file)
(let ((base (file-name-sans-extension (buffer-file-name (buffer-base-buffer)))))
(cond ((file-exists-p! (or (concat base ".cpp")
(concat base ".cc")))
(c++-mode))
@ -83,6 +82,8 @@ preceded by the opening brace or a comma (disregarding whitespace in between)."
"\\|" "#include" ws-maybe "<\\(?:string\\|iostream\\|map\\)>"
"\\)")))
(c++-mode))
((functionp +cc-default-header-file-mode)
(funcall +cc-default-header-file-mode))
((c-mode)))))

View file

@ -5,6 +5,10 @@
C/C++. Paths can be absolute. This is ignored if your project has a compilation
database.")
(defvar +cc-default-header-file-mode 'c-mode
"Fallback major mode for .h files if all other heuristics fail (in
`+cc-c-c++-objc-mode').")
(defvar +cc-default-compiler-options
`((c-mode . nil)
(c++-mode

View file

@ -1,8 +1,6 @@
;;; lang/crystal/config.el -*- lexical-binding: t; -*-
(def-package! crystal-mode
:defer t
:config
(after! crystal-mode
(set-lookup-handlers! 'crystal-mode
:definition #'crystal-def-jump
:references #'crystal-tool-imp)
@ -17,4 +15,5 @@
:after crystal-mode)
(def-package! inf-crystal :commands crystal-switch-to-inf)
(def-package! inf-crystal
:commands crystal-switch-to-inf)

View file

@ -1,6 +1,6 @@
;;; lang/csharp/config.el -*- lexical-binding: t; -*-
;; unity shaders
;; `shader-mode' --- unity shaders
(add-to-list 'auto-mode-alist '("\\.shader$" . shader-mode))
@ -15,9 +15,10 @@
"Clean up the omnisharp server once you kill the last csharp-mode buffer."
(unless (doom-buffers-in-mode 'csharp-mode (buffer-list))
(omnisharp-stop-server)))
(add-hook! csharp-mode (add-hook 'kill-buffer-hook #'omnisharp-stop-server nil t))
(add-hook! csharp-mode
(add-hook 'kill-buffer-hook #'omnisharp-stop-server nil t))
(set-company-backend! 'csharp-mode '(company-omnisharp))
(set-company-backend! 'csharp-mode 'company-omnisharp)
(set-lookup-handlers! 'csharp-mode
:definition #'omnisharp-go-to-definition

View file

@ -1,28 +1,27 @@
;;; lang/data/config.el -*- lexical-binding: t; -*-
;; Built in plugins
(unless after-init-time
(push '("/sxhkdrc\\'" . conf-mode) auto-mode-alist)
(push '("\\.\\(?:hex\\|nes\\)\\'" . hexl-mode) auto-mode-alist)
(push '("\\.plist\\'" . nxml-mode) auto-mode-alist))
(add-to-list 'auto-mode-alist '("/sxhkdrc\\'" . conf-mode))
(add-to-list 'auto-mode-alist '("\\.\\(?:hex\\|nes\\)\\'" . hexl-mode))
(add-to-list 'auto-mode-alist '("\\.plist\\'" . nxml-mode))
(after! nxml-mode
(set-company-backend! 'nxml-mode '(company-nxml company-yasnippet)))
;; Third-party plugins
;;
;; Third-party plugins
;; `csv-mode'
(map! :after csv-mode
:map csv-mode-map
(:localleader
:desc "Align fields" :nvm "a" #'csv-align-fields
:desc "Unalign fields" :nvm "u" #'csv-unalign-fields
:desc "Sort fields" :nvm "s" #'csv-sort-fields
:desc "Sort fields (n)" :nvm "S" #'csv-sort-numeric-fields
:desc "Kill fields" :nvm "k" #'csv-kill-fields
:desc "Transpose fields" :nvm "t" #'csv-transpose))
:localleader
:nvm "a" #'csv-align-fields
:nvm "u" #'csv-unalign-fields
:nvm "s" #'csv-sort-fields
:nvm "S" #'csv-sort-numeric-fields
:nvm "k" #'csv-kill-fields
:nvm "t" #'csv-transpose)
(def-package! graphql-mode
:mode "\\.gql\\'")
@ -36,8 +35,8 @@
:mode "\\.?vimperatorrc\\'")
;; Frameworks
;;
;; Frameworks
(def-project-mode! +data-ansible-mode
:modes (yaml-mode)

View file

@ -16,7 +16,8 @@ to a pop up buffer."
(read-only-mode +1)
(erase-buffer)
(setq-local scroll-margin 0)
(delay-mode-hooks (emacs-lisp-mode))
(let (emacs-lisp-mode-hook)
(emacs-lisp-mode))
(prin1 result buf)
(pp-buffer)
(setq lines (count-lines (point-min) (point-max)))

View file

@ -29,7 +29,6 @@
;;
;; Major modes
;;
(def-package! js2-mode
:mode "\\.js\\'"
@ -125,7 +124,6 @@
;;
;; Tools
;;
(def-package! tide
:defer t
@ -211,6 +209,7 @@
:localleader
:n "se" #'skewer-html-eval-tag))
;; `npm-mode'
(map! :after npm-mode
:map npm-mode-keymap
@ -224,9 +223,9 @@
:n "nr" #'npm-mode-npm-run
:n "nv" #'npm-mode-visit-project-file)
;;
;; Projects
;;
(def-project-mode! +javascript-npm-mode
:modes (html-mode css-mode web-mode js2-mode rjsx-mode json-mode markdown-mode)

View file

@ -1,8 +1,6 @@
;; -*- no-byte-compile: t; -*-
;;; lang/javascript/packages.el
;; requires node npm js-beautify eslint eslint-plugin-react
(package! coffee-mode)
(package! eslintd-fix)
(package! js2-mode)

View file

@ -11,8 +11,8 @@
(set-company-backend! 'lua-mode '(company-lua company-yasnippet)))
(after! moonscript
(defvaralias 'moonscript-indent-offset 'tab-width))
;; `moonscript'
(setq-hook! 'moonscript-mode-hook moonscript-indent-offset tab-width)
;;

View file

@ -42,7 +42,9 @@
(define-key python-mode-map (kbd "DEL") nil) ; interferes with smartparens
(sp-with-modes 'python-mode
(sp-local-pair "'" nil :unless '(sp-point-before-word-p sp-point-after-word-p sp-point-before-same-p)))
(sp-local-pair "'" nil :unless '(sp-point-before-word-p
sp-point-after-word-p
sp-point-before-same-p)))
(when (featurep! +ipython)
(setq python-shell-interpreter "ipython"

View file

@ -23,7 +23,7 @@
'("tidy" "-q" "-indent"
"--tidy-mark" "no"
"--drop-empty-elements" "no"
"--show-body-only" "auto"
"--show-body-only" "auto" ; don't inject html/body tags
("--indent-spaces" "%d" tab-width)
("--indent-with-tabs" "%s" (if indent-tabs-mode "yes" "no"))
("-xml" (memq major-mode '(nxml-mode xml-mode))))

View file

@ -1,14 +1,6 @@
;; -*- no-byte-compile: t; -*-
;;; lang/web/packages.el
;; requires js-beautify stylelint stylelint-scss
(package! rainbow-mode)
(when (featurep! :completion ivy)
(package! counsel-css))
(when (featurep! :completion helm)
(package! helm-css-scss))
;; +html.el
(package! emmet-mode)
(package! haml-mode)
@ -22,4 +14,8 @@
(package! less-css-mode)
(package! sass-mode)
(package! stylus-mode)
(package! rainbow-mode)
(when (featurep! :completion ivy)
(package! counsel-css))
(when (featurep! :completion helm)
(package! helm-css-scss))

View file

@ -29,7 +29,7 @@
(enh-ruby-mode enh-ruby-indent-level))
editorconfig-indentation-alist)))
(defun doom*editorconfig-smart-detection (orig-fn &rest args)
(defun doom*editorconfig-smart-detection (orig-fn)
"Retrieve the properties for the current file. If it doesn't have an
extension, try to guess one."
(let ((buffer-file-name
@ -40,12 +40,13 @@ extension, try to guess one."
(if-let* ((ext (cdr (assq major-mode +editorconfig-mode-alist))))
(concat "." ext)
"")))))
(apply orig-fn args)))
(funcall orig-fn)))
(advice-add #'editorconfig-call-editorconfig-exec :around #'doom*editorconfig-smart-detection)
(defun +editorconfig|disable-ws-butler-maybe (props)
"Disable `ws-butler-mode' if trim_trailing_whitespace is true."
(when (equal (gethash 'trim_trailing_whitespace props) "true")
(when (and (equal (gethash 'trim_trailing_whitespace props) "true")
(bound-and-true-p ws-butler-mode))
(ws-butler-mode -1)))
(add-hook 'editorconfig-custom-hooks #'+editorconfig|disable-ws-butler-maybe)