Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yaml-language-server settting yaml.schemaStore.url not working #1207

Closed
longwuyuan opened this issue Aug 30, 2021 · 51 comments · Fixed by #1421
Closed

yaml-language-server settting yaml.schemaStore.url not working #1207

longwuyuan opened this issue Aug 30, 2021 · 51 comments · Fixed by #1421
Labels
bug Something isn't working

Comments

@longwuyuan
Copy link

longwuyuan commented Aug 30, 2021

  • nvim --version:
    % nvim --version
    NVIM v0.5.0
    Build type: RelWithDebInfo
    LuaJIT 2.1.0-beta3
    Compilation: /usr/bin/gcc-11 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/runner/work/neovim/neovim/build/config -I/home/runner/work/neovim/neovim/src -I/home/runner/work/neovim/neovim/.deps/usr/include -I/usr/include -I/home/runner/work/neovim/neovim/build/src/nvim/auto -I/home/runner/work/neovim/neovim/build/include
    Compiled by runner@fv-az242-526

Features: +acl +iconv +tui
See ":help feature-compile"

system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "
/home/runner/work/neovim/neovim/build/nvim.AppDir/usr/share/nvim"

Run :checkhealth for more info

  • nvim-lspconfig version(commit hash):
    latest as of today as i did a PlugUpdate
  • What language server (If the problem is related to a specific language server):
    yaml-language-server
  • Can you reproduce this behavior on other language server clients (vscode, languageclient-neovim, coc.nvim, etc.):
    I have a workaround with coc on vim https://octetz.com/docs/2020/2020-01-06-vim-k8s-yaml-support/
  • Can you reproduce this behavior on other language servers offered in the nvim-lspconfig repo? (pyls -> pyright):
    Not tried as he setting is unique
  • Is the problem isolated to a particular language server:
    Yes
  • Operating system/version:
    Debian

How to reproduce the problem from neovim startup

require'lspconfig'.yamlls.setup {                                                                                                                                                                           
    on_attach = on_attach,                                                                                                                                                                                  
    settings = {                                                                                                                                                                                            
        yaml = {                                                                                                                                                                                            
            trace = {                                                                                                                                                                                       
                server = "verbose"                                                                                                                                                                          
            },                                                                                                                                                                                              
            schemaStore = {                                                                                                                                                                                 
                url = "file:///home/me//k8s.jsonschema/master-standalone-strict/all.json"                                                                                              
            },                                                                                                                                                                                              
            schemas = {                                                                                                                                                                                     
            ┆   kubernetes = "/*.yaml"                                                                                                                                                                      
            }                                                                                                                                                                                               
        }                                                                                                                                                                                                   
    },                                                                                                                                                                                                      
}               

Actual behaviour

  • I have configured my own schemaStore.url and the schema for the yaml-language-server, using the setting seen above and also detailed in full below
  • My schema is compiled for K8s v1.22 which is the current GA release of Kubernetes
  • The default schaStore does not have updated schema or there is some other problem
  • There are many api versions deprecated in K8s v1.22
  • I see yaml-language-server trying to use old deprecated api versions of kubernetes
  • I use the same schema on VIM with COC and it works perfectly on VIM with COC
  • In the picture below, the extensions/v1beta1 is a deprecated api and also that impacts the specs in the yaml

image

Expected behaviour

  • I have configured the yamlls for a custom schema that is compiled for kubernetes v1.22
  • The api versions and specs the yamlls uses should be from my schemaStore.url
  • Even from the default schemaStore should, at least NOT pick the older api versions
  • Default schemaStore.url It should pick the latest versions of the K8s api(s)

Minimal init.vim or init.lua and code sample

vim.cmd [[set runtimepath=$VIMRUNTIME]]
vim.cmd [[set packpath=/tmp/nvim/site]]

local package_root = '/tmp/nvim/site/pack'
local install_path = package_root .. '/packer/start/packer.nvim'

local function load_plugins()
  require('packer').startup {
    {
      'wbthomason/packer.nvim',
      'neovim/nvim-lspconfig',
    },
    config = {
      package_root = package_root,
      compile_path = install_path .. '/plugin/packer_compiled.lua',
    },
  }
end

_G.load_config = function()
  vim.lsp.set_log_level 'trace'
  local nvim_lsp = require 'lspconfig'
  local on_attach = function(_, bufnr)
    local function buf_set_keymap(...)
      vim.api.nvim_buf_set_keymap(bufnr, ...)
    end
    local function buf_set_option(...)
      vim.api.nvim_buf_set_option(bufnr, ...)
    end

    buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')

    -- Mappings.
    local opts = { noremap = true, silent = true }
    buf_set_keymap('n', 'gD', '<Cmd>lua vim.lsp.buf.declaration()<CR>', opts)
    buf_set_keymap('n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>', opts)
    buf_set_keymap('n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts)
    buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
    buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
    buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
    buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
    buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
    buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
    buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
    buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
    buf_set_keymap('n', '<space>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
    buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
    buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
    buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
  end

  -- Add the server that troubles you here
  local name = 'yamlls'
  -- local cmd = { 'pyright-langserver', '--stdio' } -- needed for elixirls, omnisharp, sumneko_lua
  if not name then
    print 'You have not defined a server name, please edit minimal_init.lua'
  end
  if not nvim_lsp[name].document_config.default_config.cmd and not cmd then
    print [[You have not defined a server default cmd for a server
      that requires it please edit minimal_init.lua]]
  end

  nvim_lsp[name].setup {
    --cmd = cmd,
    on_attach = on_attach,
    settings = {
      yaml = {
        trace = {
          server = "verbose"
        },
        schemaStore = {
          url = "file:///home/me/mystuff/myconfigs/vim/k8s.jsonschema/master-standalone-strict/all.json"
        },
        schemas = {
          kubernetes = "/*.yaml"
        }
      }
    },
  }

  print [[You can find your log at $HOME/.cache/nvim/lsp.log. Please paste in a github issue under a details tag as described in the issue template.]]
end

if vim.fn.isdirectory(install_path) == 0 then
  vim.fn.system { 'git', 'clone', 'https://github.com/wbthomason/packer.nvim', install_path }
  load_plugins()
  require('packer').sync()
  vim.cmd [[autocmd User PackerComplete ++once lua load_config()]]
else
  load_plugins()
  require('packer').sync()
  _G.load_config()
end


Health check

Checkhealth result

health#nvim#check
========================================================================
## Configuration
  - OK: no issues found

## Performance
  - OK: Build type: RelWithDebInfo

## Remote Plugins
  - OK: Up to date

## terminal
  - INFO: key_backspace (kbs) terminfo entry: key_backspace=\177
  - INFO: key_dc (kdch1) terminfo entry: key_dc=\E[3~
  - INFO: $VTE_VERSION='6203'
  - INFO: $COLORTERM='truecolor'

## tmux
  - OK: escape-time: 10
  - INFO: Checking stuff
  - OK: focus-events: on
  - INFO: $TERM: screen-256color

health#provider#check
========================================================================
## Clipboard (optional)
  - OK: Clipboard tool found: tmux

## Python 2 provider (optional)
  - WARNING: No Python executable found that can `import neovim`. Using the first available executable for diagnostics.
  - ERROR: Python provider error:
    - ADVICE:
      - provider/pythonx: Could not load Python 2:
          python2 not found in search path or not executable.
          python2.7 not found in search path or not executable.
          python2.6 not found in search path or not executable.
          /home/me/bin/python is Python 3.9 and cannot provide Python 2.
  - INFO: Executable: Not found

## Python 3 provider (optional)
  - INFO: `g:python3_host_prog` is not set.  Searching for python3 in the environment.
  - INFO: Multiple python3 executables found.  Set `g:python3_host_prog` to avoid surprises.
  - INFO: Executable: /usr/bin/python3
  - INFO: Other python executable: /bin/python3
  - INFO: Python version: 3.9.2
  - INFO: pynvim version: 0.4.3
  - OK: Latest pynvim is installed.

## Python virtualenv
  - OK: no $VIRTUAL_ENV

## Ruby provider (optional)
  - WARNING: `ruby` and `gem` must be in $PATH.
    - ADVICE:
      - Install Ruby and verify that `ruby` and `gem` commands work.

## Node.js provider (optional)
  - INFO: Node.js: v14.17.5
  - INFO: Nvim node.js host: /usr/local/lib/node_modules/neovim/bin/cli.js
  - OK: Latest "neovim" npm/yarn package is installed: 4.10.0

## Perl provider (optional)
  - ERROR: perl provider error:
    - ADVICE:
      - "Neovim::Ext" cpan module is not installed

health#treesitter#check
========================================================================
## Checking treesitter configuration
  - INFO: Runtime ABI version : 13

health#lspconfig#check
========================================================================
## Checking language server protocol configuration
  - INFO: yamlls: configuration checked.

LSP log

[ START ] 2021-08-30T22:58:42+0530 ] LSP logging initiated
[ WARN ] 2021-08-30T22:58:42+0530 ] ...imxfxG1v/usr/share/nvim/runtime/lua/vim/lsp/handlers.lua:108 ]	"The language server yamlls triggers a registerCapability handler despite dynamicRegistration set to false. Report upstream, this warning is harmless"
[ START ] 2021-08-30T23:27:05+0530 ] LSP logging initiated
[ INFO ] 2021-08-30T23:27:16+0530 ] ....mount_nvim4ZtYG7/usr/share/nvim/runtime/lua/vim/lsp.lua:1214 ]	"exit_handler"	{}
[ START ] 2021-08-30T23:27:19+0530 ] LSP logging initiated
[ INFO ] 2021-08-30T23:28:37+0530 ] ...nt_nvimpUxgxR/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:316 ]	"Starting RPC client"	{  args = { "--stdio" },  cmd = "yaml-language-server",  extra = {}}
[ DEBUG ] 2021-08-30T23:28:37+0530 ] ....mount_nvimpUxgxR/usr/share/nvim/runtime/lua/vim/lsp.lua:827 ]	"LSP[yamlls]"	"initialize_params"	{  capabilities = {    callHierarchy = {      dynamicRegistration = false,      <metatable> = <1>{        __tostring = <function 1>      }    },    textDocument = {      codeAction = {        codeActionLiteralSupport = {          codeActionKind = {            valueSet = { "", "Empty", "QuickFix", "Refactor", "RefactorExtract", "RefactorInline", "RefactorRewrite", "Source", "SourceOrganizeImports", "quickfix", "refactor", "refactor.extract", "refactor.inline", "refactor.rewrite", "source", "source.organizeImports" },            <metatable> = <table 1>          },          <metatable> = <table 1>        },        dynamicRegistration = false,        <metatable> = <table 1>      },      completion = {        completionItem = {          commitCharactersSupport = false,          deprecatedSupport = false,          documentationFormat = { "markdown", "plaintext" },          preselectSupport = false,          snippetSupport = false,          <metatable> = <table 1>        },        completionItemKind = {          valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 },          <metatable> = <table 1>        },        contextSupport = false,        dynamicRegistration = false,        <metatable> = <table 1>      },      declaration = {        linkSupport = true,        <metatable> = <table 1>      },      definition = {        linkSupport = true,        <metatable> = <table 1>      },      documentHighlight = {        dynamicRegistration = false,        <metatable> = <table 1>      },      documentSymbol = {        dynamicRegistration = false,        hierarchicalDocumentSymbolSupport = true,        symbolKind = {          valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 },          <metatable> = <table 1>        },        <metatable> = <table 1>      },      hover = {        contentFormat = { "markdown", "plaintext" },        dynamicRegistration = false,        <metatable> = <table 1>      },      implementation = {        linkSupport = true,        <metatable> = <table 1>      },      publishDiagnostics = {        relatedInformation = true,        tagSupport = {          valueSet = { 1, 2 },          <metatable> = <table 1>        },        <metatable> = <table 1>      },      references = {        dynamicRegistration = false,        <metatable> = <table 1>      },      rename = {        dynamicRegistration = false,        prepareSupport = true,        <metatable> = <table 1>      },      signatureHelp = {        dynamicRegistration = false,        signatureInformation = {          documentationFormat = { "markdown", "plaintext" },          <metatable> = <table 1>        },        <metatable> = <table 1>      },      synchronization = {        didSave = true,        dynamicRegistration = false,        willSave = false,        willSaveWaitUntil = false,        <metatable> = <table 1>      },      typeDefinition = {        linkSupport = true,        <metatable> = <table 1>      },      <metatable> = <table 1>    },    window = {      showDocument = {        support = false,        <metatable> = <table 1>      },      showMessage = {        messageActionItem = {          additionalPropertiesSupport = false,          <metatable> = <table 1>        },        <metatable> = <table 1>      },      workDoneProgress = true,      <metatable> = <table 1>    },    workspace = {      applyEdit = true,      configuration = true,      symbol = {        dynamicRegistration = false,        hierarchicalWorkspaceSymbolSupport = true,        symbolKind = {          valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 },          <metatable> = <table 1>        },        <metatable> = <table 1>      },      workspaceEdit = {        resourceOperations = { "rename", "create", "delete" },        <metatable> = <table 1>      },      workspaceFolders = true,      <metatable> = <table 1>    }  },  clientInfo = {    name = "Neovim",    version = "0.5.0"  },  initializationOptions = vim.empty_dict(),  processId = 156168,  rootPath = "/home/me/Downloads/nvim_test/yamlls",  rootUri = "file:///home/me/Downloads/nvim_test/yamlls",  trace = "off",  workspaceFolders = { {      name = "/home/me/Downloads/nvim_test/yamlls",      uri = "file:///home/me/Downloads/nvim_test/yamlls"    } }}
[ DEBUG ] 2021-08-30T23:28:37+0530 ] ...nt_nvimpUxgxR/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:395 ]	"rpc.send.payload"	{  id = 1,  jsonrpc = "2.0",  method = "initialize",  params = {    capabilities = {      callHierarchy = {        dynamicRegistration = false,        <metatable> = <1>{          __tostring = <function 1>        }      },      textDocument = {        codeAction = {          codeActionLiteralSupport = {            codeActionKind = {              valueSet = { "", "Empty", "QuickFix", "Refactor", "RefactorExtract", "RefactorInline", "RefactorRewrite", "Source", "SourceOrganizeImports", "quickfix", "refactor", "refactor.extract", "refactor.inline", "refactor.rewrite", "source", "source.organizeImports" },              <metatable> = <table 1>            },            <metatable> = <table 1>          },          dynamicRegistration = false,          <metatable> = <table 1>        },        completion = {          completionItem = {            commitCharactersSupport = false,            deprecatedSupport = false,            documentationFormat = { "markdown", "plaintext" },            preselectSupport = false,            snippetSupport = false,            <metatable> = <table 1>          },          completionItemKind = {            valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 },            <metatable> = <table 1>          },          contextSupport = false,          dynamicRegistration = false,          <metatable> = <table 1>        },        declaration = {          linkSupport = true,          <metatable> = <table 1>        },        definition = {          linkSupport = true,          <metatable> = <table 1>        },        documentHighlight = {          dynamicRegistration = false,          <metatable> = <table 1>        },        documentSymbol = {          dynamicRegistration = false,          hierarchicalDocumentSymbolSupport = true,          symbolKind = {            valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 },            <metatable> = <table 1>          },          <metatable> = <table 1>        },        hover = {          contentFormat = { "markdown", "plaintext" },          dynamicRegistration = false,          <metatable> = <table 1>        },        implementation = {          linkSupport = true,          <metatable> = <table 1>        },        publishDiagnostics = {          relatedInformation = true,          tagSupport = {            valueSet = { 1, 2 },            <metatable> = <table 1>          },          <metatable> = <table 1>        },        references = {          dynamicRegistration = false,          <metatable> = <table 1>        },        rename = {          dynamicRegistration = false,          prepareSupport = true,          <metatable> = <table 1>        },        signatureHelp = {          dynamicRegistration = false,          signatureInformation = {            documentationFormat = { "markdown", "plaintext" },            <metatable> = <table 1>          },          <metatable> = <table 1>        },        synchronization = {          didSave = true,          dynamicRegistration = false,          willSave = false,          willSaveWaitUntil = false,          <metatable> = <table 1>        },        typeDefinition = {          linkSupport = true,          <metatable> = <table 1>        },        <metatable> = <table 1>      },      window = {        showDocument = {          support = false,          <metatable> = <table 1>        },        showMessage = {          messageActionItem = {            additionalPropertiesSupport = false,            <metatable> = <table 1>          },          <metatable> = <table 1>        },        workDoneProgress = true,        <metatable> = <table 1>      },      workspace = {        applyEdit = true,        configuration = true,        symbol = {          dynamicRegistration = false,          hierarchicalWorkspaceSymbolSupport = true,          symbolKind = {            valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 },            <metatable> = <table 1>          },          <metatable> = <table 1>        },        workspaceEdit = {          resourceOperations = { "rename", "create", "delete" },          <metatable> = <table 1>        },        workspaceFolders = true,        <metatable> = <table 1>      }    },    clientInfo = {      name = "Neovim",      version = "0.5.0"    },    initializationOptions = vim.empty_dict(),    processId = 156168,    rootPath = "/home/me/Downloads/nvim_test/yamlls",    rootUri = "file:///home/me/Downloads/nvim_test/yamlls",    trace = "off",    workspaceFolders = { {        name = "/home/me/Downloads/nvim_test/yamlls",        uri = "file:///home/me/Downloads/nvim_test/yamlls"      } }  }}
[ DEBUG ] 2021-08-30T23:28:38+0530 ] ...nt_nvimpUxgxR/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:496 ]	"decoded"	{  id = 1,  jsonrpc = "2.0",  result = {    capabilities = {      codeActionProvider = true,      codeLensProvider = {        resolveProvider = false      },      completionProvider = {        resolveProvider = false      },      documentFormattingProvider = false,      documentLinkProvider = vim.empty_dict(),      documentOnTypeFormattingProvider = {        firstTriggerCharacter = "\n"      },      documentRangeFormattingProvider = false,      documentSymbolProvider = true,      executeCommandProvider = {        commands = { "jumpToSchema" }      },      foldingRangeProvider = false,      hoverProvider = true,      textDocumentSync = 2,      workspace = {        workspaceFolders = {          changeNotifications = true,          supported = true        }      }    }  }}
[ DEBUG ] 2021-08-30T23:28:38+0530 ] ...nt_nvimpUxgxR/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:395 ]	"rpc.send.payload"	{  jsonrpc = "2.0",  method = "initialized",  params = {    [true] = 6  }}
[ DEBUG ] 2021-08-30T23:28:38+0530 ] ...nt_nvimpUxgxR/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:395 ]	"rpc.send.payload"	{  jsonrpc = "2.0",  method = "workspace/didChangeConfiguration",  params = {    settings = {      yaml = {        schemaStore = {          url = "file:///home/me/mystuff/myconfigs/vim/k8s.jsonschema/master-standalone-strict/all.json",          <metatable> = <1>{            __tostring = <function 1>          }        },        schemas = {          kubernetes = "/*.yaml",          <metatable> = <table 1>        },        trace = {          server = "verbose",          <metatable> = <table 1>        },        <metatable> = <table 1>      },      <metatable> = <table 1>    }  }}
[ DEBUG ] 2021-08-30T23:28:38+0530 ] ....mount_nvimpUxgxR/usr/share/nvim/runtime/lua/vim/lsp.lua:854 ]	"LSP[yamlls]"	"server_capabilities"	{  codeActionProvider = true,  codeLensProvider = {    resolveProvider = false  },  completionProvider = {    resolveProvider = false  },  documentFormattingProvider = false,  documentLinkProvider = {},  documentOnTypeFormattingProvider = {    firstTriggerCharacter = "\n"  },  documentRangeFormattingProvider = false,  documentSymbolProvider = true,  executeCommandProvider = {    commands = { "jumpToSchema" }  },  foldingRangeProvider = false,  hoverProvider = true,  textDocumentSync = 2,  workspace = {    workspaceFolders = {      changeNotifications = true,      supported = true    }  }}
[ INFO ] 2021-08-30T23:28:38+0530 ] ....mount_nvimpUxgxR/usr/share/nvim/runtime/lua/vim/lsp.lua:855 ]	"LSP[yamlls]"	"initialized"	{  resolved_capabilities = {    call_hierarchy = false,    code_action = true,    code_lens = true,    code_lens_resolve = false,    completion = true,    declaration = false,    document_formatting = false,    document_highlight = false,    document_range_formatting = false,    document_symbol = true,    execute_command = true,    find_references = false,    goto_definition = false,    hover = true,    implementation = false,    rename = false,    signature_help = false,    signature_help_trigger_characters = {},    text_document_did_change = 2,    text_document_open_close = true,    text_document_save = true,    text_document_save_include_text = false,    text_document_will_save = false,    text_document_will_save_wait_until = false,    type_definition = false,    workspace_folder_properties = {      changeNotifications = true,      supported = true    },    workspace_symbol = false  }}
[ DEBUG ] 2021-08-30T23:28:38+0530 ] ...nt_nvimpUxgxR/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:395 ]	"rpc.send.payload"	{  jsonrpc = "2.0",  method = "textDocument/didOpen",  params = {    textDocument = {      languageId = "yaml",      text = "apiVersion: networking.k8s.io/v1\nkind: Ingress\nmetadata:\n  name: name1\nspec:\n  ingressClassName: nginx\n  rules:\n    - host: abc.com\n      http:\n        paths:\n          - backend:\n            path: /\n            pathType: Prefix\n             \n",      uri = "file:///home/me/Downloads/nvim_test/yamlls/ingress.test.yaml",      version = 0    }  }}
[ DEBUG ] 2021-08-30T23:28:38+0530 ] ...impUxgxR/usr/share/nvim/runtime/lua/vim/lsp/handlers.lua:434 ]	"default_handler"	"textDocument/publishDiagnostics"	{  client_id = 1,  params = {    diagnostics = {},    uri = "file:///home/me/Downloads/nvim_test/yamlls/ingress.test.yaml"  }}
[ DEBUG ] 2021-08-30T23:28:38+0530 ] ...nt_nvimpUxgxR/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:496 ]	"decoded"	{  id = 0,  jsonrpc = "2.0",  method = "client/registerCapability",  params = {    registrations = { {        id = "23fcc225-9bb2-4d4a-ab4c-1bbb32dc7677",        method = "workspace/didChangeWorkspaceFolders",        registerOptions = vim.empty_dict()      } }  }}
[ DEBUG ] 2021-08-30T23:28:38+0530 ] ....mount_nvimpUxgxR/usr/share/nvim/runtime/lua/vim/lsp.lua:694 ]	"server_request"	"client/registerCapability"	{  registrations = { {      id = "23fcc225-9bb2-4d4a-ab4c-1bbb32dc7677",      method = "workspace/didChangeWorkspaceFolders",      registerOptions = {}    } }}
[ DEBUG ] 2021-08-30T23:28:38+0530 ] ....mount_nvimpUxgxR/usr/share/nvim/runtime/lua/vim/lsp.lua:697 ]	"server_request: found handler for"	"client/registerCapability"
[ DEBUG ] 2021-08-30T23:28:38+0530 ] ...impUxgxR/usr/share/nvim/runtime/lua/vim/lsp/handlers.lua:434 ]	"default_handler"	"client/registerCapability"	{  client_id = 1,  params = {    registrations = { {        id = "23fcc225-9bb2-4d4a-ab4c-1bbb32dc7677",        method = "workspace/didChangeWorkspaceFolders",        registerOptions = {}      } }  }}
[ WARN ] 2021-08-30T23:28:38+0530 ] ...impUxgxR/usr/share/nvim/runtime/lua/vim/lsp/handlers.lua:108 ]	"The language server yamlls triggers a registerCapability handler despite dynamicRegistration set to false. Report upstream, this warning is harmless"
[ DEBUG ] 2021-08-30T23:28:38+0530 ] ...nt_nvimpUxgxR/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:507 ]	"server_request: callback result"	{  result = vim.NIL,  status = true}
[ DEBUG ] 2021-08-30T23:28:38+0530 ] ...nt_nvimpUxgxR/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:395 ]	"rpc.send.payload"	{  id = 0,  jsonrpc = "2.0",  result = vim.NIL}
[ DEBUG ] 2021-08-30T23:28:38+0530 ] ...nt_nvimpUxgxR/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:496 ]	"decoded"	{  id = 1,  jsonrpc = "2.0",  method = "workspace/configuration",  params = {    items = { {        section = "yaml"      }, {        section = "http"      }, {        section = "[yaml]"      } }  }}
[ DEBUG ] 2021-08-30T23:28:38+0530 ] ....mount_nvimpUxgxR/usr/share/nvim/runtime/lua/vim/lsp.lua:694 ]	"server_request"	"workspace/configuration"	{  items = { {      section = "yaml"    }, {      section = "http"    }, {      section = "[yaml]"    } }}
[ DEBUG ] 2021-08-30T23:28:38+0530 ] ....mount_nvimpUxgxR/usr/share/nvim/runtime/lua/vim/lsp.lua:697 ]	"server_request: found handler for"	"workspace/configuration"
[ DEBUG ] 2021-08-30T23:28:38+0530 ] ...impUxgxR/usr/share/nvim/runtime/lua/vim/lsp/handlers.lua:434 ]	"default_handler"	"workspace/configuration"	{  client_id = 1,  params = {    items = { {        section = "yaml"      }, {        section = "http"      }, {        section = "[yaml]"      } }  }}
[ DEBUG ] 2021-08-30T23:28:38+0530 ] ...nt_nvimpUxgxR/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:507 ]	"server_request: callback result"	{  result = { {      schemaStore = {        url = "file:///home/me/mystuff/myconfigs/vim/k8s.jsonschema/master-standalone-strict/all.json",        <metatable> = <1>{          __tostring = <function 1>        }      },      schemas = {        kubernetes = "/*.yaml",        <metatable> = <table 1>      },      trace = {        server = "verbose",        <metatable> = <table 1>      },      <metatable> = <table 1>    }, vim.NIL, vim.NIL },  status = true}
[ DEBUG ] 2021-08-30T23:28:38+0530 ] ...nt_nvimpUxgxR/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:395 ]	"rpc.send.payload"	{  id = 1,  jsonrpc = "2.0",  result = { {      schemaStore = {        url = "file:///home/me/mystuff/myconfigs/vim/k8s.jsonschema/master-standalone-strict/all.json",        <metatable> = <1>{          __tostring = <function 1>        }      },      schemas = {        kubernetes = "/*.yaml",        <metatable> = <table 1>      },      trace = {        server = "verbose",        <metatable> = <table 1>      },      <metatable> = <table 1>    }, vim.NIL, vim.NIL }}
[ DEBUG ] 2021-08-30T23:28:38+0530 ] ...nt_nvimpUxgxR/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:496 ]	"decoded"	{  id = 2,  jsonrpc = "2.0",  method = "workspace/configuration",  params = {    items = { {        section = "yaml"      }, {        section = "http"      }, {        section = "[yaml]"      } }  }}
[ DEBUG ] 2021-08-30T23:28:38+0530 ] ....mount_nvimpUxgxR/usr/share/nvim/runtime/lua/vim/lsp.lua:694 ]	"server_request"	"workspace/configuration"	{  items = { {      section = "yaml"    }, {      section = "http"    }, {      section = "[yaml]"    } }}
[ DEBUG ] 2021-08-30T23:28:38+0530 ] ....mount_nvimpUxgxR/usr/share/nvim/runtime/lua/vim/lsp.lua:697 ]	"server_request: found handler for"	"workspace/configuration"
[ DEBUG ] 2021-08-30T23:28:38+0530 ] ...impUxgxR/usr/share/nvim/runtime/lua/vim/lsp/handlers.lua:434 ]	"default_handler"	"workspace/configuration"	{  client_id = 1,  params = {    items = { {        section = "yaml"      }, {        section = "http"      }, {        section = "[yaml]"      } }  }}
[ DEBUG ] 2021-08-30T23:28:38+0530 ] ...nt_nvimpUxgxR/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:507 ]	"server_request: callback result"	{  result = { {      schemaStore = {        url = "file:///home/me/mystuff/myconfigs/vim/k8s.jsonschema/master-standalone-strict/all.json",        <metatable> = <1>{          __tostring = <function 1>        }      },      schemas = {        kubernetes = "/*.yaml",        <metatable> = <table 1>      },      trace = {        server = "verbose",        <metatable> = <table 1>      },      <metatable> = <table 1>    }, vim.NIL, vim.NIL },  status = true}
[ DEBUG ] 2021-08-30T23:28:38+0530 ] ...nt_nvimpUxgxR/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:395 ]	"rpc.send.payload"	{  id = 2,  jsonrpc = "2.0",  result = { {      schemaStore = {        url = "file:///home/me/mystuff/myconfigs/vim/k8s.jsonschema/master-standalone-strict/all.json",        <metatable> = <1>{          __tostring = <function 1>        }      },      schemas = {        kubernetes = "/*.yaml",        <metatable> = <table 1>      },      trace = {        server = "verbose",        <metatable> = <table 1>      },      <metatable> = <table 1>    }, vim.NIL, vim.NIL }}
[ DEBUG ] 2021-08-30T23:28:38+0530 ] ...nt_nvimpUxgxR/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:496 ]	"decoded"	{  jsonrpc = "2.0",  method = "telemetry/event",  params = {    name = "yaml.schema.configured",    properties = {      kubernetes = true    }  }}
[ DEBUG ] 2021-08-30T23:28:38+0530 ] ...nt_nvimpUxgxR/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:496 ]	"decoded"	{  jsonrpc = "2.0",  method = "telemetry/event",  params = {    name = "yaml.schema.configured",    properties = {      kubernetes = true    }  }}
[ DEBUG ] 2021-08-30T23:28:38+0530 ] ....mount_nvimpUxgxR/usr/share/nvim/runtime/lua/vim/lsp.lua:680 ]	"notification"	"telemetry/event"	{  name = "yaml.schema.configured",  properties = {    kubernetes = true  }}
[ DEBUG ] 2021-08-30T23:28:38+0530 ] ....mount_nvimpUxgxR/usr/share/nvim/runtime/lua/vim/lsp.lua:680 ]	"notification"	"telemetry/event"	{  name = "yaml.schema.configured",  properties = {    kubernetes = true  }}
[ DEBUG ] 2021-08-30T23:28:39+0530 ] ...nt_nvimpUxgxR/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:496 ]	"decoded"	{  jsonrpc = "2.0",  method = "textDocument/publishDiagnostics",  params = {    diagnostics = { {        code = 0,        data = {          schemaUri = { "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.20.5-standalone-strict/_definitions.json" }        },        message = 'Incorrect type. Expected "io.k8s.api.extensions.v1beta1.IngressBackend".',        range = {          end = {            character = 20,            line = 10          },          start = {            character = 20,            line = 10          }        },        severity = 1,        source = "yaml-schema: https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.20.5-standalone-strict/_definitions.json"      } },    uri = "file:///home/me/Downloads/nvim_test/yamlls/ingress.test.yaml"  }}
[ DEBUG ] 2021-08-30T23:28:39+0530 ] ....mount_nvimpUxgxR/usr/share/nvim/runtime/lua/vim/lsp.lua:680 ]	"notification"	"textDocument/publishDiagnostics"	{  diagnostics = { {      code = 0,      data = {        schemaUri = { "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.20.5-standalone-strict/_definitions.json" }      },      message = 'Incorrect type. Expected "io.k8s.api.extensions.v1beta1.IngressBackend".',      range = {        end = {          character = 20,          line = 10        },        start = {          character = 20,          line = 10        }      },      severity = 1,      source = "yaml-schema: https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.20.5-standalone-strict/_definitions.json"    } },  uri = "file:///home/me/Downloads/nvim_test/yamlls/ingress.test.yaml"}
[ DEBUG ] 2021-08-30T23:28:39+0530 ] ...impUxgxR/usr/share/nvim/runtime/lua/vim/lsp/handlers.lua:434 ]	"default_handler"	"textDocument/publishDiagnostics"	{  client_id = 1,  params = {    diagnostics = { {        code = 0,        data = {          schemaUri = { "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.20.5-standalone-strict/_definitions.json" }        },        message = 'Incorrect type. Expected "io.k8s.api.extensions.v1beta1.IngressBackend".',        range = {          end = {            character = 20,            line = 10          },          start = {            character = 20,            line = 10          }        },        severity = 1,        source = "yaml-schema: https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.20.5-standalone-strict/_definitions.json"      } },    uri = "file:///home/me/Downloads/nvim_test/yamlls/ingress.test.yaml"  }}
[ DEBUG ] 2021-08-30T23:28:55+0530 ] ...nt_nvimpUxgxR/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:395 ]	"rpc.send.payload"	{  jsonrpc = "2.0",  method = "textDocument/didSave",  params = {    textDocument = {      uri = "file:///home/me/Downloads/nvim_test/yamlls/ingress.test.yaml"    }  }}
[ INFO ] 2021-08-30T23:28:55+0530 ] ....mount_nvimpUxgxR/usr/share/nvim/runtime/lua/vim/lsp.lua:1214 ]	"exit_handler"	{ {    _on_attach = <function 1>,    cancel_request = <function 2>,    config = {      _on_attach = <function 3>,      autostart = true,      capabilities = {        callHierarchy = {          dynamicRegistration = false,          <metatable> = <1>{            __tostring = <function 4>          }        },        textDocument = {          codeAction = {            codeActionLiteralSupport = {              codeActionKind = {                valueSet = { "", "Empty", "QuickFix", "Refactor", "RefactorExtract", "RefactorInline", "RefactorRewrite", "Source", "SourceOrganizeImports", "quickfix", "refactor", "refactor.extract", "refactor.inline", "refactor.rewrite", "source", "source.organizeImports" },                <metatable> = <table 1>              },              <metatable> = <table 1>            },            dynamicRegistration = false,            <metatable> = <table 1>          },          completion = {            completionItem = {              commitCharactersSupport = false,              deprecatedSupport = false,              documentationFormat = { "markdown", "plaintext" },              preselectSupport = false,              snippetSupport = false,              <metatable> = <table 1>            },            completionItemKind = {              valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 },              <metatable> = <table 1>            },            contextSupport = false,            dynamicRegistration = false,            <metatable> = <table 1>          },          declaration = {            linkSupport = true,            <metatable> = <table 1>          },          definition = {            linkSupport = true,            <metatable> = <table 1>          },          documentHighlight = {            dynamicRegistration = false,            <metatable> = <table 1>          },          documentSymbol = {            dynamicRegistration = false,            hierarchicalDocumentSymbolSupport = true,            symbolKind = {              valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 },              <metatable> = <table 1>            },            <metatable> = <table 1>          },          hover = {            contentFormat = { "markdown", "plaintext" },            dynamicRegistration = false,            <metatable> = <table 1>          },          implementation = {            linkSupport = true,            <metatable> = <table 1>          },          publishDiagnostics = {            relatedInformation = true,            tagSupport = {              valueSet = { 1, 2 },              <metatable> = <table 1>            },            <metatable> = <table 1>          },          references = {            dynamicRegistration = false,            <metatable> = <table 1>          },          rename = {            dynamicRegistration = false,            prepareSupport = true,            <metatable> = <table 1>          },          signatureHelp = {            dynamicRegistration = false,            signatureInformation = {              documentationFormat = { "markdown", "plaintext" },              <metatable> = <table 1>            },            <metatable> = <table 1>          },          synchronization = {            didSave = true,            dynamicRegistration = false,            willSave = false,            willSaveWaitUntil = false,            <metatable> = <table 1>          },          typeDefinition = {            linkSupport = true,            <metatable> = <table 1>          },          <metatable> = <table 1>        },        window = {          showDocument = {            support = false,            <metatable> = <table 1>          },          showMessage = {            messageActionItem = {              additionalPropertiesSupport = false,              <metatable> = <table 1>            },            <metatable> = <table 1>          },          workDoneProgress = true,          <metatable> = <table 1>        },        workspace = {          applyEdit = true,          configuration = true,          symbol = {            dynamicRegistration = false,            hierarchicalWorkspaceSymbolSupport = true,            symbolKind = {              valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 },              <metatable> = <table 1>            },            <metatable> = <table 1>          },          workspaceEdit = {            resourceOperations = { "rename", "create", "delete" },            <metatable> = <table 1>          },          workspaceFolders = true,          <metatable> = <table 1>        }      },      cmd = { "yaml-language-server", "--stdio" },      filetypes = { "yaml" },      flags = {},      get_language_id = <function 5>,      handlers = <2>{},      init_options = vim.empty_dict(),      log_level = 2,      message_level = 2,      name = "yamlls",      on_attach = <function 6>,      on_exit = <function 7>,      on_init = <function 8>,      root_dir = "/home/me/Downloads/nvim_test/yamlls",      settings = {        yaml = {          schemaStore = {            url = "file:///home/me/mystuff/myconfigs/vim/k8s.jsonschema/master-standalone-strict/all.json",            <metatable> = <table 1>          },          schemas = {            kubernetes = "/*.yaml",            <metatable> = <table 1>          },          trace = {            server = "verbose",            <metatable> = <table 1>          },          <metatable> = <table 1>        },        <metatable> = <table 1>      },      <metatable> = <table 1>    },    handlers = <table 2>,    id = 1,    initialized = true,    is_stopped = <function 9>,    messages = {      messages = {},      name = "yamlls",      progress = {},      status = {}    },    name = "yamlls",    notify = <function 10>,    offset_encoding = "utf-16",    request = <function 11>,    request_sync = <function 12>,    resolved_capabilities = {      call_hierarchy = false,      code_action = true,      code_lens = true,      code_lens_resolve = false,      completion = true,      declaration = false,      document_formatting = false,      document_highlight = false,      document_range_formatting = false,      document_symbol = true,      execute_command = true,      find_references = false,      goto_definition = false,      hover = true,      implementation = false,      rename = false,      signature_help = false,      signature_help_trigger_characters = {},      text_document_did_change = 2,      text_document_open_close = true,      text_document_save = true,      text_document_save_include_text = false,      text_document_will_save = false,      text_document_will_save_wait_until = false,      type_definition = false,      workspace_folder_properties = {        changeNotifications = true,        supported = true      },      workspace_symbol = false    },    rpc = {      handle = <userdata 1>,      notify = <function 13>,      pid = 156318,      request = <function 14>    },    server_capabilities = {      codeActionProvider = true,      codeLensProvider = {        resolveProvider = false      },      completionProvider = {        resolveProvider = false      },      documentFormattingProvider = false,      documentLinkProvider = {},      documentOnTypeFormattingProvider = {        firstTriggerCharacter = "\n"      },      documentRangeFormattingProvider = false,      documentSymbolProvider = true,      executeCommandProvider = {        commands = { "jumpToSchema" }      },      foldingRangeProvider = false,      hoverProvider = true,      textDocumentSync = 2,      workspace = {        workspaceFolders = {          changeNotifications = true,          supported = true        }      }    },    stop = <function 15>,    supports_method = <function 16>,    workspaceFolders = { {        name = "/home/me/Downloads/nvim_test/yamlls",        uri = "file:///home/me/Downloads/nvim_test/yamlls"      } },    workspace_did_change_configuration = <function 17>  } }
[ DEBUG ] 2021-08-30T23:28:55+0530 ] ...nt_nvimpUxgxR/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:395 ]	"rpc.send.payload"	{  id = 2,  jsonrpc = "2.0",  method = "shutdown"}
[ DEBUG ] 2021-08-30T23:28:55+0530 ] ...nt_nvimpUxgxR/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:496 ]	"decoded"	{  id = 2,  jsonrpc = "2.0",  result = vim.NIL}
[ DEBUG ] 2021-08-30T23:28:55+0530 ] ...nt_nvimpUxgxR/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:395 ]	"rpc.send.payload"	{  jsonrpc = "2.0",  method = "exit"}

@longwuyuan longwuyuan added the bug Something isn't working label Aug 30, 2021
@longwuyuan longwuyuan changed the title yaml-language-server unable to use custom schema for kubernetes latest version yaml-language-server unable to use custom schema for kubernetes (default schemaStore.url uses deprecated K8s-api versions) Aug 30, 2021
@longwuyuan longwuyuan changed the title yaml-language-server unable to use custom schema for kubernetes (default schemaStore.url uses deprecated K8s-api versions) yaml-language-server settting yaml.SchemaStore.url not working (default schemaStore.url uses deprecated K8s-api versions) Aug 30, 2021
@longwuyuan longwuyuan changed the title yaml-language-server settting yaml.SchemaStore.url not working (default schemaStore.url uses deprecated K8s-api versions) yaml-language-server settting yaml.SchemaStore.url not working Aug 30, 2021
@longwuyuan longwuyuan changed the title yaml-language-server settting yaml.SchemaStore.url not working yaml-language-server settting yaml.schemaStore.url not working Aug 30, 2021
@kylo252
Copy link
Contributor

kylo252 commented Sep 4, 2021

Can you please paste the example yaml that you're using?

If you take a look over at redhat-developer/yaml-language-server#307 and https://github.com/redhat-developer/yaml-language-server/issues/211you'll see a lot of discussion about the peculiar behavior of the server when it comes to k8s.

This took some effort so I hope it will work for you

  nvim_lsp[name].setup {
    --cmd = cmd,
    on_attach = on_attach,
    settings = {
      yaml = {
        trace = {
          server = "verbose"
        },
        schemas = {
          kubernetes = "/*.yaml"
        },
        schemaDownload = {  enable = true },
      	validate = true,
      }
    },
  }

I then tested it with this which gives a "Property not allowed" error

image

and in the lsp.log I see it actually validated against v1.20.5 which indicates success!

{  
  jsonrpc = "2.0",
  method = "textDocument/publishDiagnostics",
  params = {   
    diagnostics = { 
      {
        code = 0,
        data = {
          schemaUri = { "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.20.5-standalone-strict/_definitions.json" }
        }, 
        message = "Property containers is not allowed.", 
        range = { end = { character = 12, line = 8 }, start = {character = 2, line = 8 } }, 
        severity = 1,
        source = "yaml-schema: https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.20.5-standalone-strict/_definitions.json"
      }
    },
    uri = "file:///tmp/backend-service.k8s.yaml" 
  }
}

@longwuyuan
Copy link
Author

@kylo252 Thank you.
Do you know how I can validate yaml files with K8s v1.22 schema ?

@kylo252
Copy link
Contributor

kylo252 commented Sep 5, 2021

@kylo252 Thank you.
Do you know how I can validate yaml files with K8s v1.22 schema ?

As I mentioned earlier, that seems like an internal issue with the language server, you can see the hard-coded value here:

https://github.com/redhat-developer/yaml-language-server/blob/6df37d38dfe7bedce12aee4175fbe7da05b8e333/src/languageservice/utils/schemaUrls.ts#L6-L8

So I guess you can just build the server yourself, or some are talking about overriding it with an environment variable, maybe that's a thing(?). And you can see in redhat-developer/yaml-language-server#211 that the devs aren't terribly invested in making this easier.

This could also be of interest for you if there's some port that works with lspconfig: https://github.com/Azure/vscode-kubernetes-tools

@mjlbach
Copy link
Contributor

mjlbach commented Sep 7, 2021

This seems resolved? Can one of you document this in yaml language server and file a PR?

@longwuyuan
Copy link
Author

longwuyuan commented Sep 8, 2021 via email

@mjlbach
Copy link
Contributor

mjlbach commented Sep 8, 2021

Reading the yamlls code, it seems like you can do something like:

require('lspconfig').yamlls.setup{
    settings = { yaml = { schemas = { kubernetes =  'https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.22.1-standalone/all.json'}}}
}

As kylo mentioned, this isn't really an lspconfig thing, but more a "how to send the right settings to the server", so you may need to read through the upstream documentation.

@kylo252
Copy link
Contributor

kylo252 commented Sep 8, 2021

Reading the yamlls code, it seems like you can do something like:

require('lspconfig').yamlls.setup{
    settings = { yaml = { schemas = { kubernetes =  'https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.22.1-standalone/all.json'}}}
}

Yeah this snippet is supposed to work, but it's either not reliable or straight-up broken. I do believe that in essence it's 100% a language-server problem, even by the dev admission, as you can see in the tickets that I linked.

@mjlbach
Copy link
Contributor

mjlbach commented Sep 8, 2021

But it seems like this works for the user on the referenced issue no?

@longwuyuan
Copy link
Author

longwuyuan commented Sep 9, 2021 via email

@kylo252
Copy link
Contributor

kylo252 commented Sep 9, 2021

I tried. Does not work. I am hospitalized. I will explain in detail after I am able to.

Sorry to hear that. Get better soon!

--

@mjlbach, it didn't work for me as I said. Maybe I needed to turn off the schemaDownload, but I don't see how that should affect it, i.e. it's unreliable.

Do you think it would be possible to port the linter from https://github.com/Azure/vscode-kubernetes-tools ?

@mjlbach
Copy link
Contributor

mjlbach commented Sep 9, 2021

Maybe I needed to turn off the schemaDownload, but I don't see how that should affect it, i.e. it's unreliable.

I would just file an upstream issue. I don't use yamlls, so I won't

Do you think it would be possible to port the linter from https://github.com/Azure/vscode-kubernetes-tools ?

wdym port the linter? port the linter to what? Do you mean extract a linter out of a vscode and wrap it into its own language server? I have 0 idea.

@longwuyuan
Copy link
Author

longwuyuan commented Sep 9, 2021 via email

@mjlbach
Copy link
Contributor

mjlbach commented Nov 11, 2021

@longwuyuan were you able to resolve the issue? If you can provide an exact reproduction (our minimal init.lua modified to use the schema you wanted, a yaml file you would expect to work) I will look at it.

@longwuyuan
Copy link
Author

My lua file

-- Install packer
local install_path = vim.fn.stdpath 'data' .. '/site/pack/packer/start/packer.nvim'

if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
  vim.fn.execute('!git clone https://github.com/wbthomason/packer.nvim ' .. install_path)
end

vim.api.nvim_exec(
  [[
  augroup Packer
    autocmd!
    autocmd BufWritePost init.lua PackerCompile
  augroup end
]],
  false
)

local use = require('packer').use
require('packer').startup(function()
  use 'wbthomason/packer.nvim' -- Package manager
  use 'tpope/vim-fugitive' -- Git commands in nvim
  use 'tpope/vim-rhubarb' -- Fugitive-companion to interact with github
  use 'tpope/vim-commentary' -- "gc" to comment visual regions/lines
  use 'ludovicchabant/vim-gutentags' -- Automatic tags management
  -- UI to select things (files, grep results, open buffers...)
  use { 'nvim-telescope/telescope.nvim', requires = { 'nvim-lua/plenary.nvim' } }
  use 'joshdick/onedark.vim' -- Theme inspired by Atom
  use 'itchyny/lightline.vim' -- Fancier statusline
  -- Add indentation guides even on blank lines
  use 'lukas-reineke/indent-blankline.nvim'
  -- Add git related info in the signs columns and popups
  use { 'lewis6991/gitsigns.nvim', requires = { 'nvim-lua/plenary.nvim' } }
  -- Highlight, edit, and navigate code using a fast incremental parsing library
  use 'nvim-treesitter/nvim-treesitter'
  -- Additional textobjects for treesitter
  use 'nvim-treesitter/nvim-treesitter-textobjects'
  use 'neovim/nvim-lspconfig' -- Collection of configurations for built-in LSP client
  use 'kabouzeid/nvim-lspinstall' -- LspInstall
  use 'hrsh7th/nvim-cmp' -- Autocompletion plugin
  use 'hrsh7th/cmp-nvim-lsp'
  use 'saadparwaiz1/cmp_luasnip'
  use 'L3MON4D3/LuaSnip' -- Snippets plugin
end)

--Incremental live completion (note: this is now a default on master)
vim.o.inccommand = 'nosplit'

--Set highlight on search
vim.o.hlsearch = false

--Make line numbers default
vim.wo.number = true

--Do not save when switching buffers (note: this is now a default on master)
vim.o.hidden = true

--Enable mouse mode
vim.o.mouse = 'a'

--Enable break indent
vim.o.breakindent = true

--Save undo history
vim.opt.undofile = true

--Case insensitive searching UNLESS /C or capital in search
vim.o.ignorecase = true
vim.o.smartcase = true

--Decrease update time
vim.o.updatetime = 250
vim.wo.signcolumn = 'yes'

--Set colorscheme (order is important here)
vim.o.termguicolors = true
vim.g.onedark_terminal_italics = 2
vim.cmd [[colorscheme onedark]]

--Set statusbar
vim.g.lightline = {
  colorscheme = 'onedark',
  active = { left = { { 'mode', 'paste' }, { 'gitbranch', 'readonly', 'filename', 'modified' } } },
  component_function = { gitbranch = 'fugitive#head' },
}

--Remap space as leader key
vim.api.nvim_set_keymap('', '<Space>', '<Nop>', { noremap = true, silent = true })
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '

--Remap for dealing with word wrap
vim.api.nvim_set_keymap('n', 'k', "v:count == 0 ? 'gk' : 'k'", { noremap = true, expr = true, silent = true })
vim.api.nvim_set_keymap('n', 'j', "v:count == 0 ? 'gj' : 'j'", { noremap = true, expr = true, silent = true })

-- Highlight on yank
vim.api.nvim_exec(
  [[
  augroup YankHighlight
    autocmd!
    autocmd TextYankPost * silent! lua vim.highlight.on_yank()
  augroup end
]],
  false
)

-- Y yank until the end of line  (note: this is now a default on master)
vim.api.nvim_set_keymap('n', 'Y', 'y$', { noremap = true })

--Map blankline
vim.g.indent_blankline_char = '┊'
vim.g.indent_blankline_filetype_exclude = { 'help', 'packer' }
vim.g.indent_blankline_buftype_exclude = { 'terminal', 'nofile' }
vim.g.indent_blankline_char_highlight = 'LineNr'
vim.g.indent_blankline_show_trailing_blankline_indent = false

-- Gitsigns
require('gitsigns').setup {
  signs = {
    add = { hl = 'GitGutterAdd', text = '+' },
    change = { hl = 'GitGutterChange', text = '~' },
    delete = { hl = 'GitGutterDelete', text = '_' },
    topdelete = { hl = 'GitGutterDelete', text = '‾' },
    changedelete = { hl = 'GitGutterChange', text = '~' },
  },
}

-- Telescope
require('telescope').setup {
  defaults = {
    mappings = {
      i = {
        ['<C-u>'] = false,
        ['<C-d>'] = false,
      },
    },
  },
}
--Add leader shortcuts
vim.api.nvim_set_keymap('n', '<leader><space>', [[<cmd>lua require('telescope.builtin').buffers()<CR>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>sf', [[<cmd>lua require('telescope.builtin').find_files({previewer = false})<CR>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>sb', [[<cmd>lua require('telescope.builtin').current_buffer_fuzzy_find()<CR>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>sh', [[<cmd>lua require('telescope.builtin').help_tags()<CR>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>st', [[<cmd>lua require('telescope.builtin').tags()<CR>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>sd', [[<cmd>lua require('telescope.builtin').grep_string()<CR>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>sp', [[<cmd>lua require('telescope.builtin').live_grep()<CR>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>so', [[<cmd>lua require('telescope.builtin').tags{ only_current_buffer = true }<CR>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>?', [[<cmd>lua require('telescope.builtin').oldfiles()<CR>]], { noremap = true, silent = true })

-- Treesitter configuration
-- Parsers must be installed manually via :TSInstall
require('nvim-treesitter.configs').setup {
  highlight = {
    enable = true, -- false will disable the whole extension
  },
  incremental_selection = {
    enable = true,
    keymaps = {
      init_selection = 'gnn',
      node_incremental = 'grn',
      scope_incremental = 'grc',
      node_decremental = 'grm',
    },
  },
  indent = {
    enable = true,
  },
  textobjects = {
    select = {
      enable = true,
      lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
      keymaps = {
        -- You can use the capture groups defined in textobjects.scm
        ['af'] = '@function.outer',
        ['if'] = '@function.inner',
        ['ac'] = '@class.outer',
        ['ic'] = '@class.inner',
      },
    },
    move = {
      enable = true,
      set_jumps = true, -- whether to set jumps in the jumplist
      goto_next_start = {
        [']m'] = '@function.outer',
        [']]'] = '@class.outer',
      },
      goto_next_end = {
        [']M'] = '@function.outer',
        [']['] = '@class.outer',
      },
      goto_previous_start = {
        ['[m'] = '@function.outer',
        ['[['] = '@class.outer',
      },
      goto_previous_end = {
        ['[M'] = '@function.outer',
        ['[]'] = '@class.outer',
      },
    },
  },
}

-- LSP settings
local nvim_lsp = require 'lspconfig'
local on_attach = function(_, bufnr)
  vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')

  local opts = { noremap = true, silent = true }
  vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', '<Cmd>lua vim.lsp.buf.declaration()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
  -- vim.api.nvim_buf_set_keymap(bufnr, 'v', '<leader>ca', '<cmd>lua vim.lsp.buf.range_code_action()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
  vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>so', [[<cmd>lua require('telescope.builtin').lsp_document_symbols()<CR>]], opts)
  vim.cmd [[ command! Format execute 'lua vim.lsp.buf.formatting()' ]]
end

-- nvim-cmp supports additional completion capabilities
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)

-- Enable the following language servers
local servers = { 'gopls', 'pyright', 'bashls', 'dockerls', 'sqlls', 'html'}
for _, lsp in ipairs(servers) do
  nvim_lsp[lsp].setup {
    on_attach = on_attach,
    capabilities = capabilities,
  }
end

-- Example custom server
local sumneko_root_path = vim.fn.getenv 'HOME' .. '/.local/bin/sumneko_lua' -- Change to your sumneko root installation
local sumneko_binary = sumneko_root_path .. '/bin/linux/lua-language-server'

-- Make runtime files discoverable to the server
local runtime_path = vim.split(package.path, ';')
table.insert(runtime_path, 'lua/?.lua')
table.insert(runtime_path, 'lua/?/init.lua')

require('lspconfig').sumneko_lua.setup {
  cmd = { sumneko_binary, '-E', sumneko_root_path .. '/main.lua' },
  on_attach = on_attach,
  capabilities = capabilities,
  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 = runtime_path,
      },
      diagnostics = {
        -- Get the language server to recognize the `vim` global
        globals = { 'vim' },
      },
      workspace = {
        -- Make the server aware of Neovim runtime files
        library = vim.api.nvim_get_runtime_file('', true),
      },
      -- Do not send telemetry data containing a randomized but unique identifier
      telemetry = {
        enable = false,
      },
    },
  },
}

-- Set completeopt to have a better completion experience
vim.o.completeopt = 'menuone,noselect'

-- luasnip setup
local luasnip = require 'luasnip'

-- nvim-cmp setup
local cmp = require 'cmp'
cmp.setup {
  snippet = {
    expand = function(args)
      require('luasnip').lsp_expand(args.body)
    end,
  },
  mapping = {
    ['<C-p>'] = cmp.mapping.select_prev_item(),
    ['<C-n>'] = cmp.mapping.select_next_item(),
    ['<C-d>'] = cmp.mapping.scroll_docs(-4),
    ['<C-f>'] = cmp.mapping.scroll_docs(4),
    ['<C-Space>'] = cmp.mapping.complete(),
    ['<C-e>'] = cmp.mapping.close(),
    ['<CR>'] = cmp.mapping.confirm {
      behavior = cmp.ConfirmBehavior.Replace,
      select = true,
    },
    ['<Tab>'] = function(fallback)
      if vim.fn.pumvisible() == 1 then
        vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<C-n>', true, true, true), 'n')
      elseif luasnip.expand_or_jumpable() then
        vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<Plug>luasnip-expand-or-jump', true, true, true), '')
      else
        fallback()
      end
    end,
    ['<S-Tab>'] = function(fallback)
      if vim.fn.pumvisible() == 1 then
        vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<C-p>', true, true, true), 'n')
      elseif luasnip.jumpable(-1) then
        vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<Plug>luasnip-jump-prev', true, true, true), '')
      else
        fallback()
      end
    end,
  },
  sources = {
    { name = 'nvim_lsp' },
    { name = 'luasnip' },
  },
}


@mjlbach
Copy link
Contributor

mjlbach commented Nov 16, 2021

Hi @longwuyuan, hope you are feeling better :)

I don't see yamlls anywhere in that lua file, were you having another issue? I updated the documentation for yamlls that should cover the custom schemas (tested on a couple files myself and it seemed to work as expected).

@longwuyuan
Copy link
Author

ah ok... i will have to go through the tests again. apologies if i confused you.
am i seeing this right. this is my current understanding.

  • everything works except its not possible to choose a schema like the schema for a specific version of kubernetes
  • For example the schema for Kubernetes 1.22 differs from earlier versions of kubernetes
  • I was hacking the ts and js files in some deep subdirectory of the language-server
  • I was replacing the URL to the schema in the ts/js files with a url of schema for kubernetes 1.22 on my laptop
  • Now it seems you have updated the documentation for using custom schema

If this is correct, I will do the needful and check the docs and change settings and test

This involves another issue , not related to this project. The schema for kubernetes 1.22 is not available on the web as well. One has to use the script provided, to generate the kubernetes 1.22 schema

@mjlbach
Copy link
Contributor

mjlbach commented Nov 16, 2021

everything works except its not possible to choose a schema like the schema for a specific version of kubernetes

This should work, try adding the following into a kubernetes yaml (not sure if this is the correct schema):

# yaml-language-server: $schema=https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.22.0/deployment-apps-v1.json

This modeline should set the kubernetes schema correctly to 1.22, there are other online schema available on that repo here: https://github.com/yannh/kubernetes-json-schema/tree/master/v1.22.0

@longwuyuan
Copy link
Author

oh, this is so helpful. thanks tons. I will try now

@mjlbach
Copy link
Contributor

mjlbach commented Nov 16, 2021

If you check server_configurations.md you can see the other way, which would be affiliating that URL with a filesystem path relative to resolved root of the project which is the tricky part, since that's dynamic and depends on your project structure (that's a yamlls quirk, which I guess makes sense since it would not be compatible on different systems otherwise).

I personally think the modeline is easier haha, since you don't have to worry about relative anything.

@longwuyuan
Copy link
Author

I am a little lost now. have to get my bearings. This is my current init.vim

" vim-bootstrap 2021-08-28 17:55:02

"*****************************************************************************
"" Vim-Plug core
"*****************************************************************************
let vimplug_exists=expand('~/.config/nvim/autoload/plug.vim')
if has('win32')&&!has('win64')
  let curl_exists=expand('C:\Windows\Sysnative\curl.exe')
else
  let curl_exists=expand('curl')
endif

let g:vim_bootstrap_langs = ""
let g:vim_bootstrap_editor = "neovim"				" nvim or vim
let g:vim_bootstrap_theme = "molokai"
let g:vim_bootstrap_frams = ""

if !filereadable(vimplug_exists)
  if !executable(curl_exists)
    echoerr "You have to install curl or first install vim-plug yourself!"
    execute "q!"
  endif
  echo "Installing Vim-Plug..."
  echo ""
  silent exec "!"curl_exists" -fLo " . shellescape(vimplug_exists) . " --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"
  let g:not_finish_vimplug = "yes"

  autocmd VimEnter * PlugInstall
endif

" Required:
call plug#begin(expand('~/.config/nvim/plugged'))

"*****************************************************************************
"" Plug install packages
"*****************************************************************************
Plug 'scrooloose/nerdtree'
Plug 'jistr/vim-nerdtree-tabs'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-fugitive'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'airblade/vim-gitgutter'
Plug 'vim-scripts/grep.vim'
Plug 'vim-scripts/CSApprox'
Plug 'Raimondi/delimitMate'
Plug 'majutsushi/tagbar'
"Plug 'dense-analysis/ale'
Plug 'Yggdroot/indentLine'
Plug 'editor-bootstrap/vim-bootstrap-updater'
Plug 'tpope/vim-rhubarb' " required by fugitive to :Gbrowse
Plug 'tomasr/molokai'


if isdirectory('/usr/local/opt/fzf')
  Plug '/usr/local/opt/fzf' | Plug 'junegunn/fzf.vim'
else
  Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --bin' }
  Plug 'junegunn/fzf.vim'
endif
let g:make = 'gmake'
if exists('make')
        let g:make = 'make'
endif
Plug 'Shougo/vimproc.vim', {'do': g:make}

"" Vim-Session
Plug 'xolox/vim-misc'
Plug 'xolox/vim-session'

"" Snippets
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'

"*****************************************************************************
"" Custom bundles
"*****************************************************************************
Plug 'neovim/nvim-lspconfig'
Plug 'kabouzeid/nvim-lspinstall'
Plug 'hrsh7th/nvim-cmp'
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'saadparwaiz1/cmp_luasnip'
Plug 'L3MON4D3/LuaSnip'
Plug 'morhetz/gruvbox'

"*****************************************************************************
"*****************************************************************************

"" Include user's extra bundle
if filereadable(expand("~/.config/nvim/local_bundles.vim"))
  source ~/.config/nvim/local_bundles.vim
endif

call plug#end()

" Required:
filetype plugin indent on


"*****************************************************************************
"" Basic Setup
"*****************************************************************************"
"G" Encoding
set encoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8
set ttyfast

"" Fix backspace indent
set backspace=indent,eol,start

"" Tabs. May be overridden by autocmd rules
set tabstop=4
set softtabstop=0
set shiftwidth=4
set expandtab

"" Map leader to ,
let mapleader=','

"" Enable hidden buffers
set hidden

"" Searching
set hlsearch
set incsearch
set ignorecase
set smartcase

set fileformats=unix,dos,mac

if exists('$SHELL')
    set shell=$SHELL
else
    set shell=/bin/sh
endif

" session management
let g:session_directory = "~/.config/nvim/session"
let g:session_autoload = "no"
let g:session_autosave = "no"
let g:session_command_aliases = 1

"*****************************************************************************
"" Visual Settings
"*****************************************************************************
syntax on
set ruler
set number

let no_buffers_menu=1
"colorscheme molokai
set tgc
colorscheme gruvbox
let g:gruvbox_contrast_dark = 'hard'
if exists('+termguicolors')
    let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
    let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
endif
let g:gruvbox_invert_selection='0'
set background=dark


set mousemodel=popup
set t_Co=256
set guioptions=egmrti
set gfn=Monospace\ 10

if has("gui_running")
  if has("gui_mac") || has("gui_macvim")
    set guifont=Menlo:h12
    set transparency=7
  endif
else
  let g:CSApprox_loaded = 1

  " IndentLine
  let g:indentLine_enabled = 1
  let g:indentLine_concealcursor = 0
  let g:indentLine_char = '┆'
  let g:indentLine_faster = 1

  
  if $COLORTERM == 'gnome-terminal'
    set term=gnome-256color
  else
    if $TERM == 'xterm'
      set term=xterm-256color
    endif
  endif
  
endif


if &term =~ '256color'
  set t_ut=
endif


"" Disable the blinking cursor.
set gcr=a:blinkon0

set scrolloff=3


"" Status bar
set laststatus=2

"" Use modeline overrides
set modeline
set modelines=10

set title
set titleold="Terminal"
set titlestring=%F

set statusline=%F%m%r%h%w%=(%{&ff}/%Y)\ (line\ %l\/%L,\ col\ %c)\

" Search mappings: These will make it so that going to the next one in a
" search will center on the line it's found in.
nnoremap n nzzzv
nnoremap N Nzzzv

if exists("*fugitive#statusline")
  set statusline+=%{fugitive#statusline()}
endif

" vim-airline
let g:airline_theme = 'powerlineish'
let g:airline#extensions#branch#enabled = 1
let g:airline#extensions#ale#enabled = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tagbar#enabled = 1
let g:airline_skip_empty_sections = 1

"*****************************************************************************
"" Abbreviations
"*****************************************************************************
"" no one is really happy until you have this shortcuts
cnoreabbrev W! w!
cnoreabbrev Q! q!
cnoreabbrev Qall! qall!
cnoreabbrev Wq wq
cnoreabbrev Wa wa
cnoreabbrev wQ wq
cnoreabbrev WQ wq
cnoreabbrev W w
cnoreabbrev Q q
cnoreabbrev Qall qall

"" NERDTree configuration
let g:NERDTreeChDirMode=2
let g:NERDTreeIgnore=['\.rbc$', '\~$', '\.pyc$', '\.db$', '\.sqlite$', '__pycache__']
let g:NERDTreeSortOrder=['^__\.py$', '\/$', '*', '\.swp$', '\.bak$', '\~$']
let g:NERDTreeShowBookmarks=1
let g:nerdtree_tabs_focus_on_files=1
let g:NERDTreeMapOpenInTabSilent = '<RightMouse>'
let g:NERDTreeWinSize = 31
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.pyc,*.db,*.sqlite
nnoremap <silent> <F2> :NERDTreeFind<CR>
nnoremap <silent> <F3> :NERDTreeToggle<CR>

" grep.vim
nnoremap <silent> <leader>f :Rgrep<CR>
let Grep_Default_Options = '-IR'
let Grep_Skip_Files = '*.log *.db'
let Grep_Skip_Dirs = '.git node_modules'

" terminal emulation
nnoremap <silent> <leader>sh :terminal<CR>


"*****************************************************************************
"" Commands
"*****************************************************************************
" remove trailing whitespaces
command! FixWhitespace :%s/\s\+$//e

"*****************************************************************************
"" Functions
"*****************************************************************************
if !exists('*s:setupWrapping')
  function s:setupWrapping()
    set wrap
    set wm=2
    set textwidth=79
  endfunction
endif

"*****************************************************************************
"" Autocmd Rules
"*****************************************************************************
"" The PC is fast enough, do syntax highlight syncing from start unless 200 lines
augroup vimrc-sync-fromstart
  autocmd!
  autocmd BufEnter * :syntax sync maxlines=200
augroup END

"" Remember cursor position
augroup vimrc-remember-cursor-position
  autocmd!
  autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
augroup END

"" txt
augroup vimrc-wrapping
  autocmd!
  autocmd BufRead,BufNewFile *.txt call s:setupWrapping()
augroup END

"" make/cmake
augroup vimrc-make-cmake
  autocmd!
  autocmd FileType make setlocal noexpandtab
  autocmd BufNewFile,BufRead CMakeLists.txt setlocal filetype=cmake
augroup END

set autoread

"*****************************************************************************
"" Mappings
"*****************************************************************************

"" Split
noremap <Leader>h :<C-u>split<CR>
noremap <Leader>v :<C-u>vsplit<CR>

"" Git
noremap <Leader>ga :Gwrite<CR>
noremap <Leader>gc :Git commit --verbose<CR>
noremap <Leader>gsh :Gpush<CR>
noremap <Leader>gll :Gpull<CR>
noremap <Leader>gs :Gstatus<CR>
noremap <Leader>gb :Gblame<CR>
noremap <Leader>gd :Gvdiff<CR>
noremap <Leader>gr :Gremove<CR>

" session management
nnoremap <leader>so :OpenSession<Space>
nnoremap <leader>ss :SaveSession<Space>
nnoremap <leader>sd :DeleteSession<CR>
nnoremap <leader>sc :CloseSession<CR>

"" Tabs
nnoremap <Tab> gt
nnoremap <S-Tab> gT
nnoremap <silent> <S-t> :tabnew<CR>

"" Set working directory
nnoremap <leader>. :lcd %:p:h<CR>

"" Opens an edit command with the path of the currently edited file filled in
noremap <Leader>e :e <C-R>=expand("%:p:h") . "/" <CR>

"" Opens a tab edit command with the path of the currently edited file filled
noremap <Leader>te :tabe <C-R>=expand("%:p:h") . "/" <CR>

"" fzf.vim
set wildmode=list:longest,list:full
set wildignore+=*.o,*.obj,.git,*.rbc,*.pyc,__pycache__
let $FZF_DEFAULT_COMMAND =  "find * -path '*/\.*' -prune -o -path 'node_modules/**' -prune -o -path 'target/**' -prune -o -path 'dist/**' -prune -o  -type f -print -o -type l -print 2> /dev/null"

" The Silver Searcher
if executable('ag')
  let $FZF_DEFAULT_COMMAND = 'ag --hidden --ignore .git -g ""'
  set grepprg=ag\ --nogroup\ --nocolor
endif

" ripgrep
if executable('rg')
  let $FZF_DEFAULT_COMMAND = 'rg --files --hidden --follow --glob "!.git/*"'
  set grepprg=rg\ --vimgrep
  command! -bang -nargs=* Find call fzf#vim#grep('rg --column --line-number --no-heading --fixed-strings --ignore-case --hidden --follow --glob "!.git/*" --color "always" '.shellescape(<q-args>).'| tr -d "\017"', 1, <bang>0)
endif

cnoremap <C-P> <C-R>=expand("%:p:h") . "/" <CR>
nnoremap <silent> <leader>b :Buffers<CR>
nnoremap <silent> <leader>e :FZF -m<CR>
"Recovery commands from history through FZF
nmap <leader>y :History:<CR>

" snippets
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<c-b>"
let g:UltiSnipsEditSplit="vertical"

" ale
let g:ale_linters = {}

" Tagbar
nmap <silent> <F4> :TagbarToggle<CR>
let g:tagbar_autofocus = 1

" Disable visualbell
set noerrorbells visualbell t_vb=
if has('autocmd')
  autocmd GUIEnter * set visualbell t_vb=
endif

"" Copy/Paste/Cut
if has('unnamedplus')
  set clipboard=unnamed,unnamedplus
endif

noremap YY "+y<CR>
noremap <leader>p "+gP<CR>
noremap XX "+x<CR>

if has('macunix')
  " pbcopy for OSX copy/paste
  vmap <C-x> :!pbcopy<CR>
  vmap <C-c> :w !pbcopy<CR><CR>
endif

"" Buffer nav
noremap <leader>z :bp<CR>
noremap <leader>q :bp<CR>
noremap <leader>x :bn<CR>
noremap <leader>w :bn<CR>

"" Close buffer
noremap <leader>c :bd<CR>

"" Clean search (highlight)
nnoremap <silent> <leader><space> :noh<cr>

"" Switching windows
noremap <C-j> <C-w>j
noremap <C-k> <C-w>k
noremap <C-l> <C-w>l
noremap <C-h> <C-w>h

"" Vmap for maintain Visual Mode after shifting > and <
vmap < <gv
vmap > >gv

"" Move visual block
vnoremap J :m '>+1<CR>gv=gv
vnoremap K :m '<-2<CR>gv=gv

"" Open current line on GitHub
nnoremap <Leader>o :.Gbrowse<CR>

"*****************************************************************************
"" Custom configs
"*****************************************************************************


"*****************************************************************************
"*****************************************************************************

"" Include user's local vim config
if filereadable(expand("~/.config/nvim/local_init.vim"))
  source ~/.config/nvim/local_init.vim
endif

"*****************************************************************************
"" Convenience variables
"*****************************************************************************

" vim-airline
if !exists('g:airline_symbols')
  let g:airline_symbols = {}
endif

if !exists('g:airline_powerline_fonts')
  let g:airline#extensions#tabline#left_sep = ' '
  let g:airline#extensions#tabline#left_alt_sep = '|'
  let g:airline_left_sep          = '▶'
  let g:airline_left_alt_sep      = '»'
  let g:airline_right_sep         = '◀'
  let g:airline_right_alt_sep     = '«'
  let g:airline#extensions#branch#prefix     = '⤴' "➔, ➥, ⎇
  let g:airline#extensions#readonly#symbol   = '⊘'
  let g:airline#extensions#linecolumn#prefix = '¶'
  let g:airline#extensions#paste#symbol      = 'ρ'
  let g:airline_symbols.linenr    = '␊'
  let g:airline_symbols.branch    = '⎇'
  let g:airline_symbols.paste     = 'ρ'
  let g:airline_symbols.paste     = 'Þ'
  let g:airline_symbols.paste     = '∥'
  let g:airline_symbols.whitespace = 'Ξ'
else
  let g:airline#extensions#tabline#left_sep = ''
  let g:airline#extensions#tabline#left_alt_sep = ''

  " powerline symbols
  let g:airline_left_sep = ''
  let g:airline_left_alt_sep = ''
  let g:airline_right_sep = ''
  let g:airline_right_alt_sep = ''
  let g:airline_symbols.branch = ''
  let g:airline_symbols.readonly = ''
  let g:airline_symbols.linenr = ''
endif


lua << EOF
local nvim_lsp = require('lspconfig')

-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local on_attach = function(client, bufnr)
  local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
  local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end

  -- Enable completion triggered by <c-x><c-o>
  -- buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')

  -- Mappings.
  local opts = { noremap=true, silent=true }

  -- See `:help vim.lsp.*` for documentation on any of the below functions
  buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
  buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
  buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
  buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
  buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
  buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
  buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
  buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
  buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
  buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
  buf_set_keymap('n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
  buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
  buf_set_keymap('n', '<space>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
  buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
  buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
  buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
  buf_set_keymap('n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)

end

-- Use a loop to conveniently call 'setup' on multiple servers and
-- map buffer local keybindings when the language server attaches
local servers = { 'gopls', 'pyright', 'bashls', 'dockerls', 'html', 'jsonls' }
for _, lsp in ipairs(servers) do
  nvim_lsp[lsp].setup {
    on_attach = on_attach,
    flags = {
      debounce_text_changes = 150,
    }
  }
end

-- Other Langservers
require'lspconfig'.terraformls.setup {
    on_attach = on_attach,
    cmd = { "terraform-ls", "serve" },
    filetypes = { "tf" },
--    root_dir = root_pattern(".terraform"),
}

require'lspconfig'.yamlls.setup {
    on_attach = on_attach,
    settings = {
        yaml = {
            schemas = {
                kubernetes = "/*.yaml"
--                kubernetes = 'https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.22.1-standalone/all.json'
            }
        }
    },
}


-- Set completeopt to have a better completion experience
vim.o.completeopt = 'menuone,noselect'

-- luasnip setup
local luasnip = require 'luasnip'

-- nvim-cmp setup
local cmp = require 'cmp'
cmp.setup {
  snippet = {
    expand = function(args)
      require('luasnip').lsp_expand(args.body)
    end,
  },
  mapping = {
    ['<C-p>'] = cmp.mapping.select_prev_item(),
    ['<C-n>'] = cmp.mapping.select_next_item(),
    ['<C-d>'] = cmp.mapping.scroll_docs(-4),
    ['<C-f>'] = cmp.mapping.scroll_docs(4),
    ['<C-Space>'] = cmp.mapping.complete(),
    ['<C-e>'] = cmp.mapping.close(),
    ['<CR>'] = cmp.mapping.confirm {
      behavior = cmp.ConfirmBehavior.Replace,
      select = true,
    },
    ['<Tab>'] = function(fallback)
      if vim.fn.pumvisible() == 1 then
        vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<C-n>', true, true, true), 'n')
      elseif luasnip.expand_or_jumpable() then
        vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<Plug>luasnip-expand-or-jump', true, true, true), '')
      else
        fallback()
      end
    end,
    ['<S-Tab>'] = function(fallback)
      if vim.fn.pumvisible() == 1 then
        vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<C-p>', true, true, true), 'n')
      elseif luasnip.jumpable(-1) then
        vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<Plug>luasnip-jump-prev', true, true, true), '')
      else
        fallback()
      end
    end,
  },
  sources = {
    { name = 'nvim_lsp' },
    { name = 'luasnip' },
  },
}

function goimports(timeout_ms)
  local context = { only = { "source.organizeImports" } }
  vim.validate { context = { context, "t", true } }

  local params = vim.lsp.util.make_range_params()
  params.context = context

  -- See the implementation of the textDocument/codeAction callback
  -- (lua/vim/lsp/handler.lua) for how to do this properly.
  local result = vim.lsp.buf_request_sync(0, "textDocument/codeAction", params, timeout_ms)
  if not result or next(result) == nil then return end
  local actions = result[1].result
  if not actions then return end
  local action = actions[1]

  -- textDocument/codeAction can return either Command[] or CodeAction[]. If it
  -- is a CodeAction, it can have either an edit, a command or both. Edits
  -- should be executed first.
  if action.edit or type(action.command) == "table" then
    if action.edit then
      vim.lsp.util.apply_workspace_edit(action.edit)
    end
    if type(action.command) == "table" then
      vim.lsp.buf.execute_command(action.command)
    end
  else
    vim.lsp.buf.execute_command(action)
  end
end

EOF
autocmd BufWritePre *.go lua goimports(1000)

Now, I have to check where to put your sugested config

@mjlbach
Copy link
Contributor

mjlbach commented Nov 16, 2021

You put my comment in the yaml file itself (if you can edit it), see :help modeline for a more general explanation (yamlls supports modelines)

@mjlbach
Copy link
Contributor

mjlbach commented Nov 16, 2021

alternatively

require('lspconfig').yamlls.setup {
    on_attach = on_attach,
    settings = {
        yaml = {
            schemas = {
                ["https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.22.0/deployment-apps-v1.json"] = "/*"
            }
        }
    },
}

@longwuyuan
Copy link
Author

Something wonderful is being observed.
I am getting the correct spec as per kubernetes 1.22.
Thanks tons. Really really grateful for all you have done. Saved from the hell of IDE GUI.

Now next problem is autocompletion. You can see my init.vim above. If you already know of any tips to get autocompletion, I will be grateful.

@mjlbach
Copy link
Contributor

mjlbach commented Nov 16, 2021

You can try copy/pasting that into the config you pasted above (the first one) which I believe is also the example config I wrote https://github.com/nvim-lua/kickstart.nvim

That includes autocompletion/snippet support out of the box

@longwuyuan
Copy link
Author

Apologies, I don't understand.
After trying the schema config you sent above, i can get Kubernetes 1.22 specs and validation, if I edit a Kubernetes manifest yaml file. So that long standing problem is thankfully resolved now. Much gratitude.

Next I mentioned I am unable to gt autocomplete with cntrl+space. Likely I have forgotten and need to check key mappings in my init.vim I pasted above. I was hoping you know how to enable autocomplete for kubernetes yaml. THen I see you sugested I copy/paste. I already copy/pasted just the one line that begins with a brace. That solved the schema problem. Do I need to copy/paste something else to solve the autocompletion problem. Thanks tons again.

@mjlbach
Copy link
Contributor

mjlbach commented Nov 16, 2021

Next I mentioned I am unable to gt autocomplete with cntrl+space.

That, to me, does not sound like autocompletion but completion for which you could use the built-in omnifunc. There's no difference anymore with the built-in client between completion sources, the difference is now in the interface.

Built-in, neovim has manually triggered completion via omnifunc (), which you could map to ctrl-space. If you want auto-completion, where the completion menu automatically pops up, you'd want to install a completion plugin like https://github.com/hrsh7th/nvim-cmp which is documented in our wiki.

For manually triggered completion (what I think you want):

Add this somewhere, add it within your on_attach callbac if you only want it to take effect when the language server starts

vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')

You can then trigger completion for any running language server (including yamlls which I verified) with (control-x control-o) which you can remap to ctrl-space.

For autocompletion:

Specifically you'd want to install these four plugins (nvim-cmp uses a modular approach as opposed to monolithic):
https://github.com/nvim-lua/kickstart.nvim/blob/61bd292f2a3ac15ee641b6524586a5ec1aa25df4/init.lua#L35-L38

and add this https://github.com/nvim-lua/kickstart.nvim/blob/61bd292f2a3ac15ee641b6524586a5ec1aa25df4/init.lua#L275-L320 to your config.

@longwuyuan
Copy link
Author

Thanks so much again. I am checking this

@longwuyuan
Copy link
Author

I chose autocompletion so installed the 4 plugins and put the config in init.vim.
I get the magical dropdown or boxes while editing golang now. I desired it. But yaml still does not have that dropdown/box and that was desired.

But yo have helped so much and autocompletion is documented and this issue was not for autocompletion. Just that I expected i expected nvim-cmp to work for yaml, just like it does for golang. Please suggest if we should drop this conversation here as this is not the original topic of this already closed issue. Thanks tons.

@mjlbach
Copy link
Contributor

mjlbach commented Nov 16, 2021

With the kickstart.nvim config, with only the following modification (and yamlls installed of course):

diff --git a/init.lua b/init.lua
index 5f3e8ea..c1ed0c8 100644
--- a/init.lua
+++ b/init.lua
@@ -224,7 +224,7 @@ local capabilities = vim.lsp.protocol.make_client_capabilities()
 capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
 
 -- Enable the following language servers
-local servers = { 'clangd', 'rust_analyzer', 'pyright', 'tsserver' }
+local servers = { 'clangd', 'rust_analyzer', 'pyright', 'tsserver', 'yamlls' }
 for _, lsp in ipairs(servers) do
   nvim_lsp[lsp].setup {
     on_attach = on_attach,

If I open the following yaml file:

action.yaml

# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json

If I add a new line and type c I get the concurrency option as an autocomplete option, so its working for me at least :)

@longwuyuan
Copy link
Author

:-( this is not working ;

image

@mjlbach , where am i making a mistake :-(

@mjlbach
Copy link
Contributor

mjlbach commented Nov 16, 2021

That's not what I sent you :)

The pattern is schema: filepattern, like:

schemas = {
                ["https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.22.0/deployment-apps-v1.json"] = "/*"
            }

what you have above is schema: schema.

You proably don't ever want to explicitly write "kubernetes" on the left, as that uses their built-in schemas (which you don't want to use), and you always want the right to be a file pattern.

@lithammer

This comment has been minimized.

@longwuyuan
Copy link
Author

I am copy/pasting my init.vim as well the error below ;

image

" vim-bootstrap 2021-08-28 17:55:02

"*****************************************************************************
"" Vim-Plug core
"*****************************************************************************
let vimplug_exists=expand('~/.config/nvim/autoload/plug.vim')
if has('win32')&&!has('win64')
  let curl_exists=expand('C:\Windows\Sysnative\curl.exe')
else
  let curl_exists=expand('curl')
endif

let g:vim_bootstrap_langs = ""
let g:vim_bootstrap_editor = "neovim"				" nvim or vim
let g:vim_bootstrap_theme = "molokai"
let g:vim_bootstrap_frams = ""

if !filereadable(vimplug_exists)
  if !executable(curl_exists)
    echoerr "You have to install curl or first install vim-plug yourself!"
    execute "q!"
  endif
  echo "Installing Vim-Plug..."
  echo ""
  silent exec "!"curl_exists" -fLo " . shellescape(vimplug_exists) . " --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"
  let g:not_finish_vimplug = "yes"

  autocmd VimEnter * PlugInstall
endif

" Required:
call plug#begin(expand('~/.config/nvim/plugged'))

"*****************************************************************************
"" Plug install packages
"*****************************************************************************
Plug 'scrooloose/nerdtree'
Plug 'jistr/vim-nerdtree-tabs'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-fugitive'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'airblade/vim-gitgutter'
Plug 'vim-scripts/grep.vim'
Plug 'vim-scripts/CSApprox'
Plug 'Raimondi/delimitMate'
Plug 'majutsushi/tagbar'
"Plug 'dense-analysis/ale'
Plug 'Yggdroot/indentLine'
Plug 'editor-bootstrap/vim-bootstrap-updater'
Plug 'tpope/vim-rhubarb' " required by fugitive to :Gbrowse
Plug 'tomasr/molokai'


if isdirectory('/usr/local/opt/fzf')
  Plug '/usr/local/opt/fzf' | Plug 'junegunn/fzf.vim'
else
  Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --bin' }
  Plug 'junegunn/fzf.vim'
endif
let g:make = 'gmake'
if exists('make')
        let g:make = 'make'
endif
Plug 'Shougo/vimproc.vim', {'do': g:make}

"" Vim-Session
Plug 'xolox/vim-misc'
Plug 'xolox/vim-session'

"" Snippets
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'

"*****************************************************************************
"" Custom bundles
"*****************************************************************************
Plug 'neovim/nvim-lspconfig'
Plug 'kabouzeid/nvim-lspinstall'
Plug 'hrsh7th/nvim-cmp'
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'saadparwaiz1/cmp_luasnip'
Plug 'L3MON4D3/LuaSnip'
Plug 'morhetz/gruvbox'

"*****************************************************************************
"*****************************************************************************
" Autocompletion
"
Plug 'hrsh7th/nvim-cmp'
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'saadparwaiz1/cmp_luasnip'
Plug 'L3MON4D3/LuaSnip'

"*******

"" Include user's extra bundle
if filereadable(expand("~/.config/nvim/local_bundles.vim"))
  source ~/.config/nvim/local_bundles.vim
endif

call plug#end()

" Required:
filetype plugin indent on


"*****************************************************************************
"" Basic Setup
"*****************************************************************************"
"G" Encoding
set encoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8
set ttyfast

"" Fix backspace indent
set backspace=indent,eol,start

"" Tabs. May be overridden by autocmd rules
set tabstop=4
set softtabstop=0
set shiftwidth=4
set expandtab

"" Map leader to ,
let mapleader=','

"" Enable hidden buffers
set hidden

"" Searching
set hlsearch
set incsearch
set ignorecase
set smartcase

set fileformats=unix,dos,mac

if exists('$SHELL')
    set shell=$SHELL
else
    set shell=/bin/sh
endif

" session management
let g:session_directory = "~/.config/nvim/session"
let g:session_autoload = "no"
let g:session_autosave = "no"
let g:session_command_aliases = 1

"*****************************************************************************
"" Visual Settings
"*****************************************************************************
syntax on
set ruler
set number

let no_buffers_menu=1
"colorscheme molokai
set tgc
colorscheme gruvbox
let g:gruvbox_contrast_dark = 'hard'
if exists('+termguicolors')
    let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
    let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
endif
let g:gruvbox_invert_selection='0'
set background=dark


set mousemodel=popup
set t_Co=256
set guioptions=egmrti
set gfn=Monospace\ 10

if has("gui_running")
  if has("gui_mac") || has("gui_macvim")
    set guifont=Menlo:h12
    set transparency=7
  endif
else
  let g:CSApprox_loaded = 1

  " IndentLine
  let g:indentLine_enabled = 1
  let g:indentLine_concealcursor = 0
  let g:indentLine_char = '┆'
  let g:indentLine_faster = 1

  
  if $COLORTERM == 'gnome-terminal'
    set term=gnome-256color
  else
    if $TERM == 'xterm'
      set term=xterm-256color
    endif
  endif
  
endif


if &term =~ '256color'
  set t_ut=
endif


"" Disable the blinking cursor.
set gcr=a:blinkon0

set scrolloff=3


"" Status bar
set laststatus=2

"" Use modeline overrides
set modeline
set modelines=10

set title
set titleold="Terminal"
set titlestring=%F

set statusline=%F%m%r%h%w%=(%{&ff}/%Y)\ (line\ %l\/%L,\ col\ %c)\

" Search mappings: These will make it so that going to the next one in a
" search will center on the line it's found in.
nnoremap n nzzzv
nnoremap N Nzzzv

if exists("*fugitive#statusline")
  set statusline+=%{fugitive#statusline()}
endif

" vim-airline
let g:airline_theme = 'powerlineish'
let g:airline#extensions#branch#enabled = 1
let g:airline#extensions#ale#enabled = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tagbar#enabled = 1
let g:airline_skip_empty_sections = 1

"*****************************************************************************
"" Abbreviations
"*****************************************************************************
"" no one is really happy until you have this shortcuts
cnoreabbrev W! w!
cnoreabbrev Q! q!
cnoreabbrev Qall! qall!
cnoreabbrev Wq wq
cnoreabbrev Wa wa
cnoreabbrev wQ wq
cnoreabbrev WQ wq
cnoreabbrev W w
cnoreabbrev Q q
cnoreabbrev Qall qall

"" NERDTree configuration
let g:NERDTreeChDirMode=2
let g:NERDTreeIgnore=['\.rbc$', '\~$', '\.pyc$', '\.db$', '\.sqlite$', '__pycache__']
let g:NERDTreeSortOrder=['^__\.py$', '\/$', '*', '\.swp$', '\.bak$', '\~$']
let g:NERDTreeShowBookmarks=1
let g:nerdtree_tabs_focus_on_files=1
let g:NERDTreeMapOpenInTabSilent = '<RightMouse>'
let g:NERDTreeWinSize = 31
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.pyc,*.db,*.sqlite
nnoremap <silent> <F2> :NERDTreeFind<CR>
nnoremap <silent> <F3> :NERDTreeToggle<CR>

" grep.vim
nnoremap <silent> <leader>f :Rgrep<CR>
let Grep_Default_Options = '-IR'
let Grep_Skip_Files = '*.log *.db'
let Grep_Skip_Dirs = '.git node_modules'

" terminal emulation
nnoremap <silent> <leader>sh :terminal<CR>


"*****************************************************************************
"" Commands
"*****************************************************************************
" remove trailing whitespaces
command! FixWhitespace :%s/\s\+$//e

"*****************************************************************************
"" Functions
"*****************************************************************************
if !exists('*s:setupWrapping')
  function s:setupWrapping()
    set wrap
    set wm=2
    set textwidth=79
  endfunction
endif

"*****************************************************************************
"" Autocmd Rules
"*****************************************************************************
"" The PC is fast enough, do syntax highlight syncing from start unless 200 lines
augroup vimrc-sync-fromstart
  autocmd!
  autocmd BufEnter * :syntax sync maxlines=200
augroup END

"" Remember cursor position
augroup vimrc-remember-cursor-position
  autocmd!
  autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
augroup END

"" txt
augroup vimrc-wrapping
  autocmd!
  autocmd BufRead,BufNewFile *.txt call s:setupWrapping()
augroup END

"" make/cmake
augroup vimrc-make-cmake
  autocmd!
  autocmd FileType make setlocal noexpandtab
  autocmd BufNewFile,BufRead CMakeLists.txt setlocal filetype=cmake
augroup END

set autoread

"*****************************************************************************
"" Mappings
"*****************************************************************************

"" Split
noremap <Leader>h :<C-u>split<CR>
noremap <Leader>v :<C-u>vsplit<CR>

"" Git
noremap <Leader>ga :Gwrite<CR>
noremap <Leader>gc :Git commit --verbose<CR>
noremap <Leader>gsh :Gpush<CR>
noremap <Leader>gll :Gpull<CR>
noremap <Leader>gs :Gstatus<CR>
noremap <Leader>gb :Gblame<CR>
noremap <Leader>gd :Gvdiff<CR>
noremap <Leader>gr :Gremove<CR>

" session management
nnoremap <leader>so :OpenSession<Space>
nnoremap <leader>ss :SaveSession<Space>
nnoremap <leader>sd :DeleteSession<CR>
nnoremap <leader>sc :CloseSession<CR>

"" Tabs
nnoremap <Tab> gt
nnoremap <S-Tab> gT
nnoremap <silent> <S-t> :tabnew<CR>

"" Set working directory
nnoremap <leader>. :lcd %:p:h<CR>

"" Opens an edit command with the path of the currently edited file filled in
noremap <Leader>e :e <C-R>=expand("%:p:h") . "/" <CR>

"" Opens a tab edit command with the path of the currently edited file filled
noremap <Leader>te :tabe <C-R>=expand("%:p:h") . "/" <CR>

"" fzf.vim
set wildmode=list:longest,list:full
set wildignore+=*.o,*.obj,.git,*.rbc,*.pyc,__pycache__
let $FZF_DEFAULT_COMMAND =  "find * -path '*/\.*' -prune -o -path 'node_modules/**' -prune -o -path 'target/**' -prune -o -path 'dist/**' -prune -o  -type f -print -o -type l -print 2> /dev/null"

" The Silver Searcher
if executable('ag')
  let $FZF_DEFAULT_COMMAND = 'ag --hidden --ignore .git -g ""'
  set grepprg=ag\ --nogroup\ --nocolor
endif

" ripgrep
if executable('rg')
  let $FZF_DEFAULT_COMMAND = 'rg --files --hidden --follow --glob "!.git/*"'
  set grepprg=rg\ --vimgrep
  command! -bang -nargs=* Find call fzf#vim#grep('rg --column --line-number --no-heading --fixed-strings --ignore-case --hidden --follow --glob "!.git/*" --color "always" '.shellescape(<q-args>).'| tr -d "\017"', 1, <bang>0)
endif

cnoremap <C-P> <C-R>=expand("%:p:h") . "/" <CR>
nnoremap <silent> <leader>b :Buffers<CR>
nnoremap <silent> <leader>e :FZF -m<CR>
"Recovery commands from history through FZF
nmap <leader>y :History:<CR>

" snippets
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<c-b>"
let g:UltiSnipsEditSplit="vertical"

" ale
let g:ale_linters = {}

" Tagbar
nmap <silent> <F4> :TagbarToggle<CR>
let g:tagbar_autofocus = 1

" Disable visualbell
set noerrorbells visualbell t_vb=
if has('autocmd')
  autocmd GUIEnter * set visualbell t_vb=
endif

"" Copy/Paste/Cut
if has('unnamedplus')
  set clipboard=unnamed,unnamedplus
endif

noremap YY "+y<CR>
noremap <leader>p "+gP<CR>
noremap XX "+x<CR>

if has('macunix')
  " pbcopy for OSX copy/paste
  vmap <C-x> :!pbcopy<CR>
  vmap <C-c> :w !pbcopy<CR><CR>
endif

"" Buffer nav
noremap <leader>z :bp<CR>
noremap <leader>q :bp<CR>
noremap <leader>x :bn<CR>
noremap <leader>w :bn<CR>

"" Close buffer
noremap <leader>c :bd<CR>

"" Clean search (highlight)
nnoremap <silent> <leader><space> :noh<cr>

"" Switching windows
noremap <C-j> <C-w>j
noremap <C-k> <C-w>k
noremap <C-l> <C-w>l
noremap <C-h> <C-w>h

"" Vmap for maintain Visual Mode after shifting > and <
vmap < <gv
vmap > >gv

"" Move visual block
vnoremap J :m '>+1<CR>gv=gv
vnoremap K :m '<-2<CR>gv=gv

"" Open current line on GitHub
nnoremap <Leader>o :.Gbrowse<CR>

"*****************************************************************************
"" Custom configs
"*****************************************************************************


"*****************************************************************************
"*****************************************************************************

"" Include user's local vim config
if filereadable(expand("~/.config/nvim/local_init.vim"))
  source ~/.config/nvim/local_init.vim
endif

"*****************************************************************************
"" Convenience variables
"*****************************************************************************

" vim-airline
if !exists('g:airline_symbols')
  let g:airline_symbols = {}
endif

if !exists('g:airline_powerline_fonts')
  let g:airline#extensions#tabline#left_sep = ' '
  let g:airline#extensions#tabline#left_alt_sep = '|'
  let g:airline_left_sep          = '▶'
  let g:airline_left_alt_sep      = '»'
  let g:airline_right_sep         = '◀'
  let g:airline_right_alt_sep     = '«'
  let g:airline#extensions#branch#prefix     = '⤴' "➔, ➥, ⎇
  let g:airline#extensions#readonly#symbol   = '⊘'
  let g:airline#extensions#linecolumn#prefix = '¶'
  let g:airline#extensions#paste#symbol      = 'ρ'
  let g:airline_symbols.linenr    = '␊'
  let g:airline_symbols.branch    = '⎇'
  let g:airline_symbols.paste     = 'ρ'
  let g:airline_symbols.paste     = 'Þ'
  let g:airline_symbols.paste     = '∥'
  let g:airline_symbols.whitespace = 'Ξ'
else
  let g:airline#extensions#tabline#left_sep = ''
  let g:airline#extensions#tabline#left_alt_sep = ''

  " powerline symbols
  let g:airline_left_sep = ''
  let g:airline_left_alt_sep = ''
  let g:airline_right_sep = ''
  let g:airline_right_alt_sep = ''
  let g:airline_symbols.branch = ''
  let g:airline_symbols.readonly = ''
  let g:airline_symbols.linenr = ''
endif


lua << EOF
local nvim_lsp = require('lspconfig')

-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local on_attach = function(client, bufnr)
  local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
  local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end

  -- Enable completion triggered by <c-x><c-o>
  -- buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')

  -- Mappings.
  local opts = { noremap=true, silent=true }

  -- See `:help vim.lsp.*` for documentation on any of the below functions
  buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
  buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
  buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
  buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
  buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
  buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
  buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
  buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
  buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
  buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
  buf_set_keymap('n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
  buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
  buf_set_keymap('n', '<space>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
  buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
  buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
  buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
  buf_set_keymap('n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)

end

-- Use a loop to conveniently call 'setup' on multiple servers and
-- map buffer local keybindings when the language server attaches
local servers = { 'gopls', 'pyright', 'bashls', 'dockerls', 'html', 'jsonls' }
for _, lsp in ipairs(servers) do
  nvim_lsp[lsp].setup {
    on_attach = on_attach,
    flags = {
      debounce_text_changes = 150,
    }
  }
end

-- Other Langservers
require'lspconfig'.terraformls.setup {
    on_attach = on_attach,
    cmd = { "terraform-ls", "serve" },
    filetypes = { "tf" },
--    root_dir = root_pattern(".terraform"),
}

require('lspconfig').yamlls.setup {
  -- other configuration for setup {}
  settings = {
  	yaml = {
      schemas = {
        ["https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.22.1-standalone/all.json"] = "/*"
      },
    },
  }
}


-- Set completeopt to have a better completion experience
vim.o.completeopt = 'menuone,noselect'

-- luasnip setup
local luasnip = require 'luasnip'

-- nvim-cmp setup
local cmp = require 'cmp'
cmp.setup {
  snippet = {
    expand = function(args)
      require('luasnip').lsp_expand(args.body)
    end,
  },
  mapping = {
    ['<C-p>'] = cmp.mapping.select_prev_item(),
    ['<C-n>'] = cmp.mapping.select_next_item(),
    ['<C-d>'] = cmp.mapping.scroll_docs(-4),
    ['<C-f>'] = cmp.mapping.scroll_docs(4),
    ['<C-Space>'] = cmp.mapping.complete(),
    ['<C-e>'] = cmp.mapping.close(),
    ['<CR>'] = cmp.mapping.confirm {
      behavior = cmp.ConfirmBehavior.Replace,
      select = true,
    },
    ['<Tab>'] = function(fallback)
      if vim.fn.pumvisible() == 1 then
        vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<C-n>', true, true, true), 'n')
      elseif luasnip.expand_or_jumpable() then
        vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<Plug>luasnip-expand-or-jump', true, true, true), '')
      else
        fallback()
      end
    end,
    ['<S-Tab>'] = function(fallback)
      if vim.fn.pumvisible() == 1 then
        vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<C-p>', true, true, true), 'n')
      elseif luasnip.jumpable(-1) then
        vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<Plug>luasnip-jump-prev', true, true, true), '')
      else
        fallback()
      end
    end,
  },
  sources = {
    { name = 'nvim_lsp' },
    { name = 'luasnip' },
  },
}

function goimports(timeout_ms)
  local context = { only = { "source.organizeImports" } }
  vim.validate { context = { context, "t", true } }

  local params = vim.lsp.util.make_range_params()
  params.context = context

  -- See the implementation of the textDocument/codeAction callback
  -- (lua/vim/lsp/handler.lua) for how to do this properly.
  local result = vim.lsp.buf_request_sync(0, "textDocument/codeAction", params, timeout_ms)
  if not result or next(result) == nil then return end
  local actions = result[1].result
  if not actions then return end
  local action = actions[1]

  -- textDocument/codeAction can return either Command[] or CodeAction[]. If it
  -- is a CodeAction, it can have either an edit, a command or both. Edits
  -- should be executed first.
  if action.edit or type(action.command) == "table" then
    if action.edit then
      vim.lsp.util.apply_workspace_edit(action.edit)
    end
    if type(action.command) == "table" then
      vim.lsp.buf.execute_command(action.command)
    end
  else
    vim.lsp.buf.execute_command(action)
  end
end

EOF
autocmd BufWritePre *.go lua goimports(1000)


@mjlbach
Copy link
Contributor

mjlbach commented Nov 16, 2021

@lithammer

schemas = {
  "https://..." = ["/*"]
}

That is not a valid lua table :)

@lithammer
Copy link
Collaborator

lithammer commented Nov 16, 2021

@lithammer

schemas = {
  "https://..." = ["/*"]
}

That is not a valid lua table :)

Ooops, don't know what I was thinking 🤦‍♂️

@mjlbach
Copy link
Contributor

mjlbach commented Nov 16, 2021

@longwuyuan that's a bit too long for me to go through 😅 I'd recommend starting with the kickstart.nvim config (which I'm almost certain works), and gradually modifying it to see where things break.

@longwuyuan
Copy link
Author

ok. will do that now

@longwuyuan
Copy link
Author

@mjlbach , i see the same error with minimimal_init.lua for yamlls ;

image

local on_windows = vim.loop.os_uname().version:match 'Windows'

local function join_paths(...)
  local path_sep = on_windows and '\\' or '/'
  local result = table.concat({ ... }, path_sep)
  return result
end

vim.cmd [[set runtimepath=$VIMRUNTIME]]

local temp_dir
if on_windows then
  temp_dir = vim.loop.os_getenv 'TEMP'
else
  temp_dir = '/tmp'
end

vim.cmd('set packpath=' .. join_paths(temp_dir, 'nvim', 'site'))

local package_root = join_paths(temp_dir, 'nvim', 'site', 'pack')
local install_path = join_paths(package_root, 'packer', 'start', 'packer.nvim')
local compile_path = join_paths(install_path, 'plugin', 'packer_compiled.lua')

local function load_plugins()
  require('packer').startup {
    {
      'wbthomason/packer.nvim',
      'neovim/nvim-lspconfig',
    },
    config = {
      package_root = package_root,
      compile_path = compile_path,
    },
  }
end

_G.load_config = function()
  vim.lsp.set_log_level 'trace'
  if vim.fn.has 'nvim-0.5.1' == 1 then
    require('vim.lsp.log').set_format_func(vim.inspect)
  end
  local nvim_lsp = require 'lspconfig'
  local on_attach = function(_, bufnr)
    local function buf_set_keymap(...)
      vim.api.nvim_buf_set_keymap(bufnr, ...)
    end
    local function buf_set_option(...)
      vim.api.nvim_buf_set_option(bufnr, ...)
    end

    buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')

    -- Mappings.
    local opts = { noremap = true, silent = true }
    buf_set_keymap('n', 'gD', '<Cmd>lua vim.lsp.buf.declaration()<CR>', opts)
    buf_set_keymap('n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>', opts)
    buf_set_keymap('n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts)
    buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
    buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
    buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
    buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
    buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
    buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
    buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
    buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
    buf_set_keymap('n', '<space>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
    buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
    buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
    buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
  end

  -- Add the server that troubles you here
  local name = 'yamlls'

  if not name then
    print 'You have not defined a server name, please edit minimal_init.lua'
  end
  if not nvim_lsp[name].document_config.default_config.cmd and not cmd then
    print [[You have not defined a server default cmd for a server
      that requires it please edit minimal_init.lua]]
  end

  nvim_lsp[name].setup {
    cmd = cmd,
    on_attach = on_attach,
  }

  print [[You can find your log at $HOME/.cache/nvim/lsp.log. Please paste in a github issue under a details tag as described in the issue template.]]
end

if vim.fn.isdirectory(install_path) == 0 then
  vim.fn.system { 'git', 'clone', 'https://github.com/wbthomason/packer.nvim', install_path }
  load_plugins()
  require('packer').sync()
  vim.cmd [[autocmd User PackerComplete ++once lua load_config()]]
else
  load_plugins()
  require('packer').sync()
  _G.load_config()
end

@mjlbach
Copy link
Contributor

mjlbach commented Nov 17, 2021

What version of neovim are you on? You should be on at least the 0.5.1 release

@longwuyuan
Copy link
Author

ok. big apology. Looks like I am on 0.5.0

 nvim --version
NVIM v0.5.0
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc-11 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/runner/work/neovim/neovim/build/config -I/home/runner/work/neovim/neovim/src -I/home/runner/work/neovim/neovim/.deps/usr/include -I/usr/include -I/home/runner/work/neovim/neovim/build/src/nvim/auto -I/home/runner/work/neovim/neovim/build/include
Compiled by runner@fv-az242-526

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "
/home/runner/work/neovim/neovim/build/nvim.AppDir/usr/share/nvim"

Run :checkhealth for more info

I will try to change now and check

@mjlbach
Copy link
Contributor

mjlbach commented Nov 17, 2021

No worries, there were some bugfixes to the client that you are running into that were fixed in the 0.5.1 release (0.6 is coming out in a few weeks). Generally lspconfig will support the nightly + last stable version (I'm going to start semver after the 0.6 release)

@longwuyuan
Copy link
Author

ok. different behaviour with 5.1. Attacin log file here ;

[START][2021-11-17 07:03:36] LSP logging initiated
[INFO][2021-11-17 07:03:36] .../vim/lsp/rpc.lua:316	"Starting RPC client"	{
  args = { "--stdio" },
  cmd = "yaml-language-server",
  extra = {}
}
[TRACE][2021-11-17 07:03:36] .../lua/vim/lsp.lua:839	"LSP[yamlls]"	"initialize_params"	{
  capabilities = {
    callHierarchy = {
      dynamicRegistration = false,
      <metatable> = <1>{
        __tostring = <function 1>
      }
    },
    textDocument = {
      codeAction = {
        codeActionLiteralSupport = {
          codeActionKind = {
            valueSet = { "", "Empty", "QuickFix", "Refactor", "RefactorExtract", "RefactorInline", "RefactorRewrite", "Source", "SourceOrganizeImports", "quickfix", "refactor", "refactor.extract", "refactor.inline", "refactor.rewrite", "source", "source.organizeImports" },
            <metatable> = <table 1>
          },
          <metatable> = <table 1>
        },
        dynamicRegistration = false,
        <metatable> = <table 1>
      },
      completion = {
        completionItem = {
          commitCharactersSupport = false,
          deprecatedSupport = false,
          documentationFormat = { "markdown", "plaintext" },
          preselectSupport = false,
          snippetSupport = false,
          <metatable> = <table 1>
        },
        completionItemKind = {
          valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 },
          <metatable> = <table 1>
        },
        contextSupport = false,
        dynamicRegistration = false,
        <metatable> = <table 1>
      },
      declaration = {
        linkSupport = true,
        <metatable> = <table 1>
      },
      definition = {
        linkSupport = true,
        <metatable> = <table 1>
      },
      documentHighlight = {
        dynamicRegistration = false,
        <metatable> = <table 1>
      },
      documentSymbol = {
        dynamicRegistration = false,
        hierarchicalDocumentSymbolSupport = true,
        symbolKind = {
          valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 },
          <metatable> = <table 1>
        },
        <metatable> = <table 1>
      },
      hover = {
        contentFormat = { "markdown", "plaintext" },
        dynamicRegistration = false,
        <metatable> = <table 1>
      },
      implementation = {
        linkSupport = true,
        <metatable> = <table 1>
      },
      publishDiagnostics = {
        relatedInformation = true,
        tagSupport = {
          valueSet = { 1, 2 },
          <metatable> = <table 1>
        },
        <metatable> = <table 1>
      },
      references = {
        dynamicRegistration = false,
        <metatable> = <table 1>
      },
      rename = {
        dynamicRegistration = false,
        prepareSupport = true,
        <metatable> = <table 1>
      },
      signatureHelp = {
        dynamicRegistration = false,
        signatureInformation = {
          documentationFormat = { "markdown", "plaintext" },
          <metatable> = <table 1>
        },
        <metatable> = <table 1>
      },
      synchronization = {
        didSave = true,
        dynamicRegistration = false,
        willSave = false,
        willSaveWaitUntil = false,
        <metatable> = <table 1>
      },
      typeDefinition = {
        linkSupport = true,
        <metatable> = <table 1>
      },
      <metatable> = <table 1>
    },
    window = {
      showDocument = {
        support = false,
        <metatable> = <table 1>
      },
      showMessage = {
        messageActionItem = {
          additionalPropertiesSupport = false,
          <metatable> = <table 1>
        },
        <metatable> = <table 1>
      },
      workDoneProgress = true,
      <metatable> = <table 1>
    },
    workspace = {
      applyEdit = true,
      configuration = true,
      symbol = {
        dynamicRegistration = false,
        hierarchicalWorkspaceSymbolSupport = true,
        symbolKind = {
          valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 },
          <metatable> = <table 1>
        },
        <metatable> = <table 1>
      },
      workspaceEdit = {
        resourceOperations = { "rename", "create", "delete" },
        <metatable> = <table 1>
      },
      workspaceFolders = true,
      <metatable> = <table 1>
    }
  },
  clientInfo = {
    name = "Neovim",
    version = "0.5.1"
  },
  initializationOptions = vim.empty_dict(),
  processId = 400812,
  trace = "off"
}
[DEBUG][2021-11-17 07:03:36] .../vim/lsp/rpc.lua:395	"rpc.send"	{
  id = 1,
  jsonrpc = "2.0",
  method = "initialize",
  params = {
    capabilities = {
      callHierarchy = {
        dynamicRegistration = false,
        <metatable> = <1>{
          __tostring = <function 1>
        }
      },
      textDocument = {
        codeAction = {
          codeActionLiteralSupport = {
            codeActionKind = {
              valueSet = { "", "Empty", "QuickFix", "Refactor", "RefactorExtract", "RefactorInline", "RefactorRewrite", "Source", "SourceOrganizeImports", "quickfix", "refactor", "refactor.extract", "refactor.inline", "refactor.rewrite", "source", "source.organizeImports" },
              <metatable> = <table 1>
            },
            <metatable> = <table 1>
          },
          dynamicRegistration = false,
          <metatable> = <table 1>
        },
        completion = {
          completionItem = {
            commitCharactersSupport = false,
            deprecatedSupport = false,
            documentationFormat = { "markdown", "plaintext" },
            preselectSupport = false,
            snippetSupport = false,
            <metatable> = <table 1>
          },
          completionItemKind = {
            valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 },
            <metatable> = <table 1>
          },
          contextSupport = false,
          dynamicRegistration = false,
          <metatable> = <table 1>
        },
        declaration = {
          linkSupport = true,
          <metatable> = <table 1>
        },
        definition = {
          linkSupport = true,
          <metatable> = <table 1>
        },
        documentHighlight = {
          dynamicRegistration = false,
          <metatable> = <table 1>
        },
        documentSymbol = {
          dynamicRegistration = false,
          hierarchicalDocumentSymbolSupport = true,
          symbolKind = {
            valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 },
            <metatable> = <table 1>
          },
          <metatable> = <table 1>
        },
        hover = {
          contentFormat = { "markdown", "plaintext" },
          dynamicRegistration = false,
          <metatable> = <table 1>
        },
        implementation = {
          linkSupport = true,
          <metatable> = <table 1>
        },
        publishDiagnostics = {
          relatedInformation = true,
          tagSupport = {
            valueSet = { 1, 2 },
            <metatable> = <table 1>
          },
          <metatable> = <table 1>
        },
        references = {
          dynamicRegistration = false,
          <metatable> = <table 1>
        },
        rename = {
          dynamicRegistration = false,
          prepareSupport = true,
          <metatable> = <table 1>
        },
        signatureHelp = {
          dynamicRegistration = false,
          signatureInformation = {
            documentationFormat = { "markdown", "plaintext" },
            <metatable> = <table 1>
          },
          <metatable> = <table 1>
        },
        synchronization = {
          didSave = true,
          dynamicRegistration = false,
          willSave = false,
          willSaveWaitUntil = false,
          <metatable> = <table 1>
        },
        typeDefinition = {
          linkSupport = true,
          <metatable> = <table 1>
        },
        <metatable> = <table 1>
      },
      window = {
        showDocument = {
          support = false,
          <metatable> = <table 1>
        },
        showMessage = {
          messageActionItem = {
            additionalPropertiesSupport = false,
            <metatable> = <table 1>
          },
          <metatable> = <table 1>
        },
        workDoneProgress = true,
        <metatable> = <table 1>
      },
      workspace = {
        applyEdit = true,
        configuration = true,
        symbol = {
          dynamicRegistration = false,
          hierarchicalWorkspaceSymbolSupport = true,
          symbolKind = {
            valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 },
            <metatable> = <table 1>
          },
          <metatable> = <table 1>
        },
        workspaceEdit = {
          resourceOperations = { "rename", "create", "delete" },
          <metatable> = <table 1>
        },
        workspaceFolders = true,
        <metatable> = <table 1>
      }
    },
    clientInfo = {
      name = "Neovim",
      version = "0.5.1"
    },
    initializationOptions = vim.empty_dict(),
    processId = 400812,
    trace = "off"
  }
}
[DEBUG][2021-11-17 07:04:02] .../vim/lsp/rpc.lua:496	"rpc.receive"	{
  id = 1,
  jsonrpc = "2.0",
  result = {
    capabilities = {
      codeActionProvider = true,
      codeLensProvider = {
        resolveProvider = false
      },
      completionProvider = {
        resolveProvider = false
      },
      definitionProvider = true,
      documentFormattingProvider = false,
      documentLinkProvider = vim.empty_dict(),
      documentOnTypeFormattingProvider = {
        firstTriggerCharacter = "\n"
      },
      documentRangeFormattingProvider = false,
      documentSymbolProvider = true,
      executeCommandProvider = {
        commands = { "jumpToSchema" }
      },
      foldingRangeProvider = false,
      hoverProvider = true,
      textDocumentSync = 2,
      workspace = {
        workspaceFolders = {
          changeNotifications = true,
          supported = true
        }
      }
    }
  }
}
[DEBUG][2021-11-17 07:04:02] .../vim/lsp/rpc.lua:395	"rpc.send"	{
  jsonrpc = "2.0",
  method = "initialized",
  params = {
    [true] = 6
  }
}
[DEBUG][2021-11-17 07:04:02] .../vim/lsp/rpc.lua:395	"rpc.send"	{
  jsonrpc = "2.0",
  method = "workspace/didChangeConfiguration",
  params = {
    settings = {
      redhat = {
        telemetry = {
          enabled = false,
          <metatable> = <1>{
            __tostring = <function 1>
          }
        },
        <metatable> = <table 1>
      },
      <metatable> = <table 1>
    }
  }
}
[DEBUG][2021-11-17 07:04:02] .../lua/vim/lsp.lua:866	"LSP[yamlls]"	"server_capabilities"	{
  codeActionProvider = true,
  codeLensProvider = {
    resolveProvider = false
  },
  completionProvider = {
    resolveProvider = false
  },
  definitionProvider = true,
  documentFormattingProvider = false,
  documentLinkProvider = {},
  documentOnTypeFormattingProvider = {
    firstTriggerCharacter = "\n"
  },
  documentRangeFormattingProvider = false,
  documentSymbolProvider = true,
  executeCommandProvider = {
    commands = { "jumpToSchema" }
  },
  foldingRangeProvider = false,
  hoverProvider = true,
  textDocumentSync = 2,
  workspace = {
    workspaceFolders = {
      changeNotifications = true,
      supported = true
    }
  }
}
[INFO][2021-11-17 07:04:02] .../lua/vim/lsp.lua:867	"LSP[yamlls]"	"initialized"	{
  resolved_capabilities = {
    call_hierarchy = false,
    code_action = true,
    code_lens = true,
    code_lens_resolve = false,
    completion = true,
    declaration = false,
    document_formatting = false,
    document_highlight = false,
    document_range_formatting = false,
    document_symbol = true,
    execute_command = true,
    find_references = false,
    goto_definition = true,
    hover = true,
    implementation = false,
    rename = false,
    signature_help = false,
    signature_help_trigger_characters = {},
    text_document_did_change = 2,
    text_document_open_close = true,
    text_document_save = true,
    text_document_save_include_text = false,
    text_document_will_save = false,
    text_document_will_save_wait_until = false,
    type_definition = false,
    workspace_folder_properties = {
      changeNotifications = true,
      supported = true
    },
    workspace_symbol = false
  }
}
[DEBUG][2021-11-17 07:04:02] .../vim/lsp/rpc.lua:395	"rpc.send"	{
  jsonrpc = "2.0",
  method = "textDocument/didOpen",
  params = {
    textDocument = {
      languageId = "yaml",
      text = "\n",
      uri = "file:///home/me/Documents/nvim/project/test.yaml",
      version = 0
    }
  }
}
[TRACE][2021-11-17 07:04:02] ...lsp/handlers.lua:452	"default_handler"	"textDocument/publishDiagnostics"	{
  ctx = '{\n  bufnr = 1,\n  client_id = 1,\n  method = "textDocument/publishDiagnostics"\n}',
  result = {
    diagnostics = {},
    uri = "file:///home/me/Documents/nvim/project/test.yaml"
  }
}
[DEBUG][2021-11-17 07:04:02] .../vim/lsp/rpc.lua:496	"rpc.receive"	{
  id = 0,
  jsonrpc = "2.0",
  method = "client/registerCapability",
  params = {
    registrations = { {
        id = "aa5b4e3f-646b-48df-9320-5804eaf0e676",
        method = "workspace/didChangeWorkspaceFolders",
        registerOptions = vim.empty_dict()
      } }
  }
}
[DEBUG][2021-11-17 07:04:02] .../vim/lsp/rpc.lua:496	"rpc.receive"	{
  id = 1,
  jsonrpc = "2.0",
  method = "workspace/configuration",
  params = {
    items = { {
        section = "yaml"
      }, {
        section = "http"
      }, {
        section = "[yaml]"
      } }
  }
}
[DEBUG][2021-11-17 07:04:02] .../vim/lsp/rpc.lua:496	"rpc.receive"	{
  id = 2,
  jsonrpc = "2.0",
  method = "workspace/configuration",
  params = {
    items = { {
        section = "yaml"
      }, {
        section = "http"
      }, {
        section = "[yaml]"
      } }
  }
}
[TRACE][2021-11-17 07:04:03] .../lua/vim/lsp.lua:701	"server_request"	"client/registerCapability"	{
  registrations = { {
      id = "aa5b4e3f-646b-48df-9320-5804eaf0e676",
      method = "workspace/didChangeWorkspaceFolders",
      registerOptions = {}
    } }
}
[TRACE][2021-11-17 07:04:03] .../lua/vim/lsp.lua:704	"server_request: found handler for"	"client/registerCapability"
[TRACE][2021-11-17 07:04:03] ...lsp/handlers.lua:452	"default_handler"	"client/registerCapability"	{
  ctx = '{\n  client_id = 1,\n  method = "client/registerCapability"\n}',
  result = {
    registrations = { {
        id = "aa5b4e3f-646b-48df-9320-5804eaf0e676",
        method = "workspace/didChangeWorkspaceFolders",
        registerOptions = {}
      } }
  }
}
[WARN][2021-11-17 07:04:03] ...lsp/handlers.lua:108	"The language server yamlls triggers a registerCapability handler despite dynamicRegistration set to false. Report upstream, this warning is harmless"
[DEBUG][2021-11-17 07:04:03] .../vim/lsp/rpc.lua:507	"server_request: callback result"	{
  result = vim.NIL,
  status = true
}
[DEBUG][2021-11-17 07:04:03] .../vim/lsp/rpc.lua:395	"rpc.send"	{
  id = 0,
  jsonrpc = "2.0",
  result = vim.NIL
}
[TRACE][2021-11-17 07:04:03] .../lua/vim/lsp.lua:701	"server_request"	"workspace/configuration"	{
  items = { {
      section = "yaml"
    }, {
      section = "http"
    }, {
      section = "[yaml]"
    } }
}
[TRACE][2021-11-17 07:04:03] .../lua/vim/lsp.lua:704	"server_request: found handler for"	"workspace/configuration"
[TRACE][2021-11-17 07:04:03] ...lsp/handlers.lua:452	"default_handler"	"workspace/configuration"	{
  ctx = '{\n  client_id = 1,\n  method = "workspace/configuration"\n}',
  result = {
    items = { {
        section = "yaml"
      }, {
        section = "http"
      }, {
        section = "[yaml]"
      } }
  }
}
[DEBUG][2021-11-17 07:04:03] .../vim/lsp/rpc.lua:507	"server_request: callback result"	{
  result = { vim.NIL, vim.NIL, vim.NIL },
  status = true
}
[DEBUG][2021-11-17 07:04:03] .../vim/lsp/rpc.lua:395	"rpc.send"	{
  id = 1,
  jsonrpc = "2.0",
  result = { vim.NIL, vim.NIL, vim.NIL }
}
[TRACE][2021-11-17 07:04:03] .../lua/vim/lsp.lua:701	"server_request"	"workspace/configuration"	{
  items = { {
      section = "yaml"
    }, {
      section = "http"
    }, {
      section = "[yaml]"
    } }
}
[TRACE][2021-11-17 07:04:03] .../lua/vim/lsp.lua:704	"server_request: found handler for"	"workspace/configuration"
[TRACE][2021-11-17 07:04:03] ...lsp/handlers.lua:452	"default_handler"	"workspace/configuration"	{
  ctx = '{\n  client_id = 1,\n  method = "workspace/configuration"\n}',
  result = {
    items = { {
        section = "yaml"
      }, {
        section = "http"
      }, {
        section = "[yaml]"
      } }
  }
}
[DEBUG][2021-11-17 07:04:03] .../vim/lsp/rpc.lua:507	"server_request: callback result"	{
  result = { vim.NIL, vim.NIL, vim.NIL },
  status = true
}
[DEBUG][2021-11-17 07:04:03] .../vim/lsp/rpc.lua:395	"rpc.send"	{
  id = 2,
  jsonrpc = "2.0",
  result = { vim.NIL, vim.NIL, vim.NIL }
}
[DEBUG][2021-11-17 07:04:03] .../vim/lsp/rpc.lua:496	"rpc.receive"	{
  jsonrpc = "2.0",
  method = "textDocument/publishDiagnostics",
  params = {
    diagnostics = {},
    uri = "file:///home/me/Documents/nvim/project/test.yaml"
  }
}
[TRACE][2021-11-17 07:04:03] .../lua/vim/lsp.lua:687	"notification"	"textDocument/publishDiagnostics"	{
  diagnostics = {},
  uri = "file:///home/me/Documents/nvim/project/test.yaml"
}
[TRACE][2021-11-17 07:04:03] ...lsp/handlers.lua:452	"default_handler"	"textDocument/publishDiagnostics"	{
  ctx = '{\n  client_id = 1,\n  method = "textDocument/publishDiagnostics"\n}',
  result = {
    diagnostics = {},
    uri = "file:///home/me/Documents/nvim/project/test.yaml"
  }
}
[DEBUG][2021-11-17 07:04:05] .../vim/lsp/rpc.lua:496	"rpc.receive"	{
  jsonrpc = "2.0",
  method = "textDocument/publishDiagnostics",
  params = {
    diagnostics = {},
    uri = "file:///home/me/Documents/nvim/project/test.yaml"
  }
}
[TRACE][2021-11-17 07:04:05] .../lua/vim/lsp.lua:687	"notification"	"textDocument/publishDiagnostics"	{
  diagnostics = {},
  uri = "file:///home/me/Documents/nvim/project/test.yaml"
}
[TRACE][2021-11-17 07:04:05] ...lsp/handlers.lua:452	"default_handler"	"textDocument/publishDiagnostics"	{
  ctx = '{\n  client_id = 1,\n  method = "textDocument/publishDiagnostics"\n}',
  result = {
    diagnostics = {},
    uri = "file:///home/me/Documents/nvim/project/test.yaml"
  }
}
[INFO][2021-11-17 07:04:25] .../lua/vim/lsp.lua:1226	"exit_handler"	{ {
    _on_attach = <function 1>,
    cancel_request = <function 2>,
    config = {
      _on_attach = <function 3>,
      autostart = true,
      capabilities = {
        callHierarchy = {
          dynamicRegistration = false,
          <metatable> = <1>{
            __tostring = <function 4>
          }
        },
        textDocument = {
          codeAction = {
            codeActionLiteralSupport = {
              codeActionKind = {
                valueSet = { "", "Empty", "QuickFix", "Refactor", "RefactorExtract", "RefactorInline", "RefactorRewrite", "Source", "SourceOrganizeImports", "quickfix", "refactor", "refactor.extract", "refactor.inline", "refactor.rewrite", "source", "source.organizeImports" },
                <metatable> = <table 1>
              },
              <metatable> = <table 1>
            },
            dynamicRegistration = false,
            <metatable> = <table 1>
          },
          completion = {
            completionItem = {
              commitCharactersSupport = false,
              deprecatedSupport = false,
              documentationFormat = { "markdown", "plaintext" },
              preselectSupport = false,
              snippetSupport = false,
              <metatable> = <table 1>
            },
            completionItemKind = {
              valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 },
              <metatable> = <table 1>
            },
            contextSupport = false,
            dynamicRegistration = false,
            <metatable> = <table 1>
          },
          declaration = {
            linkSupport = true,
            <metatable> = <table 1>
          },
          definition = {
            linkSupport = true,
            <metatable> = <table 1>
          },
          documentHighlight = {
            dynamicRegistration = false,
            <metatable> = <table 1>
          },
          documentSymbol = {
            dynamicRegistration = false,
            hierarchicalDocumentSymbolSupport = true,
            symbolKind = {
              valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 },
              <metatable> = <table 1>
            },
            <metatable> = <table 1>
          },
          hover = {
            contentFormat = { "markdown", "plaintext" },
            dynamicRegistration = false,
            <metatable> = <table 1>
          },
          implementation = {
            linkSupport = true,
            <metatable> = <table 1>
          },
          publishDiagnostics = {
            relatedInformation = true,
            tagSupport = {
              valueSet = { 1, 2 },
              <metatable> = <table 1>
            },
            <metatable> = <table 1>
          },
          references = {
            dynamicRegistration = false,
            <metatable> = <table 1>
          },
          rename = {
            dynamicRegistration = false,
            prepareSupport = true,
            <metatable> = <table 1>
          },
          signatureHelp = {
            dynamicRegistration = false,
            signatureInformation = {
              documentationFormat = { "markdown", "plaintext" },
              <metatable> = <table 1>
            },
            <metatable> = <table 1>
          },
          synchronization = {
            didSave = true,
            dynamicRegistration = false,
            willSave = false,
            willSaveWaitUntil = false,
            <metatable> = <table 1>
          },
          typeDefinition = {
            linkSupport = true,
            <metatable> = <table 1>
          },
          <metatable> = <table 1>
        },
        window = {
          showDocument = {
            support = false,
            <metatable> = <table 1>
          },
          showMessage = {
            messageActionItem = {
              additionalPropertiesSupport = false,
              <metatable> = <table 1>
            },
            <metatable> = <table 1>
          },
          workDoneProgress = true,
          <metatable> = <table 1>
        },
        workspace = {
          applyEdit = true,
          configuration = true,
          symbol = {
            dynamicRegistration = false,
            hierarchicalWorkspaceSymbolSupport = true,
            symbolKind = {
              valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 },
              <metatable> = <table 1>
            },
            <metatable> = <table 1>
          },
          workspaceEdit = {
            resourceOperations = { "rename", "create", "delete" },
            <metatable> = <table 1>
          },
          workspaceFolders = true,
          <metatable> = <table 1>
        }
      },
      cmd = { "yaml-language-server", "--stdio" },
      cwd = "/home/me/Documents/nvim/project",
      filetypes = { "yaml" },
      flags = {},
      get_language_id = <function 5>,
      handlers = <2>{},
      init_options = vim.empty_dict(),
      log_level = 2,
      message_level = 2,
      name = "yamlls",
      on_attach = <function 6>,
      on_exit = <function 7>,
      on_init = <function 8>,
      settings = {
        redhat = {
          telemetry = {
            enabled = false,
            <metatable> = <table 1>
          },
          <metatable> = <table 1>
        },
        <metatable> = <table 1>
      },
      single_file_support = true,
      <metatable> = <table 1>
    },
    handlers = <table 2>,
    id = 1,
    initialized = true,
    is_stopped = <function 9>,
    messages = {
      messages = {},
      name = "yamlls",
      progress = {},
      status = {}
    },
    name = "yamlls",
    notify = <function 10>,
    offset_encoding = "utf-16",
    request = <function 11>,
    request_sync = <function 12>,
    resolved_capabilities = {
      call_hierarchy = false,
      code_action = true,
      code_lens = true,
      code_lens_resolve = false,
      completion = true,
      declaration = false,
      document_formatting = false,
      document_highlight = false,
      document_range_formatting = false,
      document_symbol = true,
      execute_command = true,
      find_references = false,
      goto_definition = true,
      hover = true,
      implementation = false,
      rename = false,
      signature_help = false,
      signature_help_trigger_characters = {},
      text_document_did_change = 2,
      text_document_open_close = true,
      text_document_save = true,
      text_document_save_include_text = false,
      text_document_will_save = false,
      text_document_will_save_wait_until = false,
      type_definition = false,
      workspace_folder_properties = {
        changeNotifications = true,
        supported = true
      },
      workspace_symbol = false
    },
    rpc = {
      handle = <userdata 1>,
      notify = <function 13>,
      pid = 400821,
      request = <function 14>
    },
    server_capabilities = {
      codeActionProvider = true,
      codeLensProvider = {
        resolveProvider = false
      },
      completionProvider = {
        resolveProvider = false
      },
      definitionProvider = true,
      documentFormattingProvider = false,
      documentLinkProvider = {},
      documentOnTypeFormattingProvider = {
        firstTriggerCharacter = "\n"
      },
      documentRangeFormattingProvider = false,
      documentSymbolProvider = true,
      executeCommandProvider = {
        commands = { "jumpToSchema" }
      },
      foldingRangeProvider = false,
      hoverProvider = true,
      textDocumentSync = 2,
      workspace = {
        workspaceFolders = {
          changeNotifications = true,
          supported = true
        }
      }
    },
    stop = <function 15>,
    supports_method = <function 16>,
    workspace_did_change_configuration = <function 17>
  } }
[DEBUG][2021-11-17 07:04:25] .../vim/lsp/rpc.lua:395	"rpc.send"	{
  id = 2,
  jsonrpc = "2.0",
  method = "shutdown"
}
[DEBUG][2021-11-17 07:04:25] .../vim/lsp/rpc.lua:496	"rpc.receive"	{
  id = 2,
  jsonrpc = "2.0",
  result = vim.NIL
}
[DEBUG][2021-11-17 07:04:25] .../vim/lsp/rpc.lua:395	"rpc.send"	{
  jsonrpc = "2.0",
  method = "exit"
}


@mjlbach
Copy link
Contributor

mjlbach commented Nov 17, 2021

You didn't say what the different behavior is :) The log file looks fine.

@longwuyuan
Copy link
Author

oh yes. how stupid can i get.

Now I tried modeline in a test.yaml file and I see that it is doing some validation

image

Although the validation itself is bonkers

@longwuyuan
Copy link
Author

oh sorry .. not bonkers at all. to validate all objects .. i should put all.json there

@mjlbach
Copy link
Contributor

mjlbach commented Nov 17, 2021

No worries :)

I know nothing about k8s but there are a ton of different schemas under that 1.22 subfolder, maybe it's not the deployment-apps one you need

@longwuyuan
Copy link
Author

true. this is super fantastic. I just put the modeline in my yaml file and it works wonders. your help and your work is the motivation to use nvim. thanks tons.

Not sure if this is right place to ask, but after all the youtube videos and blogs, is there a authoritative list of plugins or a authoritative init.lua that is designed for practical use anywhere ? I mean for serious work, what are the plugns and related configs I need to add. nvim-cmp seems like one requirement. Beyond that there is so much talk about gitgutter, airline etc

@mjlbach
Copy link
Contributor

mjlbach commented Nov 17, 2021

You are welcome! As for your question, it depends.

That's why I created kickstart.nvim/try.nvim, to at least give people a place to start. There are also "frameworks" like lunarvim, nvchad, et. al. Lunarvim appears reasonably popular. I am personally a KISS/DIY person so I stick to things I write myself haha

@longwuyuan
Copy link
Author

Thanks tons. Same here in terms of KISS/DIY. But I am not a developer level skilled user. The biggest problem right now is closing unused files. The shortcuts and :bd (buffer delete) commands close and exit the editor nvim. There seems no way to keep nvim open and just close some files.

@mjlbach
Copy link
Contributor

mjlbach commented Nov 17, 2021

For those type questions I would ask on the matrix. I think at least the yaml-language-server issue is mostly resolved :)

@longwuyuan
Copy link
Author

yes... not ostly ... i think fully and satisfactory resolved as no more a mystery. thanks tons.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants