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

Opt out of saving in Project Root Markers #246

Open
lemeb opened this issue Nov 17, 2019 · 1 comment
Open

Opt out of saving in Project Root Markers #246

lemeb opened this issue Nov 17, 2019 · 1 comment
Labels
enhancement: feature dev new requests, or significant changes to existing ones priority: 3 - wishlist

Comments

@lemeb
Copy link
Contributor

lemeb commented Nov 17, 2019

Is your feature request related to a problem? Please describe.
That cs_workspaces is saved in version control directories (in my case, .git) makes it very hard to sync workspaces between machines. The .git folder is, as far as I know, not traversed by git, and the files in it are computed by the version control system and the machine. In other words, cs_workspaces is a local file.

On the other hand, getting rid of g:CtrlSpaceProjectRootMarkers feels like overkill. Markers are very useful to detect root folders!

Describe the solution you'd like
Have an option, such as g:CtrlSpaceSaveInRootFolder, that enables users to save .cs_workspaces in the root folder by default instead of the root markers.

Happy to submit a PR if you want! The changes would be quite trivial, I think, and would mostly consist in editing one line. (See annex).

Describe alternatives you've considered
Clearing g:CtrlSpaceProjectRootMarkers, but that would mess up Ctrl-Space's normal behavior.

Additional context
Add any other context or screenshots about the feature request here.

Version(s) (please complete the following information):

  • Vim: nvim 0.4.2 / 0.4.3
  • CtrlSpace version: latest according to Vim-Plug. Not on my own fork.
  • OS: Ubuntu 18.04 / Ubuntu 19.10 / macOS Catalina

Much support for all the good maintainers! 🤜

Annex 1: What would replace autoload/ctrlspace/util.vim L70-85

function! s:internalFilePath(name)
    let root = ctrlspace#roots#CurrentProjectRoot()
    let fullPart = empty(root) ? "" : (root . "/")

    "  👇 CHANGED CODE IS HERE 👇
    if !s:config.SaveInRootFolder && !empty(s:config.ProjectRootMarkers)
        for candidate in s:config.ProjectRootMarkers
            let candidatePath = fullPart . candidate

            if isdirectory(candidatePath)
                return candidatePath . "/" . a:name
            endif
        endfor
    endif

    return fullPart . "." . a:name
endfunction
@cometsong
Copy link
Member

cometsong commented Nov 19, 2019

Interesting idea of a technique to do this.
I'm 💯% with you on the idea of optionally not storing the workspaces in the git/etc RootMarker directories. However, there also needs to be a way to set an actual desired Root directory to use. As this is a multi-layered and complex plugin, many other facets need to be associated too.

How can we determine the CurrentProjectRoot() ? 🤔

I've also tried just emptying the ProjectRootMarkers variable as well, as I'd prefer to have all the workspaces related to one of my projects in a single project-specific directory. Plus not all of my projects are in the same git (or other) repository directory.
e.g. for this plugin I have one core workspace, plus another for my fork and another for the version-testing setup that I do for new features/PRs/bug fixes/etc. So in that case the ProjectRootMarkers are ok for some, but I'd like to have all those workspaces stored in the same file for cross-navigation from one to another. I very rarely have more than one workspace in a single git repo. 😐

One of the PRs (#198) has this workspace-list-storing-dir use the s:config.CacheDir which defaults to $HOME. (That one also has a bazillion other changes in the same place, so it'll be done one piece at a time!) So that's a possibility, to have all workspaces in a single place such as your g:CtrlSpaceSaveInRootFolder where the default RootFolder can be the user's home dir.

Personally I'd prefer to have the Project root set in a more malleable way, with search path for CurrentProjectRoot() starting with ProjectRootMarkers (when enabled in config) then up in parent dirs for (how many?) levels searching for those Marker dirs, then getcwd for current dir, then to designated RootDir if that's set in config (defaulting to $HOME?).

Also, if config.LoadLastWorkspaceOnStart is set, it has to get the actual last workspace used, if in different branch of the directory tree. The devil's in the details. I'm going to add these various details project task for this specifically, listing all the variables to track and possibly modify. I'm definitely in for it. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement: feature dev new requests, or significant changes to existing ones priority: 3 - wishlist
Projects
config option for `GlobalProjectRoot`...
  
Descriptions/Issues/PRs
Development

No branches or pull requests

3 participants