diff --git a/autoload/tsdetect.vim b/autoload/tsdetect.vim index 22c6133..80ba4b9 100644 --- a/autoload/tsdetect.vim +++ b/autoload/tsdetect.vim @@ -1,26 +1,17 @@ -function! tsdetect#init(once) abort - function! s:detect_filetype() abort closure +function! tsdetect#init() abort + function! s:detect_filetype() abort let b:tsdetect_is_node = tsdetect#util#is_node() - if a:once - autocmd! tsdetect#init - endif doautocmd User tsdetect#detect endfunction - function! s:detect_buffer(amatch) abort closure + function! s:detect_buffer(amatch) abort if a:amatch =~? '^deno:/\|\.tsx\?\|\.js$' let b:tsdetect_is_node = tsdetect#util#is_node() - if a:once - autocmd! tsdetect#init - endif doautocmd User tsdetect#detect else let l:is_node_shebang = tsdetect#util#is_node_shebang() if l:is_node_shebang != v:null let b:tsdetect_is_node = l:is_node_shebang - if a:once - autocmd! tsdetect#init - endif doautocmd User tsdetect#detect endif endif diff --git a/src/entrypoints/coc.ts b/src/entrypoints/coc.ts index 5be8e50..6121bc6 100644 --- a/src/entrypoints/coc.ts +++ b/src/entrypoints/coc.ts @@ -12,20 +12,12 @@ const initialize = async (_context: ExtensionContext) => { settings.mode, settings.configType, ]); + proms.push(setup.then(() => workspace.nvim.call("tsdetect#init"))); if (settings.mode === "auto") { proms.push( workspace.nvim.call(`tsdetect#coc#auto#switch_${settings.configType}`), ); - proms.push( - setup.then(() => - workspace.nvim.call("tsdetect#init", [ - settings.configType === "ephemeral", - ]), - ), - ); - } else { - proms.push(setup); } await Promise.all(proms);