Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions lsp/vb_ls.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---@brief
---
--- https://github.com/CoolCoderSuper/visualbasic-language-server
---
--- Language Server for VB.NET.
---
--- vb-ls requires the [dotnet-sdk](https://dotnet.microsoft.com/download) to be installed.
---
--- The preferred way to install vb-ls is with `dotnet tool install --global vb-ls`.
--- Additionally you need to register the .vb extension with the vbnet filetype.
--- A plugin that does this as well as improved syntax highlighting is [vbnet.nvim](https://github.com/CoolCoderSuper/vbnet.nvim).

local util = require 'lspconfig.util'

return {
cmd = { 'vb-ls' },
root_dir = function(bufnr, on_dir)
local fname = vim.api.nvim_buf_get_name(bufnr)
on_dir(util.root_pattern '*.sln'(fname) or util.root_pattern '*.vbproj'(fname) or util.root_pattern '*.slnx'(fname))
end,
filetypes = { 'vbnet' },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is the "vbnet" filetype coming from, a thirdparty plugin I assume (should mention and link to it in the doc)? The filetype shipped w/ vim is "vb": https://github.com/neovim/neovim/blob/5cf135f9a0ac472621d133bb4a03780a7bff6640/runtime/lua/vim/filetype/detect.lua#L107

Copy link
Contributor Author

@CoolCoderSuper CoolCoderSuper Jun 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that was one of my questions.
The reason for it is that the built in vb targetting VB6 and vb.net do differ in some areas but I can switch it to vb.
The patched version I have been using is here.
https://github.com/CoolCoderSuper/visualbasic-language-server/blob/main/vim-config/syntax/vbnet.vim

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this config will work for exactly 1 person currently? :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use :h vim.filetype.add to create filetype vbnet based on the presence of vbproj, and clarify these setup on docs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sharpchen thanks for the guidance. I will look into that and update the docs.

Copy link
Contributor

@sharpchen sharpchen Jun 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And for the syntax for vbnet you should wrap it as a vim plugin so others can install it, should look like https://github.com/vim-scripts/vbnet.vim, not related to ls config but it's worth noting.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@justinmk I understand, just to mention the workaround to manage external filetype for language server if needed, it should be added to user config, not related to lspconfig, thanks for clarification :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you both for your feedback.
I created this plugin https://github.com/CoolCoderSuper/vbnet.nvim and added a reference to it in the doc.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CoolCoderSuper I was expecting https://github.com/CoolCoderSuper/vbnet.nvim to be a pure syntax plugin, it seems you're enforcing user to override vb to vbnet, I do think we should leave it to user to decide whether to override or not if distinction between vb6 and vb.net does matter, as you mentioned earlier. something like this:

vim.filetype.add {
  extension = {
    vb = function(path, _)
      if vim.fs.root(path, function(name, _) return name:match('%.vbproj$') end) then
        return 'vbnet'
      else
        return 'vb'
      end
    end,
  },
}

With snippet above, all buffer with extension vb would be of filetype vbnet when it find a vbproj upward, otherwise it would be just vb

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sharpchen OK, that makes sense. I have updated it to use that approach.

init_options = {
AutomaticWorkspaceInit = true,
},
}