Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export NVIM_RUNNER_VERSION := v0.10.3
export NVIM_TEST_VERSION ?= v0.10.3
export NVIM_RUNNER_VERSION := v0.10.4
export NVIM_TEST_VERSION ?= v0.10.4

nvim-test:
git clone https://github.com/lewis6991/nvim-test
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ opts = {
## 📚 Commands

- `:Roslyn restart` restarts the server
- `:Roslyn start` starts the server
- `:Roslyn stop` stops the server
- `:Roslyn target` chooses a solution if there are multiple to chose from

Expand Down
34 changes: 34 additions & 0 deletions lua/roslyn/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,35 @@ local M = {}

local cmd_name = "Roslyn"

local function start_lsp(bufnr, sln_file)
local roslyn_lsp = require("roslyn.lsp")
if not sln_file then
return
end

local clients = vim.lsp.get_clients({ name = "roslyn" })
if #clients > 0 then
vim.notify("\n" .. cmd_name .. " server already running", vim.log.levels.WARNING, { title = "roslyn.nvim" })
return
end

local sln_dir = vim.fs.dirname(sln_file)
roslyn_lsp.start(bufnr, assert(sln_dir), roslyn_lsp.on_init_sln(sln_file))
end

local function select_sln_and_start_lsp()
local bufnr = vim.api.nvim_get_current_buf()
local root = vim.b.roslyn_root or require("roslyn.sln.utils").root(bufnr)
local targets = vim.iter({ root.solutions, root.solution_filters }):flatten():totable()
if #targets == 1 then
start_lsp(bufnr, targets[1])
return
end
vim.ui.select(targets or {}, { prompt = "Select target solution: " }, function(file)
start_lsp(bufnr, file)
end)
end

---@class RoslynSubcommandTable
---@field impl fun(args: string[], opts: vim.api.keyset.user_command) The command implementation
---@field complete? fun(subcmd_arg_lead: string): string[] Command completions callback, taking the lead of the subcommand's arguments
Expand Down Expand Up @@ -71,6 +100,11 @@ local subcommand_tbl = {
end)
end,
},
start = {
impl = function()
select_sln_and_start_lsp()
end,
},
}

---@param opts table
Expand Down
Loading