Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error from fts/common.lua attempt to index python #379

Open
MikeLemo1 opened this issue Jun 4, 2024 · 2 comments
Open

Error from fts/common.lua attempt to index python #379

MikeLemo1 opened this issue Jun 4, 2024 · 2 comments

Comments

@MikeLemo1
Copy link

I've basically installed iron on ubuntu 24.04 the latest nvim with lazy in bash with the following slightly edited config:

 local M = {
  'Vigemus/iron.nvim'
}

function M.config()
  local iron = require("iron.core")

  iron.setup {
    config = {
      -- Whether a repl should be discarded or not
      scratch_repl = true,
      -- Your repl definitions come here
      repl_definition = {
        sh = {
          -- Can be a table or a function that
          -- returns a table (see below)
          command = {"bash"}
        }
      },
      -- How the repl window will be displayed
      -- See below for more information
      repl_open_cmd = require('iron.view').bottom(40),
    },
    -- Iron doesn't set keymaps by default anymore.
    -- You can set them here or manually add keymaps to the functions in iron.core
    keymaps = {
      send_motion = "<space>sc",
      visual_send = "<space>sc",
      send_file = "<space>ef",
      send_line = "<space>el",
      send_paragraph = "<space>sp",
      send_until_cursor = "<space>su",
      send_mark = "<space>sm",
      mark_motion = "<space>mc",
      mark_visual = "<space>mc",
      remove_mark = "<space>md",
      cr = "<space>s<cr>",
      interrupt = "<space>s<space>",
      exit = "<space>sq",
      clear = "<space>cl",
    },
    -- If the highlight is on, you can change how it looks
    -- For the available options, check nvim_set_hl
    highlight = {
      italic = true
    },
    ignore_blank_lines = true, -- ignore blank lines when sending visual select lines
  }

  -- iron also has a list of commands, see :h iron-commands for all available commands
  vim.keymap.set('n', '<space>rs', '<cmd>IronRepl<cr>')
  vim.keymap.set('n', '<space>rr', '<cmd>IronRestart<cr>')
  vim.keymap.set('n', '<space>rf', '<cmd>IronFocus<cr>')
  vim.keymap.set('n', '<space>rh', '<cmd>IronHide<cr>')

end

doing send_file sends the following error:

E5108: Error executing lua: ....local/share/nvim/lazy/iron.nvim/lua/iron/fts/common.lua:99: attempt to in
dex field 'python' (a nil value)
stack traceback:
        ....local/share/nvim/lazy/iron.nvim/lua/iron/fts/common.lua:99: in function 'format'
        ...g/.local/share/nvim/lazy/iron.nvim/lua/iron/lowlevel.lua:158: in function 'send_to_repl'
        .../pong/.local/share/nvim/lazy/iron.nvim/lua/iron/core.lua:238: in function 'send'
        .../pong/.local/share/nvim/lazy/iron.nvim/lua/iron/core.lua:249: in function 'send'
        .../pong/.local/share/nvim/lazy/iron.nvim/lua/iron/core.lua:290: in function <.../pong/.local/sha
re/nvim/lazy/iron.nvim/lua/iron/core.lua:276>

Any idea?

Also I'm not sure how to run the whole file, one line, visual selection with lua functions

@ottersome
Copy link
Contributor

@MikeLemo1 I am not associated to dev-team but here is a fix if you are in Linux:
Find the common.lua file inside of the package and set local is_python = false in line 93.
For the dev team (@nickeisenberg ) : there seems to be some nasty circular dependency: "common-> config -> init->python->common" Id be interested to write a PR if you guys'd like.

@nickeisenberg
Copy link
Contributor

@MikeLemo1 @ottersome Hey sorry for the late reply. There is a bug here that I noticed awhile back. I have been busy and was not able to get to it. The problem is that if repl_definition is not nil then you need to specify the setup for each language.

@ottersome feel free to submit a PR! That would be highly appreciated and I can look at it this weekend.

@MikeLemo1 a quick fix for this right now would be to do either of the following in your configuration:

  1. repl_definition = nil

    local python_format = require("iron.fts.common").bracketed_paste_python
    local repl_definition = {
      python = {
        command = { "python3" },
        format = python_format
      }
    }

    iron.setup {
      config = {
        ...,
        repl_definition = repl_definition
        ..., 
      },
      ...,
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants