diff --git a/README.md b/README.md index bc512be5..b889805c 100644 --- a/README.md +++ b/README.md @@ -138,7 +138,7 @@ in the `Replace:` input. You can use `match` to refer to each match and need to `return` the value you want to be the replacement. In the case of the `astgrep` engine, you will also have access to the meta variables by accessing them through the -`vars` table. ex: `$A` is referred to by `vars.A`, `$$$ARGS` is referred to by `vars.ARGS`. +`vars` table. e.g. `$A` is referred to by `vars.A`, `$$$ARGS` is referred to by `vars.ARGS`. It is a similar situation for the `vimscript` interpreter. @@ -204,14 +204,14 @@ open the search history as a buffer. From there you can pick an entry that will Note that you can edit the history buffer and save just like any other buffer if you need to do some cleanup. The format of a history entry is: ``` - + Engine: (|lua)? Search: Replace: Files Filter: Flags: ``` -where `` can span multiple line with the aid of a "continuation prefix" (`| `). ex: +where `` can span multiple line with the aid of a "continuation prefix" (`| `). e.g. ``` Replace: something | additional replace text diff --git a/doc/grug-far.txt b/doc/grug-far.txt index 4cbf9b5c..107dc5d3 100644 --- a/doc/grug-far.txt +++ b/doc/grug-far.txt @@ -87,7 +87,7 @@ require('grug-far').toggle_instance({config}) *grug-far.toggle_instance()* require('grug-far').toggle_flags({flags}) *grug-far.toggle_flags()* Toggles given list of flags in the current grug-far buffer. The flags get added to/removed from the Flags input line. - ex: require('grug-far).toggle_flags({'--fixed-strings'}). + e.g. require('grug-far).toggle_flags({'--fixed-strings'}). Parameters: ~ {flags}(table) List of flag strings to toggle. diff --git a/lua/grug-far/opts.lua b/lua/grug-far/opts.lua index 393f5f9c..b2400f16 100644 --- a/lua/grug-far/opts.lua +++ b/lua/grug-far/opts.lua @@ -58,12 +58,12 @@ M.defaultOptions = { -- whether to show placeholders enabled = true, - search = 'ex: foo foo([a-z0-9]*) fun\\(', - replacement = 'ex: bar ${1}_foo $$MY_ENV_VAR ', - replacement_lua = 'ex: if vim.startsWith(match, "use") \\n then return "employ" .. match \\n else return match end', - filesFilter = 'ex: *.lua *.{css,js} **/docs/*.md (specify one per line)', - flags = 'ex: --help --ignore-case (-i) --replace= (empty replace) --multiline (-U)', - paths = 'ex: /foo/bar ../ ./hello\\ world/ ./src/foo.lua ~/.config', + search = 'e.g. foo foo([a-z0-9]*) fun\\(', + replacement = 'e.g. bar ${1}_foo $$MY_ENV_VAR ', + replacement_lua = 'e.g. if vim.startsWith(match, "use") \\n then return "employ" .. match \\n else return match end', + filesFilter = 'e.g. *.lua *.{css,js} **/docs/*.md (specify one per line)', + flags = 'e.g. --help --ignore-case (-i) --replace= (empty replace) --multiline (-U)', + paths = 'e.g. /foo/bar ../ ./hello\\ world/ ./src/foo.lua ~/.config', }, }, -- see https://ast-grep.github.io @@ -81,12 +81,12 @@ M.defaultOptions = { -- whether to show placeholders enabled = true, - search = 'ex: $A && $A() foo.bar($$$ARGS) $_FUNC($_FUNC)', - replacement = 'ex: $A?.() blah($$$ARGS)', - replacement_lua = 'ex: return vars.A == "blah" and "foo(" .. table.concat(vars.ARGS, ", ") .. ")" or match', - filesFilter = 'ex: *.lua *.{css,js} **/docs/*.md (specify one per line, filters via ripgrep)', - flags = 'ex: --help (-h) --debug-query=ast --rewrite= (empty replace) --strictness=', - paths = 'ex: /foo/bar ../ ./hello\\ world/ ./src/foo.lua ~/.config', + search = 'e.g. $A && $A() foo.bar($$$ARGS) $_FUNC($_FUNC)', + replacement = 'e.g. $A?.() blah($$$ARGS)', + replacement_lua = 'e.g. return vars.A == "blah" and "foo(" .. table.concat(vars.ARGS, ", ") .. ")" or match', + filesFilter = 'e.g. *.lua *.{css,js} **/docs/*.md (specify one per line, filters via ripgrep)', + flags = 'e.g. --help (-h) --debug-query=ast --rewrite= (empty replace) --strictness=', + paths = 'e.g. /foo/bar ../ ./hello\\ world/ ./src/foo.lua ~/.config', }, }, }, @@ -102,9 +102,9 @@ M.defaultOptions = { -- Supported: -- * 'default': treat replacement as a string to pass to the current engine -- * 'lua': treat replacement as lua function body where search match is identified by `match` and - -- meta variables (with astgrep for example) are available in `vars` table (ex: `vars.A` captures `$A`) + -- meta variables (with astgrep for example) are available in `vars` table (e.g. `vars.A` captures `$A`) -- * 'vimscript': treat replacement as vimscript function body where search match is identified by `match` and - -- meta variables (with astgrep for example) are available in `vars` table (ex: `vars.A` captures `$A`) + -- meta variables (with astgrep for example) are available in `vars` table (e.g. `vars.A` captures `$A`) enabledReplacementInterpreters = { 'default', 'lua', 'vimscript' }, -- which replacement interprer to use @@ -157,7 +157,7 @@ M.defaultOptions = { -- shortcuts for the actions you see at the top of the buffer -- set to '' or false to unset. Mappings with no normal mode value will be removed from the help header -- you can specify either a string which is then used as the mapping for both normal and insert mode - -- or you can specify a table of the form { [mode] = } (ex: { i = '', n = 'gr'}) + -- or you can specify a table of the form { [mode] = } (e.g. { i = '', n = 'gr'}) -- it is recommended to use though as that is more vim-ish -- see https://learnvimscriptthehardway.stevelosh.com/chapters/11.html#local-leader keymaps = { diff --git a/tests/screenshots/tests-astgrep-test_search.lua---can-search-for-some-string-with-placeholders-on b/tests/screenshots/tests-astgrep-test_search.lua---can-search-for-some-string-with-placeholders-on index 64873016..9cb62296 100644 --- a/tests/screenshots/tests-astgrep-test_search.lua---can-search-for-some-string-with-placeholders-on +++ b/tests/screenshots/tests-astgrep-test_search.lua---can-search-for-some-string-with-placeholders-on @@ -4,13 +4,13 @@ 03|  Search: 04| grug 05|  Replace: -06| ex: $A?.() blah($$$ARGS) +06| e.g. $A?.() blah($$$ARGS) 07|  Files Filter: -08| ex: *.lua *.{css,js} **/docs/*.md (specify one per line, filters via ... +08| e.g. *.lua *.{css,js} **/docs/*.md (specify one per line, filters via ... 09| 󰮚 Flags: -10| ex: --help (-h) --debug-query=ast --rewrite= (empty replace) --strictness= ... +10| e.g. --help (-h) --debug-query=ast --rewrite= (empty replace) --strictness= ... 11|  Paths: -12| ex: /foo/bar ../ ./hello\ world/ ./src/foo.lua ~/.config +12| e.g. /foo/bar ../ ./hello\ world/ ./src/foo.lua ~/.config 13| 14| STATUS_SUCCESS ⟪ astgrep ⟫ 15| 2 matches in 1 files diff --git a/tests/screenshots/tests-base-test_search.lua---can-search-for-some-string-with-placeholders-on b/tests/screenshots/tests-base-test_search.lua---can-search-for-some-string-with-placeholders-on index 4fbca66c..34d50409 100644 --- a/tests/screenshots/tests-base-test_search.lua---can-search-for-some-string-with-placeholders-on +++ b/tests/screenshots/tests-base-test_search.lua---can-search-for-some-string-with-placeholders-on @@ -4,13 +4,13 @@ 03|  Search: 04|grug 05|  Replace: -06|ex: bar ${1}_foo $$MY_ENV_VAR +06|e.g. bar ${1}_foo $$MY_ENV_VAR 07|  Files Filter: -08|ex: *.lua *.{css,js} **/docs/*.md (specify one per line) +08|e.g. *.lua *.{css,js} **/docs/*.md (specify one per line) 09| 󰮚 Flags: -10|ex: --help --ignore-case (-i) --replace= (empty replace) --multiline (-U) +10|e.g. --help --ignore-case (-i) --replace= (empty replace) --multiline (-U) 11|  Paths: -12|ex: /foo/bar ../ ./hello\ world/ ./src/foo.lua ~/.config +12|e.g. /foo/bar ../ ./hello\ world/ ./src/foo.lua ~/.config 13| 14| STATUS_SUCCESS ⟪ ripgrep ⟫ 15| 4 matches in 2 files