diff options
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/lspconfig/jsonls.lua | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lua/lspconfig/jsonls.lua b/lua/lspconfig/jsonls.lua index 9db3cb7b..3db6b83d 100644 --- a/lua/lspconfig/jsonls.lua +++ b/lua/lspconfig/jsonls.lua @@ -8,6 +8,9 @@ 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 = { @@ -22,6 +25,20 @@ vscode-json-languageserver, a language server for JSON and JSON schema ```sh npm install -g vscode-json-languageserver ``` + +vscode-json-languageserver 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())]]; |
