Skip to content

Instantly share code, notes, and snippets.

@zardoz03
Created March 19, 2026 23:04
Show Gist options
  • Select an option

  • Save zardoz03/fd3ea49f7bd1a113a90a17a6cf506a3e to your computer and use it in GitHub Desktop.

Select an option

Save zardoz03/fd3ea49f7bd1a113a90a17a6cf506a3e to your computer and use it in GitHub Desktop.
require('vis')
require('vis-std')
buffer_local_settings = { }
function buffer_local_settings.apply_settings(win)
local file = win.file
local lines = file.lines
for i=1, #lines do
if i > 10 then
if i > (#lines - 10) then
goto process
end
goto continue
end
::process::
local l = lines[i]
--[[ HACK:
this uses all letters instead of getting something like,
scintillua information about comments, so
--]]
local strti, endi = l:find("^.+ ?vis: ")
-- vis:message(string.format("%s->%s", strti, endi))
local options_str = nil
if type(endi) == "number" then
options_str = l:sub(endi, #l)
end
if options_str == nil then
goto continue
end
for k, v in options_str:gmatch("(%w*)=(%w*)")do
local s = string.format("set %s %s", k, v)
vis:message(s)
vis:command(s)
win:draw()
end
::continue::
end
end
vis:command_register("apply_bufferlocal_settings", function(argv, force, win, sel, r)
return buffer_local_settings.apply_settings(win)
end, "Sets window settings based on buffer contents at the start of the file")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment