Skip to content

Commit 16c0a71

Browse files
committed
Working on 1.0.0
1 parent ba984dd commit 16c0a71

File tree

276 files changed

+19576
-3906
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

276 files changed

+19576
-3906
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
.vimrc
99
Gemfile.lock
1010
VimFlavor.lock
11+
_
1112
tags
1213
test.py
1314
todo.txt

Changelog.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
Changelog
22
=========
33

4+
## 2013-??-??
5+
-------------
6+
* Update indentation support
7+
* Python3 support
8+
* Variables changes:
9+
'pymode_run_key' -> 'pymode_run_bind'
10+
'pymode_lint_write' -> 'pymode_lint_on_write'
11+
'pymode_lint_onfly' -> 'pymode_lint_on_fly'
12+
'pymode_lint_message' -> 'pymode_lint_status'
13+
'pymode_lint_checker' -> 'pymode_lint_checkers'
14+
415
## 2013-10-29 0.6.19
516
--------------------
617
* Added `g:pymode_rope_autocomplete_map` option;

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ clean:
44

55
.PHONY: test
66
test:
7+
bundle install
78
rake test
89

910
.PHONY: pylama

after/ftplugin/python.vim

Lines changed: 44 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,49 @@
1-
" Fix omnifunc
2-
if g:pymode && g:pymode_rope && g:pymode_rope_vim_completion
3-
setlocal omnifunc=RopeOmni
1+
if !g:pymode
2+
finish
43
endif
54

6-
" Motion {{{
7-
8-
if !pymode#Default('g:pymode_motion', 1) || g:pymode_motion
9-
10-
nnoremap <buffer> ]] :<C-U>call pymode#motion#move('^\(class\\|def\)\s', '')<CR>
11-
nnoremap <buffer> [[ :<C-U>call pymode#motion#move('^\(class\\|def\)\s', 'b')<CR>
12-
nnoremap <buffer> ]C :<C-U>call pymode#motion#move('^\(class\\|def\)\s', '')<CR>
13-
nnoremap <buffer> [C :<C-U>call pymode#motion#move('^\(class\\|def\)\s', 'b')<CR>
14-
nnoremap <buffer> ]M :<C-U>call pymode#motion#move('^\s*def\s', '')<CR>
15-
nnoremap <buffer> [M :<C-U>call pymode#motion#move('^\s*def\s', 'b')<CR>
16-
17-
onoremap <buffer> ]] :<C-U>call pymode#motion#move('^\(class\\|def\)\s', '')<CR>
18-
onoremap <buffer> [[ :<C-U>call pymode#motion#move('^\(class\\|def\)\s', 'b')<CR>
19-
onoremap <buffer> ]C :<C-U>call pymode#motion#move('^\(class\\|def\)\s', '')<CR>
20-
onoremap <buffer> [C :<C-U>call pymode#motion#move('^\(class\\|def\)\s', 'b')<CR>
21-
onoremap <buffer> ]M :<C-U>call pymode#motion#move('^\s*def\s', '')<CR>
22-
onoremap <buffer> [M :<C-U>call pymode#motion#move('^\s*def\s', 'b')<CR>
23-
24-
vnoremap <buffer> ]] :call pymode#motion#vmove('^\(class\\|def\)\s', '')<CR>
25-
vnoremap <buffer> [[ :call pymode#motion#vmove('^\(class\\|def\)\s', 'b')<CR>
26-
vnoremap <buffer> ]M :call pymode#motion#vmove('^\s*def\s', '')<CR>
27-
vnoremap <buffer> [M :call pymode#motion#vmove('^\s*def\s', 'b')<CR>
28-
29-
onoremap <buffer> C :<C-U>call pymode#motion#select('^\s*class\s', 0)<CR>
30-
onoremap <buffer> aC :<C-U>call pymode#motion#select('^\s*class\s', 0)<CR>
31-
onoremap <buffer> iC :<C-U>call pymode#motion#select('^\s*class\s', 1)<CR>
32-
vnoremap <buffer> aC :<C-U>call pymode#motion#select('^\s*class\s', 0)<CR>
33-
vnoremap <buffer> iC :<C-U>call pymode#motion#select('^\s*class\s', 1)<CR>
34-
35-
onoremap <buffer> M :<C-U>call pymode#motion#select('^\s*def\s', 0)<CR>
36-
onoremap <buffer> aM :<C-U>call pymode#motion#select('^\s*def\s', 0)<CR>
37-
onoremap <buffer> iM :<C-U>call pymode#motion#select('^\s*def\s', 1)<CR>
38-
vnoremap <buffer> aM :<C-U>call pymode#motion#select('^\s*def\s', 0)<CR>
39-
vnoremap <buffer> iM :<C-U>call pymode#motion#select('^\s*def\s', 1)<CR>
5+
if g:pymode_motion
6+
7+
nnoremap <buffer> ]] :<C-U>call pymode#motion#move('^\(class\\|def\)\s', '')<CR>
8+
nnoremap <buffer> [[ :<C-U>call pymode#motion#move('^\(class\\|def\)\s', 'b')<CR>
9+
nnoremap <buffer> ]C :<C-U>call pymode#motion#move('^\(class\\|def\)\s', '')<CR>
10+
nnoremap <buffer> [C :<C-U>call pymode#motion#move('^\(class\\|def\)\s', 'b')<CR>
11+
nnoremap <buffer> ]M :<C-U>call pymode#motion#move('^\s*def\s', '')<CR>
12+
nnoremap <buffer> [M :<C-U>call pymode#motion#move('^\s*def\s', 'b')<CR>
13+
14+
onoremap <buffer> ]] :<C-U>call pymode#motion#move('^\(class\\|def\)\s', '')<CR>
15+
onoremap <buffer> [[ :<C-U>call pymode#motion#move('^\(class\\|def\)\s', 'b')<CR>
16+
onoremap <buffer> ]C :<C-U>call pymode#motion#move('^\(class\\|def\)\s', '')<CR>
17+
onoremap <buffer> [C :<C-U>call pymode#motion#move('^\(class\\|def\)\s', 'b')<CR>
18+
onoremap <buffer> ]M :<C-U>call pymode#motion#move('^\s*def\s', '')<CR>
19+
onoremap <buffer> [M :<C-U>call pymode#motion#move('^\s*def\s', 'b')<CR>
20+
21+
vnoremap <buffer> ]] :call pymode#motion#vmove('^\(class\\|def\)\s', '')<CR>
22+
vnoremap <buffer> [[ :call pymode#motion#vmove('^\(class\\|def\)\s', 'b')<CR>
23+
vnoremap <buffer> ]M :call pymode#motion#vmove('^\s*def\s', '')<CR>
24+
vnoremap <buffer> [M :call pymode#motion#vmove('^\s*def\s', 'b')<CR>
25+
26+
onoremap <buffer> C :<C-U>call pymode#motion#select('^\s*class\s', 0)<CR>
27+
onoremap <buffer> aC :<C-U>call pymode#motion#select('^\s*class\s', 0)<CR>
28+
onoremap <buffer> iC :<C-U>call pymode#motion#select('^\s*class\s', 1)<CR>
29+
vnoremap <buffer> aC :<C-U>call pymode#motion#select('^\s*class\s', 0)<CR>
30+
vnoremap <buffer> iC :<C-U>call pymode#motion#select('^\s*class\s', 1)<CR>
31+
32+
onoremap <buffer> M :<C-U>call pymode#motion#select('^\s*def\s', 0)<CR>
33+
onoremap <buffer> aM :<C-U>call pymode#motion#select('^\s*def\s', 0)<CR>
34+
onoremap <buffer> iM :<C-U>call pymode#motion#select('^\s*def\s', 1)<CR>
35+
vnoremap <buffer> aM :<C-U>call pymode#motion#select('^\s*def\s', 0)<CR>
36+
vnoremap <buffer> iM :<C-U>call pymode#motion#select('^\s*def\s', 1)<CR>
4037
38+
endif
39+
40+
if g:pymode_rope && g:pymode_rope_completion
41+
42+
setlocal omnifunc=pymode#rope#completions
43+
44+
exe "inoremap <silent> <buffer> " . g:pymode_rope_completion_bind . " <C-R>=pymode#rope#complete()<CR>"
45+
if tolower(g:pymode_rope_completion_bind) == '<c-space>'
46+
exe "inoremap <silent> <buffer> <Nul> <C-R>=pymode#rope#complete()<CR>"
4147
endif
4248

43-
" }}}
49+
end

after/indent/python.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ setlocal shiftwidth=4
1010
setlocal shiftround
1111
setlocal expandtab
1212
setlocal autoindent
13-
setlocal indentexpr=pymode#indent#Indent(v:lnum)
13+
setlocal indentexpr=pymode#indent#get_indent(v:lnum)
1414
setlocal indentkeys=!^F,o,O,<:>,0),0],0},=elif,=except

autoload/pymode.vim

Lines changed: 60 additions & 150 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,49 @@
1-
" Python-mode base functions
1+
" Pymode core functions
22

3-
4-
fun! pymode#Default(name, default) "{{{
5-
" DESC: Set default value if it not exists
6-
"
3+
" DESC: Check variable and set default value if it not exists
4+
fun! pymode#default(name, default) "{{{
75
if !exists(a:name)
86
let {a:name} = a:default
97
return 0
108
endif
119
return 1
1210
endfunction "}}}
1311

12+
" DESC: Import python libs
13+
fun! pymode#init(plugin_root, paths) "{{{
1414

15-
fun! pymode#Option(name) "{{{
16-
17-
let name = 'b:pymode_' . a:name
18-
if exists(name)
19-
return eval(name)
15+
if g:pymode_python == 'disable'
16+
if g:pymode_warning
17+
call pymode#error("Pymode requires vim compiled with +python. Most of features will be disabled.")
18+
endif
19+
return
2020
endif
2121

22-
let name = 'g:pymode_' . a:name
23-
return eval(name)
22+
PymodePython import sys, vim
23+
PymodePython sys.path.insert(0, vim.eval('a:plugin_root'))
24+
PymodePython sys.path = vim.eval('a:paths') + sys.path
25+
26+
endfunction "}}}
2427

28+
" DESC: Show wide message
29+
fun! pymode#wide_message(msg) "{{{
30+
let x=&ruler | let y=&showcmd
31+
set noruler noshowcmd
32+
redraw
33+
echohl Debug | echo strpart("[Pymode] " . a:msg, 0, &columns-1) | echohl none
34+
let &ruler=x | let &showcmd=y
2535
endfunction "}}}
2636

37+
" DESC: Show error
38+
fun! pymode#error(msg) "{{{
39+
execute "normal \<Esc>"
40+
echohl ErrorMsg
41+
echomsg "[Pymode]: error: " . a:msg
42+
echohl None
43+
endfunction "}}}
2744

28-
fun! pymode#QuickfixOpen(onlyRecognized, holdCursor, maxHeight, minHeight, jumpError) "{{{
29-
" DESC: Open quickfix window
30-
"
45+
" DESC: Open quickfix window
46+
fun! pymode#quickfix_open(onlyRecognized, holdCursor, maxHeight, minHeight, jumpError) "{{{
3147
let numErrors = len(filter(getqflist(), 'v:val.valid'))
3248
let numOthers = len(getqflist()) - numErrors
3349
if numErrors > 0 || (!a:onlyRecognized && numOthers > 0)
@@ -43,153 +59,47 @@ fun! pymode#QuickfixOpen(onlyRecognized, holdCursor, maxHeight, minHeight, jumpE
4359
endif
4460
redraw
4561
if numOthers > 0
46-
echo printf('Quickfix: %d(+%d)', numErrors, numOthers)
62+
call pymode#wide_message(printf('Quickfix: %d(+%d)', numErrors, numOthers))
4763
else
48-
echo printf('Quickfix: %d', numErrors)
49-
endif
50-
endfunction "}}}
51-
52-
53-
fun! pymode#PlaceSigns(bnum) "{{{
54-
" DESC: Place error signs
55-
"
56-
if has('signs')
57-
call pymode#Default('b:pymode_signs', [])
58-
59-
for item in b:pymode_signs
60-
execute printf('sign unplace %d buffer=%d', item.lnum, item.bufnr)
61-
endfor
62-
let b:pymode_signs = []
63-
64-
if !pymode#Default("g:pymode_lint_signs_always_visible", 0) || g:pymode_lint_signs_always_visible
65-
call RopeShowSignsRulerIfNeeded()
66-
endif
67-
68-
for item in filter(getqflist(), 'v:val.bufnr != ""')
69-
call add(b:pymode_signs, item)
70-
execute printf('sign place %d line=%d name=%s buffer=%d', item.lnum, item.lnum, "Pymode".item.type, item.bufnr)
71-
endfor
72-
73-
endif
74-
endfunction "}}}
75-
76-
77-
fun! pymode#CheckProgram(name, append) "{{{
78-
" DESC: Check program is executable or redifined by user.
79-
"
80-
let name = 'g:' . a:name
81-
if pymode#Default(name, a:name)
82-
return 1
83-
endif
84-
if !executable(eval(l:name))
85-
echoerr "Can't find '".eval(name)."'. Please set ".name .", or extend $PATH, ".a:append
86-
return 0
64+
call pymode#wide_message(printf('Quickfix: %d', numErrors))
8765
endif
88-
return 1
8966
endfunction "}}}
9067

91-
92-
fun! pymode#TempBuffer() "{{{
93-
" DESC: Open temp buffer.
94-
"
95-
pclose | botright 8new
68+
" DESC: Open temp buffer.
69+
fun! pymode#tempbuffer_open(name) "{{{
70+
pclose
71+
exe "botright 8new " . a:name
9672
setlocal buftype=nofile bufhidden=delete noswapfile nowrap previewwindow
9773
redraw
9874
endfunction "}}}
9975

100-
101-
fun! pymode#ShowStr(str) "{{{
102-
" DESC: Open temp buffer with `str`.
103-
"
104-
let g:pymode_curbuf = bufnr("%")
105-
call pymode#TempBuffer()
106-
put! =a:str
107-
wincmd p
108-
redraw
109-
endfunction "}}}
110-
111-
112-
fun! pymode#ShowCommand(cmd) "{{{
113-
" DESC: Run command and open temp buffer with result
114-
"
115-
call pymode#TempBuffer()
116-
try
117-
silent exec 'r!' . a:cmd
118-
catch /.*/
119-
close
120-
echoerr 'Command fail: '.a:cmd
121-
endtry
122-
redraw
123-
normal gg
124-
wincmd p
125-
endfunction "}}}
126-
127-
128-
fun! pymode#WideMessage(msg) "{{{
129-
" DESC: Show wide message
130-
131-
let x=&ruler | let y=&showcmd
132-
set noruler noshowcmd
133-
redraw
134-
echohl Debug | echo strpart(a:msg, 0, &columns-1) | echohl none
135-
let &ruler=x | let &showcmd=y
136-
endfunction "}}}
137-
138-
139-
fun! pymode#BlockStart(lnum, ...) "{{{
140-
let pattern = a:0 ? a:1 : '^\s*\(@\|class\s.*:\|def\s\)'
141-
let lnum = a:lnum + 1
142-
let indent = 100
143-
while lnum
144-
let lnum = prevnonblank(lnum - 1)
145-
let test = indent(lnum)
146-
let line = getline(lnum)
147-
if line =~ '^\s*#' " Skip comments
148-
continue
149-
elseif !test " Zero-level regular line
150-
return lnum
151-
elseif test >= indent " Skip deeper or equal lines
152-
continue
153-
" Indent is strictly less at this point: check for def/class
154-
elseif line =~ pattern && line !~ '^\s*@'
155-
return lnum
156-
endif
157-
let indent = indent(lnum)
158-
endwhile
159-
return 0
160-
endfunction "}}}
161-
162-
163-
fun! pymode#BlockEnd(lnum, ...) "{{{
164-
let indent = a:0 ? a:1 : indent(a:lnum)
165-
let lnum = a:lnum
166-
while lnum
167-
let lnum = nextnonblank(lnum + 1)
168-
if getline(lnum) =~ '^\s*#' | continue
169-
elseif lnum && indent(lnum) <= indent
170-
return lnum - 1
171-
endif
172-
endwhile
173-
return line('$')
76+
" DESC: Remove unused whitespaces
77+
fun! pymode#trim_whitespaces() "{{{
78+
let cursor_pos = getpos('.')
79+
silent! %s/\s\+$//
80+
call setpos('.', cursor_pos)
17481
endfunction "}}}
17582

17683

177-
fun! pymode#Modeline() "{{{
178-
let modeline = getline(prevnonblank('$'))
179-
if modeline =~ '^#\s\+pymode:'
180-
for ex in split(modeline, ':')[1:]
181-
let [name, value] = split(ex, '=')
182-
let {'b:pymode_'.name} = value
183-
endfor
84+
fun! pymode#save() "{{{
85+
if &modifiable && &modified
86+
try
87+
noautocmd write
88+
catch /E212/
89+
call pymode#error("File modified and I can't save it. Cancel code checking.")
90+
return 0
91+
endtry
18492
endif
93+
return 1
18594
endfunction "}}}
18695

187-
188-
fun! pymode#TrimWhiteSpace() "{{{
189-
let cursor_pos = getpos('.')
190-
silent! %s/\s\+$//
191-
call setpos('.', cursor_pos)
96+
fun! pymode#reload_buf_by_nr(nr) "{{{
97+
let cur = bufnr("")
98+
try
99+
exe "buffer " . a:nr
100+
catch /E86/
101+
return
102+
endtry
103+
exe "e!"
104+
exe "buffer " . cur
192105
endfunction "}}}
193-
194-
195-
" vim: fdm=marker:fdl=0

0 commit comments

Comments
 (0)