From bdbf733def78dbb58a2ceddb323ad44bf8d4295e Mon Sep 17 00:00:00 2001 From: Tigor Hutasuhut Date: Thu, 1 Aug 2024 18:21:54 +0700 Subject: [PATCH] cmp: path now uses async_path plugin source --- lazy-lock.json | 5 +- lua/plugins/cmp.lua | 110 ++++++++++++++++++++++++-------------------- 2 files changed, 62 insertions(+), 53 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index b9a4369..57f6a51 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -7,6 +7,7 @@ "before.nvim": { "branch": "master", "commit": "42294a3ba5dc02d3f3a9fe4e9a033ef29da6dcc6" }, "bufferline.nvim": { "branch": "main", "commit": "0b2fd861eee7595015b6561dade52fb060be10c4" }, "catppuccin": { "branch": "main", "commit": "10eda02ea4faa7d1f94e77a3410a4ae91c25c5f5" }, + "cmp-async-path": { "branch": "main", "commit": "7df7f3721c45aac26b6e0474087538f4681c9c7a" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, @@ -67,13 +68,13 @@ "nvim-treesitter-endwise": { "branch": "master", "commit": "8b34305ffc28bd75a22f5a0a9928ee726a85c9a6" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "34867c69838078df7d6919b130c0541c0b400c47" }, "nvim-ts-autotag": { "branch": "main", "commit": "dc5e1687ab76ee02e0f11c5ce137f530b36e98b3" }, - "obsidian.nvim": { "branch": "main", "commit": "b92e75b7e711161467ca4805260b787e652358bf" }, + "obsidian.nvim": { "branch": "main", "commit": "7466e3f70ffde1d3d8daf2d724da4ea9b4fa3642" }, "one-small-step-for-vimkind": { "branch": "main", "commit": "730189c92c6fd80eb92bb6c1886392a142dba273" }, "persistence.nvim": { "branch": "main", "commit": "f6aad7dde7fcf54148ccfc5f622c6d5badd0cc3d" }, "plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" }, "presence.nvim": { "branch": "main", "commit": "87c857a56b7703f976d3a5ef15967d80508df6e6" }, "project.nvim": { "branch": "main", "commit": "8c6bad7d22eef1b71144b401c9f74ed01526a4fb" }, - "render-markdown": { "branch": "main", "commit": "ef0c921858cbe079d40304200af60b6ce0c99429" }, + "render-markdown": { "branch": "main", "commit": "4d046cdf65393a62c0eb209e01574b39f28bc01b" }, "rose-pine": { "branch": "main", "commit": "e4b08d74b7272cb21e4e9c71b8b9e0830fd722fe" }, "rustaceanvim": { "branch": "master", "commit": "047f9c9d8cd2861745eb9de6c1570ee0875aa795" }, "silicon.lua": { "branch": "main", "commit": "f1387c8e2e69743899d6da6d4bd0e42be5ac5fa0" }, diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua index 49ae531..8fae20d 100644 --- a/lua/plugins/cmp.lua +++ b/lua/plugins/cmp.lua @@ -1,62 +1,70 @@ return { - "hrsh7th/nvim-cmp", - dependencies = { - "hrsh7th/cmp-cmdline", - "hrsh7th/cmp-nvim-lsp-document-symbol", - -- "hrsh7th/cmp-nvim-lsp-signature-help", - { "lukas-reineke/cmp-rg", enabled = vim.fn.exepath "rg" ~= "" }, + { + "hrsh7th/cmp-path", + enabled = false, }, - event = { "InsertEnter", "CmdlineEnter" }, - opts = function(_, opts) - local cmp = require "cmp" + { + "hrsh7th/nvim-cmp", + dependencies = { + "hrsh7th/cmp-cmdline", + "hrsh7th/cmp-nvim-lsp-document-symbol", + "https://codeberg.org/FelipeLema/cmp-async-path.git", + -- "hrsh7th/cmp-nvim-lsp-signature-help", + { "lukas-reineke/cmp-rg", enabled = vim.fn.exepath "rg" ~= "" }, + }, + event = { "InsertEnter", "CmdlineEnter" }, + opts = function(_, opts) + local cmp = require "cmp" + table.insert(opts.sources, 3, { name = "async_path" }) - if vim.fn.exepath "rg" ~= "" then - table.insert(opts.sources, 3, { name = "rg" }) - end + if vim.fn.exepath "rg" ~= "" then + table.insert(opts.sources, 4, { name = "rg" }) + end - opts.preselect = cmp.PreselectMode.None + opts.preselect = cmp.PreselectMode.None - opts.mapping = cmp.mapping.preset.insert { - [""] = function(fallback) - cmp.abort() - fallback() - end, - [""] = cmp.mapping.confirm { select = true }, - [""] = cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Insert }, - [""] = cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Insert }, - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.complete(), - [""] = cmp.mapping.abort(), - [""] = cmp.mapping.confirm { - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }, -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. - } + opts.mapping = cmp.mapping.preset.insert { + [""] = function(fallback) + cmp.abort() + fallback() + end, + [""] = cmp.mapping.confirm { select = true }, + [""] = cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Insert }, + [""] = cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Insert }, + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }, -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + } - ---@diagnostic disable-next-line: missing-fields - cmp.setup.cmdline(":", { - mapping = cmp.mapping.preset.cmdline(), - sources = cmp.config.sources { - { name = "path" }, - { - name = "cmdline", - option = { - ignore_cmds = { "Man", "!" }, + ---@diagnostic disable-next-line: missing-fields + cmp.setup.cmdline(":", { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources { + { name = "async_path" }, + { + name = "cmdline", + option = { + ignore_cmds = { "Man", "!" }, + }, }, }, - }, - }) + }) - ---@diagnostic disable-next-line: missing-fields - cmp.setup.cmdline("/", { - mapping = cmp.mapping.preset.cmdline(), - sources = cmp.config.sources { - { name = "nvim_lsp_document_symbol" }, - { name = "buffer" }, - }, - }) + ---@diagnostic disable-next-line: missing-fields + cmp.setup.cmdline("/", { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources { + { name = "nvim_lsp_document_symbol" }, + { name = "buffer" }, + }, + }) - return opts - end, + return opts + end, + }, }