local lsp_utils = require('lsp-utils')
local ra_config = lsp_utils.ra_config()

vim.lsp.start(ra_config)

vim.cmd.compiler('cargo')
vim.bo.makeprg = 'cargo build --all'

vim.keymap.set('n', 'cbb', ":Dispatch! cargo build<CR>"     , { noremap=true, buffer=0 })
vim.keymap.set('n', 'cbc', ":Dispatch! cargo clean<CR>"     , { noremap=true, buffer=0 })
vim.keymap.set('n', 'cbd', ":Dispatch! cargo doc<CR>"       , { noremap=true, buffer=0 })
vim.keymap.set('n', 'cdD', ":Dispatch! cargo doc --open<CR>", { noremap=true, buffer=0 })
vim.keymap.set('n', 'cbu', ":Dispatch! cargo update<CR>"    , { noremap=true, buffer=0 })
vim.keymap.set('n', ',r' , ":CargoReload<CR>"               , { noremap=true, buffer=0 })

vim.api.nvim_create_autocmd({ "BufReadPre", "BufWinEnter" }, {
  pattern  = { "*/git/checkouts/*", "*/toolchains/*", "*cargo/registry/*" },
  callback = function()
    vim.bo.buflisted = false
  end,
})
