Skip to content

Option to set window.open for each individual file being opened, not once globally #111

@dk949

Description

@dk949

Is your feature request related to a problem? Please describe.

When using the terminal to open files normally, I like having them open in the alternate window, but for git commit, I would like to be able to do something like:

[open floating window]
vim.cmd.term("git commit")

Such that the editor opens in that floating window.

Describe the solution you'd like

Perhaps a global variable to make it possible to do something like GIT_EDITOR="nvim --cmd 'let g:flatten_window_open=\"current\"'"

Another option could be to let the pre_open hook return a new configuration (or subset of the configuration) which would be applied to just the current window being opened. This is a bit more complicated to work with, but it would solve this question for other config options too, not just window.open.

Describe alternatives you've considered

My current solution seems to work, but it's pretty ugly

-- config:
{
    hooks = {
        post_open = function ()
            require("flatten").config.window.open = "alternate"
        end
    },
}

-- git commit function:

require("flatten").config.window.open = "current"
[open floating window]
vim.cmd.term("git commit")

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions