https://github.com/chrisgrieser/nvim-puppeteer

Automatically convert strings to f-strings or template strings and back.

https://github.com/chrisgrieser/nvim-puppeteer

Science Score: 36.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: researchgate.net
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.2%) to scientific vocabulary

Keywords

f-strings neovim-plugin nvim-plugin string-manipulation template-strings

Keywords from Contributors

archival projection alfred-workflow interactive generic pdf-summarization sequences reference-management conventional-commit text-object
Last synced: 5 months ago · JSON representation

Repository

Automatically convert strings to f-strings or template strings and back.

Basic Info
  • Host: GitHub
  • Owner: chrisgrieser
  • License: mit
  • Language: Lua
  • Default Branch: main
  • Homepage:
  • Size: 99.6 KB
Statistics
  • Stars: 67
  • Watchers: 1
  • Forks: 4
  • Open Issues: 0
  • Releases: 0
Topics
f-strings neovim-plugin nvim-plugin string-manipulation template-strings
Created over 2 years ago · Last pushed 6 months ago
Metadata Files
Readme Funding License

README.md

nvim-puppeteer 🎎

Shield

Master of strings. Automatically convert strings to f-strings or template strings and back.

Features

  • When typing {} in a Python string automatically converts it to an f-string.
  • Adding ${} or a line break in a JavaScript string automatically converts it to a template string. (Also works in related languages like JS-React or Typescript.)
  • Typing %s in a non-pattern Lua string automatically converts it to a formatted string. (Opt-in, as this has some caveats.)
  • Removing the {}, ${}, or %s converts it back to a regular string.
  • Also works with multi-line strings and undos.
  • Zero configuration. Just install and you are ready to go.

Requirements

  • nvim 0.9 or higher.
  • The respective Treesitter parsers: :TSInstall python javascript typescript. (Installing them requires nvim-treesitter.)

Installation

```lua -- lazy.nvim { "chrisgrieser/nvim-puppeteer", lazy = false, -- plugin lazy-loads itself. Can also load on filetypes. },

-- packer use { "chrisgrieser/nvim-puppeteer" } ```

There is no .setup() call. The plugin already automatically lazy-loads itself (and is lightweight to begin with).

You can disable nvim-puppeteer only for specific filetypes via:

Configuration

Shown are the default values.

```lua -- list of filestypes (please see the README before enabling this plugin for lua) vim.g.puppeteerdisablefiletypes = { "lua" }

-- quotation mark to use when converting back to normal string (" or ') vim.g.puppeteerjsquotation_mark = '"' ```

[!NOTE] When using lazy.nvim, vim.g.… variables must be set in init, not in config.

User commands

The plugin is enabled by default and lazy-loaded upon opening a relevant file type. In case you wish to turn of puppeteer for the current buffer, the following user commands are provided:

  • PuppeteerToggle: Toggle puppeteer for the current buffer.
  • PuppeteerDisable: Disable puppeteer for the current buffer.
  • PuppeteerEnable: Enable puppeteer for the current buffer.

Special case: formatted strings in Lua

Through string.format, there are also formatted strings in Lua. However, auto-conversions are far more difficult in lua %s is used as a placeholder for string.format and as class in lua patterns at the same time. While it is possible to identify in some cases whether a lua string is used as pattern, there are certain cases where that is not possible:

```lua -- desired: conversion to format string when typing the placeholder "%s" local str = "foobar %s baz" -- before local str = ("foobar %s baz"):format() -- after

-- problem case that can be dealt with: "%s" used as class in lua pattern local found = str:find("foobar %s")

-- problem case that cannot be dealt with: "%s" in string, which -- is only later used as pattern local pattern = "foobar %s baz" -- some code… str:find(pattern) ```

Since the auto-conversion of lua strings can result in undesired false conversions, the feature is opt-in only. This way, you can decide for yourself whether the occasional false positive is worth it for you or not.

lua -- Enable auto-conversion of lua strings by removing lua from the disabled filetypes vim.g.puppeteer_disable_filetypes = {}

[!TIP] You can also use PuppeteerToggle to temporarily disable the plugin for the current buffer, if a specific lua string is giving you trouble.

Credits

In my day job, I am a sociologist studying the social mechanisms underlying the digital economy. For my PhD project, I investigate the governance of the app economy and how software ecosystems manage the tension between innovation and compatibility. If you are interested in this subject, feel free to get in touch.

Buy Me a Coffee at ko-fi.com

Owner

  • Name: Chris Grieser
  • Login: chrisgrieser
  • Kind: user
  • Location: Berlin, Germany
  • Company: Technical University of Berlin

Researcher in sociology & software developer

GitHub Events

Total
  • Issues event: 4
  • Watch event: 8
  • Delete event: 1
  • Issue comment event: 2
  • Push event: 27
  • Pull request event: 6
  • Fork event: 1
  • Create event: 4
Last Year
  • Issues event: 4
  • Watch event: 8
  • Delete event: 1
  • Issue comment event: 2
  • Push event: 27
  • Pull request event: 6
  • Fork event: 1
  • Create event: 4

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 173
  • Total Committers: 5
  • Avg Commits per committer: 34.6
  • Development Distribution Score (DDS): 0.052
Past Year
  • Commits: 45
  • Committers: 2
  • Avg Commits per committer: 22.5
  • Development Distribution Score (DDS): 0.044
Top Committers
Name Email Commits
Chris Grieser 7****r 164
Sergey Kochetkov s****3@p****e 3
dependabot[bot] 4****] 2
Kevin Witlox k****x@u****l 2
Gui g****l 2
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 9 months ago

All Time
  • Total issues: 16
  • Total pull requests: 6
  • Average time to close issues: about 1 month
  • Average time to close pull requests: about 6 hours
  • Total issue authors: 12
  • Total pull request authors: 4
  • Average comments per issue: 2.88
  • Average comments per pull request: 1.83
  • Merged pull requests: 6
  • Bot issues: 0
  • Bot pull requests: 2
Past Year
  • Issues: 2
  • Pull requests: 2
  • Average time to close issues: 31 minutes
  • Average time to close pull requests: 8 minutes
  • Issue authors: 2
  • Pull request authors: 1
  • Average comments per issue: 1.0
  • Average comments per pull request: 0.0
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 2
Top Authors
Issue Authors
  • Popkornium18 (2)
  • gbcreation (2)
  • skoch13 (1)
  • simonmandlik (1)
  • MoritzBoehme (1)
  • kwyntes (1)
  • TroySigX (1)
  • mhellstr (1)
  • roobert (1)
  • frdwhite24 (1)
  • z775729168 (1)
  • alvarosevilla95 (1)
Pull Request Authors
  • dependabot[bot] (4)
  • Quitlox (4)
  • skoch13 (1)
  • guivazcabral (1)
Top Labels
Issue Labels
bug (10) enhancement (4) help wanted (1) Stale (1)
Pull Request Labels
dependencies (4) github_actions (3)

Dependencies

.github/workflows/panvimdoc.yml actions
  • actions/checkout v2 composite
  • kdheepak/panvimdoc main composite
  • stefanzweifel/git-auto-commit-action v4 composite
.github/workflows/stale-bot.yml actions
  • actions/stale v8 composite
.github/workflows/stylua.yml actions
  • JohnnyMorganz/stylua-action v2 composite
  • actions/checkout v3 composite