generated from ellisonleao/nvim-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rearrange event handling and start introducing exception handling
- Loading branch information
Showing
7 changed files
with
60 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,41 @@ | ||
local M = {} | ||
local dap = require("dap") | ||
local state = require("dap-view.state") | ||
local breakpoints = require("dap-view.breakpoints") | ||
local actions = require("dap-view.actions") | ||
|
||
M.listen_breakpoints = function() | ||
-- TODO a better approach could be to hijack the "toggle breakpoint" command | ||
-- and use some autocmds (eg, BufLeave/BufEnter for our buffer) | ||
require("dap").listeners.after.setBreakpoints["dap-view"] = function() | ||
require("dap-view.breakpoints").show() | ||
dap.listeners.after.setBreakpoints["dap-view"] = function() | ||
breakpoints.show() | ||
end | ||
|
||
dap.listeners.after.launch["dap-view"] = function() | ||
if state.exceptions_options == nil then | ||
return | ||
end | ||
|
||
local filters = vim.iter(state.exceptions_options) | ||
:filter(function(x) | ||
return x.enabled | ||
end) | ||
:map(function(x) | ||
return x.exception_filter.filter | ||
end) | ||
:totable() | ||
|
||
dap.set_exception_breakpoints(filters) | ||
end | ||
|
||
return M | ||
dap.listeners.after.initialize["dap-view"] = function(session, _) | ||
state.exceptions_options = vim.iter(session.capabilities.exceptionBreakpointFilters) | ||
:map(function(filter) | ||
return { enabled = filter.default, exception_filter = filter } | ||
end) | ||
:totable() | ||
end | ||
|
||
dap.listeners.before.event_terminated.dapui_config = function() | ||
actions.close() | ||
end | ||
|
||
dap.listeners.before.event_exited.dapui_config = function() | ||
actions.close() | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
return { | ||
MAIN_BUF_NAME = "dap-view://main", | ||
NAMESPACE = vim.api.nvim_create_namespace("dap-view"), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
---@class ExceptionsOption | ||
---@field exception_filter dap.ExceptionBreakpointsFilter[] | ||
---@field enabled boolean | ||
|
||
---@class State | ||
---@field bufnr? integer | ||
---@field winnr? integer | ||
---@field current_section? SectionType | ||
---@field exceptions_options? ExceptionsOption[] | ||
local M = { | ||
bufnr = nil, | ||
winnr = nil, | ||
current_section = nil, | ||
exceptions_options = nil, | ||
} | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters