theKnightsOfRohan/csvlens.nvim

Cannot call Csvlens:open_csv

Closed this issue · 1 comments

Issue

Hi, thanks for creating this plugin :). I tried to use the plugin but with the default configuration, it kept complaining about command_args ,and then self.* is nil in Cslens:open_csv. I am not very familiar with Lua but I understand by calling : you can access self but it is not a case.

I managed to make it work after modifying the function as following

--Changed self to Csvlens

function Csvlens:open_csv(command_args)
    if not Csvlens._verified then
        Installer:install_flow()
    end
    local delimiter = ','
    --Added checking for no command_args.
    if command_args ~= nil then
        delimiter = command_args.fargs[1]
    end
    local file_to_open = vim.fn.expand("%:p")
    local constructed_cmd = Utils:_construct_cmd(Csvlens._config.exec_path, file_to_open, delimiter)
    if not constructed_cmd then
        vim.api.nvim_err_writeln(
            "ERROR: " .. file_to_open .. " is not a csv or tsv file, or a delimiter was not provided."
        )
        return
    end

    UI.open(constructed_cmd, Csvlens._config)
end

My setup

  • Neovim: NVIM v0.9.5
    • Using Lazy for package manager
  • Lua: Lua 5.4.6 Copyright (C) 1994-2023 Lua.org, PUC-Rio
  • Latest version this plugin
  • OS: MacOS 14

Hey there! Sorry for the trouble. There was a bug I had overlooked when refactoring some of the code, and I had incorrectly called the new open_csv method when creating the :Csvlens command. It should be working as intended now!