0

I'm using Neovim with the nvim-lspconfig plugin and for some projects, it would be great to have the TypeScript suggestions for JSON files such as TSConfig, but even though I'm not working with them things such as Angular JSON configuration or Package JSON would be great to have in the diagnostic.

How can I do that using jsonls with neovim and the nvim-lspconfig plugin?

The goal would be to mimic what VSCode does when you edit a tsconfig.json file and get suggestions as you type.

1 Answer 1

0

if you use nvim-cmp to do your completion, configure both the json and jsonc filetypes to use nvim-lsp as a completion source:

      local JSON_CONFIG = {
        sources = cmp.config.sources({
          { name = 'nvim_lsp' },
          { name = 'luasnip', option = { show_autosnippets = true } },
          { name = 'npm', keyword_length = 2 },
        }, {
          { name = 'buffer' },
        }, {
          { name = 'calc' },
          { name = 'emoji' },
        })
      }

      cmp.setup.filetype('json', JSON_CONFIG)
      cmp.setup.filetype('jsonc', JSON_CONFIG)

screenshot of neovim with autocomplete from nvim_lsp provider for tsconfig.json

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.