Skip to content

Opt out of saving in Project Root Markers #246

Description

@lemeb

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions