From e14aa9ef5a4d19eb0dfb2733d16aa800326de665 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 16 May 2019 22:58:08 -0400 Subject: [PATCH 1/2] Move plugin to ftdetect,ftplugin Optimize startup by delaying filetype-dependent code until the user opens a powershell file. --- ftdetect/ps1.vim | 1 + plugin/coc-powershell.vim => ftplugin/ps1.vim | 8 +------- 2 files changed, 2 insertions(+), 7 deletions(-) create mode 100644 ftdetect/ps1.vim rename plugin/coc-powershell.vim => ftplugin/ps1.vim (88%) diff --git a/ftdetect/ps1.vim b/ftdetect/ps1.vim new file mode 100644 index 0000000..0a965d3 --- /dev/null +++ b/ftdetect/ps1.vim @@ -0,0 +1 @@ +autocmd BufNewFile,BufRead *.ps*1 setfiletype ps1 diff --git a/plugin/coc-powershell.vim b/ftplugin/ps1.vim similarity index 88% rename from plugin/coc-powershell.vim rename to ftplugin/ps1.vim index 6aca473..3da63c0 100644 --- a/plugin/coc-powershell.vim +++ b/ftplugin/ps1.vim @@ -42,10 +42,4 @@ function! s:PSESSetup () \) endfunction -" Set the file type to ps1 for ps1, psm1, and psd1 -" 'ps1' is what vim-polyglot uses for styling -if(&filetype == "") - autocmd BufNewFile,BufRead *.ps*1 set filetype=ps1 -endif - -autocmd FileType ps1,psd1,psm1 call s:PSESSetup() +call s:PSESSetup() From 634b85e7d9dbbba9861e51f47f0f811d2c2e880b Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 24 May 2019 01:26:52 -0400 Subject: [PATCH 2/2] Add ftplugin guard to setup once only --- ftplugin/ps1.vim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ftplugin/ps1.vim b/ftplugin/ps1.vim index 3da63c0..53a384f 100644 --- a/ftplugin/ps1.vim +++ b/ftplugin/ps1.vim @@ -1,3 +1,7 @@ +if exists('s:loaded_ftplugin') + finish +endif +let s:loaded_ftplugin = 1 let s:vimscript_dir = expand(':p:h') function! s:PSESSetup () let g:pses_dir = resolve(expand(s:vimscript_dir . '/../PowerShellEditorServices/PowerShellEditorServices'))