simrat39 / rust-tools.nvim

Tools for better development in rust using neovim's builtin lsp
MIT License
2.16k stars 158 forks source link

Error detected while processing BufReadPost Autocommands for "*" #259

Open StHagel opened 2 years ago

StHagel commented 2 years ago

I installed the plugin via packer.nvim, but when I open a rust file afterwards, I get the following error:

Error detected while processing BufReadPost Autocommands for "*":

It just pops up quickly before dissappearing again and the file opens, but the plugin does not work.

Here is my ~/.config/nvim/init.vim:

set runtimepath^=~/.vim runtimepath+=~/.vim/after
let &packpath = &runtimepath
source ~/.vimrc

lua require('init')
lua require('plugins')

Here is my ~/.config/nvim/lua/init.lua:

local rt = require("rust-tools")

rt.setup({
  server = {
    on_attach = function(_, bufnr)
      -- Hover actions
      vim.keymap.set("n", "<C-space>", rt.hover_actions.hover_actions, { buffer = bufnr })
      -- Code action groups
      vim.keymap.set("n", "<Leader>a", rt.code_action_group.code_action_group, { buffer = bufnr })
    end
  },
})
require('rust-tools').inlay_hints.enable()

require("null-ls").setup({
    sources = {
        require("null-ls").builtins.formatting.stylua,
        require("null-ls").builtins.diagnostics.eslint,
        require("null-ls").builtins.completion.spell,
    },
})

And finally my ~/.config/nvim/lua/plugins.lua:

return require('packer').startup(function(use)
    use("wbthomason/packer.nvim")   

    use 'neovim/nvim-lspconfig'

    use 'simrat39/rust-tools.nvim'

    -- Debugging
    use 'jose-elias-alvarez/null-ls.nvim'
    use 'nvim-lua/plenary.nvim'
    use 'mfussenegger/nvim-dap'

    use {
        'saecki/crates.nvim',
        requires = { 'nvim-lua/plenary.nvim' },
        config = function()
            require('crates').setup()
        end,
    }
    use {
        'sakhnik/nvim-gdb'
    }

end)

I am using nvim version v0.8.0-dev-1207-g183984880, which I built from source today. Any ideas on how to fix this?

rockerBOO commented 2 years ago

If you do :messages you can see the full error (when it would disappear quickly). Would be helpful, in this case, to identify the problem.

Qyriad commented 1 year ago

I'm not certain if this is the exact error that OP is getting, but here's the full version of what I get:

Error detected while processing BufReadPost Autocommands for "*":
Error executing lua callback: ...brew/Cellar/neovim/0.9.1/share/nvim/runtime/filetype.lua:21: Error executing lua: ...brew/Cellar/neovim/0.9.1/share/nvim/runtime/filetype.lua:22: BufReadPost Autocommands for "*"..FileType Autocommands for "*"..function <SNR>1_LoadFTPlugin[19]..script /Users/qyriad/.local/share/nvim/lazy/rust-tools.nvim/ftplugin/rust.vim, line 1: Vim(command):E174: Command already exists: add ! to replace it: RustStartStandaloneServerForBuffer :lua require('rust-tools.standalone').start_standalone_client()
stack traceback:
    [C]: in function 'nvim_cmd'
    ...brew/Cellar/neovim/0.9.1/share/nvim/runtime/filetype.lua:22: in function <...brew/Cellar/neovim/0.9.1/share/nvim/runtime/filetype.lua:21>
    [C]: in function 'nvim_buf_call'
    ...brew/Cellar/neovim/0.9.1/share/nvim/runtime/filetype.lua:21: in function <...brew/Cellar/neovim/0.9.1/share/nvim/runtime/filetype.lua:10>
stack traceback:
    [C]: in function 'nvim_buf_call'
    ...brew/Cellar/neovim/0.9.1/share/nvim/runtime/filetype.lua:21: in function <...brew/Cellar/neovim/0.9.1/share/nvim/runtime/filetype.lua:10>
Qyriad commented 1 year ago

Which looks to me like command RustStartStandaloneServerForBuffer just needs to be command! to overwrite, or needs to be buffer scoped with command -buffer.