martanne / vis

A vi-like editor based on Plan 9's structural regular expressions
Other
4.2k stars 258 forks source link

Statusline Example #994

Closed FOSSilizedDaemon closed 1 year ago

FOSSilizedDaemon commented 2 years ago

Hello,

I have been reading over the vis editor lua API documentation in hopes of porting my custom neovim statusline to vis. While I think I generally understand what I need to do, I can't help but run into issues figuring out how to actually set things into the status bar. For example, I am trying to write a simple "hello world" status that displays the text "hello world" on the left side of the status bar. To do this I have:

require('vis')

vis.win:status("Hello World")

I know this is likely wrong, but I can not for the life of me find any examples of basic status bars for vis. Do any of you guys have some examples or did I miss something in the documentation?

Update

I have done a bit more research and was able to port a good bit of my old neovim statusline to one that works with vis. The only major thing I need help with is determining how to actually set the value of the status bar in vis.

jpaulogg commented 2 years ago

The only major thing I need help with is determining how to actually set the value of the status bar in vis.

You can edit /usr/local/share/vis/vis-std.lua file or create a plugin and load it from your visrc.

mizlan commented 2 years ago

Here's a small example. Note the subscribing to an event:

local function my_stl(win)
  local stl = ' '
  if win.file.name ~= nil then
    stl = stl .. win.file.name
  else
    stl = stl .. '(no filename)'
  end
  if win.file.modified then
    stl = stl .. ' (modified)'
  end
  if vis.recording then
    stl = stl .. ' (recording)'
  end
  win:status(stl)
end

vis.events.subscribe(vis.events.WIN_STATUS, my_stl)
mcepl commented 1 year ago

This seems like the question was answered, doesn't it?