local overrides = require("custom.configs.overrides")

---@type NvPluginSpec[]
local plugins = {
  -- Override plugin definition options
  {
    "neovim/nvim-lspconfig",
    dependencies = {
     "jose-elias-alvarez/null-ls.nvim",
     config = function()
       require "custom.configs.null-ls"
     end,
   },
    config = function()
      require "plugins.configs.lspconfig"
      require "custom.configs.lspconfig"
    end,
  },
    -- override plugin configs
  {
    "williamboman/mason.nvim",
    opts = overrides.mason
  },

  {
    "nvim-treesitter/nvim-treesitter",
    opts = overrides.treesitter,
  },

  {
    "nvim-tree/nvim-tree.lua",
    opts = overrides.nvimtree,
  },

  -- Debugger 
  {
    "mfussenegger/nvim-dap",
    init = function()
      require("core.utils").load_mappings("dap")
    end
  },

  {
    "theHamsta/nvim-dap-virtual-text",
    lazy = false,
    config = function(_, opts)
      require("nvim-dap-virtual-text").setup()
    end
  },

  -- Rust
  -- {
  --   "simrat39/rust-tools.nvim",
  --   ft = "rust",
  --   dependencies = "neovim/nvim-lspconfig",
  --   opts = function ()
  --     return require "custom.configs.rust-tools"
  --   end,
  --   config = function(_, opts)
  --     require('rust-tools').setup(opts)
  --   end
  -- },

  -- {
  --   'saecki/crates.nvim',
  --   ft = {"rust", "toml"},
  --   config = function(_, opts)
  --     local crates  = require('crates')
  --     crates.setup(opts)
  --     require('cmp').setup.buffer({
  --       sources = { { name = "crates" }}
  --     })
  --     crates.show()
  --     require("core.utils").load_mappings("crates")
  --   end,
  -- },

  {
    "rust-lang/rust.vim",
    ft = "rust",
    init = function ()
      vim.g.rustfmt_autosave = 1
    end
  },

  -- Better escape (jj/jk)
  {
    "max397574/better-escape.nvim",
    event = "InsertEnter",
    config = function()
      require("better_escape").setup()
    end,
  },

  -- Signatures plugin to show function signatures as you type them
  {
    "ray-x/lsp_signature.nvim",
    event = "BufRead",
    config = function()
      require("lsp_signature").setup {
        hint_enable = false,
      }
    end,
  },

  -- -- Rooter plugin to change directory to the project root
  -- {
  --   "notjedi/nvim-rooter.lua",
  --   event = "UIEnter",
  --   config = function()
  --     require("nvim-rooter").setup {
  --       rooter_patterns = { "Makefile", ".git", ".hg", ".svn" },
  --       trigger_patterns = { "*" },
  --       manual = false,
  --     }
  --   end,
  -- },

  -- Leap plugin to jump to any line in the file
  {
    "ggandor/leap.nvim",
    event = "UIEnter",
    config = function() require("leap").add_default_mappings() end,
  },

  -- Copilot plugin to autocomplete text
  {
    "zbirenbaum/copilot.lua",
    cmd = "Copilot",
    event = "InsertEnter",
    config = function()
      require("copilot").setup {
        suggestion = { enabled = false },
        panel = { enabled = false },
        filetypes = { markdown = true },
      }
    end,
  },

  -- Copilot CMP plugin to autocomplete text in the completion menu
  {
    "zbirenbaum/copilot-cmp",
    dependencies = "zbirenbaum/copilot.lua",
    event = "InsertEnter",
    config = function() require("copilot_cmp").setup() end,
  },
  -- {
  --   "hrsh7th/nvim-cmp",
  --   opts = function()
  --     local M = require "plugins.configs.cmp"
  --     M.completion.completeopt = "menu,menuone,noselect"
  --     M.mapping["<CR>"] = cmp.mapping.confirm {
  --       behavior = cmp.ConfirmBehavior.Insert,
  --       select = false,
  --     }
  --     table.insert(M.sources, {name = "crates"})
  --     return M
  --   end,
  -- }
}
return plugins
