forked from magnars/.emacs.d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-ido.el
77 lines (61 loc) · 2.44 KB
/
setup-ido.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
;; Interactively Do Things
(require 'ido)
(ido-mode t)
(setq ido-enable-prefix nil
ido-enable-flex-matching t
ido-case-fold nil
ido-auto-merge-work-directories-length -1
ido-create-new-buffer 'always
ido-use-filename-at-point nil
ido-max-prospects 10)
;; Try out flx-ido for better flex matching between words
(require 'flx-ido)
(flx-ido-mode 1)
;; disable ido faces to see flx highlights.
(setq ido-use-faces nil)
;; flx-ido looks better with ido-vertical-mode
(require 'ido-vertical-mode)
(ido-vertical-mode)
(defun sd/ido-define-keys () ;; C-n/p is more intuitive in vertical layout
(define-key ido-completion-map (kbd "C-n") 'ido-next-match)
(define-key ido-completion-map (kbd "<down>") 'ido-next-match)
(define-key ido-completion-map (kbd "C-p") 'ido-prev-match)
(define-key ido-completion-map (kbd "<up>") 'ido-prev-match))
(require 'dash)
(defun my/setup-ido ()
;; Go straight home
(define-key ido-file-completion-map
(kbd "~")
(lambda ()
(interactive)
(cond
((looking-back "~/") (insert "projects/"))
((looking-back "/") (insert "~/"))
(:else (call-interactively 'self-insert-command)))))
;; Use C-w to go back up a dir to better match normal usage of C-w
;; - insert current file name with C-x C-w instead.
(define-key ido-file-completion-map (kbd "C-w") 'ido-delete-backward-updir)
(define-key ido-file-completion-map (kbd "C-x C-w") 'ido-copy-current-file-name)
(define-key ido-file-dir-completion-map (kbd "C-w") 'ido-delete-backward-updir)
(define-key ido-file-dir-completion-map (kbd "C-x C-w") 'ido-copy-current-file-name))
(add-hook 'ido-setup-hook 'my/setup-ido)
;; Always rescan buffer for imenu
(set-default 'imenu-auto-rescan t)
(add-to-list 'ido-ignore-directories "target")
(add-to-list 'ido-ignore-directories "node_modules")
;; Ido at point (C-,)
;; (require 'ido-at-point)
;; (ido-at-point-mode)
;; Use ido everywhere
(require 'ido-ubiquitous)
(ido-ubiquitous-mode 1)
;; Fix ido-ubiquitous for newer packages
(defmacro ido-ubiquitous-use-new-completing-read (cmd package)
`(eval-after-load ,package
'(defadvice ,cmd (around ido-ubiquitous-new activate)
(let ((ido-ubiquitous-enable-compatibility nil))
ad-do-it))))
(ido-ubiquitous-use-new-completing-read webjump 'webjump)
(ido-ubiquitous-use-new-completing-read yas-expand 'yasnippet)
(ido-ubiquitous-use-new-completing-read yas-visit-snippet-file 'yasnippet)
(provide 'setup-ido)