From 142445bb06f5b0886d36dd50f161594e08a6a0c2 Mon Sep 17 00:00:00 2001 From: David Bland Date: Mon, 3 Mar 2025 17:37:42 -0500 Subject: [PATCH] Custom --- init.lua | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 57 insertions(+), 4 deletions(-) diff --git a/init.lua b/init.lua index 5cac3d14..83b6c8a8 100644 --- a/init.lua +++ b/init.lua @@ -102,7 +102,7 @@ vim.g.have_nerd_font = false vim.opt.number = true -- You can also add relative line numbers, to help with jumping. -- Experiment for yourself to see if you like it! --- vim.opt.relativenumber = true +vim.opt.relativenumber = true -- Enable mouse mode, can be useful for resizing splits for example! vim.opt.mouse = 'a' @@ -188,6 +188,7 @@ vim.keymap.set('n', '', '', { desc = 'Move focus to the left wind vim.keymap.set('n', '', '', { desc = 'Move focus to the right window' }) vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) +vim.keymap.set('n', 'e', ':Explor', { desc = 'Open [E]xplor' }) -- [[ Basic Autocommands ]] -- See `:help lua-guide-autocommands` @@ -236,7 +237,6 @@ require('lazy').setup({ -- -- Use `opts = {}` to automatically pass options to a plugin's `setup()` function, forcing the plugin to be loaded. -- - -- Alternatively, use `config = function() ... end` for full control over the configuration. -- If you prefer to call `setup` explicitly, use: -- { @@ -252,6 +252,33 @@ require('lazy').setup({ -- options to `gitsigns.nvim`. -- -- See `:help gitsigns` to understand what the configuration keys do + { + 'zbirenbaum/copilot.lua', + cmd = 'Copilot', + build = ':Copilot auth', + event = 'BufReadPost', + opts = { + suggestion = { + enabled = not vim.g.ai_cmp, + auto_trigger = true, + hide_during_completion = vim.g.ai_cmp, + keymap = { + accept = false, -- handled by nvim-cmp / blink.cmp + next = '', + prev = '', + }, + }, + panel = { enabled = false }, + filetypes = { + markdown = true, + help = true, + }, + }, + }, + { + 'nvim-tree/nvim-tree.lua', + }, + { -- Adds git related signs to the gutter, as well as utilities for managing changes 'lewis6991/gitsigns.nvim', opts = { @@ -479,6 +506,7 @@ require('lazy').setup({ 'hrsh7th/cmp-nvim-lsp', }, config = function() + require('lspconfig').lua_ls.setup {} -- Brief aside: **What is LSP?** -- -- LSP is an initialism you've probably heard, but might not understand what it is. @@ -835,7 +863,15 @@ require('lazy').setup({ -- This will auto-import if your LSP supports it. -- This will expand snippets if the LSP sent a snippet. [''] = cmp.mapping.confirm { select = true }, - + [''] = cmp.mapping(function(fallback) + local fallback_key = vim.api.nvim_replace_termcodes('', true, true, true) + local resolved_key = vim.fn['copilot#Accept'](fallback) + if fallback_key == resolved_key then + cmp.confirm { select = true } + else + vim.api.nvim_feedkeys(resolved_key, 'n', true) + end + end), -- If you prefer more traditional completion keymaps, -- you can uncomment the following lines --[''] = cmp.mapping.confirm { select = true }, @@ -846,7 +882,23 @@ require('lazy').setup({ -- Generally you don't need this, because nvim-cmp will display -- completions whenever it has completion options available. [''] = cmp.mapping.complete {}, - + [''] = cmp.mapping(function(fallback) + local copilot = require 'copilot.suggestion' + if copilot.is_visible() then + copilot.accept() + elseif cmp.visible() then + local entry = cmp.get_selected_entry() + if not entry then + cmp.select_next_item { behavior = cmp.SelectBehavior.Select } + else + cmp.confirm() + end + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, { 'i', 's' }), -- Think of as moving to the right of your snippet expansion. -- So if you have a snippet that's like: -- function $name($args) @@ -875,6 +927,7 @@ require('lazy').setup({ -- set group index to 0 to skip loading LuaLS completions as lazydev recommends it group_index = 0, }, + { name = 'copilot' }, { name = 'nvim_lsp' }, { name = 'luasnip' }, { name = 'path' },