Myzel394 / jsonfly.nvim

❴🦋❵ Fly through your JSON / XML / YAML files with ease. Search ✨ blazingly fast ✨ for keys via Telescope.
125 stars 2 forks source link

Search through an array #3

Closed victorgdb closed 2 months ago

victorgdb commented 2 months ago

Hello, first of all this plugin is amazing. Kudos for it!

I have a large array, and I would like to get a specific array index. Is it doable?

package.components[0] doens't return the first component.

Other question, do you think it would be possible to run the code through a unsaved buffer (to avoid having to save the buffer to a file.json)?

Thanks!

Myzel394 commented 2 months ago

I have a large array, and I would like to get a specific array index. Is it doable?

This should work already via package.components.0 in this case. Are the indexes not showing up for you?

Other question, do you think it would be possible to run the code through a unsaved buffer (to avoid having to save the buffer to a file.json)?

I'm not sure what you mean. Can you elaborate?

victorgdb commented 2 months ago

Thanks for your prompt answer! package.components.0 doesn't return anything for me, could it be because the json file is too big (12K lines)?

Screenshot 2024-04-17 at 10 06 25

Attached a screenshot showing the results part for the search components, it seems 0 is not displayed. But .1 is not working either.

I'm not sure what you mean. Can you elaborate?

  1. I copy a JSON from what returns my API
  2. I create a new buffer to receive this json
  3. I paste the copied JSON

I would like to be able to run jsonfly on the unamed temporary buffer I've just created, but apparently I need to save this buffer as a json file :w test.json first. I would prefer not to store any json file, since they are temporary.

Myzel394 commented 2 months ago

package.components.0 doesn't return anything for me

Ahh I see. Can you try changing the backend to the native lua one:

require"telescope".setup {
    extensions = {
        jsonfly = {
            backend = "lua"
        }
    }
}

I guess there's something up with the lsp backend...

I create a new buffer to receive this json

I personally don't work with unnamed (?) buffers, how do you create them? I can see if there's some way to add support for that :D

victorgdb commented 2 months ago
      require('telescope').load_extension 'jsonfly'
      require('telescope').setup {
        defaults = {
          -- `hidden = true` is not supported in text grep commands.
          vimgrep_arguments = vimgrep_arguments,
        },
        pickers = {
          find_files = {
            -- `hidden = true` will still show the inside of `.git/` as it's not `.gitignore`d.
            find_command = {
              'rg',
              '--files',
              '--ignore',
              '--hidden',
              '-u',
              '--glob',
              '!**/.git/*',
              '--glob',
              '!**/node_modules/*',
              '--glob',
              '!**/.next/*',
              '--glob',
              '!**/dist/*',
            },
          },
        },
        extensions = {
          fzf = true,
          jsonfly = {
            backend = 'lua',
          },
        },
      }

Does this configuration look correct to you? Because with it it's still not working.

I'm far from being a vim expert, I use :tabnew to add a new buffer. What would be your flow to analyze a json copied from an external source?

Myzel394 commented 2 months ago

All right so I've spoken to the LSP and told them their behavior is completely unacceptable. Luckily they said it's no problem to also parse arrays and it should work now. Can you update the plugin and test if it works? (make sure you are at least on commit 52d56f2e072c91b0da548db48f4e9375b29d740f)

Myzel394 commented 2 months ago

I'm far from being a vim expert, I use :tabnew to add a new buffer. What would be your flow to analyze a json copied from an external source?

When I use APIs or other external stuff, I personally use jq most of the times

victorgdb commented 2 months ago

Amazing it's now working!!! Thanks again for your time 🙇