json.lua 812 B

1234567891011121314151617181920212223242526272829303132333435
  1. O.formatters.filetype["json"] = {
  2. function()
  3. return {
  4. exe = O.lang.json.formatter.exe,
  5. args = O.lang.json.formatter.args,
  6. stdin = not (O.lang.json.formatter.stdin ~= nil),
  7. }
  8. end,
  9. }
  10. require("formatter.config").set_defaults {
  11. logging = false,
  12. filetype = O.formatters.filetype,
  13. }
  14. if require("lv-utils").check_lsp_client_active "jsonls" then
  15. return
  16. end
  17. -- npm install -g vscode-json-languageserver
  18. require("lspconfig").jsonls.setup {
  19. cmd = {
  20. "node",
  21. DATA_PATH .. "/lspinstall/json/vscode-json/json-language-features/server/dist/node/jsonServerMain.js",
  22. "--stdio",
  23. },
  24. on_attach = require("lsp").common_on_attach,
  25. commands = {
  26. Format = {
  27. function()
  28. vim.lsp.buf.range_formatting({}, { 0, 0 }, { vim.fn.line "$", 0 })
  29. end,
  30. },
  31. },
  32. }