dotfiles-ansible/roles/nvim/files/nvim/lua/modules/ui/config.lua

424 lines
14 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

local M = {}
function M.dashboard()
math.randomseed(os.time()) -- For random footer
local dashboard = require('alpha.themes.dashboard')
dashboard.section.header = {
type = 'text',
val = {
[[<-. (`-')_ (`-') _ (`-') _ <-. (`-') ]],
[[ \( OO) ) ( OO).-/ .-> _(OO ) (_) \(OO )_ ]],
[[,--./ ,--/ (,------.(`-')----. ,--.(_/,-.\ ,-(`-'),--./ ,-.)]],
[[| \ | | | .---'( OO).-. '\ \ / (_/ | ( OO)| `.' |]],
[[| . '| |)(| '--. ( _) | | | \ / / | | )| |'.'| |]],
[[| |\ | | .--' \| |)| |_ \ /_)(| |_/ | | | |]],
[[| | \ | | `---. ' '-' '\-'\ / | |'->| | | |]],
[[`--' `--' `------' `-----' `-' `--' `--' `--']]
},
opts = {
position = 'center',
-- wrap = 'overflow',
hl = 'DashboardHeader'
}
}
local footers = {
[[☆*:.。. o(≧▽≦)o .。.:*☆]],
[[°˖✧ ◝(⁰▿⁰)◜✧˖°]],
[[✿ ♬ ゚+.(。◡‿◡)♪.+ ゚♬ ✿ ]],
[[— ฅ/ᐠ. ̫ .ᐟ\ฅ —]],
[[/ᐠ_ ꞈ _ᐟ\ɴʏᴀ~]]
}
dashboard.section.footer = {
type = 'text',
val = footers[math.random(#footers)],
opts = {
position = 'center',
hl = 'DashboardFooter'
}
}
dashboard.button = function(sc, txt, keybind, keybind_opts)
local sc_ = sc:gsub('%s', ''):gsub('SPC', '<leader>')
local opts = {
position = 'center',
shortcut = sc,
cursor = 5,
width = 50,
align_shortcut = 'right',
hl = 'DashboardCenter',
hl_shortcut = 'DashboardShortcut',
}
if keybind then
keybind_opts = vim.F.if_nil(keybind_opts, {noremap = true, silent = true, nowait = true})
opts.keymap = {'n', sc_, keybind, keybind_opts}
end
local function on_press()
local key = vim.api.nvim_replace_termcodes(sc_ .. '<Ignore>', true, false, true)
vim.api.nvim_feedkeys(key, 'normal', false)
end
return {
type = 'button',
val = txt,
on_press = on_press,
opts = opts,
}
end
local button = dashboard.button
dashboard.section.buttons = {
type = 'group',
val = {
button('SPC f g', ' Find word'),
button('SPC f f', ' Find file'),
button('SPC f o', ' Recent files'),
button('SPC f d', 'ﱮ Recent directories'),
button('SPC f m', ' Bookmarks'),
button('SPC f p', ' Projects'),
button('SPC s l', ' Load last session')
},
opts = {spacing = 1}
}
require('alpha').setup {
layout = {
{type = 'padding', val = 4},
dashboard.section.header,
{type = 'padding', val = 2},
dashboard.section.buttons,
dashboard.section.footer
},
opts = {margin = 5}
}
end
function M.statusline()
-- Initialize the components table before defining it
local comps = require('modules.ui.components')
local components = {
active = {},
inactive = {}
}
table.insert(components.active, {})
table.insert(components.active, {})
table.insert(components.active, {})
table.insert(components.inactive, {})
table.insert(components.inactive, {})
table.insert(components.active[1], comps.dummy)
table.insert(components.active[1], comps.vi_mode)
table.insert(components.active[1], comps.filesize)
table.insert(components.active[1], comps.fileinfo)
table.insert(components.active[1], comps.lineinfo)
table.insert(components.active[1], comps.percent)
-- table.insert(components.active[1], comps.gps)
table.insert(components.active[3], comps.codeact)
table.insert(components.active[3], comps.diagerr)
table.insert(components.active[3], comps.diagwarn)
table.insert(components.active[3], comps.diaghint)
table.insert(components.active[3], comps.diaginfo)
table.insert(components.active[3], comps.lspclient)
table.insert(components.active[3], comps.format)
table.insert(components.active[3], comps.encode)
table.insert(components.active[3], comps.filetype)
table.insert(components.active[3], comps.gitbranch)
table.insert(components.active[3], comps.diffadd)
table.insert(components.active[3], comps.diffchange)
table.insert(components.active[3], comps.diffremove)
table.insert(components.inactive[1], comps.dummy)
table.insert(components.inactive[1], comps.fileinfo)
table.insert(components.inactive[2], comps.filetype)
require('feline').setup {
colors = comps.normal_colors,
components = components,
vi_mode_colors = comps.vi_mode_colors,
force_inactive = {
filetypes = {
'packer',
'dashboard',
'alpha',
'NvimTree',
'undotree',
'DIFF',
'TROUBLE',
'Outline'
},
buftypes = {'terminal', 'nofile'},
bufnames = {}
}
}
end
function M.bufferline()
require('bufferline').setup {
options = {
numbers = 'none',
max_name_length = 16,
max_prefix_length = 13,
tab_size = 16,
diagnostics = false,
show_close_icon = false,
show_buffer_icons = true,
show_tab_indicators = true,
enforce_regular_tabs = false,
show_buffer_close_icons = false,
always_show_bufferline = true,
offsets = {
{filetype = 'NvimTree', text = 'NvimTree', text_align = 'center'},
{filetype = 'packer', text = 'Packer', text_align = 'center'}
},
separator_style = 'thin'
},
highlights = {
fill = {guibg = {attribute = 'bg', highlight = 'TabLineFill'}},
indicator_selected = {guifg = {attribute = 'fg', highlight = 'TabLineSel'}}
}
}
end
-- FIX: wait for config migration to setup()
function M.nvimtree()
vim.g.nvim_tree_gitignore = 1
vim.g.nvim_tree_ignore = {'.git', '.hg', '.svn', 'node_modules'}
vim.g.nvim_tree_auto_ignore_ft = {'dashboard', 'alpha'}
vim.g.nvim_tree_indent_markers = 1
vim.g.nvim_tree_git_hl = 1
vim.g.nvim_tree_highlight_opened_files = 1
-- vim.g.nvim_tree_add_trailing = 1
-- vim.g.nvim_tree_disable_window_picker = 1
-- vim.g.nvim_tree_symlink_arrow = ' ➛ '
vim.g.nvim_tree_respect_buf_cwd = 1
-- vim.g.nvim_tree_create_in_closed_folder = 1
vim.g.nvim_tree_icons = {
default = '',
symlink = '',
git = {
unstaged = '',
staged = '',
unmerged = '',
renamed = '',
untracked = '',
deleted = '',
ignored = ''
},
folder = {
arrow_open = '',
arrow_closed = '',
default = '',
open = '',
empty = '',
empty_open = '',
symlink = '',
symlink_open = ''
}
}
require('nvim-tree').setup {
open_on_setup = false,
ignore_ft_on_setup = {'dashboard', 'alpha'},
auto_close = true,
open_on_tab = false,
hijack_cursor = true,
update_cwd = true,
update_to_buf_dir = {
enable = false,
auto_open = true
},
diagnostics = {
enable = true,
icons = {
hint = '',
info = '',
warning = '',
error = ''
}
},
update_focused_file = {
enable = true,
update_cwd = true,
ignore_list = {}
},
system_open = {
cmd = 'xdg-open',
args = {}
},
filters = {
dotfiles = false
},
git = {
enable = true,
ignore = false,
timeout = 500
},
view = {
width = 35,
hide_root_folder = false,
side = 'left',
auto_resize = false,
number = false,
relativenumber = false
}
}
end
function M.whichkey()
require('which-key').setup {
plugins = {
spelling = {
enabled = true,
suggestions = 30
}
},
icons = {
breadcrumb = '»',
separator = '',
group = '+'
},
layout = {
align = 'center'
}
}
end
function M.gitsigns()
require('gitsigns').setup {
signs = {
add = {hl = 'DiffAdd' , text = '', numhl='GitSignsAddNr'},
change = {hl = 'DiffChange', text = '', numhl='GitSignsChangeNr'},
delete = {hl = 'DiffDelete', text = '', numhl='GitSignsDeleteNr'},
topdelete = {hl = 'DiffDelete', text = '', numhl='GitSignsDeleteNr'},
changedelete = {hl = 'DiffChange', text = '', numhl='GitSignsChangeNr'}
},
signcolumn = false,
numhl = true,
linehl = false,
word_diff = false,
keymaps = {
-- Default keymap options
noremap = true,
['n ]g'] = {expr = true, '&diff ? \']g\' : \':lua require"gitsigns.actions".next_hunk()<CR>\''},
['n [g'] = {expr = true, '&diff ? \'[g\' : \':lua require"gitsigns.actions".prev_hunk()<CR>\''},
['n <leader>gs'] = ':lua require"gitsigns".stage_hunk()<CR>',
['v <leader>gs'] = ':lua require"gitsigns".stage_hunk({vim.fn.line("."), vim.fn.line("v")})<CR>',
['n <leader>gu'] = ':lua require"gitsigns".undo_stage_hunk()<CR>',
['n <leader>gr'] = ':lua require"gitsigns".reset_hunk()<CR>',
['v <leader>gr'] = ':lua require"gitsigns".reset_hunk({vim.fn.line("."), vim.fn.line("v")})<CR>',
['n <leader>gR'] = ':lua require"gitsigns".reset_buffer()<CR>',
['n <leader>gp'] = ':lua require"gitsigns".preview_hunk()<CR>',
['n <leader>gb'] = ':lua require"gitsigns".blame_line{full = true}<CR>',
['n <leader>gS'] = ':lua require"gitsigns".stage_buffer()<CR>',
['n <leader>gU'] = ':lua require"gitsigns".reset_buffer_index()<CR>',
-- Text objects
['o ih'] = ':<C-U>lua require"gitsigns.actions".select_hunk()<CR>',
['x ih'] = ':<C-U>lua require"gitsigns.actions".select_hunk()<CR>'
},
watch_gitdir = {
interval = 1000,
follow_files = true
},
attach_to_untracked = true,
current_line_blame = false,
current_line_blame_opts = {
delay = 1000,
virt_text = true,
virt_text_pos = 'right_align',
ignore_whitespace = false
},
current_line_blame_formatter_opts = {
relative_time = false
},
sign_priority = 6,
update_debounce = 100,
status_formatter = nil, -- Use default
max_file_length = 40000,
preview_config = {
-- Options passed to nvim_open_win
border = 'single',
style = 'minimal',
relative = 'cursor',
row = 0,
col = 1
},
yadm = {
enable = false
},
diff_opts = {
algorithm = 'myers', -- others: 'minimal', 'patience', 'histogram'
internal = true -- If luajit is present
}
}
end
-- function M.gps()
-- require('nvim-gps').setup {
-- icons = {
-- ['class-name'] = '𝓒 ',
-- ['function-name'] = 'ƒ ',
-- ['method-name'] = ' ',
-- ['container-name'] = ' ',
-- ['tag-name'] = '炙'
-- },
-- -- Add custom configuration per language or
-- -- Disable the plugin for a language
-- -- Any language not disabled here is enabled by default
-- languages = {
-- -- Some languages have custom icons
-- ['json'] = {
-- icons = {
-- ['array-name'] = ' ',
-- ['object-name'] = ' ',
-- ['null-name'] = '[] ',
-- ['boolean-name'] = 'ﰰﰴ ',
-- ['number-name'] = '# ',
-- ['string-name'] = ' '
-- }
-- },
-- ['toml'] = {
-- icons = {
-- ['table-name'] = ' ',
-- ['array-name'] = ' ',
-- ['boolean-name'] = 'ﰰﰴ ',
-- ['date-name'] = ' ',
-- ['date-time-name'] = ' ',
-- ['float-name'] = ' ',
-- ['inline-table-name'] = ' ',
-- ['integer-name'] = '# ',
-- ['string-name'] = ' ',
-- ['time-name'] = ' '
-- }
-- },
-- ['verilog'] = {
-- icons = {
-- ['module-name'] = ' '
-- }
-- },
-- ['yaml'] = {
-- icons = {
-- ['mapping-name'] = ' ',
-- ['sequence-name'] = ' ',
-- ['null-name'] = '[] ',
-- ['boolean-name'] = 'ﰰﰴ ',
-- ['integer-name'] = '# ',
-- ['float-name'] = ' ',
-- ['string-name'] = ' '
-- }
-- }
-- },
-- separator = '  ',
-- depth = 0,
-- depth_limit_indicator = '..'
-- }
-- end
return M