From 9ae483043ef75de16478c1130d608243d3b94abc Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Thu, 24 Mar 2022 09:17:36 +1100 Subject: [PATCH] fix(langs,javascript,typescript): tsserver crashing when switching between js/ts file. --- lua/doom/modules/langs/javascript/init.lua | 33 ++-------------------- lua/doom/modules/langs/typescript/init.lua | 4 +-- 2 files changed, 5 insertions(+), 32 deletions(-) diff --git a/lua/doom/modules/langs/javascript/init.lua b/lua/doom/modules/langs/javascript/init.lua index dab6c48..a9aa4ba 100644 --- a/lua/doom/modules/langs/javascript/init.lua +++ b/lua/doom/modules/langs/javascript/init.lua @@ -1,30 +1,3 @@ -local javascript = {} - -javascript.settings = {} - -javascript.autocmds = { - { - "FileType", - "javascript,javascriptreact", - function() - local langs_utils = require('doom.modules.langs.utils') - langs_utils.use_lsp('tsserver') - - require("nvim-treesitter.install").ensure_installed("javascript,javascriptreact") - - -- Setup null-ls - if doom.modules.linter then - local null_ls = require("null-ls") - - langs_utils.use_null_ls_source({ - null_ls.builtins.formatting.eslint_d, - null_ls.builtins.code_actions.eslint_d, - null_ls.builtins.diagnostics.eslint_d, - }) - end - end, - once = true, - }, -} - -return javascript +-- Because javascript and typescript use the same tooling, +-- this module is just an alias for the typescript module. +return require('doom.modules.langs.typescript') diff --git a/lua/doom/modules/langs/typescript/init.lua b/lua/doom/modules/langs/typescript/init.lua index 9fb111e..9873da5 100644 --- a/lua/doom/modules/langs/typescript/init.lua +++ b/lua/doom/modules/langs/typescript/init.lua @@ -8,7 +8,7 @@ typescript.settings = { typescript.autocmds = { { "FileType", - "typescript,typescriptreact", + "typescript,typescriptreact,javascript,javascriptreact", utils.make_run_once_function(function() print('Configuring typescript') local langs_utils = require('doom.modules.langs.utils') @@ -16,7 +16,7 @@ typescript.autocmds = { vim.defer_fn(function() local ts_install = require("nvim-treesitter.install") - ts_install.ensure_installed("typescript") + ts_install.ensure_installed("typescript", "javascript") end, 0) -- Setup null-ls