Skip to content

Commit

Permalink
docs: fix some typos / leftovers
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisgrieser committed Dec 13, 2024
1 parent 176e910 commit 02164ff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
19 changes: 9 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,11 @@ vim.keymap.set({ "o", "x" }, "is", '<cmd>lua require("various-textobjs").subword
```

For most text objects, there is only one parameter which accepts `"inner"` or
`"outer"`. There only exceptions is the `indentation` text object:
`"outer"`. The only exception is the `indentation` text object:

```lua
-- THE INDENTATION TEXTOBJ requires two parameters, the first for
-- exclusion of the starting border, the second for the exclusion of ending border
-- THE INDENTATION TEXTOBJ requires two parameters, the first for exclusion of
-- the starting border, the second for the exclusion of ending border
vim.keymap.set(
{ "o", "x" },
"ii",
Expand Down Expand Up @@ -273,8 +273,7 @@ end, { desc = "URL Opener" })
```

You could go even further: When no URL can be found by `various-textobjs`, you
could retrieve all URLs in the buffer and select one to open. (The URL-pattern
used by this plugin is exposed for this purpose.)
could retrieve all URLs in the buffer and select one to open.

```lua
vim.keymap.set("n", "gx", function()
Expand All @@ -283,23 +282,23 @@ vim.keymap.set("n", "gx", function()
if foundURL then
vim.cmd.normal('"zy')
local url = vim.fn.getreg("z")
vim.ui.open(url)
vim.ui.open(url) -- requires nvim 0.10
return
end

-- find all URLs in buffer
local urlPattern = "%l%l%l-://[^%s)]+"
local urlPattern = [[%l%l%l-://[^%s)"'`]+]]
local bufText = table.concat(vim.api.nvim_buf_get_lines(0, 0, -1, false), "\n")
local urls = {}
for url in bufText:gmatch(urlPattern) do
table.insert(urls, url)
end
if #urls == 0 then return end

-- select one, use a plugin like dressing.nvim for nicer UI for
-- `vim.ui.select`
-- select one
vim.ui.select(urls, { prompt = "Select URL:" }, function(choice)
if choice then vim.ui.open(choice) end
if not choice then return end
vim.ui.open(url) -- requires nvim 0.10
end)
end, { desc = "URL Opener" })
```
Expand Down
2 changes: 1 addition & 1 deletion lua/various-textobjs/textobjs/charwise.lua
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ function M.number(scope)
end

function M.url()
local pattern = [=[%l%l%l-://[^%s)"'`]+]=] -- excludes: )"'` and whitespace
local pattern = [[%l%l%l-://[^%s)"'`]+]] -- excludes: )"'` and whitespace
local bigForward = require("various-textobjs.config").config.forwardLooking.big
core.selectClosestTextobj(pattern, "outer", bigForward)
end
Expand Down

0 comments on commit 02164ff

Please sign in to comment.