Skip to content

Commit

Permalink
fix(omnisharp): omnisharp does not start when local dotnet is availab…
Browse files Browse the repository at this point in the history
…le for some reason, here we launch dll directly
  • Loading branch information
konradmalik committed Nov 2, 2023
1 parent 8c232cd commit e4a7e6d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
7 changes: 4 additions & 3 deletions config/native/lua/konrad/fs.lua
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
local M = {}

---Get PATH executable, returns nil if not found
---@param binary string
---@return string | nil
local path_executable = function(binary)
M.path_executable = function(binary)
local exe = vim.fn.exepath(binary)
if exe == "" then
return nil
end
return exe
end

local M = {}
---Returns a full path to exec from PATH if found,
---if not found, then returns the provided one
---@param binname any
---@param fullpath any
---@return string
M.from_path_or_default = function(binname, fullpath)
return path_executable(binname) or fullpath
return M.path_executable(binname) or fullpath
end

return M
11 changes: 10 additions & 1 deletion config/native/lua/konrad/lsp/configs/omnisharp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,22 @@
-- https://github.com/Hoffs/omnisharp-extended-lsp.nvim
vim.cmd("packadd omnisharp-extended-lsp.nvim")

local fs = require("konrad.fs")
local binaries = require("konrad.binaries")
local configs = require("konrad.lsp.configs")

local M = {}

local make_cmd = function()
local cmd = { binaries.omnisharp() }
local cmd
-- something's broken with omnisharp script in nix when dotnet is in path...
local local_dotnet = fs.path_executable("dotnet")
if local_dotnet then
cmd = { local_dotnet, binaries.omnisharp_dll() }
else
cmd = { binaries.omnisharp() }
end

-- Append hard-coded command arguments
table.insert(cmd, "-z") -- https://github.com/OmniSharp/omnisharp-vscode/pull/4300
vim.list_extend(cmd, { "--hostPID", tostring(vim.fn.getpid()) })
Expand Down
1 change: 1 addition & 0 deletions config/nix/lua/konrad/binaries.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pkgs.writeTextDir "lua/konrad/binaries.lua" ''
lua_ls = function() return "${pkgs.sumneko-lua-language-server}/bin/lua-language-server" end,
nil_ls = function() return "${pkgs.nil}/bin/nil" end,
omnisharp = function() return "${pkgs.omnisharp-roslyn}/bin/OmniSharp" end,
omnisharp_dll = function() return "${pkgs.omnisharp-roslyn}/lib/omnisharp-roslyn/OmniSharp.dll" end,
pyright = function() return "${pkgs.nodePackages.pyright}/bin/pyright" end,
rust_analyzer = function() return "${pkgs.rust-analyzer}/bin/rust-analyzer" end,
terraformls = function() return "${pkgs.terraform-ls}/bin/terraform-ls" end,
Expand Down

0 comments on commit e4a7e6d

Please sign in to comment.