Skip to content

Commit

Permalink
refactor: more variable name improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisgrieser committed Jun 4, 2024
1 parent 0e9eb52 commit 2409cab
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions lua/rip-substitute/popup-win.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ local function closePopupWin()
if vim.api.nvim_buf_is_valid(state.popupBufNr) then
vim.api.nvim_buf_delete(state.popupBufNr, { force = true })
end
vim.api.nvim_buf_clear_namespace(0, state.matchHlNs, 0, -1)
vim.api.nvim_buf_clear_namespace(0, state.incPreviewNs, 0, -1)
end

function M.substitute()
Expand All @@ -47,7 +47,7 @@ function M.substitute()
targetBuf = vim.api.nvim_get_current_buf(),
targetWin = vim.api.nvim_get_current_win(),
labelNs = vim.api.nvim_create_namespace("rip-substitute-labels"),
matchHlNs = vim.api.nvim_create_namespace("rip-substitute-match-hls"),
incPreviewNs = vim.api.nvim_create_namespace("rip-substitute-incpreview"),
targetFile = vim.api.nvim_buf_get_name(0),
popupBufNr = -999, -- placeholder value
popupWinNr = -999, -- placeholder value
Expand Down Expand Up @@ -109,7 +109,7 @@ function M.substitute()
group = vim.api.nvim_create_augroup("rip-substitute-popup-changes", {}),
callback = function()
ensureOnly2LinesInPopup()
rg.highlightMatches()
rg.incrementalPreview()
setPopupLabels()
end,
})
Expand Down
8 changes: 4 additions & 4 deletions lua/rip-substitute/rg-operations.lua
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ local function onEachRgResultInViewport(rgArgs, callback)
:each(callback)
end

function M.highlightMatches()
function M.incrementalPreview()
local state = require("rip-substitute.state").state
vim.api.nvim_buf_clear_namespace(state.targetBuf, state.matchHlNs, 0, -1)
vim.api.nvim_buf_clear_namespace(state.targetBuf, state.incPreviewNs, 0, -1)
local toSearch, toReplace = getSearchAndReplace()
if toSearch == "" then return end

Expand All @@ -103,7 +103,7 @@ function M.highlightMatches()
local endCol = result.col + #result.text
vim.api.nvim_buf_add_highlight(
state.targetBuf,
state.matchHlNs,
state.incPreviewNs,
toReplace == "" and "IncSearch" or "LspInlayHint",
result.lnum,
result.col,
Expand All @@ -118,7 +118,7 @@ function M.highlightMatches()
local virtText = { result.text, "IncSearch" }
vim.api.nvim_buf_set_extmark(
state.targetBuf,
state.matchHlNs,
state.incPreviewNs,
result.lnum,
result.col,
{ virt_text = { virtText }, virt_text_pos = "inline" }
Expand Down
2 changes: 1 addition & 1 deletion lua/rip-substitute/state.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ local M = {}
---@field popupBufNr number
---@field popupWinNr number
---@field labelNs number
---@field matchHlNs number
---@field incPreviewNs number
M.state = {}

---@param newState ripSubstituteState
Expand Down

0 comments on commit 2409cab

Please sign in to comment.