Skip to content

Commit

Permalink
Fix: Paths and lsp deprecations
Browse files Browse the repository at this point in the history
Fix for windows shellslash not working on linux
Fix for deprecated get_active_clients lsp function
  • Loading branch information
ghaspire committed Jun 14, 2024
1 parent 413b353 commit cba9ccf
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions lua/ionide/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ M.getIonideClientAttachedToCurrentBufferOrFirstInActiveClients = function()
local bufnr = vim.api.nvim_get_current_buf()
-- local bufname = vim.fs.normalize(vim.api.nvim_buf_get_name(bufnr))
-- local projectRoot = vim.fs.normalize(M.GitFirstRootDir(bufname))
local ionideClientsList = vim.lsp.get_active_clients({ name = "ionide" })
local ionideClientsList = vim.lsp.get_clients({ name = "ionide" })
if ionideClientsList then
if #ionideClientsList > 1 then
for _, client in ipairs(ionideClientsList) do
Expand Down Expand Up @@ -1096,16 +1096,22 @@ end
---@param path string
---@return lsp.TextDocumentIdentifier
function M.TextDocumentIdentifier(path)
local usr_ss_opt = vim.o.shellslash
vim.o.shellslash = true
local is_windows = vim.loop.os_uname().version:match("Windows")
local usr_ss_opt
if is_windows then
usr_ss_opt = vim.o.shellslash
vim.o.shellslash = true
end
local uri = vim.fn.fnamemodify(path, ":p")
if string.sub(uri, 1, 1) == "/" then
uri = "file://" .. uri
else
uri = "file:///" .. uri
end
vim.o.shellslash = usr_ss_opt

if is_windows then
vim.o.shellslash = usr_ss_opt
end
---
---@type lsp.TextDocumentIdentifier
return { Uri = uri }
end
Expand Down Expand Up @@ -1530,11 +1536,11 @@ function M.Initialize()
M.RegisterAutocmds()
local thisBufnr = vim.api.nvim_get_current_buf()
local thisBufname = vim.api.nvim_buf_get_name(thisBufnr)
---@type lsp.Client
local thisIonide = vim.lsp.get_active_clients({ bufnr = thisBufnr, name = "ionide" })[1]
or { workspace_folders = { { vim.fn.getcwd() } } }
---@type vim.lsp.Client
local thisIonide = vim.lsp.get_clients({ bufnr = thisBufnr, name = "ionide" })[1]
or { workspace_folders = { { name = vim.fn.getcwd() } } }

local thisBufIonideRootDir = thisIonide.workspace_folders[1][1] -- or vim.fn.getcwd()
local thisBufIonideRootDir = thisIonide.workspace_folders[1].name -- or vim.fn.getcwd()
M.CallFSharpWorkspacePeek(
thisBufIonideRootDir,
M.MergedConfig.settings.FSharp.workspaceModePeekDeepLevel,
Expand Down Expand Up @@ -1666,7 +1672,7 @@ autocmd({ "BufReadPost" }, {
-- M.notify("closest fs file is " .. closestFsFile )
---@type integer
local closestFileBufNumber = vim.fn.bufadd(closestFsFile)
local ionideClientsList = vim.lsp.get_active_clients({ name = "ionide" })
local ionideClientsList = vim.lsp.get_clients({ name = "ionide" })
local isAleadyStarted = false
if ionideClientsList then
for _, client in ipairs(ionideClientsList) do
Expand Down

0 comments on commit cba9ccf

Please sign in to comment.