Skip to content

Commit

Permalink
fix: remove init once mode for users who use b:tsdetect_is_node
Browse files Browse the repository at this point in the history
  • Loading branch information
LumaKernel committed Feb 20, 2021
1 parent 15b1da6 commit 34cf1bc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 21 deletions.
15 changes: 3 additions & 12 deletions autoload/tsdetect.vim
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 1 addition & 9 deletions src/entrypoints/coc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 34cf1bc

Please sign in to comment.