Because these are ancient methods that were only added to support
ancient versions of Vim (ie. before `execute()` existed). For context,
see:
- https://github.com/wincent/wincent/commit/
3b0b2950cdcb09d23c87f0167c207d8c837cb1b2
- https://github.com/wincent/wincent/commit/
386edd17854e609fe9dd9736524798e7057eefe7
Back in the old days, we used to capture the output of `:highlight`
with `:redir`, and it was sensitive to terminal width, which meant that
lines could wrap and wreak havoc. In newer Vim we just use `execute()`
which is width-agnostic, and in Neovim we can be even more direct
and call `nvim_exec()`. ie. instead of going Lua to Vimscript (eg.
`vim.fn.execute`) to turn a string into a command to run, we can go from
Lua directly to running the command.
Replaces newlines with spaces.
+Note that this function is not implemented in the Lua API, because it is required only for support on legacy Vim versions.
+
<p align="right"><a name="pinnaclecaptureline" href="#user-content-pinnaclecaptureline"><code>pinnacle#capture_line()</code></a></p>
### `pinnacle#capture_line()`<a name="pinnacle-pinnaclecaptureline" href="#user-content-pinnacle-pinnaclecaptureline"></a>
Useful when we don't want to let long lines on narrow windows produce unwanted embedded newlines.
+Note that this function is not implemented in the Lua API, because it is required only for support on legacy Vim versions.
+
<p align="right"><a name="pinnaclecapturehighlight" href="#user-content-pinnaclecapturehighlight"><code>pinnacle#capture_highlight()</code></a></p>
### `pinnacle#capture_highlight()`<a name="pinnacle-pinnaclecapturehighlight" href="#user-content-pinnacle-pinnaclecapturehighlight"></a>
"
" Replaces newlines with spaces.
"
+" Note that this function is not implemented in the Lua API, because it is
+" required only for support on legacy Vim versions.
+"
function! pinnacle#sub_newlines(string) abort
return tr(a:string, "\r\n", ' ')
endfunction
" Useful when we don't want to let long lines on narrow windows produce unwanted
" embedded newlines.
"
+" Note that this function is not implemented in the Lua API, because it is
+" required only for support on legacy Vim versions.
+"
function! pinnacle#capture_line(command) abort
if exists('*execute')
let l:capture=execute(a:command)
Replaces newlines with spaces.
+Note that this function is not implemented in the Lua API, because it is
+required only for support on legacy Vim versions.
+
*pinnacle#capture_line()*
pinnacle#capture_line() ~
Useful when we don't want to let long lines on narrow windows produce
unwanted embedded newlines.
+Note that this function is not implemented in the Lua API, because it is
+required only for support on legacy Vim versions.
+
*pinnacle#capture_highlight()*
pinnacle#capture_highlight() ~
-- Gets the current value of a highlight group.
pinnacle.capture_highlight = function(group)
- return pinnacle.capture_line('0verbose silent highlight ' .. group)
-end
-
--- Runs a command and returns the captured output as a single line.
---
--- Useful when we don't want to let long lines on narrow windows produce
--- unwanted embedded newlines.
-pinnacle.capture_line = function(command)
- local capture = vim.fn.execute(command)
-
- return pinnacle.sub_newlines(capture)
+ return vim.api.nvim_exec('0verbose silent highlight ' .. group, true)
end
-- Returns a copy of `group` decorated with `style` (eg. "bold",
original = before .. setting .. after
end
- return pinnacle.sub_newlines(original)
+ return original
end
end
return pinnacle.decorate('italic', group)
end
--- Replaces newlines with spaces.
-pinnacle.sub_newlines = function(string)
- return ({string:gsub('[\r\n]', ' ')})[1]
-end
-
-- Returns an underlined copy of `group` suitable for passing to
-- `:highlight`.
pinnacle.underline = function(group)