VisualStudioのインストール
インストールするときにC++によるデスクトップ開発の中のWindows用C++Clangツールにチェックをつける
Powershellのプロファイル編集
プロファイルの場所
https://docs.microsoft.com/en-us/previous-versions//bb613488(v=vs.85)?redirectedfrom=MSDN
プロファイルに下記を追加する
function Activate-VSEnv {
$installPath = &"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -version 16.0 -property installationpath
Import-Module (Join-Path $installPath "Common7\Tools\Microsoft.VisualStudio.DevShell.dll")
Enter-VsDevShell -VsInstallPath $installPath -SkipAutomaticLocation
$env:path += ";" + $installPath + "\VC\Tools\Llvm\bin"
}
参考:https://intellitect.com/enter-vsdevshell-powershell/
Vimプラグインの追加
vim-lsp-settingsを入れる
https://github.com/mattn/vim-lsp-settings
vim-lsp-settingsが依存している下記プラグインも入れる
https://github.com/prabirshrestha/async.vim
https://github.com/prabirshrestha/asyncomplete.vim
https://github.com/prabirshrestha/asyncomplete-lsp.vim
https://github.com/prabirshrestha/vim-lsp
プラグインさえ入れれば基本的にvimrcの設定は不要
vimの実行
powershellを開いて
Activate-VSEnv
を実行した後にそのpowershellからvimを開く
Cのソースファイルを開いたときに自動補完やコードチェックが機能すれば成功。
コンパイル
先ほど
Activate-VSEnv
を実行したpowershellで
clang-cl [ファイル名]
でコンパイルできる。