-- LSP, completion, and code formatting
return {
  -- LSP server manager
  {
    "williamboman/mason.nvim",
    cmd = { "Mason", "MasonInstall", "MasonUninstall", "MasonUpdate" },
    opts = {
      PATH = "skip",
      ui = {
        icons = {
          package_pending = " ",
          package_installed = " ",
          package_uninstalled = " ",
        },
      },
      max_concurrent_installers = 10,
    },
  },

  -- Bridge between mason and lspconfig
  {
    "williamboman/mason-lspconfig.nvim",
    dependencies = { "williamboman/mason.nvim" },
  },

  -- LSP configuration
  {
    "neovim/nvim-lspconfig",
    event = "User FilePost",
    config = function()
      require "configs.lspconfig"
    end,
  },

  -- Treesitter parser manager
  {
    "nvim-treesitter/nvim-treesitter",
    build = ":TSUpdate",
    cmd = { "TSInstall", "TSUpdate" },
    config = function()
      require("nvim-treesitter").setup()
    end,
  },

  -- Completion engine (load on insert or command mode for faster startup)
  {
    "saghen/blink.cmp",
    version = "1.*",
    event = { "InsertEnter", "CmdlineEnter" },
    dependencies = {
      "saghen/blink.compat",
      optional = true,
      opts = {},
    },
    opts = {
      keymap = {
        preset = 'none',
        ['<Tab>'] = { 'select_next', 'fallback' },
        ['<S-Tab>'] = { 'select_prev', 'fallback' },
        ['<Esc>'] = { 'hide', 'fallback' },
        ['<CR>'] = { 'accept', 'fallback' },
        ['<C-space>'] = { 'show', 'show_documentation', 'hide_documentation' },
      },
      appearance = {
        use_nvim_cmp_as_default = true,
        nerd_font_variant = 'mono'
      },
      signature = {
        enabled = true,
      },
      completion = {
        menu = { border = "rounded" },
        list = { selection = { auto_insert = false } },
      },
      sources = {
        default = { 'lsp', 'path', 'buffer' },
        transform_items = function(_, items)
          return vim.tbl_filter(function(item)
            return item.kind ~= require('blink.cmp.types').CompletionItemKind.Snippet
          end, items)
        end,
      },
    },
  },

  -- Inline diagnostic messages
  {
    "rachartier/tiny-inline-diagnostic.nvim",
    event = "VeryLazy",
    priority = 1000,
    config = function()
      require('tiny-inline-diagnostic').setup({
        preset = "powerline",
      })
      vim.diagnostic.config({
        virtual_text = false,
        severity_sort = true,
      })
    end
  },

  -- Code formatter
  {
    'stevearc/conform.nvim',
    opts = {
      formatters_by_ft = {
        wgsl = { 'wgslfmt' },
        wesl = { 'wgslfmt' },
      },
      formatters = {
        wgslfmt = {
          command = 'wgslfmt',
          args = { '-' },
          stdin = true,
        },
      },
    },
  },

  -- Filetype-specific plugins
  {
    "elkowar/yuck.vim",
    ft = "yuck",
  },
  -- Disabled plugins
  { "hrsh7th/nvim-cmp", enabled = false },
}
