Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dirman): dynamically set default workspace #1623

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mtrajano
Copy link
Contributor

@mtrajano mtrajano commented Dec 23, 2024

Ability to dynamically set the default workspace based on the cwd.

This gives you the ability to open different workspaces based on context for example:

config = {
  workspaces = {
    dev = '~/notes/dev',
    personal = '~/notes/personal',
  },
  default_workspace = function()
    local git_root = vim.fs.root(0, '.git')
    local basename = vim.fs.basename(git_root)

    if basename == 'dotfiles' then
      return 'dev'
    end

    return 'personal'
  end,
},

@benlubas
Copy link
Contributor

I like this addition. Can you document the type of cwd. Bc users would probably assume it's a string.

Honestly it's not necessary to pass the cwd at all. People can get it from neovim themselves. But idc either way

@mtrajano
Copy link
Contributor Author

@benlubas That's a great point, that way the user isn't tied to the more internal Path object and can resolve it however he/she wants. I updated the pr and the example comment of how this would look like using the nvim internal fs api. Let me know if you think this comment should be removed as well since the cwd isn't passed anymore may be set dynamically based on cwd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants