Skip to content

Commit 058e34d

Browse files
committed
chore: autoformat README, update some hl group links
1 parent 8e30868 commit 058e34d

File tree

3 files changed

+76
-61
lines changed

3 files changed

+76
-61
lines changed

README.md

Lines changed: 61 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
- [Jumping](#jumping)
2222
- [Expanding Variables](#expanding-variables)
2323
- [Highlight Groups](#highlight-groups)
24-
- [Filetypes and autocommands](#filetypes-and-autocommands)
25-
- [Custom buttons](#custom-buttons)
24+
- [Filetypes and Autocommands](#filetypes-and-autocommands)
25+
- [Custom Buttons](#custom-buttons)
2626
- [Roadmap](#roadmap)
2727
- [Known Issues](#known-issues)
2828
- [Acknowledgements](#acknowledgements)
@@ -324,39 +324,44 @@ return {
324324

325325
### Highlight Groups
326326

327-
`nvim-dap-view` defines 22 highlight groups linked to (somewhat) reasonable defaults, but they may look odd with your colorscheme. If the links aren't defined, no highlighting will be applied. To fix that, you have to manually define the highlight groups (see `:h nvim_set_hl()`). Consider contributing to your colorscheme by sending a PR to add support to `nvim-dap-view`!
327+
`nvim-dap-view` defines 28 highlight groups linked to (somewhat) reasonable defaults, but they may look odd with your colorscheme. If the links aren't defined, no highlighting will be applied. To fix that, you have to manually define the highlight groups (see `:h nvim_set_hl()`). Consider contributing to your colorscheme by sending a PR to add support to `nvim-dap-view`!
328328

329329
<details>
330330
<summary>Highlight groups</summary>
331331

332332
| Highlight Group | Default link |
333333
|--------------------------------------|-----------------------------|
334334
| `NvimDapViewMissingData` | `DapBreakpoint` |
335-
| `NvimDapViewWatchText` | `Comment` |
336-
| `NvimDapViewWatchTextChanged` | `DiagnosticVirtualTextWarn` |
337335
| `NvimDapViewExceptionFilterEnabled` | `DiagnosticOk` |
338336
| `NvimDapViewExceptionFilterDisabled` | `DiagnosticError` |
339337
| `NvimDapViewFileName` | `qfFileName` |
340338
| `NvimDapViewLineNumber` | `qfLineNr` |
341339
| `NvimDapViewSeparator` | `Comment` |
342-
| `NvimDapViewThread` | `@namespace` |
343-
| `NvimDapViewThreadStopped` | `@conditional` |
340+
| `NvimDapViewThread` | `Tag` |
341+
| `NvimDapViewThreadStopped` | `Conditional` |
344342
| `NvimDapViewTab` | `TabLine` |
345343
| `NvimDapViewTabSelected` | `TabLineSel` |
346344
| `NvimDapViewControlNC` | `Comment` |
347-
| `NvimDapViewControlPlay` | `@keyword` |
348-
| `NvimDapViewControlPause` | `@boolean` |
349-
| `NvimDapViewControlStepInto` | `@function` |
350-
| `NvimDapViewControlStepOut` | `@function` |
351-
| `NvimDapViewControlStepOver` | `@function` |
352-
| `NvimDapViewControlStepBack` | `@function` |
353-
| `NvimDapViewControlRunLast` | `@keyword` |
345+
| `NvimDapViewControlPlay` | `Keyword` |
346+
| `NvimDapViewControlPause` | `Boolean` |
347+
| `NvimDapViewControlStepInto` | `Function` |
348+
| `NvimDapViewControlStepOut` | `Function` |
349+
| `NvimDapViewControlStepOver` | `Function` |
350+
| `NvimDapViewControlStepBack` | `Function` |
351+
| `NvimDapViewControlRunLast` | `Keyword` |
354352
| `NvimDapViewControlTerminate` | `DapBreakpoint` |
355353
| `NvimDapViewControlDisconnect` | `DapBreakpoint` |
354+
| `NvimDapViewWatchExpr` | `Identifier` |
355+
| `NvimDapViewWatchError` | `DiagnosticError` |
356+
| `NvimDapViewWatchUpdated` | `DiagnosticVirtualTextWarn` |
357+
| `NvimDapViewBoolean` | `Boolean` |
358+
| `NvimDapViewString` | `String` |
359+
| `NvimDapViewNumber` | `Number` |
360+
| `NvimDapViewFloat` | `Float` |
361+
| `NvimDapViewFunction` | `Function` |
356362

357363
<details>
358364

359-
360365
### Filetypes and Autocommands
361366

362367
`nvim-dap-view` sets the following filetypes:
@@ -386,9 +391,9 @@ vim.api.nvim_create_autocmd({ "FileType" }, {
386391

387392
</details>
388393

389-
### Custom buttons
394+
### Custom Buttons
390395

391-
`nvim-dap-view` provides some default buttons for the control bar, but you can also add your own. To do that, in the `controls` table you can use the `custom_buttons` table to declare your new button and then add it at the position you want in the `buttons` list.
396+
`nvim-dap-view` provides some default buttons for the control bar, but you can also add your own. To do that, in the `controls` table you can use the `custom_buttons` table to declare your new button and then add it at the position you want in the `buttons` list.
392397

393398
A custom button has 2 methods:
394399

@@ -404,42 +409,50 @@ See the `@ N` section in `:help statusline` for the complete specifications of a
404409
<summary>Example custom buttons</summary>
405410

406411
An example adding 2 buttons:
412+
407413
- `fun`: the most basic button possible, just prints "🎊" when clicked
408414
- `term_restart`: an hybrid button that acts as a stop/restart button. If the stop button is triggered by anything else than a single left click (middle click, right click, double click or click with a modifier), it will disconnect the session instead.
409415

410416
```lua
411-
winbar = {
412-
controls = {
413-
enabled = true,
414-
buttons = {"play", "step_into", "step_over", "step_out", "term_restart", "fun" },
415-
custom_buttons = {
416-
fun = {
417-
render = function() return "🎉" end,
418-
action = function() vim.print("🎊") end,
419-
},
420-
-- Stop/Restart button
421-
-- Double click, middle click or click with a modifier disconnect instead of stop
422-
term_restart = {
423-
render = function()
424-
local session = require("dap").session()
425-
local group = session and "ControlTerminate" or "ControlRunLast"
426-
local icon = session and "" or ""
427-
return "%#NvimDapView" .. group .. "#" .. icon .. "%*"
428-
end,
429-
action = function(clicks, button, modifiers)
430-
local dap = require("dap")
431-
local alt = clicks > 1 or button ~= "l" or modifiers:gsub(" ", "") ~= ""
432-
if not dap.session() then
433-
dap.run_last()
434-
elseif alt then
435-
dap.disconnect()
436-
else
437-
dap.terminate()
438-
end
439-
end,
440-
},
417+
-- No need to include the "return" statement
418+
return {
419+
winbar = {
420+
controls = {
421+
enabled = true,
422+
buttons = { "play", "step_into", "step_over", "step_out", "term_restart", "fun" },
423+
custom_buttons = {
424+
fun = {
425+
render = function()
426+
return "🎉"
427+
end,
428+
action = function()
429+
vim.print("🎊")
430+
end,
431+
},
432+
-- Stop/Restart button
433+
-- Double click, middle click or click with a modifier disconnect instead of stop
434+
term_restart = {
435+
render = function()
436+
local session = require("dap").session()
437+
local group = session and "ControlTerminate" or "ControlRunLast"
438+
local icon = session and "" or ""
439+
return "%#NvimDapView" .. group .. "#" .. icon .. "%*"
440+
end,
441+
action = function(clicks, button, modifiers)
442+
local dap = require("dap")
443+
local alt = clicks > 1 or button ~= "l" or modifiers:gsub(" ", "") ~= ""
444+
if not dap.session() then
445+
dap.run_last()
446+
elseif alt then
447+
dap.disconnect()
448+
else
449+
dap.terminate()
450+
end
451+
end,
452+
},
453+
},
454+
},
441455
},
442-
},
443456
}
444457
```
445458

lua/dap-view/highlight.lua

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1+
local globals = require("dap-view.globals")
2+
13
local api = vim.api
2-
local prefix = require("dap-view.globals").HL_PREFIX
34

45
---@param name string
56
---@param link string
67
local hl_create = function(name, link)
7-
api.nvim_set_hl(0, prefix .. name, { link = link })
8+
api.nvim_set_hl(0, globals.HL_PREFIX .. name, { link = link })
89
end
910

1011
local define_base_links = function()
1112
hl_create("MissingData", "DapBreakpoint")
1213
hl_create("FileName", "qfFileName")
1314
hl_create("LineNumber", "qfLineNr")
1415
hl_create("Separator", "Comment")
15-
hl_create("Thread", "@namespace")
16-
hl_create("ThreadStopped", "@conditional")
16+
hl_create("Thread", "Tag")
17+
hl_create("ThreadStopped", "Conditional")
1718

1819
hl_create("ExceptionFilterEnabled", "DiagnosticOk")
1920
hl_create("ExceptionFilterDisabled", "DiagnosticError")
@@ -22,15 +23,16 @@ local define_base_links = function()
2223
hl_create("TabSelected", "TabLineSel")
2324

2425
hl_create("ControlNC", "Comment")
25-
hl_create("ControlPlay", "@keyword")
26-
hl_create("ControlPause", "@boolean")
27-
hl_create("ControlStepInto", "@function")
28-
hl_create("ControlStepOut", "@function")
29-
hl_create("ControlStepOver", "@function")
30-
hl_create("ControlStepBack", "@function")
31-
hl_create("ControlRunLast", "@keyword")
26+
hl_create("ControlPlay", "Keyword")
27+
hl_create("ControlPause", "Boolean")
28+
hl_create("ControlStepInto", "Function")
29+
hl_create("ControlStepOut", "Function")
30+
hl_create("ControlStepOver", "Function")
31+
hl_create("ControlStepBack", "Function")
32+
hl_create("ControlRunLast", "Keyword")
3233
hl_create("ControlTerminate", "DapBreakpoint")
3334
hl_create("ControlDisconnect", "DapBreakpoint")
35+
3436
hl_create("WatchExpr", "Identifier")
3537
hl_create("WatchError", "DiagnosticError")
3638
hl_create("WatchUpdated", "DiagnosticVirtualTextWarn")

lua/dap-view/util/statusline.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
local M = {}
2-
local prefix = require("dap-view.globals").HL_PREFIX
2+
local global = require("dap-view.globals")
33

44
---@param text string
55
---@param group string
66
M.hl = function(text, group)
7-
return "%#" .. prefix .. group .. "#" .. text .. "%*"
7+
return "%#" .. global.HL_PREFIX .. group .. "#" .. text .. "%*"
88
end
99

1010
---@param text string

0 commit comments

Comments
 (0)