git.fiddlerwoaroof.com
Browse code

Emacs, vim

emacs: update find-system to work between cl and clojure
vim: rearrange vimrc_work

Ed Langley authored on 20/04/2019 04:44:10
Showing 5 changed files
... ...
@@ -181,6 +181,26 @@ With a prefix ARG invalidates the cache first."
181 181
 (use-package cl-generic
182 182
   :ensure t)
183 183
 
184
+(defun intercept-print (f)
185
+  (print f)
186
+  f)
187
+
188
+(cl-defmethod fwoar--find-system (&context (major-mode clojure-mode))
189
+  (let ((systems (directory-files
190
+                  (locate-dominating-file default-directory
191
+                                          (lambda (n)
192
+                                            (or (directory-files n nil "project.clj")
193
+                                                (directory-files n nil "build.boot")
194
+                                                (directory-files n nil "deps.edn")
195
+                                                (directory-files n nil "shadow-cljs.edn"))))
196
+                  t "^\\(project.clj\\|build.boot\\|deps.edn\\|shadow-cljs.edn\\)$")))
197
+    (find-file (if (not (null (cdr systems)))
198
+                   (helm-comp-read "system:" systems)
199
+                 (car systems)))))
200
+
201
+(def-cider-selector-method ?S "find clojure project file"
202
+  (fwoar--find-system))
203
+
184 204
 (cl-defgeneric fwoar--pl-selector ()
185 205
   (:method ()
186 206
            (slime-selector))
... ...
@@ -28,6 +28,7 @@
28 28
 (add-hook 'lisp-mode-hook 'setup-lisp-mode) 
29 29
 (add-hook 'emacs-lisp-mode-hook 'setup-lisp-mode) 
30 30
 
31
+(evil-define-key 'normal lisp-mode-map "gd" 'slime-edit-definition)
31 32
 
32 33
 (modify-syntax-entry ?- "w" lisp-mode-syntax-table)
33 34
 (modify-syntax-entry ?* "w" lisp-mode-syntax-table)
... ...
@@ -65,7 +66,8 @@
65 66
          slime-selector-methods
66 67
          :key #'car)
67 68
 
68
-(defun fwoar--slime-find-system ()
69
+(cl-defgeneric fwoar--find-system ())
70
+(cl-defmethod fwoar--find-system (&context (major-mode lisp-mode))
69 71
   (let ((systems (directory-files
70 72
                   (locate-dominating-file default-directory
71 73
                                           (lambda (n)
... ...
@@ -75,7 +77,7 @@
75 77
                    (helm-comp-read "system:" systems)
76 78
                  (car systems)))))
77 79
 
78
-(pushnew (list ?S "Goto System" #'fwoar--slime-find-system)
80
+(pushnew (list ?S "Goto System" #'fwoar--find-system)
79 81
          slime-selector-methods
80 82
          :key #'car)
81 83
 
... ...
@@ -1,7 +1,7 @@
1 1
 #!/usr/bin/osascript
2 2
 on run argv
3 3
   set currentApp to my getCurrentApp()
4
-  do shell script "/usr/local/bin/emacsclient -c '" & (item 1 of argv) & "' '" & (item 2 of argv) & "'"
4
+  do shell script "/usr/local/bin/emacsclient -c '" & (item 1 of argv) & "'"
5 5
   do shell script "open '/Volumes/" & currentApp & "'"
6 6
 end run
7 7
 
... ...
@@ -1,4 +1,7 @@
1
-"dein Scripts-----------------------------
1
+" vim: foldmethod=marker foldlevel=2 :
2
+"dein Scripts----------------------------- {{{1
3
+"dein init {{{3
4
+
2 5
 if &compatible
3 6
   set nocompatible               " Be iMproved
4 7
 endif
... ...
@@ -15,6 +18,8 @@ if dein#load_state(vim_config_directory)
15 18
   " Required:
16 19
   call dein#add(vim_config_directory.'/repos/github.com/Shougo/dein.vim')
17 20
 
21
+"}}}3
22
+" plugins {{{2
18 23
   call dein#add('LnL7/vim-nix')
19 24
   call dein#add('Shougo/vimproc', {'build': 'make'})
20 25
   call dein#add('Shougo/unite-outline')
... ...
@@ -43,8 +48,9 @@ if dein#load_state(vim_config_directory)
43 48
   call dein#add('vim-scripts/matchit.zip')
44 49
   call dein#add('vim-voom/VOoM')
45 50
   call dein#add('jnurmine/zenburn')
46
-
47
-
51
+  call dein#add('jremmen/vim-ripgrep')
52
+"}}}2
53
+"{{{3
48 54
   " Required:
49 55
   call dein#end()
50 56
   call dein#save_state()
... ...
@@ -53,29 +59,19 @@ endif
53 59
 " Required:
54 60
 filetype plugin indent on
55 61
 syntax enable
56
-
57 62
 " If you want to install not installed plugins on startup.
58 63
 if dein#check_install()
59 64
   call dein#install()
60 65
 endif
61
-"End dein Scripts-------------------------
66
+
67
+"}}}3
68
+"End dein Scripts }}}1
62 69
 
63 70
 let g:airline_theme="murmur"
64 71
 let maplocalleader=','
65 72
 
66 73
 filetype indent on
67 74
 
68
-"Enable support for Color xterm
69
-:if has("terminfo")
70
-:  set t_Co=8
71
-:  set t_Sf=^[[3%p1%dm
72
-:  set t_Sb=^[[4%p1%dm
73
-:else
74
-:  set  t_Co=8
75
-:  set t_Sf=^[[3%dm
76
-:  set t_Sb=^[[4%dm
77
-:endif
78
-
79 75
 set ignorecase
80 76
 set smartcase
81 77
 set nu
... ...
@@ -104,7 +100,7 @@ set modelines=1      " CVE-2007-2438
104 100
 set backspace=2      " more powerful backspacing
105 101
 
106 102
 syntax enable
107
-colorscheme zenburn
103
+"colorscheme zenburn
108 104
 
109 105
 function! Checkft()
110 106
   if &filetype==""
... ...
@@ -129,27 +125,12 @@ if filereadable(".vim.custom")
129 125
     so .vim.custom
130 126
 endif
131 127
 
132
-call unite#custom#source('file,file/new,buffer,file_rec','matchers','matcher_fuzzy')
133
-
134
-autocmd FileType unite call s:unite_my_settings()
135
-function! s:unite_my_settings()
136
-  " Overwrite settings.
137
-  let b:SuperTabDisabled=1
138
-  imap <buffer><expr> <C-v>     unite#do_action('vsplit')
139
-  imap <buffer><expr> <C-s>     unite#do_action('split')
140
-  imap <buffer>  <Tab>     <Plug>(unite_complete)
141
-  imap <buffer> <C-j>   <Plug>(unite_select_next_line)
142
-  imap <buffer> <Down>   <Plug>(unite_select_next_line)
143
-  imap <buffer> <C-k>   <Plug>(unite_select_previous_line)
144
-  imap <buffer> <Up>   <Plug>(unite_select_previous_line)
145
-
146
-  " exit with esc
147
-  nmap <buffer> <ESC> <Plug>(unite_exit)
128
+nmap <F2> :set nu!<CR>
129
+imap <F2> <C-o>:set nu!<CR>
148 130
 
149
-  " exit with ctrl-c
150
-  imap <buffer> <c-c> <Plug>(unite_exit)
151
-  nmap <buffer> <c-c> <Plug>(unite_exit)
152
-endfunction
131
+"unite settings {{{1
132
+"unite variable setup {{{3
133
+call unite#custom#source('file,file/new,buffer,file_rec','matchers','matcher_fuzzy')
153 134
 
154 135
 if executable('ag')
155 136
   let g:unite_source_file_async_command = ['ag', '--follow', '--nocolor', '--nogroup', '--hidden', '-g', '""', '--ignore', '''.sass-cache''']
... ...
@@ -176,10 +157,29 @@ elseif executable('ack')
176 157
   let g:unite_source_grep_default_opts = '--exclude ''\.(git|svn|hg|bzr)'''
177 158
   let g:unite_source_grep_recursive_opt = ''
178 159
 endif
160
+"}}}3
161
+"window keybindings {{{2
162
+autocmd FileType unite call s:unite_my_settings()
163
+function! s:unite_my_settings()
164
+  " Overwrite settings.
165
+  let b:SuperTabDisabled=1
166
+  imap <buffer><expr> <C-v>   unite#do_action('vsplit')
167
+  imap <buffer><expr> <C-s>   unite#do_action('split')
168
+  imap <buffer>       <Tab>   <Plug>(unite_complete)
169
+  imap <buffer>       <C-j>   <Plug>(unite_select_next_line)
170
+  imap <buffer>       <Down>  <Plug>(unite_select_next_line)
171
+  imap <buffer>       <C-k>   <Plug>(unite_select_previous_line)
172
+  imap <buffer>       <Up>    <Plug>(unite_select_previous_line)
179 173
 
180
-nmap <F2> :set nu!<CR>
181
-imap <F2> <C-o>:set nu!<CR>
174
+  " exit with esc
175
+  nmap <buffer>       <ESC>   <Plug>(unite_exit)
182 176
 
177
+  " exit with ctrl-c
178
+  imap <buffer>       <c-c>   <Plug>(unite_exit)
179
+  nmap <buffer>       <c-c>   <Plug>(unite_exit)
180
+endfunction
181
+"}}}2
182
+"unite commands {{{2
183 183
 nnoremap [unite] <Nop>
184 184
 nmap <space> [unite]
185 185
 
... ...
@@ -190,17 +190,20 @@ nmap                 [unite]F :<C-u>Unite file -start-insert<C-m>
190 190
 nmap                 [unite]g :<C-u>Unite file_rec/git -start-insert<C-m>
191 191
 nmap                 [unite]j :<C-u>Unite buffer -start-insert<C-m>
192 192
 nmap                 [unite]k :<C-u>Unite tab:no-current<C-m>
193
-
194
-nmap                 [unite]t :NERDTreeToggle<CR>
195
-nmap                 [unite]u :GundoToggle<CR>
196
-"nmap                 [unite]r :!vagrant rsync<CR>
193
+"}}}2
194
+"}}}1
195
+"space-prefixed commands {{{1
197 196
 nmap                 [unite]h :set hlsearch!<CR>
198 197
 nmap                 [unite]l :set list!<CR>
199
-nmap <silent> <expr> [unite]z FS_ToggleFoldAroundSearch({'context':2})
200
-nmap          <expr> [unite]x FS_ToggleFoldAroundSearch({'context':0})
201
-nmap                 [unite]w :let @/='\<<C-r><C-w>\>'<CR>:set hlsearch<CR>
202 198
 nmap                 [unite]r :s/<C-r><C-w>/<C-r>=input('replacement? ').'/g'<CR>
199
+"nmap                 [unite]r :!vagrant rsync<CR>
203 200
 nmap                 [unite]R :%s/<C-r><C-w>/<C-r>=input('replacement? ').'/g'<CR>
201
+nmap                 [unite]t :NERDTreeToggle<CR>
202
+nmap                 [unite]u :GundoToggle<CR>
203
+nmap                 [unite]w :let @/='\<<C-r><C-w>\>'<CR>:set hlsearch<CR>
204
+nmap          <expr> [unite]x FS_ToggleFoldAroundSearch({'context':0})
205
+nmap <silent> <expr> [unite]z FS_ToggleFoldAroundSearch({'context':2})
206
+"}}}1
204 207
 
205 208
 nmap                 <C-x>o <C-w><C-w>
206 209
 
... ...
@@ -208,6 +211,18 @@ autocmd BufRead,BufNewFile *.css,*.scss,*.less setlocal foldmethod=marker foldma
208 211
 
209 212
 command -nargs=+ Gadd Git add <q-args>
210 213
 
214
+"cursor setup / terminal setup {{{1
215
+"Enable support for Color xterm
216
+:if has("terminfo")
217
+:  set t_Co=8
218
+:  set t_Sf=^[[3%p1%dm
219
+:  set t_Sb=^[[4%p1%dm
220
+:else
221
+:  set  t_Co=8
222
+:  set t_Sf=^[[3%dm
223
+:  set t_Sb=^[[4%dm
224
+:endif
225
+
211 226
 if &term =~ '^\(xterm\)\|\(screen\)'
212 227
   " solid underscore
213 228
   let &t_SI .= "\<Esc>[3 q"
... ...
@@ -220,5 +235,12 @@ if &term =~ '^\(xterm\)\|\(screen\)'
220 235
   " 6 -> solid vertical bar
221 236
 endif
222 237
 set timeoutlen=1000 ttimeoutlen=0
238
+"}}}1
223 239
 
224 240
 command FwoarSc ':let g:syntastic_sh_shellcheck_tail = " -x"'
241
+
242
+
243
+runtime ftplugin/man.vim
244
+let g:ft_man_open_mode = 'vert'
245
+let g:ft_man_folding_enable = 1
246
+autocmd FileType man setlocal foldmethod=indent foldenable foldlevel=0
... ...
@@ -1,4 +1,5 @@
1 1
 #:depends-on:git-get
2
+autoload -U regexp-replace
2 3
 GIT_DEBUG=0
3 4
 
4 5
 git-update-repos() {
... ...
@@ -93,6 +94,24 @@ for line in sys.stdin:
93 94
       print("%s\n\t%s" % (":".join(line[2:]), ":".join(line[:2])))'
94 95
 }
95 96
 
97
+git-gh-create() {
98
+  local repo_name=${1?need a repo name}
99
+  regexp-replace repo_name '[" ]' '-'
100
+  local GH_TOKEN
101
+  source "$HOME/.github-token"
102
+ jq '{full_name, clone_url, ssh_url}' <( (
103
+  curl -XPOST \
104
+       -u "fiddlerwoaroof:$GH_TOKEN" \
105
+       https://api.github.com/user/repos \
106
+      -H 'Content-Type: application/json' \
107
+      --data-binary @- <<-EOF
108
+{
109
+  "name": "${repo_name}"
110
+}
111
+EOF
112
+  ) )
113
+}
114
+
96 115
 alias git-msg=git-messages
97 116
 alias git-cj="git-get cj"
98 117
 alias git-hub="git-get github"