debugging.vim 3.1 KB

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