mattn / vim-lsp-settings

Auto configurations for Language Server for vim-lsp
MIT License
1.3k stars 232 forks source link

runtimepath order causes to suggest to install plugin that has already installed #489

Open 0xBADDCAFE opened 2 years ago

0xBADDCAFE commented 2 years ago

My pack path has plugins vim-lsp-settings and vim-ps1. Vim load vim-lsp-settings first and next load vim-ps1. So autocmd order should be there:

--- Autocommands ---
...
vim_lsp_suggest  BufRead
    *         call s:vim_lsp_suggest_plugin()
filetypedetect  BufRead
    *.ps1     set ft=ps1
    *.psd1    set ft=ps1
    *.psm1    set ft=ps1
    *.pssc    set ft=ps1
    *.ps1xml  set ft=ps1xml
    *.cdxml   set ft=xml
    *.psc1    set ft=xml
...

This causes that s:vim_lsp_suggest_plugin() is called before set ft=ps1.

Renaming vim-lsp-setting to z-vim-lsp-setting to change order disappears the suggest message.

4513ECHO commented 2 years ago

@0xBADDCAFE I think, it fix this problem to register autocmd FIieType for vim_lsp_suggest.

4513ECHO commented 2 years ago

Sorry, vim_lsp_suggest_ps1 augroup has already defined and registered autocmd FIieType. Why did you happen this problem?

0xBADDCAFE commented 2 years ago

本文に英語で記載した内容ですが、私は英語が苦手なので日本語で詳細に記載してみます。

Vim 本体の package 機能でプラグインを管理している場合、 'packpath' 内ディレクトリのプラグインは恐らくディレクトリの alphabet 順に登録されるはずです。その際に vim-lsp-settings よりあとになる filetype plugin(この場合は vim-ps1)があると、autocmd の登録順も vim-lsp-settings よりあとになります(本文のコードブロック参照)。 すると LSP が実行されて欲しいファイルを開いた際に、autocmd 順に従って filetype 設定より先に s:vim_lsp_suggest_plugin() が実行され、LSP Plugin の前提となるであろう filetype plugin のインストール有無に関わらずインストールするように suggest message が出ます。 vim-lsp-settings のディレクトリ名を z-vim-lsp-settings と変更し、package 機能による runtimepath 登録順を変更するとメッセージが表示されなくなりました。

なおここでは package 機能を利用しているため alphabet 順に依存していますが、実際のところは runtimepath に登録された順に依存すると考えたのでこのようなタイトルとしてあります。

4513ECHO commented 2 years ago

なるほど、理解しました。vim-lsp-settings側がインストールしてくださいと指示しているのはLSPではなくpluginなんですね。で、s:vim_lsp_suggest_plugin()は冒頭で&filetypeが空でなければ終了しています。s:vim_lsp_suggest_plugin()の実行をfiletypedetectaugroupの終了まで明確に待てば解決する気がします。