diff --git a/README.md b/README.md index e144f85..5496609 100644 --- a/README.md +++ b/README.md @@ -7,18 +7,18 @@ ### Root plugin папка Скрипты в этой папке загружаются автоматически после инициализации `neovim`, но до загрузки файлов типа `ftplugin/` или `after/`. ### Plugins -Разберем на примере `oil.nvim`: Сначала базовые настройки, такие как инструкция откуда качать и всякие зависимости и атрибуты по типу приоритета кладутся в директорию `custom/plugins` в виде названия плагина: -*lua/custom/plugins/oil.lua* +Плагины ставятся встроенным менеджером `vim.pack` (Neovim 0.12+), см. раздел [Работа с vim.pack](#работа-с-vimpack). +Разберем на примере `oil.nvim`: источник плагина указывается в списке `vim.pack.add` в `lua/custom/pack.lua`: +*lua/custom/pack.lua* ```lua -return { - "stevearc/oil.nvim", - dependencies = { { "echasnovski/mini.icons", opts = {} } }, - config = function() - require "custom/oil" - end, -} +vim.pack.add({ + gh("echasnovski/mini.icons"), + gh("stevearc/oil.nvim"), +}) +require("mini.icons").setup() +require "custom.oil" ``` -Затем, как можно видеть, сама функция настроек расположена отдельно в файле с идентичным названием, но в директории "повыше": +Затем сама функция настроек расположена отдельно, в файле с названием плагина: *lua/custom/oil.lua* ```lua require("oil").setup{ @@ -36,20 +36,40 @@ require("oil").setup{ Тут храняться настройки, которые будут применены **до** загразуки плагинов. Т.е. настройки, что определны где-то в настройках плагинов будут переписывать если что те, которые установлены для типов файлов тут ### after/ftplugin Настройки для типов файлов тут будут применены уже после того, как загрузится все содержимое neovim => эти настройки будут перегружать все то, что было настроено в плагинах -## Включение / Выключение некоторых плагинов -Из за возникновения случаев, когда некоторые плагины на некоторых машинах не нужно включать (например obsidian мне нужен только на хостовых машинах, на удаленных он будет только мешать открывать .md файлы), то в `init.lua` у меня в самом начале устанавливаются для таких плагинов глобальные переменные со следующей семантикой: -``` -vim.g._enabled = -``` -Например: +## Работа с vim.pack +Плагины описаны в `lua/custom/pack.lua`, версии зафиксированы в `nvim-pack-lock.json` (его нужно коммитить). Плагины ставятся в `~/.local/share/nvim/site/pack/core/opt`. + +| Задача | lazy.nvim | vim.pack | +|---|---|---| +| Установить плагин | добавить spec, `:Lazy install` | добавить в `vim.pack.add({...})` и перезапустить, недостающее ставится при старте с подтверждением | +| Обновить все | `:Lazy update` | `:lua vim.pack.update()`, откроется буфер с диффом | +| Обновить один | `:Lazy update name` | `:lua vim.pack.update({"name"})` | +| Применить обновление | кнопка в UI | `:write` в буфере с диффом | +| Отклонить обновление | закрыть окно | закрыть буфер (`:quit`) | +| Список плагинов | `:Lazy` | `:lua vim.print(vim.pack.get())` | +| Удалить | убрать spec, `:Lazy clean` | убрать из `pack.lua`, затем `:lua vim.pack.del({"name"})` | +| Откатить к lock-файлу | `:Lazy restore` | `:lua vim.pack.update(nil, {target = "lockfile"})` | +| Lock-файл | `lazy-lock.json` | `nvim-pack-lock.json` | +| Профилирование | `:Lazy profile` | `nvim --startuptime out.log` | + +Порядок обновления: `:lua vim.pack.update()` → прочитать дифф → `:write` → перезапустить nvim → закоммитить `nvim-pack-lock.json`. +Парсеры treesitter обновляются вручную командой `:TSUpdate`. + +### Чего нет по сравнению с lazy +- Нет окна `:Lazy`, всё делается командами и через буфер диффа. +- Нет ленивой загрузки (`event`, `cmd`, `ft`, `keys`), плагины грузятся при старте. +- Нет `dependencies`, `opts` и `config`: зависимости перечисляются в `vim.pack.add`, а `setup()` вызывается вручную. +- Нет хука `build`. Вместо него автокоманда `PackChanged`, которую нужно объявить **до** `vim.pack.add` (пример для `markdown-preview` в `pack.lua`). + +### Версии +Без `version` плагин следует за веткой по умолчанию. Версию можно зафиксировать: ```lua -vim.g.obsidian_enabled = false +{ src = gh("L3MON4D3/LuaSnip"), version = vim.version.range("2.*") } ``` -Это позволяет динамически включать/выключать плагины без необходимости усложнять конфиг `lazy` # FAQ > Зачем так мучаться? Не проще все кидать в один файл? -Проще, но такое распараллеливание позволяет легче дебажить файлы настроек. Т.е. исправляя настройки мы можем просто `source`ить файл настроек, не трогая конфигурации скачивания файлов, чтобы лишний раз не триггерить Lazy. +Проще, но такое распараллеливание позволяет легче дебажить файлы настроек. Т.е. исправляя настройки мы можем просто `source`ить файл настроек, не трогая список плагинов в `pack.lua`. > Что делать, если в `checkhealth` выдается ошибка `luarocks not found`? diff --git a/init.lua b/init.lua index 7f4af20..1dd6d20 100644 --- a/init.lua +++ b/init.lua @@ -1,7 +1,3 @@ --- Global settings params ---- Option to enable/disalbe obsidian plugin -vim.g.obsidian_enabled = false - -- Making leader () key to space vim.g.mapleader = "\\" -- Making local leader () key to backslash @@ -10,32 +6,5 @@ vim.g.maplocalleader = "" vim.opt.exrc = true vim.opt.secure = true --- Bootstrap lazy.nvim -local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" -if not (vim.uv or vim.loop).fs_stat(lazypath) then - local lazyrepo = "https://github.com/folke/lazy.nvim.git" - local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) - if vim.v.shell_error ~= 0 then - vim.api.nvim_echo({ - { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, - { out, "WarningMsg" }, - { "\nPress any key to exit..." }, - }, true, {}) - vim.fn.getchar() - os.exit(1) - end -end -vim.opt.rtp:prepend(lazypath) - --- Setup lazy.nvim -require("lazy").setup({ - spec = { - -- import your plugins - { import = "custom/plugins" }, - }, - -- Configure any other settings here. See the documentation for more details. - -- colorscheme that will be used when installing plugins. - install = { colorscheme = { "gruvbox-material" } }, - -- automatically check for plugin updates - checker = { enabled = false }, -}) +-- Plugins (vim.pack) +require "custom.pack" diff --git a/lua/custom/obsidian.lua b/lua/custom/obsidian.lua deleted file mode 100644 index 1d02283..0000000 --- a/lua/custom/obsidian.lua +++ /dev/null @@ -1,72 +0,0 @@ -require("obsidian").setup { - -- Set workspace setting - workspaces = { - { - name = "personal", - path = "~/Documents/t0xa_vault", - } - }, - -- Disable conceal level to supress varning log message - ui = { - enable = false - }, - -- Set notes subdir to store new notes - notes_subdir = "Unsorted", - new_notes_location = "notes_subdir", - -- Set template params - templates = { - folder = "Templates", - date_format = "%Y-%m-%d", - time_format = "%H:%M", - substitutions = { - yesterday = function() - return os.date("%Y-%m-%d", os.time() - 86400) - end - } - }, - -- Set behaviour of following links - follow_url_func = function(url) - -- vim.fn.jobstart({ "open", url }) -- Mac OS - vim.fn.jobstart({ "xdg-open", url }) -- linux - -- vim.cmd(':silent exec "!start ' .. url .. '"') -- Windows - -- vim.ui.open(url) -- need Neovim 0.10.0+ - end, - -- Set behaviour for opening images - follow_img_func = function(img) - -- vim.fn.jobstart { "qlmanage", "-p", img } -- Mac OS quick look preview - vim.fn.jobstart({ "xdg-open", url }) -- linux - -- vim.cmd(':silent exec "!start ' .. url .. '"') -- Windows - end, - -- Set sorting for creation date - sort_by = "created", - -- Set attachements new folder - attachments = { - img_folder = "Media" - }, - -- Disable auto formatter for files - disable_frontmatter = true, -} - - --- Obsidian-related keybinds -vim.keymap.set("n", "oit", "ObsidianTemplate", - { silent = true, noremap = true, desc = "Obsidian: insert template" }) -vim.keymap.set("n", "oo", "ObsidianQuickSwitch", - { silent = true, noremap = true, desc = "Obsidian: open file" }) -vim.keymap.set("n", "opi", "ObsidianPasteImg", - { silent = true, noremap = true, desc = "Obsidian: paste image" }) -vim.keymap.set("n", "or", "ObsidianRename", - { silent = true, noremap = true, desc = "Obsidian: rename file" }) -vim.keymap.set("n", "oc", "ObsidianToggleCheckbox", - { silent = true, noremap = true, desc = "Obsidian: toggle checkbox" }) -vim.keymap.set("n", "on", "ObsidianNew", { silent = true, noremap = true, desc = "Obsidian: new file" }) -vim.keymap.set("n", "otoc", "ObsidianTOC", - { silent = true, noremap = true, desc = "Obsidian: open TOC" }) -vim.keymap.set("n", "ofl", "ObsidianFollowLink", - { silent = true, noremap = true, desc = "Obsidian: follow link" }) -vim.keymap.set("n", "olt", "ObsidianTags", - { silent = true, noremap = true, desc = "Obsidian: Get tags list" }) -vim.keymap.set("n", "osb", "ObsidianBacklinks", - { silent = true, noremap = true, desc = "Obsidian: Show Backlinks" }) -vim.keymap.set("n", "osl", "ObsidianLinks", - { silent = true, noremap = true, desc = "Obsidian: Show Links" }) diff --git a/lua/custom/pack.lua b/lua/custom/pack.lua new file mode 100644 index 0000000..0f9f613 --- /dev/null +++ b/lua/custom/pack.lua @@ -0,0 +1,95 @@ +-- Plugin management via built-in vim.pack (Neovim 0.12+) +-- Lockfile: nvim-pack-lock.json (commit it). Update: :lua vim.pack.update() +-- Treesitter parsers are updated manually with :TSUpdate + +local gh = function(repo) return "https://github.com/" .. repo end + +-- Build hooks. Must be registered BEFORE vim.pack.add() +vim.api.nvim_create_autocmd("PackChanged", { + callback = function(ev) + local data = ev.data + if data.spec.name == "markdown-preview.nvim" and data.kind ~= "delete" then + -- Downloads the pre-built preview server + local cmd = vim.fn.has("win32") == 1 and { "cmd.exe", "/c", "install.cmd" } or { "./install.sh" } + vim.system(cmd, { cwd = data.path .. "/app" }):wait() + end + end, +}) + +-- Used by which-key +vim.o.timeout = true +vim.o.timeoutlen = 500 + +vim.pack.add({ + -- Libraries + gh("nvim-lua/plenary.nvim"), + gh("nvim-tree/nvim-web-devicons"), + gh("echasnovski/mini.icons"), + + -- Colorschemes + gh("folke/tokyonight.nvim"), + gh("ellisonleao/gruvbox.nvim"), + gh("sainnhe/everforest"), + gh("sainnhe/gruvbox-material"), + gh("rebelot/kanagawa.nvim"), + { src = gh("catppuccin/nvim"), name = "catppuccin" }, + gh("luisiacc/gruvbox-baby"), + + -- Treesitter + gh("nvim-treesitter/nvim-treesitter"), + + -- Completion & snippets + { src = gh("L3MON4D3/LuaSnip"), version = vim.version.range("2.*") }, + gh("onsails/lspkind.nvim"), + gh("hrsh7th/nvim-cmp"), + gh("hrsh7th/cmp-buffer"), + gh("hrsh7th/cmp-path"), + gh("hrsh7th/cmp-nvim-lsp"), + gh("saadparwaiz1/cmp_luasnip"), + + -- LSP + gh("neovim/nvim-lspconfig"), + gh("folke/lazydev.nvim"), + gh("mason-org/mason.nvim"), + gh("mason-org/mason-lspconfig.nvim"), + gh("WhoIsSethDaniel/mason-tool-installer.nvim"), + gh("j-hui/fidget.nvim"), + gh("stevearc/conform.nvim"), + + -- UI / navigation + gh("nvim-lualine/lualine.nvim"), + gh("ibhagwan/fzf-lua"), + gh("stevearc/oil.nvim"), + gh("stevearc/dressing.nvim"), + gh("folke/which-key.nvim"), + gh("folke/trouble.nvim"), + gh("folke/todo-comments.nvim"), + gh("christoomey/vim-tmux-navigator"), + + -- Tools + { src = gh("danymat/neogen"), version = vim.version.range("*") }, + gh("sammaji/markdown-preview.nvim"), +}) + +-- Plugins configured with defaults only +require("mini.icons").setup() +require("fidget").setup() +require("which-key").setup() +require("lazydev").setup({ + library = { + -- luv (vim.uv) types + { path = "${3rd}/luv/library", words = { "vim%.uv" } }, + }, +}) + +-- Plugins with custom configuration +require "custom.colorschemes" +require "custom.treesitter" +require "custom.completion" +require "custom.lsp" +require "custom.lualine" +require "custom.fzf_lua" +require "custom.oil" +require "custom.trouble" +require "custom.todo" +require "custom.neogen" diff --git a/lua/custom/plugins/colorschemes.lua b/lua/custom/plugins/colorschemes.lua deleted file mode 100644 index 7fe659b..0000000 --- a/lua/custom/plugins/colorschemes.lua +++ /dev/null @@ -1,20 +0,0 @@ --- TODO: Need to refactor ways of downloading colorschemes --- Now it is just a hack to download all colorschemes as dependecies -return { - "folke/tokyonight.nvim", - dependencies = { - "ellisonleao/gruvbox.nvim", - "sainnhe/everforest", - "sainnhe/gruvbox-material", - "rebelot/kanagawa.nvim", - "catppuccin/nvim", - "folke/tokyonight.nvim", - "luisiacc/gruvbox-baby", - }, - lazy = false, - priority = 1000, - config = function() - require "custom/colorschemes" - end, -} - diff --git a/lua/custom/plugins/completion.lua b/lua/custom/plugins/completion.lua deleted file mode 100644 index 2628a4c..0000000 --- a/lua/custom/plugins/completion.lua +++ /dev/null @@ -1,20 +0,0 @@ -return { - "hrsh7th/nvim-cmp", - event = "InsertEnter", -- Only load plugin when in INSERT mode - dependencies = { - "hrsh7th/cmp-buffer", -- source for text in buffer - "hrsh7th/cmp-path", -- source for file system paths - { - "L3MON4D3/LuaSnip", - -- follow latest release. - version = "v2.*", -- Replace by the latest released major (first number of latest release) - }, - "saadparwaiz1/cmp_luasnip", -- for autocompletion - "rafamadriz/friendly-snippets", -- useful snippets - "onsails/lspkind.nvim", -- vs-code like pictograms - "hrsh7th/cmp-nvim-lsp", - }, - config = function() - require "custom/completion" - end, -} diff --git a/lua/custom/plugins/dressing.lua b/lua/custom/plugins/dressing.lua deleted file mode 100644 index feadb27..0000000 --- a/lua/custom/plugins/dressing.lua +++ /dev/null @@ -1,4 +0,0 @@ -return { - "stevearc/dressing.nvim", - event = "VeryLazy" -} diff --git a/lua/custom/plugins/fzf_lua.lua b/lua/custom/plugins/fzf_lua.lua deleted file mode 100644 index e363d16..0000000 --- a/lua/custom/plugins/fzf_lua.lua +++ /dev/null @@ -1,9 +0,0 @@ -return { - "ibhagwan/fzf-lua", - dependencies = { "nvim-tree/nvim-web-devicons" }, - opts = {}, - config = function() - require "custom.fzf_lua" - end - -} diff --git a/lua/custom/plugins/lsp.lua b/lua/custom/plugins/lsp.lua deleted file mode 100644 index 022c2eb..0000000 --- a/lua/custom/plugins/lsp.lua +++ /dev/null @@ -1,35 +0,0 @@ -return { - { - "neovim/nvim-lspconfig", - dependencies = { - { - --`lazydev` configures Lua LSP for your Neovim config, runtime and plugins - -- used for completion, annotations and signatures of Neovim apis - "folke/lazydev.nvim", - ft = "lua", - opts = { - library = { - -- Load luvit types when the `vim.uv` word is found - { path = "luvit-meta/library", words = { "vim%.uv" } }, - }, - }, - }, - { "Bilal2453/luvit-meta", lazy = true }, - "williamboman/mason.nvim", - "williamboman/mason-lspconfig.nvim", - "WhoIsSethDaniel/mason-tool-installer.nvim", - - -- Some enhancements for notifications in bottom-right corner - { "j-hui/fidget.nvim", opts = {} }, - - -- Following plugin enables enhancements for diagnostics info - -- { "https://git.sr.ht/~whynothugo/lsp_lines.nvim" }, - - -- Autoformatting - "stevearc/conform.nvim", - }, - config = function() - require "custom/lsp" - end, - }, -} diff --git a/lua/custom/plugins/lualine.lua b/lua/custom/plugins/lualine.lua deleted file mode 100644 index 03460e3..0000000 --- a/lua/custom/plugins/lualine.lua +++ /dev/null @@ -1,7 +0,0 @@ -return { - "nvim-lualine/lualine.nvim", - dependencies = { "nvim-tree/nvim-web-devicons" }, - config = function() - require "custom/lualine" - end, -} diff --git a/lua/custom/plugins/luasnip.lua b/lua/custom/plugins/luasnip.lua deleted file mode 100644 index 99006fc..0000000 --- a/lua/custom/plugins/luasnip.lua +++ /dev/null @@ -1,9 +0,0 @@ -return { - { - "L3MON4D3/LuaSnip", - -- follow latest release. - version = "v2.*", -- Replace by the latest released major (first number of latest release) - -- install jsregexp (optional!). - build = "make install_jsregexp" - } -} diff --git a/lua/custom/plugins/markdown_preview.lua b/lua/custom/plugins/markdown_preview.lua deleted file mode 100644 index 6f124b8..0000000 --- a/lua/custom/plugins/markdown_preview.lua +++ /dev/null @@ -1,11 +0,0 @@ -return { - "iamcco/markdown-preview.nvim", - cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" }, - build = "cd app && npm install && git restore .", - -- or if you use yarn: (I have not checked this, I use npm) - -- build = "cd app && yarn install && git restore .", - init = function() - vim.g.mkdp_filetypes = { "markdown" } - end, - ft = { "markdown" }, -} diff --git a/lua/custom/plugins/neogen.lua b/lua/custom/plugins/neogen.lua deleted file mode 100644 index 1f0174e..0000000 --- a/lua/custom/plugins/neogen.lua +++ /dev/null @@ -1,12 +0,0 @@ --- Plugin for generating annotations -return { - { - "danymat/neogen", - config = true, - -- Uncomment next line if you want to follow only stable versions - version = "*", - config = function() - require "custom/neogen" - end, - } -} diff --git a/lua/custom/plugins/obsidian.lua b/lua/custom/plugins/obsidian.lua deleted file mode 100644 index 0f9377d..0000000 --- a/lua/custom/plugins/obsidian.lua +++ /dev/null @@ -1,16 +0,0 @@ -if vim.g.obsidian_enabled then - return { - "epwalsh/obsidian.nvim", - version = "*", - lazy = true, - ft = "markdown", - dependencies = { - "nvim-lua/plenary.nvim", - }, - config = function() - require "custom.obsidian" - end - } -else - return {} -end diff --git a/lua/custom/plugins/oil.lua b/lua/custom/plugins/oil.lua deleted file mode 100644 index 96156df..0000000 --- a/lua/custom/plugins/oil.lua +++ /dev/null @@ -1,8 +0,0 @@ -return { - "stevearc/oil.nvim", - dependencies = { { "echasnovski/mini.icons", opts = {} } }, - config = function() - require "custom/oil" - end, -} - diff --git a/lua/custom/plugins/telescope.lua b/lua/custom/plugins/telescope.lua deleted file mode 100644 index 68acb53..0000000 --- a/lua/custom/plugins/telescope.lua +++ /dev/null @@ -1,13 +0,0 @@ -return { - "nvim-telescope/telescope.nvim", - enabled = false, - dependencies = { - { "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, - "nvim-lua/plenary.nvim", - "nvim-tree/nvim-web-devicons", - "folke/todo-comments.nvim", - }, - config = function() - require "custom.telescope" - end -} diff --git a/lua/custom/plugins/tmux_navigator.lua b/lua/custom/plugins/tmux_navigator.lua deleted file mode 100644 index b1b48a6..0000000 --- a/lua/custom/plugins/tmux_navigator.lua +++ /dev/null @@ -1,19 +0,0 @@ -return { - "christoomey/vim-tmux-navigator", - cmd = { - "TmuxNavigateLeft", - "TmuxNavigateDown", - "TmuxNavigateUp", - "TmuxNavigateRight", - "TmuxNavigatePrevious", - "TmuxNavigatorProcessList", - }, - keys = { - { "", "TmuxNavigateLeft" }, - { "", "TmuxNavigateDown" }, - { "", "TmuxNavigateUp" }, - { "", "TmuxNavigateRight" }, - { "", "TmuxNavigatePrevious" }, - }, -} --- return {} diff --git a/lua/custom/plugins/todo.lua b/lua/custom/plugins/todo.lua deleted file mode 100644 index 76b7eee..0000000 --- a/lua/custom/plugins/todo.lua +++ /dev/null @@ -1,8 +0,0 @@ -return { - "folke/todo-comments.nvim", - event = { "BufReadPre", "BufNewFile" }, - dependencies = { "nvim-lua/plenary.nvim" }, - config = function() - require "custom/todo" - end, -} diff --git a/lua/custom/plugins/treesitter.lua b/lua/custom/plugins/treesitter.lua deleted file mode 100644 index b7faedc..0000000 --- a/lua/custom/plugins/treesitter.lua +++ /dev/null @@ -1,8 +0,0 @@ -return { - 'nvim-treesitter/nvim-treesitter', - lazy = false, - build = ':TSUpdate', - config = function() - require "custom/treesitter" - end, -} diff --git a/lua/custom/plugins/trouble.lua b/lua/custom/plugins/trouble.lua deleted file mode 100644 index fe73a96..0000000 --- a/lua/custom/plugins/trouble.lua +++ /dev/null @@ -1,10 +0,0 @@ -return { - { - "folke/trouble.nvim", - opts = {}, -- for default options, refer to the configuration section for custom setup. - cmd = "Trouble", - config = function() - require "custom/trouble" - end, - }, -} diff --git a/lua/custom/plugins/which_key.lua b/lua/custom/plugins/which_key.lua deleted file mode 100644 index f2cff19..0000000 --- a/lua/custom/plugins/which_key.lua +++ /dev/null @@ -1,20 +0,0 @@ -return { - "folke/which-key.nvim", - -- Telling nvim that it can load this plugin later, and that it is not - -- that important for initial UI - event = "VeryLazy", - -- Function that will run while neovim startup instead of when plugin is actualy loads - init = function() - -- How long which-key will wait until activation - vim.o.timeout = true - vim.o.timeoutlen = 500 - end, - -- Options that will pass to setup function, but we are leaving it empty to use - -- default configuration - opts = { - -- your configuration comes here - -- or leave it empty to use the default settings - -- refer to the configuration section below - } -} - diff --git a/lua/custom/telescope.lua b/lua/custom/telescope.lua deleted file mode 100644 index b998bc0..0000000 --- a/lua/custom/telescope.lua +++ /dev/null @@ -1,133 +0,0 @@ -require("telescope").setup { - defaults = { - vimgrep_arguments = { - "rg", - "--color=never", - "--no-heading", - "--with-filename", - "--line-number", - "--column", - "--smart-case", - }, - path_display = { shorten = 4 }, - }, -} - --- Load fzf extension to imporve performance -pcall(require("telescope").load_extension, "fzf") - --- Glob pattern searcher -local function live_grep_with_glob() - vim.ui.input({ - prompt = "Glob pattern: ", - default = "/home/user/Work/root/ivideon/audio_storage/", -- Optional default value - }, function(input) - if input then - require('telescope.builtin').live_grep({ - -- glob_pattern = input, - search_dirs = { input } - }) - end - end) -end - -local function live_grep_in_current_dir() - -- Get currentp path - local search_dirs = { vim.fn.expand('%:p') } - -- Extract path from table - local current_dir = search_dirs[1] - -- Get path, cutting last entry (current file) - local result = current_dir:match(".*/") - vim.ui.input({ - prompt = "Glob pattern: ", - default = result, -- Optional default value - }, function(input) - if input then - require('telescope.builtin').live_grep({ - search_dirs = { input } - }) - end - end) -end - --- Function for copying current file path -local function copy_current_file_path() - local filepath = vim.fn.expand('%:p') - vim.fn.setreg("+", filepath) - print("Copied: " .. filepath) -end - --- Function for gettings snapshot of current cursor position -local function copy_file_path_and_position() - local filepath = vim.fn.expand('%:p') - local cursor_pos = vim.api.nvim_win_get_cursor(0) - local line = cursor_pos[1] - local col = cursor_pos[2] - - local output = string.format("%s:%d:%d", filepath, line, col) - - vim.fn.setreg("+", output) - - print("Copied: " .. output) -end - --- Function for getting filename and copy it to + buffer -local function copy_filename() - local filepath = vim.fn.expand('%:t') - local output = string.format("[[%s]]", filepath) - vim.fn.setreg("+", output) - print("Copied: " .. output) -end - - -local builtin = require("telescope.builtin") -local keymap = vim.keymap - --- Live grep in quickfix list -local function live_grep_in_quick_fix_list_files() - builtin.live_grep({ - search_dirs = vim.fn.getqflist({ items = 0 }).items - and vim.tbl_map(function(item) - return vim.fn.bufname(item.bufnr) - end, vim.fn.getqflist()) - or nil - }) -end - --- Find files with hidden included -local function find_files_with_hidden_included() - require('telescope.builtin').find_files({ - hidden = true, - no_ignore = true, - }) -end - --- Create a Neovim command -vim.api.nvim_create_user_command('TelescopeGrepGlob', live_grep_with_glob, {}) - -keymap.set("n", "ff", builtin.find_files, { desc = "FZF: find files in cwd" }) -keymap.set("n", "fml", builtin.marks, { desc = "FZF: find marks list" }) -keymap.set("n", "fmp", builtin.man_pages, { desc = "FZF: find available man pages" }) -keymap.set("n", "fg", builtin.live_grep, { desc = "FZF: find string in cwd" }) -keymap.set("n", "fs", builtin.grep_string, { desc = "FZF: find string under cursor" }) -keymap.set("n", "fb", builtin.buffers, { desc = "FZF: display opened buffers" }) -keymap.set("n", "fh", builtin.help_tags, { desc = "FZF: display help tags" }) -keymap.set("n", "ft", "TodoTelescope", { desc = "FZF: display TODO comments" }) -keymap.set("n", "fds", builtin.lsp_document_symbols, { desc = "Grep: Document symbols" }) -keymap.set('n', 'fp', live_grep_with_glob, { desc = 'Live grep with glob pattern' }) -keymap.set('n', 'fcp', live_grep_in_current_dir, { desc = 'Live grep in current directory' }) -keymap.set('n', 'ccp', copy_file_path_and_position, { desc = "Copy cursor position" }) -keymap.set('n', 'ccf', copy_filename, { desc = "Copy only filename" }) -keymap.set('n', 'ccd', copy_current_file_path, { desc = 'Live grep in current directory' }) -keymap.set('n', 'fq', live_grep_in_quick_fix_list_files, { desc = "Live grep in quickfix files" }) -keymap.set('n', 'fa', find_files_with_hidden_included, { desc = "Find all files (hidden + no ignore)" }) - --- Live grep in current file -vim.keymap.set('n', 'fcf', function() - require('telescope.builtin').live_grep({ - search_dirs = { vim.fn.expand('%:p') }, -- Current file's full path - -- disable_coordinates = true, -- Hide line/column numbers - -- fname_width = 0, -- Hide filename column - path_display = { 'hidden' }, - }) -end, { desc = 'Live grep in current file' }) diff --git a/lua/custom/todo.lua b/lua/custom/todo.lua index e10a301..92c5fa2 100644 --- a/lua/custom/todo.lua +++ b/lua/custom/todo.lua @@ -9,4 +9,4 @@ keymap.set("n", "[t", function() todo_comments.jump_prev() end, { desc = "Previous todo comment" }) -todo_comments.setup(opts) +todo_comments.setup() diff --git a/nvim-pack-lock.json b/nvim-pack-lock.json new file mode 100644 index 0000000..6ab45c3 --- /dev/null +++ b/nvim-pack-lock.json @@ -0,0 +1,146 @@ +{ + "plugins": { + "LuaSnip": { + "rev": "642b0c595e11608b4c18219e93b88d7637af27bc", + "src": "https://github.com/L3MON4D3/LuaSnip", + "version": "2.0.0 - 3.0.0" + }, + "catppuccin": { + "rev": "edefef779ab08ce1a4a404713e3012b0d202bd35", + "src": "https://github.com/catppuccin/nvim" + }, + "cmp-buffer": { + "rev": "b74fab3656eea9de20a9b8116afa3cfc4ec09657", + "src": "https://github.com/hrsh7th/cmp-buffer" + }, + "cmp-nvim-lsp": { + "rev": "cbc7b02bb99fae35cb42f514762b89b5126651ef", + "src": "https://github.com/hrsh7th/cmp-nvim-lsp" + }, + "cmp-path": { + "rev": "c642487086dbd9a93160e1679a1327be111cbc25", + "src": "https://github.com/hrsh7th/cmp-path" + }, + "cmp_luasnip": { + "rev": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90", + "src": "https://github.com/saadparwaiz1/cmp_luasnip" + }, + "conform.nvim": { + "rev": "016802de402556da54c36bd7359b441266b01cdd", + "src": "https://github.com/stevearc/conform.nvim" + }, + "dressing.nvim": { + "rev": "2d7c2db2507fa3c4956142ee607431ddb2828639", + "src": "https://github.com/stevearc/dressing.nvim" + }, + "everforest": { + "rev": "85a86eb62409e3ec88713bff3d1b9d7374e112e4", + "src": "https://github.com/sainnhe/everforest" + }, + "fidget.nvim": { + "rev": "9e0201673e08e997e7cf52afca5565c70bd117f3", + "src": "https://github.com/j-hui/fidget.nvim" + }, + "fzf-lua": { + "rev": "48d7c3db291a2c7c1825905c227a6bc81c83b837", + "src": "https://github.com/ibhagwan/fzf-lua" + }, + "gruvbox-baby": { + "rev": "bd52e62d8134647090108189e69c8b3cd18bdbbf", + "src": "https://github.com/luisiacc/gruvbox-baby" + }, + "gruvbox-material": { + "rev": "11d779b26a9ab2b3db8c22c6ac9fb6e8ed4fea79", + "src": "https://github.com/sainnhe/gruvbox-material" + }, + "gruvbox.nvim": { + "rev": "154eb5ff5b96d0641307113fa385eaf0d36d9796", + "src": "https://github.com/ellisonleao/gruvbox.nvim" + }, + "kanagawa.nvim": { + "rev": "bb85e4bfc8d89b0e62c8fa53ccdd13d12e2f77b3", + "src": "https://github.com/rebelot/kanagawa.nvim" + }, + "lazydev.nvim": { + "rev": "ff2cbcba459b637ec3fd165a2be59b7bbaeedf0d", + "src": "https://github.com/folke/lazydev.nvim" + }, + "lspkind.nvim": { + "rev": "c7274c48137396526b59d86232eabcdc7fed8a32", + "src": "https://github.com/onsails/lspkind.nvim" + }, + "lualine.nvim": { + "rev": "221ce6b2d999187044529f49da6554a92f740a96", + "src": "https://github.com/nvim-lualine/lualine.nvim" + }, + "markdown-preview.nvim": { + "rev": "ec05f00643513d2e819dcc9176e3a4a0930e33a4", + "src": "https://github.com/sammaji/markdown-preview.nvim" + }, + "mason-lspconfig.nvim": { + "rev": "e17625cdc8c2650787467398e02c5d63a2cde966", + "src": "https://github.com/mason-org/mason-lspconfig.nvim" + }, + "mason-tool-installer.nvim": { + "rev": "443f1ef8b5e6bf47045cb2217b6f748a223cf7dc", + "src": "https://github.com/WhoIsSethDaniel/mason-tool-installer.nvim" + }, + "mason.nvim": { + "rev": "2a6940af80375532e5e9e7c1f2fc6319a1b7a69d", + "src": "https://github.com/mason-org/mason.nvim" + }, + "mini.icons": { + "rev": "f642e3ba8c12afbc8f32f6d77ef6597eac56786f", + "src": "https://github.com/echasnovski/mini.icons" + }, + "neogen": { + "rev": "b2e78708876f4da507839726816010a68e33fec8", + "src": "https://github.com/danymat/neogen", + "version": ">=0.0.0" + }, + "nvim-cmp": { + "rev": "2ffe79f1f021def8dd1fcd81deb16f1bb0d989f3", + "src": "https://github.com/hrsh7th/nvim-cmp" + }, + "nvim-lspconfig": { + "rev": "c59fc922f718fa055f69f5f3bc888f23211571eb", + "src": "https://github.com/neovim/nvim-lspconfig" + }, + "nvim-treesitter": { + "rev": "1a4f47b03dfe92d28de7d5654c67327ef008c9e6", + "src": "https://github.com/nvim-treesitter/nvim-treesitter" + }, + "nvim-web-devicons": { + "rev": "58447c1fca354bbf184425e4a8d01deecbd6f3c4", + "src": "https://github.com/nvim-tree/nvim-web-devicons" + }, + "oil.nvim": { + "rev": "b73018b75affd13fa38e2fc94ef753b465f770d7", + "src": "https://github.com/stevearc/oil.nvim" + }, + "plenary.nvim": { + "rev": "74b06c6c75e4eeb3108ec01852001636d85a932b", + "src": "https://github.com/nvim-lua/plenary.nvim" + }, + "todo-comments.nvim": { + "rev": "31e3c38ce9b29781e4422fc0322eb0a21f4e8668", + "src": "https://github.com/folke/todo-comments.nvim" + }, + "tokyonight.nvim": { + "rev": "cdc07ac78467a233fd62c493de29a17e0cf2b2b6", + "src": "https://github.com/folke/tokyonight.nvim" + }, + "trouble.nvim": { + "rev": "bd67efe408d4816e25e8491cc5ad4088e708a69a", + "src": "https://github.com/folke/trouble.nvim" + }, + "vim-tmux-navigator": { + "rev": "e41c431a0c7b7388ae7ba341f01a0d217eb3a432", + "src": "https://github.com/christoomey/vim-tmux-navigator" + }, + "which-key.nvim": { + "rev": "3aab2147e74890957785941f0c1ad87d0a44c15a", + "src": "https://github.com/folke/which-key.nvim" + } + } +}