diff --git a/lua/doom/modules/langs/typescript/init.lua b/lua/doom/modules/langs/typescript/init.lua index b3940b4..9fb111e 100644 --- a/lua/doom/modules/langs/typescript/init.lua +++ b/lua/doom/modules/langs/typescript/init.lua @@ -1,3 +1,5 @@ +local utils = require('doom.utils'); + local typescript = {} typescript.settings = { @@ -7,7 +9,8 @@ typescript.autocmds = { { "FileType", "typescript,typescriptreact", - function() + utils.make_run_once_function(function() + print('Configuring typescript') local langs_utils = require('doom.modules.langs.utils') langs_utils.use_lsp('tsserver') @@ -26,7 +29,7 @@ typescript.autocmds = { null_ls.builtins.diagnostics.eslint_d, }) end - end, + end), once = true, }, } diff --git a/lua/doom/utils/init.lua b/lua/doom/utils/init.lua index d3b3bab..b8a7052 100644 --- a/lua/doom/utils/init.lua +++ b/lua/doom/utils/init.lua @@ -224,6 +224,19 @@ utils.is_module_enabled = function(plugin) return false end +--- Returns a function that can only be run once +---@param fn function +---@return function +utils.make_run_once_function = function(fn) + local has_run = false + return function(...) + if not has_run then + fn(...) + has_run = true + end + end +end + --- Rounds a number, optionally to the nearest decimal place --- @param num number - Value to round --- @param decimalplace number|nil - Number of decimal places