FollieHiyuki-dotfiles/home/.config/nvim/lua/modules/ui.lua
FollieHiyuki 3cefe864f4
neovim: big refractor
- nvim-compe -> nvim-cmp
- combine multple modules config into category files
- add some more plugins
2021-10-17 21:48:10 +07:00

402 lines
13 KiB
Lua
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. 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_conf()
-- vim.g.dashboard_disable_at_vimenter = 1
-- vim.g.dashboard_disable_statusline = 1
vim.g.dashboard_preview_file_height = 12
vim.g.dashboard_preview_file_width = 80
vim.g.dashboard_default_executive = 'telescope'
vim.g.dashboard_session_directory = vim.fn.stdpath('data') .. '/sessions'
vim.g.dashboard_custom_section = {
a = {description = {' Find File SPC f f'}, command = 'DashboardFindFile'},
b = {description = {' Recents SPC f o'}, command = 'DashboardFindHistory'},
c = {description = {' Find Word SPC f g'}, command = 'DashboardFindWord'},
d = {description = {'洛 New File SPC b n'}, command = 'DashboardNewFile'},
e = {description = {' Bookmarks SPC f m'}, command = 'DashboardJumpMark'}
}
vim.g.dashboard_custom_header = {
" ",
" ",
" ",
"<-. (`-')_ (`-') _ (`-') _ <-. (`-') ",
" \\( OO) ) ( OO).-/ .-> _(OO ) (_) \\(OO )_ ",
",--./ ,--/ (,------.(`-')----. ,--.(_/,-.\\ ,-(`-'),--./ ,-.)",
"| \\ | | | .---'( OO).-. '\\ \\ / (_/ | ( OO)| `.' |",
"| . '| |)(| '--. ( _) | | | \\ / / | | )| |'.'| |",
"| |\\ | | .--' \\| |)| |_ \\ /_)(| |_/ | | | |",
"| | \\ | | `---. ' '-' '\\-'\\ / | |'->| | | |",
"`--' `--' `------' `-----' `-' `--' `--' `--'",
}
vim.g.dashboard_custom_footer = {
'おかえりなさい'
}
end
function M.statusline_conf()
local gl = require('galaxyline')
local gls = gl.section
local condition = require('galaxyline.condition')
local colors = require('colors.' .. vim.g.global_theme).colors
gl.short_line_list = {'NvimTree', 'packer', 'Outline'}
gls.left[1] = {
LeftCorner = {
provider = function()
return ''
end,
highlight = {colors.blue, colors.grey1}
}
}
gls.left[2] = {
ViMode = {
provider = function()
local mode_color = {
n = colors.green, -- Normal
no = colors.green, -- N-Pending
i = colors.blue, -- Insert
ic = colors.blue, -- Insert
v = colors.yellow, -- Visual
[''] = colors.yellow, -- V-Block
V = colors.yellow, -- V-Line
c = colors.white2, -- Command
s = colors.purple, -- Select
S = colors.purple, -- S-Line
[''] = colors.purple, -- S-Block
R = colors.red, -- Replace
Rv = colors.red, -- V-Replace
cv = colors.white2, -- Vim-Ex
ce = colors.white2, -- Ex
r = colors.cyan, -- Prompt
rm = colors.cyan, -- More
['r?'] = colors.cyan, -- Confirm
['!'] = colors.orange, -- Shell
t = colors.orange -- Terminal
}
vim.api.nvim_command('hi GalaxyViMode guifg=' .. mode_color[vim.fn.mode()])
return ''
end,
highlight = {colors.green, colors.grey1}
}
}
gls.left[3] = {
FileSize = {
provider = 'FileSize',
condition = condition.buffer_not_empty,
highlight = {colors.fg, colors.grey1}
}
}
gls.left[4] ={
FileIcon = {
provider = 'FileIcon',
condition = condition.buffer_not_empty,
highlight = {
require('galaxyline.provider_fileinfo').get_file_icon_color,
colors.grey1
}
}
}
gls.left[5] = {
FileName = {
provider = 'FileName',
condition = condition.buffer_not_empty,
highlight = {colors.fg, colors.grey1, 'bold'}
}
}
gls.left[6] = {
LineInfo = {
provider = 'LineColumn',
highlight = {colors.fg, colors.grey1}
}
}
gls.left[7] = {
PerCent = {
provider = 'LinePercent',
highlight = {colors.fg, colors.grey1, 'bold'}
}
}
gls.left[8] = {
DiagnosticError = {
provider = 'DiagnosticError',
icon = '',
highlight = {colors.red, colors.grey1}
}
}
gls.left[9] = {
DiagnosticWarn = {
provider = 'DiagnosticWarn',
icon = '',
highlight = {colors.yellow, colors.grey1}
}
}
gls.left[10] = {
DiagnosticHint = {
provider = 'DiagnosticHint',
icon = '',
highlight = {colors.cyan, colors.grey1}
}
}
gls.left[11] = {
DiagnosticInfo = {
provider = 'DiagnosticInfo',
icon = '',
highlight = {colors.blue, colors.grey1}
}
}
gls.right[1] = {
ShowLspClient = {
provider = 'GetLspClient',
condition = function ()
local tbl = {['dashboard'] = true, [''] = true}
if tbl[vim.bo.filetype] then
return false
end
return true
end,
icon = ' LSP:',
highlight = {colors.purple, colors.grey1, 'bold'}
}
}
gls.right[2] = {
FileEncode = {
provider = 'FileEncode',
condition = condition.hide_in_width,
separator = ' ',
separator_highlight = {'NONE', colors.grey1},
highlight = {colors.fg, colors.grey1}
}
}
gls.right[3] = {
FileFormat = {
provider = 'FileFormat',
condition = condition.hide_in_width,
separator = ' ',
separator_highlight = {'NONE', colors.grey1},
highlight = {colors.fg, colors.grey1}
}
}
gls.right[4] = {
GitIcon = {
provider = function() return '' end,
condition = condition.check_git_workspace,
separator = ' ',
separator_highlight = {'NONE', colors.grey1},
highlight = {colors.green, colors.grey1, 'bold'}
}
}
gls.right[5] = {
GitBranch = {
provider = 'GitBranch',
condition = condition.check_git_workspace,
highlight = {colors.green, colors.grey1, 'bold'}
}
}
gls.right[6] = {
GitSeparator = {
provider = function()
return ' '
end,
highlight = {colors.green, colors.grey1}
}
}
gls.right[7] = {
DiffAdd = {
provider = 'DiffAdd',
condition = condition.hide_in_width,
icon = '',
highlight = {colors.green, colors.grey1}
}
}
gls.right[8] = {
DiffModified = {
provider = 'DiffModified',
condition = condition.hide_in_width,
icon = '',
highlight = {colors.yellow, colors.grey1}
}
}
gls.right[9] = {
DiffRemove = {
provider = 'DiffRemove',
condition = condition.hide_in_width,
icon = '',
highlight = {colors.red, colors.grey1}
}
}
gls.short_line_left[1] = {
BufferType = {
provider = 'FileTypeName',
separator = ' ',
separator_highlight = {'NONE', colors.grey1},
highlight = {colors.blue, colors.grey1, 'bold'}
}
}
gls.short_line_left[2] = {
SFileName = {
provider = 'SFileName',
condition = condition.buffer_not_empty,
highlight = {colors.fg, colors.grey1, 'bold'}
}
}
gls.short_line_right[1] = {
BufferIcon = {
provider= 'BufferIcon',
highlight = {colors.fg, colors.grey1}
}
}
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'
}
}
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_open = 0
vim.g.nvim_tree_auto_close = 1
vim.g.nvim_tree_auto_ignore_ft = {'dashboard'}
vim.g.nvim_tree_follow = 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'}
},
numhl = true,
keymaps = {
-- Default keymap options
noremap = true,
buffer = 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>'
},
watch_index = {
interval = 1000,
follow_files = true
},
current_line_blame = false,
current_line_blame_opts = {
delay = 1000,
virt_text = true,
virt_text_pos = 'eol'
},
sign_priority = 6,
update_debounce = 100,
status_formatter = nil, -- Use default
word_diff = false,
use_internal_diff = true -- If luajit is present
}
end
return M