b0o / SchemaStore.nvim

🛍 JSON schemas for Neovim
https://schemastore.org
Apache License 2.0
697 stars 17 forks source link

Error running config for nvim-lspconfig: /home/kricss/.config/nvim/lua/config/lsp/installer.lua:9: module 'schemastore' not found: #11

Closed TomYule closed 1 year ago

TomYule commented 1 year ago
 ERROR packer.nvim: Error running config for nvim-lspconfig: /home/kricss/.config/nvim/lua/config/lsp/installer.lua:9: module 'schemastore' not found:
        no field package.preload['schemastore']
        no file './schemastore.lua'
        no file '/home/runner/work/neovim/neovim/.deps/usr/share/luajit-2.1.0-beta3/schemastore.lua'
        no file '/usr/local/share/lua/5.1/schemastore.lua'
        no file '/usr/local/share/lua/5.1/schemastore/init.lua'
        no file '/home/runner/work/neovim/neovim/.deps/usr/share/lua/5.1/schemastore.lua'
        no file '/home/runner/work/neovim/neovim/.deps/usr/share/lua/5.1/schemastore/init.lua'
        no file '/home/kricss/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/schemastore.lua'
        no file '/home/kricss/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/schemastore/init.lua'
        no file '/home/kricss/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/schemastore.lua'
        no file '/home/kricss/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/schemastore/init.lua'
        no file './schemastore.so'
        no file '/usr/local/lib/lua/5.1/schemastore.so'
        no file '/home/runner/work/neovim/neovim/.deps/usr/lib/lua/5.1/schemastore.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
        no file '/home/kricss/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/lua/5.1/schemastore.so'

plugins.lua config

  use {
    "neovim/nvim-lspconfig",
    opt = true,
    event = { "BufReadPre" },
    wants = {
      "nvim-lsp-installer",
      "cmp-nvim-lsp",
      "lua-dev.nvim",
      "vim-illuminate",
      "null-ls.nvim",
      "schemastore.nvim",
    },
    config = function()
      require("config.lsp").setup()
    end,
    requires = {
      "williamboman/nvim-lsp-installer",
      "folke/lua-dev.nvim",
      "RRethy/vim-illuminate",
      "jose-elias-alvarez/null-ls.nvim",
      {
        "j-hui/fidget.nvim",
        config = function()
          require("fidget").setup {}
        end,
      },
      "b0o/schemastore.nvim",
      "jose-elias-alvarez/typescript.nvim",
    },
  }

installer.lua config

local M = {}

local servers = {
  gopls = {},
  html = {},
  jsonls = {
    settings = {
      json = {
        schemas = require("schemastore").json.schemas(),
      },
    },
  },
  pyright = {
    analysis = {
      typeCheckingMode = "off",
    },
  },
  rust_analyzer = {
    settings = {
      ["rust-analyzer"] = {
        cargo = { allFeatures = true },
        checkOnSave = {
          command = "clippy",
          extraArgs = { "--no-deps" },
        },
      },
    },
  },
  sumneko_lua = {
    settings = {
      Lua = {
        runtime = {
          -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
          version = "LuaJIT",
          -- Setup your lua path
          path = vim.split(package.path, ";"),
        },
        diagnostics = {
          -- Get the language server to recognize the `vim` global
          globals = { "vim", "describe", "it", "before_each", "after_each", "packer_plugins" },
          -- disable = { "lowercase-global", "undefined-global", "unused-local", "unused-vararg", "trailing-space" },
        },
        workspace = {
          -- Make the server aware of Neovim runtime files
          library = {
            [vim.fn.expand "$VIMRUNTIME/lua"] = true,
            [vim.fn.expand "$VIMRUNTIME/lua/vim/lsp"] = true,
          },
          maxPreload = 2000,
          preloadFileSize = 50000,
        },
        completion = { callSnippet = "Both" },
        telemetry = { enable = false },
      },
    },
  },
  tsserver = { disable_formatting = true },
  vimls = {},
  tailwindcss = {},
  yamlls = {
    schemastore = {
      enable = true,
    },
    settings = {
      yaml = {
        hover = true,
        completion = true,
        validate = true,
        schemas = require("schemastore").json.schemas(),
      },
    },
  },
  jdtls = {},
  dockerls = {},
  graphql = {},
  bashls = {},
  kotlin_language_server = {},
  marksman = {},
  volar = {},
}

function M.setup(options)
  local lspconfig = require "lspconfig"
  local icons = require "config.icons"

  require("mason").setup {
    ui = {
      icons = {
        package_installed = icons.server_installed,
        package_pending = icons.server_pending,
        package_uninstalled = icons.server_uninstalled,
      },
    },
  }
  require("mason-tool-installer").setup {
    ensure_installed = {
      "codelldb",
      "stylua",
      "shfmt",
      "shellcheck",
      "black",
      "isort",
      "prettierd",
      "chrome-debug-adapter",
    },
    auto_update = false,
    run_on_start = true,
  }

  require("mason-lspconfig").setup {
    ensure_installed = vim.tbl_keys(servers),
    automatic_installation = false,
  }

  -- Package installation folder
  local install_root_dir = vim.fn.stdpath "data" .. "/mason"

  require("mason-lspconfig").setup_handlers {
    function(server_name)
      local opts = vim.tbl_deep_extend("force", options, servers[server_name] or {})
      lspconfig[server_name].setup { opts }
    end,
    ["jdtls"] = function()
      -- print "jdtls is handled by nvim-jdtls"
    end,
    ["sumneko_lua"] = function()
      local opts = vim.tbl_deep_extend("force", options, servers["sumneko_lua"] or {})
      lspconfig.sumneko_lua.setup(require("lua-dev").setup { opts })
    end,
    ["rust_analyzer"] = function()
      local opts = vim.tbl_deep_extend("force", options, servers["rust_analyzer"] or {})

      -- DAP settings - https://github.com/simrat39/rust-tools.nvim#a-better-debugging-experience
      local extension_path = install_root_dir .. "/packages/codelldb/extension/"
      local codelldb_path = extension_path .. "adapter/codelldb"
      local liblldb_path = extension_path .. "lldb/lib/liblldb.so"

      require("rust-tools").setup {
        tools = {
          executor = require("rust-tools/executors").toggleterm,
          hover_actions = { border = "solid" },
          on_initialized = function()
            vim.api.nvim_create_autocmd({ "BufWritePost", "BufEnter", "CursorHold", "InsertLeave" }, {
              pattern = { "*.rs" },
              callback = function()
                vim.lsp.codelens.refresh()
              end,
            })
          end,
        },
        server = opts,
        dap = {
          adapter = require("rust-tools.dap").get_codelldb_adapter(codelldb_path, liblldb_path),
        },
      }
    end,
    ["tsserver"] = function()
      local opts = vim.tbl_deep_extend("force", options, servers["tsserver"] or {})
      require("typescript").setup {
        disable_commands = false,
        debug = false,
        server = opts,
      }
    end,
  }
end

return M

I don't know what went wrong please help me