workspaces.nvim icon indicating copy to clipboard operation
workspaces.nvim copied to clipboard

Maintain list of project names and root paths by hand

Open snoblenet opened this issue 1 year ago • 3 comments

Would it be practical to configure workspaces.nvim to disable all :WorkspaceAdd etc type commands and to read its list of workspace names and root paths from a file that is maintained by hand?

snoblenet avatar Jul 15 '24 01:07 snoblenet

Maybe... I'm curious why you would want this?

The current workspace file is very dumb (simple) and uses null bytes to separate data

natecraddock avatar Jul 19 '24 05:07 natecraddock

Thanks.

I'm currently using Telescope's default project manager and I'm finding it's too easy to create duplicate projects and delete projects by accident when commands to do both are tied to keybindings.

And it's too tedious to then go manually looking up the key bindings to delete the accidental duplicates and reinstate the accidental deletions.

If I could just set a local project_roots = { 'root/address/1', 'root/address/2', 'etc' } in my /lua/plugins/workspace.lua, that would be brilliant.

I might (??) just define something quick in Telescope myself and use it to read the project local justfile etc.

But piggybacking on some else's great work is usually better.

snoblenet avatar Jul 19 '24 05:07 snoblenet

Hmm. Well workspaces doesn't do anything automatically. And (at least to me) having to type :WorkspacesAdd is manual enough that I don't think it would be easy to make a duplicate or delete by accident. Have you tried this plugin as-is yet?

I don't think I want to add/extend this plugin, but if you aren't satisfied with the current behavior, it wouldn't be a ton of work to remove all the commands and then make it sync the list of workspaces with a project_roots variable

natecraddock avatar Jul 19 '24 15:07 natecraddock

I've found I can achieve what I want by checking in the workspace data file as part of my dotfiles and then editing it manually when desired.

local path = os.getenv('HOME') .. '/code/dotfiles/workspaces/data'

return { 
  "natecraddock/workspaces.nvim",
  config = function()
    require('workspaces').setup({
      path = path
    })
    local workspaces_group = {
      { '<leader>w',   group = 'Workspaces' },
      { '<leader>wa', ':WorkspacesAdd<CR>', desc = 'Add' },
      { '<leader>we', (':vs<CR>:edit ' .. path .. '<CR>'), desc = 'Edit' },
      { '<leader>wr', ':WorkspacesRemove<CR>', desc = 'Remove' },
    }

    local wk = require('which-key')
    wk.add(workspaces_group)
  end
}

snoblenet avatar Aug 30 '24 21:08 snoblenet

Glad to hear you found a good solution!

natecraddock avatar Aug 30 '24 23:08 natecraddock