someone-stole-my-name / yaml-companion.nvim

Get, set and autodetect YAML schemas in your buffers.
MIT License
202 stars 18 forks source link

Error when trying to open Telescope picker #7

Closed marcusramberg closed 2 years ago

marcusramberg commented 2 years ago
stack traceback:
        ...n.nvim/lua/telescope/_extensions/yaml_schema_builtin.lua:21: in function 'yaml_schema'
        ...n.nvim/lua/telescope/_extensions/yaml_schema_builtin.lua:59: in function <...n.nvim/lua/telescope/_extensions/yaml_schema_builtin.lua:58>
        ...ck/packer/start/telescope.nvim/lua/telescope/command.lua:193: in function 'run_command'
        ...ck/packer/start/telescope.nvim/lua/telescope/command.lua:253: in function 'load_command'
        ...te/pack/packer/start/telescope.nvim/plugin/telescope.lua:109: in function <...te/pack/packer/start/telescope.nvim/plugin/telescope.lua:108>

My config looks like this:

  use {
  "someone-stole-my-name/yaml-companion.nvim",
  requires = {
    { "nvim-lua/plenary.nvim"},
    { "nvim-telescope/telescope.nvim" },
  },
  config = function()
    require("telescope").load_extension("yaml_schema")
    local cfg = require("yaml-companion").setup({
        result = {
          {
            name = "Kubernetes 1.22.4",
            uri = "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.22.4-standalone-strict/all.json",
          },
          { 
            name = "Taskfile",
            uri = "https://gist.githubusercontent.com/KROSF/c5435acf590acd632f71bb720f685895/raw/6f11aa982ad09a341e20fa7f4beed1a1b2a8f40e/taskfile.schema.json",
          }
        },
      })
    require("lspconfig")["yamlls"].setup(cfg)
  end,
}
someone-stole-my-name commented 2 years ago

It is crashing on a line that merges your custom schemas defined during setup with the LSP ones. Can you update the plugin and post the output of:

:lua print(vim.inspect(require("yaml-companion.config").options))

Your setup is wrong too btw but shouldn't cause it to crash. The Kubernetes support is built-in, so you don't really need to redefine another schema for it unless you need multiple versions. If you want to have "Kubernetes 1.22.4" and "Taskfile" schemas available in Telescope, your setup should look like:

      local cfg = require("yaml-companion").setup({
        schemas = {
          result = {
            {
              name = "Kubernetes 1.22.4",
              uri = "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.22.4-standalone-strict/all.json",
            },
            {
              name = "Taskfile",
              uri = "https://gist.githubusercontent.com/KROSF/c5435acf590acd632f71bb720f685895/raw/6f11aa982ad09a341e20fa7f4beed1a1b2a8f40e/taskfile.schema.json",
            }
          },
        },
      })

I couldn't manage to reproduce it, on my end it works as expected with your config block fixed.

image
erancx commented 2 years ago

Having the same issue here.

{:lua print(vim.inspect(require("yaml-companion.config").options))                                                                                                                  
  builtin_matchers = {                                                                                                                                                              
    kubernetes = {                                                                                                                                                                  
      enabled = true                                                                                                                                                                
    }                                                                                                                                                                               
  },                                                                                                                                                                                
  lspconfig = {                                                                                                                                                                     
    flags = {                                                                                                                                                                       
      debounce_text_changes = 150                                                                                                                                                   
    },                                                                                                                                                                              
    on_attach = <function 1>,                                                                                                                                                       
    settings = {                                                                                                                                                                    
      redhat = {                                                                                                                                                                    
        telemetry = {                                                                                                                                                               
          enabled = false                                                                                                                                                           
        }                                                                                                                                                                           
      },                                                                                                                                                                            
      yaml = {                                                                                                                                                                      
        format = {                                                                                                                                                                  
          enable = true                                                                                                                                                             
        },                                                                                                                                                                          
        hover = true,                                                                                                                                                               
        schemaDownload = {                                                                                                                                                          
          enable = true                                                                                                                                                             
        },                                                                                                                                                                          
        schemaStore = {                                                                                                                                                             
          enable = true,                                                                                                                                                            
          url = "https://www.schemastore.org/api/json/catalog.json"                                                                                                                 
        },                                                                                                                                                                          
        schemas = {},                                                                                                                                                               
        trace = {                                                                                                                                                                   
          server = "debug"                                                                                                                                                          
        },                                                                                                                                                                          
        validate = true                                                                                                                                                             
      }                                                                                                                                                                             
    },                                                                                                                                                                              
    single_file_support = true                                                                                                                                                      
  },                                
  },                                                                                                                                                                                
  schemas = {}                                                                                                                                                                      
} 

All my plugins are up-to-date.

someone-stole-my-name commented 2 years ago

@erancx can't reproduce it on master and nvim 0.8.0 even with your full config and a minimal init ie only two use blocks, the plugin and packer itself:

return require('packer').startup(function()
  use 'wbthomason/packer.nvim'

  use {
    "someone-stole-my-name/yaml-companion.nvim",
    requires = {
      { "neovim/nvim-lspconfig" },
      { "nvim-lua/plenary.nvim" },
      { "nvim-telescope/telescope.nvim" },
    },
    config = function()
      require("telescope").load_extension("yaml_schema")
      local cfg = require("yaml-companion").setup({
        builtin_matchers = {
          kubernetes = {
            enabled = true
          }
        },
        lspconfig = {
          flags = {
            debounce_text_changes = 150
          },
          settings = {
            redhat = {
              telemetry = {
                enabled = false
              }
            },
            yaml = {
              format = {
                enable = true
              },
              hover = true,
              schemaDownload = {
                enable = true
              },
              schemaStore = {
                enable = true,
                url = "https://www.schemastore.org/api/json/catalog.json"
              },
              schemas = {},
              trace = {
                server = "debug"
              },
              validate = true
            }
          },
          single_file_support = true
        },
        schemas = {},
      })
      require("lspconfig")["yamlls"].setup(cfg)
    end,
  }
end)

What is your neovim version? Do you have any other errors on startup? Even with only yaml-companion enabled (as in my snippet) does it still crashes?

marcusramberg commented 2 years ago

Thanks, after updating my config to the correct syntax and updating to the latest, it's not crashing for me anymore :).