json.lua 645 B

1234567891011121314151617181920212223242526272829
  1. -- npm install -g vscode-json-languageserver
  2. require("lspconfig").jsonls.setup {
  3. cmd = {
  4. "node",
  5. DATA_PATH .. "/lspinstall/json/vscode-json/json-language-features/server/dist/node/jsonServerMain.js",
  6. "--stdio",
  7. },
  8. on_attach = require("lsp").common_on_attach,
  9. commands = {
  10. Format = {
  11. function()
  12. vim.lsp.buf.range_formatting({}, { 0, 0 }, { vim.fn.line "$", 0 })
  13. end,
  14. },
  15. },
  16. }
  17. if O.lang.json.autoformat then
  18. require("lv-utils").define_augroups {
  19. _json_format = {
  20. {
  21. "BufWritePre",
  22. "*.json",
  23. "lua vim.lsp.buf.formatting_sync(nil, 1000)",
  24. },
  25. },
  26. }
  27. end