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