Not for normies
feat: nvim add json ls
1 file changed, +32 -0
+32-0nvim/lsp/jsonls.lua
| @@ -0,0 +1,32 @@ | ||
| 1 | +---@brief | |
| 2 | +--- | |
| 3 | +--- https://github.com/hrsh7th/vscode-langservers-extracted | |
| 4 | +--- | |
| 5 | +--- vscode-json-language-server, a language server for JSON and JSON schema | |
| 6 | +--- | |
| 7 | +--- `vscode-json-language-server` can be installed via `npm`: | |
| 8 | +--- ```sh | |
| 9 | +--- npm i -g vscode-langservers-extracted | |
| 10 | +--- ``` | |
| 11 | +--- | |
| 12 | +--- `vscode-json-language-server` only provides completions when snippet support is enabled. If you use Neovim older than v0.10 you need to enable completion, install a snippet plugin and add the following override to your language client capabilities during setup. | |
| 13 | +--- | |
| 14 | +--- ```lua | |
| 15 | +--- --Enable (broadcasting) snippet capability for completion | |
| 16 | +--- local capabilities = vim.lsp.protocol.make_client_capabilities() | |
| 17 | +--- capabilities.textDocument.completion.completionItem.snippetSupport = true | |
| 18 | +--- | |
| 19 | +--- vim.lsp.config('jsonls', { | |
| 20 | +--- capabilities = capabilities, | |
| 21 | +--- }) | |
| 22 | +--- ``` | |
| 23 | + | |
| 24 | +---@type vim.lsp.Config | |
| 25 | +return { | |
| 26 | + cmd = { 'vscode-json-language-server', '--stdio' }, | |
| 27 | + filetypes = { 'json', 'jsonc' }, | |
| 28 | + init_options = { | |
| 29 | + provideFormatter = true, | |
| 30 | + }, | |
| 31 | + root_markers = { '.git' }, | |
| 32 | +} |