From 9fb1a834d6a435fc87875087900f8d4d561e2bcf Mon Sep 17 00:00:00 2001 From: Rob Watson Date: Fri, 8 Oct 2021 14:30:42 +0200 Subject: [PATCH] nvimrc: add basic tsserver setup --- nvimrc | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/nvimrc b/nvimrc index 6fdb9cd..a7ce53b 100644 --- a/nvimrc +++ b/nvimrc @@ -632,6 +632,46 @@ nvim_lsp.solargraph.setup{ on_attach = on_attach, } +-- Typescript +-- https://jose-elias-alvarez.medium.com/configuring-neovims-lsp-client-for-typescript-development-5789d58ea9c + +nvim_lsp.tsserver.setup{ + on_attach = on_attach, +} + +local filetypes = { + typescript = "eslint", + typescriptreact = "eslint", +} +local linters = { + eslint = { + sourceName = "eslint", + command = "eslint", + rootPatterns = {".eslintrc.js", "package.json"}, + debounce = 100, + args = {"--stdin", "--stdin-filename", "%filepath", "--format", "json"}, + parseJson = { + errorsRoot = "[0].messages", + line = "line", + column = "column", + endLine = "endLine", + endColumn = "endColumn", + message = "${message} [${ruleId}]", + security = "severity" + }, + securities = {[1] = "error", [2] = "warning"} + } +} + +nvim_lsp.diagnosticls.setup{ + on_attach = on_attach, + filetypes = vim.tbl_keys(filetypes), + init_options = { + linters = linters, + filetypes = filetypes, + } +} + -- Lua local system_name