Skip to content

Conversation

@catgoose
Copy link
Contributor

@catgoose catgoose commented Feb 15, 2025

allows for creating terminal window before dap session has started

Addresses #18

I'm not sure about storing the terminal bufnr/winnr state in the terminal module, maybe we can store it in state module? I just needed some way to get bufnr out of the plugin after opening nvim-dap-view

allows for creating terminal window before dap session has started
@catgoose catgoose marked this pull request as draft February 15, 2025 17:15
@catgoose catgoose marked this pull request as ready for review February 15, 2025 20:08
@catgoose catgoose force-pushed the feat/ignore_session-create_terminal branch from c26d777 to ba3110e Compare February 15, 2025 20:28
@igorlfs
Copy link
Owner

igorlfs commented Feb 18, 2025

maybe we can store it in state module?

Yeah, if we proceed with this change, I think it's better to store these variables in the state module.

Copy link
Owner

@igorlfs igorlfs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember to add the new option to the default config in the README.

I'm a bit wary of adding yet another option to control the terminal. The major issue is that it's not clear how this setting should behave when other settings are enabled. For instance: should hide take precedence over ignore_session? I'm fine with either behavior, but this should be documented, as to not give users any surprises.

@catgoose
Copy link
Contributor Author

maybe we can store it in state module?

Yeah, if we proceed with this change, I think it's better to store these variables in the state module.

I am in no rush to merge this PR because I want to do a bit of testing to make sure everything is good, but I will address your comments.

@catgoose
Copy link
Contributor Author

catgoose commented Feb 19, 2025

Remember to add the new option to the default config in the README.

I'm a bit wary of adding yet another option to control the terminal. The major issue is that it's not clear how this setting should behave when other settings are enabled. For instance: should hide take precedence over ignore_session? I'm fine with either behavior, but this should be documented, as to not give users any surprises.

Yeah of course, I understand. I'll test different configurations to make sure this doesn't conflict with the other terminal settings.

@catgoose catgoose changed the title feat: creates windows.terminal.ignore_session configuration option feat: creates windows.terminal.bootstrap configuration option Feb 19, 2025
@catgoose
Copy link
Contributor Author

catgoose commented Feb 19, 2025

Ok it seems that I can make this work without the bootstrap option. Using this configuration after 92010f2:

    opts = {
      winbar = {
        show = true,
        sections = { "watches", "breakpoints", "repl" },
        default_section = "breakpoints",
      },
      windows = {
        height = 12,
        terminal = {
          position = "right",
          -- hide = { "go" },
          start_hidden = true,
        },
      },
    },

If I use start_hidden = false, some weird jumping occurs, but start_hidden = true operates the same as the bootstrap configuration.

In summary what we had to do was make the term bufnr and winnr available in state module and do that nil check on previous adapter in events.

By the way it seems that there is a go and delve adapters: https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation#Go

Co-authored-by: Igor Lacerda <igorlfs@ufmg.br>

ref: rename config.windows.terminal.ignore_session to ...bootstrap

chore: adds comment about checking state.last_active_adapter for nil
…tate module

ref: removes bootstrap configuration option
@catgoose catgoose force-pushed the feat/ignore_session-create_terminal branch from 92010f2 to 14a6d44 Compare February 19, 2025 10:34
@catgoose catgoose closed this Feb 19, 2025
@catgoose catgoose deleted the feat/ignore_session-create_terminal branch February 19, 2025 10:35
@catgoose catgoose restored the feat/ignore_session-create_terminal branch February 19, 2025 10:36
@catgoose catgoose reopened this Feb 19, 2025
@catgoose catgoose force-pushed the feat/ignore_session-create_terminal branch from 9477390 to 08ed2d3 Compare February 19, 2025 10:42
@igorlfs
Copy link
Owner

igorlfs commented Feb 20, 2025

Hey! I'm glad you managed to make it work without having to introduce another option!

By the way it seems that there is a go and delve adapters

I've never written a single line of Go in my life, so I'm not really well versed with the language. But if you feel this belongs into the README example, go ahead!

@catgoose
Copy link
Contributor Author

Hey! I'm glad you managed to make it work without having to introduce another option!

By the way it seems that there is a go and delve adapters

I've never written a single line of Go in my life, so I'm not really well versed with the language. But if you feel this belongs into the README example, go ahead!

I think from reading that link that it would be more correct to reference go rather than delve. But in any case the user would be able to add whatever adapters they need to the hide table.

@catgoose catgoose force-pushed the feat/ignore_session-create_terminal branch from 6106ead to a7bf821 Compare February 21, 2025 00:36
@igorlfs
Copy link
Owner

igorlfs commented Feb 21, 2025

I think from reading that link that it would be more correct to reference go rather than delve

Either way is fine by me ^^

@catgoose catgoose force-pushed the feat/ignore_session-create_terminal branch from a7bf821 to 65c0b62 Compare February 21, 2025 11:36
@catgoose catgoose changed the title feat: creates windows.terminal.bootstrap configuration option feat: expose terminal bufnr/winnr in state module Feb 21, 2025
@igorlfs igorlfs merged commit a0c5f9f into igorlfs:main Feb 22, 2025
1 check passed
@igorlfs
Copy link
Owner

igorlfs commented Feb 22, 2025

Hm, oddly this is breaking my setup, which uses pretty much a default config :/

-- Since there has not been a `last_active_adapter` yet, we don't need to
-- call `delete_term_buf`, which conflicts with bootstrapping the terminal
-- window. See: https://github.com/igorlfs/nvim-dap-view/issues/18
if state.last_active_adapter and state.last_active_adapter ~= adapter then
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As is turns out, this line actually breaks the "standard" use case. If you first open a ndv's main window and then try to start a session, the terminal will be spawned on top of ndv's main a window (an additional split is also created). Perhaps we DO have to introduce an option for your use case!

For now, I'm reverting this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, I'll try to recreate that issue and see what I can do in another PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I cannot reproduce. I am using the basic go debug adapter without my special magic, and for nvim-dap-view: no config overrides, open with DapViewOpen or require("dap-view").toggle(true), start debugger and it looks right:

image

Perhaps it's something with your debug adapter (or mine)? Can you post a screenshot of what is happening?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey! Sorry, for the past few days, my main concern was getting the stacks + threads view working!

For the reproduction, I'm also using the default options, but I'm using debugpy. I believe this is issue is actually being caused by how debugpy handles multiple sessions, though I haven't been able to confirm that. Can you try using debugpy to check if you can reproduce?

If this turns out to be an issue with debugpy, I'm not sure how to best handle the situation.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As is turns out, this line actually breaks the "standard" use case. If you first open a ndv's main window and then try to start a session, the terminal will be spawned on top of ndv's main a window (an additional split is also created). Perhaps we DO have to introduce an option for your use case!

I have no idea how I was observing this behavior. Seriously. Perhaps I had some uncommited change, which was interfering? No idea. I'm sorry for the trouble!

I'll be reverting the revert once I'm done with another portion of my refactoring.

igorlfs pushed a commit that referenced this pull request Feb 25, 2025
* feat: creates windows.terminal.ignore_session configuration option
allows for creating terminal window before dap session has started

* fix: correctly position terminal if ignoring dap session

* Update README.md

Co-authored-by: Igor Lacerda <igorlfs@ufmg.br>

ref: rename config.windows.terminal.ignore_session to ...bootstrap

chore: adds comment about checking state.last_active_adapter for nil

* ref: move terminal creation logic concerning terminal edge cases to state module

ref: removes bootstrap configuration option

* chore: removes unused import and converts function to local

* ref: simplify logic for opening terminal window
igorlfs added a commit that referenced this pull request Feb 25, 2025
* feat: threads and stacks view

* auto-generate vimdoc

* feat: expose terminal bufnr/winnr in state module (#19)

* feat: creates windows.terminal.ignore_session configuration option
allows for creating terminal window before dap session has started

* fix: correctly position terminal if ignoring dap session

* Update README.md

Co-authored-by: Igor Lacerda <igorlfs@ufmg.br>

ref: rename config.windows.terminal.ignore_session to ...bootstrap

chore: adds comment about checking state.last_active_adapter for nil

* ref: move terminal creation logic concerning terminal edge cases to state module

ref: removes bootstrap configuration option

* chore: removes unused import and converts function to local

* ref: simplify logic for opening terminal window

* auto-generate vimdoc

* fix: revert not deleting term buf when no session was run yet

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Meow Honk <21010072+catgoose@users.noreply.github.com>
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.

2 participants