Skip to content

Commit 142445b

Browse files
David BlandDavid Bland
authored andcommitted
Custom
1 parent 34e7d29 commit 142445b

File tree

1 file changed

+57
-4
lines changed

1 file changed

+57
-4
lines changed

init.lua

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ vim.g.have_nerd_font = false
102102
vim.opt.number = true
103103
-- You can also add relative line numbers, to help with jumping.
104104
-- Experiment for yourself to see if you like it!
105-
-- vim.opt.relativenumber = true
105+
vim.opt.relativenumber = true
106106

107107
-- Enable mouse mode, can be useful for resizing splits for example!
108108
vim.opt.mouse = 'a'
@@ -188,6 +188,7 @@ vim.keymap.set('n', '<C-h>', '<C-w><C-h>', { desc = 'Move focus to the left wind
188188
vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right window' })
189189
vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' })
190190
vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' })
191+
vim.keymap.set('n', '<leader>e', ':Explor<CR>', { desc = 'Open [E]xplor' })
191192

192193
-- [[ Basic Autocommands ]]
193194
-- See `:help lua-guide-autocommands`
@@ -236,7 +237,6 @@ require('lazy').setup({
236237
--
237238
-- Use `opts = {}` to automatically pass options to a plugin's `setup()` function, forcing the plugin to be loaded.
238239
--
239-
240240
-- Alternatively, use `config = function() ... end` for full control over the configuration.
241241
-- If you prefer to call `setup` explicitly, use:
242242
-- {
@@ -252,6 +252,33 @@ require('lazy').setup({
252252
-- options to `gitsigns.nvim`.
253253
--
254254
-- See `:help gitsigns` to understand what the configuration keys do
255+
{
256+
'zbirenbaum/copilot.lua',
257+
cmd = 'Copilot',
258+
build = ':Copilot auth',
259+
event = 'BufReadPost',
260+
opts = {
261+
suggestion = {
262+
enabled = not vim.g.ai_cmp,
263+
auto_trigger = true,
264+
hide_during_completion = vim.g.ai_cmp,
265+
keymap = {
266+
accept = false, -- handled by nvim-cmp / blink.cmp
267+
next = '<M-]>',
268+
prev = '<M-[>',
269+
},
270+
},
271+
panel = { enabled = false },
272+
filetypes = {
273+
markdown = true,
274+
help = true,
275+
},
276+
},
277+
},
278+
{
279+
'nvim-tree/nvim-tree.lua',
280+
},
281+
255282
{ -- Adds git related signs to the gutter, as well as utilities for managing changes
256283
'lewis6991/gitsigns.nvim',
257284
opts = {
@@ -479,6 +506,7 @@ require('lazy').setup({
479506
'hrsh7th/cmp-nvim-lsp',
480507
},
481508
config = function()
509+
require('lspconfig').lua_ls.setup {}
482510
-- Brief aside: **What is LSP?**
483511
--
484512
-- LSP is an initialism you've probably heard, but might not understand what it is.
@@ -835,7 +863,15 @@ require('lazy').setup({
835863
-- This will auto-import if your LSP supports it.
836864
-- This will expand snippets if the LSP sent a snippet.
837865
['<C-y>'] = cmp.mapping.confirm { select = true },
838-
866+
['<C-o>'] = cmp.mapping(function(fallback)
867+
local fallback_key = vim.api.nvim_replace_termcodes('<Tab>', true, true, true)
868+
local resolved_key = vim.fn['copilot#Accept'](fallback)
869+
if fallback_key == resolved_key then
870+
cmp.confirm { select = true }
871+
else
872+
vim.api.nvim_feedkeys(resolved_key, 'n', true)
873+
end
874+
end),
839875
-- If you prefer more traditional completion keymaps,
840876
-- you can uncomment the following lines
841877
--['<CR>'] = cmp.mapping.confirm { select = true },
@@ -846,7 +882,23 @@ require('lazy').setup({
846882
-- Generally you don't need this, because nvim-cmp will display
847883
-- completions whenever it has completion options available.
848884
['<C-Space>'] = cmp.mapping.complete {},
849-
885+
['<Tab>'] = cmp.mapping(function(fallback)
886+
local copilot = require 'copilot.suggestion'
887+
if copilot.is_visible() then
888+
copilot.accept()
889+
elseif cmp.visible() then
890+
local entry = cmp.get_selected_entry()
891+
if not entry then
892+
cmp.select_next_item { behavior = cmp.SelectBehavior.Select }
893+
else
894+
cmp.confirm()
895+
end
896+
elseif luasnip.expand_or_jumpable() then
897+
luasnip.expand_or_jump()
898+
else
899+
fallback()
900+
end
901+
end, { 'i', 's' }),
850902
-- Think of <c-l> as moving to the right of your snippet expansion.
851903
-- So if you have a snippet that's like:
852904
-- function $name($args)
@@ -875,6 +927,7 @@ require('lazy').setup({
875927
-- set group index to 0 to skip loading LuaLS completions as lazydev recommends it
876928
group_index = 0,
877929
},
930+
{ name = 'copilot' },
878931
{ name = 'nvim_lsp' },
879932
{ name = 'luasnip' },
880933
{ name = 'path' },

0 commit comments

Comments
 (0)