From 195fa719ca4e6b41e183135c55a348c265ec7dea Mon Sep 17 00:00:00 2001 From: Shinya Ohyanagi Date: Mon, 27 May 2024 13:34:28 +0000 Subject: [PATCH] Add globalPlugins for vue --- settings/vtsls.vim | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/settings/vtsls.vim b/settings/vtsls.vim index 6fee0703..9e7dd2a5 100644 --- a/settings/vtsls.vim +++ b/settings/vtsls.vim @@ -8,6 +8,30 @@ function! Vim_lsp_settings_vtsls_get_blocklist() abort return [] endfunction +function! s:find_vue_plugin() abort + let plugin_location = lsp_settings#servers_dir() .. '/volar-server/node_modules/@vue/typescript-plugin' + if !isdirectory(plugin_location) + return v:null + endif + + return { + \ 'name': '@vue/typescript-plugin', + \ 'location': plugin_location, + \ 'languages': ['vue'], + \ } +endfunction + +function! Vim_lsp_settings_vtsls_setup_plugins() abort + let plugins = [] + + let vue_plugin = s:find_vue_plugin() + if !empty(vue_plugin) + call add(plugins, vue_plugin) + endif + + return plugins +endfunction + augroup vim_lsp_settings_vtsls au! LspRegisterServer { @@ -63,6 +87,11 @@ augroup vim_lsp_settings_vtsls \ }, \ }, \ }, + \ 'vtsls': { + \ 'tsserver': { + \ 'globalPlugins': Vim_lsp_settings_vtsls_setup_plugins(), + \ }, + \ }, \ }), \ 'semantic_highlight': lsp_settings#get('vtsls', 'semantic_highlight', {}), \ }