DEV Community

Discussion on: My Neovim setup for React, TypeScript, Tailwind CSS, etc

Collapse
 
joshuanr5 profile image
Joshua Navarro • Edited

Hi Takyuta, nice blog and video I liked it so much.

I'm new in Vim world and I don't know how to make the lspconfig and cmp show autocompletation for my eslint config (eslintrc.json), for example in vscode if I write "no-con" the IDE shows me suggestion for "no-console" but in vim I can't replicate that feature. If someone with more knowledge in this world can help me I will really appreciate.

Thanks everyone!!

Collapse
 
joshuanr5 profile image
Joshua Navarro • Edited

Resolve, that happened because lspconfig doesn't have suggestions for JSON files, you have to specify the JSON Schema for each classic JSON file like package.json eslintrc.json etc.

There is a plugin which contains almost all the JSON schemas called squemastore so you can add the next line in your plugins.lua

use "b0o/schemastore.nvim" -- json schemas to use with lspconfig
Enter fullscreen mode Exit fullscreen mode

and in your lspconfig.rc.lua add the JSON configuration

-- JSON
capabilities.textDocument.completion.completionItem.snippetSupport = true

local schemas = require 'schemastore'.json.schemas()

nvim_lsp.jsonls.setup {
  -- on_attach = on_attach,
  capabilities = capabilities,
  settings = {
    json = {
      schemas = schemas,
      validate = { enable = true }
    }
  }
}
Enter fullscreen mode Exit fullscreen mode