From af0c5c0825bd50c127ffe14b30383be7ce5a458d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20La=C3=ADn?= Date: Thu, 21 Sep 2023 17:43:35 +0200 Subject: [PATCH] Changed the binds for telescope and cmp as well as adding fzf native for telescope --- .config/nvim/lua/plugins/cmp.lua | 62 ++++++++++++++++++++++++++ .config/nvim/lua/plugins/telescope.lua | 16 ++++++- 2 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 .config/nvim/lua/plugins/cmp.lua diff --git a/.config/nvim/lua/plugins/cmp.lua b/.config/nvim/lua/plugins/cmp.lua new file mode 100644 index 00000000..e112ae35 --- /dev/null +++ b/.config/nvim/lua/plugins/cmp.lua @@ -0,0 +1,62 @@ +return { + { + "hrsh7th/nvim-cmp", + version = false, -- last release is way too old + event = "InsertEnter", + dependencies = { + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "saadparwaiz1/cmp_luasnip", + }, + opts = function() + vim.api.nvim_set_hl(0, "CmpGhostText", { link = "Comment", default = true }) + local cmp = require("cmp") + local defaults = require("cmp.config.default")() + return { + completion = { + completeopt = "menu,menuone,noinsert", + }, + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ + [""] = 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({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + [""] = cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + }), + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "buffer" }, + { name = "path" }, + }), + formatting = { + format = function(_, item) + local icons = require("lazyvim.config").icons.kinds + if icons[item.kind] then + item.kind = icons[item.kind] .. item.kind + end + return item + end, + }, + experimental = { + ghost_text = { + hl_group = "CmpGhostText", + }, + }, + sorting = defaults.sorting, + } + end, + }, +} diff --git a/.config/nvim/lua/plugins/telescope.lua b/.config/nvim/lua/plugins/telescope.lua index 75e792c1..b7c15e72 100644 --- a/.config/nvim/lua/plugins/telescope.lua +++ b/.config/nvim/lua/plugins/telescope.lua @@ -6,7 +6,13 @@ return { commit = vim.fn.has("nvim-0.9.0") == 0 and "057ee0f8783" or nil, cmd = "Telescope", version = false, -- telescope did only one release, so use HEAD for now - dependencies = {}, + dependencies = { + "nvim-telescope/telescope-fzf-native.nvim", + build = "make", + config = function() + require("telescope").load_extension("fzf") + end, + }, keys = { { ",", @@ -355,6 +361,7 @@ return { }, }, config = function() + local actions = require("telescope.actions") require("telescope").setup({ defaults = { file_ignore_patterns = { @@ -367,6 +374,13 @@ return { "*/tmp/*", "Juegos/", }, + mappings = { + i = { + [""] = actions.move_selection_previous, + [""] = actions.move_selection_next, + [""] = actions.send_selected_to_qflist + actions.open_qflist, + }, + }, }, pickers = { find_files = {