Update ALL the plugins!
git-svn-id: http://photonzero.com/dotfiles/trunk@80 23f722f6-122a-0410-8cef-c75bd312dd78
This commit is contained in:
parent
0a85941bf4
commit
0ad6077023
42 changed files with 9620 additions and 1644 deletions
File diff suppressed because it is too large
Load diff
975
.vim/autoload/conque_term/conque.py
Normal file
975
.vim/autoload/conque_term/conque.py
Normal file
File diff suppressed because it is too large
Load diff
287
.vim/autoload/conque_term/conque_globals.py
Normal file
287
.vim/autoload/conque_term/conque_globals.py
Normal file
|
|
@ -0,0 +1,287 @@
|
|||
# FILE: autoload/conque_term/conque_globals.py {{{
|
||||
# AUTHOR: Nico Raffo <nicoraffo@gmail.com>
|
||||
# WEBSITE: http://conque.googlecode.com
|
||||
# MODIFIED: 2010-11-15
|
||||
# VERSION: 2.0, for Vim 7.0
|
||||
# LICENSE:
|
||||
# Conque - Vim terminal/console emulator
|
||||
# Copyright (C) 2009-2010 Nico Raffo
|
||||
#
|
||||
# MIT License
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE. }}}
|
||||
|
||||
"""Common global constants and functions for Conque."""
|
||||
|
||||
import sys
|
||||
import os
|
||||
import re
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# shared memory size
|
||||
CONQUE_SOLE_BUFFER_LENGTH = 1000
|
||||
CONQUE_SOLE_INPUT_SIZE = 1000
|
||||
CONQUE_SOLE_STATS_SIZE = 1000
|
||||
CONQUE_SOLE_COMMANDS_SIZE = 255
|
||||
CONQUE_SOLE_RESCROLL_SIZE = 255
|
||||
CONQUE_SOLE_RESIZE_SIZE = 255
|
||||
|
||||
# interval of screen redraw
|
||||
# larger number means less frequent
|
||||
CONQUE_SOLE_SCREEN_REDRAW = 100
|
||||
|
||||
# interval of full buffer redraw
|
||||
# larger number means less frequent
|
||||
CONQUE_SOLE_BUFFER_REDRAW = 500
|
||||
|
||||
# interval of full output bucket replacement
|
||||
# larger number means less frequent, 1 = every time
|
||||
CONQUE_SOLE_MEM_REDRAW = 1000
|
||||
|
||||
# PYTHON VERSION
|
||||
CONQUE_PYTHON_VERSION = sys.version_info[0]
|
||||
|
||||
|
||||
def u(str_val, str_encoding='latin-1', errors='strict'):
|
||||
"""foolhardy attempt to make unicode string syntax compatible with both python 2 and 3"""
|
||||
|
||||
if not str_val:
|
||||
str_val = ''
|
||||
|
||||
if CONQUE_PYTHON_VERSION == 3:
|
||||
return str_val
|
||||
|
||||
else:
|
||||
return unicode(str_val, str_encoding, errors)
|
||||
|
||||
# Escape sequence settings {{{
|
||||
|
||||
CONQUE_CTL = {
|
||||
1: 'soh', # start of heading
|
||||
2: 'stx', # start of text
|
||||
7: 'bel', # bell
|
||||
8: 'bs', # backspace
|
||||
9: 'tab', # tab
|
||||
10: 'nl', # new line
|
||||
13: 'cr', # carriage return
|
||||
14: 'so', # shift out
|
||||
15: 'si' # shift in
|
||||
}
|
||||
# 11 : 'vt', # vertical tab
|
||||
# 12 : 'ff', # form feed
|
||||
|
||||
# Escape sequences
|
||||
CONQUE_ESCAPE = {
|
||||
'm': 'font',
|
||||
'J': 'clear_screen',
|
||||
'K': 'clear_line',
|
||||
'@': 'add_spaces',
|
||||
'A': 'cursor_up',
|
||||
'B': 'cursor_down',
|
||||
'C': 'cursor_right',
|
||||
'D': 'cursor_left',
|
||||
'G': 'cursor_to_column',
|
||||
'H': 'cursor',
|
||||
'P': 'delete_chars',
|
||||
'f': 'cursor',
|
||||
'g': 'tab_clear',
|
||||
'r': 'set_coords',
|
||||
'h': 'set',
|
||||
'l': 'reset'
|
||||
}
|
||||
# 'L': 'insert_lines',
|
||||
# 'M': 'delete_lines',
|
||||
# 'd': 'cusor_vpos',
|
||||
|
||||
# Alternate escape sequences, no [
|
||||
CONQUE_ESCAPE_PLAIN = {
|
||||
'D': 'scroll_up',
|
||||
'E': 'next_line',
|
||||
'H': 'set_tab',
|
||||
'M': 'scroll_down'
|
||||
}
|
||||
# 'N': 'single_shift_2',
|
||||
# 'O': 'single_shift_3',
|
||||
# '=': 'alternate_keypad',
|
||||
# '>': 'numeric_keypad',
|
||||
# '7': 'save_cursor',
|
||||
# '8': 'restore_cursor',
|
||||
|
||||
# Character set escape sequences, with "("
|
||||
CONQUE_ESCAPE_CHARSET = {
|
||||
'A': 'uk',
|
||||
'B': 'us',
|
||||
'0': 'graphics'
|
||||
}
|
||||
|
||||
# Uber alternate escape sequences, with # or ?
|
||||
CONQUE_ESCAPE_QUESTION = {
|
||||
'1h': 'new_line_mode',
|
||||
'3h': '132_cols',
|
||||
'4h': 'smooth_scrolling',
|
||||
'5h': 'reverse_video',
|
||||
'6h': 'relative_origin',
|
||||
'7h': 'set_auto_wrap',
|
||||
'8h': 'set_auto_repeat',
|
||||
'9h': 'set_interlacing_mode',
|
||||
'1l': 'set_cursor_key',
|
||||
'2l': 'set_vt52',
|
||||
'3l': '80_cols',
|
||||
'4l': 'set_jump_scrolling',
|
||||
'5l': 'normal_video',
|
||||
'6l': 'absolute_origin',
|
||||
'7l': 'reset_auto_wrap',
|
||||
'8l': 'reset_auto_repeat',
|
||||
'9l': 'reset_interlacing_mode'
|
||||
}
|
||||
|
||||
CONQUE_ESCAPE_HASH = {
|
||||
'8': 'screen_alignment_test'
|
||||
}
|
||||
# '3': 'double_height_top',
|
||||
# '4': 'double_height_bottom',
|
||||
# '5': 'single_height_single_width',
|
||||
# '6': 'single_height_double_width',
|
||||
|
||||
CONQUE_GRAPHICS_SET = [
|
||||
0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
|
||||
0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F,
|
||||
0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
|
||||
0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F,
|
||||
0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
|
||||
0x0028, 0x0029, 0x002A, 0x2192, 0x2190, 0x2191, 0x2193, 0x002F,
|
||||
0x2588, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
|
||||
0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
|
||||
0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
|
||||
0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
|
||||
0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
|
||||
0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x00A0,
|
||||
0x25C6, 0x2592, 0x2409, 0x240C, 0x240D, 0x240A, 0x00B0, 0x00B1,
|
||||
0x2591, 0x240B, 0x2518, 0x2510, 0x250C, 0x2514, 0x253C, 0xF800,
|
||||
0xF801, 0x2500, 0xF803, 0xF804, 0x251C, 0x2524, 0x2534, 0x252C,
|
||||
0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00B7, 0x007F,
|
||||
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
|
||||
0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F,
|
||||
0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
|
||||
0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F,
|
||||
0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
|
||||
0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
|
||||
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
|
||||
0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF,
|
||||
0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7,
|
||||
0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
|
||||
0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7,
|
||||
0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF,
|
||||
0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7,
|
||||
0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
|
||||
0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7,
|
||||
0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF
|
||||
]
|
||||
|
||||
# Font codes {{{
|
||||
CONQUE_FONT = {
|
||||
0: {'description': 'Normal (default)', 'attributes': {'cterm': 'NONE', 'ctermfg': 'NONE', 'ctermbg': 'NONE', 'gui': 'NONE', 'guifg': 'NONE', 'guibg': 'NONE'}, 'normal': True},
|
||||
1: {'description': 'Bold', 'attributes': {'cterm': 'BOLD', 'gui': 'BOLD'}, 'normal': False},
|
||||
4: {'description': 'Underlined', 'attributes': {'cterm': 'UNDERLINE', 'gui': 'UNDERLINE'}, 'normal': False},
|
||||
5: {'description': 'Blink (appears as Bold)', 'attributes': {'cterm': 'BOLD', 'gui': 'BOLD'}, 'normal': False},
|
||||
7: {'description': 'Inverse', 'attributes': {'cterm': 'REVERSE', 'gui': 'REVERSE'}, 'normal': False},
|
||||
8: {'description': 'Invisible (hidden)', 'attributes': {'ctermfg': '0', 'ctermbg': '0', 'guifg': '#000000', 'guibg': '#000000'}, 'normal': False},
|
||||
22: {'description': 'Normal (neither bold nor faint)', 'attributes': {'cterm': 'NONE', 'gui': 'NONE'}, 'normal': True},
|
||||
24: {'description': 'Not underlined', 'attributes': {'cterm': 'NONE', 'gui': 'NONE'}, 'normal': True},
|
||||
25: {'description': 'Steady (not blinking)', 'attributes': {'cterm': 'NONE', 'gui': 'NONE'}, 'normal': True},
|
||||
27: {'description': 'Positive (not inverse)', 'attributes': {'cterm': 'NONE', 'gui': 'NONE'}, 'normal': True},
|
||||
28: {'description': 'Visible (not hidden)', 'attributes': {'ctermfg': 'NONE', 'ctermbg': 'NONE', 'guifg': 'NONE', 'guibg': 'NONE'}, 'normal': True},
|
||||
30: {'description': 'Set foreground color to Black', 'attributes': {'ctermfg': '16', 'guifg': '#000000'}, 'normal': False},
|
||||
31: {'description': 'Set foreground color to Red', 'attributes': {'ctermfg': '1', 'guifg': '#ff0000'}, 'normal': False},
|
||||
32: {'description': 'Set foreground color to Green', 'attributes': {'ctermfg': '2', 'guifg': '#00ff00'}, 'normal': False},
|
||||
33: {'description': 'Set foreground color to Yellow', 'attributes': {'ctermfg': '3', 'guifg': '#ffff00'}, 'normal': False},
|
||||
34: {'description': 'Set foreground color to Blue', 'attributes': {'ctermfg': '4', 'guifg': '#0000ff'}, 'normal': False},
|
||||
35: {'description': 'Set foreground color to Magenta', 'attributes': {'ctermfg': '5', 'guifg': '#990099'}, 'normal': False},
|
||||
36: {'description': 'Set foreground color to Cyan', 'attributes': {'ctermfg': '6', 'guifg': '#009999'}, 'normal': False},
|
||||
37: {'description': 'Set foreground color to White', 'attributes': {'ctermfg': '7', 'guifg': '#ffffff'}, 'normal': False},
|
||||
39: {'description': 'Set foreground color to default (original)', 'attributes': {'ctermfg': 'NONE', 'guifg': 'NONE'}, 'normal': True},
|
||||
40: {'description': 'Set background color to Black', 'attributes': {'ctermbg': '16', 'guibg': '#000000'}, 'normal': False},
|
||||
41: {'description': 'Set background color to Red', 'attributes': {'ctermbg': '1', 'guibg': '#ff0000'}, 'normal': False},
|
||||
42: {'description': 'Set background color to Green', 'attributes': {'ctermbg': '2', 'guibg': '#00ff00'}, 'normal': False},
|
||||
43: {'description': 'Set background color to Yellow', 'attributes': {'ctermbg': '3', 'guibg': '#ffff00'}, 'normal': False},
|
||||
44: {'description': 'Set background color to Blue', 'attributes': {'ctermbg': '4', 'guibg': '#0000ff'}, 'normal': False},
|
||||
45: {'description': 'Set background color to Magenta', 'attributes': {'ctermbg': '5', 'guibg': '#990099'}, 'normal': False},
|
||||
46: {'description': 'Set background color to Cyan', 'attributes': {'ctermbg': '6', 'guibg': '#009999'}, 'normal': False},
|
||||
47: {'description': 'Set background color to White', 'attributes': {'ctermbg': '7', 'guibg': '#ffffff'}, 'normal': False},
|
||||
49: {'description': 'Set background color to default (original).', 'attributes': {'ctermbg': 'NONE', 'guibg': 'NONE'}, 'normal': True},
|
||||
90: {'description': 'Set foreground color to Black', 'attributes': {'ctermfg': '8', 'guifg': '#000000'}, 'normal': False},
|
||||
91: {'description': 'Set foreground color to Red', 'attributes': {'ctermfg': '9', 'guifg': '#ff0000'}, 'normal': False},
|
||||
92: {'description': 'Set foreground color to Green', 'attributes': {'ctermfg': '10', 'guifg': '#00ff00'}, 'normal': False},
|
||||
93: {'description': 'Set foreground color to Yellow', 'attributes': {'ctermfg': '11', 'guifg': '#ffff00'}, 'normal': False},
|
||||
94: {'description': 'Set foreground color to Blue', 'attributes': {'ctermfg': '12', 'guifg': '#0000ff'}, 'normal': False},
|
||||
95: {'description': 'Set foreground color to Magenta', 'attributes': {'ctermfg': '13', 'guifg': '#990099'}, 'normal': False},
|
||||
96: {'description': 'Set foreground color to Cyan', 'attributes': {'ctermfg': '14', 'guifg': '#009999'}, 'normal': False},
|
||||
97: {'description': 'Set foreground color to White', 'attributes': {'ctermfg': '15', 'guifg': '#ffffff'}, 'normal': False},
|
||||
100: {'description': 'Set background color to Black', 'attributes': {'ctermbg': '8', 'guibg': '#000000'}, 'normal': False},
|
||||
101: {'description': 'Set background color to Red', 'attributes': {'ctermbg': '9', 'guibg': '#ff0000'}, 'normal': False},
|
||||
102: {'description': 'Set background color to Green', 'attributes': {'ctermbg': '10', 'guibg': '#00ff00'}, 'normal': False},
|
||||
103: {'description': 'Set background color to Yellow', 'attributes': {'ctermbg': '11', 'guibg': '#ffff00'}, 'normal': False},
|
||||
104: {'description': 'Set background color to Blue', 'attributes': {'ctermbg': '12', 'guibg': '#0000ff'}, 'normal': False},
|
||||
105: {'description': 'Set background color to Magenta', 'attributes': {'ctermbg': '13', 'guibg': '#990099'}, 'normal': False},
|
||||
106: {'description': 'Set background color to Cyan', 'attributes': {'ctermbg': '14', 'guibg': '#009999'}, 'normal': False},
|
||||
107: {'description': 'Set background color to White', 'attributes': {'ctermbg': '15', 'guibg': '#ffffff'}, 'normal': False}
|
||||
}
|
||||
# }}}
|
||||
|
||||
# regular expression matching (almost) all control sequences
|
||||
CONQUE_SEQ_REGEX = re.compile(u("(\x1b\[?\??#?[0-9;]*[a-zA-Z0-9@=>]|\x1b\][0-9];.*?\x07|[\x01-\x0f]|\x1b\([AB0])"), re.UNICODE)
|
||||
CONQUE_SEQ_REGEX_CTL = re.compile(u("^[\x01-\x0f]$"), re.UNICODE)
|
||||
CONQUE_SEQ_REGEX_CSI = re.compile(u("^\x1b\["), re.UNICODE)
|
||||
CONQUE_SEQ_REGEX_TITLE = re.compile(u("^\x1b\]"), re.UNICODE)
|
||||
CONQUE_SEQ_REGEX_HASH = re.compile(u("^\x1b#"), re.UNICODE)
|
||||
CONQUE_SEQ_REGEX_ESC = re.compile(u("^\x1b.$"), re.UNICODE)
|
||||
CONQUE_SEQ_REGEX_CHAR = re.compile(u("^\x1b\("), re.UNICODE)
|
||||
|
||||
# match table output
|
||||
CONQUE_TABLE_OUTPUT = re.compile("^\s*\|\s.*\s\|\s*$|^\s*\+[=+-]+\+\s*$")
|
||||
|
||||
# }}}
|
||||
|
||||
# Windows subprocess config {{{
|
||||
|
||||
CONQUE_SEQ_REGEX_VK = re.compile(u("(\x1b\[\d{1,3}VK)"), re.UNICODE)
|
||||
|
||||
# }}}
|
||||
|
||||
CONQUE_COLOR_SEQUENCE = (
|
||||
'000', '009', '090', '099', '900', '909', '990', '999',
|
||||
'000', '00f', '0f0', '0ff', 'f00', 'f0f', 'ff0', 'fff'
|
||||
)
|
||||
|
||||
# vim:foldmethod=marker
|
||||
209
.vim/autoload/conque_term/conque_screen.py
Normal file
209
.vim/autoload/conque_term/conque_screen.py
Normal file
|
|
@ -0,0 +1,209 @@
|
|||
# FILE: autoload/conque_term/conque_screen.py {{{
|
||||
# AUTHOR: Nico Raffo <nicoraffo@gmail.com>
|
||||
# WEBSITE: http://conque.googlecode.com
|
||||
# MODIFIED: 2010-11-15
|
||||
# VERSION: 2.0, for Vim 7.0
|
||||
# LICENSE:
|
||||
# Conque - Vim terminal/console emulator
|
||||
# Copyright (C) 2009-2010 Nico Raffo
|
||||
#
|
||||
# MIT License
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE. }}}
|
||||
|
||||
"""
|
||||
ConqueScreen is an extention of the vim.current.buffer object
|
||||
|
||||
It restricts the working indices of the buffer object to the scroll region
|
||||
which pty is expecting. It also uses 1-based indexes, to match escape
|
||||
sequence commands.
|
||||
|
||||
E.g.:
|
||||
s = ConqueScreen()
|
||||
...
|
||||
s[5] = 'Set 5th line in terminal to this line'
|
||||
s.append('Add new line to terminal')
|
||||
s[5] = 'Since previous append() command scrolled the terminal down, this is a different line than first cb[5] call'
|
||||
"""
|
||||
|
||||
import vim
|
||||
|
||||
|
||||
class ConqueScreen(object):
|
||||
|
||||
# CLASS PROPERTIES {{{
|
||||
|
||||
# the buffer
|
||||
buffer = None
|
||||
|
||||
# screen and scrolling regions
|
||||
screen_top = 1
|
||||
|
||||
# screen width
|
||||
screen_width = 80
|
||||
screen_height = 80
|
||||
|
||||
# }}}
|
||||
|
||||
def __init__(self): # {{{
|
||||
self.buffer = vim.current.buffer
|
||||
|
||||
self.screen_top = 1
|
||||
self.screen_width = vim.current.window.width
|
||||
self.screen_height = vim.current.window.height
|
||||
# }}}
|
||||
|
||||
###############################################################################################
|
||||
# List overload {{{
|
||||
|
||||
def __len__(self): # {{{
|
||||
return len(self.buffer)
|
||||
# }}}
|
||||
|
||||
def __getitem__(self, key): # {{{
|
||||
real_line = self.get_real_idx(key)
|
||||
|
||||
# if line is past buffer end, add lines to buffer
|
||||
if real_line >= len(self.buffer):
|
||||
for i in range(len(self.buffer), real_line + 1):
|
||||
self.append(' ' * self.screen_width)
|
||||
|
||||
return u(self.buffer[real_line], 'utf-8')
|
||||
# }}}
|
||||
|
||||
def __setitem__(self, key, value): # {{{
|
||||
real_line = self.get_real_idx(key)
|
||||
|
||||
if CONQUE_PYTHON_VERSION == 2:
|
||||
val = value.encode('utf-8')
|
||||
else:
|
||||
# XXX / Vim's python3 interface doesn't accept bytes object
|
||||
val = str(value)
|
||||
|
||||
# if line is past end of screen, append
|
||||
if real_line == len(self.buffer):
|
||||
self.buffer.append(val)
|
||||
else:
|
||||
self.buffer[real_line] = val
|
||||
# }}}
|
||||
|
||||
def __delitem__(self, key): # {{{
|
||||
del self.buffer[self.screen_top + key - 2]
|
||||
# }}}
|
||||
|
||||
def append(self, value): # {{{
|
||||
if len(self.buffer) > self.screen_top + self.screen_height - 1:
|
||||
self.buffer[len(self.buffer) - 1] = value
|
||||
else:
|
||||
self.buffer.append(value)
|
||||
|
||||
if len(self.buffer) > self.screen_top + self.screen_height - 1:
|
||||
self.screen_top += 1
|
||||
if vim.current.buffer.number == self.buffer.number:
|
||||
vim.command('normal G')
|
||||
# }}}
|
||||
|
||||
def insert(self, line, value): # {{{
|
||||
|
||||
l = self.screen_top + line - 2
|
||||
self.buffer.append(value, l)
|
||||
|
||||
# }}}
|
||||
# }}}
|
||||
|
||||
###############################################################################################
|
||||
# Util {{{
|
||||
|
||||
def get_top(self): # {{{
|
||||
return self.screen_top
|
||||
# }}}
|
||||
|
||||
def get_real_idx(self, line): # {{{
|
||||
return (self.screen_top + line - 2)
|
||||
# }}}
|
||||
|
||||
def get_real_line(self, line): # {{{
|
||||
return (self.screen_top + line - 1)
|
||||
# }}}
|
||||
|
||||
def set_screen_width(self, width): # {{{
|
||||
self.screen_width = width
|
||||
# }}}
|
||||
|
||||
# }}}
|
||||
|
||||
###############################################################################################
|
||||
def clear(self): # {{{
|
||||
self.buffer.append(' ')
|
||||
vim.command('normal Gzt')
|
||||
self.screen_top = len(self.buffer)
|
||||
# }}}
|
||||
|
||||
def set_cursor(self, line, column): # {{{
|
||||
# figure out line
|
||||
real_line = self.screen_top + line - 1
|
||||
if real_line > len(self.buffer):
|
||||
for l in range(len(self.buffer) - 1, real_line):
|
||||
self.buffer.append('')
|
||||
|
||||
# figure out column
|
||||
real_column = column
|
||||
if len(self.buffer[real_line - 1]) < real_column:
|
||||
self.buffer[real_line - 1] = self.buffer[real_line - 1] + ' ' * (real_column - len(self.buffer[real_line - 1]))
|
||||
|
||||
# python version is occasionally grumpy
|
||||
try:
|
||||
vim.current.window.cursor = (real_line, real_column - 1)
|
||||
except:
|
||||
vim.command('call cursor(' + str(real_line) + ', ' + str(real_column) + ')')
|
||||
# }}}
|
||||
|
||||
def reset_size(self, line): # {{{
|
||||
|
||||
|
||||
|
||||
|
||||
# save cursor line number
|
||||
real_line = self.screen_top + line
|
||||
|
||||
# reset screen size
|
||||
self.screen_width = vim.current.window.width
|
||||
self.screen_height = vim.current.window.height
|
||||
self.screen_top = len(self.buffer) - vim.current.window.height + 1
|
||||
if self.screen_top < 1:
|
||||
self.screen_top = 1
|
||||
|
||||
|
||||
# align bottom of buffer to bottom of screen
|
||||
vim.command('normal ' + str(self.screen_height) + 'kG')
|
||||
|
||||
# return new relative line number
|
||||
return (real_line - self.screen_top)
|
||||
# }}}
|
||||
|
||||
def scroll_to_bottom(self): # {{{
|
||||
vim.current.window.cursor = (len(self.buffer) - 1, 1)
|
||||
# }}}
|
||||
|
||||
def align(self): # {{{
|
||||
# align bottom of buffer to bottom of screen
|
||||
vim.command('normal ' + str(self.screen_height) + 'kG')
|
||||
# }}}
|
||||
|
||||
# vim:foldmethod=marker
|
||||
459
.vim/autoload/conque_term/conque_sole.py
Normal file
459
.vim/autoload/conque_term/conque_sole.py
Normal file
|
|
@ -0,0 +1,459 @@
|
|||
# FILE: autoload/conque_term/conque_sole.py {{{
|
||||
# AUTHOR: Nico Raffo <nicoraffo@gmail.com>
|
||||
# WEBSITE: http://conque.googlecode.com
|
||||
# MODIFIED: 2010-11-15
|
||||
# VERSION: 2.0, for Vim 7.0
|
||||
# LICENSE:
|
||||
# Conque - Vim terminal/console emulator
|
||||
# Copyright (C) 2009-2010 Nico Raffo
|
||||
#
|
||||
# MIT License
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE. }}}
|
||||
|
||||
import vim
|
||||
|
||||
|
||||
class ConqueSole(Conque):
|
||||
|
||||
window_top = None
|
||||
window_bottom = None
|
||||
|
||||
color_cache = {}
|
||||
color_mode = None
|
||||
color_conceals = {}
|
||||
|
||||
buffer = None
|
||||
|
||||
# counters for periodic rendering
|
||||
buffer_redraw_ct = 0
|
||||
screen_redraw_ct = 0
|
||||
|
||||
# *********************************************************************************************
|
||||
# start program and initialize this instance
|
||||
|
||||
def open(self, command, options={}, python_exe='', communicator_py=''): # {{{
|
||||
|
||||
# init size
|
||||
self.columns = vim.current.window.width
|
||||
self.lines = vim.current.window.height
|
||||
self.window_top = 0
|
||||
self.window_bottom = vim.current.window.height - 1
|
||||
|
||||
# init color
|
||||
self.enable_colors = options['color']
|
||||
|
||||
# open command
|
||||
self.proc = ConqueSoleWrapper()
|
||||
self.proc.open(command, {'TERM': options['TERM'], 'CONQUE': '1', 'LINES': self.lines, 'COLUMNS': self.columns}, python_exe, communicator_py)
|
||||
|
||||
self.buffer = vim.current.buffer
|
||||
|
||||
# }}}
|
||||
|
||||
|
||||
# *********************************************************************************************
|
||||
# read and update screen
|
||||
|
||||
def read(self, timeout=1, set_cursor=True, return_output=False, update_buffer=True): # {{{
|
||||
|
||||
try:
|
||||
stats = self.proc.get_stats()
|
||||
|
||||
if not stats:
|
||||
return
|
||||
|
||||
self.buffer_redraw_ct += 1
|
||||
self.screen_redraw_ct += 1
|
||||
|
||||
update_top = 0
|
||||
update_bottom = 0
|
||||
lines = []
|
||||
|
||||
# full buffer redraw, our favorite!
|
||||
if self.buffer_redraw_ct == CONQUE_SOLE_BUFFER_REDRAW:
|
||||
self.buffer_redraw_ct = 0
|
||||
update_top = 0
|
||||
update_bottom = stats['top_offset'] + self.lines
|
||||
(lines, attributes) = self.proc.read(update_top, update_bottom)
|
||||
if return_output:
|
||||
output = self.get_new_output(lines, update_top, stats)
|
||||
if update_buffer:
|
||||
for i in range(update_top, update_bottom + 1):
|
||||
self.plain_text(i, lines[i], attributes[i], stats)
|
||||
|
||||
# full screen redraw
|
||||
elif stats['cursor_y'] + 1 != self.l or stats['top_offset'] != self.window_top or self.screen_redraw_ct == CONQUE_SOLE_SCREEN_REDRAW:
|
||||
self.screen_redraw_ct = 0
|
||||
update_top = self.window_top
|
||||
update_bottom = stats['top_offset'] + self.lines + 1
|
||||
(lines, attributes) = self.proc.read(update_top, update_bottom - update_top + 1)
|
||||
if return_output:
|
||||
output = self.get_new_output(lines, update_top, stats)
|
||||
if update_buffer:
|
||||
for i in range(update_top, update_bottom + 1):
|
||||
self.plain_text(i, lines[i - update_top], attributes[i - update_top], stats)
|
||||
|
||||
|
||||
# single line redraw
|
||||
else:
|
||||
update_top = stats['cursor_y']
|
||||
update_bottom = stats['cursor_y']
|
||||
(lines, attributes) = self.proc.read(update_top, 1)
|
||||
if return_output:
|
||||
output = self.get_new_output(lines, update_top, stats)
|
||||
if update_buffer:
|
||||
if lines[0].rstrip() != self.buffer[update_top].rstrip():
|
||||
self.plain_text(update_top, lines[0], attributes[0], stats)
|
||||
|
||||
|
||||
# reset current position
|
||||
self.window_top = stats['top_offset']
|
||||
self.l = stats['cursor_y'] + 1
|
||||
self.c = stats['cursor_x'] + 1
|
||||
|
||||
# reposition cursor if this seems plausible
|
||||
if set_cursor:
|
||||
self.set_cursor(self.l, self.c)
|
||||
|
||||
if return_output:
|
||||
return output
|
||||
|
||||
except:
|
||||
|
||||
pass
|
||||
# }}}
|
||||
|
||||
#########################################################################
|
||||
# Calculate the "new" output from this read. Fake but useful
|
||||
|
||||
def get_new_output(self, lines, update_top, stats): # {{{
|
||||
|
||||
if not (stats['cursor_y'] + 1 > self.l or (stats['cursor_y'] + 1 == self.l and stats['cursor_x'] + 1 > self.c)):
|
||||
return ""
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
try:
|
||||
num_to_return = stats['cursor_y'] - self.l + 2
|
||||
|
||||
lines = lines[self.l - update_top - 1:]
|
||||
|
||||
|
||||
new_output = []
|
||||
|
||||
# first line
|
||||
new_output.append(lines[0][self.c - 1:].rstrip())
|
||||
|
||||
# the rest
|
||||
for i in range(1, num_to_return):
|
||||
new_output.append(lines[i].rstrip())
|
||||
|
||||
except:
|
||||
|
||||
pass
|
||||
|
||||
|
||||
|
||||
return "\n".join(new_output)
|
||||
# }}}
|
||||
|
||||
#########################################################################
|
||||
# update the buffer
|
||||
|
||||
def plain_text(self, line_nr, text, attributes, stats): # {{{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
self.l = line_nr + 1
|
||||
|
||||
# remove trailing whitespace
|
||||
text = text.rstrip()
|
||||
|
||||
# if we're using concealed text for color, then s- is weird
|
||||
if self.color_mode == 'conceal':
|
||||
|
||||
text = self.add_conceal_color(text, attributes, stats, line_nr)
|
||||
|
||||
|
||||
# update vim buffer
|
||||
if len(self.buffer) <= line_nr:
|
||||
self.buffer.append(text)
|
||||
else:
|
||||
self.buffer[line_nr] = text
|
||||
|
||||
if not self.color_mode == 'conceal':
|
||||
self.do_color(attributes=attributes, stats=stats)
|
||||
|
||||
# }}}
|
||||
|
||||
#########################################################################
|
||||
# add conceal color
|
||||
|
||||
def add_conceal_color(self, text, attributes, stats, line_nr): # {{{
|
||||
|
||||
# stop here if coloration is disabled
|
||||
if not self.enable_colors:
|
||||
return text
|
||||
|
||||
# if no colors for this line, clear everything out
|
||||
if len(attributes) == 0 or attributes == u(chr(stats['default_attribute'])) * len(attributes):
|
||||
return text
|
||||
|
||||
new_text = ''
|
||||
|
||||
# if text attribute is different, call add_color()
|
||||
attr = None
|
||||
start = 0
|
||||
self.color_conceals[line_nr] = []
|
||||
ends = []
|
||||
for i in range(0, len(attributes)):
|
||||
c = ord(attributes[i])
|
||||
|
||||
if c != attr:
|
||||
if attr and attr != stats['default_attribute']:
|
||||
|
||||
color = self.translate_color(attr)
|
||||
|
||||
new_text += chr(27) + 'sf' + color['fg_code'] + ';'
|
||||
ends.append(chr(27) + 'ef' + color['fg_code'] + ';')
|
||||
self.color_conceals[line_nr].append(start)
|
||||
|
||||
if c > 15:
|
||||
new_text += chr(27) + 'sf' + color['bg_code'] + ';'
|
||||
ends.append(chr(27) + 'ef' + color['bg_code'] + ';')
|
||||
self.color_conceals[line_nr].append(start)
|
||||
|
||||
new_text += text[start:i]
|
||||
|
||||
# close color regions
|
||||
ends.reverse()
|
||||
for j in range(0, len(ends)):
|
||||
new_text += ends[j]
|
||||
self.color_conceals[line_nr].append(i)
|
||||
ends = []
|
||||
|
||||
start = i
|
||||
attr = c
|
||||
|
||||
|
||||
if attr and attr != stats['default_attribute']:
|
||||
|
||||
color = self.translate_color(attr)
|
||||
|
||||
new_text += chr(27) + 'sf' + color['fg_code'] + ';'
|
||||
ends.append(chr(27) + 'ef' + color['fg_code'] + ';')
|
||||
|
||||
if c > 15:
|
||||
new_text += chr(27) + 'sf' + color['bg_code'] + ';'
|
||||
ends.append(chr(27) + 'ef' + color['bg_code'] + ';')
|
||||
|
||||
new_text += text[start:]
|
||||
|
||||
# close color regions
|
||||
ends.reverse()
|
||||
for i in range(0, len(ends)):
|
||||
new_text += ends[i]
|
||||
|
||||
return new_text
|
||||
|
||||
# }}}
|
||||
|
||||
#########################################################################
|
||||
|
||||
def do_color(self, start=0, end=0, attributes='', stats=None): # {{{
|
||||
|
||||
# stop here if coloration is disabled
|
||||
if not self.enable_colors:
|
||||
return
|
||||
|
||||
# if no colors for this line, clear everything out
|
||||
if len(attributes) == 0 or attributes == u(chr(stats['default_attribute'])) * len(attributes):
|
||||
self.color_changes = {}
|
||||
self.apply_color(1, len(attributes), self.l)
|
||||
return
|
||||
|
||||
# if text attribute is different, call add_color()
|
||||
attr = None
|
||||
start = 0
|
||||
for i in range(0, len(attributes)):
|
||||
c = ord(attributes[i])
|
||||
|
||||
if c != attr:
|
||||
if attr and attr != stats['default_attribute']:
|
||||
self.color_changes = self.translate_color(attr)
|
||||
self.apply_color(start + 1, i + 1, self.l)
|
||||
start = i
|
||||
attr = c
|
||||
|
||||
if attr and attr != stats['default_attribute']:
|
||||
self.color_changes = self.translate_color(attr)
|
||||
self.apply_color(start + 1, len(attributes), self.l)
|
||||
|
||||
|
||||
# }}}
|
||||
|
||||
#########################################################################
|
||||
|
||||
def translate_color(self, attr): # {{{
|
||||
|
||||
# check for cached color
|
||||
if attr in self.color_cache:
|
||||
return self.color_cache[attr]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# convert attribute integer to bit string
|
||||
bit_str = bin(attr)
|
||||
bit_str = bit_str.replace('0b', '')
|
||||
|
||||
# slice foreground and background portions of bit string
|
||||
fg = bit_str[-4:].rjust(4, '0')
|
||||
bg = bit_str[-8:-4].rjust(4, '0')
|
||||
|
||||
# ok, first create foreground #rbg
|
||||
red = int(fg[1]) * 204 + int(fg[0]) * int(fg[1]) * 51
|
||||
green = int(fg[2]) * 204 + int(fg[0]) * int(fg[2]) * 51
|
||||
blue = int(fg[3]) * 204 + int(fg[0]) * int(fg[3]) * 51
|
||||
fg_str = "#%02x%02x%02x" % (red, green, blue)
|
||||
fg_code = "%02x%02x%02x" % (red, green, blue)
|
||||
fg_code = fg_code[0] + fg_code[2] + fg_code[4]
|
||||
|
||||
# ok, first create foreground #rbg
|
||||
red = int(bg[1]) * 204 + int(bg[0]) * int(bg[1]) * 51
|
||||
green = int(bg[2]) * 204 + int(bg[0]) * int(bg[2]) * 51
|
||||
blue = int(bg[3]) * 204 + int(bg[0]) * int(bg[3]) * 51
|
||||
bg_str = "#%02x%02x%02x" % (red, green, blue)
|
||||
bg_code = "%02x%02x%02x" % (red, green, blue)
|
||||
bg_code = bg_code[0] + bg_code[2] + bg_code[4]
|
||||
|
||||
# build value for color_changes
|
||||
|
||||
color = {'guifg': fg_str, 'guibg': bg_str}
|
||||
|
||||
if self.color_mode == 'conceal':
|
||||
color['fg_code'] = fg_code
|
||||
color['bg_code'] = bg_code
|
||||
|
||||
self.color_cache[attr] = color
|
||||
|
||||
return color
|
||||
|
||||
# }}}
|
||||
|
||||
#########################################################################
|
||||
# write virtual key code to shared memory using proprietary escape seq
|
||||
|
||||
def write_vk(self, vk_code): # {{{
|
||||
|
||||
self.proc.write_vk(vk_code)
|
||||
|
||||
# }}}
|
||||
|
||||
# *********************************************************************************************
|
||||
# resize if needed
|
||||
|
||||
def update_window_size(self): # {{{
|
||||
|
||||
if vim.current.window.width != self.columns or vim.current.window.height != self.lines:
|
||||
|
||||
# reset all window size attributes to default
|
||||
self.columns = vim.current.window.width
|
||||
self.lines = vim.current.window.height
|
||||
self.working_columns = vim.current.window.width
|
||||
self.working_lines = vim.current.window.height
|
||||
self.bottom = vim.current.window.height
|
||||
|
||||
self.proc.window_resize(vim.current.window.height, vim.current.window.width)
|
||||
|
||||
# }}}
|
||||
|
||||
# *********************************************************************************************
|
||||
# resize if needed
|
||||
|
||||
def set_cursor(self, line, column): # {{{
|
||||
|
||||
# shift cursor position to handle concealed text
|
||||
if self.enable_colors and self.color_mode == 'conceal':
|
||||
if line - 1 in self.color_conceals:
|
||||
for c in self.color_conceals[line - 1]:
|
||||
if c < column:
|
||||
column += 7
|
||||
else:
|
||||
break
|
||||
|
||||
# figure out line
|
||||
real_line = line
|
||||
if real_line > len(self.buffer):
|
||||
for l in range(len(self.buffer) - 1, real_line):
|
||||
self.buffer.append('')
|
||||
|
||||
# figure out column
|
||||
real_column = column
|
||||
if len(self.buffer[real_line - 1]) < real_column:
|
||||
self.buffer[real_line - 1] = self.buffer[real_line - 1] + ' ' * (real_column - len(self.buffer[real_line - 1]))
|
||||
|
||||
# python version is occasionally grumpy
|
||||
try:
|
||||
vim.current.window.cursor = (real_line, real_column - 1)
|
||||
except:
|
||||
vim.command('call cursor(' + str(real_line) + ', ' + str(real_column) + ')')
|
||||
# }}}
|
||||
|
||||
|
||||
# *********************************************************************************************
|
||||
# go into idle mode
|
||||
|
||||
def idle(self): # {{{
|
||||
|
||||
self.proc.idle()
|
||||
|
||||
# }}}
|
||||
|
||||
# *********************************************************************************************
|
||||
# resume from idle mode
|
||||
|
||||
def resume(self): # {{{
|
||||
|
||||
self.proc.resume()
|
||||
|
||||
# }}}
|
||||
|
||||
# *********************************************************************************************
|
||||
# end subprocess
|
||||
|
||||
def close(self):
|
||||
self.proc.close()
|
||||
|
||||
# *********************************************************************************************
|
||||
# end subprocess forcefully
|
||||
|
||||
def abort(self):
|
||||
self.proc.close()
|
||||
|
||||
|
||||
# vim:foldmethod=marker
|
||||
183
.vim/autoload/conque_term/conque_sole_communicator.py
Normal file
183
.vim/autoload/conque_term/conque_sole_communicator.py
Normal file
|
|
@ -0,0 +1,183 @@
|
|||
# FILE: autoload/conque_term/conque_sole_communicator.py {{{
|
||||
# AUTHOR: Nico Raffo <nicoraffo@gmail.com>
|
||||
# WEBSITE: http://conque.googlecode.com
|
||||
# MODIFIED: 2010-11-15
|
||||
# VERSION: 2.0, for Vim 7.0
|
||||
# LICENSE:
|
||||
# Conque - Vim terminal/console emulator
|
||||
# Copyright (C) 2009-2010 Nico Raffo
|
||||
#
|
||||
# MIT License
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE. }}}
|
||||
|
||||
"""
|
||||
ConqueSoleCommunicator
|
||||
|
||||
Script to transfer communications between python being run in Vim and a
|
||||
subprocess run inside a Windows console. This is required since interactive
|
||||
programs in Windows appear to require a console, and python run in Vim is
|
||||
not attached to any console. So a console version of python must be initiated
|
||||
for the subprocess. Communication is then done with the use of shared memory
|
||||
objects. Good times!
|
||||
"""
|
||||
|
||||
import time
|
||||
import sys
|
||||
|
||||
from conque_globals import *
|
||||
from conque_win32_util import *
|
||||
from conque_sole_subprocess import *
|
||||
from conque_sole_shared_memory import *
|
||||
|
||||
##############################################################
|
||||
# only run if this file was run directly
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# attempt to catch ALL exceptions to fend of zombies
|
||||
try:
|
||||
|
||||
# startup and config {{{
|
||||
|
||||
# simple arg validation
|
||||
|
||||
if len(sys.argv) < 5:
|
||||
|
||||
exit()
|
||||
|
||||
# shared memory size
|
||||
CONQUE_SOLE_COMMANDS_SIZE = 255
|
||||
|
||||
# maximum time this thing reads. 0 means no limit. Only for testing.
|
||||
max_loops = 0
|
||||
|
||||
# read interval, in seconds
|
||||
sleep_time = 0.01
|
||||
|
||||
# idle read interval, in seconds
|
||||
idle_sleep_time = 0.10
|
||||
|
||||
# are we idled?
|
||||
is_idle = False
|
||||
|
||||
# mem key
|
||||
mem_key = sys.argv[1]
|
||||
|
||||
# console width
|
||||
console_width = int(sys.argv[2])
|
||||
|
||||
# console height
|
||||
console_height = int(sys.argv[3])
|
||||
|
||||
# the actual subprocess to run
|
||||
cmd_line = " ".join(sys.argv[4:])
|
||||
|
||||
|
||||
# width and height
|
||||
options = {'LINES': console_height, 'COLUMNS': console_width}
|
||||
|
||||
|
||||
|
||||
# set initial idle status
|
||||
shm_command = ConqueSoleSharedMemory(CONQUE_SOLE_COMMANDS_SIZE, 'command', mem_key, serialize=True)
|
||||
shm_command.create('write')
|
||||
|
||||
cmd = shm_command.read()
|
||||
if cmd:
|
||||
|
||||
if cmd['cmd'] == 'idle':
|
||||
is_idle = True
|
||||
shm_command.clear()
|
||||
|
||||
# }}}
|
||||
|
||||
##############################################################
|
||||
# Create the subprocess
|
||||
|
||||
# {{{
|
||||
proc = ConqueSoleSubprocess()
|
||||
res = proc.open(cmd_line, mem_key, options)
|
||||
|
||||
if not res:
|
||||
|
||||
exit()
|
||||
|
||||
# }}}
|
||||
|
||||
##############################################################
|
||||
# main loop!
|
||||
|
||||
loops = 0
|
||||
|
||||
while True:
|
||||
|
||||
# check for idle/resume
|
||||
if is_idle or loops % 25 == 0:
|
||||
|
||||
# check process health
|
||||
if not proc.is_alive():
|
||||
|
||||
proc.close()
|
||||
exit()
|
||||
|
||||
# check for change in buffer focus
|
||||
cmd = shm_command.read()
|
||||
if cmd:
|
||||
|
||||
if cmd['cmd'] == 'idle':
|
||||
is_idle = True
|
||||
shm_command.clear()
|
||||
|
||||
elif cmd['cmd'] == 'resume':
|
||||
is_idle = False
|
||||
shm_command.clear()
|
||||
|
||||
|
||||
# sleep between loops if moderation is requested
|
||||
if sleep_time > 0:
|
||||
if is_idle:
|
||||
time.sleep(idle_sleep_time)
|
||||
else:
|
||||
time.sleep(sleep_time)
|
||||
|
||||
# write, read, etc
|
||||
proc.write()
|
||||
proc.read()
|
||||
|
||||
# increment loops, and exit if max has been reached
|
||||
loops += 1
|
||||
if max_loops and loops >= max_loops:
|
||||
|
||||
break
|
||||
|
||||
##############################################################
|
||||
# all done!
|
||||
|
||||
|
||||
|
||||
proc.close()
|
||||
|
||||
# if an exception was thrown, croak
|
||||
except:
|
||||
|
||||
proc.close()
|
||||
|
||||
|
||||
# vim:foldmethod=marker
|
||||
202
.vim/autoload/conque_term/conque_sole_shared_memory.py
Normal file
202
.vim/autoload/conque_term/conque_sole_shared_memory.py
Normal file
|
|
@ -0,0 +1,202 @@
|
|||
# FILE: autoload/conque_term/conque_sole_shared_memory.py {{{
|
||||
# AUTHOR: Nico Raffo <nicoraffo@gmail.com>
|
||||
# WEBSITE: http://conque.googlecode.com
|
||||
# MODIFIED: 2010-11-15
|
||||
# VERSION: 2.0, for Vim 7.0
|
||||
# LICENSE:
|
||||
# Conque - Vim terminal/console emulator
|
||||
# Copyright (C) 2009-2010 Nico Raffo
|
||||
#
|
||||
# MIT License
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE. }}}
|
||||
|
||||
"""Wrapper class for shared memory between Windows python processes"""
|
||||
|
||||
import mmap
|
||||
import sys
|
||||
|
||||
if sys.version_info[0] == 2:
|
||||
CONQUE_PYTHON_VERSION = 2
|
||||
else:
|
||||
CONQUE_PYTHON_VERSION = 3
|
||||
|
||||
if CONQUE_PYTHON_VERSION == 2:
|
||||
import cPickle as pickle
|
||||
else:
|
||||
import pickle
|
||||
|
||||
|
||||
class ConqueSoleSharedMemory():
|
||||
|
||||
# ****************************************************************************
|
||||
# class properties
|
||||
|
||||
# {{{
|
||||
|
||||
# is the data being stored not fixed length
|
||||
fixed_length = False
|
||||
|
||||
# fill memory with this character when clearing and fixed_length is true
|
||||
fill_char = ' '
|
||||
|
||||
# serialize and unserialize data automatically
|
||||
serialize = False
|
||||
|
||||
# size of shared memory, in bytes / chars
|
||||
mem_size = None
|
||||
|
||||
# size of shared memory, in bytes / chars
|
||||
mem_type = None
|
||||
|
||||
# unique key, so multiple console instances are possible
|
||||
mem_key = None
|
||||
|
||||
# mmap instance
|
||||
shm = None
|
||||
|
||||
# character encoding, dammit
|
||||
encoding = 'ascii'
|
||||
|
||||
# pickle terminator
|
||||
TERMINATOR = None
|
||||
|
||||
# }}}
|
||||
|
||||
# ****************************************************************************
|
||||
# constructor I guess
|
||||
|
||||
def __init__(self, mem_size, mem_type, mem_key, fixed_length=False, fill_char=' ', serialize=False, encoding='ascii'): # {{{
|
||||
|
||||
self.mem_size = mem_size
|
||||
self.mem_type = mem_type
|
||||
self.mem_key = mem_key
|
||||
self.fixed_length = fixed_length
|
||||
self.fill_char = fill_char
|
||||
self.serialize = serialize
|
||||
self.encoding = encoding
|
||||
self.TERMINATOR = str(chr(0)).encode(self.encoding)
|
||||
|
||||
# }}}
|
||||
|
||||
# ****************************************************************************
|
||||
# create memory block
|
||||
|
||||
def create(self, access='write'): # {{{
|
||||
|
||||
if access == 'write':
|
||||
mmap_access = mmap.ACCESS_WRITE
|
||||
else:
|
||||
mmap_access = mmap.ACCESS_READ
|
||||
|
||||
name = "conque_%s_%s" % (self.mem_type, self.mem_key)
|
||||
|
||||
self.shm = mmap.mmap(0, self.mem_size, name, mmap_access)
|
||||
|
||||
if not self.shm:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
# }}}
|
||||
|
||||
# ****************************************************************************
|
||||
# read data
|
||||
|
||||
def read(self, chars=1, start=0): # {{{
|
||||
|
||||
# invalid reads
|
||||
if self.fixed_length and (chars == 0 or start + chars > self.mem_size):
|
||||
return ''
|
||||
|
||||
# go to start position
|
||||
self.shm.seek(start)
|
||||
|
||||
if not self.fixed_length:
|
||||
chars = self.shm.find(self.TERMINATOR)
|
||||
|
||||
if chars == 0:
|
||||
return ''
|
||||
|
||||
shm_str = self.shm.read(chars)
|
||||
|
||||
# return unpickled byte object
|
||||
if self.serialize:
|
||||
return pickle.loads(shm_str)
|
||||
|
||||
# decode byes in python 3
|
||||
if CONQUE_PYTHON_VERSION == 3:
|
||||
return str(shm_str, self.encoding)
|
||||
|
||||
# encoding
|
||||
if self.encoding != 'ascii':
|
||||
shm_str = unicode(shm_str, self.encoding)
|
||||
|
||||
return shm_str
|
||||
|
||||
# }}}
|
||||
|
||||
# ****************************************************************************
|
||||
# write data
|
||||
|
||||
def write(self, text, start=0): # {{{
|
||||
|
||||
# simple scenario, let pickle create bytes
|
||||
if self.serialize:
|
||||
if CONQUE_PYTHON_VERSION == 3:
|
||||
tb = pickle.dumps(text, 0)
|
||||
else:
|
||||
tb = pickle.dumps(text, 0).encode(self.encoding)
|
||||
|
||||
else:
|
||||
tb = text.encode(self.encoding, 'replace')
|
||||
|
||||
self.shm.seek(start)
|
||||
|
||||
# write to memory
|
||||
if self.fixed_length:
|
||||
self.shm.write(tb)
|
||||
else:
|
||||
self.shm.write(tb + self.TERMINATOR)
|
||||
|
||||
# }}}
|
||||
|
||||
# ****************************************************************************
|
||||
# clear
|
||||
|
||||
def clear(self, start=0): # {{{
|
||||
|
||||
self.shm.seek(start)
|
||||
|
||||
if self.fixed_length:
|
||||
self.shm.write(str(self.fill_char * self.mem_size).encode(self.encoding))
|
||||
else:
|
||||
self.shm.write(self.TERMINATOR)
|
||||
|
||||
# }}}
|
||||
|
||||
# ****************************************************************************
|
||||
# close
|
||||
|
||||
def close(self):
|
||||
|
||||
self.shm.close()
|
||||
|
||||
|
||||
# vim:foldmethod=marker
|
||||
753
.vim/autoload/conque_term/conque_sole_subprocess.py
Normal file
753
.vim/autoload/conque_term/conque_sole_subprocess.py
Normal file
File diff suppressed because it is too large
Load diff
304
.vim/autoload/conque_term/conque_sole_wrapper.py
Normal file
304
.vim/autoload/conque_term/conque_sole_wrapper.py
Normal file
|
|
@ -0,0 +1,304 @@
|
|||
# FILE: autoload/conque_term/conque_sole_wrapper.py {{{
|
||||
# AUTHOR: Nico Raffo <nicoraffo@gmail.com>
|
||||
# WEBSITE: http://conque.googlecode.com
|
||||
# MODIFIED: 2010-11-15
|
||||
# VERSION: 2.0, for Vim 7.0
|
||||
# LICENSE:
|
||||
# Conque - Vim terminal/console emulator
|
||||
# Copyright (C) 2009-2010 Nico Raffo
|
||||
#
|
||||
# MIT License
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE. }}}
|
||||
|
||||
""" ConqueSoleSubprocessWrapper {{{
|
||||
|
||||
Subprocess wrapper to deal with Windows insanity. Launches console based python,
|
||||
which in turn launches originally requested command. Communicates with cosole
|
||||
python through shared memory objects.
|
||||
|
||||
}}} """
|
||||
|
||||
import ctypes
|
||||
import time
|
||||
|
||||
|
||||
class ConqueSoleWrapper():
|
||||
|
||||
# class properties {{{
|
||||
|
||||
shm_key = ''
|
||||
|
||||
# process info
|
||||
handle = None
|
||||
pid = None
|
||||
|
||||
# queue input in this bucket
|
||||
bucket = None
|
||||
|
||||
# console size
|
||||
# NOTE: columns should never change after open() is called
|
||||
lines = 24
|
||||
columns = 80
|
||||
|
||||
# shared memory objects
|
||||
shm_input = None
|
||||
shm_output = None
|
||||
shm_attributes = None
|
||||
shm_stats = None
|
||||
shm_command = None
|
||||
shm_rescroll = None
|
||||
shm_resize = None
|
||||
|
||||
# console python process
|
||||
proc = None
|
||||
|
||||
# }}}
|
||||
|
||||
#########################################################################
|
||||
# unused
|
||||
|
||||
def __init__(self): # {{{
|
||||
self.bucket = u('')
|
||||
|
||||
# }}}
|
||||
|
||||
#########################################################################
|
||||
# run communicator process which will in turn run cmd
|
||||
|
||||
def open(self, cmd, options={}, python_exe='python.exe', communicator_py='conque_sole_communicator.py'): # {{{
|
||||
|
||||
self.lines = options['LINES']
|
||||
self.columns = options['COLUMNS']
|
||||
|
||||
# create a shm key
|
||||
self.shm_key = 'mk' + str(time.time())
|
||||
|
||||
# python command
|
||||
cmd_line = '%s "%s" %s %d %d %s' % (python_exe, communicator_py, self.shm_key, int(self.columns), int(self.lines), cmd)
|
||||
|
||||
|
||||
# console window attributes
|
||||
flags = NORMAL_PRIORITY_CLASS | DETACHED_PROCESS
|
||||
si = STARTUPINFO()
|
||||
pi = PROCESS_INFORMATION()
|
||||
|
||||
# start the stupid process already
|
||||
try:
|
||||
res = ctypes.windll.kernel32.CreateProcessW(None, u(cmd_line), None, None, 0, flags, None, u('.'), ctypes.byref(si), ctypes.byref(pi))
|
||||
except:
|
||||
|
||||
raise
|
||||
|
||||
# handle
|
||||
self.pid = pi.dwProcessId
|
||||
|
||||
|
||||
|
||||
# init shared memory objects
|
||||
self.init_shared_memory(self.shm_key)
|
||||
|
||||
# }}}
|
||||
|
||||
#########################################################################
|
||||
# read output from shared memory
|
||||
|
||||
def read(self, start_line, num_lines, timeout=0): # {{{
|
||||
|
||||
# emulate timeout by sleeping timeout time
|
||||
if timeout > 0:
|
||||
read_timeout = float(timeout) / 1000
|
||||
|
||||
time.sleep(read_timeout)
|
||||
|
||||
output = []
|
||||
attributes = []
|
||||
|
||||
# get output
|
||||
for i in range(start_line, start_line + num_lines + 1):
|
||||
output.append(self.shm_output.read(self.columns, i * self.columns))
|
||||
attributes.append(self.shm_attributes.read(self.columns, i * self.columns))
|
||||
|
||||
return (output, attributes)
|
||||
|
||||
# }}}
|
||||
|
||||
#########################################################################
|
||||
# get current cursor/scroll position
|
||||
|
||||
def get_stats(self): # {{{
|
||||
|
||||
try:
|
||||
rescroll = self.shm_rescroll.read()
|
||||
if rescroll != '' and rescroll != None:
|
||||
|
||||
|
||||
|
||||
self.shm_rescroll.clear()
|
||||
|
||||
# close down old memory
|
||||
self.shm_output.close()
|
||||
self.shm_output = None
|
||||
|
||||
self.shm_attributes.close()
|
||||
self.shm_attributes = None
|
||||
|
||||
# reallocate memory
|
||||
|
||||
self.shm_output = ConqueSoleSharedMemory(CONQUE_SOLE_BUFFER_LENGTH * self.columns * rescroll['data']['blocks'], 'output', rescroll['data']['mem_key'], True)
|
||||
self.shm_output.create('read')
|
||||
|
||||
self.shm_attributes = ConqueSoleSharedMemory(CONQUE_SOLE_BUFFER_LENGTH * self.columns * rescroll['data']['blocks'], 'attributes', rescroll['data']['mem_key'], True, encoding='latin-1')
|
||||
self.shm_attributes.create('read')
|
||||
|
||||
stats_str = self.shm_stats.read()
|
||||
if stats_str != '':
|
||||
self.stats = stats_str
|
||||
else:
|
||||
return False
|
||||
except:
|
||||
|
||||
return False
|
||||
|
||||
return self.stats
|
||||
|
||||
# }}}
|
||||
|
||||
#########################################################################
|
||||
# get process status
|
||||
|
||||
def is_alive(self): # {{{
|
||||
if not self.shm_stats:
|
||||
return True
|
||||
|
||||
stats_str = self.shm_stats.read()
|
||||
if stats_str:
|
||||
return (stats_str['is_alive'])
|
||||
else:
|
||||
return True
|
||||
# }}}
|
||||
|
||||
#########################################################################
|
||||
# write input to shared memory
|
||||
|
||||
def write(self, text): # {{{
|
||||
|
||||
self.bucket += u(text, 'ascii', 'replace')
|
||||
|
||||
|
||||
|
||||
istr = self.shm_input.read()
|
||||
|
||||
if istr == '':
|
||||
|
||||
self.shm_input.write(self.bucket[:500])
|
||||
self.bucket = self.bucket[500:]
|
||||
|
||||
# }}}
|
||||
|
||||
#########################################################################
|
||||
# write virtual key code to shared memory using proprietary escape seq
|
||||
|
||||
def write_vk(self, vk_code): # {{{
|
||||
|
||||
seq = "\x1b[" + str(vk_code) + "VK"
|
||||
self.write(seq)
|
||||
|
||||
# }}}
|
||||
|
||||
#########################################################################
|
||||
# idle
|
||||
|
||||
def idle(self): # {{{
|
||||
|
||||
|
||||
self.shm_command.write({'cmd': 'idle', 'data': {}})
|
||||
|
||||
# }}}
|
||||
|
||||
#########################################################################
|
||||
# resume
|
||||
|
||||
def resume(self): # {{{
|
||||
|
||||
self.shm_command.write({'cmd': 'resume', 'data': {}})
|
||||
|
||||
# }}}
|
||||
|
||||
#########################################################################
|
||||
# shut it all down
|
||||
|
||||
def close(self): # {{{
|
||||
|
||||
self.shm_command.write({'cmd': 'close', 'data': {}})
|
||||
time.sleep(0.2)
|
||||
|
||||
# }}}
|
||||
|
||||
#########################################################################
|
||||
# resize console window
|
||||
|
||||
def window_resize(self, lines, columns): # {{{
|
||||
|
||||
self.lines = lines
|
||||
|
||||
# we don't shrink buffer width
|
||||
if columns > self.columns:
|
||||
self.columns = columns
|
||||
|
||||
self.shm_resize.write({'cmd': 'resize', 'data': {'width': columns, 'height': lines}})
|
||||
|
||||
# }}}
|
||||
|
||||
# ****************************************************************************
|
||||
# create shared memory objects
|
||||
|
||||
def init_shared_memory(self, mem_key): # {{{
|
||||
|
||||
self.shm_input = ConqueSoleSharedMemory(CONQUE_SOLE_INPUT_SIZE, 'input', mem_key)
|
||||
self.shm_input.create('write')
|
||||
self.shm_input.clear()
|
||||
|
||||
self.shm_output = ConqueSoleSharedMemory(CONQUE_SOLE_BUFFER_LENGTH * self.columns, 'output', mem_key, True)
|
||||
self.shm_output.create('write')
|
||||
|
||||
self.shm_attributes = ConqueSoleSharedMemory(CONQUE_SOLE_BUFFER_LENGTH * self.columns, 'attributes', mem_key, True, encoding='latin-1')
|
||||
self.shm_attributes.create('write')
|
||||
|
||||
self.shm_stats = ConqueSoleSharedMemory(CONQUE_SOLE_STATS_SIZE, 'stats', mem_key, serialize=True)
|
||||
self.shm_stats.create('write')
|
||||
self.shm_stats.clear()
|
||||
|
||||
self.shm_command = ConqueSoleSharedMemory(CONQUE_SOLE_COMMANDS_SIZE, 'command', mem_key, serialize=True)
|
||||
self.shm_command.create('write')
|
||||
self.shm_command.clear()
|
||||
|
||||
self.shm_resize = ConqueSoleSharedMemory(CONQUE_SOLE_RESIZE_SIZE, 'resize', mem_key, serialize=True)
|
||||
self.shm_resize.create('write')
|
||||
self.shm_resize.clear()
|
||||
|
||||
self.shm_rescroll = ConqueSoleSharedMemory(CONQUE_SOLE_RESCROLL_SIZE, 'rescroll', mem_key, serialize=True)
|
||||
self.shm_rescroll.create('write')
|
||||
self.shm_rescroll.clear()
|
||||
|
||||
return True
|
||||
|
||||
# }}}
|
||||
|
||||
# vim:foldmethod=marker
|
||||
195
.vim/autoload/conque_term/conque_subprocess.py
Normal file
195
.vim/autoload/conque_term/conque_subprocess.py
Normal file
|
|
@ -0,0 +1,195 @@
|
|||
# FILE: autoload/conque_term/conque_subprocess.py {{{
|
||||
# AUTHOR: Nico Raffo <nicoraffo@gmail.com>
|
||||
# WEBSITE: http://conque.googlecode.com
|
||||
# MODIFIED: 2010-11-15
|
||||
# VERSION: 2.0, for Vim 7.0
|
||||
# LICENSE:
|
||||
# Conque - Vim terminal/console emulator
|
||||
# Copyright (C) 2009-2010 Nico Raffo
|
||||
#
|
||||
# MIT License
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE. }}}
|
||||
|
||||
"""
|
||||
ConqueSubprocess
|
||||
|
||||
Create and interact with a subprocess through a pty.
|
||||
|
||||
Usage:
|
||||
|
||||
p = ConqueSubprocess()
|
||||
p.open('bash', {'TERM':'vt100'})
|
||||
output = p.read()
|
||||
p.write('cd ~/vim' + "\r")
|
||||
p.write('ls -lha' + "\r")
|
||||
output += p.read(timeout = 500)
|
||||
p.close()
|
||||
"""
|
||||
|
||||
if CONQUE_PLATFORM == 'nix':
|
||||
import os
|
||||
import signal
|
||||
import pty
|
||||
import tty
|
||||
import select
|
||||
import fcntl
|
||||
import termios
|
||||
import struct
|
||||
|
||||
|
||||
class ConqueSubprocess:
|
||||
|
||||
# process id
|
||||
pid = 0
|
||||
|
||||
# stdout+stderr file descriptor
|
||||
fd = None
|
||||
|
||||
# constructor
|
||||
def __init__(self): # {{{
|
||||
self.pid = 0
|
||||
# }}}
|
||||
|
||||
# create pty + subprocess
|
||||
def open(self, command, env={}): # {{{
|
||||
|
||||
# parse command
|
||||
command_arr = command.split()
|
||||
executable = command_arr[0]
|
||||
args = command_arr
|
||||
|
||||
# try to fork a new pty
|
||||
try:
|
||||
self.pid, self.fd = pty.fork()
|
||||
|
||||
except:
|
||||
|
||||
return False
|
||||
|
||||
# child proc, replace with command after altering terminal attributes
|
||||
if self.pid == 0:
|
||||
|
||||
# set requested environment variables
|
||||
for k in env.keys():
|
||||
os.environ[k] = env[k]
|
||||
|
||||
# set some attributes
|
||||
try:
|
||||
attrs = tty.tcgetattr(1)
|
||||
attrs[0] = attrs[0] ^ tty.IGNBRK
|
||||
attrs[0] = attrs[0] | tty.BRKINT | tty.IXANY | tty.IMAXBEL
|
||||
attrs[2] = attrs[2] | tty.HUPCL
|
||||
attrs[3] = attrs[3] | tty.ICANON | tty.ECHO | tty.ISIG | tty.ECHOKE
|
||||
attrs[6][tty.VMIN] = 1
|
||||
attrs[6][tty.VTIME] = 0
|
||||
tty.tcsetattr(1, tty.TCSANOW, attrs)
|
||||
except:
|
||||
|
||||
pass
|
||||
|
||||
# replace this process with the subprocess
|
||||
os.execvp(executable, args)
|
||||
|
||||
# else master, do nothing
|
||||
else:
|
||||
pass
|
||||
|
||||
# }}}
|
||||
|
||||
# read from pty
|
||||
# XXX - select.poll() doesn't work in OS X!!!!!!!
|
||||
def read(self, timeout=1): # {{{
|
||||
|
||||
output = ''
|
||||
read_timeout = float(timeout) / 1000
|
||||
|
||||
try:
|
||||
# read from fd until no more output
|
||||
while 1:
|
||||
s_read, s_write, s_error = select.select([self.fd], [], [], read_timeout)
|
||||
|
||||
lines = ''
|
||||
for s_fd in s_read:
|
||||
try:
|
||||
lines = os.read(self.fd, 32)
|
||||
except:
|
||||
pass
|
||||
output = output + lines.decode('utf-8')
|
||||
|
||||
if lines == '':
|
||||
break
|
||||
except:
|
||||
pass
|
||||
|
||||
return output
|
||||
# }}}
|
||||
|
||||
# I guess this one's not bad
|
||||
def write(self, input): # {{{
|
||||
try:
|
||||
if CONQUE_PYTHON_VERSION == 2:
|
||||
os.write(self.fd, input)
|
||||
else:
|
||||
os.write(self.fd, bytes(input, 'utf-8'))
|
||||
except:
|
||||
|
||||
pass
|
||||
# }}}
|
||||
|
||||
# signal process
|
||||
def signal(self, signum): # {{{
|
||||
try:
|
||||
os.kill(self.pid, signum)
|
||||
except:
|
||||
pass
|
||||
# }}}
|
||||
|
||||
# close process
|
||||
def close(self): # {{{
|
||||
self.signal(15)
|
||||
# }}}
|
||||
|
||||
# get process status
|
||||
def is_alive(self): #{{{
|
||||
|
||||
p_status = True
|
||||
|
||||
try:
|
||||
if os.waitpid(self.pid, os.WNOHANG)[0]:
|
||||
p_status = False
|
||||
except:
|
||||
p_status = False
|
||||
|
||||
return p_status
|
||||
|
||||
# }}}
|
||||
|
||||
# update window size in kernel, then send SIGWINCH to fg process
|
||||
def window_resize(self, lines, columns): # {{{
|
||||
try:
|
||||
fcntl.ioctl(self.fd, termios.TIOCSWINSZ, struct.pack("HHHH", lines, columns, 0, 0))
|
||||
os.kill(self.pid, signal.SIGWINCH)
|
||||
except:
|
||||
pass
|
||||
|
||||
# }}}
|
||||
|
||||
|
||||
# vim:foldmethod=marker
|
||||
473
.vim/autoload/conque_term/conque_win32_util.py
Normal file
473
.vim/autoload/conque_term/conque_win32_util.py
Normal file
|
|
@ -0,0 +1,473 @@
|
|||
# FILE: autoload/conque_term/conque_win32_util.py {{{
|
||||
# AUTHOR: Nico Raffo <nicoraffo@gmail.com>
|
||||
# WEBSITE: http://conque.googlecode.com
|
||||
# MODIFIED: 2010-11-15
|
||||
# VERSION: 2.0, for Vim 7.0
|
||||
# LICENSE:
|
||||
# Conque - Vim terminal/console emulator
|
||||
# Copyright (C) 2009-2010 Nico Raffo
|
||||
#
|
||||
# MIT License
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE. }}}
|
||||
|
||||
"""Python structures used for ctypes interaction"""
|
||||
|
||||
from ctypes import *
|
||||
|
||||
# Constants
|
||||
|
||||
# create process flag constants {{{
|
||||
|
||||
CREATE_BREAKAWAY_FROM_JOB = 0x01000000
|
||||
CREATE_DEFAULT_ERROR_MODE = 0x04000000
|
||||
CREATE_NEW_CONSOLE = 0x00000010
|
||||
CREATE_NEW_PROCESS_GROUP = 0x00000200
|
||||
CREATE_NO_WINDOW = 0x08000000
|
||||
CREATE_PROTECTED_PROCESS = 0x00040000
|
||||
CREATE_PRESERVE_CODE_AUTHZ_LEVEL = 0x02000000
|
||||
CREATE_SEPARATE_WOW_VDM = 0x00000800
|
||||
CREATE_SHARED_WOW_VDM = 0x00001000
|
||||
CREATE_SUSPENDED = 0x00000004
|
||||
CREATE_UNICODE_ENVIRONMENT = 0x00000400
|
||||
|
||||
|
||||
DETACHED_PROCESS = 0x00000008
|
||||
EXTENDED_STARTUPINFO_PRESENT = 0x00080000
|
||||
INHERIT_PARENT_AFFINITY = 0x00010000
|
||||
|
||||
# }}}
|
||||
|
||||
# process priority constants {{{
|
||||
|
||||
ABOVE_NORMAL_PRIORITY_CLASS = 0x00008000
|
||||
BELOW_NORMAL_PRIORITY_CLASS = 0x00004000
|
||||
HIGH_PRIORITY_CLASS = 0x00000080
|
||||
IDLE_PRIORITY_CLASS = 0x00000040
|
||||
NORMAL_PRIORITY_CLASS = 0x00000020
|
||||
REALTIME_PRIORITY_CLASS = 0x00000100
|
||||
|
||||
# }}}
|
||||
|
||||
# startup info constants {{{
|
||||
|
||||
STARTF_FORCEONFEEDBACK = 0x00000040
|
||||
STARTF_FORCEOFFFEEDBACK = 0x00000080
|
||||
STARTF_PREVENTPINNING = 0x00002000
|
||||
STARTF_RUNFULLSCREEN = 0x00000020
|
||||
STARTF_TITLEISAPPID = 0x00001000
|
||||
STARTF_TITLEISLINKNAME = 0x00000800
|
||||
STARTF_USECOUNTCHARS = 0x00000008
|
||||
STARTF_USEFILLATTRIBUTE = 0x00000010
|
||||
STARTF_USEHOTKEY = 0x00000200
|
||||
STARTF_USEPOSITION = 0x00000004
|
||||
STARTF_USESHOWWINDOW = 0x00000001
|
||||
STARTF_USESIZE = 0x00000002
|
||||
STARTF_USESTDHANDLES = 0x00000100
|
||||
|
||||
# }}}
|
||||
|
||||
# show window constants {{{
|
||||
|
||||
SW_FORCEMINIMIZE = 11
|
||||
SW_HIDE = 0
|
||||
SW_MAXIMIZE = 3
|
||||
SW_MINIMIZE = 6
|
||||
SW_RESTORE = 9
|
||||
SW_SHOW = 5
|
||||
SW_SHOWDEFAULT = 10
|
||||
SW_SHOWMAXIMIZED = 3
|
||||
SW_SHOWMINIMIZED = 2
|
||||
SW_SHOWMINNOACTIVE = 7
|
||||
SW_SHOWNA = 8
|
||||
SW_SHOWNOACTIVATE = 4
|
||||
SW_SHOWNORMAL = 1
|
||||
|
||||
# }}}
|
||||
|
||||
# input event types {{{
|
||||
|
||||
FOCUS_EVENT = 0x0010
|
||||
KEY_EVENT = 0x0001
|
||||
MENU_EVENT = 0x0008
|
||||
MOUSE_EVENT = 0x0002
|
||||
WINDOW_BUFFER_SIZE_EVENT = 0x0004
|
||||
|
||||
# }}}
|
||||
|
||||
# key event modifiers {{{
|
||||
|
||||
CAPSLOCK_ON = 0x0080
|
||||
ENHANCED_KEY = 0x0100
|
||||
LEFT_ALT_PRESSED = 0x0002
|
||||
LEFT_CTRL_PRESSED = 0x0008
|
||||
NUMLOCK_ON = 0x0020
|
||||
RIGHT_ALT_PRESSED = 0x0001
|
||||
RIGHT_CTRL_PRESSED = 0x0004
|
||||
SCROLLLOCK_ON = 0x0040
|
||||
SHIFT_PRESSED = 0x0010
|
||||
|
||||
# }}}
|
||||
|
||||
# process access {{{
|
||||
|
||||
PROCESS_CREATE_PROCESS = 0x0080
|
||||
PROCESS_CREATE_THREAD = 0x0002
|
||||
PROCESS_DUP_HANDLE = 0x0040
|
||||
PROCESS_QUERY_INFORMATION = 0x0400
|
||||
PROCESS_QUERY_LIMITED_INFORMATION = 0x1000
|
||||
PROCESS_SET_INFORMATION = 0x0200
|
||||
PROCESS_SET_QUOTA = 0x0100
|
||||
PROCESS_SUSPEND_RESUME = 0x0800
|
||||
PROCESS_TERMINATE = 0x0001
|
||||
PROCESS_VM_OPERATION = 0x0008
|
||||
PROCESS_VM_READ = 0x0010
|
||||
PROCESS_VM_WRITE = 0x0020
|
||||
|
||||
# }}}
|
||||
|
||||
# input / output handles {{{
|
||||
|
||||
STD_INPUT_HANDLE = c_ulong(-10)
|
||||
STD_OUTPUT_HANDLE = c_ulong(-11)
|
||||
STD_ERROR_HANDLE = c_ulong(-12)
|
||||
|
||||
# }}}
|
||||
|
||||
CONQUE_WINDOWS_VK = { # {{{
|
||||
'VK_LBUTTON': 0x0001,
|
||||
'VK_RBUTTON': 0x0002,
|
||||
'VK_CANCEL': 0x0003,
|
||||
'VK_BACK': 0x0008,
|
||||
'VK_TAB': 0x0009,
|
||||
'VK_CLEAR': 0x000C,
|
||||
'VK_RETURN': 0x0D,
|
||||
'VK_SHIFT': 0x10,
|
||||
'VK_CONTROL': 0x11,
|
||||
'VK_MENU': 0x12,
|
||||
'VK_PAUSE': 0x0013,
|
||||
'VK_CAPITAL': 0x0014,
|
||||
'VK_ESCAPE': 0x001B,
|
||||
'VK_SPACE': 0x0020,
|
||||
'VK_PRIOR': 0x0021,
|
||||
'VK_NEXT': 0x0022,
|
||||
'VK_END': 0x0023,
|
||||
'VK_HOME': 0x0024,
|
||||
'VK_LEFT': 0x0025,
|
||||
'VK_UP': 0x0026,
|
||||
'VK_RIGHT': 0x0027,
|
||||
'VK_DOWN': 0x0028,
|
||||
'VK_SELECT': 0x0029,
|
||||
'VK_PRINT': 0x002A,
|
||||
'VK_EXECUTE': 0x002B,
|
||||
'VK_SNAPSHOT': 0x002C,
|
||||
'VK_INSERT': 0x002D,
|
||||
'VK_DELETE': 0x002E,
|
||||
'VK_HELP': 0x002F,
|
||||
'VK_0': 0x0030,
|
||||
'VK_1': 0x0031,
|
||||
'VK_2': 0x0032,
|
||||
'VK_3': 0x0033,
|
||||
'VK_4': 0x0034,
|
||||
'VK_5': 0x0035,
|
||||
'VK_6': 0x0036,
|
||||
'VK_7': 0x0037,
|
||||
'VK_8': 0x0038,
|
||||
'VK_9': 0x0039,
|
||||
'VK_A': 0x0041,
|
||||
'VK_B': 0x0042,
|
||||
'VK_C': 0x0043,
|
||||
'VK_D': 0x0044,
|
||||
'VK_E': 0x0045,
|
||||
'VK_F': 0x0046,
|
||||
'VK_G': 0x0047,
|
||||
'VK_H': 0x0048,
|
||||
'VK_I': 0x0049,
|
||||
'VK_J': 0x004A,
|
||||
'VK_K': 0x004B,
|
||||
'VK_L': 0x004C,
|
||||
'VK_M': 0x004D,
|
||||
'VK_N': 0x004E,
|
||||
'VK_O': 0x004F,
|
||||
'VK_P': 0x0050,
|
||||
'VK_Q': 0x0051,
|
||||
'VK_R': 0x0052,
|
||||
'VK_S': 0x0053,
|
||||
'VK_T': 0x0054,
|
||||
'VK_U': 0x0055,
|
||||
'VK_V': 0x0056,
|
||||
'VK_W': 0x0057,
|
||||
'VK_X': 0x0058,
|
||||
'VK_Y': 0x0059,
|
||||
'VK_Z': 0x005A,
|
||||
'VK_LWIN': 0x005B,
|
||||
'VK_RWIN': 0x005C,
|
||||
'VK_APPS': 0x005D,
|
||||
'VK_SLEEP': 0x005F,
|
||||
'VK_NUMPAD0': 0x0060,
|
||||
'VK_NUMPAD1': 0x0061,
|
||||
'VK_NUMPAD2': 0x0062,
|
||||
'VK_NUMPAD3': 0x0063,
|
||||
'VK_NUMPAD4': 0x0064,
|
||||
'VK_NUMPAD5': 0x0065,
|
||||
'VK_NUMPAD6': 0x0066,
|
||||
'VK_NUMPAD7': 0x0067,
|
||||
'VK_NUMPAD8': 0x0068,
|
||||
'VK_MULTIPLY': 0x006A,
|
||||
'VK_ADD': 0x006B,
|
||||
'VK_SEPARATOR': 0x006C,
|
||||
'VK_SUBTRACT': 0x006D,
|
||||
'VK_DECIMAL': 0x006E,
|
||||
'VK_DIVIDE': 0x006F,
|
||||
'VK_F1': 0x0070,
|
||||
'VK_F2': 0x0071,
|
||||
'VK_F3': 0x0072,
|
||||
'VK_F4': 0x0073,
|
||||
'VK_F5': 0x0074,
|
||||
'VK_F6': 0x0075,
|
||||
'VK_F7': 0x0076,
|
||||
'VK_F8': 0x0077,
|
||||
'VK_F9': 0x0078,
|
||||
'VK_F10': 0x0079,
|
||||
'VK_F11': 0x007A,
|
||||
'VK_F12': 0x007B,
|
||||
'VK_F13': 0x007C,
|
||||
'VK_F14': 0x007D,
|
||||
'VK_F15': 0x007E,
|
||||
'VK_F16': 0x007F,
|
||||
'VK_F17': 0x0080,
|
||||
'VK_F18': 0x0081,
|
||||
'VK_F19': 0x0082,
|
||||
'VK_F20': 0x0083,
|
||||
'VK_F21': 0x0084,
|
||||
'VK_F22': 0x0085,
|
||||
'VK_F23': 0x0086,
|
||||
'VK_F24': 0x0087,
|
||||
'VK_NUMLOCK': 0x0090,
|
||||
'VK_SCROLL': 0x0091,
|
||||
'VK_LSHIFT': 0x00A0,
|
||||
'VK_RSHIFT': 0x00A1,
|
||||
'VK_LCONTROL': 0x00A2,
|
||||
'VK_RCONTROL': 0x00A3,
|
||||
'VK_LMENU': 0x00A4,
|
||||
'VK_RMENU': 0x00A5
|
||||
}
|
||||
|
||||
CONQUE_WINDOWS_VK_INV = dict([v, k] for k, v in CONQUE_WINDOWS_VK.items())
|
||||
|
||||
CONQUE_WINDOWS_VK_ENHANCED = {
|
||||
str(int(CONQUE_WINDOWS_VK['VK_UP'])): 1,
|
||||
str(int(CONQUE_WINDOWS_VK['VK_DOWN'])): 1,
|
||||
str(int(CONQUE_WINDOWS_VK['VK_LEFT'])): 1,
|
||||
str(int(CONQUE_WINDOWS_VK['VK_RIGHT'])): 1,
|
||||
str(int(CONQUE_WINDOWS_VK['VK_HOME'])): 1,
|
||||
str(int(CONQUE_WINDOWS_VK['VK_END'])): 1
|
||||
}
|
||||
|
||||
# }}}
|
||||
|
||||
# structures used for CreateProcess
|
||||
|
||||
# Odd types {{{
|
||||
|
||||
LPBYTE = POINTER(c_ubyte)
|
||||
LPTSTR = POINTER(c_char)
|
||||
|
||||
# }}}
|
||||
|
||||
|
||||
class STARTUPINFO(Structure): # {{{
|
||||
_fields_ = [("cb", c_ulong),
|
||||
("lpReserved", LPTSTR),
|
||||
("lpDesktop", LPTSTR),
|
||||
("lpTitle", LPTSTR),
|
||||
("dwX", c_ulong),
|
||||
("dwY", c_ulong),
|
||||
("dwXSize", c_ulong),
|
||||
("dwYSize", c_ulong),
|
||||
("dwXCountChars", c_ulong),
|
||||
("dwYCountChars", c_ulong),
|
||||
("dwFillAttribute", c_ulong),
|
||||
("dwFlags", c_ulong),
|
||||
("wShowWindow", c_short),
|
||||
("cbReserved2", c_short),
|
||||
("lpReserved2", LPBYTE),
|
||||
("hStdInput", c_void_p),
|
||||
("hStdOutput", c_void_p),
|
||||
("hStdError", c_void_p),]
|
||||
|
||||
def to_str(self):
|
||||
return ''
|
||||
|
||||
# }}}
|
||||
|
||||
class PROCESS_INFORMATION(Structure): # {{{
|
||||
_fields_ = [("hProcess", c_void_p),
|
||||
("hThread", c_void_p),
|
||||
("dwProcessId", c_ulong),
|
||||
("dwThreadId", c_ulong),]
|
||||
|
||||
def to_str(self):
|
||||
return ''
|
||||
|
||||
# }}}
|
||||
|
||||
class MEMORY_BASIC_INFORMATION(Structure): # {{{
|
||||
_fields_ = [("BaseAddress", c_void_p),
|
||||
("AllocationBase", c_void_p),
|
||||
("AllocationProtect", c_ulong),
|
||||
("RegionSize", c_ulong),
|
||||
("State", c_ulong),
|
||||
("Protect", c_ulong),
|
||||
("Type", c_ulong),]
|
||||
|
||||
def to_str(self):
|
||||
return ''
|
||||
|
||||
# }}}
|
||||
|
||||
class SECURITY_ATTRIBUTES(Structure): # {{{
|
||||
_fields_ = [("Length", c_ulong),
|
||||
("SecDescriptor", c_void_p),
|
||||
("InheritHandle", c_bool)]
|
||||
|
||||
def to_str(self):
|
||||
return ''
|
||||
|
||||
# }}}
|
||||
|
||||
class COORD(Structure): # {{{
|
||||
_fields_ = [("X", c_short),
|
||||
("Y", c_short)]
|
||||
|
||||
def to_str(self):
|
||||
return ''
|
||||
|
||||
# }}}
|
||||
|
||||
class SMALL_RECT(Structure): # {{{
|
||||
_fields_ = [("Left", c_short),
|
||||
("Top", c_short),
|
||||
("Right", c_short),
|
||||
("Bottom", c_short)]
|
||||
|
||||
def to_str(self):
|
||||
return ''
|
||||
|
||||
# }}}
|
||||
|
||||
class CONSOLE_SCREEN_BUFFER_INFO(Structure): # {{{
|
||||
_fields_ = [("dwSize", COORD),
|
||||
("dwCursorPosition", COORD),
|
||||
("wAttributes", c_short),
|
||||
("srWindow", SMALL_RECT),
|
||||
("dwMaximumWindowSize", COORD)]
|
||||
|
||||
def to_str(self):
|
||||
return ''
|
||||
|
||||
# }}}
|
||||
|
||||
class CHAR_UNION(Union): # {{{
|
||||
_fields_ = [("UnicodeChar", c_wchar),
|
||||
("AsciiChar", c_char)]
|
||||
|
||||
def to_str(self):
|
||||
return ''
|
||||
|
||||
# }}}
|
||||
|
||||
class CHAR_INFO(Structure): # {{{
|
||||
_fields_ = [("Char", CHAR_UNION),
|
||||
("Attributes", c_short)]
|
||||
|
||||
def to_str(self):
|
||||
return ''
|
||||
|
||||
# }}}
|
||||
|
||||
class KEY_EVENT_RECORD(Structure): # {{{
|
||||
_fields_ = [("bKeyDown", c_byte),
|
||||
("pad2", c_byte),
|
||||
('pad1', c_short),
|
||||
("wRepeatCount", c_short),
|
||||
("wVirtualKeyCode", c_short),
|
||||
("wVirtualScanCode", c_short),
|
||||
("uChar", CHAR_UNION),
|
||||
("dwControlKeyState", c_int)]
|
||||
|
||||
def to_str(self):
|
||||
return ''
|
||||
|
||||
# }}}
|
||||
|
||||
class MOUSE_EVENT_RECORD(Structure): # {{{
|
||||
_fields_ = [("dwMousePosition", COORD),
|
||||
("dwButtonState", c_int),
|
||||
("dwControlKeyState", c_int),
|
||||
("dwEventFlags", c_int)]
|
||||
|
||||
def to_str(self):
|
||||
return ''
|
||||
|
||||
# }}}
|
||||
|
||||
class WINDOW_BUFFER_SIZE_RECORD(Structure): # {{{
|
||||
_fields_ = [("dwSize", COORD)]
|
||||
|
||||
def to_str(self):
|
||||
return ''
|
||||
|
||||
# }}}
|
||||
|
||||
class MENU_EVENT_RECORD(Structure): # {{{
|
||||
_fields_ = [("dwCommandId", c_uint)]
|
||||
|
||||
def to_str(self):
|
||||
return ''
|
||||
|
||||
# }}}
|
||||
|
||||
class FOCUS_EVENT_RECORD(Structure): # {{{
|
||||
_fields_ = [("bSetFocus", c_byte)]
|
||||
|
||||
def to_str(self):
|
||||
return ''
|
||||
# }}}
|
||||
|
||||
class INPUT_UNION(Union): # {{{
|
||||
_fields_ = [("KeyEvent", KEY_EVENT_RECORD),
|
||||
("MouseEvent", MOUSE_EVENT_RECORD),
|
||||
("WindowBufferSizeEvent", WINDOW_BUFFER_SIZE_RECORD),
|
||||
("MenuEvent", MENU_EVENT_RECORD),
|
||||
("FocusEvent", FOCUS_EVENT_RECORD)]
|
||||
|
||||
def to_str(self):
|
||||
return ''
|
||||
# }}}
|
||||
|
||||
class INPUT_RECORD(Structure): # {{{
|
||||
_fields_ = [("EventType", c_short),
|
||||
("Event", INPUT_UNION)]
|
||||
|
||||
def to_str(self):
|
||||
return ''
|
||||
# }}}
|
||||
|
||||
# vim:foldmethod=marker
|
||||
|
|
@ -12,7 +12,7 @@ The *Official Version* of this plugin is available at [vim.org](http://www.vim.o
|
|||
|
||||
### Ack
|
||||
|
||||
You have to install [ack](http://search.cpan.org/~petdance/ack/ack), of course.
|
||||
You have to install [ack](http://betterthangrep.com/), of course.
|
||||
|
||||
Install on Debian / Ubuntu with:
|
||||
|
||||
|
|
@ -26,6 +26,9 @@ Install on Gentoo with:
|
|||
|
||||
sudo emerge ack
|
||||
|
||||
Install with Homebrew:
|
||||
brew install ack
|
||||
|
||||
Install with MacPorts:
|
||||
|
||||
sudo port install p5-app-ack
|
||||
|
|
@ -59,7 +62,7 @@ in this window will open the file, and place the cursor on the matching line.
|
|||
|
||||
Just like where you use :grep, :grepadd, :lgrep, and :lgrepadd, you can use `:Ack`, `:AckAdd`, `:LAck`, and `:LAckAdd` respectively. (See `doc/ack.txt`, or install and `:h Ack` for more information.)
|
||||
|
||||
**From the [ack docs](http://search.cpan.org/~petdance/ack/ack)** (my favorite feature):
|
||||
**From the [ack docs](http://betterthangrep.com/)** (my favorite feature):
|
||||
|
||||
--type=TYPE, --type=noTYPE
|
||||
|
||||
|
|
@ -71,10 +74,20 @@ Just like where you use :grep, :grepadd, :lgrep, and :lgrepadd, you can use `:Ac
|
|||
|
||||
See ack --help=types for a list of valid types.
|
||||
|
||||
### Keyboard Shortcuts ###
|
||||
|
||||
In the quickfix window, you can use:
|
||||
|
||||
o to open (same as enter)
|
||||
go to preview file (open but maintain focus on ack.vim results)
|
||||
t to open in new tab
|
||||
T to open in new tab silently
|
||||
q to close the quickfix window
|
||||
|
||||
This Vim plugin is derived (and by derived, I mean copied, essentially) from
|
||||
Antoine Imbert's blog post [Ack and Vim
|
||||
Integration](http://blog.ant0ine.com/2007/03/ack_and_vim_integration.html) (in
|
||||
Integration](http://blog.ant0ine.com/typepad/2007/03/ack-and-vim-integration.html) (in
|
||||
particular, the function at the bottom of the post). I added a help file that
|
||||
provides just enough reference to get you going. I also highly recommend you
|
||||
check out the docs for the Perl script 'ack', for obvious reasons: [ack -
|
||||
grep-like text finder](http://search.cpan.org/~petdance/ack/ack).
|
||||
grep-like text finder](http://betterthangrep.com/).
|
||||
|
|
|
|||
|
|
@ -11,11 +11,12 @@ This plugin is a front for the Perl module App::Ack. Ack can be used as a
|
|||
replacement for grep. This plugin will allow you to run ack from vim, and
|
||||
shows the results in a split window.
|
||||
|
||||
:Ack [options] {pattern} [{directory}] *:Ack*
|
||||
:Ack[!] [options] {pattern} [{directory}] *:Ack*
|
||||
|
||||
Search recursively in {directory} (which defaults to the current
|
||||
directory) for the {pattern}. Behaves just like the |:grep| command, but
|
||||
will open the |Quickfix| window for you.
|
||||
will open the |Quickfix| window for you. If [!] is not given the first
|
||||
error is jumped to.
|
||||
|
||||
:AckAdd [options] {pattern} [{directory}] *:AckAdd*
|
||||
|
||||
|
|
@ -47,4 +48,4 @@ with the line number of the occurrence, once for each occurrence. <Enter> on
|
|||
a line in this window will open the file, and place the cursor on the matching
|
||||
line.
|
||||
|
||||
See http://search.cpan.org/~petdance/ack/ack for more information.
|
||||
See http://betterthangrep.com/ for more information.
|
||||
|
|
|
|||
|
|
@ -17,6 +17,13 @@ function! s:Ack(cmd, args)
|
|||
redraw
|
||||
echo "Searching ..."
|
||||
|
||||
" If no pattern is provided, search for the word under the cursor
|
||||
if empty(a:args)
|
||||
let l:grepargs = expand("<cword>")
|
||||
else
|
||||
let l:grepargs = a:args
|
||||
end
|
||||
|
||||
" Format, used to manage column jump
|
||||
if a:cmd =~# '-g$'
|
||||
let g:ackformat="%f"
|
||||
|
|
@ -29,7 +36,7 @@ function! s:Ack(cmd, args)
|
|||
try
|
||||
let &grepprg=g:ackprg
|
||||
let &grepformat=g:ackformat
|
||||
silent execute a:cmd . " " . a:args
|
||||
silent execute a:cmd . " " . l:grepargs
|
||||
finally
|
||||
let &grepprg=grepprg_bak
|
||||
let &grepformat=grepformat_bak
|
||||
|
|
@ -41,7 +48,18 @@ function! s:Ack(cmd, args)
|
|||
botright copen
|
||||
endif
|
||||
|
||||
exec "nnoremap <silent> <buffer> q :ccl<CR>"
|
||||
" TODO: Document this!
|
||||
exec "nnoremap <silent> <buffer> q :ccl<CR>"
|
||||
exec "nnoremap <silent> <buffer> t <C-W><CR><C-W>T"
|
||||
exec "nnoremap <silent> <buffer> T <C-W><CR><C-W>TgT<C-W><C-W>"
|
||||
exec "nnoremap <silent> <buffer> o <CR>"
|
||||
exec "nnoremap <silent> <buffer> go <CR><C-W><C-W>"
|
||||
|
||||
" If highlighting is on, highlight the search keyword.
|
||||
if exists("g:ackhighlight")
|
||||
let @/=a:args
|
||||
set hlsearch
|
||||
end
|
||||
|
||||
redraw!
|
||||
endfunction
|
||||
|
|
|
|||
181
.vim/bundle/command-t/ruby/command-t/Makefile
Normal file
181
.vim/bundle/command-t/ruby/command-t/Makefile
Normal file
|
|
@ -0,0 +1,181 @@
|
|||
|
||||
SHELL = /bin/sh
|
||||
|
||||
#### Start of system configuration section. ####
|
||||
|
||||
srcdir = .
|
||||
topdir = /usr/lib/ruby/1.8/x86_64-linux
|
||||
hdrdir = $(topdir)
|
||||
VPATH = $(srcdir):$(topdir):$(hdrdir)
|
||||
exec_prefix = $(prefix)
|
||||
prefix = $(DESTDIR)/usr
|
||||
sharedstatedir = $(prefix)/com
|
||||
mandir = $(prefix)/share/man
|
||||
psdir = $(docdir)
|
||||
oldincludedir = $(DESTDIR)/usr/include
|
||||
localedir = $(datarootdir)/locale
|
||||
bindir = $(exec_prefix)/bin
|
||||
libexecdir = $(prefix)/lib/ruby1.8
|
||||
sitedir = $(DESTDIR)/usr/local/lib/site_ruby
|
||||
htmldir = $(docdir)
|
||||
vendorarchdir = $(vendorlibdir)/$(sitearch)
|
||||
includedir = $(prefix)/include
|
||||
infodir = $(prefix)/share/info
|
||||
vendorlibdir = $(vendordir)/$(ruby_version)
|
||||
sysconfdir = $(DESTDIR)/etc
|
||||
libdir = $(exec_prefix)/lib
|
||||
sbindir = $(exec_prefix)/sbin
|
||||
rubylibdir = $(libdir)/ruby/$(ruby_version)
|
||||
docdir = $(datarootdir)/doc/$(PACKAGE)
|
||||
dvidir = $(docdir)
|
||||
vendordir = $(libdir)/ruby/vendor_ruby
|
||||
datarootdir = $(prefix)/share
|
||||
pdfdir = $(docdir)
|
||||
archdir = $(rubylibdir)/$(arch)
|
||||
sitearchdir = $(sitelibdir)/$(sitearch)
|
||||
datadir = $(datarootdir)
|
||||
localstatedir = $(DESTDIR)/var
|
||||
sitelibdir = $(sitedir)/$(ruby_version)
|
||||
|
||||
CC = gcc
|
||||
LIBRUBY = $(LIBRUBY_SO)
|
||||
LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
|
||||
LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
|
||||
LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
|
||||
|
||||
RUBY_EXTCONF_H =
|
||||
CFLAGS = -fPIC -fno-strict-aliasing -g -g -O2 -fPIC $(cflags)
|
||||
INCFLAGS = -I. -I$(topdir) -I$(hdrdir) -I$(srcdir)
|
||||
DEFS =
|
||||
CPPFLAGS = -DHAVE_RUBY_H $(DEFS) $(cppflags)
|
||||
CXXFLAGS = $(CFLAGS)
|
||||
ldflags = -L. -Wl,-Bsymbolic-functions -rdynamic -Wl,-export-dynamic
|
||||
dldflags =
|
||||
archflag =
|
||||
DLDFLAGS = $(ldflags) $(dldflags) $(archflag)
|
||||
LDSHARED = $(CC) -shared
|
||||
AR = ar
|
||||
EXEEXT =
|
||||
|
||||
RUBY_INSTALL_NAME = ruby1.8
|
||||
RUBY_SO_NAME = ruby1.8
|
||||
arch = x86_64-linux
|
||||
sitearch = x86_64-linux
|
||||
ruby_version = 1.8
|
||||
ruby = /usr/bin/ruby1.8
|
||||
RUBY = $(ruby)
|
||||
RM = rm -f
|
||||
MAKEDIRS = mkdir -p
|
||||
INSTALL = /usr/bin/install -c
|
||||
INSTALL_PROG = $(INSTALL) -m 0755
|
||||
INSTALL_DATA = $(INSTALL) -m 644
|
||||
COPY = cp
|
||||
|
||||
#### End of system configuration section. ####
|
||||
|
||||
preload =
|
||||
|
||||
libpath = . $(libdir)
|
||||
LIBPATH = -L. -L$(libdir)
|
||||
DEFFILE =
|
||||
|
||||
CLEANFILES = mkmf.log
|
||||
DISTCLEANFILES =
|
||||
|
||||
extout =
|
||||
extout_prefix =
|
||||
target_prefix =
|
||||
LOCAL_LIBS =
|
||||
LIBS = $(LIBRUBYARG_SHARED) -lpthread -lrt -ldl -lcrypt -lm -lc
|
||||
SRCS = ext.c match.c matcher.c
|
||||
OBJS = ext.o match.o matcher.o
|
||||
TARGET = ext
|
||||
DLLIB = $(TARGET).so
|
||||
EXTSTATIC =
|
||||
STATIC_LIB =
|
||||
|
||||
BINDIR = $(bindir)
|
||||
RUBYCOMMONDIR = $(sitedir)$(target_prefix)
|
||||
RUBYLIBDIR = $(sitelibdir)$(target_prefix)
|
||||
RUBYARCHDIR = $(sitearchdir)$(target_prefix)
|
||||
|
||||
TARGET_SO = $(DLLIB)
|
||||
CLEANLIBS = $(TARGET).so $(TARGET).il? $(TARGET).tds $(TARGET).map
|
||||
CLEANOBJS = *.o *.a *.s[ol] *.pdb *.exp *.bak
|
||||
|
||||
all: $(DLLIB)
|
||||
static: $(STATIC_LIB)
|
||||
|
||||
clean:
|
||||
@-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
|
||||
|
||||
distclean: clean
|
||||
@-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
|
||||
@-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
|
||||
|
||||
realclean: distclean
|
||||
install: install-so install-rb
|
||||
|
||||
install-so: $(RUBYARCHDIR)
|
||||
install-so: $(RUBYARCHDIR)/$(DLLIB)
|
||||
$(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
|
||||
$(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
|
||||
install-rb: pre-install-rb install-rb-default
|
||||
install-rb-default: pre-install-rb-default
|
||||
pre-install-rb: Makefile
|
||||
pre-install-rb-default: Makefile
|
||||
$(RUBYARCHDIR):
|
||||
$(MAKEDIRS) $@
|
||||
|
||||
site-install: site-install-so site-install-rb
|
||||
site-install-so: install-so
|
||||
site-install-rb: install-rb
|
||||
|
||||
.SUFFIXES: .c .m .cc .cxx .cpp .C .o
|
||||
|
||||
.cc.o:
|
||||
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
|
||||
|
||||
.cxx.o:
|
||||
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
|
||||
|
||||
.cpp.o:
|
||||
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
|
||||
|
||||
.C.o:
|
||||
$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
|
||||
|
||||
.c.o:
|
||||
$(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) -c $<
|
||||
|
||||
$(DLLIB): $(OBJS) Makefile
|
||||
@-$(RM) $@
|
||||
$(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
|
||||
|
||||
|
||||
|
||||
###
|
||||
# Copyright 2010 Wincent Colaiuta. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
CFLAGS += -std=c99 -Wall -Wextra -Wno-unused-parameter
|
||||
10
.vim/bundle/command-t/ruby/command-t/mkmf.log
Normal file
10
.vim/bundle/command-t/ruby/command-t/mkmf.log
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
have_header: checking for ruby.h... -------------------- yes
|
||||
|
||||
"gcc -E -I. -I/usr/lib/ruby/1.8/x86_64-linux -I. -fno-strict-aliasing -g -g -O2 -fPIC conftest.c -o conftest.i"
|
||||
checked program was:
|
||||
/* begin */
|
||||
1: #include <ruby.h>
|
||||
/* end */
|
||||
|
||||
--------------------
|
||||
|
||||
|
|
@ -404,6 +404,8 @@ then the script would do a sexy comment on the last visual selection.
|
|||
doing visual-block comments.
|
||||
|'NERDCommentWholeLinesInVMode'| Changes behaviour of visual comments.
|
||||
|'NERDCreateDefaultMappings'| Turn the default mappings on/off.
|
||||
|'NERDCustomDelimiters'| Add or override delimiters for any
|
||||
filetypes.
|
||||
|'NERDDefaultNesting'| Tells the script to use nested comments
|
||||
by default.
|
||||
|'NERDMenuMode'| Specifies how the NERD commenter menu
|
||||
|
|
@ -550,7 +552,7 @@ Note that this option does not affect the behaviour of commenting in
|
|||
|visual-block| mode.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*'NERDCreateDefaultMappings'*
|
||||
*'NERDCreateDefaultMappings'*
|
||||
Values: 0 or 1.
|
||||
Default: 1.
|
||||
|
||||
|
|
@ -559,6 +561,25 @@ If set to 0, none of the default mappings will be created.
|
|||
See also |NERDComMappings|.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*'NERDCustomDelimiters'*
|
||||
Values: A map (format specified below).
|
||||
Default: {}
|
||||
|
||||
Use this option if you have new filetypes you want the script to handle, or if
|
||||
you want to override the default delimiters of a filetype.
|
||||
|
||||
Example: >
|
||||
let g:NERDCustomDelimiters = {
|
||||
\ 'ruby': { 'left': '#', 'leftAlt': 'FOO', 'rightAlt': 'BAR' },
|
||||
\ 'grondle': { 'left': '{{', 'right': '}}' }
|
||||
\ }
|
||||
<
|
||||
|
||||
Here we override the delimiter settings for ruby and add FOO/BAR as alternative
|
||||
delimiters. We also add {{ and }} as delimiters for a new filetype called
|
||||
'grondle'.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*'NERDRemoveAltComs'*
|
||||
Values: 0 or 1.
|
||||
Default: 1.
|
||||
|
|
@ -576,7 +597,7 @@ It will not be uncommented if the NERDRemoveAltComs is set to 0.
|
|||
------------------------------------------------------------------------------
|
||||
*'NERDRemoveExtraSpaces'*
|
||||
Values: 0 or 1.
|
||||
Default: 1.
|
||||
Default: 0.
|
||||
|
||||
By default, the NERD commenter will remove spaces around comment delimiters if
|
||||
either:
|
||||
|
|
@ -599,8 +620,6 @@ Otherwise they would become: >
|
|||
int bar = 10;
|
||||
int baz = foo + bar
|
||||
<
|
||||
If you want the spaces to be removed only if |'NERDSpaceDelims'| is set then
|
||||
set NERDRemoveExtraSpaces to 0.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*'NERDLPlace'*
|
||||
|
|
@ -633,7 +652,7 @@ Default: 3
|
|||
This option can take 4 values:
|
||||
"0": Turns the menu off.
|
||||
"1": Turns the 'comment' menu on with no menu shortcut.
|
||||
"2": Turns the 'comment 'menu on with <alt>-c as the shortcut.
|
||||
"2": Turns the 'comment' menu on with <alt>-c as the shortcut.
|
||||
"3": Turns the 'Plugin -> comment' menu on with <alt>-c as the shortcut.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
|
@ -781,6 +800,15 @@ The latest dev versions are on github
|
|||
==============================================================================
|
||||
8. Changelog *NERDComChangelog*
|
||||
|
||||
2.3.0
|
||||
- remove all filetypes which have a &commentstring in the standard vim
|
||||
runtime for vim > 7.0 unless the script stores an alternate set of
|
||||
delimiters
|
||||
- make the script complain if the user doesnt have filetype plugins enabled
|
||||
- use <leader> instead of comma to start the default mappings
|
||||
- fix a couple of bugs with sexy comments - thanks to Tim Smart
|
||||
- lots of refactoring
|
||||
|
||||
2.2.2
|
||||
- remove the NERDShutup option and the message is suppresses, this makes
|
||||
the plugin silently rely on &commentstring for unknown filetypes.
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
" ============================================================================
|
||||
" File: NERD_commenter.vim
|
||||
" Description: vim global plugin that provides easy code commenting
|
||||
" Maintainer: Martin Grenfell <martin_grenfell at msn dot com>
|
||||
" Version: 2.2.2
|
||||
" Last Change: 09th October, 2010
|
||||
" Maintainer: Martin Grenfell <martin.grenfell at gmail dot com>
|
||||
" Version: 2.3.0
|
||||
" Last Change: 08th December, 2010
|
||||
" License: This program is free software. It comes without any warranty,
|
||||
" to the extent permitted by applicable law. You can redistribute
|
||||
" it and/or modify it under the terms of the Do What The Fuck You
|
||||
|
|
@ -47,7 +47,7 @@ endfunction
|
|||
let s:spaceStr = ' '
|
||||
let s:lenSpaceStr = strlen(s:spaceStr)
|
||||
|
||||
" Section: variable init calls {{{2
|
||||
" Section: variable initialization {{{2
|
||||
call s:InitVariable("g:NERDAllowAnyVisualDelims", 1)
|
||||
call s:InitVariable("g:NERDBlockComIgnoreEmpty", 0)
|
||||
call s:InitVariable("g:NERDCommentWholeLinesInVMode", 0)
|
||||
|
|
@ -58,13 +58,15 @@ call s:InitVariable("g:NERDMenuMode", 3)
|
|||
call s:InitVariable("g:NERDLPlace", "[>")
|
||||
call s:InitVariable("g:NERDUsePlaceHolders", 1)
|
||||
call s:InitVariable("g:NERDRemoveAltComs", 1)
|
||||
call s:InitVariable("g:NERDRemoveExtraSpaces", 1)
|
||||
call s:InitVariable("g:NERDRemoveExtraSpaces", 0)
|
||||
call s:InitVariable("g:NERDRPlace", "<]")
|
||||
call s:InitVariable("g:NERDSpaceDelims", 0)
|
||||
call s:InitVariable("g:NERDDelimiterRequests", 1)
|
||||
|
||||
if !exists("g:NERDCustomDelimiters")
|
||||
let g:NERDCustomDelimiters = {}
|
||||
endif
|
||||
|
||||
let s:NERDFileNameEscape="[]#*$%'\" ?`!&();<>\\"
|
||||
"vf ;;dA:hcs"'A {j^f(lyi(k$p0f{a A }0f{a 'left':jdd^
|
||||
|
||||
let s:delimiterMap = {
|
||||
\ 'aap': { 'left': '#' },
|
||||
|
|
@ -144,7 +146,7 @@ let s:delimiterMap = {
|
|||
\ 'eiffel': { 'left': '--' },
|
||||
\ 'elf': { 'left': "'" },
|
||||
\ 'elmfilt': { 'left': '#' },
|
||||
\ 'erlang': { 'left': '%' },
|
||||
\ 'erlang': { 'left': '%', 'leftAlt': '%%' },
|
||||
\ 'eruby': { 'left': '<%#', 'right': '%>', 'leftAlt': '<!--', 'rightAlt': '-->' },
|
||||
\ 'expect': { 'left': '#' },
|
||||
\ 'exports': { 'left': '#' },
|
||||
|
|
@ -173,7 +175,7 @@ let s:delimiterMap = {
|
|||
\ 'gitrebase': { 'left': '#' },
|
||||
\ 'gnuplot': { 'left': '#' },
|
||||
\ 'groovy': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
||||
\ 'gsp': { 'left': '<%--', 'right': '--%>' },
|
||||
\ 'gsp': { 'left': '<%--', 'right': '--%>', 'leftAlt': '<!--','rightAlt': '-->'},
|
||||
\ 'gtkrc': { 'left': '#' },
|
||||
\ 'haskell': { 'left': '{-','right': '-}', 'leftAlt': '--' },
|
||||
\ 'hb': { 'left': '#' },
|
||||
|
|
@ -206,9 +208,10 @@ let s:delimiterMap = {
|
|||
\ 'kscript': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
||||
\ 'lace': { 'left': '--' },
|
||||
\ 'ldif': { 'left': '#' },
|
||||
\ 'less': { 'left': '/*','right': '*/' },
|
||||
\ 'lilo': { 'left': '#' },
|
||||
\ 'lilypond': { 'left': '%' },
|
||||
\ 'liquid': { 'left': '{%', 'right': '%}' },
|
||||
\ 'liquid': { 'left': '{% comment %}', 'right': '{% endcomment %}' },
|
||||
\ 'lisp': { 'left': ';', 'leftAlt': '#|', 'rightAlt': '|#' },
|
||||
\ 'llvm': { 'left': ';' },
|
||||
\ 'lotos': { 'left': '(*', 'right': '*)' },
|
||||
|
|
@ -255,6 +258,7 @@ let s:delimiterMap = {
|
|||
\ 'occam': { 'left': '--' },
|
||||
\ 'omlet': { 'left': '(*', 'right': '*)' },
|
||||
\ 'omnimark': { 'left': ';' },
|
||||
\ 'ooc': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
||||
\ 'openroad': { 'left': '//' },
|
||||
\ 'opl': { 'left': "REM" },
|
||||
\ 'ora': { 'left': '#' },
|
||||
|
|
@ -300,8 +304,10 @@ let s:delimiterMap = {
|
|||
\ 'sass': { 'left': '//', 'leftAlt': '/*' },
|
||||
\ 'sather': { 'left': '--' },
|
||||
\ 'scala': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' },
|
||||
\ 'scheme': { 'left': ';', 'leftAlt': '#|', 'rightAlt': '|#' },
|
||||
\ 'scilab': { 'left': '//' },
|
||||
\ 'scsh': { 'left': ';' },
|
||||
\ 'scss': { 'left': '/*','right': '*/' },
|
||||
\ 'sed': { 'left': '#' },
|
||||
\ 'sgmldecl': { 'left': '--', 'right': '--' },
|
||||
\ 'sgmllnx': { 'left': '<!--', 'right': '-->' },
|
||||
|
|
@ -376,12 +382,17 @@ let s:delimiterMap = {
|
|||
\ 'z8a': { 'left': ';' }
|
||||
\ }
|
||||
|
||||
"merge in the custom delimiters
|
||||
for ft in keys(g:NERDCustomDelimiters)
|
||||
let s:delimiterMap[ft] = g:NERDCustomDelimiters[ft]
|
||||
endfor
|
||||
|
||||
" Section: Comment mapping functions, autocommands and commands {{{1
|
||||
" ============================================================================
|
||||
" Section: Comment enabler autocommands {{{2
|
||||
" ============================================================================
|
||||
|
||||
augroup commentEnablers
|
||||
augroup NERDCommenter
|
||||
|
||||
"if the user enters a buffer or reads a buffer then we gotta set up
|
||||
"the comment delimiters for that new filetype
|
||||
|
|
@ -403,10 +414,24 @@ augroup END
|
|||
" set for this buffer.
|
||||
"
|
||||
function s:SetUpForNewFiletype(filetype, forceReset)
|
||||
let ft = a:filetype
|
||||
|
||||
"for compound filetypes, if we dont know how to handle the full filetype
|
||||
"then break it down and use the first part that we know how to handle
|
||||
if ft =~ '\.' && !has_key(s:delimiterMap, ft)
|
||||
let filetypes = split(a:filetype, '\.')
|
||||
for i in filetypes
|
||||
if has_key(s:delimiterMap, i)
|
||||
let ft = i
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
|
||||
let b:NERDSexyComMarker = ''
|
||||
|
||||
if has_key(s:delimiterMap, a:filetype)
|
||||
let b:NERDCommenterDelims = s:delimiterMap[a:filetype]
|
||||
if has_key(s:delimiterMap, ft)
|
||||
let b:NERDCommenterDelims = s:delimiterMap[ft]
|
||||
for i in ['left', 'leftAlt', 'right', 'rightAlt']
|
||||
if !has_key(b:NERDCommenterDelims, i)
|
||||
let b:NERDCommenterDelims[i] = ''
|
||||
|
|
@ -1001,6 +1026,10 @@ function! NERDComment(isVisual, type) range
|
|||
let oldIgnoreCase = &ignorecase
|
||||
set noignorecase
|
||||
|
||||
if !exists("g:did_load_ftplugin") || g:did_load_ftplugin != 1
|
||||
call s:NerdEcho("filetype plugins should be enabled. See :help NERDComInstallation and :help :filetype-plugin-on", 0)
|
||||
endif
|
||||
|
||||
if a:isVisual
|
||||
let firstLine = line("'<")
|
||||
let lastLine = line("'>")
|
||||
|
|
@ -2400,10 +2429,10 @@ endfunction
|
|||
function s:NerdEcho(msg, typeOfMsg)
|
||||
if a:typeOfMsg == 0
|
||||
echohl WarningMsg
|
||||
echo 'NERDCommenter:' . a:msg
|
||||
echom 'NERDCommenter:' . a:msg
|
||||
echohl None
|
||||
elseif a:typeOfMsg == 1
|
||||
echo 'NERDCommenter:' . a:msg
|
||||
echom 'NERDCommenter:' . a:msg
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
|
|
|||
|
|
@ -642,6 +642,12 @@ NERD tree. These options should be set in your vimrc.
|
|||
|'NERDTreeWinSize'| Sets the window size when the NERD tree is
|
||||
opened.
|
||||
|
||||
|'NERDTreeMinimalUI'| Disables display of the 'Bookmarks' label and
|
||||
'Press ? for help' text.
|
||||
|
||||
|'NERDTreeDirArrows'| Tells the NERD tree to use arrows instead of
|
||||
+ ~ chars when displaying directories.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
3.2. Customisation details *NERDTreeOptionDetails*
|
||||
|
||||
|
|
@ -921,6 +927,30 @@ Default: 31.
|
|||
|
||||
This option is used to change the size of the NERD tree when it is loaded.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*'NERDTreeMinimalUI'*
|
||||
Values: 0 or 1
|
||||
Default: 0
|
||||
|
||||
This options disables the 'Bookmarks' label 'Press ? for help' text. Use one
|
||||
of the following lines to set this option: >
|
||||
let NERDTreeMinimalUI=0
|
||||
let NERDTreeMinimalUI=1
|
||||
<
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*'NERDTreeDirArrows'*
|
||||
Values: 0 or 1
|
||||
Default: 0.
|
||||
|
||||
This option is used to change the default look of directory nodes displayed in
|
||||
the tree. When set to 0 it shows old-school bars (|), + and ~ chars. If set to
|
||||
1 it shows right and down arrows. Use one of the follow lines to set this
|
||||
option: >
|
||||
let NERDTreeDirArrows=0
|
||||
let NERDTreeDirArrows=1
|
||||
<
|
||||
|
||||
==============================================================================
|
||||
4. The NERD tree API *NERDTreeAPI*
|
||||
|
||||
|
|
@ -1080,6 +1110,9 @@ The latest dev versions are on github
|
|||
==============================================================================
|
||||
6. Changelog *NERDTreeChangelog*
|
||||
|
||||
4.x.x
|
||||
- Fix a bug with :NERDTreeFind and symlinks. Thanks to Vitaly Bogdanov.
|
||||
|
||||
4.1.0
|
||||
features:
|
||||
- NERDTreeFind to reveal the node for the current buffer in the tree,
|
||||
|
|
@ -1214,6 +1247,7 @@ just downloaded pr0n instead.
|
|||
Ricky
|
||||
jfilip1024
|
||||
Chris Chambers
|
||||
Vitaly Bogdanov
|
||||
|
||||
==============================================================================
|
||||
8. License *NERDTreeLicense*
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ endif
|
|||
let g:loaded_nerdtree_fs_menu = 1
|
||||
|
||||
call NERDTreeAddMenuItem({'text': '(a)dd a childnode', 'shortcut': 'a', 'callback': 'NERDTreeAddNode'})
|
||||
call NERDTreeAddMenuItem({'text': '(m)ove the curent node', 'shortcut': 'm', 'callback': 'NERDTreeMoveNode'})
|
||||
call NERDTreeAddMenuItem({'text': '(d)elete the curent node', 'shortcut': 'd', 'callback': 'NERDTreeDeleteNode'})
|
||||
call NERDTreeAddMenuItem({'text': '(m)ove the current node', 'shortcut': 'm', 'callback': 'NERDTreeMoveNode'})
|
||||
call NERDTreeAddMenuItem({'text': '(d)elete the current node', 'shortcut': 'd', 'callback': 'NERDTreeDeleteNode'})
|
||||
if g:NERDTreePath.CopyingSupported()
|
||||
call NERDTreeAddMenuItem({'text': '(c)copy the current node', 'shortcut': 'c', 'callback': 'NERDTreeCopyNode'})
|
||||
endif
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
1
.vim/bundle/vim-coffee-script/ftdetect/eco.vim
Normal file
1
.vim/bundle/vim-coffee-script/ftdetect/eco.vim
Normal file
|
|
@ -0,0 +1 @@
|
|||
autocmd BufNewFile,BufRead *.eco set filetype=eco
|
||||
|
|
@ -12,3 +12,8 @@ let b:did_ftplugin = 1
|
|||
setlocal formatoptions-=t formatoptions+=croql
|
||||
setlocal comments=s:###,m:\ ,e:###,:#
|
||||
setlocal commentstring=#\ %s
|
||||
|
||||
" Compile the current file on write.
|
||||
if exists("coffee_compile_on_save")
|
||||
autocmd BufWritePost,FileWritePost *.coffee silent !coffee -c <afile> &
|
||||
endif
|
||||
|
|
|
|||
|
|
@ -11,30 +11,30 @@ let b:did_indent = 1
|
|||
|
||||
setlocal autoindent
|
||||
setlocal indentexpr=GetCoffeeIndent(v:lnum)
|
||||
" Make sure GetCoffeeIndent is run when these are typed so they can be outdented
|
||||
setlocal indentkeys+=0],0),=else,=when,=catch,=finally
|
||||
" Make sure GetCoffeeIndent is run when these are typed so they can be
|
||||
" indented or outdented.
|
||||
setlocal indentkeys+=0],0),0.,=else,=when,=catch,=finally
|
||||
|
||||
" Only define the function once
|
||||
" Only define the function once.
|
||||
if exists("*GetCoffeeIndent")
|
||||
finish
|
||||
endif
|
||||
|
||||
" Join a list of regexps as branches
|
||||
" Join a list of regexps as branches.
|
||||
function! s:RegexpJoin(regexps)
|
||||
return join(a:regexps, '\|')
|
||||
endfunction
|
||||
|
||||
" Create a regexp group from a list of regexps
|
||||
" Create a regexp group from a list of regexps.
|
||||
function! s:RegexpGroup(...)
|
||||
return '\%(' . s:RegexpJoin(a:000) . '\)'
|
||||
endfunction
|
||||
|
||||
" Outdent certain keywords and brackets
|
||||
" Outdent certain keywords and brackets.
|
||||
let s:outdent = '^'
|
||||
\ . s:RegexpGroup('else', 'when', 'catch', 'finally',
|
||||
\ ']', '}', ')')
|
||||
\ . s:RegexpGroup('else', 'when', 'catch', 'finally', ']', '}', ')')
|
||||
|
||||
" Indent after certain keywords
|
||||
" Indent after certain keywords.
|
||||
let s:indent_after_keywords = '^'
|
||||
\ . s:RegexpGroup('if', 'unless', 'else', 'for',
|
||||
\ 'while', 'until', 'loop', 'switch',
|
||||
|
|
@ -42,23 +42,28 @@ let s:indent_after_keywords = '^'
|
|||
\ 'class')
|
||||
\ . '\>'
|
||||
|
||||
" Indent after brackets, functions, and assignments
|
||||
let s:indent_after_literals = s:RegexpGroup('\[', '{', '(', '->', '=>',
|
||||
\ ':', '=')
|
||||
" Indent after brackets, functions, and assignments.
|
||||
let s:indent_after_literals = s:RegexpGroup('\[', '{', '(', '->', '=>', ':', '=')
|
||||
\ . '$'
|
||||
|
||||
" Combine the two regexps above
|
||||
" Combine the two regexps above.
|
||||
let s:indent_after = s:RegexpJoin([s:indent_after_keywords,
|
||||
\ s:indent_after_literals])
|
||||
|
||||
" Indent after certain keywords used in multi-line assignments
|
||||
" Indent after operators at the end of lines.
|
||||
let s:continuations = s:RegexpGroup('-\@<!>', '=\@<!>', '-\@<!-', '+\@<!+',
|
||||
\ '<', '\*', '/', '%', '|', '&', ',',
|
||||
\ '\.\@<!\.', 'is', 'isnt', 'and', 'or')
|
||||
\ . '$'
|
||||
|
||||
" Indent after certain keywords used as multi-line assignments.
|
||||
let s:assignment_keywords = s:RegexpGroup(':', '=')
|
||||
\ . '\s*\<'
|
||||
\ . s:RegexpGroup('if', 'unless', 'for', 'while',
|
||||
\ 'until', 'switch', 'try', 'class')
|
||||
\ . '\>'
|
||||
|
||||
" Outdent after certain keywords
|
||||
" Outdent after certain keywords.
|
||||
let s:outdent_after = '^'
|
||||
\ . s:RegexpGroup('return', 'break', 'continue', 'throw')
|
||||
\ . '\>'
|
||||
|
|
@ -68,37 +73,55 @@ let s:outdent_after = '^'
|
|||
let s:dont_outdent_after = '\<' . s:RegexpGroup('if', 'unless') . '\>'
|
||||
|
||||
" Check for a single-line statement (e.g., 'if a then b'), which doesn't need an
|
||||
" indent afterwards
|
||||
" indent afterwards.
|
||||
function! s:IsSingleLineStatement(line)
|
||||
" The 'then' keyword is usually a good hint
|
||||
" The 'then' keyword is usually a good hint.
|
||||
return a:line =~ '\<then\>'
|
||||
endfunction
|
||||
|
||||
" Check for a single-line 'else' statement (e.g., 'else return a' but
|
||||
" not 'else if a'), which doesn't need an indent afterwards
|
||||
" not 'else if a'), which doesn't need an indent afterwards.
|
||||
function! s:IsSingleLineElse(line)
|
||||
" Check if the line actually starts with 'else', then if the line contains
|
||||
" anything other than 'else', then finally if the line is actually an 'else'
|
||||
" statement rather than an 'else if' statement
|
||||
return a:line =~ '^else\>' && a:line !~ '^else$' && a:line !~ '^else if\>'
|
||||
" statement rather than an 'else if' or 'else unless' statement.
|
||||
return a:line =~ '^else\>'
|
||||
\ && a:line !~ '^else$'
|
||||
\ && a:line !~ '^else if\>'
|
||||
\ && a:line !~ '^else unless\>'
|
||||
endfunction
|
||||
|
||||
" Check if a 'when' statement is the first in a 'switch' block by searching the
|
||||
" Check if a 'when' statement is the first in a switch block by searching the
|
||||
" previous line for the 'switch' keyword. The first 'when' shouldn't be
|
||||
" outdented
|
||||
" outdented.
|
||||
function! s:IsFirstWhen(curline, prevline)
|
||||
return a:curline =~ '^when\>' && a:prevline =~ '\<switch\>'
|
||||
endfunction
|
||||
|
||||
" Check for a multi-line assignment like
|
||||
" a: if b
|
||||
" c
|
||||
" else
|
||||
" d
|
||||
" a = if b
|
||||
" c
|
||||
" else
|
||||
" d
|
||||
function! s:IsMultiLineAssignment(line)
|
||||
return a:line =~ s:assignment_keywords
|
||||
endfunction
|
||||
|
||||
" Check if a line is a comment.
|
||||
function! s:IsComment(line)
|
||||
return a:line =~ '^#'
|
||||
endfunction
|
||||
|
||||
" Check if a line is a dot-access.
|
||||
function! s:IsDotAccess(line)
|
||||
return a:line =~ '^\.'
|
||||
endfunction
|
||||
|
||||
" Check if a line is a continuation.
|
||||
function! s:IsContinuation(line)
|
||||
return a:line =~ s:continuations
|
||||
endfunction
|
||||
|
||||
function! s:ShouldOutdent(curline, prevline)
|
||||
return !s:IsSingleLineStatement(a:prevline)
|
||||
\ && !s:IsFirstWhen(a:curline, a:prevline)
|
||||
|
|
@ -106,11 +129,21 @@ function! s:ShouldOutdent(curline, prevline)
|
|||
\ && a:curline =~ s:outdent
|
||||
endfunction
|
||||
|
||||
function! s:ShouldIndentAfter(prevline)
|
||||
function! s:ShouldIndent(curline, prevline)
|
||||
return !s:IsDotAccess(a:prevline) && s:IsDotAccess(a:curline)
|
||||
endfunction
|
||||
|
||||
function! s:ShouldIndentAfter(prevline, prevprevline)
|
||||
return !s:IsSingleLineStatement(a:prevline)
|
||||
\ && !s:IsSingleLineElse(a:prevline)
|
||||
\ && !s:IsComment(a:prevline)
|
||||
\
|
||||
\ && (a:prevline =~ s:indent_after
|
||||
\ || s:IsMultiLineAssignment(a:prevline))
|
||||
\ || s:IsMultiLineAssignment(a:prevline)
|
||||
\
|
||||
\ || (s:IsContinuation(a:prevline)
|
||||
\ && !s:IsContinuation(a:prevprevline)
|
||||
\ && a:prevprevline !~ s:indent_after_literals))
|
||||
endfunction
|
||||
|
||||
function! s:ShouldOutdentAfter(prevline)
|
||||
|
|
@ -119,21 +152,36 @@ function! s:ShouldOutdentAfter(prevline)
|
|||
\ && a:prevline =~ s:outdent_after
|
||||
endfunction
|
||||
|
||||
function! GetCoffeeIndent(curlinenum)
|
||||
" Find a non-blank line above the current line
|
||||
let prevlinenum = prevnonblank(a:curlinenum - 1)
|
||||
" Get the nearest previous non-blank line.
|
||||
function! s:GetPrevLineNum(linenum)
|
||||
return prevnonblank(a:linenum - 1)
|
||||
endfunction
|
||||
|
||||
" No indenting is needed at the start of a file
|
||||
" Get the contents of a line without leading whitespace.
|
||||
function! s:GetTrimmedLine(linenum, indent)
|
||||
return substitute(getline(a:linenum)[a:indent : -1], '\s\+$', '', '')
|
||||
endfunction
|
||||
|
||||
function! GetCoffeeIndent(curlinenum)
|
||||
let prevlinenum = s:GetPrevLineNum(a:curlinenum)
|
||||
let prevprevlinenum = s:GetPrevLineNum(prevlinenum)
|
||||
|
||||
" No indenting is needed at the start of a file.
|
||||
if prevlinenum == 0
|
||||
return 0
|
||||
endif
|
||||
|
||||
let curindent = indent(a:curlinenum)
|
||||
let previndent = indent(prevlinenum)
|
||||
let prevprevindent = indent(prevprevlinenum)
|
||||
|
||||
" Strip off leading whitespace
|
||||
let curline = getline(a:curlinenum)[curindent : -1]
|
||||
let prevline = getline(prevlinenum)[previndent : -1]
|
||||
let curline = s:GetTrimmedLine(a:curlinenum, curindent)
|
||||
let prevline = s:GetTrimmedLine(prevlinenum, previndent)
|
||||
let prevprevline = s:GetTrimmedLine(prevprevlinenum, prevprevindent)
|
||||
|
||||
if s:ShouldIndent(curline, prevline)
|
||||
return previndent + &shiftwidth
|
||||
endif
|
||||
|
||||
if s:ShouldOutdent(curline, prevline)
|
||||
" Is the line already outdented?
|
||||
|
|
@ -144,7 +192,7 @@ function! GetCoffeeIndent(curlinenum)
|
|||
endif
|
||||
endif
|
||||
|
||||
if s:ShouldIndentAfter(prevline)
|
||||
if s:ShouldIndentAfter(prevline, prevprevline)
|
||||
return previndent + &shiftwidth
|
||||
endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
This project adds [CoffeeScript] support to the vim editor. Currently, it
|
||||
supports [almost][todo] all of CoffeeScript 0.9.2's syntax and indentation style.
|
||||
supports [almost][todo] all of CoffeeScript's syntax and indentation style.
|
||||
|
||||
![Screenshot][screenshot]
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ supports [almost][todo] all of CoffeeScript 0.9.2's syntax and indentation style
|
|||
> so you actually need to "filetype off" before "filetype plugin indent on"
|
||||
> to force reloading.
|
||||
|
||||
[pathogen]: http://vim.org/scripts/script.php?script_id=2332
|
||||
[pathogen]: http://www.vim.org/scripts/script.php?script_id=2332
|
||||
|
||||
2. Create, and change into, the `~/.vim/bundle/` directory:
|
||||
|
||||
|
|
@ -50,12 +50,19 @@ extension or a `Cakefile` will load all the CoffeeScript stuff.
|
|||
|
||||
$ git pull
|
||||
|
||||
Everything will then be brought up to date!
|
||||
Everything will then be brought up to date.
|
||||
|
||||
### Customizing
|
||||
|
||||
Some of the possibly unwanted syntax highlighting elements can be disabled
|
||||
in the following ways.
|
||||
#### Compile the current file on write/save
|
||||
|
||||
If you are using the NodeJS version of CofeeScript, with the `coffee` command
|
||||
in your `$PATH`, you can enable auto-compiling on file write/save like so:
|
||||
|
||||
let coffee_compile_on_save = 1
|
||||
|
||||
This will compile the CoffeeScript to JavaScript. For example,
|
||||
`/Users/brian/ZOMG.coffee` will compile to `/Users/brian/ZOMG.js`.
|
||||
|
||||
#### Disable trailing whitespace error highlighting
|
||||
|
||||
|
|
|
|||
|
|
@ -13,11 +13,15 @@ endif
|
|||
|
||||
let b:current_syntax = "coffee"
|
||||
|
||||
" Highlight long strings.
|
||||
syntax sync minlines=100
|
||||
|
||||
" CoffeeScript allows dollar signs in identifiers
|
||||
" CoffeeScript allows dollar signs in identifiers.
|
||||
setlocal isident+=$
|
||||
|
||||
" These are 'matches' rather than 'keywords' because vim's highlighting priority
|
||||
" for keywords (the highest) causes them to be wrongly highlighted when used as
|
||||
" dot-properties.
|
||||
syntax match coffeeStatement /\<\%(return\|break\|continue\|throw\)\>/
|
||||
highlight default link coffeeStatement Statement
|
||||
|
||||
|
|
@ -33,7 +37,7 @@ highlight default link coffeeException Exception
|
|||
syntax match coffeeOperator /\<\%(instanceof\|typeof\|delete\)\>/
|
||||
highlight default link coffeeOperator Operator
|
||||
|
||||
syntax match coffeeKeyword /\<\%(new\|in\|of\|by\|where\|and\|or\|not\|is\|isnt\|class\|extends\|super\|all\)\>/
|
||||
syntax match coffeeKeyword /\<\%(new\|in\|of\|by\|and\|or\|not\|is\|isnt\|class\|extends\|super\|own\|do\)\>/
|
||||
highlight default link coffeeKeyword Keyword
|
||||
|
||||
syntax match coffeeBoolean /\<\%(\%(true\|on\|yes\|false\|off\|no\)\)\>/
|
||||
|
|
@ -42,50 +46,74 @@ highlight default link coffeeBoolean Boolean
|
|||
syntax match coffeeGlobal /\<\%(null\|undefined\)\>/
|
||||
highlight default link coffeeGlobal Type
|
||||
|
||||
" Keywords reserved by the language
|
||||
syntax cluster coffeeReserved contains=coffeeStatement,coffeeRepeat,
|
||||
\ coffeeConditional,coffeeException,
|
||||
\ coffeeOperator,coffeeKeyword,
|
||||
\ coffeeBoolean,coffeeGlobal
|
||||
|
||||
syntax match coffeeAssignmentMod /\%(\s\+\zs\%(and\|or\)\|\W\{,3}\)\ze=/ contained
|
||||
highlight default link coffeeAssignmentMod SpecialChar
|
||||
|
||||
syntax match coffeeAssignmentChar /:\|=/ contained
|
||||
highlight default link coffeeAssignmentChar SpecialChar
|
||||
|
||||
syntax match coffeeVar /\<\%(this\|prototype\|arguments\)\>/
|
||||
" Matches @-variables like @abc
|
||||
" Matches @-variables like @abc.
|
||||
syntax match coffeeVar /@\%(\I\i*\)\?/
|
||||
highlight default link coffeeVar Type
|
||||
|
||||
" Matches class-like names that start with a capital letter, like Array or
|
||||
" Object
|
||||
" Object.
|
||||
syntax match coffeeObject /\<\u\w*\>/
|
||||
highlight default link coffeeObject Structure
|
||||
|
||||
" Matches constant-like names in SCREAMING_CAPS
|
||||
" Matches constant-like names in SCREAMING_CAPS.
|
||||
syntax match coffeeConstant /\<\u[A-Z0-9_]\+\>/
|
||||
highlight default link coffeeConstant Constant
|
||||
|
||||
syntax match coffeePrototype /::/
|
||||
highlight default link coffeePrototype SpecialChar
|
||||
|
||||
syntax region coffeeString start=/"/ skip=/\\\\\|\\"/ end=/"/ contains=@coffeeInterpString
|
||||
syntax region coffeeString start=/'/ skip=/\\\\\|\\'/ end=/'/ contains=@coffeeSimpleString
|
||||
highlight default link coffeeString String
|
||||
|
||||
" What can make up a variable name
|
||||
syntax cluster coffeeIdentifier contains=coffeeVar,coffeeObject,coffeeConstant,
|
||||
\ coffeePrototype
|
||||
|
||||
syntax match coffeeAssignment /@\?\I\%(\i\|::\|\.\|\[.\+\]\|([^)]*)\)*\s*\%(::\@!\|\%(and\|or\|\|&&\|||\|?\|+\|-\|\/\|\*\|%\|<<\|>>\|>>>\|&\||\|\^\)==\@!>\@!\)/
|
||||
\ contains=@coffeeIdentifier,coffeeAssignmentMod,
|
||||
\ coffeeAssignmentChar,coffeeBrackets,
|
||||
\ coffeeParens
|
||||
syntax match coffeeAssignment /\%("\|'\)[^'"]\+\%("\|'\)\s*:/ contains=coffeeString,
|
||||
\ coffeeAssignmentChar
|
||||
syntax match coffeeAssignment /\d*\%(\.\d\+\)\?\s*:/ contains=coffeeNumber,coffeeAssignmentChar
|
||||
highlight default link coffeeAssignment Identifier
|
||||
syntax region coffeeString start=/"/ skip=/\\\\\|\\"/ end=/"/ contains=@coffeeInterpString
|
||||
syntax region coffeeString start=/'/ skip=/\\\\\|\\'/ end=/'/ contains=@coffeeSimpleString
|
||||
highlight default link coffeeString String
|
||||
|
||||
syntax region coffeeAssignString start=/"/ skip=/\\\\\|\\"/ end=/"/ contained contains=@coffeeSimpleString
|
||||
syntax region coffeeAssignString start=/'/ skip=/\\\\\|\\'/ end=/'/ contained contains=@coffeeSimpleString
|
||||
highlight default link coffeeAssignString String
|
||||
|
||||
" Matches numbers like -10, -10e8, -10E8, 10, 10e8, 10E8.
|
||||
syntax match coffeeNumber /\i\@<![-+]\?\d\+\%([eE][+-]\?\d\+\)\?/
|
||||
" Matches hex numbers like 0xfff, 0x000.
|
||||
syntax match coffeeNumber /\<0[xX]\x\+\>/
|
||||
highlight default link coffeeNumber Number
|
||||
|
||||
" Matches floating-point numbers like -10.42e8, 10.42e-8.
|
||||
syntax match coffeeFloat /\i\@<![-+]\?\d*\.\@<!\.\d\+\%([eE][+-]\?\d\+\)\?/
|
||||
highlight default link coffeeFloat Float
|
||||
|
||||
syntax match coffeeAssignSymbols /:\@<!::\@!\|++\|--\|\%(\%(\s\zs\%(and\|or\)\)\|&&\|||\|?\|+\|-\|\/\|\*\|%\|<<\|>>\|>>>\|&\||\|\^\)\?=\@<!==\@!>\@!/ contained
|
||||
highlight default link coffeeAssignSymbols SpecialChar
|
||||
|
||||
syntax match coffeeAssignBrackets /\[.\+\]/ contained contains=TOP,coffeeAssign
|
||||
|
||||
syntax match coffeeAssign /\%(++\|--\)\s*\%(@\|@\?\I\)\%(\i\|::\|\.\|?\|\[.\+\]\)*/
|
||||
\ contains=@coffeeIdentifier,coffeeAssignSymbols,coffeeAssignBrackets
|
||||
syntax match coffeeAssign /\%(@\|@\?\I\)\%(\i\|::\|\.\|?\|\[.\+\]\)*\%(++\|--\|\s*\%(and\|or\|&&\|||\|?\|+\|-\|\/\|\*\|%\|<<\|>>\|>>>\|&\||\|\^\)\?=\@<!==\@!>\@!\)/
|
||||
\ contains=@coffeeIdentifier,coffeeAssignSymbols,coffeeAssignBrackets
|
||||
|
||||
" Displays an error for reserved words.
|
||||
if !exists("coffee_no_reserved_words_error")
|
||||
syntax match coffeeReservedError /\<\%(case\|default\|function\|var\|void\|with\|const\|let\|enum\|export\|import\|native\|__hasProp\|__extends\|__slice\|__bind\|__indexOf\)\>/
|
||||
highlight default link coffeeReservedError Error
|
||||
endif
|
||||
|
||||
syntax match coffeeAssign /@\?\I\i*\s*:\@<!::\@!/ contains=@coffeeIdentifier,coffeeAssignSymbols
|
||||
" Matches string assignments in object literals like {'a': 'b'}.
|
||||
syntax match coffeeAssign /\("\|'\)[^'"]\+\1\s*;\@<!::\@!/ contains=coffeeAssignString,
|
||||
\ coffeeAssignSymbols
|
||||
" Matches number assignments in object literals like {42: 'a'}.
|
||||
syntax match coffeeAssign /\d\+\%(\.\d\+\)\?\s*:\@<!::\@!/ contains=coffeeNumber,coffeeAssignSymbols
|
||||
highlight default link coffeeAssign Identifier
|
||||
|
||||
syntax match coffeePrototype /::/
|
||||
highlight default link coffeePrototype SpecialChar
|
||||
|
||||
syntax match coffeeFunction /->\|=>/
|
||||
highlight default link coffeeFunction Function
|
||||
|
|
@ -97,65 +125,51 @@ syntax match coffeeComment /#.*/ contains=@Spell,coffeeTodo
|
|||
syntax match coffeeComment /####\@!\_.\{-}###/ contains=@Spell,coffeeTodo
|
||||
highlight default link coffeeComment Comment
|
||||
|
||||
syntax region coffeeEmbed start=/`/ end=/`/
|
||||
syntax region coffeeHereComment start=/#/ end=/\ze\/\/\// end=/$/ contained contains=@Spell,coffeeTodo
|
||||
highlight default link coffeeHereComment coffeeComment
|
||||
|
||||
syntax region coffeeEmbed start=/`/ skip=/\\\\\|\\`/ end=/`/
|
||||
highlight default link coffeeEmbed Special
|
||||
|
||||
" Matches numbers like -10, -10e8, -10E8, 10, 10e8, 10E8
|
||||
syntax match coffeeNumber /\<-\?\d\+\%([eE][+-]\?\d\+\)\?\>/
|
||||
" Matches hex numbers like 0xfff, 0x000
|
||||
syntax match coffeeNumber /\<0[xX]\x\+\>/
|
||||
highlight default link coffeeNumber Number
|
||||
|
||||
" Matches floating-point numbers like -10.42e8, 10.42e-8
|
||||
syntax match coffeeFloat /-\?\d*\.\@<!\.\d\+\%([eE][+-]\?\d\+\)\?/
|
||||
highlight default link coffeeFloat Float
|
||||
|
||||
syntax region coffeeInterpolation matchgroup=coffeeInterpDelim
|
||||
\ start=/\#{/ end=/}/
|
||||
\ contained contains=TOP
|
||||
highlight default link coffeeInterpDelim Delimiter
|
||||
|
||||
" Matches escape sequences like \000, \x00, \u0000, \n.
|
||||
syntax match coffeeEscape /\\\d\d\d\|\\x\x\{2\}\|\\u\x\{4\}\|\\./ contained
|
||||
highlight default link coffeeEscape SpecialChar
|
||||
|
||||
" What is in a non-interpolated string
|
||||
syntax cluster coffeeSimpleString contains=@Spell,coffeeEscape
|
||||
" What is in an interpolated string
|
||||
syntax cluster coffeeInterpString contains=@coffeeSimpleString,
|
||||
\ coffeeInterpolation
|
||||
|
||||
syntax region coffeeRegExp start=/)\@<!\%(\%((\s*\|=\s\+\)\@<=\/\|\s\zs\/\s\@!\)/
|
||||
\ end=/\/[gimy]\{,4}/ oneline
|
||||
\ contains=@coffeeInterpString
|
||||
\ skip=/\[.*\/.*\]/ end=/\/[gimy]\{,4}/ oneline
|
||||
\ contains=@coffeeSimpleString
|
||||
syntax region coffeeHereRegexp start=/\/\/\// end=/\/\/\/[gimy]\{,4}/ contains=@coffeeInterpString,coffeeHereComment fold
|
||||
highlight default link coffeeHereRegexp coffeeRegExp
|
||||
highlight default link coffeeRegExp String
|
||||
|
||||
syntax region coffeeHeredoc start=/"""/ end=/"""/ contains=@coffeeInterpString
|
||||
syntax region coffeeHeredoc start=/'''/ end=/'''/ contains=@coffeeSimpleString
|
||||
syntax region coffeeHeredoc start=/"""/ end=/"""/ contains=@coffeeInterpString fold
|
||||
syntax region coffeeHeredoc start=/'''/ end=/'''/ contains=@coffeeSimpleString fold
|
||||
highlight default link coffeeHeredoc String
|
||||
|
||||
syntax region coffeeCurlies start=/{/ end=/}/ contains=TOP
|
||||
syntax region coffeeBrackets start=/\[/ end=/\]/ contains=TOP,coffeeAssignment
|
||||
syntax match coffeeParens /(.*)/ contains=TOP,coffeeAssignment
|
||||
|
||||
" Displays an error for trailing whitespace
|
||||
" Displays an error for trailing whitespace.
|
||||
if !exists("coffee_no_trailing_space_error")
|
||||
syntax match coffeeSpaceError /\s\+$/ display
|
||||
syntax match coffeeSpaceError /\S\@<=\s\+$/ display
|
||||
highlight default link coffeeSpaceError Error
|
||||
endif
|
||||
|
||||
" Displays an error for trailing semicolons
|
||||
" Displays an error for trailing semicolons.
|
||||
if !exists("coffee_no_trailing_semicolon_error")
|
||||
syntax match coffeeSemicolonError /;$/ display
|
||||
highlight default link coffeeSemicolonError Error
|
||||
endif
|
||||
|
||||
" Displays an error for reserved words
|
||||
if !exists("coffee_no_reserved_words_error")
|
||||
syntax keyword coffeeReservedError case default do function var void with const
|
||||
\ let enum export import native __hasProp
|
||||
\ __extends __slice
|
||||
highlight default link coffeeReservedError Error
|
||||
endif
|
||||
|
||||
" Reserved words can be used as dot-properties
|
||||
" Reserved words can be used as dot-properties.
|
||||
syntax match coffeeDot /\.\@<!\.\i\+/ transparent
|
||||
\ contains=ALLBUT,@coffeeReserved,
|
||||
\ coffeeReservedError
|
||||
|
|
|
|||
62
.vim/bundle/vim-coffee-script/syntax/eco.vim
Normal file
62
.vim/bundle/vim-coffee-script/syntax/eco.vim
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
" Vim syntax file
|
||||
" Language: eco
|
||||
" Maintainer: Jay Adkisson
|
||||
" Mostly stolen from eruby.vim
|
||||
|
||||
if !exists("g:eco_default_subtype")
|
||||
let g:eco_default_subtype = "html"
|
||||
endif
|
||||
|
||||
if !exists("b:eco_subtype")
|
||||
let s:lines = getline(1)."\n".getline(2)."\n".getline(3)."\n".getline(4)."\n".getline(5)."\n".getline("$")
|
||||
let b:eco_subtype = matchstr(s:lines,'eco_subtype=\zs\w\+')
|
||||
if b:eco_subtype == ''
|
||||
let b:eco_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.erb\|\.eco\)\+$','',''),'\.\zs\w\+$')
|
||||
endif
|
||||
if b:eco_subtype == 'rhtml'
|
||||
let b:eco_subtype = 'html'
|
||||
elseif b:eco_subtype == 'rb'
|
||||
let b:eco_subtype = 'ruby'
|
||||
elseif b:eco_subtype == 'yml'
|
||||
let b:eco_subtype = 'yaml'
|
||||
elseif b:eco_subtype == 'js'
|
||||
let b:eco_subtype = 'javascript'
|
||||
elseif b:eco_subtype == 'txt'
|
||||
" Conventional; not a real file type
|
||||
let b:eco_subtype = 'text'
|
||||
elseif b:eco_subtype == ''
|
||||
if b:current_syntax == ''
|
||||
let b:eco_subtype = g:eco_default_subtype
|
||||
else
|
||||
let b:eco_subtype = b:current_syntax
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
if exists("b:eruby_subtype") && b:eruby_subtype != ''
|
||||
exec "runtime! syntax/".b:eruby_subtype.".vim"
|
||||
let b:current_syntax = "eco"
|
||||
endif
|
||||
|
||||
syn include @coffeeTop syntax/coffee.vim
|
||||
|
||||
syn cluster ecoRegions contains=ecoBlock,ecoExpression,ecoComment
|
||||
|
||||
syn region ecoBlock matchgroup=ecoDelimiter start=/<%/ end=/%>/ contains=@coffeeTop containedin=ALLBUT,@ecoRegions keepend
|
||||
syn region ecoExpression matchgroup=ecoDelimiter start=/<%[=\-]/ end=/%>/ contains=@coffeeTop containedin=ALLBUT,@ecoRegions keepend
|
||||
syn region ecoComment matchgroup=ecoComment start=/<%#/ end=/%>/ contains=@coffeeTodo,@Spell containedin=ALLBUT,@ecoRegions keepend
|
||||
|
||||
" eco features not in coffeescript proper
|
||||
syn keyword ecoEnd end containedin=@ecoRegions
|
||||
syn match ecoIndentColon /\s+\w+:/ containedin=@ecoRegions
|
||||
|
||||
" Define the default highlighting.
|
||||
|
||||
hi def link ecoDelimiter Delimiter
|
||||
hi def link ecoComment Comment
|
||||
hi def link ecoEnd coffeeConditional
|
||||
hi def link ecoIndentColon None
|
||||
|
||||
let b:current_syntax = 'eco'
|
||||
|
||||
" vim: nowrap sw=2 sts=2 ts=8:
|
||||
22
.vim/bundle/vim-coffee-script/thanks.md
Normal file
22
.vim/bundle/vim-coffee-script/thanks.md
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
Thanks to the following contributors:
|
||||
|
||||
Brian Egan (3):
|
||||
Adding compile functionality to the ftplugin. Must be enabled in .vimrc
|
||||
Updating the readme with compilation instructions
|
||||
Updating bad header in readme to make instructions easier to read
|
||||
|
||||
Chris Hoffman (3):
|
||||
Add new keywoards from, to, and do
|
||||
Highlight the - in negative integers
|
||||
Add here regex highlighting, increase fold level for here docs
|
||||
|
||||
Jay Adkisson:
|
||||
Support for eco templates
|
||||
|
||||
Karl Guertin (1):
|
||||
Cakefiles are coffeescript
|
||||
|
||||
Simon Lipp (1):
|
||||
Trailing spaces are not error on lines containing only spaces
|
||||
|
||||
And thanks to anyone who files or has filed a bug report.
|
||||
|
|
@ -6,14 +6,6 @@
|
|||
{a, b} = c
|
||||
└──┴─ these should be highlighted as identifiers
|
||||
|
||||
- Assignments inside brackets (sounds simple enough):
|
||||
|
||||
a[b -= c] = d
|
||||
|
||||
this should still be highlighted correctly:
|
||||
|
||||
a[b[c]] = d
|
||||
|
||||
- Smart, lookback outdenting for cases like:
|
||||
|
||||
a = {
|
||||
|
|
@ -22,14 +14,13 @@
|
|||
}
|
||||
└─ bracket should be put here
|
||||
|
||||
- Should indent if the previous line ends, or the current line starts, with one
|
||||
of these:
|
||||
- Fix assignments with brackets in these cases:
|
||||
|
||||
+ - * / % | & , . is isnt and or && ||
|
||||
a[b] = c[d]
|
||||
a[b -= c] = d
|
||||
|
||||
- Support `else unless` in indentation:
|
||||
and still highlight these correctly:
|
||||
|
||||
unless a
|
||||
b
|
||||
else unless c
|
||||
d
|
||||
a[b] = c
|
||||
a[b[c]] = d
|
||||
a[b[c] -= d] = e
|
||||
|
|
|
|||
1
.vim/bundle/vim-fugitive/.gitignore
vendored
Normal file
1
.vim/bundle/vim-fugitive/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
/doc/tags
|
||||
70
.vim/bundle/vim-fugitive/README.markdown
Normal file
70
.vim/bundle/vim-fugitive/README.markdown
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
fugitive.vim
|
||||
============
|
||||
|
||||
I'm not going to lie to you; fugitive.vim may very well be the best
|
||||
Git wrapper of all time. Check out these features:
|
||||
|
||||
View any blob, tree, commit, or tag in the repository with `:Gedit` (and
|
||||
`:Gsplit`, `:Gvsplit`, `:Gtabedit`, ...). Edit a file in the index and
|
||||
write to it to stage the changes. Use `:Gdiff` to bring up the staged
|
||||
version of the file side by side with the working tree version and use
|
||||
Vim's diff handling capabilities to stage a subset of the file's
|
||||
changes.
|
||||
|
||||
Bring up the output of `git status` with `:Gstatus`. Press `-` to
|
||||
`add`/`reset` a file's changes, or `p` to `add`/`reset` `--patch` that
|
||||
mofo. And guess what `:Gcommit` does!
|
||||
|
||||
`:Gblame` brings up an interactive vertical split with `git blame`
|
||||
output. Press enter on a line to reblame the file as it stood in that
|
||||
commit, or `o` to open that commit in a split. When you're done, use
|
||||
`:Gedit` in the historic buffer to go back to the work tree version.
|
||||
|
||||
`:Gmove` does a `git mv` on a file and simultaneously renames the
|
||||
buffer. `:Gremove` does a `git rm` on a file and simultaneously deletes
|
||||
the buffer.
|
||||
|
||||
Use `:Ggrep` to search the work tree (or any arbitrary commit) with
|
||||
`git grep`, skipping over that which is not tracked in the repository.
|
||||
`:Glog` loads all previous revisions of a file into the quickfix list so
|
||||
you can iterate over them and watch the file evolve!
|
||||
|
||||
`:Gread` is a variant of `git checkout -- filename` that operates on the
|
||||
buffer rather than the filename. This means you can use `u` to undo it
|
||||
and you never get any warnings about the file changing outside Vim.
|
||||
`:Gwrite` writes to both the work tree and index versions of a file,
|
||||
making it like `git add` when called from a work tree file and like
|
||||
`git checkout` when called from the index or a blob in history.
|
||||
|
||||
Use `:Gbrowse` to open the current file on GitHub, with optional line
|
||||
range (try it in visual mode!). If your current repository isn't on
|
||||
GitHub, `git instaweb` will be spun up instead.
|
||||
|
||||
Add `%{fugitive#statusline()}` to `'statusline'` to get an indicator
|
||||
with the current branch in (surprise!) your statusline.
|
||||
|
||||
Oh, and of course there's `:Git` for running any arbitrary command.
|
||||
|
||||
Like fugitive.vim? Follow the repository on
|
||||
[GitHub](http://github.com/tpope/vim-fugitive) and vote for it on
|
||||
[vim.org](http://www.vim.org/scripts/script.php?script_id=2975).
|
||||
|
||||
FAQ
|
||||
---
|
||||
|
||||
> I installed the plugin and started Vim. Why don't any of the commands
|
||||
> exist?
|
||||
|
||||
Fugitive cares about the current file, not the current working
|
||||
directory. Edit a file from the repository.
|
||||
|
||||
> I opened a new tab. Why don't any of the commands exist?
|
||||
|
||||
Fugitive cares about the current file, not the current working
|
||||
directory. Edit a file from the repository.
|
||||
|
||||
> I changed the current working directory. Why do all the commands use
|
||||
> the old directory?
|
||||
|
||||
Fugitive cares about the current file, not the current working
|
||||
directory. Edit a file from the repository.
|
||||
255
.vim/bundle/vim-fugitive/doc/fugitive.txt
Normal file
255
.vim/bundle/vim-fugitive/doc/fugitive.txt
Normal file
|
|
@ -0,0 +1,255 @@
|
|||
*fugitive.txt* A Git wrapper so awesome, it should be illegal
|
||||
|
||||
Author: Tim Pope <vimNOSPAM@tpope.org> *fugitive-author*
|
||||
License: Same terms as Vim itself (see |license|)
|
||||
|
||||
This plugin is only available if 'compatible' is not set.
|
||||
|
||||
INTRODUCTION *fugitive*
|
||||
|
||||
Install in ~/.vim, or in ~\vimfiles if you're on Windows and feeling lucky.
|
||||
Vim 7.2 is recommended as it ships with syntax highlighting for many Git file
|
||||
types.
|
||||
|
||||
If you're in a hurry to get started, here are some things to try:
|
||||
|
||||
In any file in your repository, run |:Gedit| HEAD. Press <CR> to jump to the
|
||||
current branch. Press <CR> again to jump to the top most commit. Keep using
|
||||
<CR> to explore parent commits, trees, and blobs. Use C in a tree or blob to
|
||||
get back to the commit.
|
||||
|
||||
Edit a file in the work tree and make some changes. Use |:Gdiff| to open up
|
||||
the indexed version. Use |do| and |dp| on various hunks to bring the files in
|
||||
sync, or use |:Gread| to pull in all changes. Write the indexed version to
|
||||
stage the file.
|
||||
|
||||
Run |:Gstatus| to check your repository's status. Use "-" to stage and reset
|
||||
files and "p" to add/reset --patch them. Invoke |:Gcommit| to commit your
|
||||
changes.
|
||||
|
||||
Run |:Gblame| in a work tree file to see a blame in a vertical split. Press
|
||||
<CR> on any line to reopen and reblame that file as it stood in that commit.
|
||||
Press o or O on any line to inspect that commit in a split or a tab.
|
||||
|
||||
Run |:Ggrep| to search the work tree or history. Run |:Gmove| to rename a
|
||||
file. Run |:Gremove| to delete a file.
|
||||
|
||||
COMMANDS *fugitive-commands*
|
||||
|
||||
These commands are local to the buffers in which they work (generally, buffers
|
||||
that are part of Git repositories).
|
||||
|
||||
*fugitive-:Git*
|
||||
:Git [args] Run an arbitrary git command. Similar to :!git [args]
|
||||
but chdir to the repository tree first.
|
||||
|
||||
*fugitive-:Gcd*
|
||||
:Gcd [directory] |:cd| relative to the repository.
|
||||
|
||||
*fugitive-:Glcd*
|
||||
:Glcd [directory] |:lcd| relative to the repository.
|
||||
|
||||
*fugitive-:Gstatus*
|
||||
:Gstatus Bring up the output of git-status in the preview
|
||||
window. In addition to standard motions, you can
|
||||
use <C-N> and <C-P> to jump from filename to
|
||||
filename. Press D to |:Gdiff| the file on the cursor
|
||||
line, or ds to |:Gsdiff|. Press - to stage or unstage
|
||||
the file on the cursor line. Press p to do so on a
|
||||
per hunk basis (--patch). Press C to invoke
|
||||
|:Gcommit|.
|
||||
|
||||
*fugitive-:Gcommit*
|
||||
:Gcommit [args] A wrapper around git-commit. If there is nothing
|
||||
to commit, |:Gstatus| is called instead. Unless the
|
||||
arguments given would skip the invocation of an editor
|
||||
(e.g., -m), a split window will be used to obtain a
|
||||
commit message. Write and close that window (:wq or
|
||||
|:Gwrite|) to finish the commit. Unlike when running
|
||||
the actual git-commit command, it is possible (but
|
||||
unadvisable) to muck with the index with commands like
|
||||
git-add and git-reset while a commit message is
|
||||
pending.
|
||||
|
||||
*fugitive-:Ggrep*
|
||||
:Ggrep [args] |:grep| with git-grep as 'grepprg'.
|
||||
|
||||
*fugitive-:Glog*
|
||||
:Glog [args] Load all previous revisions of the current file into
|
||||
the quickfix list. Additional git-log arguments can
|
||||
be given (for example, --reverse). If "--" appears as
|
||||
an argument, no file specific filtering is done, and
|
||||
commits are loaded into the quickfix list.
|
||||
|
||||
*fugitive-:Gedit* *fugitive-:Ge*
|
||||
:Gedit [revision] |:edit| a |fugitive-revision|.
|
||||
|
||||
*fugitive-:Gsplit*
|
||||
:Gsplit [revision] |:split| a |fugitive-revision|.
|
||||
|
||||
*fugitive-:Gvsplit*
|
||||
:Gvsplit [revision] |:vsplit| a |fugitive-revision|.
|
||||
|
||||
*fugitive-:Gtabedit*
|
||||
:Gtabedit [revision] |:tabedit| a |fugitive-revision|
|
||||
|
||||
*fugitive-:Gpedit*
|
||||
:Gpedit [revision] |:pedit| a |fugitive-revision|
|
||||
|
||||
*fugitive-:Gread*
|
||||
:Gread [revision] Empty the buffer and |:read| a |fugitive-revision|.
|
||||
When the argument is omitted, this is similar to
|
||||
git-checkout on a work tree file or git-add on a stage
|
||||
file, but without writing anything to disk.
|
||||
|
||||
:{range}Gread [revision]
|
||||
|:read| in a |fugitive-revision| after {range}.
|
||||
|
||||
*fugitive-:Gwrite*
|
||||
:Gwrite Write to the current file's path and stage the results.
|
||||
When run in a work tree file, it is effectively git
|
||||
add. Elsewhere, it is effectively git-checkout. A
|
||||
great deal of effort is expended to behave sensibly
|
||||
when the work tree or index version of the file is
|
||||
open in another buffer.
|
||||
|
||||
:Gwrite {path} You can give |:Gwrite| an explicit path of where in
|
||||
the work tree to write. You can also give a path like
|
||||
:0:foo.txt or even :0 to write to just that stage in
|
||||
the index.
|
||||
|
||||
*fugitive-:Gwq*
|
||||
:Gwq [path] Like |:Gwrite| followed by |:quit| if the write
|
||||
succeeded.
|
||||
|
||||
:Gwq! [path] Like |:Gwrite|! followed by |:quit|! if the write
|
||||
succeeded.
|
||||
|
||||
*fugitive-:Gdiff*
|
||||
:Gdiff [revision] Perform a |vimdiff| against the current file in the
|
||||
given revision. With no argument, the version in the
|
||||
index is used (which means a three-way diff during a
|
||||
merge conflict, making it a git-mergetool
|
||||
alternative). The newer of the two files is placed
|
||||
to the right. Use |do| and |dp| and write to the
|
||||
index file to simulate "git add --patch".
|
||||
|
||||
*fugitive-:Gsdiff*
|
||||
:Gsdiff [revision] Like |:Gdiff|, but split horizontally.
|
||||
|
||||
*fugitive-:Gvdiff*
|
||||
:Gvdiff [revision] Identical to |:Gdiff|. For symmetry with |:Gsdiff|.
|
||||
|
||||
*fugitive-:Gmove*
|
||||
:Gmove {destination} Wrapper around git-mv that renames the buffer
|
||||
afterward. The destination is relative to the current
|
||||
directory except when started with a /, in which case
|
||||
it is relative to the work tree. Add a ! to pass -f.
|
||||
|
||||
*fugitive-:Gremove*
|
||||
:Gremove Wrapper around git-rm that deletes the buffer
|
||||
afterward. When invoked in an index file, --cached is
|
||||
passed. Add a ! to pass -f and forcefully discard the
|
||||
buffer.
|
||||
|
||||
*fugitive-:Gblame*
|
||||
:Gblame [flags] Run git-blame on the file and open the results in a
|
||||
scroll bound vertical split. Press enter on a line to
|
||||
reblame the file as it was in that commit. You can
|
||||
give any of ltwfsMC as flags and they will be passed
|
||||
along to git-blame.
|
||||
|
||||
:[range]Gblame [flags] Run git-blame on the given range.
|
||||
|
||||
*fugitive-:Gbrowse*
|
||||
:[range]Gbrowse If the remote for the current branch is on GitHub,
|
||||
open the current file, blob, tree, commit, or tag
|
||||
(with git-web--browse) on GitHub. Otherwise, open the
|
||||
current file, blob, tree, commit, or tag in
|
||||
git-instaweb (if you have issues, verify you can run
|
||||
"git instaweb" from a terminal). If a range is given,
|
||||
it is appropriately appended to the URL as an anchor.
|
||||
|
||||
:[range]Gbrowse! Like :Gbrowse, but put the URL on the clipboard rather
|
||||
than opening it.
|
||||
|
||||
:[range]Gbrowse {revision}
|
||||
Like :Gbrowse, but for a given |fugitive-revision|. A
|
||||
useful value here is -, which ties the URL to the
|
||||
latest commit rather than a volatile branch.
|
||||
|
||||
:[range]Gbrowse [...]@{remote}
|
||||
Force using the given remote rather than the remote
|
||||
for the current branch. The remote is used to
|
||||
determine which GitHub repository to link to.
|
||||
|
||||
MAPPINGS *fugitive-mappings*
|
||||
|
||||
These maps are available in Git objects.
|
||||
|
||||
*fugitive-<CR>*
|
||||
<CR> Jump to the revision under the cursor.
|
||||
|
||||
*fugitive-o*
|
||||
o Jump to the revision under the cursor in a new split.
|
||||
|
||||
*fugitive-O*
|
||||
O Jump to the revision under the cursor in a new tab.
|
||||
|
||||
*fugitive-~*
|
||||
~ Go to the current file in the [count]th first
|
||||
ancestor.
|
||||
|
||||
*fugitive-P*
|
||||
P Go to the current file in the [count]th parent.
|
||||
|
||||
*fugitive-C*
|
||||
C Go to the commit containing the current file.
|
||||
|
||||
*fugitive-a*
|
||||
a Show the current tag, commit, or tree in an alternate
|
||||
format.
|
||||
|
||||
SPECIFYING REVISIONS *fugitive-revision*
|
||||
|
||||
Fugitive revisions are similar to Git revisions as defined in the "SPECIFYING
|
||||
REVISIONS" section in the git-rev-parse man page. For commands that accept an
|
||||
optional revision, the default is the file in the index for work tree files
|
||||
and the work tree file for everything else. Example revisions follow.
|
||||
|
||||
Revision Meaning ~
|
||||
HEAD .git/HEAD
|
||||
master .git/refs/heads/master
|
||||
HEAD^{} The commit referenced by HEAD
|
||||
HEAD^ The parent of the commit referenced by HEAD
|
||||
HEAD: The tree referenced by HEAD
|
||||
/HEAD The file named HEAD in the work tree
|
||||
Makefile The file named Makefile in the work tree
|
||||
HEAD^:Makefile The file named Makefile in the parent of HEAD
|
||||
:Makefile The file named Makefile in the index (writable)
|
||||
- The current file in HEAD
|
||||
^ The current file in the previous commit
|
||||
~3 The current file 3 commits ago
|
||||
: .git/index (Same as |:Gstatus|)
|
||||
:0 The current file in the index
|
||||
:1 The current file's common ancestor during a conflict
|
||||
:2 The current file in the target branch during a conflict
|
||||
:3 The current file in the merged branch during a conflict
|
||||
:/foo The most recent commit with "foo" in the message
|
||||
|
||||
STATUSLINE *fugitive-statusline*
|
||||
|
||||
*fugitive#statusline()*
|
||||
Add %{fugitive#statusline()} to your statusline to get an indicator including
|
||||
the current branch and the currently edited file's commit. If you don't have
|
||||
a statusline, this one matches the default when 'ruler' is set:
|
||||
>
|
||||
set statusline=%<%f\ %h%m%r%{fugitive#statusline()}%=%-14.(%l,%c%V%)\ %P
|
||||
<
|
||||
ABOUT *fugitive-about*
|
||||
|
||||
Grab the latest version or report a bug on GitHub:
|
||||
|
||||
http://github.com/tpope/vim-fugitive
|
||||
|
||||
vim:tw=78:et:ft=help:norl:
|
||||
2016
.vim/bundle/vim-fugitive/plugin/fugitive.vim
Normal file
2016
.vim/bundle/vim-fugitive/plugin/fugitive.vim
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -94,8 +94,6 @@ Mnenomic: encoding always comes before decoding; "[" always comes before "]".
|
|||
|
||||
TODO *unimpaired-todo*
|
||||
|
||||
Descend into and ascend from directories with |[o| and |]o|.
|
||||
|
||||
Avoid munging null characters when encoding and decoding.
|
||||
|
||||
vim:tw=78:et:ft=help:norl:
|
||||
|
|
|
|||
|
|
@ -34,9 +34,9 @@ function! s:entries(path)
|
|||
let path = substitute(a:path,'[\\/]$','','')
|
||||
let files = split(glob(path."/.*"),"\n")
|
||||
let files += split(glob(path."/*"),"\n")
|
||||
call filter(files,'v:val !=# "." && v:val !=# ".."')
|
||||
call filter(files,'v:val[-4:-1] !=# ".swp" && v:val[-1:-1] !=# "~"')
|
||||
call map(files,'substitute(v:val,"[\\/]$","","")')
|
||||
call filter(files,'v:val !~# "[\\\\/]\\.\\.\\=$"')
|
||||
call filter(files,'v:val[-4:-1] !=# ".swp" && v:val[-1:-1] !=# "~"')
|
||||
return files
|
||||
endfunction
|
||||
|
||||
|
|
@ -219,7 +219,7 @@ endfunction
|
|||
function! s:Transform(algorithm,type)
|
||||
let sel_save = &selection
|
||||
let cb_save = &clipboard
|
||||
set selection=inclusive clipboard-=unnamed
|
||||
set selection=inclusive clipboard-=unnamed clipboard-=unnamedplus
|
||||
let reg_save = @@
|
||||
if a:type =~ '^\d\+$'
|
||||
silent exe 'norm! ^v'.a:type.'$hy'
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -56,6 +56,20 @@
|
|||
:VCSUpdate vcscommand.txt /*:VCSUpdate*
|
||||
:VCSVimDiff vcscommand.txt /*:VCSVimDiff*
|
||||
ConqueTerm conque_term.txt /*ConqueTerm*
|
||||
ConqueTerm_CWInsert conque_term.txt /*ConqueTerm_CWInsert*
|
||||
ConqueTerm_CloseOnEnd conque_term.txt /*ConqueTerm_CloseOnEnd*
|
||||
ConqueTerm_Color conque_term.txt /*ConqueTerm_Color*
|
||||
ConqueTerm_EscKey conque_term.txt /*ConqueTerm_EscKey*
|
||||
ConqueTerm_InsertOnEnter conque_term.txt /*ConqueTerm_InsertOnEnter*
|
||||
ConqueTerm_PromptRegex conque_term.txt /*ConqueTerm_PromptRegex*
|
||||
ConqueTerm_PyExe conque_term.txt /*ConqueTerm_PyExe*
|
||||
ConqueTerm_PyVersion conque_term.txt /*ConqueTerm_PyVersion*
|
||||
ConqueTerm_ReadUnfocused conque_term.txt /*ConqueTerm_ReadUnfocused*
|
||||
ConqueTerm_SendFunctionKeys conque_term.txt /*ConqueTerm_SendFunctionKeys*
|
||||
ConqueTerm_SendVisKey conque_term.txt /*ConqueTerm_SendVisKey*
|
||||
ConqueTerm_Syntax conque_term.txt /*ConqueTerm_Syntax*
|
||||
ConqueTerm_TERM conque_term.txt /*ConqueTerm_TERM*
|
||||
ConqueTerm_ToggleKey conque_term.txt /*ConqueTerm_ToggleKey*
|
||||
ExtractSnips() snipMate.txt /*ExtractSnips()*
|
||||
ExtractSnipsFile() snipMate.txt /*ExtractSnipsFile()*
|
||||
Filename() snipMate.txt /*Filename()*
|
||||
|
|
@ -172,13 +186,29 @@ cocoa-license cocoa.txt /*cocoa-license*
|
|||
cocoa-mappings cocoa.txt /*cocoa-mappings*
|
||||
cocoa-suggested-plugins cocoa.txt /*cocoa-suggested-plugins*
|
||||
cocoa.txt cocoa.txt /*cocoa.txt*
|
||||
conque_term-bugs conque_term.txt /*conque_term-bugs*
|
||||
conque_term-changelog conque_term.txt /*conque_term-changelog*
|
||||
conque_term-contribute conque_term.txt /*conque_term-contribute*
|
||||
conque_term-requirements conque_term.txt /*conque_term-requirements*
|
||||
conque_term-settings conque_term.txt /*conque_term-settings*
|
||||
conque_term-todo conque_term.txt /*conque_term-todo*
|
||||
conque_term-usage conque_term.txt /*conque_term-usage*
|
||||
conque-term-Esc conque_term.txt /*conque-term-Esc*
|
||||
conque-term-F8 conque_term.txt /*conque-term-F8*
|
||||
conque-term-F9 conque_term.txt /*conque-term-F9*
|
||||
conque-term-api conque_term.txt /*conque-term-api*
|
||||
conque-term-bugs conque_term.txt /*conque-term-bugs*
|
||||
conque-term-close conque_term.txt /*conque-term-close*
|
||||
conque-term-contribute conque_term.txt /*conque-term-contribute*
|
||||
conque-term-feedback conque_term.txt /*conque-term-feedback*
|
||||
conque-term-get-instance conque_term.txt /*conque-term-get-instance*
|
||||
conque-term-installation conque_term.txt /*conque-term-installation*
|
||||
conque-term-installation-instructions conque_term.txt /*conque-term-installation-instructions*
|
||||
conque-term-misc conque_term.txt /*conque-term-misc*
|
||||
conque-term-open conque_term.txt /*conque-term-open*
|
||||
conque-term-options conque_term.txt /*conque-term-options*
|
||||
conque-term-read conque_term.txt /*conque-term-read*
|
||||
conque-term-requirements conque_term.txt /*conque-term-requirements*
|
||||
conque-term-set-callback conque_term.txt /*conque-term-set-callback*
|
||||
conque-term-special-keys conque_term.txt /*conque-term-special-keys*
|
||||
conque-term-subprocess conque_term.txt /*conque-term-subprocess*
|
||||
conque-term-usage conque_term.txt /*conque-term-usage*
|
||||
conque-term-windows conque_term.txt /*conque-term-windows*
|
||||
conque-term-write conque_term.txt /*conque-term-write*
|
||||
conque-term-writeln conque_term.txt /*conque-term-writeln*
|
||||
cs surround.txt /*cs*
|
||||
cvscommand-changes vcscommand.txt /*cvscommand-changes*
|
||||
drawit DrawIt.txt /*drawit*
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ augroup python
|
|||
autocmd FileType python set softtabstop=4
|
||||
autocmd FileType python set shiftwidth=4
|
||||
autocmd FileType python set expandtab
|
||||
autocmd FileType python set nosmartindent
|
||||
|
||||
augroup END
|
||||
augroup javascript
|
||||
autocmd FileType javascript set ts=4
|
||||
|
|
|
|||
196
.vim/indent/python.vim
Normal file
196
.vim/indent/python.vim
Normal file
|
|
@ -0,0 +1,196 @@
|
|||
" Python indent file
|
||||
" Language: Python
|
||||
" Maintainer: Eric Mc Sween <em@tomcom.de>
|
||||
" Original Author: David Bustos <bustos@caltech.edu>
|
||||
" Last Change: 2004 Jun 07
|
||||
|
||||
" Only load this indent file when no other was loaded.
|
||||
if exists("b:did_indent")
|
||||
finish
|
||||
endif
|
||||
let b:did_indent = 1
|
||||
|
||||
setlocal expandtab
|
||||
setlocal nolisp
|
||||
setlocal autoindent
|
||||
setlocal indentexpr=GetPythonIndent(v:lnum)
|
||||
setlocal indentkeys=!^F,o,O,<:>,0),0],0},=elif,=except
|
||||
|
||||
let s:maxoff = 50
|
||||
|
||||
" Find backwards the closest open parenthesis/bracket/brace.
|
||||
function! s:SearchParensPair()
|
||||
let line = line('.')
|
||||
let col = col('.')
|
||||
|
||||
" Skip strings and comments and don't look too far
|
||||
let skip = "line('.') < " . (line - s:maxoff) . " ? dummy :" .
|
||||
\ 'synIDattr(synID(line("."), col("."), 0), "name") =~? ' .
|
||||
\ '"string\\|comment"'
|
||||
|
||||
" Search for parentheses
|
||||
call cursor(line, col)
|
||||
let parlnum = searchpair('(', '', ')', 'bW', skip)
|
||||
let parcol = col('.')
|
||||
|
||||
" Search for brackets
|
||||
call cursor(line, col)
|
||||
let par2lnum = searchpair('\[', '', '\]', 'bW', skip)
|
||||
let par2col = col('.')
|
||||
|
||||
" Search for braces
|
||||
call cursor(line, col)
|
||||
let par3lnum = searchpair('{', '', '}', 'bW', skip)
|
||||
let par3col = col('.')
|
||||
|
||||
" Get the closest match
|
||||
if par2lnum > parlnum || (par2lnum == parlnum && par2col > parcol)
|
||||
let parlnum = par2lnum
|
||||
let parcol = par2col
|
||||
endif
|
||||
if par3lnum > parlnum || (par3lnum == parlnum && par3col > parcol)
|
||||
let parlnum = par3lnum
|
||||
let parcol = par3col
|
||||
endif
|
||||
|
||||
" Put the cursor on the match
|
||||
if parlnum > 0
|
||||
call cursor(parlnum, parcol)
|
||||
endif
|
||||
return parlnum
|
||||
endfunction
|
||||
|
||||
" Find the start of a multi-line statement
|
||||
function! s:StatementStart(lnum)
|
||||
let lnum = a:lnum
|
||||
while 1
|
||||
if getline(lnum - 1) =~ '\\$'
|
||||
let lnum = lnum - 1
|
||||
else
|
||||
call cursor(lnum, 1)
|
||||
let maybe_lnum = s:SearchParensPair()
|
||||
if maybe_lnum < 1
|
||||
return lnum
|
||||
else
|
||||
let lnum = maybe_lnum
|
||||
endif
|
||||
endif
|
||||
endwhile
|
||||
endfunction
|
||||
|
||||
" Find the block starter that matches the current line
|
||||
function! s:BlockStarter(lnum, block_start_re)
|
||||
let lnum = a:lnum
|
||||
let maxindent = 10000 " whatever
|
||||
while lnum > 1
|
||||
let lnum = prevnonblank(lnum - 1)
|
||||
if indent(lnum) < maxindent
|
||||
if getline(lnum) =~ a:block_start_re
|
||||
return lnum
|
||||
else
|
||||
let maxindent = indent(lnum)
|
||||
" It's not worth going further if we reached the top level
|
||||
if maxindent == 0
|
||||
return -1
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endwhile
|
||||
return -1
|
||||
endfunction
|
||||
|
||||
function! GetPythonIndent(lnum)
|
||||
|
||||
" First line has indent 0
|
||||
if a:lnum == 1
|
||||
return 0
|
||||
endif
|
||||
|
||||
" If we can find an open parenthesis/bracket/brace, line up with it.
|
||||
call cursor(a:lnum, 1)
|
||||
let parlnum = s:SearchParensPair()
|
||||
if parlnum > 0
|
||||
let parcol = col('.')
|
||||
let closing_paren = match(getline(a:lnum), '^\s*[])}]') != -1
|
||||
if match(getline(parlnum), '[([{]\s*$', parcol - 1) != -1
|
||||
if closing_paren
|
||||
return indent(parlnum)
|
||||
else
|
||||
return indent(parlnum) + &shiftwidth
|
||||
endif
|
||||
else
|
||||
if closing_paren
|
||||
return parcol - 1
|
||||
else
|
||||
return parcol
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
" Examine this line
|
||||
let thisline = getline(a:lnum)
|
||||
let thisindent = indent(a:lnum)
|
||||
|
||||
" If the line starts with 'elif' or 'else', line up with 'if' or 'elif'
|
||||
if thisline =~ '^\s*\(elif\|else\)\>'
|
||||
let bslnum = s:BlockStarter(a:lnum, '^\s*\(if\|elif\)\>')
|
||||
if bslnum > 0
|
||||
return indent(bslnum)
|
||||
else
|
||||
return -1
|
||||
endif
|
||||
endif
|
||||
|
||||
" If the line starts with 'except' or 'finally', line up with 'try'
|
||||
" or 'except'
|
||||
if thisline =~ '^\s*\(except\|finally\)\>'
|
||||
let bslnum = s:BlockStarter(a:lnum, '^\s*\(try\|except\)\>')
|
||||
if bslnum > 0
|
||||
return indent(bslnum)
|
||||
else
|
||||
return -1
|
||||
endif
|
||||
endif
|
||||
|
||||
" Examine previous line
|
||||
let plnum = a:lnum - 1
|
||||
let pline = getline(plnum)
|
||||
let sslnum = s:StatementStart(plnum)
|
||||
|
||||
" If the previous line is blank, keep the same indentation
|
||||
if pline =~ '^\s*$'
|
||||
return -1
|
||||
endif
|
||||
|
||||
" If this line is explicitly joined, try to find an indentation that looks
|
||||
" good.
|
||||
if pline =~ '\\$'
|
||||
let compound_statement = '^\s*\(if\|while\|for\s.*\sin\|except\)\s*'
|
||||
let maybe_indent = matchend(getline(sslnum), compound_statement)
|
||||
if maybe_indent != -1
|
||||
return maybe_indent
|
||||
else
|
||||
return indent(sslnum) + &sw * 2
|
||||
endif
|
||||
endif
|
||||
|
||||
" If the previous line ended with a colon, indent relative to
|
||||
" statement start.
|
||||
if pline =~ ':\s*$'
|
||||
return indent(sslnum) + &sw
|
||||
endif
|
||||
|
||||
" If the previous line was a stop-execution statement or a pass
|
||||
if getline(sslnum) =~ '^\s*\(break\|continue\|raise\|return\|pass\)\>'
|
||||
" See if the user has already dedented
|
||||
if indent(a:lnum) > indent(sslnum) - &sw
|
||||
" If not, recommend one dedent
|
||||
return indent(sslnum) - &sw
|
||||
endif
|
||||
" Otherwise, trust the user
|
||||
return -1
|
||||
endif
|
||||
|
||||
" In all other cases, line up with the start of the previous statement.
|
||||
return indent(sslnum)
|
||||
endfunction
|
||||
566
.vim/plugin/ShowFunc.vim
Normal file
566
.vim/plugin/ShowFunc.vim
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -1,9 +1,10 @@
|
|||
" FILE: plugin/conque_term.vim {{{
|
||||
" AUTHOR: Nico Raffo <nicoraffo@gmail.com>
|
||||
" MODIFIED: 2010-02-02
|
||||
" VERSION: 1.0, for Vim 7.0
|
||||
" WEBSITE: http://conque.googlecode.com
|
||||
" MODIFIED: 2010-11-15
|
||||
" VERSION: 2.0, for Vim 7.0
|
||||
" LICENSE:
|
||||
" Conque - pty interaction in Vim
|
||||
" Conque - Vim terminal/console emulator
|
||||
" Copyright (C) 2009-2010 Nico Raffo
|
||||
"
|
||||
" MIT License
|
||||
|
|
@ -37,7 +38,37 @@ endif
|
|||
" **** CONFIG **********************************************************************************************
|
||||
" **********************************************************************************************************
|
||||
|
||||
" Enable color {{{
|
||||
" {{{
|
||||
|
||||
" automatically go into insert mode when entering buffer {{{
|
||||
if !exists('g:ConqueTerm_InsertOnEnter')
|
||||
let g:ConqueTerm_InsertOnEnter = 0
|
||||
endif " }}}
|
||||
|
||||
" Allow user to use <C-w> keys to switch window in insert mode. {{{
|
||||
if !exists('g:ConqueTerm_CWInsert')
|
||||
let g:ConqueTerm_CWInsert = 0
|
||||
endif " }}}
|
||||
|
||||
" Choose key mapping to leave insert mode {{{
|
||||
" If you choose something other than '<Esc>', then <Esc> will be sent to terminal
|
||||
" Using a different key will usually fix Alt/Meta key issues
|
||||
if !exists('g:ConqueTerm_EscKey')
|
||||
let g:ConqueTerm_EscKey = '<Esc>'
|
||||
endif " }}}
|
||||
|
||||
" Use this key to send selected text to conque. {{{
|
||||
if !exists('g:ConqueTerm_SendVisKey')
|
||||
let g:ConqueTerm_SendVisKey = '<F9>'
|
||||
endif " }}}
|
||||
|
||||
" Use this key to toggle terminal key mappings. {{{
|
||||
if !exists('g:ConqueTerm_ToggleKey')
|
||||
let g:ConqueTerm_ToggleKey = '<F8>'
|
||||
endif " }}}
|
||||
|
||||
" Enable color. {{{
|
||||
" If your apps use a lot of color it will slow down the shell.
|
||||
if !exists('g:ConqueTerm_Color')
|
||||
let g:ConqueTerm_Color = 1
|
||||
endif " }}}
|
||||
|
|
@ -52,9 +83,9 @@ if !exists('g:ConqueTerm_Syntax')
|
|||
let g:ConqueTerm_Syntax = 'conque_term'
|
||||
endif " }}}
|
||||
|
||||
" Read when unfocused {{{
|
||||
" Keep on updating the shell window after you've switched to another buffer {{{
|
||||
if !exists('g:ConqueTerm_ReadUnfocused')
|
||||
let g:ConqueTerm_ReadUnfocused = 1
|
||||
let g:ConqueTerm_ReadUnfocused = 0
|
||||
endif " }}}
|
||||
|
||||
" Use this regular expression to highlight prompt {{{
|
||||
|
|
@ -62,19 +93,47 @@ if !exists('g:ConqueTerm_PromptRegex')
|
|||
let g:ConqueTerm_PromptRegex = '^\w\+@[0-9A-Za-z_.-]\+:[0-9A-Za-z_./\~,:-]\+\$'
|
||||
endif " }}}
|
||||
|
||||
" Choose which Python version to attempt to load first {{{
|
||||
" Valid values are 2, 3 or 0 (no preference)
|
||||
if !exists('g:ConqueTerm_PyVersion')
|
||||
let g:ConqueTerm_PyVersion = 2
|
||||
endif " }}}
|
||||
|
||||
" Path to python.exe. (Windows only) {{{
|
||||
" By default, Conque will check C:\PythonNN\python.exe then will search system path
|
||||
" If you have installed Python in an unusual location and it's not in your path, fill in the full path below
|
||||
" E.g. 'C:\Program Files\Python\Python27\python.exe'
|
||||
if !exists('g:ConqueTerm_PyExe')
|
||||
let g:ConqueTerm_PyExe = ''
|
||||
endif " }}}
|
||||
|
||||
" Automatically close buffer when program exits {{{
|
||||
if !exists('g:ConqueTerm_CloseOnEnd')
|
||||
let g:ConqueTerm_CloseOnEnd = 0
|
||||
endif " }}}
|
||||
|
||||
" Send function key presses to terminal {{{
|
||||
if !exists('g:ConqueTerm_SendFunctionKeys')
|
||||
let g:ConqueTerm_SendFunctionKeys = 0
|
||||
endif " }}}
|
||||
|
||||
" }}}
|
||||
|
||||
" **********************************************************************************************************
|
||||
" **** Startup *********************************************************************************************
|
||||
" **********************************************************************************************************
|
||||
|
||||
" Startup {{{
|
||||
setlocal encoding=utf-8
|
||||
|
||||
let g:ConqueTerm_Loaded = 1
|
||||
let g:ConqueTerm_Idx = 1
|
||||
let g:ConqueTerm_Idx = 0
|
||||
let g:ConqueTerm_Version = 200
|
||||
|
||||
command! -nargs=+ -complete=shellcmd ConqueTerm call conque_term#open(<q-args>)
|
||||
command! -nargs=+ -complete=shellcmd ConqueTermSplit call conque_term#open(<q-args>, ['split'])
|
||||
command! -nargs=+ -complete=shellcmd ConqueTermVSplit call conque_term#open(<q-args>, ['vsplit'])
|
||||
command! -nargs=+ -complete=shellcmd ConqueTermSplit call conque_term#open(<q-args>, ['belowright split'])
|
||||
command! -nargs=+ -complete=shellcmd ConqueTermVSplit call conque_term#open(<q-args>, ['belowright vsplit'])
|
||||
command! -nargs=+ -complete=shellcmd ConqueTermTab call conque_term#open(<q-args>, ['tabnew'])
|
||||
|
||||
" }}}
|
||||
|
||||
" vim:foldmethod=marker
|
||||
|
|
|
|||
|
|
@ -1,23 +1,56 @@
|
|||
" FILE: syntax/conque_term.vim {{{
|
||||
" AUTHOR: Nico Raffo <nicoraffo@gmail.com>
|
||||
" WEBSITE: http://conque.googlecode.com
|
||||
" MODIFIED: 2010-11-15
|
||||
" VERSION: 2.0, for Vim 7.0
|
||||
" LICENSE:
|
||||
" Conque - Vim terminal/console emulator
|
||||
" Copyright (C) 2009-2010 Nico Raffo
|
||||
"
|
||||
" MIT License
|
||||
"
|
||||
" Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
" of this software and associated documentation files (the "Software"), to deal
|
||||
" in the Software without restriction, including without limitation the rights
|
||||
" to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
" copies of the Software, and to permit persons to whom the Software is
|
||||
" furnished to do so, subject to the following conditions:
|
||||
"
|
||||
" The above copyright notice and this permission notice shall be included in
|
||||
" all copies or substantial portions of the Software.
|
||||
"
|
||||
" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
" IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
" FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
" AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
" LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
" OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
" THE SOFTWARE.
|
||||
" }}}
|
||||
|
||||
|
||||
" *******************************************************************************************************************
|
||||
" MySQL *************************************************************************************************************
|
||||
" *******************************************************************************************************************
|
||||
|
||||
" TODO Move these to syntax which is only executed for mysql
|
||||
"syn match MySQLTableBodyG "^\s*\w\+:\(.\+\)\=$" contains=MySQLTableHeadG,MySQLNullG,MySQLBool,MySQLNumberG,MySQLStorageClass oneline skipwhite skipnl
|
||||
"syn match MySQLTableHeadG "^\s*\w\+:" contains=MySQLTableColon skipwhite contained
|
||||
"syn match MySQLTableColon ":" contained
|
||||
|
||||
syn match MySQLTableHead "^ *|.*| *$" nextgroup=MySQLTableDivide contains=MySQLTableBar oneline skipwhite skipnl
|
||||
syn match MySQLTableBody "^ *|.*| *$" nextgroup=MySQLTableBody,MySQLTableEnd contains=MySQLTableBar,MySQLNull,MySQLBool,MySQLNumber,MySQLStorageClass oneline skipwhite skipnl
|
||||
syn match MySQLTableEnd "^ *+[+=-]\++ *$" oneline
|
||||
syn match MySQLTableDivide "^ *+[+=-]\++ *$" nextgroup=MySQLTableBody oneline skipwhite skipnl
|
||||
syn match MySQLTableStart "^ *+[+=-]\++ *$" nextgroup=MySQLTableHead oneline skipwhite skipnl
|
||||
syn match MySQLTableBar "|" contained
|
||||
syn match MySQLNull " NULL " contained
|
||||
syn match MySQLBool " YES " contained
|
||||
syn match MySQLBool " NO " contained
|
||||
syn match MySQLNull " NULL " contained contains=MySQLTableBar
|
||||
syn match MySQLStorageClass " PRI " contained
|
||||
syn match MySQLStorageClass " MUL " contained
|
||||
syn match MySQLStorageClass " UNI " contained
|
||||
syn match MySQLStorageClass " CURRENT_TIMESTAMP " contained
|
||||
syn match MySQLStorageClass " auto_increment " contained
|
||||
syn match MySQLNumber " \d\+ " contained
|
||||
syn match MySQLTableBar "|" contained
|
||||
syn match MySQLNumber "|\? *\d\+\(\.\d\+\)\? *|" contained contains=MySQLTableBar
|
||||
syn match MySQLQueryStat "^\d\+ rows\? in set.*" oneline
|
||||
syn match MySQLPromptLine "^.\?mysql> .*$" contains=MySQLKeyword,MySQLPrompt,MySQLString oneline
|
||||
syn match MySQLPromptLine "^ -> .*$" contains=MySQLKeyword,MySQLPrompt,MySQLString oneline
|
||||
|
|
@ -25,12 +58,13 @@ syn match MySQLPrompt "^.\?mysql>" contained oneline
|
|||
syn match MySQLPrompt "^ ->" contained oneline
|
||||
syn case ignore
|
||||
syn keyword MySQLKeyword select count max sum avg date show table tables status like as from left right outer inner join contained
|
||||
syn keyword MySQLKeyword where group by having limit offset order desc asc show contained
|
||||
syn keyword MySQLKeyword where group by having limit offset order desc asc show contained and interval is null on
|
||||
syn case match
|
||||
syn region MySQLString start=+'+ end=+'+ skip=+\\'+ contained oneline
|
||||
syn region MySQLString start=+"+ end=+"+ skip=+\\"+ contained oneline
|
||||
syn region MySQLString start=+`+ end=+`+ skip=+\\`+ contained oneline
|
||||
|
||||
|
||||
hi def link MySQLPrompt Identifier
|
||||
hi def link MySQLTableHead Title
|
||||
hi def link MySQLTableBody Normal
|
||||
|
|
@ -64,9 +98,11 @@ endif
|
|||
" *******************************************************************************************************************
|
||||
|
||||
" Typical Prompt
|
||||
silent execute "syn match ConquePromptLine '" . g:ConqueTerm_PromptRegex . ".*$' contains=ConquePrompt,ConqueString oneline"
|
||||
silent execute "syn match ConquePrompt '" . g:ConqueTerm_PromptRegex . "' contained oneline"
|
||||
hi def link ConquePrompt Identifier
|
||||
if g:ConqueTerm_PromptRegex != ''
|
||||
silent execute "syn match ConquePromptLine '" . g:ConqueTerm_PromptRegex . ".*$' contains=ConquePrompt,ConqueString oneline"
|
||||
silent execute "syn match ConquePrompt '" . g:ConqueTerm_PromptRegex . "' contained oneline"
|
||||
hi def link ConquePrompt Identifier
|
||||
endif
|
||||
|
||||
" Strings
|
||||
syn region ConqueString start=+'+ end=+'+ skip=+\\'+ contained oneline
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue