GithubHelp home page GithubHelp logo

Comments (5)

rktjmp avatar rktjmp commented on June 14, 2024 1

Will be fixed in #9, both lexer detection and you can now call any of the API functions with an optional provider name and provider options table.

The lexer list isn't actually as complete as you posted on the live site, only

  ;; list got by posting an unknown lexer to dpaste, returns list of supported types
  ;; yes, typ_o_script (???)
  (let [known-filetypes ["applescript" "arduino" "bash" "bat" "c" "clojure"
                         "cmake" "coffee-script" "common-lisp" "console" "cpp"
                         "cpp-objdump" "csharp" "css" "cuda" "d" "dart,
                         delphi" "diff" "django" "docker" "elixir" "erlang"
                         "go" "handlebars" "haskell" "html" "html+django"
                         "ini" "ipythonconsole" "irc" "java" "js" "json" "jsx"
                         "kotlin" "less" "lua" "make" "matlab" "nginx" "numpy"
                         "objective-c" "perl" "php" "postgresql" "python" "rb"
                         "rst" "rust" "sass" "scss" "sol" "sql" "swift" "tex"
                         "typoscript" "vim" "xml" "xslt" "yaml"]]

require 'paperplanes'.PP(provider_opts)

This would be done (when 0.1.2 is merged or if you checkout that branch) via

-- assumes you've just made a visual selection before running
:lua require("paperplanes").post_selection("my_provider", {opt = "tion"})

Or any of the other post_string, post_buffer or post_range.

from paperplanes.nvim.

rktjmp avatar rktjmp commented on June 14, 2024

I actually did have that originally but dpaste would hard-fail if it didn't recognise the filetype:

(fn provide [content metadata opts]
;; dpaste accepts a lexer option, but will 400 error if it doesn't recognise
;; it so we will instead rely on the filename sniffer, which falls back to
;; text if doesn't recognise the extension.

dpaste should just be finding the correct lexer by extension. That did work when I first wrote the code but dpaste may have changed.

from paperplanes.nvim.

RaafatTurki avatar RaafatTurki commented on June 14, 2024

You could use this lua table I made, I got that list from the dpaste docs and formatted it into a lua table.
And only provide curl with -F "lexer=..." if filetype is in that table.

The logic can be later improved to be smarter and knows when to use more complex lexers.
For example if you were editing an html file in a django project it's probably a django template with many curly brackets:

-F "lexer=html"
image

-F "lexer=html+django"
image

from paperplanes.nvim.

rktjmp avatar rktjmp commented on June 14, 2024

Yep seems reasonable enough to include a lookup table for known types, not 100% sure how accurate the filetypes there map to what Neovim uses for filetypes though (i.e. "js+erb" might be "erb-js" in nvim, not sure).

I think :PP should take options too as I thought here #2 (comment) and you're suggesting.

:PP lexer=python which could probably be merged into the provider options.

from paperplanes.nvim.

RaafatTurki avatar RaafatTurki commented on June 14, 2024

You don't have to be sure about its accuracy for now, if neovim can't find erb-js in the table it won't set a lexer.

I'd say leave :PP the way it is and instead provide a lua function that takes provider_opts as a table, something like require 'paperplanes'.PP(provider_opts)

from paperplanes.nvim.

Related Issues (7)

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.