Git Product home page Git Product logo

csvlens.nvim's Introduction

csvlens.nvim

A way to easily preview CSV files, as well as other separated filetypes, directly in neovim. Backed by YS-L/csvlens.

Csvlens_Demo.mov

Notes

Requires Neovim version 0.7.0 or greater. This plugin depends on toggleterm.nvim as the UI for the previewer.

Quickstart

lazy.nvim installation

return {
    "theKnightsOfRohan/csvlens.nvim",
    dependencies = {
        "akinsho/toggleterm.nvim"
    },
    config = true,
    opts = { --[[ Place your opts here ]] }
}

Config

This plugin requires you to have csvlens installed and in your PATH. You can install it automatically with this plugin, and it will be installed in $HOME/.local/bin, or you could install it using your terminal package manager of choice. You can also manually specify the path of the executable as part of the configuration.

A default config will contain the following:

require("csvlens").setup({
    direction = "float", -- "float" | "vertical" | "horizontal" |  "tab"
    exec_path = "csvlens", -- You can specify the path to the executable if you wish. Otherwise, it will use the command in the PATH.
    exec_install_path = vim.fn.stdpath("data") .. "/csvlens.nvim/", -- directory to install the executable to if it's not found in the exec_path, ends with /
})

The exec_path is prioritized as the executable location, with the exec_install_path as a backup. If it is not found in either location, the executable will be installed.

Due to the way the toggleterm API works, the csvlens preview config will take precedence over the toggleterm config for csvlens's previews.

Usage

This plugin is designed to be simple and easy to use. Open the csv file that you want to preview, then use the command :Csvlens to open a window with the preview of the opened table. The keyboard commands in this window are the same as csvlens's. Typing H in the preview will open up the help menu for csvlens, where you can find the keybindings.

You can also open a file with custom delimiters by passing them as string arguments to the command. For example, :Csvlens "$" would open the preview as if the open file were separated by $. All separators must be one character, with the exception of \t. However, this plugin will automatically use tabs as the delimiter if opening a tsv file.

Alternatives

VidocqH/data-viewer.nvim

  • This plugin supports sqlite as well
  • However, I don't like how the UI looks. csvlens looks much better to me, which is why I wanted to make this port.

Credits

The automatic download script was taken and built off of from ellisonleao/glow.nvim.

csvlens.nvim's People

Contributors

theknightsofrohan avatar github-actions[bot] avatar

Stargazers

Ivan Yordanov avatar Patrick Dewey avatar Raphael "Raph" "wrath" Vaz avatar  avatar  avatar Hungchienpeter avatar CofCat avatar Jesse Claven avatar Laurent Seigneurie avatar Viktor Ashcheulov avatar  avatar Guozhu Liu avatar Ritik avatar Mongkonchai Priyachiwa avatar  avatar Iain Simmons avatar Ivan Smirnov avatar Ole Jan Lars Riemann avatar  avatar  avatar Garner Halloran avatar  avatar Hisbaan Noorani avatar Will Hopkins avatar Gianni Young avatar vadim avatar Naser Aleisa avatar Chaz avatar Can Berk Cetin avatar Yuta Katayama avatar

Watchers

 avatar  avatar

csvlens.nvim's Issues

Cannot call Csvlens:open_csv

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.