blob: 0e84183172d21b1c68a8692917cb565da1172d6b [file] [log] [blame]
Gregory Andersfc935942023-09-12 13:23:38 -05001" Last Modified: 2023-09-11
2
3" For debugging, inspired by https://github.com/w0rp/rust/blob/master/autoload/rust/debugging.vim
4
5let s:global_variable_list = [
6 \ '_rustfmt_autosave_because_of_config',
7 \ 'ftplugin_rust_source_path',
8 \ 'loaded_syntastic_rust_cargo_checker',
9 \ 'loaded_syntastic_rust_filetype',
10 \ 'loaded_syntastic_rust_rustc_checker',
11 \ 'rust_bang_comment_leader',
12 \ 'rust_cargo_avoid_whole_workspace',
13 \ 'rust_clip_command',
14 \ 'rust_conceal',
15 \ 'rust_conceal_mod_path',
16 \ 'rust_conceal_pub',
17 \ 'rust_fold',
18 \ 'rust_last_args',
19 \ 'rust_last_rustc_args',
20 \ 'rust_original_delimitMate_excluded_regions',
21 \ 'rust_playpen_url',
22 \ 'rust_prev_delimitMate_quotes',
23 \ 'rust_recent_nearest_cargo_tol',
24 \ 'rust_recent_root_cargo_toml',
25 \ 'rust_recommended_style',
26 \ 'rust_set_conceallevel',
27 \ 'rust_set_conceallevel=1',
28 \ 'rust_set_foldmethod',
29 \ 'rust_set_foldmethod=1',
30 \ 'rust_shortener_url',
31 \ 'rustc_makeprg_no_percent',
32 \ 'rustc_path',
33 \ 'rustfmt_autosave',
34 \ 'rustfmt_autosave_if_config_present',
35 \ 'rustfmt_command',
36 \ 'rustfmt_emit_files',
37 \ 'rustfmt_fail_silently',
38 \ 'rustfmt_options',
39 \ 'syntastic_extra_filetypes',
40 \ 'syntastic_rust_cargo_fname',
41 \]
42
43function! s:Echo(message) abort
44 execute 'echo a:message'
45endfunction
46
47function! s:EchoGlobalVariables() abort
48 for l:key in s:global_variable_list
49 if l:key !~# '^_'
50 call s:Echo('let g:' . l:key . ' = ' . string(get(g:, l:key, v:null)))
51 endif
52
53 if has_key(b:, l:key)
54 call s:Echo('let b:' . l:key . ' = ' . string(b:[l:key]))
55 endif
56 endfor
57endfunction
58
59function! rust#debugging#Info() abort
60 call cargo#Load()
61 call rust#Load()
62 call rustfmt#Load()
63 call s:Echo('rust.vim Global Variables:')
64 call s:Echo('')
65 call s:EchoGlobalVariables()
66
67 silent let l:output = system(g:rustfmt_command . ' --version')
68 echo l:output
69
70 let l:rustc = exists("g:rustc_path") ? g:rustc_path : "rustc"
71 silent let l:output = system(l:rustc . ' --version')
72 echo l:output
73
74 silent let l:output = system('cargo --version')
75 echo l:output
76
77 version
78
79 if exists(":SyntasticInfo")
80 echo "----"
81 echo "Info from Syntastic:"
82 execute "SyntasticInfo"
83 endif
84endfunction
85
86function! rust#debugging#InfoToClipboard() abort
87 redir @"
88 silent call rust#debugging#Info()
89 redir END
90
91 call s:Echo('RustInfo copied to your clipboard')
92endfunction
93
94function! rust#debugging#InfoToFile(filename) abort
95 let l:expanded_filename = expand(a:filename)
96
97 redir => l:output
98 silent call rust#debugging#Info()
99 redir END
100
101 call writefile(split(l:output, "\n"), l:expanded_filename)
102 call s:Echo('RustInfo written to ' . l:expanded_filename)
103endfunction
104
105" vim: set et sw=4 sts=4 ts=8: