diff options
author | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2021-07-07 14:27:30 +0200 |
---|---|---|
committer | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2021-07-07 14:27:30 +0200 |
commit | 740e27ec856cc688f0ecf0ffe2b55b26ce771407 (patch) | |
tree | 832cd7227c0ab839baf8f004958fdddeb975422e /.config/nvim/ftplugin/javascriptreact.lua | |
parent | 409dfed3237f9f0a6e96879078d1daf3d9c02e03 (diff) |
Add language support for linting and diagnostics
Diffstat (limited to '.config/nvim/ftplugin/javascriptreact.lua')
-rw-r--r-- | .config/nvim/ftplugin/javascriptreact.lua | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/.config/nvim/ftplugin/javascriptreact.lua b/.config/nvim/ftplugin/javascriptreact.lua new file mode 100644 index 0000000..ab37036 --- /dev/null +++ b/.config/nvim/ftplugin/javascriptreact.lua @@ -0,0 +1,38 @@ +-- npm install -g typescript typescript-language-server +-- require'snippets'.use_suggested_mappings() +-- local capabilities = vim.lsp.protocol.make_client_capabilities() +-- capabilities.textDocument.completion.completionItem.snippetSupport = true; +-- local on_attach_common = function(client) +-- print("LSP Initialized") +-- require'completion'.on_attach(client) +-- require'illuminate'.on_attach(client) +-- end +require("lspconfig").tsserver.setup { + cmd = { + DATA_PATH .. "/lspinstall/typescript/node_modules/.bin/typescript-language-server", + "--stdio", + }, + filetypes = { + "javascript", + "javascriptreact", + "javascript.jsx", + "typescript", + "typescriptreact", + "typescript.tsx", + }, + on_attach = require("lsp").tsserver_on_attach, + -- This makes sure tsserver is not used for formatting (I prefer prettier) + -- on_attach = require'lsp'.common_on_attach, + root_dir = require("lspconfig/util").root_pattern("package.json", "tsconfig.json", "jsconfig.json", ".git"), + settings = { documentFormatting = false }, + handlers = { + ["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { + virtual_text = O.lang.tsserver.diagnostics.virtual_text, + signs = O.lang.tsserver.diagnostics.signs, + underline = O.lang.tsserver.diagnostics.underline, + update_in_insert = true, + }), + }, +} +require("lsp.ts-fmt-lint").setup() +vim.cmd "setl ts=2 sw=2" |