From 2cb9af61acfda466b747e5b18c947d1538c1240e Mon Sep 17 00:00:00 2001 From: Jean-Pierre Appel Date: Mon, 15 Jan 2024 16:15:05 -0500 Subject: refactor: setup completions less insanely --- nvim/lua/plugins/harpoon.lua | 26 +++++++++++----- nvim/lua/plugins/init.lua | 15 --------- nvim/lua/plugins/nvim-cmp.lua | 72 ++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 90 insertions(+), 23 deletions(-) (limited to 'nvim') diff --git a/nvim/lua/plugins/harpoon.lua b/nvim/lua/plugins/harpoon.lua index 061ca9e..123b5db 100644 --- a/nvim/lua/plugins/harpoon.lua +++ b/nvim/lua/plugins/harpoon.lua @@ -6,41 +6,53 @@ return { require("harpoon"):setup() end, keys = { - {"", function() + { + "", + function() local harpoon = require("harpoon") harpoon.ui:toggle_quick_menu(harpoon:list()) end, desc = "Open Harpoon Quickmenu" }, - {"m", function() + { + "m", + function() local harpoon = require("harpoon") harpoon:list():append() end, desc = "Add file to harpoon" }, - {"1", function() + { + "1", + function() local harpoon = require("harpoon") harpoon:list():select(1) end, desc = "Navigate to the first file" }, - {"2", function() + { + "2", + function() local harpoon = require("harpoon") harpoon:list():select(2) end, desc = "Navigate to the second file" }, - {"3", function() + { + "3", + function() local harpoon = require("harpoon") harpoon:list():select(3) end, desc = "Navigate to the third file" }, - {"4", function() + { + "4", + function() local harpoon = require("harpoon") harpoon:list():select(4) end, desc = "Navigate to the fourth file" }, - } + } } diff --git a/nvim/lua/plugins/init.lua b/nvim/lua/plugins/init.lua index 5c90a28..92e3b5f 100644 --- a/nvim/lua/plugins/init.lua +++ b/nvim/lua/plugins/init.lua @@ -3,21 +3,6 @@ return { -- common dependacy "nvim-lua/plenary.nvim", - -- completion - -- TODO:config completion and setup binds - 'hrsh7th/nvim-cmp', - { - 'hrsh7th/cmp-nvim-lsp', - dependencies = { {'hrsh7th/nvim-cmp'}, {'neovim/nvim-lspconfig'} } - }, - { - 'hrsh7th/cmp-path', - dependencies = { 'hrsh7th/nvim-cmp' } - }, - { - 'kdheepak/cmp-latex-symbols', - dependencies = { 'hrsh7th/nvim-cmp' } - }, { 'numToStr/Comment.nvim', -- faster commentting diff --git a/nvim/lua/plugins/nvim-cmp.lua b/nvim/lua/plugins/nvim-cmp.lua index 32285bf..b560732 100644 --- a/nvim/lua/plugins/nvim-cmp.lua +++ b/nvim/lua/plugins/nvim-cmp.lua @@ -216,4 +216,74 @@ function user.insert_tab() ) end -return Plugins +-- return Plugins + +return { + { + "L3MON4D3/LuaSnip", + version = "v2.*", + build = "make install_jsregexp" + }, + -- completion sources + { + 'hrsh7th/cmp-path', + }, + { + 'saadparwaiz1/cmp_luasnip' + }, + { -- TODO: lazy load on filtetype + 'hrsh7th/cmp-nvim-lua' + }, + { + -- TODO: lazy load on lsp load + 'hrsh7th/cmp-nvim-lsp', + dependencies= { + 'neovim/nvim-lspconfig' + }, + }, + { + 'hrsh7th/cmp-buffer', + }, + { + 'hrsh7th/nvim-cmp', + config = function() + local cmp = require('cmp') + cmp.setup({ + snippet = { + expand = function(args) + require('luasnip').lsp_expand(args.body) + end + }, + sources = { + { name = 'nvim_lsp', keyword_length = 3 }, + { name = 'luasnip', keyword_length = 2 }, + { name = 'path' }, + { name = 'nvim_lua' }, + { name = 'buffer', keyword_length = 3 } + -- TODO: add more sources + }, + window = { + -- TODO: style cmp windows + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered() + }, + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.scroll_docs(-5), + [''] = cmp.mapping.scroll_docs(5), + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.confirm({select = true }) + else + fallback() + end + end, {'i', 's'}) + }) + }) + end + }, + + -- { + -- 'kdheepak/cmp-latex-symbols', + -- dependencies = { 'hrsh7th/nvim-cmp' } + -- }, +} -- cgit v1.2.3