web-dev-qa-db-fra.com

Undefined Global 'Vim' dans Lua-Language-Server - Coc.NVIM

Cet extrait donne un avertissement: local api = vim.api #Undefined global 'vim'

mon cocconfig:

`  "languageserver": {
    "lua": {
      "command": "/home/manas/.config/coc/extensions/coc-sumneko-lua-data/sumneko-lua-ls/extension/server/bin/Linux/lua-language-server",
      "args": [
        "-E",
        "/home/manas/.config/coc/extensions/coc-sumneko-lua-data/sumneko-lua-ls/extension/server/main.lua"
      ],
      "filetypes": [
        "lua"
      ],
      "rootPatterns": [
        ".git/"
      ],
      "settings": {
        "Lua": {
          "workspace": {
            "library": {
              "/usr/share/nvim/runtime/lua": true,
              "/usr/share/nvim/runtime/lua/vim": true,
              "/usr/share/nvim/runtime/lua/vim/lsp": true
            },
            "maxPreload": 2000,
            "preloadFileSize": 1000
          },
          "runtime": {
            "version": "5.4.1"
          },
          "diagnostics": {
            "disable": [
              "undefined-global",
              "lowercase-global",
              "unused-local",
              "unused-vararg",
              "trailing-space"
            ],
            "globals": [
              "vim",
              "hs",
              "it",
              "describe",
              "before_each",
              "after_each"
            ]
          }
        }
      }
    }
  }
`
1
Manas Prakash
  1. Suivez le processus d'URL: https://github.com/sumneko/lua-language-server/wiki/build-and-run , à installer lua-language-server manuellement.

  2. Démarrage Neovim, entrez la commande: :CocConfig.

  3. Modifier le fichier: coc-settings.json

{
  "languageserver": {
    "lua": {
      "command": "/home/alanjui/.local/share/lua-language-server/bin/Linux/lua-language-server",
      "args": [
        "-E",
        "/home/alanjui/.local/share/lua-language-server/bin/Linux/main.lua"
      ],
      "filetypes": ["lua"],
      "settings": {
        "Lua": {
          "workspace.library": {
            "/usr/share/nvim/runtime/lua": true,
            "/usr/share/nvim/runtime/lua/vim": true,
            "/usr/share/nvim/runtime/lua/vim/lsp": true
          },
          "diagnostics": {
            "globals": [ "vim" ]
          }  
        }
      }
    }
  }
}
1
AlanJui