Skip to content

Commit

Permalink
feat: add enable and debug to lsp config
Browse files Browse the repository at this point in the history
This commit adds the following options to the lsp module:
- `enable` allows enabling or disabling the LSP module altogether
- `debug` launches omnisharp in debug mode to allow attaching debugger to the LSP server
  • Loading branch information
iabdelkareem committed Feb 14, 2024
1 parent e3e140b commit 026e316
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lua/csharp/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ local M = {}
local default_config = {
---@class CsharpConfig.Lsp
lsp = {
enable = true,
--- @type string?
cmd_path = "",
enable_editor_config_support = true,
Expand All @@ -15,6 +16,7 @@ local default_config = {
analyze_open_documents_only = false,
default_timeout = 1000,
enable_package_auto_restore = true,
debug = false,
},
---@class CsharpConfig.Logging
logging = {
Expand Down
8 changes: 8 additions & 0 deletions lua/csharp/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ local function start_omnisharp(args)
"MsBuild:EnablePackageAutoRestore=" .. tostring(config.enable_package_auto_restore),
}

if config.debug then
table.insert(cmd, 2, "-d")
end

vim.lsp.start({
name = "omnisharp",
cmd = cmd,
Expand All @@ -72,6 +76,10 @@ local function start_omnisharp(args)
end

function M.setup()
if not config_store.get_config().lsp.enable then
return
end

local lsp_group = vim.api.nvim_create_augroup("CsharpNvim", { clear = false })

vim.api.nvim_create_autocmd("FileType", {
Expand Down

0 comments on commit 026e316

Please sign in to comment.