How can I use fennel to configure vis?
See the vis cookbook on the fennel wiki.
See the presentation Configuring Vis with Fennel from FennelConf 2021.
How can I spellcheck the current file?
A solution without using any plugins could be something in the style of :!aspell -t -c $vis_filepath (modify aspell(1) options to work with the spellchecker of your choice). More polished solution is to use vis-spellcheck vis plugin.
How do I open the current file in a repl?
Lua:
:!lua -i $vis_filename
Python:
:!python -i $vis_filename
Guile Scheme:
:!guile -l $vis_filename
Javascript:
!node -i -e "$(< $vis_filename)"
How do I wrap lines to 80 characters wide?
Using command mode, pipe selected text into fold, wrap or fmt:
:|fold -w 80 -s
:|wrap -w 80
:|fmt -w 80
There is vis-par plugin, but it is in a very rudimentary state yet (although, it is already quite useful for day-to-day use).
Integrate with external window manager
From the README:
There exist plans to use a client/server architecture, delegating window management to your windowing system or favorite terminal multiplexer.
See also issue #130.
That said, there are some workarounds:
vis:command_register('xsp', function(argv)
local file = vis.win.file
local path = argv[1] or file.path
if not os.getenv("DISPLAY") then
vis:info("Error: $DISPLAY doesn't exist")
return
end
local cmd = string.format('st -e vis "%s" &', path)
os.execute(cmd)
end, "Open file in a new X11 window")
vis:command_register('tsp', function(argv)
local file = vis.win.file
local path = argv[1] or file.path
local fifo = os.getenv("DVTM_CMD_FIFO")
if not fifo then
vis:info("Error: $DVTM_CMD_FIFO doesn't exist")
return
end
local cmd = string.format([[echo 'create "vis %s"' >> %s]],
path:gsub(" ", "\\ "), fifo)
os.execute(cmd)
end, "Open file in a new dvtm(1) window")
Using and Piping to awk
Unlike tools like tr and sed which transform text and leave it as is, awk does not do that. Here is an example
; echo this | tr -s '[:lower:]' '[:upper:]' | wc
1 1 5
; echo this | sed 's/this/that/' | wc
1 1 5
; echo -n this | tr -s '[:lower:]' '[:upper:]' | wc
0 1 4
; echo -n this | sed 's/this/that/' | wc
0 1 4
awk does not work this way, awk reads a chunk of text until it finds the record separator (RS), and it throws away the separator itself, you don't know if there is an RS, which means doing transformations is trickier
; echo this | awk 'BEGIN {ORS=""} {print $0}' | wc
0 1 4
; echo -n this | awk 'BEGIN {ORS=""} {print $0}' | wc
0 1 4
As you can see, because RS gets read and chucked, portable awk is not capable of indicating if there is an RS before EOF, gawk is the only one that keeps RS by saving it in the RT (record terminator) variable.
; echo -n this | gawk 'BEGIN {ORS=""} {print $0 RT}' | wc
0 1 4
; echo this | gawk 'BEGIN {ORS=""} {print $0 RT}' | wc
1 1 5
A semi portable version can exist, on most awks, if RS is multiple characters, it is defined as a regex, which means all you need to do is define a regex that is an impossibility, everything gets read and nothing gets chucked away. be aware that posix leaves RS having multiple characters as unspecified, but most awks have this feature.
| awk 'BEGIN {RS="^$";ORS=""} {print $0}'
Another solution you could do is modify the input itself and always append a newline
| cat - <(echo) | awk 'NR>1 {print ""} {printf("%s",$0)}'