mirror of
https://git.disroot.org/FollieHiyuki/dotfiles.git
synced 2024-12-12 17:18:22 -05:00
0b6f538235
- emacs: enable parinfer - neovim: + add config for sniprun + replace lsp-rooter.nvim with project.nvim + replace galaxyline.nvim with feline.nvim + update config for gitsigns.nvim, nvimtree and alpha-nvim
454 lines
14 KiB
Lua
454 lines
14 KiB
Lua
local M = {}
|
|
|
|
function M.dashboard_conf()
|
|
local dashboard = require('alpha.themes.dashboard')
|
|
local button = dashboard.button
|
|
|
|
dashboard.section.header = {
|
|
type = 'text',
|
|
val = {
|
|
[[<-. (`-')_ (`-') _ (`-') _ <-. (`-') ]],
|
|
[[ \( OO) ) ( OO).-/ .-> _(OO ) (_) \(OO )_ ]],
|
|
[[,--./ ,--/ (,------.(`-')----. ,--.(_/,-.\ ,-(`-'),--./ ,-.)]],
|
|
[[| \ | | | .---'( OO).-. '\ \ / (_/ | ( OO)| `.' |]],
|
|
[[| . '| |)(| '--. ( _) | | | \ / / | | )| |'.'| |]],
|
|
[[| |\ | | .--' \| |)| |_ \ /_)(| |_/ | | | |]],
|
|
[[| | \ | | `---. ' '-' '\-'\ / | |'->| | | |]],
|
|
[[`--' `--' `------' `-----' `-' `--' `--' `--']]
|
|
},
|
|
opts = {
|
|
position = 'center',
|
|
-- wrap = 'overflow',
|
|
hl = 'DashboardHeader'
|
|
}
|
|
}
|
|
|
|
dashboard.section.footer = {
|
|
type = 'text',
|
|
val = 'おかえりなさい',
|
|
opts = {
|
|
position = 'center',
|
|
hl = 'DashboardFooter'
|
|
}
|
|
}
|
|
|
|
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
|
|
|
|
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 e 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}
|
|
}
|
|
|
|
-- Hide tabline in dashboard buffer
|
|
vim.api.nvim_command [[
|
|
autocmd FileType alpha set showtabline=0 | autocmd BufUnload <buffer> set showtabline=2
|
|
]]
|
|
end
|
|
|
|
function M.statusline_conf()
|
|
local colors = require('colors.' .. vim.g.global_theme).colors
|
|
|
|
local vi_mode_colors = {
|
|
NORMAL = colors.green,
|
|
OP = colors.green,
|
|
INSERT = colors.blue,
|
|
VISUAL = colors.yellow,
|
|
LINES = colors.yellow,
|
|
BLOCK = colors.yellow,
|
|
REPLACE = colors.red,
|
|
['V-REPLACE'] = colors.red,
|
|
ENTER = colors.cyan,
|
|
MORE = colors.cyan,
|
|
SELECT = colors.orange,
|
|
COMMAND = colors.purple,
|
|
SHELL = colors.green,
|
|
TERM = colors.green,
|
|
NONE = colors.white2
|
|
}
|
|
|
|
local function file_osinfo()
|
|
local os = vim.bo.fileformat:upper()
|
|
local icon
|
|
if os == 'UNIX' then
|
|
icon = ' '
|
|
elseif os == 'MAC' then
|
|
icon = ' '
|
|
else
|
|
icon = ' '
|
|
end
|
|
return icon .. os
|
|
end
|
|
|
|
local vi_mode_utils = require('feline.providers.vi_mode')
|
|
|
|
local comps = {
|
|
dummy = {
|
|
provider = '▊',
|
|
hl = {fg = colors.blue},
|
|
right_sep = ' '
|
|
},
|
|
vi_mode = {
|
|
provider = ' ',
|
|
hl = function()
|
|
return {
|
|
name = vi_mode_utils.get_mode_highlight_name(),
|
|
fg = vi_mode_utils.get_mode_color()
|
|
}
|
|
end,
|
|
right_sep = ' '
|
|
},
|
|
filesize = {
|
|
provider = 'file_size',
|
|
hl = {fg = colors.fg, style = 'bold'},
|
|
right_sep = ' '
|
|
},
|
|
fileinfo = {
|
|
provider = {
|
|
name = 'file_info',
|
|
opts = {
|
|
file_modified_icon = ' ',
|
|
file_readonly_icon = '🔒',
|
|
type = 'base-only' -- relative, unique
|
|
}
|
|
},
|
|
hl = {fg = colors.blue, style = 'bold'},
|
|
right_sep = ' '
|
|
},
|
|
lineinfo = {
|
|
provider = 'position',
|
|
hl = {fg = colors.fg},
|
|
right_sep = ' '
|
|
},
|
|
percent = {
|
|
provider = 'line_percentage',
|
|
hl = {fg = colors.fg, style = 'bold'},
|
|
right_sep = ' '
|
|
},
|
|
diagerr = {
|
|
provider = 'diagnostic_errors',
|
|
icon = ' ',
|
|
hl = {fg = colors.red},
|
|
right_sep = ' '
|
|
},
|
|
diagwarn = {
|
|
provider = 'diagnostic_warnings',
|
|
icon = ' ',
|
|
hl = {fg = colors.yellow},
|
|
right_sep = ' '
|
|
},
|
|
diaghint = {
|
|
provider = 'diagnostic_hints',
|
|
icon = ' ',
|
|
hl = {fg = colors.cyan},
|
|
right_sep = ' '
|
|
},
|
|
diaginfo = {
|
|
provider = 'diagnostic_info',
|
|
icon = ' ',
|
|
hl = {fg = colors.blue}
|
|
},
|
|
lspclient = {
|
|
provider = 'lsp_client_names',
|
|
icon = ' LSP:',
|
|
hl = {fg = colors.purple, style = 'bold'}
|
|
},
|
|
format = {
|
|
provider = file_osinfo,
|
|
hl = {fg = colors.cyan},
|
|
left_sep = ' '
|
|
},
|
|
encode = {
|
|
provider = 'file_encoding',
|
|
hl = {fg = colors.fg},
|
|
left_sep = ' '
|
|
},
|
|
filetype = {
|
|
provider = 'file_type',
|
|
hl = {fg = colors.blue, style = 'bold'},
|
|
left_sep = ' '
|
|
},
|
|
gitbranch = {
|
|
provider = 'git_branch',
|
|
icon = ' ',
|
|
hl = {fg = colors.green, style = 'bold'},
|
|
left_sep = ' '
|
|
},
|
|
diffadd = {
|
|
provider = 'git_diff_added',
|
|
icon = ' ',
|
|
hl = {fg = colors.green},
|
|
left_sep = ' '
|
|
},
|
|
diffchange = {
|
|
provider = 'git_diff_changed',
|
|
icon = '柳',
|
|
hl = {fg = colors.yellow},
|
|
left_sep = ' '
|
|
},
|
|
diffremove = {
|
|
provider = 'git_diff_removed',
|
|
icon = ' ',
|
|
hl = {fg = colors.red},
|
|
left_sep = ' '
|
|
}
|
|
}
|
|
|
|
-- Initialize the components table before defining it
|
|
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.diagerr)
|
|
table.insert(components.active[1], comps.diagwarn)
|
|
table.insert(components.active[1], comps.diaghint)
|
|
table.insert(components.active[1], 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 = {bg = colors.grey1, fg = colors.fg},
|
|
components = components,
|
|
vi_mode_colors = vi_mode_colors,
|
|
force_inactive = {
|
|
filetypes = {
|
|
'packer',
|
|
'NvimTree',
|
|
'alpha',
|
|
'undotree',
|
|
'DIFF',
|
|
'Outline'
|
|
},
|
|
buftypes = {'terminal', 'nofile'},
|
|
bufnames = {}
|
|
}
|
|
}
|
|
end
|
|
|
|
function M.bufferline_conf()
|
|
require('bufferline').setup {
|
|
options = {
|
|
numbers = 'none',
|
|
max_name_length = 16,
|
|
max_prefix_length = 14,
|
|
tab_size = 20,
|
|
diagnostics = 'nvim_lsp',
|
|
show_close_icon = false,
|
|
show_buffer_icons = true,
|
|
show_tab_indicators = true,
|
|
enforce_regular_tabs = false,
|
|
show_buffer_close_icons = true,
|
|
always_show_bufferline = true,
|
|
offsets = {
|
|
{filetype = 'NvimTree', text = 'NvimTree', text_align = 'left'},
|
|
{filetype = 'packer', text = 'Packer', text_align = 'left'}
|
|
},
|
|
separator_style = 'thin'
|
|
},
|
|
highlights = {
|
|
fill = {guibg = {attribute = 'bg', highlight = 'TabLineFill'}},
|
|
indicator_selected = {guifg = {attribute = 'fg', highlight = 'TabLineSel'}}
|
|
}
|
|
}
|
|
end
|
|
|
|
function M.nvimtree_conf()
|
|
vim.g.nvim_tree_width = 35
|
|
vim.g.nvim_tree_ignore = {'.git', '.hg', '.svn', 'node_modules'}
|
|
vim.g.nvim_tree_auto_ignore_ft = {'dashboard'}
|
|
vim.g.nvim_tree_respect_buf_cwd = 1
|
|
vim.g.nvim_tree_indent_markers = 1
|
|
vim.g.nvim_tree_git_hl = 1
|
|
vim.g.nvim_tree_auto_resize = 0
|
|
-- vim.g.nvim_tree_add_trailing = 1
|
|
vim.g.nvim_tree_lsp_diagnostics = 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 = ''
|
|
},
|
|
lsp = {
|
|
hint = '',
|
|
info = '',
|
|
warning = '',
|
|
error = ''
|
|
}
|
|
}
|
|
end
|
|
|
|
function M.whichkey_conf()
|
|
require('which-key').setup {
|
|
plugins = {
|
|
spelling = {
|
|
enabled = true,
|
|
suggestions = 30
|
|
}
|
|
},
|
|
icons = {
|
|
breadcrumb = '»',
|
|
separator = 'ﰲ',
|
|
group = '+'
|
|
},
|
|
layout = {
|
|
align = 'center'
|
|
}
|
|
}
|
|
end
|
|
|
|
function M.gitsigns_conf()
|
|
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\' : \'<cmd>lua require"gitsigns.actions".next_hunk()<CR>\''},
|
|
['n [g'] = {expr = true, '&diff ? \'[g\' : \'<cmd>lua require"gitsigns.actions".prev_hunk()<CR>\''},
|
|
|
|
['n <leader>gs'] = '<cmd>lua require"gitsigns".stage_hunk()<CR>',
|
|
['v <leader>gs'] = '<cmd>lua require"gitsigns".stage_hunk({vim.fn.line("."), vim.fn.line("v")})<CR>',
|
|
['n <leader>gu'] = '<cmd>lua require"gitsigns".undo_stage_hunk()<CR>',
|
|
['n <leader>gr'] = '<cmd>lua require"gitsigns".reset_hunk()<CR>',
|
|
['v <leader>gr'] = '<cmd>lua require"gitsigns".reset_hunk({vim.fn.line("."), vim.fn.line("v")})<CR>',
|
|
['n <leader>gR'] = '<cmd>lua require"gitsigns".reset_buffer()<CR>',
|
|
['n <leader>gp'] = '<cmd>lua require"gitsigns".preview_hunk()<CR>',
|
|
['n <leader>gb'] = '<cmd>lua require"gitsigns".blame_line(true)<CR>',
|
|
['n <leader>gS'] = '<cmd>lua require"gitsigns".stage_buffer()<CR>',
|
|
['n <leader>gU'] = '<cmd>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
|
|
},
|
|
current_line_blame = false,
|
|
current_line_blame_opts = {
|
|
delay = 1000,
|
|
virt_text = true,
|
|
virt_text_pos = 'eol'
|
|
},
|
|
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 = {
|
|
internal = true -- If luajit is present
|
|
}
|
|
}
|
|
end
|
|
|
|
return M
|