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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
|
" Debug/feedback helpers.
function! neomake#debug#pprint(d, ...) abort
return call('s:pprint', [a:d] + a:000)
endfunction
function! s:pprint(v, ...) abort
let indent = a:0 ? a:1 : ''
if type(a:v) ==# type({})
if empty(a:v)
return '{}'
endif
let r = "{\n"
for [k, l:V] in items(a:v)
let r .= printf("%s %s: %s,\n",
\ indent,
\ string(k),
\ s:pprint(neomake#utils#fix_self_ref(V), indent . ' '))
unlet V " old-vim
endfor
let r .= indent.'}'
return r
elseif type(a:v) ==# type([])
if empty(a:v)
return '[]'
endif
let r = '['."\n".join(map(copy(a:v), 'indent." ".s:pprint(v:val, indent." ")'), ",\n").",\n".indent.']'
return r
endif
return string(a:v)
endfunction
function! neomake#debug#validate_maker(maker) abort
let issues = {'errors': [], 'warnings': []}
if has_key(a:maker, 'process_json') && has_key(a:maker, 'process_output')
let issues.warnings += ['maker has process_json and process_output, but only process_json will be used.']
let check_process = ['process_json']
else
let check_process = ['process_json', 'process_output']
endif
for f in check_process
if has_key(a:maker, f)
if has_key(a:maker, 'mapexpr')
let issues.warnings += [printf(
\ 'maker has mapexpr, but only %s will be used.',
\ f)]
endif
if has_key(a:maker, 'postprocess')
let issues.warnings += [printf(
\ 'maker has postprocess, but only %s will be used.',
\ f)]
endif
if has_key(a:maker, 'errorformat')
let issues.warnings += [printf(
\ 'maker has errorformat, but only %s will be used.',
\ f)]
endif
endif
endfor
try
let maker = neomake#core#instantiate_maker(a:maker, {}, 0)
if !executable(maker.exe)
let t = get(maker, 'auto_enabled', 0) ? 'warnings' : 'errors'
let issues[t] += [printf("maker's exe (%s) is not executable.", maker.exe)]
endif
catch /^Neomake: /
let issues.errors += [substitute(v:exception, '^Neomake: ', '', '').'.']
endtry
if has_key(a:maker, 'name')
if a:maker.name !~# g:neomake#core#valid_maker_name_pattern
call add(issues['errors'], printf(
\ 'Invalid maker name: %s (should match %s)',
\ string(a:maker.name),
\ string(g:neomake#core#valid_maker_name_pattern)))
endif
endif
return issues
endfunction
" Optional arg: ft
function! s:get_makers_info(...) abort
let maker_names = call('neomake#GetEnabledMakers', a:000)
if empty(maker_names)
return ['None.']
endif
let maker_defaults = g:neomake#config#_defaults['maker_defaults']
let r = []
for maker_name in maker_names
let maker = call('neomake#GetMaker', [maker_name] + a:000)
let r += [' - '.maker.name]
let r += map(s:get_maker_info(maker, maker_defaults), "' '.v:val")
endfor
return r
endfunction
function! s:get_maker_info(maker, ...) abort
let maker_defaults = a:0 ? a:1 : {}
let maker = a:maker
let r = []
for [k, l:V] in sort(copy(items(maker)))
if k !=# 'name' && k !=# 'ft' && k !~# '^_'
if !has_key(maker_defaults, k)
\ || type(V) != type(maker_defaults[k])
\ || V !=# maker_defaults[k]
let r += [' - '.k.': '.string(V)]
endif
endif
unlet V " vim73
endfor
let issues = neomake#debug#validate_maker(maker)
if !empty(issues)
for type in sort(copy(keys(issues)))
let items = issues[type]
if !empty(items)
let r += [' - '.toupper(type) . ':']
for issue in items
let r += [' - ' . issue]
endfor
endif
endfor
endif
if type(maker.exe) == type('') && executable(maker.exe)
let version_arg = get(maker, 'version_arg', '--version')
let exe = exists('*exepath') ? exepath(maker.exe) : maker.exe
let version_output = neomake#compat#systemlist([exe, version_arg])
if empty(version_output)
let version_output = [printf(
\ 'failed to get version information (%s)',
\ v:shell_error)]
endif
let r += [printf(' - version information (%s %s): %s',
\ exe,
\ version_arg,
\ join(version_output, "\n "))]
endif
return r
endfunction
function! s:get_fts_with_makers() abort
return neomake#compat#uniq(sort(map(split(globpath(escape(&runtimepath, ' '),
\ 'autoload/neomake/makers/ft/*.vim'), "\n"),
\ 'fnamemodify(v:val, ":t:r")')))
endfunction
function! neomake#debug#get_maker_info(maker_name) abort
let source = ''
let maker = neomake#get_maker_by_name(a:maker_name, &filetype)
if empty(maker)
let maker = neomake#get_maker_by_name(a:maker_name)
if empty(maker)
let fts = filter(s:get_fts_with_makers(), 'v:val != &filetype')
for ft in fts
let maker = neomake#get_maker_by_name(a:maker_name, ft)
if !empty(maker)
let source = 'filetype '.ft
break
endif
endfor
else
let source = 'project maker'
endif
endif
if empty(maker)
call neomake#log#error(printf('Maker not found: %s.', a:maker_name))
return []
endif
let maker = neomake#create_maker_object(maker, &filetype)
return [maker.name . (empty(source) ? '' : ' ('.source.')')]
\ + s:get_maker_info(maker)
endfunction
function! neomake#debug#display_info(...) abort
let bang = a:0 ? a:1 : 0
if a:0 > 1
let maker_name = a:2
let lines = neomake#debug#get_maker_info(maker_name)
else
let lines = neomake#debug#_get_info_lines()
endif
if bang
try
call setreg('+', join(lines, "\n"), 'l')
catch
call neomake#log#error(printf(
\ 'Could not set clipboard: %s.', v:exception))
return
endtry
echom 'Copied Neomake info to clipboard ("+).'
else
echon join(lines, "\n")
endif
endfunction
function! s:trim(s) abort
return substitute(a:s, '\v^[ \t\r\n]+|[ \t\r\n]+$', '', 'g')
endfunction
function! neomake#debug#_get_info_lines() abort
let r = []
let ft = &filetype
let r += ['#### Neomake debug information']
let r += ['']
let r += ['Async support: '.neomake#has_async_support()]
let r += ['Current filetype: '.ft]
let r += ['Windows: '.neomake#utils#IsRunningWindows()]
let r += ['[shell, shellcmdflag, shellslash]: '.string([&shell, &shellcmdflag, &shellslash])]
let r += [join(map(split(neomake#utils#redir('verb set makeprg?'), '\n'), 's:trim(v:val)'), ', ')]
let r += ['']
let r += ['##### Enabled makers']
let r += ['']
let r += ['For the current filetype ("'.ft.'", used with :Neomake):']
let r += s:get_makers_info(ft)
if empty(ft)
let r += ['NOTE: the current buffer does not have a filetype.']
else
let conf_ft = neomake#utils#get_ft_confname(ft)
let r += ['NOTE: you can define g:neomake_'.conf_ft.'_enabled_makers'
\ .' to configure it (or b:neomake_'.conf_ft.'_enabled_makers).']
endif
let r += ['']
let r += ['For the project (used with :Neomake!):']
let r += s:get_makers_info()
let r += ['NOTE: you can define g:neomake_enabled_makers to configure it.']
let r += ['']
let r += ['Default maker settings:']
for [k, v] in items(neomake#config#get('maker_defaults'))
let r += [' - '.k.': '.string(v)]
unlet! v " Fix variable type mismatch with Vim 7.3.
endfor
let r += ['']
let r += ['##### Settings']
let r += ['']
let r += ['###### New-style (dict, overrides old-style)']
let r += ['']
let r += ['```']
let r += ['g:neomake: '.(exists('g:neomake') ? s:pprint(g:neomake) : 'unset')]
let r += ['b:neomake: '.(exists('b:neomake') ? s:pprint(b:neomake) : 'unset')]
let r += ['```']
let r += ['']
let r += ['###### Old-style']
let r += ['']
let r += ['```']
for [k, V] in sort(items(filter(copy(g:), "v:key =~# '^neomake_'")))
let r += ['g:'.k.' = '.string(V)]
unlet! V " Fix variable type mismatch with Vim 7.3.
endfor
let r += ['']
let r += ['```']
let r += ["\n"]
let r += ['#### :version']
let r += ['']
let r += ['```']
let r += split(neomake#utils#redir('version'), '\n')
let r += ['```']
let r += ['']
let r += ['#### :messages']
let r += ['']
let r += ['```']
let r += split(neomake#utils#redir('messages'), '\n')
let r += ['```']
return r
endfunction
" vim: ts=4 sw=4 et
|