0
0

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 1 year has passed since last update.

WSL2上でRust開発環境を整える(3日目)

Posted at

1日目
2日目

全然Rustの開発環境を整えていないのでタイトル詐欺状態。
今日中に終わらせたい。

Neovimの設定

引き続きNeovimの設定。
気付いてしまったが、VSCode-Neovimの場合は読み込まれないプラグインがあるので、keymap.lua にまとめるとVSCode判定が二重に入るからミスりそう。
キーマップは設定ファイルを見るのではなく :nmap とかで確認するようにしよう。

Telescope

これを使うために今までの設定をしてきた感ある。

~/.config/nvim/lua/plugin.lua
require("lazy").setup({
  ...
  -- setupの最後に追加
  {
    'nvim-telescope/telescope.nvim', tag = '0.1.5',
    dependencies = {
      'nvim-lua/plenary.nvim',
    },
    config = function ()
      require('telescope').setup({
        extensions = {
          coc = {
            prefer_locations = true,
          }
        }
      })

      -- keysに設定するとこの辺の関数使えなかったので。
      local builtin = require('telescope.builtin')
      local find_all_files = function ()
        builtin.find_files({no_ignore = false, hidden = true})
      end

      -- VSCodeっぽい感じを残しておく
      vim.keymap.set('n', '<C-p>', find_all_files)

      vim.keymap.set('n', '<Leader>ff', builtin.find_files);
      vim.keymap.set('n', '<Leader>fa', find_all_files);
      vim.keymap.set('n', '<Leader>fg', builtin.live_grep);
      vim.keymap.set('n', '<Leader>fb', builtin.buffers);
      vim.keymap.set('n', '<Leader>fh', builtin.help_tags);
    end,
    cond = not vim.g.vscode,
  },
  {
    'nvim-telescope/telescope-frecency.nvim',
    config = function ()
      require('telescope').load_extension("frecency")
    end,
    cond = not vim.g.vscode,
  },
  {
    'fannheyward/telescope-coc.nvim',
    config = function ()
      require('telescope').load_extension("coc")
    end,
    cond = not vim.g.vscode,
  },
})

テーマ

これは好み。
この辺から好きなのを選んでインストールすればOK。
とりあえず gruvbox-material にしてみる。
ついでに lualine も入れる。

~/.config/nvim/lua/plugin.lua
require("lazy").setup({
  ...
  -- setupの最後に追加
  { 'sainnhe/gruvbox-material' },
  {
    'nvim-lualine/lualine.nvim',
    dependencies = { 'nvim-tree/nvim-web-devicons' },
    config = function ()
      require('lualine').setup({
        options = {
          theme = 'gruvbox-material',
        }
      })
    end,
    cond = not vim.g.vscode
  },
})

Rust開発環境を整える

ようやくタイトル回収。

COCを設定する

Neovimを起動して :CocInstall coc-rust-analyzer を実行する。
rustup でコンポーネントも追加しておく。

rustup component add rust-analyzer

COCはプラグインをインストールしただけなので、キーマップ等を入れる必要があるが、項目が多いので、Example Lua configuration をすべて突っ込んだ。不便なキーはあとで修正予定。
rustのプラグインも追加。

~/.config/nvim/lua/plugin.lua
require("lazy").setup({
  ...
  -- setupの最後に追加
  {
    'rust-lang/rust.vim',
    config = function ()
      -- 保存時にフォーマッターを実行する
      vim.g.rustfmt_autosave = 1
    end,
  },
})

とりあえず表示できたのでOK。
image.png


デバッガーの導入をしようとしているがうまくいってないのでまた明日...

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?