mirror of
https://github.com/gryf/.vim.git
synced 2026-02-12 14:05:44 +01:00
Added pmx specific stuff
This commit is contained in:
12
bundle_pmx/compiler/autopylint.vim
Normal file
12
bundle_pmx/compiler/autopylint.vim
Normal file
@@ -0,0 +1,12 @@
|
||||
" Vim compiler file for Python
|
||||
" Compiler: Static code checking tool for Python
|
||||
" Maintainer: Roman 'gryf' Dobosz
|
||||
" Last Change: 2010-09-12
|
||||
" Version: 1.0
|
||||
if exists("current_compiler")
|
||||
finish
|
||||
endif
|
||||
|
||||
let current_compiler = "autopylint"
|
||||
CompilerSet makeprg=$VIM\\bin\\autopylint.py\ -p8\ %:p
|
||||
CompilerSet efm=%f\|\ %t\|\ %l\|\ %c\|\ %m,%f\|\ %t\|\ %l\|\ %m
|
||||
69
bundle_pmx/ftplugin/python/common.vim
Normal file
69
bundle_pmx/ftplugin/python/common.vim
Normal file
@@ -0,0 +1,69 @@
|
||||
setlocal cinkeys-=0#
|
||||
setlocal indentkeys-=0#
|
||||
setlocal expandtab
|
||||
setlocal foldlevel=100
|
||||
setlocal foldmethod=indent
|
||||
setlocal list
|
||||
setlocal noautoindent
|
||||
setlocal smartindent
|
||||
setlocal cinwords=if,elif,else,for,while,try,except,finally,def,class,with
|
||||
setlocal smarttab
|
||||
setlocal textwidth=78
|
||||
setlocal colorcolumn=+1
|
||||
" overwrite status line
|
||||
setlocal statusline=%<%F\ %{TagInStatusLine()}\ %h%m%r%=%(%l,%c%V%)\ %3p%%
|
||||
|
||||
set wildignore+=*.pyc
|
||||
|
||||
inoremap # X<BS>#
|
||||
|
||||
"set ofu=syntaxcomplete#Complete
|
||||
|
||||
"autocmd FileType python setlocal omnifunc=pysmell#Complete
|
||||
let python_highlight_all=1
|
||||
|
||||
"I don't want to have pyflakes errors in qfix, it interfering with Pep8/Pylint
|
||||
let g:pyflakes_use_quickfix = 0
|
||||
|
||||
"Load views for py files
|
||||
autocmd BufWinLeave *.py mkview
|
||||
autocmd BufWinEnter *.py silent loadview
|
||||
|
||||
compiler autopylint
|
||||
|
||||
if !exists('*<SID>PyLintBuf')
|
||||
function <SID>PyLintBuf(save_and_close)
|
||||
echohl Statement
|
||||
echo "Running pylint (ctrl-c to cancel) ..."
|
||||
echohl Normal
|
||||
let filename = expand('%:p')
|
||||
let cmd = expand('$VIM') . '\bin\autopylint.py -8 "' . filename . '"'
|
||||
|
||||
if has('win32') || has('win64')
|
||||
let cmd = 'cmd /c ' . cmd
|
||||
endif
|
||||
|
||||
exec "bel silent new " . filename . ".lint"
|
||||
exec "silent! read! " . cmd
|
||||
if a:save_and_close != 0
|
||||
exec "w!"
|
||||
exec "bd"
|
||||
endif
|
||||
endfunction
|
||||
command -bang -nargs=? PyLintBuf call <SID>PyLintBuf(<bang>0)
|
||||
endif
|
||||
map <F6> :PyLintBuf<cr>
|
||||
|
||||
finish "end here. all below is just for the record.
|
||||
|
||||
" Pylint function, which can be optionally mapped to some keys. Currently
|
||||
" not used.
|
||||
if !exists('*<SID>runPyLint')
|
||||
function <SID>runPyLint()
|
||||
echohl Statement
|
||||
echo "Running pylint (ctrl-c to cancel) ..."
|
||||
echohl Normal
|
||||
:Pylint
|
||||
endfunction
|
||||
endif
|
||||
|
||||
55
bundle_pmx/ftplugin/python/pep8.vim
Normal file
55
bundle_pmx/ftplugin/python/pep8.vim
Normal file
@@ -0,0 +1,55 @@
|
||||
if exists("b:did_pdpep8_functions")
|
||||
finish " only load once
|
||||
else
|
||||
let b:did_pdpep8_functions = 1
|
||||
endif
|
||||
|
||||
if !exists('*s:pdPep8')
|
||||
function s:pdPep8()
|
||||
set lazyredraw
|
||||
" Close any existing cwindows.
|
||||
cclose
|
||||
let l:grepformat_save = &grepformat
|
||||
let l:grepprogram_save = &grepprg
|
||||
set grepformat&vim
|
||||
set grepformat&vim
|
||||
let &grepformat = '%f:%l:%m'
|
||||
let &grepprg = 'c:\\Python27\\Scripts\\pep8.exe --repeat --ignore=E111'
|
||||
if &readonly == 0 | update | endif
|
||||
silent! grep! %
|
||||
let &grepformat = l:grepformat_save
|
||||
let &grepprg = l:grepprogram_save
|
||||
let l:mod_total = 0
|
||||
let l:win_count = 1
|
||||
" Determine correct window height
|
||||
windo let l:win_count = l:win_count + 1
|
||||
if l:win_count <= 2 | let l:win_count = 4 | endif
|
||||
windo let l:mod_total = l:mod_total + winheight(0)/l:win_count |
|
||||
\ execute 'resize +'.l:mod_total
|
||||
" Open cwindow
|
||||
execute 'belowright copen '.l:mod_total
|
||||
nnoremap <buffer> <silent> c :cclose<CR>
|
||||
set nolazyredraw
|
||||
redraw!
|
||||
endfunction
|
||||
command! Pep8 call s:pdPep8()
|
||||
endif
|
||||
|
||||
if !exists('*s:pdPep8Buf')
|
||||
function s:pdPep8Buf()
|
||||
echohl Statement
|
||||
echo "Running pep8 (ctrl-c to cancel) ..."
|
||||
echohl Normal
|
||||
let file = expand('%:p')
|
||||
"let cmd = 'pylint --reports=n --output-format=text "' . file . '"'
|
||||
let cmd = 'c:\\Python26\\Scripts\\pep8.exe "' . file . '"'
|
||||
|
||||
if has('win32') || has('win64')
|
||||
let cmd = 'cmd /c "' . cmd . '"'
|
||||
endif
|
||||
|
||||
exec "bel silent new " . file . ".lint"
|
||||
exec "silent! read! " . cmd
|
||||
endfunction
|
||||
command! Pep8buf call s:pdPep8Buf()
|
||||
endif
|
||||
90
bundle_pmx/snippets/pmx.snippets
Normal file
90
bundle_pmx/snippets/pmx.snippets
Normal file
@@ -0,0 +1,90 @@
|
||||
|
||||
snippet edbg
|
||||
import sys
|
||||
pydevdPath = r"c:\eclipse\plugins\org.python.pydev.debug_2.0.0.2011040403\pysrc"
|
||||
if not pydevdPath in sys.path:
|
||||
sys.path.append(pydevdPath)
|
||||
import pydevd
|
||||
pydevd.settrace()
|
||||
snippet utimport
|
||||
import pdunittest.common.pmxunittest as pmxunittest
|
||||
|
||||
snippet classt
|
||||
class ${1:Foo}Tests(pmxunittest.TestCase):
|
||||
"""
|
||||
Tests for class $1 Tests
|
||||
"""
|
||||
def setUp(self):
|
||||
"""
|
||||
TODO: Setup test
|
||||
"""
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
"""
|
||||
TODO: Cleanup test
|
||||
"""
|
||||
pass
|
||||
|
||||
def test_${2:method}(self):
|
||||
"""
|
||||
Test $2 method of class $1
|
||||
"""
|
||||
${3:pass}
|
||||
snippet runt
|
||||
def run():
|
||||
"""
|
||||
runs unit tests in "interactive" mode
|
||||
"""
|
||||
suite1 = pmxunittest.TestLoader().loadTestsFromTestCase(${1:ClassTests})
|
||||
suite = pmxunittest.TestSuite([suite1])
|
||||
ret = pmxunittest.TextTestRunner().run(suite)
|
||||
return ret
|
||||
|
||||
if __name__ == '__main__':
|
||||
run()
|
||||
|
||||
# How to run manually:
|
||||
#
|
||||
# C:\> cd L:\runtime\pdpyapp
|
||||
# C:\> L:
|
||||
# L:\runtime\pdpyapp> startapp pdunittest\${2:`expand("%:t:r")`}
|
||||
#
|
||||
# Use parameters:
|
||||
# -c (--changes) to check db changes after test run
|
||||
# -c -r (--report) to gather detailed html report additionally
|
||||
|
||||
tested_modules = ['${3:module}'] # modules referenced by the test
|
||||
automatic_run = ${4:True} # should it be run automatically?
|
||||
execution_time = 0.000 # estimated time of test ru
|
||||
snippet deft
|
||||
def test_${1:fname}(self):
|
||||
"""
|
||||
Test for $1
|
||||
"""
|
||||
${2:pass}
|
||||
snippet trace
|
||||
import traceback
|
||||
print "", 80*"-"
|
||||
for _line in traceback.format_stack():
|
||||
print _line.strip()
|
||||
snippet pdlog
|
||||
from PDLOG import PDLOG
|
||||
PDLOG(${1:31337}, ${2:"msg"})
|
||||
snippet head
|
||||
"""
|
||||
Project: 8202 / EBR
|
||||
Description: ${2:description}
|
||||
Created: ${3:00}.${4:2010}, ${5:author}
|
||||
|
||||
$RCSfile: ebrfoo.py,v $
|
||||
$Source: /var/cvs/pmx/pylib/ebrfoo.py,v $
|
||||
$Date: 2010/10/06 14:24:13 $
|
||||
$Author: foo $
|
||||
$Revision: 1.0 $
|
||||
|
||||
(c) Copyright ${6:2010} Rockwell Automation,
|
||||
40-382 Katowice, Poland
|
||||
"""
|
||||
vcsid = "$Header: /var/cvs/pmx/pylib/ebrfoo.py,v 1.1 2009/10/06 14:24:13 foo Exp $"
|
||||
${7}
|
||||
88
bundle_pmx/snippets/spyce.snippets
Normal file
88
bundle_pmx/snippets/spyce.snippets
Normal file
@@ -0,0 +1,88 @@
|
||||
snippet #!
|
||||
#!/usr/bin/python
|
||||
|
||||
snippet imp
|
||||
import ${1:module}
|
||||
# Module Docstring
|
||||
snippet docs
|
||||
'''
|
||||
File: ${1:`Filename('$1.py', 'foo.py')`}
|
||||
Author: ${2:`g:snips_author`}
|
||||
Description: ${3}
|
||||
'''
|
||||
snippet wh
|
||||
while ${1:condition}:
|
||||
${2:# code...}
|
||||
snippet for
|
||||
for ${1:needle} in ${2:haystack}:
|
||||
${3:# code...}
|
||||
# New Class
|
||||
snippet cl
|
||||
class ${1:ClassName}(${2:object}):
|
||||
"""${3:docstring for $1}"""
|
||||
def __init__(self, ${4:arg}):
|
||||
${5:super($1, self).__init__()}
|
||||
self.$4 = $4
|
||||
${6}
|
||||
# New Function
|
||||
snippet def
|
||||
def ${1:fname}(${2:`indent('.') ? 'self' : ''`}):
|
||||
"""${3:docstring for $1}"""
|
||||
${4:pass}
|
||||
snippet deff
|
||||
def ${1:fname}(${2:`indent('.') ? 'self' : ''`}):
|
||||
${3}
|
||||
# New Method
|
||||
snippet defs
|
||||
def ${1:mname}(self, ${2:arg}):
|
||||
${3:pass}
|
||||
# New Property
|
||||
snippet property
|
||||
def ${1:foo}():
|
||||
doc = "${2:The $1 property.}"
|
||||
def fget(self):
|
||||
${3:return self._$1}
|
||||
def fset(self, value):
|
||||
${4:self._$1 = value}
|
||||
# Lambda
|
||||
snippet ld
|
||||
${1:var} = lambda ${2:vars} : ${3:action}
|
||||
snippet .
|
||||
self.
|
||||
snippet try Try/Except
|
||||
try:
|
||||
${1:pass}
|
||||
except ${2:Exception}, ${3:e}:
|
||||
${4:raise $3}
|
||||
snippet try Try/Except/Else
|
||||
try:
|
||||
${1:pass}
|
||||
except ${2:Exception}, ${3:e}:
|
||||
${4:raise $3}
|
||||
else:
|
||||
${5:pass}
|
||||
snippet try Try/Except/Finally
|
||||
try:
|
||||
${1:pass}
|
||||
except ${2:Exception}, ${3:e}:
|
||||
${4:raise $3}
|
||||
finally:
|
||||
${5:pass}
|
||||
snippet try Try/Except/Else/Finally
|
||||
try:
|
||||
${1:pass}
|
||||
except ${2:Exception}, ${3:e}:
|
||||
${4:raise $3}
|
||||
else:
|
||||
${5:pass}
|
||||
finally:
|
||||
${6:pass}
|
||||
# if __name__ == '__main__':
|
||||
snippet ifmain
|
||||
if __name__ == '__main__':
|
||||
${1:main()}
|
||||
# __magic__
|
||||
snippet _
|
||||
__${1:init}__${2}
|
||||
snippet dbg
|
||||
import pywin.debugger; pywin.debugger.set_trace()
|
||||
Reference in New Issue
Block a user