diff --git a/lazy-lock.json b/lazy-lock.json index e00f089..9eb6a87 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -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" }, @@ -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" }, diff --git a/lua/config/keymaps.lua b/lua/config/keymaps.lua index 87c2236..3e1c3bb 100644 --- a/lua/config/keymaps.lua +++ b/lua/config/keymaps.lua @@ -18,11 +18,6 @@ keymap.set('n', '-', '') -- Delete a word backwards keymap.set('n', 'dw', 'vb"_d') -keymap.set('n', 'te', ':tabedit', { silent = true, desc = 'Create a new tab' }) -keymap.set('n', 'tp', ':tabprevious', { silent = true, desc = 'Switch to previous tab' }) -keymap.set('n', 'tn', ':tabnext', { silent = true, desc = 'Switch to next tab' }) -keymap.set('n', 'to', ':tabo', { silent = true, desc = 'Close all tabs but current' }) - keymap.set('n', 'si', ':splitw', { silent = true, desc = 'Horizontally split current buffer' }) keymap.set('n', 'sv', ':vsplitw', { silent = true, desc = 'Vertically split current buffer' }) diff --git a/lua/plugins/bufferline.lua b/lua/plugins/bufferline.lua deleted file mode 100644 index 3e551c3..0000000 --- a/lua/plugins/bufferline.lua +++ /dev/null @@ -1,12 +0,0 @@ -return { - 'akinsho/bufferline.nvim', - event = 'VeryLazy', - opts = { - options = { - mode = 'tabs', - -- separator_style = "slant", - show_buffer_close_icons = false, - show_close_icon = false, - }, - }, -} diff --git a/lua/plugins/indentmini.lua b/lua/plugins/indentmini.lua deleted file mode 100644 index 3cb6fa6..0000000 --- a/lua/plugins/indentmini.lua +++ /dev/null @@ -1,15 +0,0 @@ -return { - '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, -} diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 1891ccd..0feb7af 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -11,6 +11,5 @@ return { enable_autocmd = false, }, }, - 'nvim-tree/nvim-web-devicons', -- File icons 'b0o/schemastore.nvim', -- json schemas to use with lspconfig } diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua deleted file mode 100644 index e90c9a0..0000000 --- a/lua/plugins/lualine.lua +++ /dev/null @@ -1,59 +0,0 @@ -return { - '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, -} diff --git a/lua/plugins/none-ls.lua b/lua/plugins/none-ls.lua index 7999a6c..47756be 100644 --- a/lua/plugins/none-ls.lua +++ b/lua/plugins/none-ls.lua @@ -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({ diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index c6f7e89..9e8241f 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -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', }, @@ -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', }, { 's', diff --git a/lua/plugins/ui.lua b/lua/plugins/ui.lua new file mode 100644 index 0000000..9087358 --- /dev/null +++ b/lua/plugins/ui.lua @@ -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', 'tabedit', desc = 'Create a new tab' }, + { 'tn', 'BufferLineCycleNext', desc = 'Next buffer' }, + { 'tp', 'BufferLineCyclePrev', desc = 'Prev buffer' }, + { 'to', 'BufferLineCloseOthers', 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, + }, +} diff --git a/lua/plugins/util.lua b/lua/plugins/util.lua new file mode 100644 index 0000000..b047f75 --- /dev/null +++ b/lua/plugins/util.lua @@ -0,0 +1,19 @@ +return { + -- Session management. This saves your session in the background, + -- keeping track of open buffers, window arrangement, and more. + -- You can restore sessions when returning through the dashboard. + { + 'folke/persistence.nvim', + event = 'BufReadPre', + opts = { options = vim.opt.sessionoptions:get() }, + -- stylua: ignore + keys = { + { "qs", function() require("persistence").load() end, desc = "Restore Session" }, + { "ql", function() require("persistence").load({ last = true }) end, desc = "Restore Last Session" }, + { "qd", function() require("persistence").stop() end, desc = "Don't Save Current Session" }, + }, + }, + + -- library used by other plugins + { 'nvim-lua/plenary.nvim', lazy = true }, +} diff --git a/lua/util/init.lua b/lua/util/init.lua index 154a20d..1d990a0 100644 --- a/lua/util/init.lua +++ b/lua/util/init.lua @@ -10,4 +10,23 @@ function M.opts(name) return Plugin.values(plugin, 'opts', false) end +---@param name string +---@param fn fun(name:string) +function M.on_load(name, fn) + local Config = require('lazy.core.config') + if Config.plugins[name] and Config.plugins[name]._.loaded then + fn(name) + else + vim.api.nvim_create_autocmd('User', { + pattern = 'LazyLoad', + callback = function(event) + if event.data == name then + fn(name) + return true + end + end, + }) + end +end + return M