Skip to content

Commit

Permalink
feat(integrations): support outline.nvim (#335)
Browse files Browse the repository at this point in the history
## 📃 Summary

closes #296
  • Loading branch information
shortcuts committed Mar 28, 2024
1 parent b2423cf commit aec69e6
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ deps:
git clone --depth 1 https://github.com/antoinemadec/FixCursorHold.nvim deps/fixcursorhold
git clone --depth 1 https://github.com/mfussenegger/nvim-dap deps/nvimdap
git clone --depth 1 https://github.com/rcarriga/nvim-dap-ui deps/nvimdapui
git clone --depth 1 https://github.com/hedyhli/outline.nvim deps/outline

test-ci: deps test

Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,13 +262,22 @@ require("no-neck-pain").setup({
-- When `true`, if the tree was opened before enabling the plugin, we will reopen it.
reopen = true,
},
-- @link https://github.com/rcarriga/nvim-dap-ui
NvimDAPUI = {
-- The position of the tree.
--- @type "none"
position = "none",
-- When `true`, if the tree was opened before enabling the plugin, we will reopen it.
reopen = true,
},
-- @link https://github.com/hedyhli/outline.nvim
outline = {
-- The position of the tree.
--- @type "left"|"right"
position = "right",
-- When `true`, if the tree was opened before enabling the plugin, we will reopen it.
reopen = true,
},
},
})

Expand Down
8 changes: 8 additions & 0 deletions doc/no-neck-pain.txt
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,14 @@ values:
-- When `true`, if the tree was opened before enabling the plugin, we will reopen it.
reopen = true,
},
-- @link https://github.com/hedyhli/outline.nvim
outline = {
-- The position of the tree.
--- @type "left"|"right"
position = "right",
-- When `true`, if the tree was opened before enabling the plugin, we will reopen it.
reopen = true,
},
},
}
Expand Down
8 changes: 8 additions & 0 deletions lua/no-neck-pain/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,14 @@ NoNeckPain.options = {
-- When `true`, if the tree was opened before enabling the plugin, we will reopen it.
reopen = true,
},
-- @link https://github.com/hedyhli/outline.nvim
outline = {
-- The position of the tree.
--- @type "left"|"right"
position = "right",
-- When `true`, if the tree was opened before enabling the plugin, we will reopen it.
reopen = true,
},
},
}

Expand Down
5 changes: 5 additions & 0 deletions lua/no-neck-pain/util/constants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ Co.INTEGRATIONS = {
close = "lua require('dapui').close()",
open = "lua require('dapui').open()",
},
outline = {
fileTypePattern = "outline",
close = "Outline",
open = "Outline",
},
}

---Dashboards filetypes that delays the plugin enable step until next buffer entered.
Expand Down
12 changes: 12 additions & 0 deletions scripts/init_with_outline.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
vim.cmd([[let &rtp.=','.getcwd()]])

vim.cmd("set rtp+=deps/mini.nvim")
vim.cmd("set rtp+=deps/outline")

require("mini.test").setup()
require("outline").setup()
require("no-neck-pain").setup({
width = 1,
minSideBufferWidth = 0,
integrations = { outline = { reopen = true } },
})
4 changes: 4 additions & 0 deletions tests/test_API.lua
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ T["setup"]["sets exposed methods and default options value"] = function()
undotree = {
position = "left",
},
outline = {
position = "right",
reopen = true,
},
})
end

Expand Down
33 changes: 33 additions & 0 deletions tests/test_integrations.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ T["setup"]["overrides default values"] = function()
position = "left",
reopen = false,
},
outline = {
position = "right",
reopen = true,
}
})
end

Expand Down Expand Up @@ -173,6 +177,35 @@ T["neotest"]["keeps sides open"] = function()
})
end

T["outline"] = MiniTest.new_set()

T["outline"]["keeps sides open"] = function()
child.restart({ "-u", "scripts/init_with_outline.lua", "lua/no-neck-pain/main.lua" })
child.set_size(20, 100)

Helpers.toggle(child)

Helpers.expect.equality(Helpers.winsInTab(child), { 1001, 1000, 1002 })
Helpers.expect.state(child, "tabs[1].wins.main", {
curr = 1000,
left = 1001,
right = 1002,
})

child.cmd("Outline")
vim.loop.sleep(50)

Helpers.expect.state(child, "tabs[1].wins.splits", vim.NIL)

Helpers.expect.state(child, "tabs[1].wins.integrations.outline", {
close = "Outline",
fileTypePattern = "outline",
id = 1004,
open = "Outline",
width = 40,
})
end

T["NvimTree"] = MiniTest.new_set()

T["NvimTree"]["keeps sides open"] = function()
Expand Down
5 changes: 5 additions & 0 deletions tests/test_tabs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,11 @@ T["tabnew/tabclose"]["does not pick tab 1 for the first active tab"] = function(
fileTypePattern = "undotree",
open = "UndotreeToggle",
},
outline = {
close = "Outline",
fileTypePattern = "outline",
open = "Outline",
},
},
main = {
curr = 1000,
Expand Down

0 comments on commit aec69e6

Please sign in to comment.