-
-
Notifications
You must be signed in to change notification settings - Fork 767
Expand file tree
/
Copy pathdebug.vim
More file actions
67 lines (65 loc) · 2.45 KB
/
debug.vim
File metadata and controls
67 lines (65 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
" Set debugging functions.
" DESC: Get debug information about pymode problem.
fun! pymode#debug#sysinfo() "{{{
" OS info. {{{
let l:os_name = "Unknown"
if has('win16') || has('win32') || has('win64')
let l:os_name = "Windows"
else
let l:os_name = substitute(system('uname'), "\n", "", "")
endif
call pymode#debug("Operating system: " . l:os_name)
" }}}
" Loaded scripts info. {{{
call pymode#debug("Scriptnames:")
let l:scriptnames_var = execute('scriptnames')
" }}}
" Variables info. {{{
" Drop verbose file temporarily to prevent the 'let' from showing up.
let l:tmp = &verbosefile
set verbosefile=
let l:all_variables = filter(
\ split(execute('let', 'silent!'), '\n'),
\ 'v:val =~ "^pymode"')
let &verbosefile = l:tmp
" NOTE: echom does not display multiline messages. Thus a for loop is
" needed.
call pymode#debug("Pymode variables:")
for pymodevar in sort(l:all_variables)
echom pymodevar
endfor
" }}}
" Git commit info. {{{
" Find in the scriptnames the first occurence of 'python-mode'. Then parse
" the result outputting its path. This is in turn fed into the git command.
call pymode#debug("Git commit: ")
let l:pymode_folder = substitute(
\ filter(
\ split(l:scriptnames_var, '\n'),
\ 'v:val =~ "/python-mode/"')[0],
\ '\(^\s\+[0-9]\+:\s\+\)\([/~].*python-mode\/\)\(.*\)',
\ '\2',
\ '')
let l:git_head_sha1 = system('git -C ' . expand(l:pymode_folder). ' rev-parse HEAD ' )
echom join(filter(split(l:git_head_sha1, '\zs'), 'v:val =~? "[0-9A-Fa-f]"'), '')
" }}}
" Git submodules status. {{{
call pymode#debug("Git submodule status:")
let l:git_submodule_status = system('git -C ' . expand(l:pymode_folder). ' submodule status')
for submodule in split(l:git_submodule_status, '\n')
echom submodule
endfor
" }}}
call pymode#debug("End of pymode#debug#sysinfo")
endfunction "}}}
" DESC: Define debug folding function.
function! pymode#debug#foldingexpr(lnum) "{{{
let l:get_folding_result = pymode#folding#foldcase(a:lnum)
" NOTE: the 'has folding:' expression is special in the pymode#debug.
call pymode#debug(
\ 'line ' . a:lnum
\ . ' has folding: ' . l:get_folding_result['foldlevel']
\ . ' with foldcase ' . l:get_folding_result['foldcase'])
return l:get_folding_result['foldlevel']
endfunction
" }}}