-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: configure default scopes (#123)
* feat: allow configuring default scopes * docs: update documentation for default scopes
- Loading branch information
Showing
7 changed files
with
197 additions
and
24 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
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
local App = require("grapple.app") | ||
local Util = require("grapple.util") | ||
|
||
describe("App", function() | ||
describe(".update", function() | ||
it("defines the default scopes", function() | ||
local app = App:new() | ||
app:update() | ||
local names = vim.tbl_keys(app.scope_manager.scopes) | ||
table.sort(names, Util.as_lower) | ||
assert.same({ "cwd", "git", "git_branch", "global", "lsp" }, names) | ||
end) | ||
end) | ||
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
local Settings = require("grapple.settings") | ||
|
||
describe("Settings", function() | ||
describe("Defaults", function() | ||
it("has the correct style defaults", function() | ||
local settings = Settings:new() | ||
assert.same(true, settings.icons) | ||
assert.same(true, settings.status) | ||
assert.same("end", settings.name_pos) | ||
assert.same("relative", settings.style) | ||
end) | ||
|
||
it("has the correct scope default", function() | ||
local settings = Settings:new() | ||
assert.same("git", settings.scope) | ||
end) | ||
end) | ||
|
||
describe(".quick_select", function() | ||
it("has the correct quick_select default", function() | ||
local settings = Settings:new() | ||
assert.same({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, settings:quick_select()) | ||
end) | ||
|
||
it("can be set to nothing", function() | ||
local settings = Settings:new() | ||
settings:update({ quick_select = "" }) | ||
assert.same({}, settings:quick_select()) | ||
end) | ||
end) | ||
|
||
describe(".scopes", function() | ||
it("has the correct scopes default", function() | ||
local settings = Settings:new() | ||
-- stylua: ignore | ||
local names = vim.tbl_map(function(def) return def.name end, settings:scopes()) | ||
assert.same({ "global", "cwd", "git", "git_branch", "lsp" }, names) | ||
end) | ||
|
||
it("merges default and user-defined scopes", function() | ||
local settings = Settings:new() | ||
settings:update({ scopes = { { name = "test" } } }) | ||
-- stylua: ignore | ||
local names = vim.tbl_map(function(def) return def.name end, settings:scopes()) | ||
assert.same({ "global", "cwd", "git", "git_branch", "lsp", "test" }, names) | ||
end) | ||
|
||
it("overrides default scope definitions", function() | ||
local settings = Settings:new() | ||
settings:update({ default_scopes = { global = { name = "bob" } } }) | ||
-- stylua: ignore | ||
local names = vim.tbl_map(function(def) return def.name end, settings:scopes()) | ||
assert.same({ "bob", "cwd", "git", "git_branch", "lsp" }, names) | ||
end) | ||
|
||
it("marks default scopes to be deleted", function() | ||
local settings = Settings:new() | ||
settings:update({ default_scopes = { cwd = false } }) | ||
-- stylua: ignore | ||
local deleted = vim.tbl_filter(function(def) return def.delete end, settings:scopes()) | ||
assert.same({ { name = "cwd", delete = true } }, deleted) | ||
end) | ||
end) | ||
end) |