aboutsummaryrefslogtreecommitdiffstats
path: root/lua/lspconfig/jsonls.lua
blob: 20c2753beea89e5a431fb9c9998c6fcadbfbe998 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
local configs = require "lspconfig/configs"
local util = require "lspconfig/util"

local server_name = "jsonls"
local bin_name = "vscode-json-language-server"

configs[server_name] = {
  default_config = {
    cmd = { bin_name, "--stdio" },
    filetypes = { "json" },
    init_options = {
      provideFormatter = true,
    },
    root_dir = util.root_pattern(".git", vim.fn.getcwd()),
  },
  docs = {
    -- this language server config is in VSCode built-in package.json
    package_json = "https://raw.githubusercontent.com/microsoft/vscode/master/extensions/json-language-features/package.json",
    description = [[
https://github.com/hrsh7th/vscode-langservers-extracted

vscode-json-language-server, a language server for JSON and JSON schema

`vscode-json-language-server` can be installed via `npm`:
```sh
npm i -g vscode-langservers-extracted
```

vscode-json-language-server only provides range formatting. You can map a command that applies range formatting to the entire document:

```lua
require'lspconfig'.jsonls.setup {
    commands = {
      Format = {
        function()
          vim.lsp.buf.range_formatting({},{0,0},{vim.fn.line("$"),0})
        end
      }
    }
}
```
]],
    default_config = {
      root_dir = [[root_pattern(".git", vim.fn.getcwd())]],
    },
  },
}

-- vim:et ts=2 sw=2