NeogitOrg / neogit

An interactive and powerful Git interface for Neovim, inspired by Magit
MIT License
4.03k stars 239 forks source link

Allow flags (eg: --verbose commit) to be set globally #1224

Closed franklouwers closed 7 months ago

franklouwers commented 7 months ago

Is your feature request related to a problem? Please describe. I want to review my commits when committing, so use --verbose by default. I can store the preference for a file or a project, but being a freelancer, I have a lot of projects. I can't find a way to declare that I always want --verbose when committing.

Describe the solution you'd like Allow my to define defaults for flags on operations

Describe alternatives you've considered Using per-project persistent settings. This works, but not when you have a lot of projects and start new projects every two weeks.

CKolkey commented 7 months ago

If use_per_project_settings is false, then it's global instead - does that do what you need?

franklouwers commented 7 months ago

Hmm, then that doesn't seem to work... Or will per-project settings have precedence? Where are they stored, so I can verify what's there (or just wipe all prefs, set it once and test)

CKolkey commented 7 months ago

Run :NeogitResetState to clear it, or find the filepath here: https://github.com/NeogitOrg/neogit/blob/a380d41b3bfa39b70061945f058f34a24fbd1a79/lua/neogit/lib/state.lua#L15

franklouwers commented 7 months ago

I've resetted status, I've removed all files from the state, went into one project, toggled the --verbose flag on commit, went to another project, did a commit, but the --verbose flag was off :(

In my ~/.local/state/nvim/neogit folder I see a preference file per project (turned it on in 2 projects), not a single state file.

My neogit config is as follows:

  {
    "NeogitOrg/neogit",
    dependencies = {
      "nvim-lua/plenary.nvim",  -- required
      "sindrets/diffview.nvim", -- optional - Diff integration

      -- Only one of these is needed, not both.
      "nvim-telescope/telescope.nvim", -- optional
      --    "ibhagwan/fzf-lua",              -- optional
    },
    cmd = 'Neogit',
    config = true,
    opt = {
      use_per_project_settings = false,
      graph_style = 'unicode',
      git_services = {
        ["github.com"] = "https://github.com/${owner}/${repository}/compare/${branch_name}?expand=1",
        ["bitbucket.org"] = "https://bitbucket.org/${owner}/${repository}/pull-requests/new?source=${branch_name}&t=1",
        ["gitlab.com"] =
        "https://gitlab.com/${owner}/${repository}/merge_requests/new?merge_request[source_branch]=${branch_name}",
        ["gitlab.PRIVATE.NODE"] =
        "https://gitlab.PRIVATE.NODE/${owner}/${repository}/merge_requests/new?merge_request[source_branch]=${branch_name}",
      },

    }
  },
CKolkey commented 7 months ago

If you set the opt key, I think you should leave the config key as nil

franklouwers commented 7 months ago

When I remove config or set it to nil, I get a Neogit has not been setup! message.

Digging a bit further, a config shuffle to be more "traditional" (config = function() ...) setup without opt did the trip. Thanks...