|
| 1 | +# Neovim (VB.NET LSP) Prototype Notes |
| 2 | + |
| 3 | +This document captures a minimal Neovim setup snippet for the VB.NET language server, |
| 4 | +modeled after patterns used by `roslyn.nvim`, but scoped to our VB.NET server. It is |
| 5 | +not a published plugin and exists only for reference and future work. |
| 6 | + |
| 7 | +## Goals |
| 8 | + |
| 9 | +- Mirror roslyn.nvim-style root detection (search for `.sln/.slnf/.slnx/.vbproj`). |
| 10 | +- Allow filewatching behavior toggles without changing server code. |
| 11 | +- Keep VS Code behaviors isolated and untouched. |
| 12 | + |
| 13 | +## Minimal Neovim Config (built-in LSP) |
| 14 | + |
| 15 | +```lua |
| 16 | +local function root_dir(fname) |
| 17 | + local start = vim.fs.dirname(fname) |
| 18 | + local found = vim.fs.find({ ".sln", ".slnf", ".slnx", ".vbproj" }, { |
| 19 | + path = start, |
| 20 | + upward = true, |
| 21 | + stop = vim.loop.os_homedir(), |
| 22 | + }) |
| 23 | + if #found > 0 then |
| 24 | + return vim.fs.dirname(found[1]) |
| 25 | + end |
| 26 | + return start |
| 27 | +end |
| 28 | + |
| 29 | +local function setup_vbnet(filewatching) |
| 30 | + local capabilities = vim.lsp.protocol.make_client_capabilities() |
| 31 | + |
| 32 | + if filewatching == "off" or filewatching == "server" then |
| 33 | + capabilities.workspace = capabilities.workspace or {} |
| 34 | + capabilities.workspace.didChangeWatchedFiles = { |
| 35 | + -- If "off", we strip watcher registrations on the client. |
| 36 | + dynamicRegistration = (filewatching == "off"), |
| 37 | + } |
| 38 | + end |
| 39 | + |
| 40 | + vim.lsp.start({ |
| 41 | + name = "vbnet", |
| 42 | + cmd = { |
| 43 | + "dotnet", |
| 44 | + "C:\\path\\to\\VbNet.LanguageServer.dll", |
| 45 | + "--stdio", |
| 46 | + "--logLevel", |
| 47 | + "Information", |
| 48 | + }, |
| 49 | + root_dir = root_dir(vim.api.nvim_buf_get_name(0)), |
| 50 | + capabilities = capabilities, |
| 51 | + handlers = { |
| 52 | + ["client/registerCapability"] = function(err, res, ctx) |
| 53 | + if filewatching == "off" and res and res.registrations then |
| 54 | + for _, reg in ipairs(res.registrations) do |
| 55 | + if reg.method == "workspace/didChangeWatchedFiles" then |
| 56 | + reg.registerOptions.watchers = {} |
| 57 | + end |
| 58 | + end |
| 59 | + end |
| 60 | + return vim.lsp.handlers["client/registerCapability"](err, res, ctx) |
| 61 | + end, |
| 62 | + }, |
| 63 | + }) |
| 64 | +end |
| 65 | + |
| 66 | +-- "auto" | "server" | "off" |
| 67 | +setup_vbnet("auto") |
| 68 | +``` |
| 69 | + |
| 70 | +## Notes |
| 71 | + |
| 72 | +- The VB.NET server does **not** implement Roslyn-specific `solution/open` or `project/open` |
| 73 | + notifications. Root detection relies on standard LSP workspace discovery. |
| 74 | +- Filewatching is controlled from the client side only; the server already supports |
| 75 | + `workspace/didChangeWatchedFiles`. |
| 76 | +- For headless validation, use the Neovim harness under `test-explore/clients/nvim`. |
0 commit comments