neovim-confs/lua/custom/plugins/ui.lua

672 lines
23 KiB
Lua
Raw Normal View History

2024-07-04 19:08:31 +02:00
local custom_headers = {
-- stylua: ignore
sharp = {
[[ ]],
[[ █ ████████ █████ ███████ ████ ]],
[[ ███ ██████ █████ █████████ ██████ ]],
[[ █████ ██████████████████████ ████ ███████████████ ]],
[[ ██ ██ █████ █████████████ ████ ████████████████ ]],
[[ ████ ███████████████ █████████ ████ █████ ██████ ████ ]],
[[ ██████ ██████ ███ █████████ ████ █████ █████ ████ ]],
[[ ████████ ███████████████████ ████ ████ █████ ████ ████ ]],
[[ ]],
[[ 🛠️ Sharp tools make good work 🖥️ ]],
[[ ]],
}
,
}
2024-07-04 10:55:27 +02:00
return {
{
'nvim-tree/nvim-tree.lua',
2024-07-04 12:31:24 +02:00
cmd = { 'NvimTreeToggle', 'NvimTreeFocus' },
2024-07-04 17:08:26 +02:00
opts = {
filters = {
dotfiles = false,
exclude = { vim.fn.stdpath 'config' .. '/lua/custom' },
},
disable_netrw = true,
hijack_netrw = true,
hijack_cursor = true,
hijack_unnamed_buffer_when_opening = false,
sync_root_with_cwd = true,
update_focused_file = {
enable = true,
update_root = false,
},
view = {
adaptive_size = false,
side = 'left',
width = 30,
preserve_window_proportions = true,
},
git = {
enable = false,
ignore = true,
},
filesystem_watchers = {
enable = true,
},
actions = {
open_file = {
resize_window = true,
},
},
renderer = {
root_folder_label = false,
highlight_git = false,
highlight_opened_files = 'none',
indent_markers = {
enable = false,
},
icons = {
show = {
file = true,
folder = true,
folder_arrow = true,
git = false,
},
glyphs = {
default = '󰈚',
symlink = '',
folder = {
default = '',
empty = '',
empty_open = '',
open = '',
symlink = '',
symlink_open = '',
arrow_open = '',
arrow_closed = '',
},
git = {
unstaged = '',
staged = '',
unmerged = '',
renamed = '',
untracked = '',
deleted = '',
ignored = '',
},
},
},
},
},
2024-07-04 12:31:24 +02:00
config = function(_, opts)
require('nvim-tree').setup(opts)
end,
2024-07-04 12:09:09 +02:00
keys = {
{ '<F5>', '<cmd> NvimTreeToggle <cr>', desc = '[T]oggle [F]ile explorer' },
{ '<leader>tf', '<cmd> NvimTreeToggle <cr>', desc = '[T]oggle [F]ile explorer' },
},
2024-07-04 10:55:27 +02:00
},
{
'ggandor/leap.nvim',
lazy = false,
2024-07-04 16:20:45 +02:00
keys = {
{ 's', '<plug>(leap-forward)', desc = 'leap forward' },
{ 'S', '<plug>(leap-backward)', desc = 'leap backward' },
{ 'gs', '<plug>(leap-from-window)', desc = 'leap from window' },
},
2024-07-04 10:55:27 +02:00
},
{
'ggandor/flit.nvim',
lazy = false,
config = function()
require('flit').setup {
keys = { f = 'f', F = 'F', t = 't', T = 'T' },
-- A string like "nv", "nvo", "o", etc.
labeled_modes = 'v',
multiline = true,
-- Like `leap`s similar argument (call-specific overrides).
-- E.g.: opts = { equivalence_classes = {} }
opts = {},
}
end,
},
{
'kdheepak/lazygit.nvim',
2024-07-04 16:20:45 +02:00
keys = {
{ '<leader>gg', '<cmd>LazyGit<cr>', desc = 'Open LazyGit' },
},
2024-07-04 10:55:27 +02:00
cmd = 'LazyGit',
-- optional for floating window border decoration
dependencies = {
'nvim-lua/plenary.nvim',
},
},
{
'folke/which-key.nvim',
keys = { '<leader>', '<localleader>', '<c-r>', '<c-w>', '"', "'", '`', 'c', 'v', 'g' },
defaults = {
mode = { 'n', 'v' },
[';'] = { name = '+telescope' },
[';f'] = { name = '+find' },
['g'] = { name = '+goto' },
[']'] = { name = '+next' },
['['] = { name = '+prev' },
2024-07-04 12:41:35 +02:00
['<leader>d'] = { name = '+lsp/debug' },
['<leader>r'] = { name = '+diagnostics/quickfix' },
2024-07-04 10:55:27 +02:00
['<leader>c'] = { name = '+code' },
['<leader>g'] = { name = '+git' },
['<leader>t'] = { name = '+toggle/tools' },
['<leader>w'] = { name = '+window/which' },
['<leader>f'] = { name = '+formatting' },
},
opts = {
triggers_nowait = {
-- marks
'`',
"'",
'g`',
"g'",
-- registers
'"',
'<c-r>',
-- spelling
'z=',
2024-07-04 17:08:26 +02:00
'o',
'O',
2024-07-04 10:55:27 +02:00
},
triggers_blacklist = {
-- list of mode / prefixes that should never be hooked by WhichKey
-- this is mostly relevant for keymaps that start with a native binding
i = { 'j', 'k' },
v = { 'j', 'k' },
n = { 'o', 'O' },
},
},
},
{
'echasnovski/mini.trailspace',
lazy = false,
event = { 'BufReadPost', 'BufNewFile' },
2024-07-04 19:03:42 +02:00
opts = {
only_in_normal_buffers = true,
},
2024-07-04 10:55:27 +02:00
},
{
'itchyny/vim-cursorword',
event = 'FileType',
init = function()
vim.g.cursorword = 0
end,
config = function()
local augroup = vim.api.nvim_create_augroup('plex_cursorword', {})
vim.api.nvim_create_autocmd('FileType', {
group = augroup,
pattern = {
'conf',
'dosini',
'json',
'markdown',
'nginx',
'text',
'yaml',
},
callback = function()
if vim.wo.diff or vim.wo.previewwindow then
vim.b.cursorword = 0
else
vim.b.cursorword = 1
end
end,
})
vim.api.nvim_create_autocmd('InsertEnter', {
group = augroup,
callback = function()
if vim.b['cursorword'] == 1 then
vim.b['cursorword'] = 0
end
end,
})
vim.api.nvim_create_autocmd('InsertLeave', {
group = augroup,
callback = function()
if vim.b['cursorword'] == 0 then
vim.b['cursorword'] = 1
end
end,
})
end,
},
2024-07-04 14:43:32 +02:00
{ -- Useful plugin to show you pending keybinds.
'folke/which-key.nvim',
event = 'VimEnter', -- Sets the loading event to 'VimEnter'
config = function() -- This is the function that runs, AFTER loading
require('which-key').setup()
2024-07-04 10:55:27 +02:00
2024-07-04 14:43:32 +02:00
-- Document existing key chains
require('which-key').register {
['<leader>c'] = { name = '[C]ode', _ = 'which_key_ignore' },
['<leader>d'] = { name = '[D]ocument', _ = 'which_key_ignore' },
['<leader>r'] = { name = '[R]ename', _ = 'which_key_ignore' },
['<localleader>f'] = { name = '[F]ind', _ = 'which_key_ignore' },
['<leader>w'] = { name = '[W]orkspace', _ = 'which_key_ignore' },
['<leader>t'] = { name = '[T]oggle', _ = 'which_key_ignore' },
['<leader>h'] = { name = 'Git [H]unk', _ = 'which_key_ignore' },
}
-- visual mode
require('which-key').register({
['<leader>h'] = { 'Git [H]unk' },
}, { mode = 'v' })
end,
},
2024-07-04 10:55:27 +02:00
{
'RRethy/vim-illuminate',
lazy = false,
event = { 'BufReadPost', 'BufNewFile' },
opts = {
delay = 200,
under_cursor = false,
modes_allowlist = { 'n', 'no', 'nt' },
filetypes_denylist = {
'DiffviewFileHistory',
'DiffviewFiles',
'SidebarNvim',
'fugitive',
'git',
'minifiles',
'neo-tree',
},
},
keys = {
{ ']]', desc = 'Next Reference' },
{ '[[', desc = 'Prev Reference' },
},
config = function(_, opts)
require('illuminate').configure(opts)
local function map(key, dir, buffer)
vim.keymap.set('n', key, function()
require('illuminate')['goto_' .. dir .. '_reference'](false)
end, {
desc = dir:sub(1, 1):upper() .. dir:sub(2) .. ' Reference',
buffer = buffer,
})
end
map(']]', 'next')
map('[[', 'prev')
-- also set it after loading ftplugins, since a lot overwrite [[ and ]]
vim.api.nvim_create_autocmd('FileType', {
group = vim.api.nvim_create_augroup('plex_illuminate', {}),
callback = function()
local buffer = vim.api.nvim_get_current_buf()
map(']]', 'next', buffer)
map('[[', 'prev', buffer)
end,
})
end,
},
{
'folke/todo-comments.nvim',
lazy = false,
dependencies = 'nvim-telescope/telescope.nvim',
-- stylua: ignore
keys = {
{ ']t', function() require('todo-comments').jump_next() end, desc = 'Next todo comment' },
{ '[t', function() require('todo-comments').jump_prev() end, desc = 'Previous todo comment' },
2024-07-04 17:19:47 +02:00
{ '<LocalLeader>fdt', '<cmd>TodoTelescope<CR>', desc = 'todo' },
2024-07-04 10:55:27 +02:00
{ '<leader>xt', '<cmd>TodoTrouble<CR>', desc = 'Todo (Trouble)' },
{ '<leader>xT', '<cmd>TodoTrouble keywords=TODO,FIX,FIXME<cr>', desc = 'Todo/Fix/Fixme (Trouble)' },
},
opts = {
signs = true,
keywords = {
FIX = {
icon = '', -- icon used for the sign, and in search results
color = 'error', -- can be a hex color, or a named color (see below)
alt = { 'FIXME', 'BUG', 'FIXIT', 'ISSUE' }, -- a set of other keywords that all map to this FIX keywords
},
TODO = { icon = '', color = 'todo' },
HACK = { icon = '', color = 'hack' },
SECURITY = { icon = '󰒃 ', color = 'security' },
WARN = { icon = '', color = 'warning', alt = { 'WARNING', 'XXX' } },
PERF = { icon = '', color = 'perf', alt = { 'OPTIM', 'PERFORMANCE', 'OPTIMIZE' } },
NOTE = { icon = '', color = 'hint', alt = { 'INFO' } },
TEST = { icon = '', color = 'test', alt = { 'TESTING', 'PASSED', 'FAILED' } },
},
colors = {
error = { 'DiagnosticError', 'ErrorMsg', '#DC2626' },
warning = { 'DiagnosticWarn', 'WarningMsg', '#FBBF24' },
todo = { 'DiagnosticTodo', '#80e64d' },
hint = { 'DiagnosticHint', '#10B981' },
hack = { 'DiagnosticHack', '#FF33FF' },
security = { 'DiagnosticSecurity', '#FF6600' },
default = { 'Identifier', '#7C3AED' },
test = { 'DiagnosticTest', '#E6E600' },
perf = { 'DiagnosticPerf', '#9999ff' },
},
},
},
2024-07-04 14:43:32 +02:00
{
'akinsho/toggleterm.nvim',
keys = {
2024-07-04 16:20:45 +02:00
{ '<F12>', mode = { 't', 'n', 'v' }, '<cmd>exe v:count1 "ToggleTerm direction=float"<cr>', desc = 'Toggle a big floating terminal' },
{ '<A-i>', mode = { 't', 'n', 'v' }, '<cmd>exe v:count1 "ToggleTerm direction=float"<cr>', desc = 'Toggle a big floating terminal' },
{ '<A-t>', mode = { 't', 'n', 'v' }, '<cmd>exe v:count1 "ToggleTerm direction=tab"<cr>', desc = 'Toggle a terminal in a new tab' },
{ '<A-h>', mode = { 't', 'n', 'v' }, '<cmd>exe v:count1 "ToggleTerm direction=horizontal"<cr>', desc = 'Toggle a horizontal terminal' },
{ '<A-v>', mode = { 't', 'n', 'v' }, '<cmd>exe v:count1 "ToggleTerm direction=vertical"<cr>', desc = 'Toggle a vertical terminal' },
2024-07-04 14:43:32 +02:00
},
cmd = 'ToggleTerm',
opts = {
size = function(term)
if term.direction == 'horizontal' then
return vim.o.lines * 0.35
elseif term.direction == 'vertical' then
return vim.o.columns * 0.35
else
return 20
end
end,
open_mapping = false,
float_opts = {
border = 'curved',
},
},
},
2024-07-04 15:24:34 +02:00
{
'folke/noice.nvim',
enabled = not vim.g.started_by_firenvim,
event = 'VeryLazy',
-- config.lsp.signature.enabled = false
dependencies = {
-- if you lazy-load any plugin below, make sure to add proper `module="..."` entries
'MunifTanjim/nui.nvim',
-- OPTIONAL:
-- `nvim-notify` is only needed, if you want to use the notification view.
-- If not available, we use `mini` as the fallback
'rcarriga/nvim-notify',
},
config = function()
require('notify').setup {
top_down = false,
}
require('noice').setup {
lsp = {
override = {
['vim.lsp.util.convert_input_to_markdown_lines'] = true,
['vim.lsp.util.stylize_markdown'] = true,
['cmp.entry.get_documentation'] = true,
},
-- IDK how to disable the nvchad builtins for this, which would
-- produce a conflict
signature = { enabled = false },
hover = { enabled = false },
progress = {
enabled = true,
-- Lsp Progress is formatted using the builtins for lsp_progress. See config.format.builtin
-- See the section on formatting for more details on how to customize.
--- @type NoiceFormat|string
format = 'lsp_progress',
--- @type NoiceFormat|string
format_done = 'lsp_progress_done',
throttle = 1000 / 30, -- frequency to update lsp progress message
view = 'mini', -- default: mini
},
},
-- you can enable a preset for easier configuration
presets = {
bottom_search = true, -- use a classic bottom cmdline for search
command_palette = true, -- position the cmdline and popupmenu together
long_message_to_split = true, -- long messages will be sent to a split
inc_rename = true, -- enables an input dialog for inc-rename.nvim
lsp_doc_border = true, -- add a border to hover docs and signature help
},
messages = {
enabled = true,
-- NOTE: we keep it with notify,
-- change this to something else if you want
view_error = 'notify',
},
popupmenu = {
enabled = true,
},
notify = {
enabled = true,
},
}
end,
},
{
'stevearc/dressing.nvim',
init = function()
---@diagnostic disable-next-line: duplicate-set-field
vim.ui.select = function(...)
require('lazy').load { plugins = { 'dressing.nvim' } }
return vim.ui.select(...)
end
---@diagnostic disable-next-line: duplicate-set-field
vim.ui.input = function(...)
require('lazy').load { plugins = { 'dressing.nvim' } }
return vim.ui.input(...)
end
end,
},
{
'chentoast/marks.nvim',
lazy = false,
dependencies = 'lewis6991/gitsigns.nvim',
event = 'FileType',
opts = {
sign_priority = { lower = 10, upper = 15, builtin = 8, bookmark = 20 },
bookmark_1 = { sign = '󰉀' }, -- ⚐ ⚑ 󰈻 󰈼 󰈽 󰈾 󰈿 󰉀
},
},
{
'Bekaboo/deadcolumn.nvim',
event = { 'BufReadPre', 'BufNewFile' },
},
{
'kevinhwang91/nvim-ufo',
event = { 'BufReadPost', 'BufNewFile' },
-- stylua: ignore
keys = {
{ 'zR', function() require('ufo').openAllFolds() end },
{ 'zM', function() require('ufo').closeAllFolds() end },
},
dependencies = {
'kevinhwang91/promise-async',
'nvim-treesitter/nvim-treesitter',
'neovim/nvim-lspconfig',
},
opts = function()
-- fancy display function for folds (stolen from nvim-ufo readme)
local handler = function(virtText, lnum, endLnum, width, truncate)
local newVirtText = {}
local suffix = (' 󰁂 %d '):format(endLnum - lnum)
local sufWidth = vim.fn.strdisplaywidth(suffix)
local targetWidth = width - sufWidth
local curWidth = 0
for _, chunk in ipairs(virtText) do
local chunkText = chunk[1]
local chunkWidth = vim.fn.strdisplaywidth(chunkText)
if targetWidth > curWidth + chunkWidth then
table.insert(newVirtText, chunk)
else
chunkText = truncate(chunkText, targetWidth - curWidth)
local hlGroup = chunk[2]
table.insert(newVirtText, { chunkText, hlGroup })
chunkWidth = vim.fn.strdisplaywidth(chunkText)
-- str width returned from truncate() may less than 2nd argument, need padding
if curWidth + chunkWidth < targetWidth then
suffix = suffix .. (' '):rep(targetWidth - curWidth - chunkWidth)
end
break
end
curWidth = curWidth + chunkWidth
end
table.insert(newVirtText, { suffix, 'MoreMsg' })
return newVirtText
end
require('ufo').setup {
-- use treesitter to get the folds
provider_selector = function(bufnr, filetype, buftype)
return { 'treesitter', 'indent' }
end,
-- apply out fancy fold display
fold_virt_text_handler = handler,
}
end,
},
{
'b0o/incline.nvim',
event = 'FileType',
config = function()
local function get_diagnostic_label(props)
local icons = { error = '', warn = '', info = '', hint = '' }
local label = {}
for severity, icon in pairs(icons) do
local n = #vim.diagnostic.get(props.buf, { severity = vim.diagnostic.severity[string.upper(severity)] })
if n > 0 then
table.insert(label, { icon .. ' ' .. n .. ' ', group = 'DiagnosticSign' .. severity })
end
end
if #label > 0 then
table.insert(label, { '| ' })
end
return label
end
local function get_git_diff(props)
local icons = { removed = '', changed = '', added = '' }
local labels = {}
-- local signs = vim.api.nvim_buf_get_var(props.buf, "gitsigns_status_dict")
-- local signs = vim.b.gitsigns_status_dict
-- for name, icon in pairs(icons) do
-- if tonumber(signs[name]) and signs[name] > 0 then
-- table.insert(labels, { icon .. " " .. signs[name] .. " ", group = "Diff" .. name })
-- end
-- end
if #labels > 0 then
table.insert(labels, { '| ' })
end
return labels
end
require('incline').setup {
render = function(props)
local filename = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(props.buf), ':t')
local ft_icon, ft_color = require('nvim-web-devicons').get_icon_color(filename)
local modified = vim.api.nvim_buf_get_option(props.buf, 'modified') and 'bold,italic' or 'bold'
local buffer = {
{ get_diagnostic_label(props) },
{ get_git_diff(props) },
{ ft_icon, guifg = ft_color },
{ ' ' },
{ filename, gui = modified },
}
return buffer
end,
}
end,
},
{
'iamcco/markdown-preview.nvim',
cmd = { 'MarkdownPreviewToggle', 'MarkdownPreview', 'MarkdownPreviewStop' },
ft = { 'markdown' },
build = function()
vim.fn['mkdp#util#install']()
end,
config = function()
-- Ugly fix for wsl not finding my browser
-- I HATE windows
vim.g.mkdp_echo_preview_url = 1
end,
},
{
'nvim-lualine/lualine.nvim',
lazy = false,
dependencies = {
'nvim-tree/nvim-web-devicons',
'NvChad/ui', -- load after nvchad ui
},
config = function()
-- TODO: add lsp module for lualine
-- Maybe we can steal modules from the nvchad ui
2024-07-04 17:51:23 +02:00
require('lualine').setup {}
end,
},
{
'akinsho/bufferline.nvim',
dependencies = {
'nvim-tree/nvim-web-devicons',
{
'tiagovla/scope.nvim',
config = function()
require('scope').setup {}
end,
},
},
config = function()
vim.opt.termguicolors = true
require('bufferline').setup {}
2024-07-04 15:24:34 +02:00
end,
},
2024-07-04 19:03:42 +02:00
{
'MeanderingProgrammer/dashboard.nvim',
event = 'VimEnter',
dependencies = {
'MaximilianLloyd/ascii.nvim',
},
init = function()
vim.api.nvim_create_autocmd({ 'BufWinEnter', 'VimEnter' }, {
pattern = { 'dashboard', 'text', 'help', '*' },
callback = function()
vim.b.minitrailspace_disable = true
vim.opt_local.list = false
vim.opt_local.colorcolumn = '0'
end,
})
end,
config = function()
-- Do not show trailing space in unmodifiable types
require('dashboard').setup {
-- Dashboard header
2024-07-04 19:08:31 +02:00
header = custom_headers.sharp,
2024-07-04 19:03:42 +02:00
-- List of directory paths, or functions that return paths
directories = {
'~/.config/nvim',
'~/Documents/code',
'~/Documents/novel',
},
-- Format to display date in
2024-07-04 19:23:32 +02:00
date_format = '%Y-%m-%d %H:%M:%S',
2024-07-04 19:03:42 +02:00
-- Sections to add at bottom, these can be string references to
-- functions in sections.lua, custom strings, or custom functions
2024-07-04 19:23:32 +02:00
footer = {
[[  Find File ;ff ]],
[[ 󰈚 Recent Files ;fo ]],
[[  Find Word ;fw ]],
[[  Bookmarks ;fm ]],
[[  Theme ;ft ]],
[[  Git ␣ft ]],
[[  Change Directory ;cd ]],
[[  Files F5 ]],
[[  Terminal F12 ]],
},
2024-07-04 19:03:42 +02:00
-- Gets called after directory is changed and is provided with the
-- directory path as an argument
on_load = function(path)
-- Do nothing
end,
-- Highlight groups to use for various components
highlight_groups = {
header = 'Constant',
icon = 'Type',
directory = 'Delimiter',
hotkey = 'Statement',
},
}
end,
},
2024-07-04 10:55:27 +02:00
}