Simple image host.
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. " Language: Rust
  2. " Description: Vim syntax file for Rust
  3. " Maintainer: Chris Morgan <me@chrismorgan.info>
  4. " Maintainer: Kevin Ballard <kevin@sb.org>
  5. " Last Change: Jul 07, 2014
  6. if exists("b:did_ftplugin")
  7. finish
  8. endif
  9. let b:did_ftplugin = 1
  10. let s:save_cpo = &cpo
  11. set cpo&vim
  12. " Variables {{{1
  13. " The rust source code at present seems to typically omit a leader on /*!
  14. " comments, so we'll use that as our default, but make it easy to switch.
  15. " This does not affect indentation at all (I tested it with and without
  16. " leader), merely whether a leader is inserted by default or not.
  17. if exists("g:rust_bang_comment_leader") && g:rust_bang_comment_leader == 1
  18. " Why is the `,s0:/*,mb:\ ,ex:*/` there, you ask? I don't understand why,
  19. " but without it, */ gets indented one space even if there were no
  20. " leaders. I'm fairly sure that's a Vim bug.
  21. setlocal comments=s1:/*,mb:*,ex:*/,s0:/*,mb:\ ,ex:*/,:///,://!,://
  22. else
  23. setlocal comments=s0:/*!,m:\ ,ex:*/,s1:/*,mb:*,ex:*/,:///,://!,://
  24. endif
  25. setlocal commentstring=//%s
  26. setlocal formatoptions-=t formatoptions+=croqnl
  27. " j was only added in 7.3.541, so stop complaints about its nonexistence
  28. silent! setlocal formatoptions+=j
  29. " smartindent will be overridden by indentexpr if filetype indent is on, but
  30. " otherwise it's better than nothing.
  31. setlocal smartindent nocindent
  32. if !exists("g:rust_recommended_style") || g:rust_recommended_style == 1
  33. setlocal tabstop=4 shiftwidth=4 softtabstop=4 expandtab
  34. setlocal textwidth=99
  35. endif
  36. " This includeexpr isn't perfect, but it's a good start
  37. setlocal includeexpr=substitute(v:fname,'::','/','g')
  38. " NOT adding .rc as it's being phased out (0.7)
  39. setlocal suffixesadd=.rs
  40. if exists("g:ftplugin_rust_source_path")
  41. let &l:path=g:ftplugin_rust_source_path . ',' . &l:path
  42. endif
  43. if exists("g:loaded_delimitMate")
  44. if exists("b:delimitMate_excluded_regions")
  45. let b:rust_original_delimitMate_excluded_regions = b:delimitMate_excluded_regions
  46. endif
  47. let b:delimitMate_excluded_regions = delimitMate#Get("excluded_regions") . ',rustLifetimeCandidate,rustGenericLifetimeCandidate'
  48. endif
  49. if has("folding") && exists('g:rust_fold') && g:rust_fold != 0
  50. let b:rust_set_foldmethod=1
  51. setlocal foldmethod=syntax
  52. if g:rust_fold == 2
  53. setlocal foldlevel<
  54. else
  55. setlocal foldlevel=99
  56. endif
  57. endif
  58. if has('conceal') && exists('g:rust_conceal')
  59. let b:rust_set_conceallevel=1
  60. setlocal conceallevel=2
  61. endif
  62. " Motion Commands {{{1
  63. " Bind motion commands to support hanging indents
  64. nnoremap <silent> <buffer> [[ :call rust#Jump('n', 'Back')<CR>
  65. nnoremap <silent> <buffer> ]] :call rust#Jump('n', 'Forward')<CR>
  66. xnoremap <silent> <buffer> [[ :call rust#Jump('v', 'Back')<CR>
  67. xnoremap <silent> <buffer> ]] :call rust#Jump('v', 'Forward')<CR>
  68. onoremap <silent> <buffer> [[ :call rust#Jump('o', 'Back')<CR>
  69. onoremap <silent> <buffer> ]] :call rust#Jump('o', 'Forward')<CR>
  70. " Commands {{{1
  71. " See |:RustRun| for docs
  72. command! -nargs=* -complete=file -bang -bar -buffer RustRun call rust#Run(<bang>0, [<f-args>])
  73. " See |:RustExpand| for docs
  74. command! -nargs=* -complete=customlist,rust#CompleteExpand -bang -bar -buffer RustExpand call rust#Expand(<bang>0, [<f-args>])
  75. " See |:RustEmitIr| for docs
  76. command! -nargs=* -bar -buffer RustEmitIr call rust#Emit("ir", [<f-args>])
  77. " See |:RustEmitAsm| for docs
  78. command! -nargs=* -bar -buffer RustEmitAsm call rust#Emit("asm", [<f-args>])
  79. " Mappings {{{1
  80. " Bind ⌘R in MacVim to :RustRun
  81. nnoremap <silent> <buffer> <D-r> :RustRun<CR>
  82. " Bind ⌘⇧R in MacVim to :RustRun! pre-filled with the last args
  83. nnoremap <buffer> <D-R> :RustRun! <C-r>=join(b:rust_last_rustc_args)<CR><C-\>erust#AppendCmdLine(' -- ' . join(b:rust_last_args))<CR>
  84. if !exists("b:rust_last_rustc_args") || !exists("b:rust_last_args")
  85. let b:rust_last_rustc_args = []
  86. let b:rust_last_args = []
  87. endif
  88. " Cleanup {{{1
  89. let b:undo_ftplugin = "
  90. \ setlocal formatoptions< comments< commentstring< includeexpr< suffixesadd<
  91. \|setlocal tabstop< shiftwidth< softtabstop< expandtab< textwidth<
  92. \|if exists('b:rust_original_delimitMate_excluded_regions')
  93. \|let b:delimitMate_excluded_regions = b:rust_original_delimitMate_excluded_regions
  94. \|unlet b:rust_original_delimitMate_excluded_regions
  95. \|else
  96. \|unlet! b:delimitMate_excluded_regions
  97. \|endif
  98. \|if exists('b:rust_set_foldmethod')
  99. \|setlocal foldmethod< foldlevel<
  100. \|unlet b:rust_set_foldmethod
  101. \|endif
  102. \|if exists('b:rust_set_conceallevel')
  103. \|setlocal conceallevel<
  104. \|unlet b:rust_set_conceallevel
  105. \|endif
  106. \|unlet! b:rust_last_rustc_args b:rust_last_args
  107. \|delcommand RustRun
  108. \|delcommand RustExpand
  109. \|delcommand RustEmitIr
  110. \|delcommand RustEmitAsm
  111. \|nunmap <buffer> <D-r>
  112. \|nunmap <buffer> <D-R>
  113. \|nunmap <buffer> [[
  114. \|nunmap <buffer> ]]
  115. \|xunmap <buffer> [[
  116. \|xunmap <buffer> ]]
  117. \|ounmap <buffer> [[
  118. \|ounmap <buffer> ]]
  119. \"
  120. " }}}1
  121. let &cpo = s:save_cpo
  122. unlet s:save_cpo
  123. " vim: set noet sw=4 ts=4: