Adding new stuff
This commit is contained in:
parent
9ef8a96f9a
commit
0b3d063cb3
1580 changed files with 0 additions and 0 deletions
133
vim-plugins/bundle/python-mode/autoload/pymode.vim
Normal file
133
vim-plugins/bundle/python-mode/autoload/pymode.vim
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
" Pymode core functions
|
||||
|
||||
" DESC: Check variable and set default value if it not exists
|
||||
fun! pymode#default(name, default) "{{{
|
||||
if !exists(a:name)
|
||||
let {a:name} = a:default
|
||||
return 0
|
||||
endif
|
||||
return 1
|
||||
endfunction "}}}
|
||||
|
||||
" DESC: Import python libs
|
||||
fun! pymode#init(plugin_root, paths) "{{{
|
||||
|
||||
PymodePython import sys, vim
|
||||
PymodePython sys.path.insert(0, vim.eval('a:plugin_root'))
|
||||
PymodePython sys.path = vim.eval('a:paths') + sys.path
|
||||
|
||||
endfunction "}}}
|
||||
|
||||
" DESC: Show wide message
|
||||
fun! pymode#wide_message(msg) "{{{
|
||||
let x=&ruler | let y=&showcmd
|
||||
set noruler noshowcmd
|
||||
redraw
|
||||
echohl Debug | echo strpart("[Pymode] " . a:msg, 0, &columns-1) | echohl none
|
||||
let &ruler=x | let &showcmd=y
|
||||
endfunction "}}}
|
||||
|
||||
" DESC: Show error
|
||||
fun! pymode#error(msg) "{{{
|
||||
execute "normal \<Esc>"
|
||||
echohl ErrorMsg
|
||||
echomsg "[Pymode]: error: " . a:msg
|
||||
echohl None
|
||||
endfunction "}}}
|
||||
|
||||
" DESC: Open quickfix window
|
||||
fun! pymode#quickfix_open(onlyRecognized, maxHeight, minHeight, jumpError) "{{{
|
||||
let numErrors = len(filter(getqflist(), 'v:val.valid'))
|
||||
let numOthers = len(getqflist()) - numErrors
|
||||
if numErrors > 0 || (!a:onlyRecognized && numOthers > 0)
|
||||
let num = winnr()
|
||||
botright copen
|
||||
exe max([min([line("$"), a:maxHeight]), a:minHeight]) . "wincmd _"
|
||||
if a:jumpError
|
||||
cc
|
||||
elseif num != winnr()
|
||||
wincmd p
|
||||
endif
|
||||
else
|
||||
cclose
|
||||
endif
|
||||
redraw
|
||||
if numOthers > 0
|
||||
call pymode#wide_message(printf('Quickfix: %d(+%d)', numErrors, numOthers))
|
||||
elseif numErrors > 0
|
||||
call pymode#wide_message(printf('Quickfix: %d', numErrors))
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
" DESC: Open temp buffer.
|
||||
fun! pymode#tempbuffer_open(name) "{{{
|
||||
pclose
|
||||
exe "botright 8new " . a:name
|
||||
setlocal buftype=nofile bufhidden=delete noswapfile nowrap previewwindow
|
||||
redraw
|
||||
endfunction "}}}
|
||||
|
||||
" DESC: Remove unused whitespaces
|
||||
fun! pymode#trim_whitespaces() "{{{
|
||||
if g:pymode_trim_whitespaces
|
||||
let cursor_pos = getpos('.')
|
||||
silent! %s/\s\+$//
|
||||
call setpos('.', cursor_pos)
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
|
||||
fun! pymode#save() "{{{
|
||||
if &modifiable && &modified
|
||||
try
|
||||
noautocmd write
|
||||
catch /E212/
|
||||
call pymode#error("File modified and I can't save it. Please save it manually.")
|
||||
return 0
|
||||
endtry
|
||||
endif
|
||||
return expand('%') != ''
|
||||
endfunction "}}}
|
||||
|
||||
fun! pymode#reload_buf_by_nr(nr) "{{{
|
||||
let cur = bufnr("")
|
||||
try
|
||||
exe "buffer " . a:nr
|
||||
catch /E86/
|
||||
return
|
||||
endtry
|
||||
exe "e!"
|
||||
exe "buffer " . cur
|
||||
endfunction "}}}
|
||||
|
||||
fun! pymode#buffer_pre_write() "{{{
|
||||
let b:pymode_modified = &modified
|
||||
endfunction "}}}
|
||||
|
||||
fun! pymode#buffer_post_write() "{{{
|
||||
if g:pymode_rope
|
||||
if g:pymode_rope_regenerate_on_write && b:pymode_modified
|
||||
call pymode#debug('regenerate')
|
||||
call pymode#rope#regenerate()
|
||||
endif
|
||||
endif
|
||||
if g:pymode_lint
|
||||
if g:pymode_lint_unmodified || (g:pymode_lint_on_write && b:pymode_modified)
|
||||
call pymode#debug('check code')
|
||||
call pymode#lint#check()
|
||||
endif
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
fun! pymode#debug(msg) "{{{
|
||||
if g:pymode_debug
|
||||
let g:pymode_debug += 1
|
||||
echom string(g:pymode_debug) . ': ' . string(a:msg)
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
fun! pymode#quit() "{{{
|
||||
augroup pymode
|
||||
au! * <buffer>
|
||||
augroup END
|
||||
endfunction "}}}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
fun! pymode#breakpoint#init() "{{{
|
||||
|
||||
if !g:pymode_breakpoint
|
||||
return
|
||||
endif
|
||||
|
||||
if g:pymode_breakpoint_cmd == ''
|
||||
let g:pymode_breakpoint_cmd = 'import pdb; pdb.set_trace() # XXX BREAKPOINT'
|
||||
|
||||
if g:pymode_python == 'disable'
|
||||
return
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
PymodePython << EOF
|
||||
|
||||
from imp import find_module
|
||||
|
||||
for module in ('wdb', 'pudb', 'ipdb'):
|
||||
try:
|
||||
find_module(module)
|
||||
vim.command('let g:pymode_breakpoint_cmd = "import %s; %s.set_trace() # XXX BREAKPOINT"' % (module, module))
|
||||
break
|
||||
except ImportError:
|
||||
continue
|
||||
|
||||
EOF
|
||||
|
||||
endfunction "}}}
|
||||
|
||||
fun! pymode#breakpoint#operate(lnum) "{{{
|
||||
let line = getline(a:lnum)
|
||||
if strridx(line, g:pymode_breakpoint_cmd) != -1
|
||||
normal dd
|
||||
else
|
||||
let plnum = prevnonblank(a:lnum)
|
||||
if &expandtab
|
||||
let indents = repeat(' ', indent(plnum))
|
||||
else
|
||||
let indents = repeat("\t", plnum / &shiftwidth)
|
||||
endif
|
||||
|
||||
call append(line('.')-1, indents.g:pymode_breakpoint_cmd)
|
||||
normal k
|
||||
endif
|
||||
|
||||
" Save file without any events
|
||||
call pymode#save()
|
||||
|
||||
endfunction "}}}
|
||||
37
vim-plugins/bundle/python-mode/autoload/pymode/doc.vim
Normal file
37
vim-plugins/bundle/python-mode/autoload/pymode/doc.vim
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
" Python-mode search by documentation
|
||||
"
|
||||
PymodePython import pymode
|
||||
|
||||
fun! pymode#doc#find() "{{{
|
||||
" Extract the 'word' at the cursor, expanding leftwards across identifiers
|
||||
" and the . operator, and rightwards across the identifier only.
|
||||
"
|
||||
" For example:
|
||||
" import xml.dom.minidom
|
||||
" ^ !
|
||||
"
|
||||
" With the cursor at ^ this returns 'xml'; at ! it returns 'xml.dom'.
|
||||
let l:line = getline(".")
|
||||
let l:pre = l:line[:col(".") - 1]
|
||||
let l:suf = l:line[col("."):]
|
||||
let word = matchstr(pre, "[A-Za-z0-9_.]*$") . matchstr(suf, "^[A-Za-z0-9_]*")
|
||||
call pymode#doc#show(word)
|
||||
endfunction "}}}
|
||||
|
||||
fun! pymode#doc#show(word) "{{{
|
||||
if a:word == ''
|
||||
call pymode#error("No name/symbol under cursor!")
|
||||
return 0
|
||||
endif
|
||||
|
||||
call pymode#tempbuffer_open('__doc__')
|
||||
PymodePython pymode.get_documentation()
|
||||
setlocal nomodifiable
|
||||
setlocal nomodified
|
||||
setlocal filetype=rst
|
||||
if g:pymode_doc_vertical
|
||||
wincmd L
|
||||
endif
|
||||
wincmd p
|
||||
|
||||
endfunction "}}}
|
||||
274
vim-plugins/bundle/python-mode/autoload/pymode/folding.vim
Normal file
274
vim-plugins/bundle/python-mode/autoload/pymode/folding.vim
Normal file
|
|
@ -0,0 +1,274 @@
|
|||
" Python-mode folding functions
|
||||
|
||||
" Notice that folding is based on single line so complex regular expressions
|
||||
" that take previous line into consideration are not fit for the job.
|
||||
|
||||
" Regex definitions for correct folding
|
||||
let s:def_regex = g:pymode_folding_regex
|
||||
let s:blank_regex = '^\s*$'
|
||||
" Spyder, a very popular IDE for python has a template which includes
|
||||
" '@author:' ; thus the regex below.
|
||||
let s:decorator_regex = '^\s*@\(author:\)\@!'
|
||||
let s:doc_begin_regex = '^\s*[uU]\=\%("""\|''''''\)'
|
||||
let s:doc_end_regex = '\%("""\|''''''\)\s*$'
|
||||
" This one is needed for the while loop to count for opening and closing
|
||||
" docstrings.
|
||||
let s:doc_general_regex = '\%("""\|''''''\)'
|
||||
let s:doc_line_regex = '^\s*[uU]\=\("""\|''''''\).\+\1\s*$'
|
||||
let s:symbol = matchstr(&fillchars, 'fold:\zs.') " handles multibyte characters
|
||||
if s:symbol == ''
|
||||
let s:symbol = ' '
|
||||
endif
|
||||
" ''''''''
|
||||
|
||||
|
||||
fun! pymode#folding#text() " {{{
|
||||
let fs = v:foldstart
|
||||
while getline(fs) !~ s:def_regex && getline(fs) !~ s:doc_begin_regex
|
||||
let fs = nextnonblank(fs + 1)
|
||||
endwhile
|
||||
if getline(fs) =~ s:doc_end_regex && getline(fs) =~ s:doc_begin_regex
|
||||
let fs = nextnonblank(fs + 1)
|
||||
endif
|
||||
let line = getline(fs)
|
||||
|
||||
let has_numbers = &number || &relativenumber
|
||||
let nucolwidth = &fdc + has_numbers * &numberwidth
|
||||
let windowwidth = winwidth(0) - nucolwidth - 6
|
||||
let foldedlinecount = v:foldend - v:foldstart
|
||||
|
||||
" expand tabs into spaces
|
||||
let onetab = strpart(' ', 0, &tabstop)
|
||||
let line = substitute(line, '\t', onetab, 'g')
|
||||
|
||||
let line = strpart(line, 0, windowwidth - 2 -len(foldedlinecount))
|
||||
let line = substitute(line, '[uU]\=\%("""\|''''''\)', '', '')
|
||||
let fillcharcount = windowwidth - len(line) - len(foldedlinecount) + 1
|
||||
return line . ' ' . repeat(s:symbol, fillcharcount) . ' ' . foldedlinecount
|
||||
endfunction "}}}
|
||||
|
||||
fun! pymode#folding#expr(lnum) "{{{
|
||||
|
||||
let line = getline(a:lnum)
|
||||
let indent = indent(a:lnum)
|
||||
let prev_line = getline(a:lnum - 1)
|
||||
let next_line = getline(a:lnum + 1)
|
||||
|
||||
" Decorators {{{
|
||||
if line =~ s:decorator_regex
|
||||
return ">".(indent / &shiftwidth + 1)
|
||||
endif "}}}
|
||||
|
||||
" Definition {{{
|
||||
if line =~ s:def_regex
|
||||
" If indent of this line is greater or equal than line below
|
||||
" and previous non blank line does not end with : (that is, is not a
|
||||
" definition)
|
||||
" Keep the same indentation
|
||||
if indent(a:lnum) >= indent(a:lnum+1) && getline(prevnonblank(a:lnum)) !~ ':\s*$'
|
||||
return '='
|
||||
endif
|
||||
" Check if last decorator is before the last def
|
||||
let decorated = 0
|
||||
let lnum = a:lnum - 1
|
||||
while lnum > 0
|
||||
if getline(lnum) =~ s:def_regex
|
||||
break
|
||||
elseif getline(lnum) =~ s:decorator_regex
|
||||
let decorated = 1
|
||||
break
|
||||
endif
|
||||
let lnum -= 1
|
||||
endwhile
|
||||
if decorated
|
||||
return '='
|
||||
else
|
||||
return ">".(indent / &shiftwidth + 1)
|
||||
endif
|
||||
endif "}}}
|
||||
|
||||
" Docstrings {{{
|
||||
|
||||
" TODO: A while loop now counts the number of open and closed folding in
|
||||
" order to determine if it is a closing or opening folding.
|
||||
" It is working but looks like it is an overkill.
|
||||
|
||||
" Notice that an effect of this is that other docstring matches will not
|
||||
" be one liners.
|
||||
if line =~ s:doc_line_regex
|
||||
return "="
|
||||
endif
|
||||
|
||||
if line =~ s:doc_begin_regex
|
||||
" echom 'just entering'
|
||||
if s:Is_opening_folding(a:lnum)
|
||||
" echom 'entering at line ' . a:lnum
|
||||
return ">".(indent / &shiftwidth + 1)
|
||||
endif
|
||||
endif
|
||||
if line =~ s:doc_end_regex
|
||||
if !s:Is_opening_folding(a:lnum)
|
||||
" echom 'leaving at line ' . a:lnum
|
||||
return "<".(indent / &shiftwidth + 1)
|
||||
endif
|
||||
endif "}}}
|
||||
|
||||
" Nested Definitions {{{
|
||||
" Handle nested defs but only for files shorter than
|
||||
" g:pymode_folding_nest_limit lines due to performance concerns
|
||||
if line('$') < g:pymode_folding_nest_limit && indent(prevnonblank(a:lnum))
|
||||
let curpos = getpos('.')
|
||||
try
|
||||
let last_block = s:BlockStart(a:lnum)
|
||||
let last_block_indent = indent(last_block)
|
||||
|
||||
" Check if last class/def is not indented and therefore can't be
|
||||
" nested.
|
||||
if last_block_indent
|
||||
call cursor(a:lnum, 0)
|
||||
let next_def = searchpos(s:def_regex, 'nW')[0]
|
||||
let next_def_indent = next_def ? indent(next_def) : -1
|
||||
let last_block_end = s:BlockEnd(last_block)
|
||||
|
||||
" If the next def has greater indent than the previous def, it
|
||||
" is nested one level deeper and will have its own fold. If
|
||||
" the class/def containing the current line is on the first
|
||||
" line it can't be nested, and if this block ends on the last
|
||||
" line, it contains no trailing code that should not be
|
||||
" folded. Finally, if the next non-blank line after the end of
|
||||
" the previous def is less indented than the previous def, it
|
||||
" is not part of the same fold as that def. Otherwise, we know
|
||||
" the current line is at the end of a nested def.
|
||||
if next_def_indent <= last_block_indent && last_block > 1 && last_block_end < line('$')
|
||||
\ && indent(nextnonblank(last_block_end)) >= last_block_indent
|
||||
|
||||
" Include up to one blank line in the fold
|
||||
if getline(last_block_end) =~ s:blank_regex
|
||||
let fold_end = min([prevnonblank(last_block_end - 1), last_block_end]) + 1
|
||||
else
|
||||
let fold_end = last_block_end
|
||||
endif
|
||||
if a:lnum == fold_end
|
||||
return 's1'
|
||||
else
|
||||
return '='
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
finally
|
||||
call setpos('.', curpos)
|
||||
endtry
|
||||
endif " }}}
|
||||
|
||||
" Blank Line {{{
|
||||
if line =~ s:blank_regex
|
||||
if prev_line =~ s:blank_regex
|
||||
if indent(a:lnum + 1) == 0 && next_line !~ s:blank_regex && next_line !~ s:doc_general_regex
|
||||
if s:Is_opening_folding(a:lnum)
|
||||
" echom a:lnum
|
||||
return "="
|
||||
else
|
||||
" echom "not " . a:lnum
|
||||
return 0
|
||||
endif
|
||||
endif
|
||||
return -1
|
||||
else
|
||||
return '='
|
||||
endif
|
||||
endif " }}}
|
||||
|
||||
return '='
|
||||
|
||||
endfunction "}}}
|
||||
|
||||
fun! s:BlockStart(lnum) "{{{
|
||||
" Note: Make sure to reset cursor position after using this function.
|
||||
call cursor(a:lnum, 0)
|
||||
|
||||
" In case the end of the block is indented to a higher level than the def
|
||||
" statement plus one shiftwidth, we need to find the indent level at the
|
||||
" bottom of that if/for/try/while/etc. block.
|
||||
let last_def = searchpos(s:def_regex, 'bcnW')[0]
|
||||
if last_def
|
||||
let last_def_indent = indent(last_def)
|
||||
call cursor(last_def, 0)
|
||||
let next_stmt_at_def_indent = searchpos('\v^\s{'.last_def_indent.'}[^[:space:]#]', 'nW')[0]
|
||||
else
|
||||
let next_stmt_at_def_indent = -1
|
||||
endif
|
||||
|
||||
" Now find the class/def one shiftwidth lower than the start of the
|
||||
" aforementioned indent block.
|
||||
if next_stmt_at_def_indent && next_stmt_at_def_indent < a:lnum
|
||||
let max_indent = max([indent(next_stmt_at_def_indent) - &shiftwidth, 0])
|
||||
else
|
||||
let max_indent = max([indent(prevnonblank(a:lnum)) - &shiftwidth, 0])
|
||||
endif
|
||||
return searchpos('\v^\s{,'.max_indent.'}(def |class )\w', 'bcnW')[0]
|
||||
endfunction "}}}
|
||||
|
||||
fun! s:BlockEnd(lnum) "{{{
|
||||
" Note: Make sure to reset cursor position after using this function.
|
||||
call cursor(a:lnum, 0)
|
||||
return searchpos('\v^\s{,'.indent('.').'}\S', 'nW')[0] - 1
|
||||
endfunction "}}}
|
||||
|
||||
function! s:Is_opening_folding(lnum) "{{{
|
||||
" Helper function to see if docstring is opening or closing
|
||||
|
||||
" Cache the result so the loop runs only once per change
|
||||
if get(b:, 'fold_changenr', -1) == changenr()
|
||||
return b:fold_cache[a:lnum] "If odd then it is an opening
|
||||
else
|
||||
let b:fold_changenr = changenr()
|
||||
let b:fold_cache = []
|
||||
endif
|
||||
|
||||
let number_of_folding = 0 " To be analized if odd/even to inform if it is opening or closing.
|
||||
let has_open_docstring = 0 " To inform is already has an open docstring.
|
||||
let extra_docstrings = 0 " To help skipping ''' and """ which are not docstrings
|
||||
|
||||
" The idea of this part of the function is to identify real docstrings and
|
||||
" not just triple quotes (that could be a regular string).
|
||||
"
|
||||
" Iterater over all lines from the start until current line (inclusive)
|
||||
for i in range(1, line('$'))
|
||||
call add(b:fold_cache, number_of_folding % 2)
|
||||
|
||||
let i_line = getline(i)
|
||||
|
||||
if i_line =~ s:doc_line_regex
|
||||
" echom "case 00 on line " . i
|
||||
continue
|
||||
endif
|
||||
|
||||
if i_line =~ s:doc_begin_regex && ! has_open_docstring
|
||||
" echom "case 01 on line " . i
|
||||
" This causes the loop to continue if there is a triple quote which
|
||||
" is not a docstring.
|
||||
if extra_docstrings > 0
|
||||
let extra_docstrings = extra_docstrings - 1
|
||||
continue
|
||||
else
|
||||
let has_open_docstring = 1
|
||||
let number_of_folding = number_of_folding + 1
|
||||
endif
|
||||
" If it is an end doc and has an open docstring.
|
||||
elseif i_line =~ s:doc_end_regex && has_open_docstring
|
||||
" echom "case 02 on line " . i
|
||||
let has_open_docstring = 0
|
||||
let number_of_folding = number_of_folding + 1
|
||||
|
||||
elseif i_line =~ s:doc_general_regex
|
||||
" echom "extra docstrings on line " . i
|
||||
let extra_docstrings = extra_docstrings + 1
|
||||
endif
|
||||
endfor
|
||||
|
||||
call add(b:fold_cache, number_of_folding % 2)
|
||||
|
||||
return b:fold_cache[a:lnum]
|
||||
endfunction "}}}
|
||||
|
||||
" vim: fdm=marker:fdl=0
|
||||
186
vim-plugins/bundle/python-mode/autoload/pymode/indent.vim
Normal file
186
vim-plugins/bundle/python-mode/autoload/pymode/indent.vim
Normal file
|
|
@ -0,0 +1,186 @@
|
|||
" PEP8 compatible Python indent file
|
||||
" Language: Python
|
||||
" Maintainer: Hynek Schlawack <hs@ox.cx>
|
||||
" Prev Maintainer: Eric Mc Sween <em@tomcom.de> (address invalid)
|
||||
" Original Author: David Bustos <bustos@caltech.edu> (address invalid)
|
||||
" Last Change: 2012-06-21
|
||||
" License: Public Domain
|
||||
|
||||
|
||||
function! pymode#indent#get_indent(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
|
||||
return parcol
|
||||
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, find the first indentation that is a
|
||||
" multiple of four and will distinguish itself from next logical line.
|
||||
if pline =~ '\\$'
|
||||
let maybe_indent = indent(sslnum) + &sw
|
||||
let control_structure = '^\s*\(if\|while\|for\s.*\sin\|except\)\s*'
|
||||
if match(getline(sslnum), control_structure) != -1
|
||||
" add extra indent to avoid E125
|
||||
return maybe_indent + &sw
|
||||
else
|
||||
" control structure not found
|
||||
return maybe_indent
|
||||
endif
|
||||
endif
|
||||
|
||||
" If the previous line ended with a colon and is not a comment, 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
|
||||
|
||||
|
||||
" 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 - 50) . " ? dummy :" .
|
||||
\ 'synIDattr(synID(line("."), col("."), 0), "name") =~? ' .
|
||||
\ '"string\\|comment\\|doctest"'
|
||||
|
||||
" 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 " }}}
|
||||
101
vim-plugins/bundle/python-mode/autoload/pymode/lint.vim
Normal file
101
vim-plugins/bundle/python-mode/autoload/pymode/lint.vim
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
PymodePython from pymode.lint import code_check
|
||||
|
||||
call pymode#tools#signs#init()
|
||||
call pymode#tools#loclist#init()
|
||||
|
||||
|
||||
fun! pymode#lint#auto() "{{{
|
||||
if !pymode#save()
|
||||
return 0
|
||||
endif
|
||||
PymodePython from pymode import auto
|
||||
PymodePython auto()
|
||||
cclose
|
||||
call g:PymodeSigns.clear()
|
||||
edit
|
||||
call pymode#wide_message("AutoPep8 done.")
|
||||
endfunction "}}}
|
||||
|
||||
|
||||
fun! pymode#lint#show_errormessage() "{{{
|
||||
let loclist = g:PymodeLocList.current()
|
||||
if loclist.is_empty()
|
||||
return
|
||||
endif
|
||||
|
||||
let l = line('.')
|
||||
if l == b:pymode_error_line
|
||||
return
|
||||
endif
|
||||
let b:pymode_error_line = l
|
||||
if has_key(loclist._messages, l)
|
||||
call pymode#wide_message(loclist._messages[l])
|
||||
else
|
||||
echo
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
|
||||
fun! pymode#lint#toggle() "{{{
|
||||
let g:pymode_lint = g:pymode_lint ? 0 : 1
|
||||
if g:pymode_lint
|
||||
call pymode#wide_message("Code checking is enabled.")
|
||||
else
|
||||
call pymode#wide_message("Code checking is disabled.")
|
||||
end
|
||||
endfunction "}}}
|
||||
|
||||
|
||||
fun! pymode#lint#check() "{{{
|
||||
" DESC: Run checkers on current file.
|
||||
"
|
||||
let loclist = g:PymodeLocList.current()
|
||||
|
||||
let b:pymode_error_line = -1
|
||||
|
||||
call loclist.clear()
|
||||
|
||||
call pymode#wide_message('Code checking is running ...')
|
||||
|
||||
PymodePython code_check()
|
||||
|
||||
if loclist.is_empty()
|
||||
call pymode#wide_message('Code checking is completed. No errors found.')
|
||||
endif
|
||||
|
||||
call g:PymodeSigns.refresh(loclist)
|
||||
|
||||
call loclist.show()
|
||||
|
||||
call pymode#lint#show_errormessage()
|
||||
call pymode#wide_message('Found errors and warnings: ' . len(loclist._loclist))
|
||||
|
||||
endfunction " }}}
|
||||
|
||||
|
||||
fun! pymode#lint#tick_queue() "{{{
|
||||
|
||||
python import time
|
||||
python print time.time()
|
||||
|
||||
if mode() == 'i'
|
||||
if col('.') == 1
|
||||
call feedkeys("\<Right>\<Left>", "n")
|
||||
else
|
||||
call feedkeys("\<Left>\<Right>", "n")
|
||||
endif
|
||||
else
|
||||
call feedkeys("f\e", "n")
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
|
||||
fun! pymode#lint#stop() "{{{
|
||||
au! pymode CursorHold <buffer>
|
||||
endfunction "}}}
|
||||
|
||||
|
||||
fun! pymode#lint#start() "{{{
|
||||
au! pymode CursorHold <buffer> call pymode#lint#tick_queue()
|
||||
call pymode#lint#tick_queue()
|
||||
endfunction "}}}
|
||||
97
vim-plugins/bundle/python-mode/autoload/pymode/motion.vim
Normal file
97
vim-plugins/bundle/python-mode/autoload/pymode/motion.vim
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
" Python-mode motion functions
|
||||
|
||||
|
||||
fun! pymode#motion#move(pattern, flags, ...) "{{{
|
||||
let cnt = v:count1 - 1
|
||||
let [line, column] = searchpos(a:pattern, a:flags . 'sW')
|
||||
let indent = indent(line)
|
||||
while cnt && line
|
||||
let [line, column] = searchpos(a:pattern, a:flags . 'W')
|
||||
if indent(line) == indent
|
||||
let cnt = cnt - 1
|
||||
endif
|
||||
endwhile
|
||||
return [line, column]
|
||||
endfunction "}}}
|
||||
|
||||
|
||||
fun! pymode#motion#vmove(pattern, flags) range "{{{
|
||||
call cursor(a:lastline, 0)
|
||||
let end = pymode#motion#move(a:pattern, a:flags)
|
||||
call cursor(a:firstline, 0)
|
||||
normal! v
|
||||
call cursor(end)
|
||||
endfunction "}}}
|
||||
|
||||
|
||||
fun! pymode#motion#pos_le(pos1, pos2) "{{{
|
||||
return ((a:pos1[0] < a:pos2[0]) || (a:pos1[0] == a:pos2[0] && a:pos1[1] <= a:pos2[1]))
|
||||
endfunction "}}}
|
||||
|
||||
|
||||
fun! pymode#motion#select(pattern, inner) "{{{
|
||||
let cnt = v:count1 - 1
|
||||
let orig = getpos('.')[1:2]
|
||||
let snum = s:BlockStart(orig[0], a:pattern)
|
||||
if getline(snum) !~ a:pattern
|
||||
return 0
|
||||
endif
|
||||
let enum = s:BlockEnd(snum, indent(snum))
|
||||
while cnt
|
||||
let lnum = search(a:pattern, 'nW')
|
||||
if lnum
|
||||
let enum = s:BlockEnd(lnum, indent(lnum))
|
||||
call cursor(enum, 1)
|
||||
endif
|
||||
let cnt = cnt - 1
|
||||
endwhile
|
||||
if pymode#motion#pos_le([snum, 0], orig) && pymode#motion#pos_le(orig, [enum, 1])
|
||||
if a:inner
|
||||
let snum = snum + 1
|
||||
let enum = prevnonblank(enum)
|
||||
endif
|
||||
|
||||
call cursor(snum, 1)
|
||||
normal! v
|
||||
call cursor(enum, len(getline(enum)))
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
|
||||
fun! s:BlockStart(lnum, ...) "{{{
|
||||
let pattern = a:0 ? a:1 : '^\s*\(@\|class\s.*:\|def\s\)'
|
||||
let lnum = a:lnum + 1
|
||||
let indent = 100
|
||||
while lnum
|
||||
let lnum = prevnonblank(lnum - 1)
|
||||
let test = indent(lnum)
|
||||
let line = getline(lnum)
|
||||
if line =~ '^\s*#' " Skip comments
|
||||
continue
|
||||
elseif !test " Zero-level regular line
|
||||
return lnum
|
||||
elseif test >= indent " Skip deeper or equal lines
|
||||
continue
|
||||
" Indent is strictly less at this point: check for def/class
|
||||
elseif line =~ pattern && line !~ '^\s*@'
|
||||
return lnum
|
||||
endif
|
||||
let indent = indent(lnum)
|
||||
endwhile
|
||||
return 0
|
||||
endfunction "}}}
|
||||
|
||||
|
||||
fun! s:BlockEnd(lnum, ...) "{{{
|
||||
let indent = a:0 ? a:1 : indent(a:lnum)
|
||||
let lnum = a:lnum
|
||||
while lnum
|
||||
let lnum = nextnonblank(lnum + 1)
|
||||
if getline(lnum) =~ '^\s*#' | continue
|
||||
elseif lnum && indent(lnum) <= indent
|
||||
return lnum - 1
|
||||
endif
|
||||
endwhile
|
||||
return line('$')
|
||||
endfunction "}}}
|
||||
" vim: fdm=marker:fdl=0
|
||||
185
vim-plugins/bundle/python-mode/autoload/pymode/rope.vim
Normal file
185
vim-plugins/bundle/python-mode/autoload/pymode/rope.vim
Normal file
|
|
@ -0,0 +1,185 @@
|
|||
" Python-mode Rope support
|
||||
"
|
||||
PymodePython from pymode import rope
|
||||
|
||||
call pymode#tools#loclist#init()
|
||||
|
||||
|
||||
fun! pymode#rope#completions(findstart, base)
|
||||
PymodePython rope.completions()
|
||||
endfunction
|
||||
|
||||
fun! pymode#rope#complete(dot)
|
||||
if pumvisible()
|
||||
return "\<C-n>"
|
||||
end
|
||||
if a:dot
|
||||
PymodePython rope.complete(True)
|
||||
else
|
||||
PymodePython rope.complete()
|
||||
end
|
||||
return pumvisible() ? "\<C-p>\<Down>" : ""
|
||||
endfunction
|
||||
|
||||
fun! pymode#rope#complete_on_dot() "{{{
|
||||
if !exists("*synstack")
|
||||
return ""
|
||||
end
|
||||
for group in map(synstack(line('.'), col('.') - 1), 'synIDattr(v:val, "name")')
|
||||
for name in ['pythonString', 'pythonComment', 'pythonNumber', 'pythonDocstring']
|
||||
if group == name
|
||||
return ""
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
if g:pymode_rope_autoimport_import_after_complete
|
||||
PymodePython rope.complete_check()
|
||||
endif
|
||||
return pymode#rope#complete(1)
|
||||
endfunction "}}}
|
||||
|
||||
fun! pymode#rope#goto_definition()
|
||||
PymodePython rope.goto()
|
||||
endfunction
|
||||
|
||||
|
||||
fun! pymode#rope#organize_imports()
|
||||
if !pymode#save()
|
||||
return 0
|
||||
endif
|
||||
call pymode#wide_message('Organize imports ... ')
|
||||
PymodePython rope.organize_imports()
|
||||
endfunction
|
||||
|
||||
|
||||
fun! pymode#rope#find_it()
|
||||
let loclist = g:PymodeLocList.current()
|
||||
let loclist._title = "Occurrences"
|
||||
call pymode#wide_message('Finding Occurrences ...')
|
||||
PymodePython rope.find_it()
|
||||
call loclist.show()
|
||||
endfunction
|
||||
|
||||
|
||||
fun! pymode#rope#show_doc()
|
||||
let l:output = []
|
||||
|
||||
PymodePython rope.show_doc()
|
||||
|
||||
if !empty(l:output)
|
||||
call pymode#tempbuffer_open('__doc____rope__')
|
||||
call append(0, l:output)
|
||||
setlocal nomodifiable
|
||||
setlocal nomodified
|
||||
setlocal filetype=rst
|
||||
wincmd p
|
||||
end
|
||||
endfunction
|
||||
|
||||
|
||||
fun! pymode#rope#regenerate() "{{{
|
||||
call pymode#wide_message('Regenerate Rope cache ... ')
|
||||
PymodePython rope.regenerate()
|
||||
endfunction "}}}
|
||||
|
||||
|
||||
fun! pymode#rope#new(...) "{{{
|
||||
PymodePython rope.new()
|
||||
endfunction "}}}
|
||||
|
||||
|
||||
fun! pymode#rope#rename() "{{{
|
||||
if !pymode#save()
|
||||
return 0
|
||||
endif
|
||||
PymodePython rope.RenameRefactoring().run()
|
||||
endfunction "}}}
|
||||
|
||||
fun! pymode#rope#rename_module() "{{{
|
||||
if !pymode#save()
|
||||
return 0
|
||||
endif
|
||||
PymodePython rope.RenameRefactoring(True).run()
|
||||
endfunction "}}}
|
||||
|
||||
fun! pymode#rope#extract_method() range "{{{
|
||||
if !pymode#save()
|
||||
return 0
|
||||
endif
|
||||
PymodePython rope.ExtractMethodRefactoring().run()
|
||||
endfunction "}}}
|
||||
|
||||
fun! pymode#rope#extract_variable() range "{{{
|
||||
if !pymode#save()
|
||||
return 0
|
||||
endif
|
||||
PymodePython rope.ExtractVariableRefactoring().run()
|
||||
endfunction "}}}
|
||||
|
||||
fun! pymode#rope#undo() "{{{
|
||||
PymodePython rope.undo()
|
||||
endfunction "}}}
|
||||
|
||||
fun! pymode#rope#redo() "{{{
|
||||
PymodePython rope.redo()
|
||||
endfunction "}}}
|
||||
|
||||
fun! pymode#rope#inline() "{{{
|
||||
if !pymode#save()
|
||||
return 0
|
||||
endif
|
||||
PymodePython rope.InlineRefactoring().run()
|
||||
endfunction "}}}
|
||||
|
||||
fun! pymode#rope#move() "{{{
|
||||
if !pymode#save()
|
||||
return 0
|
||||
endif
|
||||
PymodePython rope.MoveRefactoring().run()
|
||||
endfunction "}}}
|
||||
|
||||
fun! pymode#rope#signature() "{{{
|
||||
if !pymode#save()
|
||||
return 0
|
||||
endif
|
||||
PymodePython rope.ChangeSignatureRefactoring().run()
|
||||
endfunction "}}}
|
||||
|
||||
fun! pymode#rope#use_function() "{{{
|
||||
if !pymode#save()
|
||||
return 0
|
||||
endif
|
||||
PymodePython rope.UseFunctionRefactoring().run()
|
||||
endfunction "}}}
|
||||
|
||||
fun! pymode#rope#module_to_package() "{{{
|
||||
if !pymode#save()
|
||||
return 0
|
||||
endif
|
||||
PymodePython rope.ModuleToPackageRefactoring().run()
|
||||
endfunction "}}}
|
||||
|
||||
fun! pymode#rope#autoimport(word) "{{{
|
||||
PymodePython rope.autoimport()
|
||||
endfunction "}}}
|
||||
|
||||
fun! pymode#rope#generate_function() "{{{
|
||||
if !pymode#save()
|
||||
return 0
|
||||
endif
|
||||
PymodePython rope.GenerateElementRefactoring('function').run()
|
||||
endfunction "}}}
|
||||
|
||||
fun! pymode#rope#generate_class() "{{{
|
||||
if !pymode#save()
|
||||
return 0
|
||||
endif
|
||||
PymodePython rope.GenerateElementRefactoring('class').run()
|
||||
endfunction "}}}
|
||||
|
||||
fun! pymode#rope#generate_package() "{{{
|
||||
if !pymode#save()
|
||||
return 0
|
||||
endif
|
||||
PymodePython rope.GenerateElementRefactoring('package').run()
|
||||
endfunction "}}}
|
||||
99
vim-plugins/bundle/python-mode/autoload/pymode/run.vim
Normal file
99
vim-plugins/bundle/python-mode/autoload/pymode/run.vim
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
" The following lines set Vim's errorformat variable, to allow the
|
||||
" quickfix window to show Python tracebacks properly. It is much
|
||||
" easier to use let than set, because set requires many more
|
||||
" characters to be escaped. This is much easier to read and
|
||||
" maintain. % escapes are still needed however before any regex meta
|
||||
" characters. Hence \S (non-whitespace) becomes %\S etc. Note that
|
||||
" * becomes %#, so .* (match any character) becomes %.%# Commas must
|
||||
" also be escaped, with a backslash (\,). See the Vim help on
|
||||
" quickfix for details.
|
||||
"
|
||||
" Python errors are multi-lined. They often start with 'Traceback', so
|
||||
" we want to capture that (with +G) and show it in the quickfix window
|
||||
" because it explains the order of error messages.
|
||||
let s:efm = '%+GTraceback%.%#,'
|
||||
|
||||
" The error message itself starts with a line with 'File' in it. There
|
||||
" are a couple of variations, and we need to process a line beginning
|
||||
" with whitespace followed by File, the filename in "", a line number,
|
||||
" and optional further text. %E here indicates the start of a multi-line
|
||||
" error message. The %\C at the end means that a case-sensitive search is
|
||||
" required.
|
||||
let s:efm .= '%E File "%f"\, line %l\,%m%\C,'
|
||||
let s:efm .= '%E File "%f"\, line %l%\C,'
|
||||
|
||||
" The possible continutation lines are idenitifed to Vim by %C. We deal
|
||||
" with these in order of most to least specific to ensure a proper
|
||||
" match. A pointer (^) identifies the column in which the error occurs
|
||||
" (but will not be entirely accurate due to indention of Python code).
|
||||
let s:efm .= '%C%p^,'
|
||||
|
||||
" Any text, indented by more than two spaces contain useful information.
|
||||
" We want this to appear in the quickfix window, hence %+.
|
||||
let s:efm .= '%+C %.%#,'
|
||||
let s:efm .= '%+C %.%#,'
|
||||
|
||||
" The last line (%Z) does not begin with any whitespace. We use a zero
|
||||
" width lookahead (\&) to check this. The line contains the error
|
||||
" message itself (%m)
|
||||
let s:efm .= '%Z%\S%\&%m,'
|
||||
|
||||
" We can ignore any other lines (%-G)
|
||||
let s:efm .= '%-G%.%#'
|
||||
|
||||
PymodePython from pymode.run import run_code
|
||||
|
||||
|
||||
" DESC: Run python code
|
||||
fun! pymode#run#code_run(line1, line2) "{{{
|
||||
|
||||
let l:output = []
|
||||
let l:traceback = []
|
||||
call setqflist([])
|
||||
|
||||
call pymode#wide_message("Code running ...")
|
||||
|
||||
try
|
||||
|
||||
PymodePython run_code()
|
||||
|
||||
if len(l:output)
|
||||
call pymode#tempbuffer_open('__run__')
|
||||
call append(line('$'), l:output)
|
||||
normal dd
|
||||
wincmd p
|
||||
else
|
||||
call pymode#wide_message("No output.")
|
||||
endif
|
||||
|
||||
cexpr ""
|
||||
|
||||
let l:_efm = &efm
|
||||
|
||||
let &efm = s:efm
|
||||
|
||||
cgetexpr(l:traceback)
|
||||
|
||||
" If a range is run (starting other than at line 1), fix the reported error line numbers for
|
||||
" the current buffer
|
||||
if a:line1 > 1
|
||||
let qflist = getqflist()
|
||||
for i in qflist
|
||||
if i.bufnr == bufnr("")
|
||||
let i.lnum = i.lnum - 1 + a:line1
|
||||
endif
|
||||
endfor
|
||||
call setqflist(qflist)
|
||||
endif
|
||||
|
||||
call pymode#quickfix_open(0, g:pymode_quickfix_maxheight, g:pymode_quickfix_maxheight, 0)
|
||||
|
||||
let &efm = l:_efm
|
||||
|
||||
catch /E234/
|
||||
|
||||
echohl Error | echo "Run-time error." | echohl none
|
||||
|
||||
endtry
|
||||
|
||||
endfunction "}}}
|
||||
|
|
@ -0,0 +1,81 @@
|
|||
let g:PymodeLocList= {}
|
||||
|
||||
|
||||
fun! pymode#tools#loclist#init() "{{{
|
||||
return
|
||||
endfunction "}}}
|
||||
|
||||
|
||||
fun! g:PymodeLocList.init(raw_list) "{{{
|
||||
let obj = copy(self)
|
||||
let loc_list = filter(copy(a:raw_list), 'v:val["valid"] == 1')
|
||||
call obj.clear()
|
||||
let obj._title = 'CodeCheck'
|
||||
return obj
|
||||
endfunction "}}}
|
||||
|
||||
|
||||
fun! g:PymodeLocList.current() "{{{
|
||||
if !exists("b:pymode_loclist")
|
||||
let b:pymode_loclist = g:PymodeLocList.init([])
|
||||
endif
|
||||
return b:pymode_loclist
|
||||
endfunction "}}}
|
||||
|
||||
|
||||
fun! g:PymodeLocList.is_empty() "{{{
|
||||
return empty(self._loclist)
|
||||
endfunction "}}}
|
||||
|
||||
|
||||
fun! g:PymodeLocList.clear() "{{{
|
||||
let self._loclist = []
|
||||
let self._messages = {}
|
||||
let self._name = expand('%:t')
|
||||
endfunction "}}}
|
||||
|
||||
|
||||
fun! g:PymodeLocList.extend(raw_list) "{{{
|
||||
call extend(self._loclist, a:raw_list)
|
||||
for issue in a:raw_list
|
||||
let self._messages[issue.lnum] = issue.text
|
||||
endfor
|
||||
return self
|
||||
endfunction "}}}
|
||||
|
||||
|
||||
fun! g:PymodeLocList.filter(filters) "{{{
|
||||
let loclist = []
|
||||
for error in self._loclist
|
||||
let passes_filters = 1
|
||||
for key in keys(a:filters)
|
||||
if get(error, key, '') !=? a:filters[key]
|
||||
let passes_filters = 0
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
|
||||
if passes_filters
|
||||
call add(loclist, error)
|
||||
endif
|
||||
|
||||
endfor
|
||||
return loclist
|
||||
endfunction "}}}
|
||||
|
||||
|
||||
fun! g:PymodeLocList.show() "{{{
|
||||
call setloclist(0, self._loclist)
|
||||
if self.is_empty()
|
||||
lclose
|
||||
elseif g:pymode_lint_cwindow
|
||||
let num = winnr()
|
||||
lopen
|
||||
setl nowrap
|
||||
execute max([min([line("$"), g:pymode_quickfix_maxheight]), g:pymode_quickfix_minheight]) . "wincmd _"
|
||||
if num != winnr()
|
||||
call setwinvar(winnr(), 'quickfix_title', self._title . ' <' . self._name . '>')
|
||||
exe num . "wincmd w"
|
||||
endif
|
||||
end
|
||||
endfunction "}}}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
let g:PymodeSigns = {}
|
||||
|
||||
|
||||
fun! pymode#tools#signs#init() "{{{
|
||||
call g:PymodeSigns.setup()
|
||||
endfunction "}}}
|
||||
|
||||
|
||||
fun! g:PymodeSigns.enabled() "{{{
|
||||
return (g:pymode_lint_signs && has('signs'))
|
||||
endfunction "}}}
|
||||
|
||||
|
||||
fun! g:PymodeSigns.setup() "{{{
|
||||
if self.enabled()
|
||||
execute 'sign define PymodeW text=' . g:pymode_lint_todo_symbol . " texthl=Todo"
|
||||
execute 'sign define PymodeD text=' . g:pymode_lint_docs_symbol . " texthl=String"
|
||||
execute 'sign define PymodeC text=' . g:pymode_lint_comment_symbol . " texthl=Comment"
|
||||
execute 'sign define PymodeR text=' . g:pymode_lint_visual_symbol . " texthl=Visual"
|
||||
execute 'sign define PymodeE text=' . g:pymode_lint_error_symbol . " texthl=Error"
|
||||
execute 'sign define PymodeI text=' . g:pymode_lint_info_symbol . " texthl=Info"
|
||||
execute 'sign define PymodeF text=' . g:pymode_lint_pyflakes_symbol . " texthl=Info"
|
||||
endif
|
||||
let self._sign_ids = []
|
||||
let self._next_id = 10000
|
||||
let self._messages = {}
|
||||
endfunction "}}}
|
||||
|
||||
|
||||
fun! g:PymodeSigns.refresh(loclist) "{{{
|
||||
if self.enabled()
|
||||
call self.clear()
|
||||
call self.place(a:loclist)
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
|
||||
fun! g:PymodeSigns.clear() "{{{
|
||||
let ids = copy(self._sign_ids)
|
||||
for i in ids
|
||||
execute "sign unplace " . i
|
||||
call remove(self._sign_ids, index(self._sign_ids, i))
|
||||
endfor
|
||||
endfunction "}}}
|
||||
|
||||
|
||||
fun! g:PymodeSigns.place(loclist) "{{{
|
||||
let seen = {}
|
||||
for issue in a:loclist._loclist
|
||||
if !has_key(seen, issue.lnum)
|
||||
let seen[issue.lnum] = 1
|
||||
call add(self._sign_ids, self._next_id)
|
||||
execute printf('sign place %d line=%d name=%s buffer=%d', self._next_id, issue.lnum, "Pymode".issue.type[0], issue.bufnr)
|
||||
let self._next_id += 1
|
||||
endif
|
||||
endfor
|
||||
endfunction "}}}
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
" DESC: Get debug information about pymode problem
|
||||
fun! pymode#troubleshooting#test() "{{{
|
||||
new
|
||||
setlocal buftype=nofile bufhidden=delete noswapfile nowrap
|
||||
|
||||
let os = "Unknown"
|
||||
if has('win16') || has('win32') || has('win64')
|
||||
let os = "Windows"
|
||||
else
|
||||
let os = substitute(system('uname'), "\n", "", "")
|
||||
endif
|
||||
|
||||
if !pymode#default('g:pymode_init', 1)
|
||||
call pymode#init(expand('<sfile>:p:h'), g:pymode_paths)
|
||||
call pymode#virtualenv#init()
|
||||
call pymode#breakpoint#init()
|
||||
endif
|
||||
|
||||
call append('0', ['Pymode diagnostic',
|
||||
\ '===================',
|
||||
\ 'VIM:' . v:version . ', OS: ' . os .', multi_byte:' . has('multi_byte') . ', pymode: ' . g:pymode_version . ', pymode-python: ' . g:pymode_python,
|
||||
\ ''])
|
||||
|
||||
if !exists('#filetypeplugin')
|
||||
call append('$', ['WARNING: ', 'Python-mode required :filetype plugin indent on', ''])
|
||||
endif
|
||||
|
||||
call append('$', ['+python: ' . has('python')])
|
||||
call append('$', ['+python3: ' . has('python3'), ''])
|
||||
|
||||
if g:pymode_python == 'disable'
|
||||
|
||||
if !has('python') && !has('python3')
|
||||
|
||||
call append('$', ['WARNING: Python-mode required vim compiled with +python or +python3.',
|
||||
\ '"lint, rope, run, doc, virtualenv" features disabled.', ''])
|
||||
|
||||
else
|
||||
|
||||
call append('$', ['WARNING: Python is disabled by `pymode_python` option.',
|
||||
\ '"lint, rope, run, doc, virtualenv" features disabled.', ''])
|
||||
|
||||
endif
|
||||
|
||||
else
|
||||
|
||||
call append('$', 'VIM python paths:')
|
||||
call append('$', '-----------------')
|
||||
PymodePython << EOF
|
||||
import vim
|
||||
vim.command('let l:output = %s' % repr(sys.path))
|
||||
EOF
|
||||
call append('$', output)
|
||||
call append('$', '')
|
||||
|
||||
endif
|
||||
|
||||
call append('$', 'Pymode variables:')
|
||||
call append('$', '-------------------')
|
||||
call append('$', 'let pymode = ' . string(g:pymode))
|
||||
call append('$', 'let pymode_breakpoint = ' . string(g:pymode_breakpoint))
|
||||
call append('$', 'let pymode_breakpoint_bind = ' . string(g:pymode_breakpoint_bind))
|
||||
call append('$', 'let pymode_doc = ' . string(g:pymode_doc))
|
||||
call append('$', 'let pymode_doc_bind = ' . string(g:pymode_doc_bind))
|
||||
call append('$', 'let pymode_folding = ' . string(g:pymode_folding))
|
||||
call append('$', 'let pymode_indent = ' . string(g:pymode_indent))
|
||||
call append('$', 'let pymode_lint = ' . string(g:pymode_lint))
|
||||
call append('$', 'let pymode_lint_checkers = ' . string(g:pymode_lint_checkers))
|
||||
call append('$', 'let pymode_lint_cwindow = ' . string(g:pymode_lint_cwindow))
|
||||
call append('$', 'let pymode_lint_ignore = ' . string(g:pymode_lint_ignore))
|
||||
call append('$', 'let pymode_lint_message = ' . string(g:pymode_lint_message))
|
||||
call append('$', 'let pymode_lint_on_fly = ' . string(g:pymode_lint_on_fly))
|
||||
call append('$', 'let pymode_lint_on_write = ' . string(g:pymode_lint_on_write))
|
||||
call append('$', 'let pymode_lint_select = ' . string(g:pymode_lint_select))
|
||||
call append('$', 'let pymode_lint_signs = ' . string(g:pymode_lint_signs))
|
||||
call append('$', 'let pymode_motion = ' . string(g:pymode_motion))
|
||||
call append('$', 'let pymode_options = ' . string(g:pymode_options))
|
||||
call append('$', 'let pymode_paths = ' . string(g:pymode_paths))
|
||||
call append('$', 'let pymode_quickfix_maxheight = ' . string(g:pymode_quickfix_maxheight))
|
||||
call append('$', 'let pymode_quickfix_minheight = ' . string(g:pymode_quickfix_minheight))
|
||||
call append('$', 'let pymode_rope = ' . string(g:pymode_rope))
|
||||
call append('$', 'let pymode_run = ' . string(g:pymode_run))
|
||||
call append('$', 'let pymode_run_bind = ' . string(g:pymode_run_bind))
|
||||
call append('$', 'let pymode_trim_whitespaces = ' . string(g:pymode_trim_whitespaces))
|
||||
call append('$', 'let pymode_virtualenv = ' . string(g:pymode_virtualenv))
|
||||
call append('$', 'let pymode_virtualenv_enabled = ' . string(g:pymode_virtualenv_enabled))
|
||||
call append('$', 'let pymode_virtualenv_path = ' . string(g:pymode_virtualenv_path))
|
||||
|
||||
endfunction "}}}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
" Support virtualenv
|
||||
"
|
||||
PymodePython from pymode.virtualenv import enable_virtualenv
|
||||
|
||||
fun! pymode#virtualenv#init() "{{{
|
||||
if !g:pymode_virtualenv || g:pymode_virtualenv_path == ""
|
||||
return
|
||||
endif
|
||||
|
||||
PymodePython enable_virtualenv()
|
||||
|
||||
endfunction "}}}
|
||||
|
||||
fun! pymode#virtualenv#activate(path) "{{{
|
||||
let g:pymode_virtualenv_path = a:path
|
||||
call pymode#virtualenv#init()
|
||||
endfunction "}}}
|
||||
Loading…
Add table
Add a link
Reference in a new issue