json.lua 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. stdin = true,
  13. },
  14. }
  15. end
  16. M.format = function()
  17. O.formatters.filetype["json"] = {
  18. function()
  19. return {
  20. exe = O.lang.json.formatter.exe,
  21. args = O.lang.json.formatter.args,
  22. stdin = O.lang.json.formatter.stdin,
  23. }
  24. end,
  25. }
  26. require("formatter.config").set_defaults {
  27. logging = false,
  28. filetype = O.formatters.filetype,
  29. }
  30. end
  31. M.lint = function()
  32. -- TODO: implement linters (if applicable)
  33. return "No linters configured!"
  34. end
  35. M.lsp = function()
  36. if require("lv-utils").check_lsp_client_active "jsonls" then
  37. return
  38. end
  39. -- npm install -g vscode-json-languageserver
  40. require("lspconfig").jsonls.setup {
  41. cmd = {
  42. "node",
  43. DATA_PATH .. "/lspinstall/json/vscode-json/json-language-features/server/dist/node/jsonServerMain.js",
  44. "--stdio",
  45. },
  46. on_attach = require("lsp").common_on_attach,
  47. commands = {
  48. Format = {
  49. function()
  50. vim.lsp.buf.range_formatting({}, { 0, 0 }, { vim.fn.line "$", 0 })
  51. end,
  52. },
  53. },
  54. }
  55. end
  56. M.dap = function()
  57. -- TODO: implement dap
  58. return "No DAP configured!"
  59. end
  60. return M