New plugin file structure

Added Helpers and Spec sections with headers. Changed
mini-local-keymaps.lua to mini-bookmarks.lua.
This commit is contained in:
2026-05-14 07:37:58 +02:00
parent a8d6501da7
commit d617c04f43
12 changed files with 189 additions and 317 deletions
+1
View File
@@ -6,3 +6,4 @@ debug
foo.*
*.log
data
mini-booksmarks.lua
+1 -6
View File
@@ -1,18 +1,13 @@
{
"baleia.nvim": { "branch": "main", "commit": "32617940adb2eea56e85a64883a19961ceac9641" },
"codediff.nvim": { "branch": "main", "commit": "8afc229d38dc13ce71b2ffbb860084b2c726e061" },
"catppuccin": { "branch": "main", "commit": "426dbebe06b5c69fd846ceb17b42e12f890aedf1" },
"diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" },
"fzf-lua": { "branch": "main", "commit": "97376e364f51f1b5ae3efaa3eb2e929430ca8419" },
"lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" },
"lualine.nvim": { "branch": "master", "commit": "131a558e13f9f28b15cd235557150ccb23f89286" },
"mini.nvim": { "branch": "main", "commit": "17c448b0f3f29c0857a3436fc64e1d7cb9267ec3" },
"mini.pick": { "branch": "main", "commit": "975e398570dd15696575c5374f94e78fd29a7a69" },
"monokai-pro.nvim": { "branch": "master", "commit": "2eb6fe008dcabb5c2d37978fe34f36bb318a2a96" },
"neogit": { "branch": "master", "commit": "395ac481e197784e410b59b987fadaf9e7481df1" },
"nvim-web-devicons": { "branch": "master", "commit": "2795c26c916bb3c57dde308b82be51971fa92747" },
"plenary.nvim": { "branch": "master", "commit": "74b06c6c75e4eeb3108ec01852001636d85a932b" },
"smart-open.nvim": { "branch": "0.2.x", "commit": "7763800068bef69334870c10cb595d49ce27580a" },
"snacks.nvim": { "branch": "main", "commit": "ad9ede6a9cddf16cedbd31b8932d6dcdee9b716e" },
"sqlite.lua": { "branch": "master", "commit": "50092d60feb242602d7578398c6eb53b4a8ffe7b" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "b25b749b9db64d375d782094e2b9dce53ad53a40" },
"telescope-fzy-native.nvim": { "branch": "master", "commit": "282f069504515eec762ab6d6c89903377252bf5b" },
+23
View File
@@ -0,0 +1,23 @@
-- lua/plugins/catppuccin.lua
-- ============================================================
-- HELPERS
-- ============================================================
-- ============================================================
-- SPEC
-- ============================================================
return {
"catppuccin/nvim",
name = "catppuccin",
priority = 1000,
config = function()
require("catppuccin").setup({
auto_integrations = true,
})
vim.cmd.colorscheme("catppuccin")
end,
}
-197
View File
@@ -1,197 +0,0 @@
-- since this is just an example spec, don't actually load anything here and return an empty spec
-- stylua: ignore
if true then return {} end
-- every spec file under the "plugins" directory will be loaded automatically by lazy.nvim
--
-- In your plugin files, you can:
-- * add extra plugins
-- * disable/enabled LazyVim plugins
-- * override the configuration of LazyVim plugins
return {
-- add gruvbox
{ "ellisonleao/gruvbox.nvim" },
-- Configure LazyVim to load gruvbox
{
"LazyVim/LazyVim",
opts = {
colorscheme = "gruvbox",
},
},
-- change trouble config
{
"folke/trouble.nvim",
-- opts will be merged with the parent spec
opts = { use_diagnostic_signs = true },
},
-- disable trouble
{ "folke/trouble.nvim", enabled = false },
-- override nvim-cmp and add cmp-emoji
{
"hrsh7th/nvim-cmp",
dependencies = { "hrsh7th/cmp-emoji" },
---@param opts cmp.ConfigSchema
opts = function(_, opts)
table.insert(opts.sources, { name = "emoji" })
end,
},
-- change some telescope options and a keymap to browse plugin files
{
"nvim-telescope/telescope.nvim",
keys = {
-- add a keymap to browse plugin files
-- stylua: ignore
{
"<leader>fp",
function() require("telescope.builtin").find_files({ cwd = require("lazy.core.config").options.root }) end,
desc = "Find Plugin File",
},
},
-- change some options
opts = {
defaults = {
layout_strategy = "horizontal",
layout_config = { prompt_position = "top" },
sorting_strategy = "ascending",
winblend = 0,
},
},
},
-- add pyright to lspconfig
{
"neovim/nvim-lspconfig",
---@class PluginLspOpts
opts = {
---@type lspconfig.options
servers = {
-- pyright will be automatically installed with mason and loaded with lspconfig
pyright = {},
},
},
},
-- add tsserver and setup with typescript.nvim instead of lspconfig
{
"neovim/nvim-lspconfig",
dependencies = {
"jose-elias-alvarez/typescript.nvim",
init = function()
require("lazyvim.util").lsp.on_attach(function(_, buffer)
-- stylua: ignore
vim.keymap.set( "n", "<leader>co", "TypescriptOrganizeImports", { buffer = buffer, desc = "Organize Imports" })
vim.keymap.set("n", "<leader>cR", "TypescriptRenameFile", { desc = "Rename File", buffer = buffer })
end)
end,
},
---@class PluginLspOpts
opts = {
---@type lspconfig.options
servers = {
-- tsserver will be automatically installed with mason and loaded with lspconfig
tsserver = {},
},
-- you can do any additional lsp server setup here
-- return true if you don't want this server to be setup with lspconfig
---@type table<string, fun(server:string, opts:_.lspconfig.options):boolean?>
setup = {
-- example to setup with typescript.nvim
tsserver = function(_, opts)
require("typescript").setup({ server = opts })
return true
end,
-- Specify * to use this function as a fallback for any server
-- ["*"] = function(server, opts) end,
},
},
},
-- for typescript, LazyVim also includes extra specs to properly setup lspconfig,
-- treesitter, mason and typescript.nvim. So instead of the above, you can use:
{ import = "lazyvim.plugins.extras.lang.typescript" },
-- add more treesitter parsers
{
"nvim-treesitter/nvim-treesitter",
opts = {
ensure_installed = {
"bash",
"html",
"javascript",
"json",
"lua",
"markdown",
"markdown_inline",
"python",
"query",
"regex",
"tsx",
"typescript",
"vim",
"yaml",
},
},
},
-- since `vim.tbl_deep_extend`, can only merge tables and not lists, the code above
-- would overwrite `ensure_installed` with the new value.
-- If you'd rather extend the default config, use the code below instead:
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
-- add tsx and treesitter
vim.list_extend(opts.ensure_installed, {
"tsx",
"typescript",
})
end,
},
-- the opts function can also be used to change the default opts:
{
"nvim-lualine/lualine.nvim",
event = "VeryLazy",
opts = function(_, opts)
table.insert(opts.sections.lualine_x, {
function()
return "😄"
end,
})
end,
},
-- or you can return new options to override all the defaults
{
"nvim-lualine/lualine.nvim",
event = "VeryLazy",
opts = function()
return {
--[[add your custom lualine config here]]
}
end,
},
-- use mini.starter instead of alpha
{ import = "lazyvim.plugins.extras.ui.mini-starter" },
-- add jsonls and schemastore packages, and setup treesitter for json, json5 and jsonc
{ import = "lazyvim.plugins.extras.lang.json" },
-- add any tools you want to have installed below
{
"williamboman/mason.nvim",
opts = {
ensure_installed = {
"stylua",
"shellcheck",
"shfmt",
"flake8",
},
},
},
}
+28 -17
View File
@@ -1,22 +1,33 @@
-- lua/plugins/lualine.lua
-- ============================================================
-- HELPERS
-- ============================================================
local function custom_location()
local line = vim.fn.line('.')
local total_lines = vim.fn.line('$')
local col = vim.fn.virtcol('.') -- virtcol accounts for tab widths
local total_cols = #vim.fn.getline('.')
return string.format('%d:%d %d:%d', line, total_lines, col, total_cols)
local line = vim.api.nvim_win_get_cursor(0)[1]
local total_lines = vim.api.nvim_buf_line_count(0)
local col = vim.fn.virtcol('.')
local total_cols = vim.fn.virtcol('$') - 1 -- $ is end of line, -1 for accurate count
return string.format('%d/%d : %d/%d', line, total_lines, col, total_cols)
end
-- ============================================================
-- PLUGIN SPEC
-- ============================================================
return {
'nvim-lualine/lualine.nvim',
dependencies = { 'nvim-tree/nvim-web-devicons' },
config = function()
require('lualine').setup({
sections = {
lualine_z = {
custom_location
}
}
})
end,
'nvim-lualine/lualine.nvim',
dependencies = { 'nvim-tree/nvim-web-devicons' },
config = function()
require('lualine').setup({
options = {
theme = 'auto',
section_separators = '',
component_separators = '|',
},
sections = {
lualine_z = { custom_location },
},
})
end,
}
+18
View File
@@ -0,0 +1,18 @@
-- lua/config/mini-bookmarks.lua
-- NB! This file is not tracked in git.
local function set_mark(id, path, desc)
require('mini.files').set_bookmark(id, path, { desc = desc })
end
vim.api.nvim_create_autocmd('User', {
pattern = 'MiniFilesExplorerOpen',
callback = function()
set_mark('c', '/home/flx/code-projects/', 'Code projects')
set_mark('h', '~', 'Home')
set_mark('n', '/home/flx/.config/nvim/', 'Neovim config')
set_mark('s', '/home/flx/scripts/', 'Scripts')
end,
})
return {}
-18
View File
@@ -1,18 +0,0 @@
-- NB! This file is not tracked in git.
-- Set permanent bookmarks
local set_mark = function(id, path, desc)
MiniFiles.set_bookmark(id, path, { desc = desc })
end
vim.api.nvim_create_autocmd('User', {
pattern = 'MiniFilesExplorerOpen',
callback = function()
set_mark('c', '/home/flx/code-projects/', 'Code projects directory')
set_mark('h', '~', 'Home directory')
set_mark('n', '/home/flx/.config/nvim/', 'Neovim directory')
set_mark('s', '/home/flx/scripts/', 'Scripts directory')
end,
})
return {}
+48 -36
View File
@@ -1,49 +1,61 @@
-- mini.nvim Docs: https://nvim-mini.org/mini.nvim/
-- lua/plugins/mini.lua
FILES_CONFIG = {
options = {
-- Whether to use for editing directories
use_as_default_explorer = true,
},
-- Customization of explorer windows
windows = {
-- Maximum number of windows to show side by side
max_number = math.huge,
-- Whether to show preview of file/directory under cursor
preview = true,
-- Width of focused window
width_focus = 50,
-- Width of non-focused window
width_nofocus = 15,
-- Width of preview window
width_preview = 25,
},
}
-- Set focused directory as current working directory
local set_cwd = function()
-- ============================================================
-- HELPERS
-- ============================================================
local function set_cwd()
local path = (MiniFiles.get_fs_entry() or {}).path
if path == nil then return vim.notify('Cursor is not on valid entry') end
if path == nil then
return vim.notify('Cursor is not on valid entry')
end
vim.fn.chdir(vim.fs.dirname(path))
end
vim.api.nvim_create_autocmd('User', {
pattern = 'MiniFilesBufferCreate',
callback = function(args)
local b = args.data.buf_id
vim.keymap.set('n', 'gc', set_cwd, { buffer = b, desc = 'Set cwd' })
end,
})
local function setup_keymaps()
vim.api.nvim_create_autocmd('User', {
pattern = 'MiniFilesBufferCreate',
callback = function(args)
vim.keymap.set('n', 'gc', set_cwd, {
buffer = args.data.buf_id,
desc = 'Set cwd',
})
end,
})
end
local function setup_bookmarks()
-- Try to load machine-specific bookmarks (not in git)
pcall(require, 'config.mini-bookmarks')
end
-- ============================================================
-- SPEC
-- ============================================================
return {
'nvim-mini/mini.nvim',
version = false,
config = function()
require("mini.files").setup(FILES_CONFIG)
end,
keys = {
{ "<leader>m", function() require("mini.files").open() end, desc = "Open mini.files" },
{ '<leader>m', function() require('mini.files').open() end, desc = 'Open mini.files' },
},
config = function()
require('mini.files').setup({
options = {
use_as_default_explorer = true,
},
windows = {
max_number = math.huge,
preview = true,
width_focus = 50,
width_nofocus = 15,
width_preview = 25,
},
})
setup_keymaps()
setup_bookmarks()
end,
}
-18
View File
@@ -1,18 +0,0 @@
CONFIG_TABLE = {
filter = "octagon",
}
return {
"loctvl842/monokai-pro.nvim",
lazy = false,
priority = 1000,
config = function()
require("monokai-pro").setup(CONFIG_TABLE)
vim.cmd.colorscheme("monokai-pro")
-- Fixes broken colors of mini.files
vim.api.nvim_set_hl(0, 'MiniFilesNormal', { link = 'Normal' })
vim.api.nvim_set_hl(0, 'MiniFilesBorder', { link = 'FloatBorder' })
vim.api.nvim_set_hl(0, 'MiniFilesDirectory', { link = 'FoldColumn' })
end,
}
+14 -12
View File
@@ -1,21 +1,23 @@
-- lua/plugins/neogit.lua
-- ============================================================
-- HELPERS
-- ============================================================
-- ============================================================
-- SPEC
-- ============================================================
return {
"NeogitOrg/neogit",
lazy = true,
dependencies = {
-- Only one of these is needed.
"sindrets/diffview.nvim", -- optional
"esmuellert/codediff.nvim", -- optional
-- For a custom log pager
"m00qek/baleia.nvim", -- optional
-- Only one of these is needed.
"nvim-telescope/telescope.nvim", -- optional
"ibhagwan/fzf-lua", -- optional
"nvim-mini/mini.pick", -- optional
"folke/snacks.nvim", -- optional
"sindrets/diffview.nvim",
"nvim-telescope/telescope.nvim",
},
cmd = "Neogit",
keys = {
{ "<leader>gg", "<cmd>Neogit<cr>", desc = "Show Neogit UI" }
}
+29
View File
@@ -0,0 +1,29 @@
-- lua/plugins/PLUGIN_NAME.lua
-- ============================================================
-- HELPERS
-- ============================================================
-- ============================================================
-- SPEC
-- ============================================================
return {
'user/repo',
-- dependencies = {},
-- lazy = false,
-- event = '',
-- cmd = '',
-- ft = '',
keys = {
-- { '<leader>x', '<cmd>Cmd<cr>', desc = '' },
},
config = function()
require('plugin').setup({
-- options
})
end,
}
+27 -13
View File
@@ -1,19 +1,33 @@
vim.keymap.set("n", "<leader>o", function ()
require("telescope").extensions.smart_open.smart_open()
end, { noremap = true, silent = true })
-- lua/plugins/smart-open.lua
-- ============================================================
-- HELPERS
-- ============================================================
-- ============================================================
-- SPEC
-- ============================================================
return {
"danielfalk/smart-open.nvim",
branch = "0.2.x",
config = function()
require("telescope").load_extension("smart_open")
end,
'danielfalk/smart-open.nvim',
branch = '0.2.x',
dependencies = {
"kkharji/sqlite.lua",
-- Only required if using match_algorithm fzf
{ "nvim-telescope/telescope-fzf-native.nvim", build = "make" },
-- Optional. If installed, native fzy will be used when match_algorithm is fzy
{ "nvim-telescope/telescope-fzy-native.nvim" },
'kkharji/sqlite.lua',
{ 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' },
'nvim-telescope/telescope-fzy-native.nvim',
},
keys = {
{
'<leader>o',
function() require('telescope').extensions.smart_open.smart_open() end,
desc = 'Smart open',
},
},
config = function()
require('telescope').load_extension('smart_open')
end,
}