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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaking!: rename disable_* config properties to enable_* #1556

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,16 @@ You can configure neogit by running the `neogit.setup()` function, passing a tab
local neogit = require("neogit")

neogit.setup {
-- Hides the hints at the top of the status buffer
disable_hint = false,
-- Disables changing the buffer highlights based on where the cursor is.
disable_context_highlighting = false,
-- Disables signs for sections/items/hunks
disable_signs = false,
-- Changes what mode the Commit Editor starts in. `true` will leave nvim in normal mode, `false` will change nvim to
-- Shows the hints at the top of the status buffer
enable_hint = true,
-- Enable changing the buffer highlights based on where the cursor is.
enable_context_highlighting = true,
-- Shows signs for sections/items/hunks
enable_signs = true,
-- Changes what mode the Commit Editor starts in. `false` will leave nvim in normal mode, `true` will change nvim to
-- insert mode, and `"auto"` will change nvim to insert mode IF the commit message is empty, otherwise leaving it in
-- normal mode.
disable_insert_on_commit = "auto",
enable_insert_on_commit = "auto",
-- When enabled, will watch the `.git/` directory for changes and refresh the status buffer in response to filesystem
-- events.
filewatcher = {
Expand Down Expand Up @@ -134,10 +134,10 @@ neogit.setup {
initial_branch_name = "",
-- Change the default way of opening neogit
kind = "tab",
-- Disable line numbers
disable_line_numbers = true,
-- Disable relative line numbers
disable_relative_line_numbers = true,
-- Show line numbers
enable_line_numbers = false,
-- Show relative line numbers
enable_relative_line_numbers = false,
-- The time after which an output console is shown for slow running commands
console_timeout = 2000,
-- Automatically show console if a command takes more than console_timeout milliseconds
Expand Down
10 changes: 5 additions & 5 deletions doc/neogit.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ to Neovim users.
TODO: Detail what these do

use_default_keymaps = true,
disable_hint = false,
disable_context_highlighting = false,
disable_signs = false,
enable_hint = true,
enable_context_highlighting = true,
enable_signs = true,
graph_style = "ascii",
commit_date_format = nil,
log_date_format = nil,
Expand All @@ -108,7 +108,7 @@ TODO: Detail what these do
bold = true,
underline = true,
},
disable_insert_on_commit = "auto",
enable_insert_on_commit = "auto",
use_per_project_settings = true,
show_head_commit_hash = true,
remember_settings = true,
Expand All @@ -117,7 +117,7 @@ TODO: Detail what these do
sort_branches = "-committerdate",
initial_branch_name = "",
kind = "tab",
disable_line_numbers = true,
enable_line_numbers = false,
-- The time after which an output console is shown for slow running commands
console_timeout = 2000,
-- Automatically show console if a command takes more than console_timeout milliseconds
Expand Down
2 changes: 1 addition & 1 deletion lua/neogit/buffers/commit_select_view/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function M:open(action)
self.buffer = Buffer.create {
name = "NeogitCommitSelectView",
filetype = "NeogitCommitSelectView",
status_column = not config.values.disable_signs and "" or nil,
status_column = config.values.enable_signs and "" or nil,
kind = config.values.commit_select_view.kind,
header = self.header or "Select a commit with <cr>, or <esc> to abort",
scroll_header = true,
Expand Down
4 changes: 2 additions & 2 deletions lua/neogit/buffers/commit_view/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ function M:open(kind)
name = "NeogitCommitView",
filetype = "NeogitCommitView",
kind = kind,
status_column = not config.values.disable_signs and "" or nil,
context_highlight = not config.values.disable_context_highlighting,
status_column = config.values.enable_signs and "" or nil,
context_highlight = config.values.enable_context_highlighting,
autocmds = {
["WinLeave"] = function()
if self.buffer and self.buffer.kind == "floating" then
Expand Down
4 changes: 2 additions & 2 deletions lua/neogit/buffers/diff/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ function M:open()
self.buffer = Buffer.create {
name = "NeogitDiffView",
filetype = "NeogitDiffView",
status_column = not config.values.disable_signs and "" or nil,
status_column = config.values.enable_signs and "" or nil,
kind = config.values.commit_editor.staged_diff_split_kind,
context_highlight = not config.values.disable_context_highlighting,
context_highlight = config.values.enable_context_highlighting,
mappings = {
n = {
["{"] = function() -- Goto Previous
Expand Down
7 changes: 3 additions & 4 deletions lua/neogit/buffers/editor/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function M:open(kind)
buftype = "",
kind = kind,
modifiable = true,
status_column = not config.values.disable_signs and "" or nil,
status_column = config.values.enable_signs and "" or nil,
readonly = false,
autocmds = {
["QuitPre"] = function() -- For :wq compatibility
Expand Down Expand Up @@ -146,10 +146,9 @@ function M:open(kind)
footer = buffer:get_lines(1, -1)

-- Start insert mode if user has configured it
local disable_insert = config.values.disable_insert_on_commit
local enable_insert = config.values.enable_insert_on_commit
if
(disable_insert == "auto" and vim.fn.prevnonblank(".") ~= vim.fn.line("."))
or not disable_insert
(enable_insert == "auto" and vim.fn.prevnonblank(".") ~= vim.fn.line(".")) or (enable_insert == true)
then
vim.cmd(":startinsert")
end
Expand Down
2 changes: 1 addition & 1 deletion lua/neogit/buffers/log_view/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function M:open()
header = self.header,
scroll_header = false,
active_item_highlight = true,
status_column = not config.values.disable_signs and "" or nil,
status_column = config.values.enable_signs and "" or nil,
mappings = {
v = {
[popups.mapping_for("CherryPickPopup")] = popups.open("cherry_pick", function(p)
Expand Down
6 changes: 3 additions & 3 deletions lua/neogit/buffers/rebase_editor/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ function M:open(kind)
load = true,
filetype = "gitrebase",
buftype = "",
status_column = not config.values.disable_signs and "" or nil,
status_column = config.values.enable_signs and "" or nil,
kind = kind,
modifiable = true,
disable_line_numbers = config.values.disable_line_numbers,
disable_relative_line_numbers = config.values.disable_relative_line_numbers,
enable_line_numbers = config.values.enable_line_numbers,
enable_relative_line_numbers = config.values.enable_relative_line_numbers,
readonly = false,
on_detach = function()
if self.on_unload then
Expand Down
2 changes: 1 addition & 1 deletion lua/neogit/buffers/reflog_view/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function M:open(_)
kind = config.values.reflog_view.kind,
header = self.header,
scroll_header = true,
status_column = not config.values.disable_signs and "" or nil,
status_column = config.values.enable_signs and "" or nil,
context_highlight = true,
active_item_highlight = true,
mappings = {
Expand Down
8 changes: 4 additions & 4 deletions lua/neogit/buffers/status/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ function M:open(kind)
name = "NeogitStatus",
filetype = "NeogitStatus",
cwd = self.cwd,
context_highlight = not config.values.disable_context_highlighting,
context_highlight = config.values.enable_context_highlighting,
kind = kind or config.values.kind or "tab",
disable_line_numbers = config.values.disable_line_numbers,
disable_relative_line_numbers = config.values.disable_relative_line_numbers,
foldmarkers = not config.values.disable_signs,
enable_line_numbers = config.values.enable_line_numbers,
enable_relative_line_numbers = config.values.enable_relative_line_numbers,
foldmarkers = config.values.enable_signs,
active_item_highlight = true,
on_detach = function()
Watcher.instance(self.root):unregister(self)
Expand Down
2 changes: 1 addition & 1 deletion lua/neogit/buffers/status/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ end)

function M.Status(state, config)
-- stylua: ignore start
local show_hint = not config.disable_hint
local show_hint = config.enable_hint

local show_upstream = state.upstream.ref
and not state.head.detached
Expand Down
36 changes: 18 additions & 18 deletions lua/neogit/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -302,21 +302,21 @@ end
---@field graph_style? NeogitGraphStyle Style for graph
---@field commit_date_format? string Commit date format
---@field log_date_format? string Log date format
---@field disable_hint? boolean Remove the top hint in the Status buffer
---@field disable_context_highlighting? boolean Disable context highlights based on cursor position
---@field disable_signs? boolean Special signs to draw for sections etc. in Neogit
---@field enable_hint? boolean Shows the top hint in the Status buffer
---@field enable_context_highlighting? boolean Enable context highlights based on cursor position
---@field enable_signs? boolean Special signs to draw for sections etc. in Neogit
---@field git_services? table Templartes to use when opening a pull request for a branch
---@field fetch_after_checkout? boolean Perform a fetch if the newly checked out branch has an upstream or pushRemote set
---@field telescope_sorter? function The sorter telescope will use
---@field process_spinner? boolean Hide/Show the process spinner
---@field disable_insert_on_commit? boolean|"auto" Disable automatically entering insert mode in commit dialogues
---@field enable_insert_on_commit? boolean|"auto" Enables automatically entering insert mode in commit dialogues
---@field use_per_project_settings? boolean Scope persisted settings on a per-project basis
---@field remember_settings? boolean Whether neogit should persist flags from popups, e.g. git push flags
---@field sort_branches? string Value used for `--sort` for the `git branch` command
---@field initial_branch_name? string Default for new branch name prompts
---@field kind? WindowKind The default type of window neogit should open in
---@field disable_line_numbers? boolean Whether to disable line numbers
---@field disable_relative_line_numbers? boolean Whether to disable line numbers
---@field enable_line_numbers? boolean Whether to enable line numbers
---@field enable_relative_line_numbers? boolean Whether to enable relative line numbers
---@field console_timeout? integer Time in milliseconds after a console is created for long running commands
---@field auto_show_console? boolean Automatically show the console if a command takes longer than console_timeout
---@field auto_show_console_on? string Specify "output" (show always; default) or "error" if `auto_show_console` enabled
Expand Down Expand Up @@ -349,9 +349,9 @@ end
function M.get_default_values()
return {
use_default_keymaps = true,
disable_hint = false,
disable_context_highlighting = false,
disable_signs = false,
enable_hint = true,
enable_context_highlighting = true,
enable_signs = true,
graph_style = "ascii",
commit_date_format = nil,
log_date_format = nil,
Expand All @@ -369,15 +369,15 @@ function M.get_default_values()
["azure.com"] = "https://dev.azure.com/${owner}/_git/${repository}/pullrequestcreate?sourceRef=${branch_name}&targetRef=${target}",
},
highlight = {},
disable_insert_on_commit = "auto",
enable_insert_on_commit = "auto",
use_per_project_settings = true,
remember_settings = true,
fetch_after_checkout = false,
sort_branches = "-committerdate",
kind = "tab",
initial_branch_name = "",
disable_line_numbers = true,
disable_relative_line_numbers = true,
enable_line_numbers = false,
enable_relative_line_numbers = false,
-- The time after which an output console is shown for slow running commands
console_timeout = 2000,
-- Automatically show console if a command takes more than console_timeout milliseconds
Expand Down Expand Up @@ -1102,9 +1102,9 @@ function M.validate_config()
end

if validate_type(config, "base config", "table") then
validate_type(config.disable_hint, "disable_hint", "boolean")
validate_type(config.disable_context_highlighting, "disable_context_highlighting", "boolean")
validate_type(config.disable_signs, "disable_signs", "boolean")
validate_type(config.enable_hint, "enable_hint", "boolean")
validate_type(config.enable_context_highlighting, "enable_context_highlighting", "boolean")
validate_type(config.enable_signs, "enable_signs", "boolean")
validate_type(config.telescope_sorter, "telescope_sorter", "function")
validate_type(config.use_per_project_settings, "use_per_project_settings", "boolean")
validate_type(config.remember_settings, "remember_settings", "boolean")
Expand All @@ -1113,8 +1113,8 @@ function M.validate_config()
validate_type(config.notification_icon, "notification_icon", "string")
validate_type(config.console_timeout, "console_timeout", "number")
validate_kind(config.kind, "kind")
validate_type(config.disable_line_numbers, "disable_line_numbers", "boolean")
validate_type(config.disable_relative_line_numbers, "disable_relative_line_numbers", "boolean")
validate_type(config.enable_line_numbers, "enable_line_numbers", "boolean")
validate_type(config.enable_relative_line_numbers, "enable_relative_line_numbers", "boolean")
validate_type(config.auto_show_console, "auto_show_console", "boolean")
validate_type(config.auto_show_console_on, "auto_show_console_on", "string")
validate_type(config.auto_close_console, "auto_close_console", "boolean")
Expand All @@ -1126,7 +1126,7 @@ function M.validate_config()
validate_type(config.status.mode_text, "status.mode_text", "table")
end
validate_signs()
validate_trinary_auto(config.disable_insert_on_commit, "disable_insert_on_commit")
validate_trinary_auto(config.enable_insert_on_commit, "enable_insert_on_commit")
-- Commit Editor
if validate_type(config.commit_editor, "commit_editor", "table") then
validate_type(config.commit_editor.show_staged_diff, "show_staged_diff", "boolean")
Expand Down
10 changes: 5 additions & 5 deletions lua/neogit/lib/buffer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -622,9 +622,9 @@ end
---@field context_highlight boolean|nil
---@field active_item_highlight boolean|nil
---@field open boolean|nil
---@field disable_line_numbers boolean|nil
---@field disable_relative_line_numbers boolean|nil
---@field disable_signs boolean|nil
---@field enable_line_numbers boolean|nil
---@field enable_relative_line_numbers boolean|nil
---@field enable_signs boolean|nil
---@field swapfile boolean|nil
---@field modifiable boolean|nil
---@field readonly boolean|nil
Expand Down Expand Up @@ -734,11 +734,11 @@ function Buffer.create(config)
vim.opt_local.fillchars:append("fold: ")
end)

if (config.disable_line_numbers == nil) or config.disable_line_numbers then
if not config.enable_line_numbers then
buffer:set_window_option("number", false)
end

if (config.disable_relative_line_numbers == nil) or config.disable_relative_line_numbers then
if not config.enable_relative_line_numbers then
buffer:set_window_option("relativenumber", false)
end

Expand Down
2 changes: 1 addition & 1 deletion lua/neogit/lib/signs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function M.get(name)
end

function M.setup(config)
if not config.disable_signs then
if config.enable_signs then
for key, val in pairs(config.signs) do
if key == "hunk" or key == "item" or key == "section" then
signs["NeogitClosed" .. key] = val[1]
Expand Down
22 changes: 11 additions & 11 deletions tests/specs/neogit/config_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ describe("Neogit config", function()
assert.True(vim.tbl_count(require("neogit.config").validate_config()) ~= 0)
end)

it("should return invalid when disable_hint isn't a boolean", function()
config.values.disable_hint = "not a boolean"
it("should return invalid when enable_hint isn't a boolean", function()
config.values.enable_hint = "not a boolean"
assert.True(vim.tbl_count(require("neogit.config").validate_config()) ~= 0)
end)

it("should return invalid when disable_context_highlighting isn't a boolean", function()
config.values.disable_context_highlighting = "not a boolean"
it("should return invalid when enable_context_highlighting isn't a boolean", function()
config.values.enable_context_highlighting = "not a boolean"
assert.True(vim.tbl_count(require("neogit.config").validate_config()) ~= 0)
end)

it("should return invalid when disable_signs isn't a boolean", function()
config.values.disable_signs = "not a boolean"
it("should return invalid when enable_signs isn't a boolean", function()
config.values.enable_signs = "not a boolean"
assert.True(vim.tbl_count(require("neogit.config").validate_config()) ~= 0)
end)

Expand All @@ -31,7 +31,7 @@ describe("Neogit config", function()
assert.True(vim.tbl_count(require("neogit.config").validate_config()) ~= 0)
end)

it("should return invalid when disable_insert_on_commit isn't a boolean", function()
it("should return invalid when enable_insert_on_commit isn't a boolean", function()
config.values.telescope_sorter = "not a boolean"
assert.True(vim.tbl_count(require("neogit.config").validate_config()) ~= 0)
end)
Expand Down Expand Up @@ -71,8 +71,8 @@ describe("Neogit config", function()
assert.True(vim.tbl_count(require("neogit.config").validate_config()) ~= 0)
end)

it("should return invalid when disable_line_numbers isn't a boolean", function()
config.values.disable_line_numbers = "not a boolean"
it("should return invalid when enable_line_numbers isn't a boolean", function()
config.values.enable_line_numbers = "not a boolean"
assert.True(vim.tbl_count(require("neogit.config").validate_config()) ~= 0)
end)

Expand Down Expand Up @@ -494,8 +494,8 @@ describe("Neogit config", function()
assert.True(vim.tbl_count(require("neogit.config").validate_config()) == 0)
end)

it("should return valid when disable_line_numbers is a boolean", function()
config.values.disable_line_numbers = true
it("should return valid when enable_line_numbers is a boolean", function()
config.values.enable_line_numbers = true
assert.True(vim.tbl_count(require("neogit.config").validate_config()) == 0)
end)

Expand Down
Loading