From 495a7f16f6eb1d3e9b2b976c77b51ab9f970046d Mon Sep 17 00:00:00 2001 From: Rui Chen <77432836+sharpchen@users.noreply.github.com> Date: Tue, 17 Dec 2024 07:22:18 +0000 Subject: [PATCH] feat(msbuild): config instruction for filetypes (#3516) --- .../configs/msbuild_project_tools_server.lua | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/lua/lspconfig/configs/msbuild_project_tools_server.lua b/lua/lspconfig/configs/msbuild_project_tools_server.lua index f9abba3e1d..4c4cbf796f 100644 --- a/lua/lspconfig/configs/msbuild_project_tools_server.lua +++ b/lua/lspconfig/configs/msbuild_project_tools_server.lua @@ -2,7 +2,7 @@ local host_dll_name = 'MSBuildProjectTools.LanguageServer.Host.dll' return { default_config = { - filetypes = { 'xml.csproj', 'xml.fsproj', 'sln' }, + filetypes = { 'msbuild' }, root_dir = function(fname) return vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1]) end, @@ -10,7 +10,7 @@ return { cmd = { 'dotnet', host_dll_name }, }, docs = { - description = [[ + description = [=[ https://github.com/tintoy/msbuild-project-tools-server/ MSBuild Project Tools Server can be installed by following the README.MD on the above repository. @@ -22,6 +22,26 @@ lspconfig.msbuild_project_tools_server.setup { } ``` -]], +There's no builtin filetypes for msbuild files, would require some filetype aliases: + +```lua +vim.filetype.add({ + extension = { + props = 'msbuild', + tasks = 'msbuild', + targets = 'msbuild', + }, + pattern = { + [ [[.*\..*proj]] ] = 'msbuild', + }, +}) +``` + +Optionally tell treesitter to treat `msbuild` as `xml` so you can get syntax highlighting if you have the treesitter-xml-parser installed. + +```lua +vim.treesitter.language.register('xml', { 'msbuild' }) +``` +]=], }, }