Compare commits

...

2 Commits

Author SHA1 Message Date
hedy c7be2982c1
nvim: Forgot to track incline config earlier 2023-11-13 22:21:04 +08:00
hedy 1f8915b0c7
nvim: Add note on outline.nvim
No more advertisement I promise, this isn't one either, anyway.
2023-11-13 22:19:29 +08:00
2 changed files with 152 additions and 2 deletions

View File

@ -121,16 +121,20 @@ return {
}
},
},
{ dir = "~/projects/outline.nvim",
{ dir = "~/projects/outline.nvim", -- See github.com/hedyhli/outline.nvim
-- Switched to this from tagbar because it does not require exctags, and it
-- lists the items in order as defined in source code.
-- See github.com/hedyhli/outline.nvim
enabled = vim.fn.has("nvim-0.7") == 1,
cmd = { "Outline", "OutlineOpen" },
keys = {
{ "<leader>tt", "<cmd>Outline<CR>", desc = "Toggle outline window" },
{ "<leader>tT", "<cmd>OutlineFollow<CR>", desc = "Focus & follow outline window" },
},
-- Unfortunately my plugins/outline.lua is not tracked in dotfiles, because
-- it is under active development and I tend to change the config quite
-- often. If you're looking for config options, you should definitely check
-- the readme and also see the sections for recipes, tips. My custom config
-- for this is not far off from the defaults.
config = function() require "plugins/outline" end,
},
-- "bling/vim-bufferline", -- I prefer this over taking over the tabline space thanks

View File

@ -0,0 +1,146 @@
local cp = require('nvim-tundra.palette.arctic')
local a = vim.api
local f = vim.fn
local mode_colors = {
n = "=Comment",
v = cp.green._500,
V = cp.green._500,
["CTRL-V"] = cp.green._500,
R = cp.red._500,
i = cp.sand._500,
s = cp.orange._500,
S = cp.orange._500,
["CTRL-S"] = cp.orange._500,
}
local function get_mode_fghl(mode)
local hl = "#Normal"
if mode_colors[mode.prefix] then
hl = mode_colors[mode.prefix]
end
if mode_colors[mode.mode] then
hl = mode_colors[mode.mode]
end
if mode.blocking then
hl = "=Error"
end
return hl
end
local function get_win_maxy()
local max_y_pos = 0
local max_y_win = 0
for _, winid in ipairs(a.nvim_list_wins()) do
local c = a.nvim_win_get_config(winid)
-- Loop only proper windows (not floating etc)
if c.relative == "" then
if max_y_pos <= a.nvim_win_get_position(winid)[1] then
max_y_win = winid
end
end
end
return max_y_win
end
function _G.Incrender(p)
-- p.buf, win, focused
-- Hide incline for bottomost win, because I have ruler
if get_win_maxy() == p.win then
return ""
end
local fp = a.nvim_buf_get_name(p.buf)
fp = f.fnamemodify(fp, ":t") or '[No Name]'
local mod = ''
if a.nvim_buf_get_option(p.buf, 'modified') then
mod = '+'
end
local mode = a.nvim_get_mode()
mode.prefix = mode.mode:sub(1,1)
mode.fghl = get_mode_fghl(mode)
local r_mode = { mode.mode, guifg = mode.fghl }
if mode.fghl:sub(1, 1) == '=' then
-- group takes higher precedence than any other hl options
r_mode.group = mode.fghl:sub(2, #mode.fghl)
end
local r = { group = "Comment", r_mode, ' ', fp, mod }
if not p.focused then
r.group = "LineNr"
r_mode.group = "LineNr"
end
return r
end
-- local render = function(props)
-- local bufname = a.nvim_buf_get_name(props.buf)
-- local res = bufname ~= '' and f.fnamemodify(bufname, ':t') or '[No Name]'
-- if a.nvim_buf_get_option(props.buf, 'modified') then
-- res = res .. ' +'
-- end
-- return res
-- end
require('incline').setup {
render = _G.Incrender,
debounce_threshold = {
falling = 50,
rising = 10
},
hide = {
cursorline = false,
focused_win = false,
only_win = true,
},
highlight = {
groups = {
InclineNormal = {
default = true,
group = "NormalFloat"
},
InclineNormalNC = {
default = true,
group = "NormalFloat"
}
}
},
ignore = {
buftypes = {},
filetypes = {},
floating_wins = true,
unlisted_buffers = true,
wintypes = {},
},
window = {
margin = {
horizontal = 0,
-- Needs = 1 if setting &lines+=1
vertical = { top = 0, bottom = 0 }
},
options = {
signcolumn = "no",
wrap = false
},
padding = 0,
padding_char = " ",
placement = {
horizontal = "right",
vertical = "bottom"
},
width = "fit",
winhighlight = {
active = {
EndOfBuffer = "None",
Normal = "InclineNormal",
Search = "None"
},
inactive = {
EndOfBuffer = "None",
Normal = "InclineNormalNC",
Search = "None"
}
},
zindex = 50
}
}