Something went wrong. Try again.
Neovim config
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104local fn = vim.fn
local M = {}
function M.buf_preview_maker(filepath, bufnr, opts) filepath = vim.fn.expand(filepath) require("plenary.job") :new({ command = "file", args = { "--mime-type", "-b", filepath }, on_exit = function(j) local mime_type = vim.split(j:result()[1], "/")[1] if mime_type == "text" or mime_type == "application" then require("telescope.previewers").buffer_previewer_maker(filepath, bufnr, opts) else vim.schedule(function() vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, { "BINARY" }) end) end end, }) :sync()end
function M.use_theme(picker_opts) local theme = "dropdown" local opts = { layout_config = { anchor = "N", width = 0.5, height = 0.5, }, } if picker_opts then for k, v in pairs(picker_opts) do opts[k] = v end end return require("telescope.themes")["get_" .. theme](opts)end
function M.pick(type) local t = setmetatable({}, { __index = function(_, picker) return function(use, opts) local picker_opts = use == false and opts or M.use_theme(opts) require(type)[picker](picker_opts) end end, }) return tend
local tb = M.pick("telescope.builtin")
function M.get_nvim_conf() local opts = { prompt_title = "Neovim Config", cwd = fn.stdpath("config"), no_ignore = true, } tb.find_files(_, opts)end
function M.get_relative_file() local cwd = fn.expand("%:p:h") local sp_buf = { "oil", "fugitive", "term" } for _, b in pairs(sp_buf) do local _, i = string.find(cwd, string.format("^%s://%%g+", b)) if i then cwd = string.sub(cwd, i + 1) break end end local opts = { prompt_title = "Relative Files", cwd = cwd, preview = true, no_ignore = true, } tb.find_files(_, opts)end
function M.get_dwots() local dothome = function() if vim.uv.os_uname().sysname == "Darwin" then return fn.finddir("~/dwots_mac/") end return fn.finddir("~/dwots/") end local opts = { prompt_title = "Dotfiles", cwd = dothome(), find_command = { "fd", "--hidden", "--exclude", ".git", "--type", "file" }, } if dothome() == "" then vim.notify("Dotfile directory not found!", vim.log.levels.ERROR) else tb.find_files(_, opts) endend
return M