diff --git a/Cask b/Cask index 6b1f08fcd..b27878675 100644 --- a/Cask +++ b/Cask @@ -139,9 +139,6 @@ (depends-on "omnisharp") (depends-on "shader-mode") -;; Lisp -- modules/module-lisp.el -(depends-on "slime") - ;; Golang -- modules/module-go.el (depends-on "go-mode") (depends-on "go-eldoc") @@ -165,6 +162,9 @@ (depends-on "company-tern") (depends-on "nodejs-repl") +;; Lisp -- modules/module-lisp.el +(depends-on "slime") + ;; Lua -- modules/module-lua.el (depends-on "lua-mode") diff --git a/core/core-completion.el b/core/core-completion.el index 4add0720c..b02fb6417 100644 --- a/core/core-completion.el +++ b/core/core-completion.el @@ -13,22 +13,15 @@ company-global-modes '(not eshell-mode comint-mode erc-mode message-mode help-mode) company-frontends '(company-pseudo-tooltip-frontend company-echo-metadata-frontend) - company-backends '((company-capf - company-dabbrev-code) - company-dabbrev) - company-statistics-file (concat narf-temp-dir "/company-stats-cache.el") - company-quickhelp-delay nil) + company-backends '((company-capf company-dabbrev-code) + company-dabbrev)) :config - ;; NOTE: pos-tip.el in Emacs 25+ does not work - (use-package company-quickhelp - :config (company-quickhelp-mode +1)) - ;; Rewrites evil-complete to use company-dabbrev (setq evil-complete-next-func 'narf/company-evil-complete-next evil-complete-previous-func 'narf/company-evil-complete-previous) - (add-to-list 'company-transformers 'company-sort-by-occurrence) + (push 'company-sort-by-occurrence company-transformers) (setq-default company-backends (append '(company-keywords) company-backends)) (define-company-backend! nxml-mode (nxml yasnippet)) @@ -38,8 +31,16 @@ (global-company-mode +1) - (require 'company-statistics) - (company-statistics-mode +1)) + ;; NOTE: pos-tip.el in Emacs 25+ does not work + (use-package company-quickhelp + :config + (company-quickhelp-mode +1) + (setq company-quickhelp-delay nil)) + + (use-package company-statistics + :config + (company-statistics-mode +1) + (setq company-statistics-file (concat narf-temp-dir "/company-stats-cache.el")))) (use-package company-dict :defer t :config (setq company-dict-dir (concat narf-private-dir "/dict"))) diff --git a/core/core-defuns.el b/core/core-defuns.el index 61e3d6733..6fe40e715 100644 --- a/core/core-defuns.el +++ b/core/core-defuns.el @@ -1,6 +1,4 @@ -(eval-when-compile - (require 'cl-lib) - (require 'dash)) +(eval-when-compile (require 'cl-lib)) ;; Backwards compatible `with-eval-after-load' (unless (fboundp 'with-eval-after-load) diff --git a/core/core-editor.el b/core/core-editor.el index 184074e99..4e4962ee9 100644 --- a/core/core-editor.el +++ b/core/core-editor.el @@ -33,6 +33,7 @@ '((tab-mark ?\t [?> ?\t]) (newline-mark 10 [36 10]))) +;; Save point across sessions (require 'saveplace) (setq-default save-place-file (concat narf-temp-dir "/saveplace") @@ -40,6 +41,36 @@ (when (>= emacs-major-version 25) (save-place-mode +1)) +;; Save history across sessions +(require 'savehist) +(setq savehist-file (concat narf-temp-dir "/savehist") + savehist-save-minibuffer-history t + savehist-additional-variables + '(kill-ring search-ring regexp-search-ring)) +(savehist-mode 1) + +;; text properties severely bloat the history so delete them (courtesy of PythonNut) +(defun unpropertize-savehist () + (mapc (lambda (list) + (with-demoted-errors + (when (boundp list) + (set list (mapcar #'substring-no-properties (eval list)))))) + '(kill-ring minibuffer-history helm-grep-history helm-ff-history file-name-history + read-expression-history extended-command-history evil-ex-history))) +(add-hook 'kill-emacs-hook #'unpropertize-savehist) +(add-hook 'savehist-save-hook #'unpropertize-savehist) + +;; Keep track of recently opened files +(require 'recentf) +(setq recentf-save-file (concat narf-temp-dir "/recentf") + recentf-exclude '("/tmp/" "/ssh:" "\\.?ido\\.last$" "\\.revive$" "/TAGS$" + "emacs\\.d/private/cache/.+" "emacs\\.d/workgroups/.+$" "wg-default" + "/company-statistics-cache.el$") + recentf-max-menu-items 0 + recentf-max-saved-items 250 + recentf-auto-cleanup 600) +(recentf-mode 1) + ;; ;; Automatic minor modes diff --git a/core/core-evil.el b/core/core-evil.el index 6a33a22f3..2dccaa1b7 100644 --- a/core/core-evil.el +++ b/core/core-evil.el @@ -14,7 +14,7 @@ (add-hook 'evil-operator-state-exit-hook 'show-paren-mode-off) ;; Disable highlights on insert-mode - (add-hook! evil-insert-state-entry 'evil-ex-nohighlight) + (add-hook 'evil-insert-state-entry-hook 'evil-ex-nohighlight) :config (setq-default evil-magic t @@ -241,6 +241,7 @@ (regexp-quote pattern) (evil-transform-vim-style-regexp pattern))) 1 1)) + (evil-define-operator narf:evil-ex-global (beg end pattern command &optional invert) :motion mark-whole-buffer :move-point nil @@ -402,7 +403,8 @@ (use-package evil-escape :config - (setq evil-escape-key-sequence "jk") + (setq evil-escape-key-sequence "jk" + evil-escape-delay 0.2) (evil-escape-mode +1)) (provide 'core-evil) diff --git a/core/core-project.el b/core/core-project.el index 8382491ee..4717d96f0 100644 --- a/core/core-project.el +++ b/core/core-project.el @@ -5,12 +5,12 @@ ;; ;; Always copy/delete recursively -(setq dired-recursive-copies (quote always)) -(setq dired-recursive-deletes (quote top)) +(setq dired-recursive-copies (quote always) + dired-recursive-deletes (quote top)) ;; Auto refresh dired, but be quiet about it -(setq global-auto-revert-non-file-buffers t) -(setq auto-revert-verbose nil) +(setq global-auto-revert-non-file-buffers t + auto-revert-verbose nil) (setq dired-omit-mode t) @@ -33,7 +33,7 @@ (when (and (not (file-exists-p parent-directory)) (y-or-n-p (format "Directory `%s' does not exist! Create it?" parent-directory))) (make-directory parent-directory t)))) -(add-to-list 'find-file-not-found-functions #'narf|create-non-existent-directory) +(push 'narf|create-non-existent-directory find-file-not-found-functions) ;; (use-package ido @@ -47,13 +47,14 @@ ido-use-faces nil ido-confirm-unique-completion t ido-case-fold t - ido-enable-tramp-completion nil - ido-enable-flex-matching t ido-create-new-buffer 'always - ido-enable-tramp-completion t + ido-enable-flex-matching t ido-enable-last-directory-history t + ido-enable-tramp-completion nil + ido-enable-tramp-completion t ido-cr+-max-items 10000 ido-save-directory-list-file (concat narf-temp-dir "/ido.last")) + (add-hook 'ido-setup-hook 'narf|ido-setup-home-keybind) :config (add-hook! ido-setup (add-to-list 'ido-ignore-files "\\`.DS_Store$") @@ -72,8 +73,7 @@ "C-w" 'ido-delete-backward-word-updir "C-u" 'ido-up-directory)) - (add-hook! (ido-make-file-list ido-make-dir-list) 'narf*ido-sort-mtime) - (add-hook! ido-setup 'narf|ido-setup-home-keybind)) + (add-hook! (ido-make-file-list ido-make-dir-list) 'narf*ido-sort-mtime)) ;; (use-package neotree diff --git a/core/core-ui.el b/core/core-ui.el index 192af100e..57dbf5f90 100644 --- a/core/core-ui.el +++ b/core/core-ui.el @@ -7,7 +7,6 @@ ;;cursor-in-non-selected-windows nil ; no cursors except in active buffer highlight-nonselected-windows nil hl-line-sticky-flag nil ; only highlight in one window - uniquify-buffer-name-style nil ; my mode-line does this for me visible-bell nil ; silence of the bells use-dialog-box nil ; always avoid GUI @@ -15,7 +14,6 @@ indicate-buffer-boundaries t ; show indicators where buffer starts/ends indicate-empty-lines t ; show indicators on empty lines fringes-outside-margins t ; switches order of fringe and margin - idle-update-delay 2 ; update a little less often split-width-threshold nil ; favor horizontal splits show-help-function nil ; hide :help-echo text @@ -30,6 +28,16 @@ fringe-indicator-alist (delq (assoc 'continuation fringe-indicator-alist) fringe-indicator-alist)) +(fset 'yes-or-no-p 'y-or-n-p) ; y/n instead of yes/no + +;; Ask for confirmation on exit only if there are real buffers left +(when window-system + (setq confirm-kill-emacs + (lambda (_) + (if (narf/get-real-buffers) + (y-or-n-p ">> Gee, I dunno Brain... Are you sure?") + t)))) + (blink-cursor-mode 1) ; blink cursor (tooltip-mode -1) ; show tooltips in echo area @@ -98,13 +106,13 @@ (defun narf|hl-line-off () (if narf--hl-line-mode (hl-line-mode -1))) (add-hook! hl-line-mode (if hl-line-mode (setq narf--hl-line-mode t))) -(add-hook! evil-visual-state-entry 'narf|hl-line-off) -(add-hook! evil-visual-state-exit 'narf|hl-line-on) +(add-hook 'evil-visual-state-entry-hook 'narf|hl-line-off) +(add-hook 'evil-visual-state-exit-hook 'narf|hl-line-on) ;; Hide modeline in help windows (defun narf|hide-mode-line () (setq mode-line-format nil)) -(add-hook! help-mode 'narf|hide-mode-line) +(add-hook 'help-mode-hook 'narf|hide-mode-line) ;; Highlight TODO/FIXME/NOTE tags (defface narf-todo-face '((t (:inherit font-lock-warning-face))) @@ -139,6 +147,7 @@ (use-package rainbow-mode :defer t :init + ;; hl-line-mode and rainbow-mode don't play well together (add-hook! rainbow-mode (when narf--hl-line-mode (hl-line-mode (if rainbow-mode -1 1))))) diff --git a/core/core-vars.el b/core/core-vars.el deleted file mode 100644 index 522c30e4a..000000000 --- a/core/core-vars.el +++ /dev/null @@ -1,70 +0,0 @@ -;;; core-vars.el --- narf emacs configuration - -(defgroup narf nil - "Narf variables." - :group 'convenience - :prefix 'narf-) - -(defvar narf-leader-prefix "," "Prefix key for maps") -(defvar narf-localleader-prefix "\\" "Prefix key for maps") - - -;; -;; Buffers/Files -;; - -(defvar narf-unreal-buffers '("^ ?\\*.+\\*" - image-mode - dired-mode - reb-mode - messages-buffer-mode) - "A list of regexps or modes whose buffers are considered unreal, and will be -ignored when using `narf:next-real-buffer' and `narf:previous-real-buffer', and -killed by `narf/kill-unreal-buffers'. - -`narf:kill-this-buffer' will also gloss over these buffers when finding a new -buffer to display.") - -(defvar narf-ignore-buffers '("*Completions*" "*Compile-Log*" "*inferior-lisp*" - "*Fuzzy Completions*" "*Apropos*" "*Help*" "*cvs*" - "*Buffer List*" "*Ibuffer*" "*esh command on file*" - "*WoMan-Log*" "*compilation*" "*use-package*" - "*quickrun*" "*eclim: problems*" "*Flycheck errors*" - "*popwin-dummy*" " *NeoTree*" - ;; Helm - "*helm*" "*helm recentf*" "*helm projectile*" "*helm imenu*" - "*helm company*" "*helm buffers*" "*Helm Css SCSS*" - "*helm-ag*" "*helm-ag-edit*" "*Helm Swoop*" - "*helm M-x*" "*helm mini*" "*Helm Completions*" - "*Helm Find Files*" "*helm mu*" "*helm mu contacts*" - "*helm-mode-describe-variable*" "*helm-mode-describe-function*" - ;; Org - "*Org todo*" "*Org Links*" "*Agenda Commands*" - ) - "List of buffer names to ignore when using `winner-undo', or `winner-redo'") - -(defvar narf-cleanup-processes-alist '(("pry" . ruby-mode) - ("irb" . ruby-mode) - ("ipython" . python-mode)) - "An alist of (process-name . major-mode), that `narf:cleanup-processes' checks -before killing processes. If there are no buffers with matching major-modes, it -gets killed.") - -(defvar narf-project-root-files - '(".git" ".hg" ".svn" ".project" "local.properties" "project.properties" - "rebar.config" "project.clj" "SConstruct" "pom.xml" "build.sbt" - "build.gradle" "Gemfile" "requirements.txt" "tox.ini" "package.json" - "gulpfile.js" "Gruntfile.js" "bower.json" "composer.json" "Cargo.toml" - "mix.exs") - "A list of files that count as 'project files', which determine whether a - folder is the root of a project or not.") - - -;; -;; Fringe/margins -;; - -(defvar narf-fringe-size 6 "Default width to use for the fringes.") - -(provide 'core-vars) -;;; core-vars.el ends here diff --git a/core/core.el b/core/core.el index 338dfc74a..3454900ad 100644 --- a/core/core.el +++ b/core/core.el @@ -16,6 +16,7 @@ ;;; (setq-default + idle-update-delay 2 ; update a little less often ad-redefinition-action 'accept ; silence the advised function warnings echo-keystrokes 0.02 ; show me what I type history-length 1000 @@ -65,15 +66,62 @@ (set-charset-priority 'unicode) (setq default-process-coding-system '(utf-8-unix . utf-8-unix)) -(fset 'yes-or-no-p 'y-or-n-p) ; y/n instead of yes/no -;; Ask for confirmation on exit only if there are real buffers left -(when window-system - (setq confirm-kill-emacs - (lambda (_) - (if (narf/get-real-buffers) - (y-or-n-p ">> Gee, I dunno Brain... Are you sure?") - t)))) +;; +;; Variables +;; + +(defvar narf-leader-prefix "," "Prefix key for maps") +(defvar narf-localleader-prefix "\\" "Prefix key for maps") + +;; Buffers/Files +(defvar narf-unreal-buffers '("^ ?\\*.+\\*" + image-mode + dired-mode + reb-mode + messages-buffer-mode) + "A list of regexps or modes whose buffers are considered unreal, and will be +ignored when using `narf:next-real-buffer' and `narf:previous-real-buffer', and +killed by `narf/kill-unreal-buffers'. + +`narf:kill-this-buffer' will also gloss over these buffers when finding a new +buffer to display.") + +(defvar narf-ignore-buffers '("*Completions*" "*Compile-Log*" "*inferior-lisp*" + "*Fuzzy Completions*" "*Apropos*" "*Help*" "*cvs*" + "*Buffer List*" "*Ibuffer*" "*esh command on file*" + "*WoMan-Log*" "*compilation*" "*use-package*" + "*quickrun*" "*eclim: problems*" "*Flycheck errors*" + "*popwin-dummy*" " *NeoTree*" + ;; Helm + "*helm*" "*helm recentf*" "*helm projectile*" "*helm imenu*" + "*helm company*" "*helm buffers*" "*Helm Css SCSS*" + "*helm-ag*" "*helm-ag-edit*" "*Helm Swoop*" + "*helm M-x*" "*helm mini*" "*Helm Completions*" + "*Helm Find Files*" "*helm mu*" "*helm mu contacts*" + "*helm-mode-describe-variable*" "*helm-mode-describe-function*" + ;; Org + "*Org todo*" "*Org Links*" "*Agenda Commands*") + "List of buffer names to ignore when using `winner-undo', or `winner-redo'") + +(defvar narf-cleanup-processes-alist '(("pry" . ruby-mode) + ("irb" . ruby-mode) + ("ipython" . python-mode)) + "An alist of (process-name . major-mode), that `narf:cleanup-processes' checks +before killing processes. If there are no buffers with matching major-modes, it +gets killed.") + +(defvar narf-project-root-files + '(".git" ".hg" ".svn" ".project" "local.properties" "project.properties" + "rebar.config" "project.clj" "SConstruct" "pom.xml" "build.sbt" + "build.gradle" "Gemfile" "requirements.txt" "tox.ini" "package.json" + "gulpfile.js" "Gruntfile.js" "bower.json" "composer.json" "Cargo.toml" + "mix.exs") + "A list of files that count as 'project files', which determine whether a + folder is the root of a project or not.") + +;; Fringe/margins +(defvar narf-fringe-size 6 "Default width to use for the fringes.") ;; @@ -84,46 +132,17 @@ (unless (require 'autoloads nil t) (load (concat narf-emacs-dir "/scripts/generate-autoloads.el")) (require 'autoloads)) -(require 'core-vars) (require 'core-defuns) (eval-when-compile (setq use-package-verbose nil) ;; Make any folders needed - (dolist (file '("" "/undo" "/backup")) - (let ((path (concat narf-temp-dir file))) - (unless (file-exists-p path) - (make-directory path t))))) - -;; Save history across sessions -(require 'savehist) -(setq savehist-file (concat narf-temp-dir "/savehist") - savehist-save-minibuffer-history t - savehist-additional-variables - '(kill-ring search-ring regexp-search-ring)) -(savehist-mode 1) - -;; text properties severely bloat the history so delete them (courtesy of PythonNut) -(defun unpropertize-savehist () - (mapc (lambda (list) - (with-demoted-errors - (when (boundp list) - (set list (mapcar #'substring-no-properties (eval list)))))) - '(kill-ring minibuffer-history helm-grep-history helm-ff-history file-name-history - read-expression-history extended-command-history evil-ex-history))) -(add-hook 'kill-emacs-hook #'unpropertize-savehist) -(add-hook 'savehist-save-hook #'unpropertize-savehist) - -(require 'recentf) -(setq recentf-save-file (concat narf-temp-dir "/recentf") - recentf-exclude '("/tmp/" "/ssh:" "\\.?ido\\.last$" "\\.revive$" "/TAGS$" - "emacs\\.d/private/cache/.+" "emacs\\.d/workgroups/.+$" "wg-default" - "/company-statistics-cache.el$") - recentf-max-menu-items 0 - recentf-max-saved-items 250 - recentf-auto-cleanup 600) -(recentf-mode 1) + (mapc (lambda (dir) + (let ((path (concat narf-temp-dir dir))) + (unless (file-exists-p path) + (make-directory path t)))) + '("" "/undo" "/backup"))) (use-package persistent-soft :commands (persistent-soft-store @@ -141,8 +160,6 @@ async-wait async-inject-variables)) - -;; (require (cond (IS-MAC 'core-os-osx) (IS-LINUX 'core-os-linux) (IS-WINDOWS 'core-os-win32))) diff --git a/init.el b/init.el index 847134323..1d04e3b6e 100644 --- a/init.el +++ b/init.el @@ -70,7 +70,7 @@ module-crystal ; ruby at the speed of c module-csharp ; unity, .NET, and mono shenanigans module-go ; the hipster dialect - module-haskell ; a language that's lazier than me + module-haskell ; a language that's lazier than I am module-java ; the poster child for carpal tunnel syndome module-js ; all(hope(abandon(ye(who(enter(here)))))) module-lisp ; drowning in parentheses diff --git a/modules/module-ansible.el b/modules/module-ansible.el index 341cd0825..b75a8914c 100644 --- a/modules/module-ansible.el +++ b/modules/module-ansible.el @@ -7,8 +7,10 @@ :lighter " ans" :keymap (make-sparse-keymap)) (associate! ansible-mode :in (yaml-mode) :files ("roles/")) -(use-package company-ansible :defer t) -(define-company-backend! ansible-mode (ansible)) +(use-package company-ansible + :defer t + :init + (define-company-backend! ansible-mode (ansible))) (provide 'module-ansible) ;;; module-ansible.el ends here diff --git a/modules/module-ruby.el b/modules/module-ruby.el index 67bd75771..9191f91c9 100644 --- a/modules/module-ruby.el +++ b/modules/module-ruby.el @@ -8,7 +8,7 @@ "/\\(Gem\\|Cap\\|Vagrant\\|Rake\\)file$") :interpreter "ruby" :init - (add-hook! ruby-mode 'flycheck-mode) + (add-hook 'ruby-mode-hook 'flycheck-mode) (define-docset! ruby-mode "rb,ruby,rubygem") (define-builder! ruby-mode "rake %s" "Rakefile") (define-env-command! ruby-mode "ruby --version | cut -d' ' -f2") diff --git a/modules/module-sh.el b/modules/module-sh.el index 585876651..691cd06b6 100644 --- a/modules/module-sh.el +++ b/modules/module-sh.el @@ -5,7 +5,6 @@ :config (setq company-shell-delete-duplicates t)) -(associate! sh-mode :match "/\\.dotfiles/aliases$") (associate! sh-mode :match "/\\.?z\\(sh/.*\\|profile\\|login\\|logout\\|shrc\\|shenv\\)$") (associate! sh-mode :match "/\\.?bash\\(/.*\\|rc\\|_profile\\)$") (after! sh-script diff --git a/modules/module-text.el b/modules/module-text.el index 388c5f9f2..9109d4512 100644 --- a/modules/module-text.el +++ b/modules/module-text.el @@ -1,14 +1,13 @@ ;;; module-text.el (use-package markdown-mode - :mode (("\\.md$" . markdown-mode) - ("/README$" . markdown-mode)) + :mode ("\\.md$" "/README$") :functions (markdown-use-region-p markdown-unwrap-things-in-region markdown-wrap-or-insert markdown-unwrap-thing-at-point) :init - (add-hook! markdown-mode 'narf|enable-hard-wrap) + (add-hook 'markdown-mode-hook 'narf|enable-hard-wrap) :config (sp-local-pair 'markdown-mode "```" "```" :post-handlers '(("||\n[i]" "RET")) diff --git a/private/my-bindings.el b/private/my-bindings.el index 593fcd212..fabacf921 100644 --- a/private/my-bindings.el +++ b/private/my-bindings.el @@ -6,7 +6,7 @@ (eval-when-compile (require 'core-defuns)) -;; See `narf-leader-prefix' & `narf-localleader-prefix' in ../core/core-vars.el +;; See `narf-leader-prefix' & `narf-localleader-prefix' in ../core/core.el (map! ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;