Giter Site home page Giter Site logo

nvim-regexplainer's Issues

FR: Config to change the border style

regexplainer seems to use nui popups that always have the "shadow" border style. Since all my other popups have a different border style, it would be nice if they were consistent, meaning an option to change the popup border style would be very useful.

Not working

I'm unable to get this to run.

I first tried installing it in an lazy-idiomatic way:

    {
        "bennypowers/nvim-regexplainer",
        dependencies = {
            "nvim-treesitter/nvim-treesitter",
            "MunifTanjim/nui.nvim",
        },
        keys = {
            {
                "<leader>cx",
                "<cmd>Regexplainer<cr>",
                desc = "Explain regex",
                mode = "n",
            },
        },
    },

Since this didn't work, I then tried to install it like in the documentation:

    {
        "bennypowers/nvim-regexplainer",
        dependencies = {
            "nvim-treesitter/nvim-treesitter",
            "MunifTanjim/nui.nvim",
        },
        config = function()
            -- defaults
            require'regexplainer'.setup {
              -- 'narrative'
              mode = 'narrative', -- TODO: 'ascii', 'graphical'

              -- automatically show the explainer when the cursor enters a regexp
              auto = false,

              -- filetypes (i.e. extensions) in which to run the autocommand
              filetypes = {
                'html',
                'js',
                'cjs',
                'mjs',
                'ts',
                'jsx',
                'tsx',
                'cjsx',
                'mjsx',
              },

              -- Whether to log debug messages
              debug = false,

              -- 'split', 'popup'
              display = 'popup',

              mappings = {
                toggle = 'gR',
                -- examples, not defaults:
                -- show = 'gS',
                -- hide = 'gH',
                -- show_split = 'gP',
                -- show_popup = 'gU',
              },

              narrative = {
                indendation_string = '> ', -- default '  '
              },
            }
        end,
    },

However, this isn't working either. I reinstalled the treesitter parsers using :TSInstall regex typescript, but to no avail.

Error about the auto option

It seems that when the initial position of the cursor is on the regular expression when the program starts, the auto option causes an error.

Support for other languages

Currently I can only reproduce the examples in the readme, and failed to get the popup in other lang, like bash or lua? Is this plugin js/ts specific?

P.S. I had already install the regex bash lua ts parsers and set them in regexplainer's config

Can't show split if auto is set and display is popup

with this config, one can't show a split using :RegexplainerShowSplit

require'regexplainer'.setup {
  auto = true,
  display = 'popup',
}

I believe that what's happening is the split is open with the command, but that triggers the autocommand which closes the split, then reopens the popup

cannot get it to open - even on the test files.

I have just installed nvim-regexplainer but I cannot get it to actually show up.
I use lunarvim (nvim with config from lunarvim.org) but the config etc is the usual lua way:

{ 'bennypowers/nvim-regexplainer',
    requires = {
      'nvim-lua/plenary.nvim',
      'MunifTanjim/nui.nvim',
    },
    config = function() require'regexplainer'.setup({
   -- 'narrative'
  mode = 'narrative', -- TODO: 'ascii', 'graphical'

  -- automatically show the explainer when the cursor enters a regexp
  auto = true,

  -- Whether to log debug messages
  debug = false,

  -- 'split', 'popup'
  display = 'popup',

  mappings = {
    toggle = 'gR',
    -- examples, not defaults:
    -- show = 'gS',
    -- hide = 'gH',
    show_split = 'gP',
    show_popup = 'gU',
  },

  narrative = {
    separator = '\n',
  },
  })
  end,
}

I can see that it is loaded (the gR, gH etc mappings are available and also the :RegexplainerShow etc) but nothing happens when I call any of them. Nothing in :messages - even when I call :RegexplainerDebug

nvim version 0.7.0-dev

any idea?

auto-hide popup after manual show/toggle

Hi, love the plugin! Will make writing regex so much better. I'm wondering if this is either a bug or needs implementing; I want to have auto = false for the config, so I have to manually show the popup, but then when I move my cursor away on to a different line, it auto hides. Currently the popup persists until I hide it/toggle it off again. Not a deal breaker but more keystrokes than necessary!

Needs tests

The project has grown to the point that manual testing is no longer sufficient

We need automated tests that will cover at least the following:

  • testing narrative results for any given regexp
  • testing options like split, pop-up, display options

I've briefly glanced at busted but that seems insufficient on it's own, since so much of what the plugin does relies on treesitter and nui. What we need are proper integration tests.

\d\.\d\.\d

/elements@\d\.\d\.\d\/elements\/.*lightdom\.css$/;

EXPECTED:

`elements@`
**0-9**
`.`
**0-9**
`.`
**0-9**
`/elements/`
**ANY** (_>= 0x_)
`lightdom.css`
**END**

ACTUAL:

`elements@`
**d.**
**d.**
`\\d/elements/`
**ANY** (_>= 0x_)
`lightdom.css`
**END**

Incorrect interpretation of a negated character list `[^p]`

Awesome idea!
I tried a simple regex in a scratch buffer:

let reggie = /^p[^p]*p/

Regexplainer incorrectly explains it like so:

START
`p`
One of ^, or p (>= 0x)
`p`

image

The first caret is correctly explained as the "start" anchor, but the second caret is interpreted as part of the character list.
The first caret inside square brackets actually negates the character list.

So maybe the output of regexplainer would be:

START
`p`
Any character not in the list: `p` (>= 0x)
`p`

And for a character list with multiple characters, e.g. /^p[^p^a]*p/:

START
`p`
Any character not in the list: `p`, `^`, `a` (>= 0x)
`p`

This is how regex101 treats that last example: https://regex101.com/r/mGQXlb/1

Remove nui dependency

I'd like to use this plugin but as someone averse to clutter installing nui.nvim for this single plugin just does not warrant it.

If you are ok with the addition of this feature I could make the PR myself.

`RegexplainerToggle` support

Hi, I think it'll be a very beneficial feature to be able to set one keybinding for both hiding and showing the explainer based on its current state, or at least having a default binding to be able to exit from open windows with <Esc>.

Transparency with `winblend`

Hi, it would be nice to be able to set transparency of the popup window using vim.api.nvim_win_set_option(winnr, "winblend", ?), where ? can be passed in as a config option :))

Not usable

Hello Guys,

i wanted to try this amazing plugin.

But calling any of the provided Regexplain functions as well as the autocmd don't work.
I tried creating files with supported filetypes and several keybindings formats.

Is this error just in the latest release?

Best regards

Missing escapes, alternation terms

User donbex at neovim discourse noted that some escape chars and alternation terms were missing from explanations

to wit:

let re = /@scope\/(.*)\.(?<extension>graphql|(?:t|j|cs)s)";?/;
                       ^                               ^

was missing the escaped . after the first anonymous capture group, and the s following the (cs) capture group

Rexexplainer: loop exceeded 1000 at node start_tag

in certain HTML files, Regexplainer can try too hard to find a pattern in start_tag, end_tag, or text nodes. I don't have a minimal repro, but check rh-audio-player detailed-transcript.html demo, particularly in the cue elements

Support for unicode escape characters

Currently, regex like /[\u005D-\uFFFF]/: is parsed as a set of literals, not as a unicode range:

One of `u`, `0`, `0`, `5`, `D-\\u`, `F`, `F`, `F`, or `F`

It should be something like:

One of \u005D-\uFFF

Backreferences

/(['"]).*?\1/g

EXPECTED:

capture group 1:
> One of `'`, or `"`
**ANY** (_>= 0x_) (_lazy_)
(capture group 1)

ACTUAL:

capture group 1:
> One of `'`, or `"`
**ANY** (_>= 0x_) (_lazy_)
`1`

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.