2
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Rust+Windows10+vimの開発環境構築備忘録

Last updated at Posted at 2019-06-15

概要

Rustの開発をしたくて環境構築した時の備忘録です。vimのインストールは省略します。補完はVim標準のomni補完を利用します。

VisualStudioをインストール

後ほどインストールするrustupにはC++コンパイラが必要です。VisualStudioをインストールするときに「C++デスクトップ開発」にチェックを入れればC++コンパイラもインストールされる。
https://visualstudio.microsoft.com/ja/downloads/

rustupのインストール

RustにはrustupというCLIのインストーラがある。rustに関するツールやライブラリがrustupからインストールできる。
https://rustup.rs/

rlsのインストールし、vimのプラグインを入れる

vimからlanguage serverを利用するプラグインvim-lspを追加します。
Rustのlanguage serverであるrlsをインストールします。
https://github.com/prabirshrestha/vim-lsp
https://github.com/prabirshrestha/vim-lsp/wiki/Servers-Rust

vimにrust用プラグインを追加

vimrcの設定

rustでlspを使うように設定
インサートモードで.か:を入力したときに補完ができるように設定

  if executable('rls')
      let g:lsp_diagnostics_enabled = 0 " エラー表示はALEで行う
      au User lsp_setup call lsp#register_server({
          \ 'name': 'rls',
          \ 'cmd': {server_info->['rustup', 'run', 'stable', 'rls']},
          \ 'workspace_config': {'rust': {'clippy_preference': 'on'}},
          \ 'whitelist': ['rust'],
          \ })
      autocmd FileType rust setlocal omnifunc=lsp#complete
      " .か:を押したときに自動的にオムニ補完
      autocmd FileType rust imap <expr> . ".\<C-X>\<C-O>"
      autocmd FileType rust imap <expr> : ":\<C-X>\<C-O>"
  endif


VimにALEを追加

コードチェッカーであるALEを追加します。
rlsでもコードチェックはできるが、コード内に下線が引かれないのでALEを使用
https://github.com/w0rp/ale

2
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?