Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(integrations): support outline.nvim #335

Merged
merged 2 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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