Skip to content

Commit

Permalink
made placeholders configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan Badragan committed May 9, 2024
1 parent f17714b commit b95103b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 17 deletions.
35 changes: 23 additions & 12 deletions lua/grug-far/opts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,21 @@ local defaultOptions = {
-- zero disables showing it
maxSearchCharsInTitles = 30,

keymaps = {
replace = '<C-enter>',
qflist = '<C-q>',
gotoLocation = '<enter>',
close = '<C-x>'
},

-- separator between inputs and results, default depends on nerdfont
resultsSeparatorLineChar = '',

-- spinner states, default depends on nerdfont, set to nil to disable
spinnerStates = {
'󱑋 ', '󱑌 ', '󱑍 ', '󱑎 ', '󱑏 ', '󱑐 ', '󱑑 ', '󱑒 ', '󱑓 ', '󱑔 ', '󱑕 ', '󱑖 '
},

-- icons for UI, default ones depend on nerdfont
icons = {
-- whether to show icons
Expand All @@ -40,19 +55,15 @@ local defaultOptions = {
resultsActionMessage = ''
},

-- separator between inputs and results, default depends on nerdfont
resultsSeparatorLineChar = '',

-- spinner states, default depends on nerdfont, set to nil to disable
spinnerStates = {
'󱑋 ', '󱑌 ', '󱑍 ', '󱑎 ', '󱑏 ', '󱑐 ', '󱑑 ', '󱑒 ', '󱑓 ', '󱑔 ', '󱑕 ', '󱑖 '
},
-- placeholders to show in inpuut areas when they are empty, set
placeholders = {
-- whether to show placeholders
enabled = true,

keymaps = {
replace = '<C-enter>',
qflist = '<C-q>',
gotoLocation = '<enter>',
close = '<C-x>'
search = "ex: foo foo([a-z0-9]*) fun\\(",
replacement = "ex: bar ${1}_foo $$MY_ENV_VAR ",
filesGlob = "ex: *.lua *.{css,js} **/docs/*.md",
flags = "ex: --hidden (-.) --ignore-case (-i) --multiline (-U) --fixed-strings (-F)",
}
}

Expand Down
10 changes: 5 additions & 5 deletions lua/grug-far/render.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ local BEFORE_RESULTS_LINES = 2
local function render(params, context)
local buf = params.buf
local inputs = context.state.inputs
local placeholders = context.options.placeholders

local lineNr = 0
ensureTopEmptyLines(buf, TOP_EMPTY_LINES)
Expand All @@ -40,7 +41,7 @@ local function render(params, context)
extmarkName = "search",
icon = 'searchInput',
label = "Search:",
placeholder = "ex: foo foo([a-z0-9]*) fun\\(",
placeholder = placeholders.enabled and placeholders.search
}, context)

vim.api.nvim_buf_set_name(buf,
Expand All @@ -53,7 +54,7 @@ local function render(params, context)
extmarkName = "replace",
icon = 'replaceInput',
label = "Replace:",
placeholder = "ex: bar ${1}_foo $$MY_ENV_VAR ",
placeholder = placeholders.enabled and placeholders.replacement
}, context)

lineNr = lineNr + 1
Expand All @@ -63,7 +64,7 @@ local function render(params, context)
extmarkName = "files_glob",
icon = 'filesFilterInput',
label = "Files Filter:",
placeholder = "ex: *.lua *.{css,js} **/docs/*.md",
placeholder = placeholders.enabled and placeholders.filesGlob
}, context))

lineNr = lineNr + 1
Expand All @@ -73,8 +74,7 @@ local function render(params, context)
extmarkName = "flags",
icon = 'flagsInput',
label = "Flags:",
-- TODO (sbadragan): make those configurable
placeholder = "ex: --hidden (-.) --ignore-case (-i) --multiline (-U) --fixed-strings (-F)",
placeholder = placeholders.enabled and placeholders.flags
}, context))

lineNr = lineNr + BEFORE_RESULTS_LINES
Expand Down

0 comments on commit b95103b

Please sign in to comment.