-
Notifications
You must be signed in to change notification settings - Fork 8
Home
Gnik edited this page Dec 8, 2022
·
2 revisions
Make sure you read README.md first. I won't be repeating stuff from there unless absolutely necessary.
Make sure to enable "localoptions" in session options.
vim.opt.sessionoptions:append("localoptions")
Session.info()
is the function you are looking for.
-- Returns the path of the session file as well as project information
-- Returns nil if path is not a valid project path
-- @args spath The path to project root
-- @returns nil | path of session file and project information
function Session.info(spath) ... end
So, suppose if you want to display project name in your status line,
local project_name_display = function ()
local projections_available, Session = pcall(require, 'projections.session')
if projections_available then
local info = Session.info(vim.loop.cwd())
if info ~= nil then
-- local session_file_path = tostring(info.path)
-- local project_workspace_patterns = info.project.workspace.patterns
-- local project_workspace_path = tostring(info.project.workspace)
local project_name = info.project.name
return '☺ ' .. project_name
end
end
return vim.fs.basename(vim.loop.cwd())
end
Now, depending on your status line plugin, you can use this function. For example, with lualine.
require('lualine').setup({
sections = { lualine_c = { { project_name_display } } }
})
Can projections
ship with some of this code?
There are some major problems.
- There are a lot of statusline plugins. And I need to ship code for quite a few of them.
lualine, galaxyline, neoline, bubbly etc..
- Some plugins like
lualine
have extension code in their own repository. So, the following snippet would be present in lualine, not inprojections
- There is no way to make sure that everyone is satisfied. People might want, among various other things, the ability to show icons only, show project name, show session path, show custom icon, etc.