diff options
Diffstat (limited to '.config/vis/plugins/vis-modal')
| -rw-r--r-- | .config/vis/plugins/vis-modal/LICENSE | 15 | ||||
| -rw-r--r-- | .config/vis/plugins/vis-modal/README.md | 65 | ||||
| -rw-r--r-- | .config/vis/plugins/vis-modal/init.lua | 99 |
3 files changed, 179 insertions, 0 deletions
diff --git a/.config/vis/plugins/vis-modal/LICENSE b/.config/vis/plugins/vis-modal/LICENSE new file mode 100644 index 0000000..d9641a4 --- /dev/null +++ b/.config/vis/plugins/vis-modal/LICENSE @@ -0,0 +1,15 @@ + vis-modal is a status line colorizer for vis + Copyright (C) 2026 dacctal + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. diff --git a/.config/vis/plugins/vis-modal/README.md b/.config/vis/plugins/vis-modal/README.md new file mode 100644 index 0000000..de00c42 --- /dev/null +++ b/.config/vis/plugins/vis-modal/README.md @@ -0,0 +1,65 @@ +<div align="center"> + <h1> + modal + </h1> +</div> + +<div align="center"> + a status line colorizer for vis +</div> + +# Installation +To install vis-modal, clone this repository in your `~/.config/vis/plugins/` directory: +``` +git clone https://git.symlinx.net/vis-modal ~/.config/vis/plugins/vis-modal +``` +Then, you can use it with the default configuration by putting this into your `~/.config/vis/visrc.lua`: +```lua +local modal = require('plugins/vis-modal') +``` + +# Customization +You can change the colors and mode descriptors in vis-modal to your liking, with this template: +``` +local modal = require('plugins/vis-modal') + +modal.MODES = { + [vis.modes.NORMAL] = ' NORMAL ', + [vis.modes.INSERT] = ' INSERT ', + [vis.modes.VISUAL] = ' VISUAL ', + [vis.modes.REPLACE] = ' REPLACE ', + [vis.modes.VISUAL_LINE] = ' VISUAL_LINE ', + [vis.modes.OPERATOR_PENDING] = ' OPERATOR_PENDING ' +} + +modal.STYLES = { + [vis.modes.NORMAL] = { + REGULAR = 'fore:default,back:yellow', + INVERTED = 'fore:yellow,back:black', + }, + [vis.modes.INSERT] = { + REGULAR = 'fore:default,back:green', + INVERTED = 'fore:green,back:black', + }, + [vis.modes.VISUAL] = { + REGULAR = 'fore:default,back:magenta', + INVERTED = 'fore:magenta,back:black', + }, + [vis.modes.REPLACE] = { + REGULAR = 'fore:default,back:blue', + INVERTED = 'fore:blue,back:black', + }, + [vis.modes.VISUAL_LINE] = { + REGULAR = 'fore:default,back:magenta', + INVERTED = 'fore:magenta,back:black', + }, + [vis.modes.OPERATOR_PENDING] = { + REGULAR = 'fore:default,back:blue', + INVERTED = 'fore:blue,back:black', + }, + UNFOCUSED = { + REGULAR = 'fore:default,back:white', + INVERTED = 'fore:white,back:black', + }, +} +``` diff --git a/.config/vis/plugins/vis-modal/init.lua b/.config/vis/plugins/vis-modal/init.lua new file mode 100644 index 0000000..38b1424 --- /dev/null +++ b/.config/vis/plugins/vis-modal/init.lua @@ -0,0 +1,99 @@ +--[[ + + modal + the status line colorizer for vis + +]] + +require('vis') + +local M = {} + +local MODAL_STYLE = 51 +local MODAL_STYLE_INVERTED = 52 + +local MODES = { + [vis.modes.NORMAL] = ' NORMAL ', + [vis.modes.INSERT] = ' INSERT ', + [vis.modes.VISUAL] = ' VISUAL ', + [vis.modes.REPLACE] = ' REPLACE ', + [vis.modes.VISUAL_LINE] = ' VISUAL_LINE ', + [vis.modes.OPERATOR_PENDING] = ' OPERATOR_PENDING ', +} +M.MODES = MODES + + +local STYLES = { + [vis.modes.NORMAL] = { + REGULAR = 'fore:default,back:yellow', + INVERTED = 'fore:yellow,back:black', + }, + [vis.modes.INSERT] = { + REGULAR = 'fore:default,back:green', + INVERTED = 'fore:green,back:black', + }, + [vis.modes.VISUAL] = { + REGULAR = 'fore:default,back:magenta', + INVERTED = 'fore:magenta,back:black', + }, + [vis.modes.REPLACE] = { + REGULAR = 'fore:default,back:blue', + INVERTED = 'fore:blue,back:black', + }, + [vis.modes.VISUAL_LINE] = { + REGULAR = 'fore:default,back:magenta', + INVERTED = 'fore:magenta,back:black', + }, + [vis.modes.OPERATOR_PENDING] = { + REGULAR = 'fore:default,back:blue', + INVERTED = 'fore:blue,back:black', + }, + UNFOCUSED = { + REGULAR = 'fore:default,back:white', + INVERTED = 'fore:white,back:black', + }, +} +M.STYLES = STYLES + +vis.events.subscribe(vis.events.WIN_STATUS, function(win) + local modified = '' + if win.file.modified then modified = ' *' end + local filename = ' [NO NAME]'..modified..' ' + if win.file.name then filename = ' '..win.file.name..modified..' ' end + local vmode = MODES[vis.mode] + local recording = '' + if vis.recording then + recording = ' @ RECORDING' + end + status_left = vmode..filename..recording + + cursors = 0 + for _ in win:selections_iterator() do cursors = cursors+1 end + selection_size = "SELECTION_SIZE: ".. + win.selection.range.finish - win.selection.range.start + cursor_amount = "CURSORS: "..cursors + cursor_pos = win.selection.line..":"..win.selection.col + status_right = selection_size.." | "..cursor_amount.." | "..cursor_pos + + win:status(status_left, status_right) + + for win in vis:windows() do + if win == vis.win then + win:style_define(MODAL_STYLE, STYLES[vis.mode].REGULAR) + win:style_define(MODAL_STYLE_INVERTED, STYLES[vis.mode].INVERTED) + else + win:style_define(MODAL_STYLE, STYLES.UNFOCUSED.REGULAR) + win:style_define(MODAL_STYLE_INVERTED, STYLES.UNFOCUSED.INVERTED) + end + end + + for i=0,win.width do + win:style_pos(MODAL_STYLE, i, win.height - 1) + end + for i=string.len(vmode),string.len(vmode)+string.len(filename)-1 do + win:style_pos(MODAL_STYLE_INVERTED, i, win.height - 1) + end +end) + + +return M |
