Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-3-7-sonnet-20250219· AnthropicHugging Face LMArena Human Preference 140K

Mappings are not being applied here: [code] Suggest changes.

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with o4-mini-2025-04-16’s answer.
  1. User

    Mappings are not being applied here:

    -- AstroCore provides a central place to modify mappings, vim options, autocommands, and more!
    -- Configuration documentation can be found with `:h astrocore`
    
    return {
      "AstroNvim/astrocore",
      opts = {
        -- Configure core features of AstroNvim
        features = {
          large_buf = { size = 1024 * 256, lines = 10000 }, -- set global limits for large files for disabling features like treesitter
          autopairs = true, -- enable autopairs at start
          cmp = true, -- enable completion at start
          diagnostics_mode = 3, -- diagnostic mode on start (0 = off, 1 = no signs/virtual text, 2 = no virtual text, 3 = on)
          highlighturl = true, -- highlight URLs at start
          notifications = true, -- enable notifications at start
        },
        -- Diagnostics configuration (for vim.diagnostics.config({...})) when diagnostics are on
        diagnostics = {
          virtual_text = true,
          underline = true,
        },
        -- vim options can be configured here
        options = {
          opt = { -- vim.opt.<key>
            relativenumber = true, -- sets vim.opt.relativenumber
            number = true, -- sets vim.opt.number
            signcolumn = "yes", -- sets vim.opt.signcolumn to yes
            mouse = "", -- Disable the mouse
            clipboard = "unnamedplus", -- Enable clipboard access
    
            -- Localization and spell check options
            spell = true, -- sets vim.opt.spell
            spelllang = { "en_us", "pt_br" },
            -- rtp:append("~/.config/nvim/")
    
            -- Softwrap options
            wrap = true, -- Enable line wrapping
            linebreak = true, -- Break lines at "breakat" characters, thus not splitting words
            breakindent = true, -- Preserve indentation when breaking lines
            whichwrap = "b,s,h,l", -- Set keys which can make the cursor wrap lines
    
            -- Set tab length
            shiftwidth = 0, -- Set to zero to return the same value as tabstop
            tabstop = 4,
          },
          g = { -- vim.g.<key>
            -- configure global vim variables (vim.g)
            -- NOTE: `mapleader` and `maplocalleader` must be set in the AstroNvim opts or before `lazy.setup`
            -- This can be found in the `lua/lazy_setup.lua` file
          },
        },
      },
      mappings = function()
        local no_operation = {
          ["<Down>"] = "<nop>",
          ["<End>"] = "<nop>",
          ["<PageDown>"] = "<nop>",
          ["<PageUp>"] = "<nop>",
          ["<Up>"] = "<nop>",
        }
    
        local keep_selection = {
          [">"] = { ">gv", desc = "Indent selection" },
          ["<"] = { "<gv", desc = "Dedent selection" },
        }
    
        local mappings = {
          n = no_operation,
          i = no_operation,
          o = no_operation,
        }
    
        mappings.v = vim.tbl_deep_extend("force", mappings, no_operation, keep_selection)
    
        return mappings
      end,
    }
    

    Suggest changes.

  2. Claude Assistant

    The issue is that your mappings function is returning a table, but it's not being properly integrated into the AstroCore configuration. In AstroNvim, mappings should be defined directly in the opts.mappings table rather than as a separate function.

    Here's how to fix it:

    -- AstroCore provides a central place to modify mappings, vim options, autocommands, and more!
    -- Configuration documentation can be found with `:h astrocore`
    
    return {
      "AstroNvim/astrocore",
      opts = {
        -- Configure core features of AstroNvim
        features = {
          large_buf = { size = 1024 * 256, lines = 10000 }, -- set global limits for large files for disabling features like treesitter
          autopairs = true, -- enable autopairs at start
          cmp = true, -- enable completion at start
          diagnostics_mode = 3, -- diagnostic mode on start (0 = off, 1 = no signs/virtual text, 2 = no virtual text, 3 = on)
          highlighturl = true, -- highlight URLs at start
          notifications = true, -- enable notifications at start
        },
        -- Diagnostics configuration (for vim.diagnostics.config({...})) when diagnostics are on
        diagnostics = {
          virtual_text = true,
          underline = true,
        },
        -- vim options can be configured here
        options = {
          opt = { -- vim.opt.<key>
            relativenumber = true, -- sets vim.opt.relativenumber
            number = true, -- sets vim.opt.number
            signcolumn = "yes", -- sets vim.opt.signcolumn to yes
            mouse = "", -- Disable the mouse
            clipboard = "unnamedplus", -- Enable clipboard access
    
            -- Localization and spell check options
            spell = true, -- sets vim.opt.spell
            spelllang = { "en_us", "pt_br" },
            -- rtp:append("~/.config/nvim/")
    
            -- Softwrap options
            wrap = true, -- Enable line wrapping
            linebreak = true, -- Break lines at "breakat" characters, thus not splitting words
            breakindent = true, -- Preserve indentation when breaking lines
            whichwrap = "b,s,h,l", -- Set keys which can make the cursor wrap lines
    
            -- Set tab length
            shiftwidth = 0, -- Set to zero to return the same value as tabstop
            tabstop = 4,
          },
          g = { -- vim.g.<key>
            -- configure global vim variables (vim.g)
            -- NOTE: `mapleader` and `maplocalleader` must be set in the AstroNvim opts or before `lazy.setup`
            -- This can be found in the `lua/lazy_setup.lua` file
          },
        },
        -- Define mappings directly in the opts table
        mappings = {
          n = {
            ["<Down>"] = { "<nop>", desc = "Disable down arrow" },
            ["<End>"] = { "<nop>", desc = "Disable end key" },
            ["<PageDown>"] = { "<nop>", desc = "Disable page down" },
            ["<PageUp>"] = { "<nop>", desc = "Disable page up" },
            ["<Up>"] = { "<nop>", desc = "Disable up arrow" },
          },
          i = {
            ["<Down>"] = { "<nop>", desc = "Disable down arrow" },
            ["<End>"] = { "<nop>", desc = "Disable end key" },
            ["<PageDown>"] = { "<nop>", desc = "Disable page down" },
            ["<PageUp>"] = { "<nop>", desc = "Disable page up" },
            ["<Up>"] = { "<nop>", desc = "Disable up arrow" },
          },
          v = {
            ["<Down>"] = { "<nop>", desc = "Disable down arrow" },
            ["<End>"] = { "<nop>", desc = "Disable end key" },
            ["<PageDown>"] = { "<nop>", desc = "Disable page down" },
            ["<PageUp>"] = { "<nop>", desc = "Disable page up" },
            ["<Up>"] = { "<nop>", desc = "Disable up arrow" },
            [">"] = { ">gv", desc = "Indent selection" },
            ["<"] = { "<gv", desc = "Dedent selection" },
          },
          o = {
            ["<Down>"] = { "<nop>", desc = "Disable down arrow" },
            ["<End>"] = { "<nop>", desc = "Disable end key" },
            ["<PageDown>"] = { "<nop>", desc = "Disable page down" },
            ["<PageUp>"] = { "<nop>", desc = "Disable page up" },
            ["<Up>"] = { "<nop>", desc = "Disable up arrow" },
          },
        },
      },
    }
    

    Would you like me to explain the changes I made?

  3. User

    Let's continue from here:

      mappings = function()
        local no_operation = {
          ["<Down>"] = "<nop>",
          ["<End>"] = "<nop>",
          ["<PageDown>"] = "<nop>",
          ["<PageUp>"] = "<nop>",
          ["<Up>"] = "<nop>",
        }
    
        local keep_selection = {
          [">"] = { ">gv", desc = "Indent selection" },
          ["<"] = { "<gv", desc = "Dedent selection" },
        }
    
        return {
          n = no_operation,
          i = no_operation,
          o = no_operation,
          v = vim.tbl_deep_extend("force", {}, no_operation, keep_selection)
        }
      end,
    

    Solve the following error:

    2025-05-14T16:43:30 lazy.nvim  ERROR Failed to run `config` for astrocore
    
    ...ity/lua/astrocommunity/diagnostics/trouble-nvim/init.lua:11: attempt to index local 'maps' (a function value)
    
    # stacktrace:
      - /astrocommunity/lua/astrocommunity/diagnostics/trouble-nvim/init.lua:11 _in_ **values**
      - ~/.config/nvim/lua/lazy_setup.lua:1
      - ~/.config/NixOS/nixos/home-manager/modules/terminal/astronvim/nvim/init.lua:18
    Press ENTER or type command to continue
    
  4. Claude Assistant

    The error is occurring because mappings is defined as a function, but something is trying to index it as if it were a table. In AstroNvim, when you define mappings as a function, it should return the mappings but also needs to be properly integrated with the plugin system.

    Let's fix it by modifying your approach:

    return {
      "AstroNvim/astrocore",
      opts = {
        -- Other options remain the same...
        
        -- Define mappings directly in the opts table
        mappings = {
          n = {
            ["<Down>"] = { "<nop>", desc = "Disable down arrow" },
            ["<End>"] = { "<nop>", desc = "Disable end key" },
            ["<PageDown>"] = { "<nop>", desc = "Disable page down" },
            ["<PageUp>"] = { "<nop>", desc = "Disable page up" },
            ["<Up>"] = { "<nop>", desc = "Disable up arrow" },
          },
          i = {
            ["<Down>"] = { "<nop>", desc = "Disable down arrow" },
            ["<End>"] = { "<nop>", desc = "Disable end key" },
            ["<PageDown>"] = { "<nop>", desc = "Disable page down" },
            ["<PageUp>"] = { "<nop>", desc = "Disable page up" },
            ["<Up>"] = { "<nop>", desc = "Disable up arrow" },
          },
          o = {
            ["<Down>"] = { "<nop>", desc = "Disable down arrow" },
            ["<End>"] = { "<nop>", desc = "Disable end key" },
            ["<PageDown>"] = { "<nop>", desc = "Disable page down" },
            ["<PageUp>"] = { "<nop>", desc = "Disable page up" },
            ["<Up>"] = { "<nop>", desc = "Disable up arrow" },
          },
          v = {
            ["<Down>"] = { "<nop>", desc = "Disable down arrow" },
            ["<End>"] = { "<nop>", desc = "Disable end key" },
            ["<PageDown>"] = { "<nop>", desc = "Disable page down" },
            ["<PageUp>"] = { "<nop>", desc = "Disable page up" },
            ["<Up>"] = { "<nop>", desc = "Disable up arrow" },
            [">"] = { ">gv", desc = "Indent selection" },
            ["<"] = { "<gv", desc = "Dedent selection" },
          },
        },
      },
    }
    

    Alternatively, if you want to keep your function approach for better organization, you need to use the config function to properly apply your mappings:

    return {
      "AstroNvim/astrocore",
      opts = {
        -- Other options remain the same...
      },
      config = function(_, opts)
        -- Apply the default configuration
        require("astrocore").setup(opts)
        
        -- Apply your custom mappings after setup
        local no_operation = {
          ["<Down>"] = { "<nop>", desc = "Disable down arrow" },
          ["<End>"] = { "<nop>", desc = "Disable end key" },
          ["<PageDown>"] = { "<nop>", desc = "Disable page down" },
          ["<PageUp>"] = { "<nop>", desc = "Disable page up" },
          ["<Up>"] = { "<nop>", desc = "Disable up arrow" },
        }
    
        local keep_selection = {
          [">"] = { ">gv", desc = "Indent selection" },
          ["<"] = { "<gv", desc = "Dedent selection" },
        }
    
        local mappings = {
          n = no_operation,
          i = no_operation,
          o = no_operation,
          v = vim.tbl_deep_extend("force", {}, no_operation, keep_selection)
        }
        
        -- Apply the mappings
        require("astrocore").add_mappings(mappings)
      end,
    }
    

    The error is specifically coming from the trouble-nvim plugin in the astrocommunity collection, which is trying to access your mappings as a table but finding a function instead. Either of these approaches should resolve the issue.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.