From 71d3ea0a3652a07ca4d007e451183586486c42ba Mon Sep 17 00:00:00 2001 From: Benjamin Chausse Date: Tue, 26 Sep 2023 13:50:22 -0400 Subject: Binary based loading + more efficient lazy loading --- lua/ben/plugins/blamer.lua | 8 +++--- lua/ben/plugins/colorscheme.lua | 9 +++---- lua/ben/plugins/fugitive.lua | 4 +++ lua/ben/plugins/gitsigns.lua | 4 +++ lua/ben/plugins/go.lua | 26 ++++++++++-------- lua/ben/plugins/gutentags.lua | 4 +++ lua/ben/plugins/nvim-r.lua | 4 +++ lua/ben/plugins/telescope.lua | 58 ++++++++++++++++++++++------------------- lua/ben/plugins/treesitter.lua | 4 +-- lua/ben/plugins/yadm.lua | 12 +++++++++ 10 files changed, 83 insertions(+), 50 deletions(-) create mode 100644 lua/ben/plugins/yadm.lua (limited to 'lua/ben/plugins') diff --git a/lua/ben/plugins/blamer.lua b/lua/ben/plugins/blamer.lua index 1a8217a..9779c3a 100644 --- a/lua/ben/plugins/blamer.lua +++ b/lua/ben/plugins/blamer.lua @@ -1,13 +1,13 @@ return { - enabled = false, "APZelos/blamer.nvim", + -- Only load if linux is the os AND git is installed + cond = function() + return (vim.fn.has("linux") == 1) and vim.fn.executable("git") + end, config = function() vim.g.blamer_enabled = 1 vim.g.blamer_delay = 500 vim.g.blamer_template = ", " vim.g.blamer_prefix = ">" end, - cond = function() - return vim.fn.has("linux") == 1 - end, } diff --git a/lua/ben/plugins/colorscheme.lua b/lua/ben/plugins/colorscheme.lua index 4caaa52..17f89bb 100644 --- a/lua/ben/plugins/colorscheme.lua +++ b/lua/ben/plugins/colorscheme.lua @@ -1,6 +1,5 @@ return { - -- Treesitter optimized colorscheme - { + { -- Treesitter-optimized colorscheme: "neanias/everforest-nvim", version = false, priority = 1000, @@ -13,8 +12,7 @@ return { require("everforest").load() end, }, - -- My very own colorscheme - { + { -- My very own colorscheme "ChausseBenjamin/friffle-vim", lazy = true, config = function() @@ -33,8 +31,7 @@ return { vim.cmd([[hi Search guifg='#810002' guibg='#738c9c']]) end, }, - -- Backup retro colorscheme - { + { -- Backup retro colorscheme "djpohly/elly.vim", lazy = true, }, diff --git a/lua/ben/plugins/fugitive.lua b/lua/ben/plugins/fugitive.lua index e6cf21d..3957d95 100644 --- a/lua/ben/plugins/fugitive.lua +++ b/lua/ben/plugins/fugitive.lua @@ -1,5 +1,9 @@ return { "tpope/vim-fugitive", + -- Only load if git is installed + cond = function() + return vim.fn.executable("git") + end, dependencies = "tpope/vim-rhubarb", -- Only enable when in a git repo keys = { diff --git a/lua/ben/plugins/gitsigns.lua b/lua/ben/plugins/gitsigns.lua index a3576c8..242f95c 100644 --- a/lua/ben/plugins/gitsigns.lua +++ b/lua/ben/plugins/gitsigns.lua @@ -1,5 +1,9 @@ return { "lewis6991/gitsigns.nvim", + -- Only load if git is installed + cond = function() + return vim.fn.executable("git") + end, event = { "BufReadPre", "BufNewFile" }, config = true, } diff --git a/lua/ben/plugins/go.lua b/lua/ben/plugins/go.lua index a2610c8..0e1511f 100644 --- a/lua/ben/plugins/go.lua +++ b/lua/ben/plugins/go.lua @@ -1,5 +1,9 @@ return { "ray-x/go.nvim", + -- Only load if go is installed + cond = function() + return vim.fn.executable("go") + end, dependencies = { -- optional packages "ray-x/guihua.lua", "neovim/nvim-lspconfig", @@ -12,17 +16,17 @@ return { vim.api.nvim_set_keymap("n", "gr", "GoRun", { noremap = true, silent = true }) vim.api.nvim_set_keymap("n", "gd", "GoDoc", { noremap = true, silent = true }) -- Commands to run on save: - -- local format_sync_grp = vim.api.nvim_create_augroup("GoFormat", {}) - -- vim.api.nvim_create_autocmd("BufWritePre", { - -- pattern = "*.go", - -- callback = function() - -- -- Go format: - -- require("go.format").gofmt() - -- -- Goimports: - -- require("go.format").goimport() - -- end, - -- group = format_sync_grp, - -- }) + local format_sync_grp = vim.api.nvim_create_augroup("GoFormat", {}) + vim.api.nvim_create_autocmd("BufWritePre", { + pattern = "*.go", + callback = function() + -- Go format: + require("go.format").gofmt() + -- Goimports: + require("go.format").goimport() + end, + group = format_sync_grp, + }) end, ft = { "go", "gomod", "gowork", "gosum" }, build = ':lua require("go.install").update_all_sync()', -- if you need to install/update all binaries diff --git a/lua/ben/plugins/gutentags.lua b/lua/ben/plugins/gutentags.lua index 76223cf..a97f2a9 100644 --- a/lua/ben/plugins/gutentags.lua +++ b/lua/ben/plugins/gutentags.lua @@ -1,4 +1,8 @@ return { "ludovicchabant/vim-gutentags", + -- Only load if ctags are installed + cond = function() + return vim.fn.executable("ctags") + end, event = { "BufReadPre", "BufNewFile" }, } diff --git a/lua/ben/plugins/nvim-r.lua b/lua/ben/plugins/nvim-r.lua index fa93005..3978d1e 100644 --- a/lua/ben/plugins/nvim-r.lua +++ b/lua/ben/plugins/nvim-r.lua @@ -1,5 +1,9 @@ return { "jalvesaq/Nvim-R", + -- Only load if R is installed + cond = function() + return vim.fn.executable("R") + end, ft = { "R", "Rnoweb", "tex", "aux", "bib" }, config = function() vim.g.r_syntax_folding = 1 diff --git a/lua/ben/plugins/telescope.lua b/lua/ben/plugins/telescope.lua index 81e550d..1b091eb 100644 --- a/lua/ben/plugins/telescope.lua +++ b/lua/ben/plugins/telescope.lua @@ -1,37 +1,41 @@ return { - "nvim-telescope/telescope.nvim", - branch = "0.1.x", - dependencies = { - "nvim-lua/plenary.nvim", - { - "joaomsa/telescope-orgmode.nvim", - lazy = true, - config = function() - require("telescope").load_extension("orgmode") - end, + { -- Main plugin: Telescope + "nvim-telescope/telescope.nvim", + branch = "0.1.x", + dependencies = { + "nvim-lua/plenary.nvim", }, - }, - keys = { -- LazyLoad telescope when it's actually needed - - -- F.ind F.iles - { "ff", 'lua require("telescope.builtin").find_files()' }, + keys = { -- LazyLoad telescope when it's actually needed - -- F.ind B.uffers - { "fb", 'lua require("telescope.builtin").buffers()' }, + -- F.ind F.iles + { "ff", 'lua require("telescope.builtin").find_files()' }, - -- F.ind G.it - { "fg", 'lua require("telescope.builtin").git_files()' }, + -- F.ind B.uffers + { "fb", 'lua require("telescope.builtin").buffers()' }, - -- F.ind H.elp - { "fh", 'lua require("telescope.builtin").help_tags()' }, + -- F.ind G.it + { "fg", 'lua require("telescope.builtin").git_files()' }, - -- F.ind Q.uick F.ix - { "fqf", 'lua require("telescope.builtin").quickfix()' }, + -- F.ind H.elp + { "fh", 'lua require("telescope.builtin").help_tags()' }, - -- F.ind C.olor S.cheme - { "fcs", 'lua require("telescope.builtin").colorscheme()' }, + -- F.ind Q.uick F.ix + { "fqf", 'lua require("telescope.builtin").quickfix()' }, - -- F.ing O.rgmode - { "fo", 'lua require("telescope").extensions.orgmode.seach_headings()' }, + -- F.ind C.olor S.cheme + { "fcs", 'lua require("telescope.builtin").colorscheme()' }, + }, + { -- Telescope extension for orgmode + "joaomsa/telescope-orgmode.nvim", + lazy = true, + config = function() + require("telescope").load_extension("orgmode") + end, + -- This way, telescope doesn't load the extension until it's actually needed + keys = { + -- F.ing O.rgmode + { "fo", 'lua require("telescope").extensions.orgmode.seach_headings()' }, + }, + }, }, } diff --git a/lua/ben/plugins/treesitter.lua b/lua/ben/plugins/treesitter.lua index b8f4ec0..ec3022b 100644 --- a/lua/ben/plugins/treesitter.lua +++ b/lua/ben/plugins/treesitter.lua @@ -1,11 +1,11 @@ return { { "nvim-treesitter/nvim-treesitter", - event = { "BufReadPre", "BufNewFile" }, - build = ":TSUpdate", dependencies = { "windwp/nvim-ts-autotag", }, + event = { "BufReadPre", "BufNewFile" }, + build = ":TSUpdate", config = function() -- import nvim-treesitter plugin local treesitter = require("nvim-treesitter.configs") diff --git a/lua/ben/plugins/yadm.lua b/lua/ben/plugins/yadm.lua new file mode 100644 index 0000000..ae0fea7 --- /dev/null +++ b/lua/ben/plugins/yadm.lua @@ -0,0 +1,12 @@ +return { + "robstumborg/yadm.nvim", + -- Only load if yadm is installed + cond = function() + return vim.fn.executable("yadm") + end, + config = function() + require("yadm").setup({ + yadm_dir = vim.fn.expand("$XDG_DATA_HOME/yadm/repo.git"), + }) + end, +} -- cgit v1.2.3