GithubHelp home page GithubHelp logo

rktjmp / paperplanes.nvim Goto Github PK

View Code? Open in Web Editor NEW
87.0 3.0 3.0 219 KB

Neovim :airplane: Pastebins

License: MIT License

Fennel 98.98% Vim Script 0.33% Lua 0.69%
neovim neovim-plugin lua fennel pastebin

paperplanes.nvim's Introduction

paperplanes.nvim

paperplanes Logo

Post selections or buffers to online paste bins. Save the URL to a register, or dont.

Requirements

  • Neovim 0.5+
  • A curl executable in your $PATH

Install

Use your package manager.

Configuration & Use

Setup

-- options shown with default values
require("paperplanes").setup({
  register = "+",
  provider = "0x0.st",
  provider_options = {},
  notifier = vim.notify or print,
})
  • register - any valid register name or false
  • provider - See provider list.
  • provider_options - passed to selected provider, see list of providers below for accepted options
  • notifier - any function that accepts a string, should show that string in some way.

Commands

Post selection or buffer to configured provider, sets configured register and print's the result.

  • :PP -> Post current buffer.

  • :[range]PP -> Post range.

    • Vim does not support column aware ranges when using commands. Use post_selection via a map for that behaviour.

Functions

See :h paperplanes for more complete documentation.

Functions are provided in snake_case and kebab-case (post_string and post-string).

All functions accept a callback argument which is called with url, nil or nil, errors.

provider-name and provider-options are optional and the default provider will be used if not given.

Functions to not automatically print the url or set any registers.

  • post_string(content, metadata, callback, provider-name, provider-options)
  • post_range(buffer, start_pos, end_pos, callback, provider-name, provider-options)
  • post_selection(callback, provider-name, provider-options)
  • post_buffer(buffer, callback, provider-name, provider-options)

Providers

paperplanes supports the following providers, see sites for TOS and features.

  • https://0x0.st (provider = "0x0.st")
  • https://paste.rs (provider = "paste.rs")
  • https://paste.sr.ht (provider = "sr.ht")
    • command: "curl" (default) or "hut".
    • token: PAT token string, or function returning token string, required if command = "curl" | nil.
  • https://gist.github.com (provider = "gist")
    • command: "curl" (default) or "gh".
    • token: PAT token string or function returning token string, required if command = "curl" | nil.
  • https://dpaste.org (provider = "dpaste.org")
  • https://ray.so (provider = "ray.so")
  • https://mystb.in (provider = "mystb.in")
  • http://ix.io (provider = "ix.io")
    • Endpoint is HTTP only, requires insecure = true explicit opt in.
  • http://sprunge.us (provider = "sprunge.us")
    • Endpoint is HTTP only, requires insecure = true explicit opt in.

To create a new provider, see :h paperplanes and fnl/paperplanes/providers/*.fnl.

paperplanes is not affiliated with any provider in any manner.

Building

Building paperplanes requires hotpot.nvim v0.9.7+.

The relevant lua| files should be build when saving any file inside fnl/.

Changelog

See CHANGELOG.md.

paperplanes.nvim's People

Contributors

nullishamy avatar p00f avatar rktjmp avatar shurizzle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

paperplanes.nvim's Issues

dpaste unreliability?

PP:'ing

local uv vim.loop → Ok

;; local uv vim.loop → "no content given"

(local uv vim.loop)

--------------------------08b6e6dad0073ff4--

Should not need to escape content when sending it as an arg as exec should be doing this for us but something is obviously incorrect, perhaps upstream parser was updated or ...?

Using (fmt "%s=%q" key content) corrects the ---<garbage> response but newline slashes are double escaped so each new line in the paste is postfixed with \.

Possible solution: copy 0x0st, write paste content to file and try attaching that instead.

(also: include warning that some providers use file to send content and secrets may remain if a post fails / provider fails to clean up after itself)

Customize each :PP call

Some providers like dpaste.org give the ability to chose syntax highlighting.
In the case of dpaste you'd add -F "lexer=lua" to your curl command.
I wanted :PP to automatically put the current filetype in there.

Maybe cmd() should take provider_options as an argument and set the dpaste provider to have a lexer provider option?

Keep in mind that I can't read fennel so if something like this was already implemented an example config would be very appreciated.

vim.notify

As of 0.1.1, paperplanes will use vim.notify if it is present. This means your urls may be reported back in a useful or not useful manner (i.e. un-clickable or selectable).

I don't use any fancy wrapper, vim.notify == print for me, so the usability is the same. Possibly this isn't true for all wrappers or UIs so please post in this issue if you want an option manually specify a notification handler function (or submit a PR that adds one to the default options and uses it).

(local options {:register :+
:provider "0x0.st"
:provider_options {}
:cmd :curl})

notify-attempt #(let [msg (fmt "%s'ing..." (get-option :provider))
show (or vim.notify print)]
(show msg))]

ray.so needs tweaking for updated API

The ray.so implementation appears to no longer work. Not a huge deal for me, but might be worth noting just so people don't spend too long trying to tinker with it.

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.