function M.get_workspace_path()
local workspaces = require 'workspaces'
local saved_workspaces = workspaces.get()
local current_workspace = workspaces.name()
if current_workspace == nil then
return
end
for _, workspace in ipairs(saved_workspaces) do
if current_workspace == workspace.name then
local path = workspace.path
if path:sub(-1, -1) == '/' then
path = path:sub(1, -2)
end
return path
end
end
end
to:
function M.get_workspace_path()
local workspaces = require 'workspaces'
local current_workspace_path = workspaces.path()
if current_workspace_path == nil then
return
end
return vim.fs.normalize(current_workspace_path)
end
I use this to force a root_dir for nvim-lspconfig, useful when go-to-definition brings you to a header file outside your project's root.
Goes from:
to:
I use this to force a
root_dir
fornvim-lspconfig
, useful when go-to-definition brings you to a header file outside your project's root.