Skip to content

Commit

Permalink
refactor: extract related configs into ui
Browse files Browse the repository at this point in the history
  • Loading branch information
BBboy01 committed Nov 25, 2023
1 parent 31bd9d6 commit c82fb42
Show file tree
Hide file tree
Showing 11 changed files with 259 additions and 102 deletions.
15 changes: 9 additions & 6 deletions lazy-lock.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{
"LuaSnip": { "branch": "master", "commit": "cab667e2674881001a86a7478fff7dc7791c63f5" },
"LuaSnip": { "branch": "master", "commit": "df58ee1664cfda71479cd2bbd56114f56599eba6" },
"bufferline.nvim": { "branch": "main", "commit": "9e8d2f695dd50ab6821a6a53a840c32d2067a78a" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-cmdline": { "branch": "main", "commit": "8ee981b4a91f536f52add291594e89fb6645e451" },
"cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
"dashboard-nvim": { "branch": "master", "commit": "63df28409d940f9cac0a925df09d3dc369db9841" },
"dressing.nvim": { "branch": "master", "commit": "fe3071330a0720ce3695ac915820c8134b22d1b0" },
"flash.nvim": { "branch": "main", "commit": "48817af25f51c0590653bbc290866e4890fe1cbe" },
"friendly-snippets": { "branch": "main", "commit": "43727c2ff84240e55d4069ec3e6158d74cb534b6" },
"git.nvim": { "branch": "main", "commit": "741696687486f25f8b73d9e4c76ab2ede9998f39" },
Expand All @@ -20,19 +22,20 @@
"mini.surround": { "branch": "main", "commit": "af8129efcabe95fc08a233e9f91569829bed031f" },
"neodev.nvim": { "branch": "main", "commit": "f972d7e6cd21b691199565cfe3e6487e774a4e8f" },
"neogen": { "branch": "main", "commit": "70127baaff25611deaf1a29d801fc054ad9d2dc1" },
"none-ls.nvim": { "branch": "main", "commit": "f1c0066bb3e9669d82040ddcf45a4d60c83ecca7" },
"none-ls.nvim": { "branch": "main", "commit": "358dd357a753f81412397b8a4cc01a2f41a1b594" },
"nvim-cmp": { "branch": "main", "commit": "0b751f6beef40fd47375eaf53d3057e0bfa317e4" },
"nvim-lspconfig": { "branch": "master", "commit": "553c4e0e667167640c5398573f6f3a488ff8047a" },
"nvim-tree.lua": { "branch": "master", "commit": "086bf310bd19a7103ee7d761eb59f89f3dd23e21" },
"nvim-treesitter": { "branch": "master", "commit": "71bdf97bf6dafc776ad957169533f2f669a8c562" },
"nvim-treesitter": { "branch": "master", "commit": "649d137371e9214d30b20565e0574824fa3a3670" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "dbcd9388e3b119a87c785e10a00d62876077d23d" },
"nvim-ts-autotag": { "branch": "main", "commit": "6be1192965df35f94b8ea6d323354f7dc7a557e4" },
"nvim-ts-context-commentstring": { "branch": "main", "commit": "bdd2a3293340465a516b126d10894f6d5cb5213c" },
"nvim-ts-context-commentstring": { "branch": "main", "commit": "b8ff464f2afc2000f6c72fa331a8fc090cb46b39" },
"nvim-ts-rainbow": { "branch": "master", "commit": "ef95c15a935f97c65a80e48e12fe72d49aacf9b9" },
"nvim-web-devicons": { "branch": "master", "commit": "cdbcca210cf3655aa9b31ebf2422763ecd85ee5c" },
"persistence.nvim": { "branch": "main", "commit": "ad538bfd5336f1335cdb6fd4e0b0eebfa6e12f32" },
"playground": { "branch": "master", "commit": "ba48c6a62a280eefb7c85725b0915e021a1a0749" },
"plenary.nvim": { "branch": "master", "commit": "50012918b2fc8357b87cff2a7f7f0446e47da174" },
"schemastore.nvim": { "branch": "main", "commit": "6316dc88db89d97d190f24547adddd13569fb746" },
"plenary.nvim": { "branch": "master", "commit": "c47e1a21d235a422034012935febd2d078d77ac6" },
"schemastore.nvim": { "branch": "main", "commit": "c2c6bd234301876a4bb310be08d23dc45768524d" },
"solarized-osaka.nvim": { "branch": "main", "commit": "aeaefec4465deb3ec36f094578e880726c8f8e24" },
"telescope-file-browser.nvim": { "branch": "master", "commit": "f41675fddb1ea9003187d07ecc627a8bf8292633" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" },
Expand Down
5 changes: 0 additions & 5 deletions lua/config/keymaps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ keymap.set('n', '-', '<C-x>')
-- Delete a word backwards
keymap.set('n', 'dw', 'vb"_d')

keymap.set('n', 'te', ':tabedit<Return>', { silent = true, desc = 'Create a new tab' })
keymap.set('n', 'tp', ':tabprevious<Return>', { silent = true, desc = 'Switch to previous tab' })
keymap.set('n', 'tn', ':tabnext<Return>', { silent = true, desc = 'Switch to next tab' })
keymap.set('n', 'to', ':tabo<Return>', { silent = true, desc = 'Close all tabs but current' })

keymap.set('n', 'si', ':split<Return><C-w>w', { silent = true, desc = 'Horizontally split current buffer' })
keymap.set('n', 'sv', ':vsplit<Return><C-w>w', { silent = true, desc = 'Vertically split current buffer' })

Expand Down
12 changes: 0 additions & 12 deletions lua/plugins/bufferline.lua

This file was deleted.

15 changes: 0 additions & 15 deletions lua/plugins/indentmini.lua

This file was deleted.

1 change: 0 additions & 1 deletion lua/plugins/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@ return {
enable_autocmd = false,
},
},
'nvim-tree/nvim-web-devicons', -- File icons
'b0o/schemastore.nvim', -- json schemas to use with lspconfig
}
59 changes: 0 additions & 59 deletions lua/plugins/lualine.lua

This file was deleted.

3 changes: 0 additions & 3 deletions lua/plugins/none-ls.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
return {
'nvimtools/none-ls.nvim',
event = 'VeryLazy',
dependencies = {
'nvim-lua/plenary.nvim',
},
config = function()
local null_ls = require('null-ls')
null_ls.setup({
Expand Down
12 changes: 11 additions & 1 deletion lua/plugins/telescope.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
local Util = require('util')

return {
'nvim-telescope/telescope.nvim',
cmd = 'Telescope',
version = false,
dependencies = {
{
'nvim-telescope/telescope-fzf-native.nvim',
build = 'make',
config = function()
Util.on_load('telescope.nvim', function()
require('telescope').load_extension('fzf')
end)
end,
},
'nvim-telescope/telescope-file-browser.nvim',
},
Expand All @@ -25,7 +34,8 @@ return {
local builtin = require('telescope.builtin')
builtin.live_grep()
end,
desc = 'Search for a string in your current working directory and get results live as you type, respects .gitignore',
desc =
'Search for a string in your current working directory and get results live as you type, respects .gitignore',
},
{
'<Leader>s',
Expand Down
201 changes: 201 additions & 0 deletions lua/plugins/ui.lua
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,
},
}
Loading

0 comments on commit c82fb42

Please sign in to comment.