diff --git a/README.md b/README.md index 591d8168a..5247656cd 100644 --- a/README.md +++ b/README.md @@ -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 = { @@ -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 diff --git a/doc/neogit.txt b/doc/neogit.txt index c6d4ad1d5..7fe25605d 100644 --- a/doc/neogit.txt +++ b/doc/neogit.txt @@ -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, @@ -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, @@ -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 diff --git a/lua/neogit/buffers/commit_select_view/init.lua b/lua/neogit/buffers/commit_select_view/init.lua index 241b0d894..92c7ff053 100644 --- a/lua/neogit/buffers/commit_select_view/init.lua +++ b/lua/neogit/buffers/commit_select_view/init.lua @@ -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 , or to abort", scroll_header = true, diff --git a/lua/neogit/buffers/commit_view/init.lua b/lua/neogit/buffers/commit_view/init.lua index cebc9b45e..4bee1d419 100644 --- a/lua/neogit/buffers/commit_view/init.lua +++ b/lua/neogit/buffers/commit_view/init.lua @@ -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 diff --git a/lua/neogit/buffers/diff/init.lua b/lua/neogit/buffers/diff/init.lua index 53f42f86e..fc5fbff4e 100644 --- a/lua/neogit/buffers/diff/init.lua +++ b/lua/neogit/buffers/diff/init.lua @@ -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 diff --git a/lua/neogit/buffers/editor/init.lua b/lua/neogit/buffers/editor/init.lua index e2475ad25..5f34d8e8f 100644 --- a/lua/neogit/buffers/editor/init.lua +++ b/lua/neogit/buffers/editor/init.lua @@ -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 @@ -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 diff --git a/lua/neogit/buffers/log_view/init.lua b/lua/neogit/buffers/log_view/init.lua index 2dbb52890..9f4b253ef 100644 --- a/lua/neogit/buffers/log_view/init.lua +++ b/lua/neogit/buffers/log_view/init.lua @@ -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) diff --git a/lua/neogit/buffers/rebase_editor/init.lua b/lua/neogit/buffers/rebase_editor/init.lua index 10149c304..193d68972 100644 --- a/lua/neogit/buffers/rebase_editor/init.lua +++ b/lua/neogit/buffers/rebase_editor/init.lua @@ -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 diff --git a/lua/neogit/buffers/reflog_view/init.lua b/lua/neogit/buffers/reflog_view/init.lua index 8f62d78c1..86e3c2321 100644 --- a/lua/neogit/buffers/reflog_view/init.lua +++ b/lua/neogit/buffers/reflog_view/init.lua @@ -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 = { diff --git a/lua/neogit/buffers/status/init.lua b/lua/neogit/buffers/status/init.lua index 948ce5e39..294deb288 100644 --- a/lua/neogit/buffers/status/init.lua +++ b/lua/neogit/buffers/status/init.lua @@ -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) diff --git a/lua/neogit/buffers/status/ui.lua b/lua/neogit/buffers/status/ui.lua index 572b223b3..ddaf30490 100755 --- a/lua/neogit/buffers/status/ui.lua +++ b/lua/neogit/buffers/status/ui.lua @@ -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 diff --git a/lua/neogit/config.lua b/lua/neogit/config.lua index e9a5c5dcd..397d41337 100644 --- a/lua/neogit/config.lua +++ b/lua/neogit/config.lua @@ -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 @@ -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, @@ -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 @@ -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") @@ -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") @@ -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") diff --git a/lua/neogit/lib/buffer.lua b/lua/neogit/lib/buffer.lua index 2c5f31aa5..fb5ee8ef6 100644 --- a/lua/neogit/lib/buffer.lua +++ b/lua/neogit/lib/buffer.lua @@ -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 @@ -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 diff --git a/lua/neogit/lib/signs.lua b/lua/neogit/lib/signs.lua index e3dbcf55e..a9a302cf4 100644 --- a/lua/neogit/lib/signs.lua +++ b/lua/neogit/lib/signs.lua @@ -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] diff --git a/tests/specs/neogit/config_spec.lua b/tests/specs/neogit/config_spec.lua index 0d169c33c..2657c944e 100644 --- a/tests/specs/neogit/config_spec.lua +++ b/tests/specs/neogit/config_spec.lua @@ -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) @@ -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) @@ -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) @@ -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)