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

306 lines
10 KiB
Lua
Raw Normal View History

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' },
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,
},
{
'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 14:43:32 +02:00
keys = { '<leader>gg', '<cmd> LazyGit <cr>', '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=',
},
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' },
opts = {},
},
{
'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' },
{ '<LocalLeader>dt', '<cmd>TodoTelescope<CR>', desc = 'todo' },
{ '<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
{
'folke/trouble.nvim',
cmd = 'Trouble',
opts = { use_diagnostic_signs = true },
-- stylua: ignore
keys = {
{ '<leader>rb', "<cmd>Trouble diagnostics toggle filter.buf=0<cr>", desc = 'Document Diagnostics (Trouble)' },
{ '<leader>rr', '<cmd>Trouble diagnostics toggle<cr>', desc = 'Workspace Diagnostics (Trouble)' },
{ '<leader>rq', "<cmd>Trouble qflist toggle<cr>", desc = 'Quickfix List (Trouble)' },
{ '<leader>rl', "<cmd>Trouble loclist toggle<cr>", desc = 'Location List (Trouble)' },
{ '<leader>rd', "<cmd>Trouble symbols<cr>", desc = 'LSP symbols (Trouble)' },
{ '<leader>rt', "<cmd>Trouble todo<cr>", desc = 'Todos (Trouble)' },
{
'[q',
function()
if require('trouble').is_open() then
require('trouble').previous({ skip_groups = true, jump = true })
else
vim.cmd.cprev()
end
end,
desc = 'Previous trouble/quickfix item',
},
{
']q',
function()
if require('trouble').is_open() then
require('trouble').next({ skip_groups = true, jump = true })
else
vim.cmd.cnext()
end
end,
desc = 'Next trouble/quickfix item',
},
},
},
{
'akinsho/toggleterm.nvim',
keys = {
{ '<F12>', '<cmd>exe v:count1 "ToggleTerm direction=float"<cr>', desc = 'Toggle a big floating terminal' },
{ '<A-i>', '<cmd>exe v:count1 "ToggleTerm direction=float"<cr>', desc = 'Toggle a big floating terminal' },
{ '<A-t>', '<cmd>exe v:count1 "ToggleTerm direction=tab"<cr>', desc = 'Toggle a terminal in a new tab' },
{ '<A-h>', '<cmd>exe v:count1 "ToggleTerm direction=horizontal"<cr>', desc = 'Toggle a horizontal terminal' },
{ '<A-v>', '<cmd>exe v:count1 "ToggleTerm direction=vertical"<cr>', desc = 'Toggle a vertical terminal' },
},
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 10:55:27 +02:00
}