json.lua 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. local M = {}
  2. M.config = function()
  3. O.lang.json = {
  4. diagnostics = {
  5. virtual_text = { spacing = 0, prefix = "" },
  6. signs = true,
  7. underline = true,
  8. },
  9. formatter = {
  10. exe = "python",
  11. args = { "-m", "json.tool" },
  12. },
  13. }
  14. end
  15. M.format = function()
  16. O.formatters.filetype["json"] = {
  17. function()
  18. return {
  19. exe = O.lang.json.formatter.exe,
  20. args = O.lang.json.formatter.args,
  21. stdin = not (O.lang.json.formatter.stdin ~= nil),
  22. }
  23. end,
  24. }
  25. require("formatter.config").set_defaults {
  26. logging = false,
  27. filetype = O.formatters.filetype,
  28. }
  29. end
  30. M.lint = function()
  31. -- TODO: implement linters (if applicable)
  32. return "No linters configured!"
  33. end
  34. M.lsp = function()
  35. if require("lv-utils").check_lsp_client_active "jsonls" then
  36. return
  37. end
  38. -- npm install -g vscode-json-languageserver
  39. require("lspconfig").jsonls.setup {
  40. cmd = {
  41. "node",
  42. DATA_PATH .. "/lspinstall/json/vscode-json/json-language-features/server/dist/node/jsonServerMain.js",
  43. "--stdio",
  44. },
  45. on_attach = require("lsp").common_on_attach,
  46. commands = {
  47. Format = {
  48. function()
  49. vim.lsp.buf.range_formatting({}, { 0, 0 }, { vim.fn.line "$", 0 })
  50. end,
  51. },
  52. },
  53. }
  54. end
  55. M.dap = function()
  56. -- TODO: implement dap
  57. return "No DAP configured!"
  58. end
  59. return M