Comments (14)
Provider post-string
and post-file
both accept a meta
argument right now, but it's filled automatically with just the file details (path, extension, etc). Not all providers actually use this though, (ixio.fnl
does).
The main API doesn't expose any meta-var except when calling post-string
directly (this was actually omitted from the docs), It's probably reasonable to add a meta var to the tail of the others functions but then its out of sync with post-string
, so I would want to shuffle that around. Which would be a breaking change.
The fact that the docs were wrong and no one raised an issue and the plugin is pretty niche probably means its unlikely actually break anything, probably....
I think I would wonder what the user interface should look like. I think you would want to set a default & probably need a way to set per-post settings.
The the :PP
command might accept x=y
arguments maybe.
from paperplanes.nvim.
I thought about specifying such default arguments in setup method. For example:
-- options shown with default values
require("paperplanes").setup({
register = "+",
provider = "dpaste.org",
expire_time = 3600,
-- default file format (it should be set based on vim filetype if not explicitly specified)
-- which sets filename and lexer in case of dpaste.org
file_format = "python"
})
Though Your idea to specify arguments with :PP
command is also nice. Never the less I'd like to set some defaults that are different then provider's defaults.
from paperplanes.nvim.
You also need to specify a token for paste.sr.ht, I think it would be better to have something like
require("paperplanes").setup({
provider = "srht",
provider_opts = { token = "xxx" }
})
and then the make
function can get these opts using something like
local token = require("paperplanes").get_config().provider_opts.token
from paperplanes.nvim.
I will admit this totally slipped my mind.
You can sample this branch https://github.com/rktjmp/paperplanes.nvim/tree/provider-opts you should be able to just pass a provider_options
table to setup.
paperplanes.nvim/fnl/paperplanes.fnl
Lines 7 to 9 in e8e1907
dpaste.org
is the only provider updated to handle options right now as a test, patches welcome until I get around to the other providers or adding sr.ht (you only need post-string
really), build instructions at the bottom of the readme.
paperplanes.nvim/fnl/paperplanes/providers/dpasteorg.fnl
Lines 3 to 8 in e8e1907
from paperplanes.nvim.
Should I make a PR against that branch?
from paperplanes.nvim.
ah the token is supplied using an iAuthorization: token xxxxxxxx
header
from paperplanes.nvim.
Yes against that branch is preferred.
I know you striked it, but right now everything is send as form data because that's just how the original providers accepted options. Not against refactoring to support both and returning a richer curl-args datastructure. There's actually a number of bits to clean up in the code tbh.
from paperplanes.nvim.
What's wrong here?
I added a print statement here and post-args seem to be fine:
https://github.com/p00f/paperplanes.nvim/blob/696ddcb2487245b6715bb07620fff02b705ca527/fnl/paperplanes.fnl#L34
Passing the same thing to curl works:
from paperplanes.nvim.
It's something to do with how uv.spawn (and curl?) handle arguments with quotes.
# See added quote marks
curl --silent --show-error --write-out "\n%{response_code}" --header "Authorization:'token <TOKEN>'" \
--header Content-Type:'application/json' https://paste.sr.ht/api/pastes \
--data '{"files":[{"filename":"README.md","contents":"contentttt"}],"visibility":"unlisted"}'
{"errors": [{"reason": "No authorization supplied (expected an OAuth token)"}]}
401%
Spawn may wrap them (or whatever handles the args eventually) with quotes to curl sends the header literally as "Auth..:"
instead of Auth: ..
?
Wrapping the header with escaped quotes in the provider itself.
from paperplanes.nvim.
Running curl with -vvv
shows:
Without quotes (creates paste) --header Authorization:'token TOKEN'
> authorization:token TOKEN
> content-type:application/json
With quotes (fails) --header "Authorization:'token TOKEN'"
> authorization:'token TOKEN'
> content-type:application/json
Note the single quotes in the second request. That'll be it probably.
from paperplanes.nvim.
I don't have those extra quotes in my request either though - see the output of (print (table.concat post-args))
in the first screenshot
from paperplanes.nvim.
uv.spawn
is "adding" them with how args are passed to exec.
from paperplanes.nvim.
See PR review, should fix it.
from paperplanes.nvim.
Fixed (?) in #5, currently only sr.ht
and dpaste.org
support provider_options
, PR's welcome. Thank you all for your contributions.
from paperplanes.nvim.
Related Issues (7)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from paperplanes.nvim.