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

How to get the component windows back if I close them? #35

Closed
mrjones2014 opened this issue Nov 29, 2022 · 15 comments
Closed

How to get the component windows back if I close them? #35

mrjones2014 opened this issue Nov 29, 2022 · 15 comments

Comments

@mrjones2014
Copy link
Contributor

I didn’t expect <ESC> to close the single window, IMO it should toggle the whole sidebar.

anyway, if I accidentally close one or more component windows, is there an easy way to get them back and fully restore the window layout?

@ldelossa
Copy link
Owner

Every component exposes a "Focus" command, which "unhides" the component and puts your mouse in it.

For example, "Workspace Explorer Focus".

You should be able to remap the "hide" keymap for components with config overrides.

@mrjones2014
Copy link
Contributor Author

Okay perfect. Is there a way to bind sort of "global" keymaps? Not truly "global" but keymaps that will apply to all nvim-ide windows.

For example, I'd like to remap <ESC> to toggle the currently focused nvim-ide sidebar, but only in the buffers that are part of the sidebar (e.g. if I'm in a normal file buffer it shouldn't do that).

@ldelossa
Copy link
Owner

I think theres two different things here.

  1. Unfortunately, there is no way to apply a keymap across multiple components. This is in my mind too, as overriding say "hide" would have to be done at ever component in the "components" override section.

  2. Every component structure should keep a reference to the panel. So one could create a command within the component that calls close on their associated panel. This would selectively toggle the the panel only when inside a component, and have it only toggle that components panel.

@mrjones2014
Copy link
Contributor Author

I think we can close this as what I'm looking for can be done with a bit of user config

@ldelossa
Copy link
Owner

do share! just because I'm interested.

@mrjones2014
Copy link
Contributor Author

How does <Esc> close the window? I'm trying to figure that out so I can disable that behavior but I don't see <Esc> anywhere in the code 🤔

@ldelossa
Copy link
Owner

ldelossa commented Nov 29, 2022

lol grep for <ctrl-[>

nice easter egg right.

@mrjones2014
Copy link
Contributor Author

mrjones2014 commented Nov 29, 2022

Ah, I think <C-]> is equivalent

EDIT: lol you beat me to it

@ldelossa
Copy link
Owner

yup:

@mrjones2014
Copy link
Contributor Author

Here's what I ended up doing, just disabling the hide keymap and setting a different keymap to toggle the whole sidebar:

local explorer = require('ide.components.explorer')
local outline = require('ide.components.outline')
local bufferlist = require('ide.components.bufferlist')
require('ide').setup({
  components = {
    [explorer.Name] = {
      list_directories_first = true,
      show_file_permissions = false,
      keymaps = {
        hide = '<NOP>',
      },
    },
    [outline.Name] = {
      keymaps = {
        hide = '<NOP>',
      },
    },
  },
  panel_groups = {
    explorer = { bufferlist.Name, explorer.Name, outline.Name },
  },
})

vim.keymap.set('n', '<F3>', ':Workspace LeftPanelToggle<CR>', {})

@ldelossa
Copy link
Owner

lol, its going to become a pain in the ass to set keymaps individually for every component, isn't it?

@mrjones2014
Copy link
Contributor Author

Yeah lol. I'd wanna always disable the hide keymap since for my workflow I'd want to always keep the same sidebar layouts, and just toggle the full sidebars.

Maybe there should be an option like freeze_layout and then in that case, the hide keymap instead toggles the whole sidebar or something?

Or alternatively a way to set keymaps that apply to all components.

@ldelossa
Copy link
Owner

ldelossa commented Nov 29, 2022

Yeah, I think we may want a "global_keymap" in the "components" block, and then in just merge that global keymap with each component config's keymaps field on component construction?

@mrjones2014
Copy link
Contributor Author

Yeah that sounds good to me.

@ldelossa
Copy link
Owner

Okay i'll create and issue and take that one on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants