From 07ddd3d2782dca0920faf74be072cb748633a8a1 Mon Sep 17 00:00:00 2001 From: Axlefublr <101342105+Axlefublr@users.noreply.github.com> Date: Thu, 20 Jun 2024 23:22:47 +0800 Subject: [PATCH] feat(completion): add `nvim-cmp-buffer-lines` (#1056) * feat(completion): add `nvim-cmp-buffer-lines` * Update lua/astrocommunity/completion/nvim-cmp-buffer-lines/README.md Co-authored-by: Uzair Aftab <48220549+Uzaaft@users.noreply.github.com> * fix readme wording * add note to readme --------- Co-authored-by: Uzair Aftab <48220549+Uzaaft@users.noreply.github.com> --- .../nvim-cmp-buffer-lines/README.md | 7 +++++ .../completion/nvim-cmp-buffer-lines/init.lua | 27 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 lua/astrocommunity/completion/nvim-cmp-buffer-lines/README.md create mode 100644 lua/astrocommunity/completion/nvim-cmp-buffer-lines/init.lua diff --git a/lua/astrocommunity/completion/nvim-cmp-buffer-lines/README.md b/lua/astrocommunity/completion/nvim-cmp-buffer-lines/README.md new file mode 100644 index 000000000..ab35a432e --- /dev/null +++ b/lua/astrocommunity/completion/nvim-cmp-buffer-lines/README.md @@ -0,0 +1,7 @@ +# nvim-cmp-buffer-lines + +nvim-cmp source for buffer lines + +**Repository:** + +_Replaces_ the `` whole line complete, instead of being included in the usual completion menu. diff --git a/lua/astrocommunity/completion/nvim-cmp-buffer-lines/init.lua b/lua/astrocommunity/completion/nvim-cmp-buffer-lines/init.lua new file mode 100644 index 000000000..f1ab1eb50 --- /dev/null +++ b/lua/astrocommunity/completion/nvim-cmp-buffer-lines/init.lua @@ -0,0 +1,27 @@ +---@type LazySpec +return { + "hrsh7th/nvim-cmp", + dependencies = { + { "amarakon/nvim-cmp-buffer-lines" }, + }, + opts = function(_, opts) + local cmp = require "cmp" + return require("astrocore").extend_tbl(opts, { + mapping = { + [""] = cmp.mapping.complete { -- this could've been a more ergonomic hotkey, but it would be a reach to try to make up one, that would fit everyone. + config = { + sources = { + { + name = "buffer-lines", + priority = 50, + option = { + leading_whitespace = false, + }, + }, + }, + }, + }, + }, + }) + end, +}