Skip to content

Conversation

@igorlfs
Copy link
Owner

@igorlfs igorlfs commented Feb 11, 2025

Closes #16

The logic to handle buffers and windows is infuriating.

@igorlfs igorlfs changed the title feat: DapViewHide command, start_hidden option feat: DapViewOpen!, DapViewClose!, start_hidden option Feb 12, 2025
@poulter7
Copy link

poulter7 commented Feb 12, 2025

What does DapViewOpen! mean to you?

@igorlfs
Copy link
Owner Author

igorlfs commented Feb 12, 2025

What does DapViewOpen! mean to you?

Ah, sorry for the lack of a description, still a WIP. The idea is to use command bangs (!) to avoid adding unnecessary commands (see :h :command-bang).

:DapViewOpen! will perform a "show both windows", :DapViewClose! will perform a "hide both windows". I'm still unsure what a :DapViewToggle! should do if there's a single window opened, though.

feat: toggle with term
@igorlfs igorlfs changed the title feat: DapViewOpen!, DapViewClose!, start_hidden option feat: DapViewToggle!, DapViewClose!, start_hidden option Feb 13, 2025
@igorlfs
Copy link
Owner Author

igorlfs commented Feb 13, 2025

:DapViewOpen! will perform a "show both windows", :DapViewClose! will perform a "hide both windows". I'm still unsure what a :DapViewToggle! should do if there's a single window opened, though.

I went with a slightly different approach:

  • Regular :DapViewOpen always shows both windows. There's no :DapViewOpen!.
  • :DapViewClose! hides the main views window and the terminal window.
  • :DapViewToggle! uses the main window to choose if it should hide both windows or show both windows.

@poulter7 can you give it a try? From my testing, everything seems to be working fine, but let me know if you run into any issues.

EDIT: and by the way, you can also try using the new start_hidden option.

@poulter7
Copy link

poulter7 commented Feb 13, 2025

The new commands work as expected! I did have to make one change to get the start_hidden flag work after calling setup:

diff --git a/lua/dap-view/events.lua b/lua/dap-view/events.lua
index 73f964c..9860667 100644
--- a/lua/dap-view/events.lua
+++ b/lua/dap-view/events.lua
@@ -6,7 +6,7 @@ local watches = require("dap-view.watches.view")
 local exceptions = require("dap-view.exceptions.view")
 local term = require("dap-view.term.init")
 local eval = require("dap-view.watches.eval")
-local config = require("dap-view.setup").config
+local setup = require("dap-view.setup")
 
 local SUBSCRIPTION_ID = "dap-view"
 
@@ -33,7 +33,8 @@ dap.listeners.before.initialize[SUBSCRIPTION_ID] = function(session, _)
     state.last_active_adapter = adapter
 
     term.setup_term()
-    if not config.windows.terminal.start_hidden then
+    if not setup.config.windows.terminal.start_hidden then
         term.open_term_buf_win()
     end
 end

I'm not an expert lua developer, but is the first import and call to .config causing a local copy of the default opts to be used in events.lua?

@igorlfs
Copy link
Owner Author

igorlfs commented Feb 15, 2025

I did have to make one change to get the start_hidden flag work after calling setup

Thanks for the heads-up! Should be all good now :)

@igorlfs igorlfs marked this pull request as ready for review February 15, 2025 02:39
@igorlfs igorlfs merged commit c86697c into main Feb 15, 2025
2 checks passed
@igorlfs igorlfs deleted the feat/start-hidden-and-hide branch February 15, 2025 02:46
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

Successfully merging this pull request may close these issues.

feature: Option to not show terminal on startup

3 participants