aboutsummaryrefslogtreecommitdiffstats
path: root/nvim
diff options
context:
space:
mode:
authorJean-Pierre Appel <jeanpierre.appel01@gmail.com>2024-01-15 16:15:05 -0500
committerJean-Pierre Appel <jeanpierre.appel01@gmail.com>2024-01-15 16:15:05 -0500
commit2cb9af61acfda466b747e5b18c947d1538c1240e (patch)
treecdb258438ffc2d255cf16eb8988fa0f4f7954e6d /nvim
parentbe7a52c6885048ed618f312070e55ab25bafb60d (diff)
refactor: setup completions less insanely
Diffstat (limited to 'nvim')
-rw-r--r--nvim/lua/plugins/harpoon.lua26
-rw-r--r--nvim/lua/plugins/init.lua15
-rw-r--r--nvim/lua/plugins/nvim-cmp.lua72
3 files changed, 90 insertions, 23 deletions
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 = {
- {"<leader><cr>", function()
+ {
+ "<leader><cr>",
+ function()
local harpoon = require("harpoon")
harpoon.ui:toggle_quick_menu(harpoon:list())
end,
desc = "Open Harpoon Quickmenu"
},
- {"<leader>m", function()
+ {
+ "<leader>m",
+ function()
local harpoon = require("harpoon")
harpoon:list():append()
end,
desc = "Add file to harpoon"
},
- {"<leader>1", function()
+ {
+ "<leader>1",
+ function()
local harpoon = require("harpoon")
harpoon:list():select(1)
end,
desc = "Navigate to the first file"
},
- {"<leader>2", function()
+ {
+ "<leader>2",
+ function()
local harpoon = require("harpoon")
harpoon:list():select(2)
end,
desc = "Navigate to the second file"
},
- {"<leader>3", function()
+ {
+ "<leader>3",
+ function()
local harpoon = require("harpoon")
harpoon:list():select(3)
end,
desc = "Navigate to the third file"
},
- {"<leader>4", function()
+ {
+ "<leader>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({
+ ['<C-k>'] = cmp.mapping.scroll_docs(-5),
+ ['<C-j>'] = cmp.mapping.scroll_docs(5),
+ ['<TAB>'] = 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' }
+ -- },
+}