comparison plugin/lawrencium.vim @ 4:b6e4446ed292

HgStatus now outputs to the location window. Fixed some commands naming.
author Ludovic Chabant <ludovic@chabant.com>
date Thu, 08 Dec 2011 17:19:52 -0800
parents 0a5b490dc35d
children 3a4f9f41a7e2
comparison
equal deleted inserted replaced
3:fc4a778325d4 4:b6e4446ed292
186 autocmd VimEnter * if expand('<amatch>')==''|call s:setup_buffer_commands()|endif 186 autocmd VimEnter * if expand('<amatch>')==''|call s:setup_buffer_commands()|endif
187 augroup end 187 augroup end
188 188
189 " }}} 189 " }}}
190 190
191 " Commands {{{ 191 " Main Buffer Commands {{{
192 192
193 let s:main_commands = [] 193 let s:main_commands = []
194 194
195 function! s:AddMainCommand(command) abort 195 function! s:AddMainCommand(command) abort
196 let s:main_commands += [a:command] 196 let s:main_commands += [a:command]
205 augroup lawrencium_main 205 augroup lawrencium_main
206 autocmd! 206 autocmd!
207 autocmd User Lawrencium call s:DefineMainCommands() 207 autocmd User Lawrencium call s:DefineMainCommands()
208 augroup end 208 augroup end
209 209
210 " }}} 210
211 211 " Hg {{{
212 " HgExecute {{{ 212
213 213 function! s:Hg(...) abort
214 function! s:HgExecute(...) abort
215 let l:repo = s:hg_repo() 214 let l:repo = s:hg_repo()
216 echo call(l:repo.RunCommand, a:000, l:repo) 215 echo call(l:repo.RunCommand, a:000, l:repo)
217 endfunction 216 endfunction
218 217
219 call s:AddMainCommand("-nargs=* Hg :execute s:HgExecute(<f-args>)") 218 call s:AddMainCommand("-nargs=* Hg :execute s:Hg(<f-args>)")
220 219
221 " }}} 220 " }}}
222 221
223 " HgStatus {{{ 222 " Hgstatus {{{
223
224 let s:hg_status_messages = {
225 \'M': 'modified',
226 \'A': 'added',
227 \'R': 'removed',
228 \'C': 'clean',
229 \'!': 'missing',
230 \'?': 'not tracked',
231 \'I': 'ignored',
232 \}
224 233
225 function! s:HgStatus() abort 234 function! s:HgStatus() abort
226 echo s:hg_repo().RunCommand('status') 235 let l:repo = s:hg_repo()
227 endfunction 236 let l:status_text = l:repo.RunCommand('status')
228 237 let l:status_lines = split(l:status_text, '\n')
229 call s:AddMainCommand("HgStatus :execute s:HgStatus()") 238 let l:entries = []
239 for l:line in l:status_lines
240 if l:line =~# '^\s*$'
241 continue
242 endif
243 echom "STATUS: " . l:line
244 let l:tokens = split(l:line, '\s\+')
245 let l:entry = {
246 \'type': l:tokens[0],
247 \'filename': (l:repo.root_dir . l:tokens[1]),
248 \'text': s:hg_status_messages[l:tokens[0]],
249 \}
250 call add(l:entries, l:entry)
251 endfor
252 call setloclist(0, l:entries)
253 lopen
254 endfunction
255
256 call s:AddMainCommand("Hgstatus :execute s:HgStatus()")
230 257
231 " }}} 258 " }}}
232 259
233 " Hgcd, Hglcd {{{ 260 " Hgcd, Hglcd {{{
234 261
250 call map(l:matches, 's:normalizepath(v:val)') 277 call map(l:matches, 's:normalizepath(v:val)')
251 return l:matches 278 return l:matches
252 endfunction 279 endfunction
253 280
254 call s:AddMainCommand("-bang -nargs=? -complete=customlist,s:ListRepoFiles Hgedit :edit<bang> `=s:hg_repo().GetFullPath(<q-args>)`") 281 call s:AddMainCommand("-bang -nargs=? -complete=customlist,s:ListRepoFiles Hgedit :edit<bang> `=s:hg_repo().GetFullPath(<q-args>)`")
282
283 " }}}
255 284
256 " }}} 285 " }}}
257 286
258 " Autoload Functions {{{ 287 " Autoload Functions {{{
259 288