json.lua 718 B

12345678910111213141516171819202122232425262728
  1. -- npm install -g vscode-json-languageserver
  2. require'lspconfig'.jsonls.setup {
  3. cmd = {
  4. "node", DATA_PATH ..
  5. "/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', '*.json',
  22. 'lua vim.lsp.buf.formatting_sync(nil, 1000)'
  23. }
  24. }
  25. })
  26. end