Skip to content

Commit 5ff75fa

Browse files
nicoraffovim-scripts
authored andcommitted
Version 0.3
* Apply escape sequence coloring to output, e.g. ls --color * Clean up syntax files for portability * Fix several Vim 7.1 bugs * Bugfixes for multiple shell buffers * Add experimental shell folding option
1 parent 426189d commit 5ff75fa

File tree

7 files changed

+355
-79
lines changed

7 files changed

+355
-79
lines changed

INSTALL renamed to README.orig

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11

2-
CONQUE
2+
Conque - Interactive shell buffer for Vim
33

4-
== Requirements ==
4+
version: 0.3
5+
6+
== REQUIREMENTS ==
57

68
* Python-enabled Vim 7.0+
79
* Some functionality only available on Linux-like system with pty libraries
810

9-
== Installation Instructions ==
11+
== INSTALLATION ==
1012

1113
Copy files from conque/ into your .vim directory, for example:
1214

@@ -16,7 +18,7 @@ $HOME/.vim/autoload/conque.vim
1618
$HOME/.vim/autoload/subprocess.vim
1719
$HOME/.vim/autoload/subprocess/proc_py.vim
1820

19-
== Usage ==
21+
== USAGE ==
2022

2123
Type :Conque <command> to run your command in vim, for example:
2224

@@ -28,7 +30,27 @@ To open Conque in a new horizontal or vertical buffer use:
2830
or
2931
:ConqueVSplit <command>
3032

31-
== Troubleshooting ==
33+
== CONFIG OPTIONS ==
34+
35+
The following options can be added to your .vimrc file. (Defaults shown below)
36+
37+
" Use '...' filler characters while waiting for a response. Prevents sending extra <CR>'s to the terminal, although in some cases that may be desirable.
38+
" 1 = on, 0 = off
39+
let g:Conque_Use_Filler = 1
40+
41+
" Return prompt to user after this many miliseconds without any new output from the terminal.
42+
" Increasing this value will cause fewer '...' read timeouts, but will also make the terminal appear less responsive.
43+
let g:Conque_Read_Timeout = 40
44+
45+
" Use this syntax type with Conque. The default is relatively stripped down, although it does provide good MySQL highlighting
46+
let g:Conque_Syntax = 'conque'
47+
48+
" Allow commands plus their output to be folded. If the commands you run produce large amounts of output, folding
49+
" them can make the terminal more readable. Very experimental. 1 = on, 0 = off
50+
let g:Conque_Folding = 0
51+
52+
53+
== TROUBLESHOOTING ==
3254

3355
The most common problem will be not having Python enabled in your installation of Vim. Recent versions of Vim should come with Python enabled by default. To check for Python, run the ":version" command and check for "+python". If instead you see "-python" or "+python/dyn", it may mean you will need to install it.
3456

@@ -44,3 +66,24 @@ The latest version of MacVim will have Python enabled. See http://code.google.co
4466

4567
Most installations of Vim 7+ these days come built with Python.
4668

69+
== CHANGELOG ==
70+
71+
- 0.3 / 2009-10-13 -
72+
* Apply escape sequence coloring to output, e.g. ls --color
73+
* Clean up syntax files for portability
74+
* Fix several Vim 7.1 bugs
75+
* Bugfixes for multiple shell buffers
76+
* Add experimental shell folding option
77+
78+
- 0.2 / 2009-10-01
79+
* Rewritten subprocess management module in python instead of c
80+
* Added support for OS X, partial support for Windows
81+
* Improved tab completion
82+
83+
- 0.1 / 2009-09-03
84+
* Initial release
85+
86+
== FOR MORE INFORMATION ==
87+
88+
http://code.google.com/p/conque/
89+

autoload/conque.vim

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
" FILE: autoload/conque.vim
22
" AUTHOR: Nico Raffo <nicoraffo@gmail.com>
3-
" MODIFIED: 2009-10-01
4-
" VERSION: 0.2, for Vim 7.0
3+
" MODIFIED: 2009-10-13
4+
" VERSION: 0.3, for Vim 7.0
55
" LICENSE: {{{
66
" Conque - pty interaction in Vim
77
" Copyright (C) 2009 Nico Raffo
@@ -33,7 +33,6 @@ function! conque#open(...)"{{{
3333
let command = get(a:000, 0, '')
3434
let hooks = get(a:000, 1, [])
3535

36-
3736
if empty(command)
3837
echohl WarningMsg | echomsg "No command found" | echohl None
3938
return 0
@@ -58,11 +57,12 @@ function! conque#open(...)"{{{
5857
" Set variables.
5958
let b:command_history = []
6059
let b:prompt_history = {}
60+
let b:fold_history = {}
6161
let b:current_command = ''
6262
let b:command_position = 0
6363

6464
" read welcome message from command
65-
call s:read(0.5)
65+
call s:read(500)
6666

6767

6868
startinsert!
@@ -72,12 +72,10 @@ endfunction"}}}
7272
" set shell environment vars
7373
" XXX - probably should delegate this to logic in .bashrc?
7474
function! s:set_environment()"{{{
75-
let $TERM = "dumb"
75+
"let $TERM = "dumb"
7676
"let $TERMCAP = "COLUMNS=" . winwidth(0)
77-
let $VIMSHELL = 1
7877
let $COLUMNS = winwidth(0) - 8 " these get reset by terminal anyway
7978
let $LINES = winheight(0)
80-
8179
endfunction"}}}
8280

8381
" buffer settings, layout, key mappings, and auto commands
@@ -87,14 +85,15 @@ function! s:set_buffer_settings(command, pre_hooks)"{{{
8785
execute h
8886
endfor
8987

90-
execute "edit " . substitute(a:command, ' ', '_', 'g') . "@" . bufnr('.', 1)
88+
execute "edit " . substitute(a:command, ' ', '_', 'g') . "@" . string(bufnr('$', 1)+1)
9189
setlocal buftype=nofile " this buffer is not a file, you can't save it
9290
setlocal nonumber " hide line numbers
9391
setlocal foldcolumn=1 " reasonable left margin
9492
setlocal nowrap " default to no wrap (esp with MySQL)
9593
setlocal noswapfile " don't bother creating a .swp file
96-
setfiletype conque " useful
94+
setfiletype conque " useful
9795
execute "setlocal syntax=".g:Conque_Syntax
96+
setlocal foldmethod=manual
9897

9998
" run the current command
10099
nnoremap <buffer><silent><CR> :<C-u>call conque#run()<CR>
@@ -137,10 +136,8 @@ function! conque#run()"{{{
137136
return
138137
endif
139138

140-
141139
call conque#write(1)
142140
call s:read(g:Conque_Read_Timeout)
143-
144141
endfunction"}}}
145142

146143
" execute current line, but return output as string instead of printing to buffer
@@ -166,7 +163,6 @@ endfunction"}}}
166163

167164
" write current line to pty
168165
function! conque#write(add_newline)"{{{
169-
170166
" pull command from the buffer
171167
let l:in = s:get_command()
172168

@@ -198,6 +194,7 @@ function! conque#write(add_newline)"{{{
198194
let l:hc = l:in
199195
endif
200196
if l:hc != '' && l:hc != '...' && l:hc !~ '\t$'
197+
let b:fold_history[line('.')] = 1
201198
call add(b:command_history, l:hc)
202199
endif
203200
let b:current_command = l:in
@@ -272,7 +269,6 @@ endfunction"}}}
272269

273270
" read from pty and write to buffer
274271
function! s:read(timeout)"{{{
275-
276272
try
277273
let l:output = b:subprocess.read(a:timeout)
278274
catch
@@ -284,17 +280,17 @@ function! s:read(timeout)"{{{
284280
call s:print_buffer(l:output)
285281
redraw
286282

283+
" ready to insert now
284+
normal! G$
285+
287286
" record prompt used on this line
288287
let b:prompt_history[line('.')] = getline('.')
289288

290-
" ready to insert now
291-
normal! G$
292289
startinsert!
293290
endfunction"}}}
294291

295292
" read from pty and return output as string
296293
function! conque#read_return_raw(timeout)"{{{
297-
298294
try
299295
let l:output = b:subprocess.read(a:timeout)
300296
catch
@@ -318,12 +314,6 @@ function! s:print_buffer(read_lines)"{{{
318314
" Convert encoding for system().
319315
let l:string = iconv(l:string, 'utf-8', &encoding)
320316

321-
" check for Bells
322-
if l:string =~ nr2char(7)
323-
let l:string = substitute(l:string, nr2char(7), '', 'g')
324-
echohl WarningMsg | echomsg "For shame!" | echohl None
325-
endif
326-
327317
" strip backspaces out of output
328318
while l:string =~ '\b'
329319
let l:string = substitute(l:string, '[^\b]\b', '', 'g')
@@ -349,10 +339,26 @@ function! s:print_buffer(read_lines)"{{{
349339
endif
350340

351341
" write to buffer
352-
call setline(line('$'), l:lines)
342+
let l:pos = 1
343+
for eline in l:lines
344+
if l:pos == 1
345+
call setline(line('$'), eline)
346+
else
347+
call append(line('$'), eline)
348+
endif
349+
normal! G$
350+
call subprocess#shell_translate#process_current_line()
351+
let l:pos = l:pos + 1
352+
endfor
353353

354-
" Set cursor.
355-
normal! G$
354+
" fold output
355+
if g:Conque_Folding == 1
356+
if !exists('b:fold_history[line("$")-1]') && max(keys(b:fold_history)) < line("$")-1 && len(keys(b:fold_history)) > 0 && getline(line('$')) != getline(line('$')-1)
357+
let l:fold_command = max(keys(b:fold_history)) . "," . (line("$")-1) . "fo"
358+
execute l:fold_command
359+
normal! kzoG$
360+
endif
361+
endif
356362
endfunction"}}}
357363

358364
function! conque#on_exit() "{{{
@@ -518,7 +524,6 @@ function! s:tab_complete()"{{{
518524
call setline(line('.'), l:working_line)
519525
"let b:tab_complete_history[line('.')] = getline(line('.'))
520526
startinsert!
521-
"echohl WarningMsg | echomsg "No completion found" | echohl None
522527
call b:subprocess.write("\<C-u>")
523528
let l:throwaway = conque#read_return_raw(0.001)
524529
let b:prompt_history[line('$')] = l:prompt
@@ -600,7 +605,7 @@ function! conque#sigint()"{{{
600605
call conque#exit()
601606
return
602607
endtry
603-
call s:read(0.5)
608+
call s:read(500)
604609
endfunction"}}}
605610

606611
" implement <Esc>
@@ -615,7 +620,7 @@ function! conque#escape()"{{{
615620
call conque#exit()
616621
return
617622
endtry
618-
call s:read(0.5)
623+
call s:read(500)
619624
endfunction"}}}
620625

621626
" implement <C-z>
@@ -629,7 +634,7 @@ function! conque#suspend()"{{{
629634
call conque#exit()
630635
return
631636
endtry
632-
call s:read(0.5)
637+
call s:read(500)
633638
endfunction"}}}
634639

635640
" implement <C-d>
@@ -643,7 +648,7 @@ function! conque#eof()"{{{
643648
call conque#exit()
644649
return
645650
endtry
646-
call s:read(0.5)
651+
call s:read(500)
647652
endfunction"}}}
648653

649654
" implement <C-\>
@@ -657,8 +662,7 @@ function! conque#quit()"{{{
657662
call conque#exit()
658663
return
659664
endtry
660-
call s:read(0.5)
665+
call s:read(500)
661666
endfunction"}}}
662667

663-
664668
" vim: foldmethod=marker

autoload/subprocess.vim

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
" FILE: autoload/subprocess.vim
22
" AUTHOR: Nico Raffo <nicoraffo@gmail.com>
3-
" MODIFIED: 2009-10-01
4-
" VERSION: 0.2, for Vim 7.0
3+
" MODIFIED: 2009-10-13
4+
" VERSION: 0.3, for Vim 7.0
55
" LICENSE: MIT License "{{{
6-
" Subprocess.vim - subprocess access from Vim
7-
"
86
" Permission is hereby granted, free of charge, to any person obtaining a copy
97
" of this software and associated documentation files (the "Software"), to deal
108
" in the Software without restriction, including without limitation the rights

0 commit comments

Comments
 (0)