nvim-telescope / telescope-cheat.nvim

WIP integration

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

telescope-cheat.nvim

An attempt to recreate cheat.sh with lua, neovim, sqlite.lua, and telescope.nvim.

Installation

Install via your favorite package manager:

use {
    "nvim-telescope/telescope-cheat.nvim",
    requires = {
        "kkharji/sqlite.lua",
        "nvim-telescope/telescope.nvim"
    }
}

require("telescope").load_extension("cheat")
require("lazy").setup({
    "nvim-telescope/telescope-cheat.nvim",
    dependencies = {
        "kkharji/sqlite.lua",
        "nvim-telescope/telescope.nvim"
    }
})

require("telescope").load_extension("cheat")

Usage

:Telescope cheat fd
:Telescope cheat recache " cheat will be auto cached with new updates on sources

Contribution

New sources can be defined in ./lua/telescope/_extensions/cheat/sources.lua.

Example:

M[2] = {
  name = "learnxinyminutes",
  uri = "https://github.com/adambard/learnxinyminutes-docs",
  root = "",
  depth = 1,
  pattern = ".*%.html%.markdown",
  add_dirs = false,
  ft = "markdown",
  parse = function(path)
    local content = p.readlines(path)
    if content[1]:find('---', 1, true) then
      local minus_count = 0
      while minus_count < 2 do
        if content[1]:find('---', 1, true) then minus_count = minus_count + 1 end
        table.remove(content, 1)
      end
    end
    while content[1] == '' do
      table.remove(content, 1)
    end

    return table.concat(content, '\n')
  end,
  get_ns_keyword = function(path)
    return "lang", path:match('.*/([^./]+).*')
  end
}

About

WIP integration

License:MIT License


Languages

Language:Lua 100.0%