a vim ide for rust language

Abstract

In order to make an IDE for rust, I followed the Ultimate vimrc, and installed Tagbar, YouCompleteMe to support the RUST language.

Details

  1. Install the Ultimate vimrc, you can follow the readme.

    1
    2
    git clone https://github.com/amix/vimrc.git ~/.vim_runtime
    sh ~/.vim_runtime/install_awesome_vimrc.sh
  2. Install Your Plugins to the directory sources_non_forked.

    1
    2
    cd ~/vim_runtime
    git clone git://github.com/tpope/vim-rails.git sources_non_forked/vim-rails
    • Install tagbar

      1
      git clone https://github.com/majutsushi/tagbar.git sources_non_forked/tagbar
    • Config tagbar for Rust, Put this into ~/.ctags

      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      --langdef=Rust
      --langmap=Rust:.rs
      --regex-Rust=/^[ t]*(#[[^]]][ t]*)*(pub[ t]+)?(extern[ t]+)?("[^"]+"[ t]+)?(unsafe[ t]+)?fn[ t]+([a-zA-Z0-9_]+)/6/f,functions,function definitions/
      --regex-Rust=/^[ t]*(pub[ t]+)?type[ t]+([a-zA-Z0-9_]+)/2/T,types,type definitions/
      --regex-Rust=/^[ t]*(pub[ t]+)?enum[ t]+([a-zA-Z0-9_]+)/2/g,enum,enumeration names/
      --regex-Rust=/^[ t]*(pub[ t]+)?struct[ t]+([a-zA-Z0-9_]+)/2/s,structure names/
      --regex-Rust=/^[ t]*(pub[ t]+)?mod[ t]+([a-zA-Z0-9_]+)/2/m,modules,module names/
      --regex-Rust=/^[ t]*(pub[ t]+)?(static|const)[ t]+(mut[ t]+)?([a-zA-Z0-9_]+)/4/c,consts,static constants/
      --regex-Rust=/^[ t]*(pub[ t]+)?(unsafe[ t]+)?trait[ t]+([a-zA-Z0-9_]+)/3/t,traits,traits/
      --regex-Rust=/^[ t]*(pub[ t]+)?(unsafe[ t]+)?impl([ tn]*<[^>]*>)?[ t]+(([a-zA-Z0-9_:]+)[ t]*(<[^>]*>)?[ t]+(for)[ t]+)?([a-zA-Z0-9_]+)/5 7 8/i,impls,trait implementations/
      --regex-Rust=/^[ t]*macro_rules![ t]+([a-zA-Z0-9_]+)/1/d,macros,macro definitions/

and add configuration to the my_configs.vim as step 4.

  1. Install YouCompleteMe for rust follow the README:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    cd ~/.vim_runtime/sources_non_forked
    git clone https://github.com/Valloric/YouCompleteMe.git sources_non_forked/YouCompleteMe
    cd YouCompleteMe
    git submodule update --init --recursive
    ./install.py --racer-completer
    mkdir -p ~/Developer
    mkdir -p ~/Developer
    cd ~/Developer
    git clone --depth 1 --branch master https://github.com/rust-lang/rust rust-master
  2. Add your configurations to the file ~/vim_runtime/my_configs.vim.

    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
    "YouCompleteMe for rust
    let g:ycm_rust_src_path="/home/huang/Developer/rust-master/src/"
    "enable mouse support
    set mouse=a
    "Arrage the NERDTreePanel to the right
    let NERDTreeWinPos = "right"
    "Arrage the tagbar to the left
    let g:tagbar_left = 1
    let g:tagbar_width = 30
    let g:tagbar_autofocus = 1
    let g:tagbar_sort = 0
    let g:tagbar_compact = 1
    "enable tagbar for rust
    let g:tagbar_type_rust = {
    'ctagstype' : 'rust',
    'kinds' : [
    'T:types,type definitions',
    'f:functions,function definitions',
    'g:enum,enumeration names',
    's:structure names',
    'm:modules,module names',
    'c:consts,static constants',
    't:traits,traits',
    'i:impls,trait implementations',
    ]
    }
    "shortcuts
    nmap <F5> :TagbarToggle<cr>
    nmap <F6> :NERDTreeToggle<cr>

Vim Appearence

Other Resources

[1]: Awesome Rust Collections, https://github.com/kud1ing/awesome-rust#ides

[2]: Vim Cheet Sheet, http://vim.rtorr.com/

[3]: VimAwesome, http://vimawesome.com/