-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: extract related configs into ui
- Loading branch information
Showing
11 changed files
with
259 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,201 @@ | ||
return { | ||
-- better vim.ui | ||
{ | ||
'stevearc/dressing.nvim', | ||
lazy = true, | ||
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, | ||
}, | ||
|
||
-- tabs, which include filetype icons and close buttons. | ||
{ | ||
'akinsho/bufferline.nvim', | ||
event = 'VeryLazy', | ||
keys = { | ||
{ 'te', '<Cmd>tabedit<CR>', desc = 'Create a new tab' }, | ||
{ 'tn', '<Cmd>BufferLineCycleNext<CR>', desc = 'Next buffer' }, | ||
{ 'tp', '<Cmd>BufferLineCyclePrev<CR>', desc = 'Prev buffer' }, | ||
{ 'to', '<Cmd>BufferLineCloseOthers<CR>', desc = 'Delete other buffers' }, | ||
}, | ||
opts = { | ||
options = { | ||
mode = 'tabs', | ||
-- separator_style = "slant", | ||
show_buffer_close_icons = false, | ||
show_close_icon = false, | ||
diagnostics = 'nvim_lsp', | ||
always_show_bufferline = false, | ||
diagnostics_indicator = function(_, _, diag) | ||
local icons = require('config').icons.diagnostics | ||
local ret = (diag.error and icons.Error .. diag.error .. ' ' or '') | ||
.. (diag.warning and icons.Warn .. diag.warning or '') | ||
return vim.trim(ret) | ||
end, | ||
}, | ||
}, | ||
config = function(_, opts) | ||
require('bufferline').setup(opts) | ||
-- Fix bufferline when restoring a session | ||
vim.api.nvim_create_autocmd('BufAdd', { | ||
callback = function() | ||
vim.schedule(function() | ||
pcall(nvim_bufferline) | ||
end) | ||
end, | ||
}) | ||
end, | ||
}, | ||
|
||
-- statusline | ||
{ | ||
'nvim-lualine/lualine.nvim', | ||
event = 'VeryLazy', | ||
opts = function() | ||
return { | ||
options = { | ||
icons_enabled = true, | ||
theme = 'solarized_dark', | ||
section_separators = { left = '', right = '' }, | ||
component_separators = { left = '', right = '' }, | ||
disabled_filetypes = {}, | ||
}, | ||
sections = { | ||
lualine_a = { 'mode' }, | ||
lualine_b = { 'branch' }, | ||
lualine_c = { | ||
{ | ||
'filename', | ||
file_status = true, -- displays file status (readonly status, modified status) | ||
path = 0, -- 0 = just filename, 1 = relative path, 2 = absolute path | ||
}, | ||
}, | ||
lualine_x = { | ||
{ | ||
'diagnostics', | ||
sources = { 'nvim_diagnostic' }, | ||
symbols = { | ||
error = ' ', | ||
warn = ' ', | ||
info = ' ', | ||
hint = ' ', | ||
}, | ||
}, | ||
'encoding', | ||
'filetype', | ||
'filesize', | ||
}, | ||
lualine_y = { 'progress' }, | ||
lualine_z = { 'location' }, | ||
}, | ||
inactive_sections = { | ||
lualine_a = {}, | ||
lualine_b = {}, | ||
lualine_c = { | ||
{ | ||
'filename', | ||
file_status = true, -- displays file status (readonly status, modified status) | ||
path = 1, -- 0 = just filename, 1 = relative path, 2 = absolute path | ||
}, | ||
}, | ||
lualine_x = { 'location' }, | ||
lualine_y = {}, | ||
lualine_z = {}, | ||
}, | ||
tabline = {}, | ||
extensions = { 'fugitive' }, | ||
} | ||
end, | ||
}, | ||
|
||
-- indent guides | ||
{ | ||
'nvimdev/indentmini.nvim', | ||
event = 'BufEnter', | ||
config = function() | ||
require('indentmini').setup({ | ||
char = '|', | ||
exclude = { | ||
'erlang', | ||
'markdown', | ||
}, | ||
}) | ||
-- use comment color | ||
vim.cmd.highlight('default link IndentLine Comment') | ||
end, | ||
}, | ||
|
||
-- icons | ||
{ 'nvim-tree/nvim-web-devicons', lazy = true }, | ||
|
||
{ | ||
'nvimdev/dashboard-nvim', | ||
event = 'VimEnter', | ||
opts = function() | ||
local logo = [[ | ||
██╗ █████╗ ███████╗██╗ ██╗██╗ ██╗██╗███╗ ███╗ Z | ||
██║ ██╔══██╗╚══███╔╝╚██╗ ██╔╝██║ ██║██║████╗ ████║ Z | ||
██║ ███████║ ███╔╝ ╚████╔╝ ██║ ██║██║██╔████╔██║ z | ||
██║ ██╔══██║ ███╔╝ ╚██╔╝ ╚██╗ ██╔╝██║██║╚██╔╝██║ z | ||
███████╗██║ ██║███████╗ ██║ ╚████╔╝ ██║██║ ╚═╝ ██║ | ||
╚══════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ | ||
]] | ||
|
||
logo = string.rep('\n', 8) .. logo .. '\n\n' | ||
|
||
local opts = { | ||
theme = 'doom', | ||
hide = { | ||
-- this is taken care of by lualine | ||
-- enabling this messes up the actual laststatus setting after loading a file | ||
statusline = false, | ||
}, | ||
config = { | ||
header = vim.split(logo, '\n'), | ||
-- stylua: ignore | ||
center = { | ||
{ action = "Telescope find_files", desc = " Find file", icon = " ", key = "f" }, | ||
{ action = "ene | startinsert", desc = " New file", icon = " ", key = "n" }, | ||
{ action = "Telescope oldfiles", desc = " Recent files", icon = " ", key = "r" }, | ||
{ action = "Telescope live_grep", desc = " Find text", icon = " ", key = "g" }, | ||
{ action = 'lua require("persistence").load()', desc = " Restore Session", icon = " ", key = "s" }, | ||
{ action = "Lazy", desc = " Lazy", icon = " ", key = "l" }, | ||
{ action = "qa", desc = " Quit", icon = " ", key = "q" }, | ||
}, | ||
footer = function() | ||
local stats = require('lazy').stats() | ||
local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100) | ||
return { '⚡ Neovim loaded ' .. stats.loaded .. '/' .. stats.count .. ' plugins in ' .. ms .. 'ms' } | ||
end, | ||
}, | ||
} | ||
|
||
for _, button in ipairs(opts.config.center) do | ||
button.desc = button.desc .. string.rep(' ', 43 - #button.desc) | ||
button.key_format = ' %s' | ||
end | ||
|
||
-- close Lazy and re-open when the dashboard is ready | ||
if vim.o.filetype == 'lazy' then | ||
vim.cmd.close() | ||
vim.api.nvim_create_autocmd('User', { | ||
pattern = 'DashboardLoaded', | ||
callback = function() | ||
require('lazy').show() | ||
end, | ||
}) | ||
end | ||
|
||
return opts | ||
end, | ||
}, | ||
} |
Oops, something went wrong.