Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
149 changes: 147 additions & 2 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ vim.g.have_nerd_font = false
vim.o.number = true
-- You can also add relative line numbers, to help with jumping.
-- Experiment for yourself to see if you like it!
-- vim.o.relativenumber = true

vim.opt.relativenumber = true

-- Enable mouse mode, can be useful for resizing splits for example!
vim.o.mouse = 'a'
Expand Down Expand Up @@ -198,6 +199,7 @@ vim.keymap.set('n', '<C-h>', '<C-w><C-h>', { desc = 'Move focus to the left wind
vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right window' })
vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' })
vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' })
vim.keymap.set('n', '<leader>e', ':Explor<CR>', { desc = 'Open [E]xplor' })

-- NOTE: Some terminals have colliding keymaps or are not able to send distinct keycodes
-- vim.keymap.set("n", "<C-S-h>", "<C-w>H", { desc = "Move window to the left" })
Expand Down Expand Up @@ -255,7 +257,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:
-- {
Expand All @@ -271,6 +272,37 @@ 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 = '<M-]>',
prev = '<M-[>',
},
},
panel = { enabled = false },
filetypes = {
markdown = true,
help = true,
},
},
},
{
'karb94/neoscroll.nvim',
opts = {},
},
{
'nvim-tree/nvim-tree.lua',
},

{ -- Adds git related signs to the gutter, as well as utilities for managing changes
'lewis6991/gitsigns.nvim',
opts = {
Expand Down Expand Up @@ -493,6 +525,7 @@ require('lazy').setup({
'saghen/blink.cmp',
},
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.
Expand Down Expand Up @@ -718,6 +751,32 @@ require('lazy').setup({
'stylua', -- Used to format Lua code
})
require('mason-tool-installer').setup { ensure_installed = ensure_installed }
require('neoscroll').setup {
mappings = { -- Keys to be mapped to their corresponding default scrolling animation
'<C-u>',
'<C-d>',
'<C-b>',
'<C-f>',
'<C-y>',
'<C-e>',
'zt',
'zz',
'zb',
},
hide_cursor = true, -- Hide cursor while scrolling
stop_eof = true, -- Stop at <EOF> when scrolling downwards
respect_scrolloff = false, -- Stop scrolling when the cursor reaches the scrolloff margin of the file
cursor_scrolls_alone = true, -- The cursor will keep on scrolling even if the window cannot scroll further
duration_multiplier = 1.0, -- Global duration multiplier
easing = 'linear', -- Default easing function
pre_hook = nil, -- Function to run before the scrolling animation starts
post_hook = nil, -- Function to run after the scrolling animation ends
performance_mode = false, -- Disable "Performance Mode" on all buffers.
ignored_events = { -- Events ignored while scrolling
'WinScrolled',
'CursorMoved',
},
}

require('mason-lspconfig').setup {
ensure_installed = {}, -- explicitly set to an empty table (Kickstart populates installs via mason-tool-installer)
Expand Down Expand Up @@ -826,6 +885,91 @@ require('lazy').setup({
-- you will need to read `:help ins-completion`
--
-- No, but seriously. Please read `:help ins-completion`, it is really good!

mapping = cmp.mapping.preset.insert {
-- Select the [n]ext item
['<C-n>'] = cmp.mapping.select_next_item(),
-- Select the [p]revious item
['<C-p>'] = cmp.mapping.select_prev_item(),

-- Scroll the documentation window [b]ack / [f]orward
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),

-- Accept ([y]es) the completion.
-- This will auto-import if your LSP supports it.
-- This will expand snippets if the LSP sent a snippet.
['<C-y>'] = cmp.mapping.confirm { select = true },
['<C-o>'] = cmp.mapping(function(fallback)
local fallback_key = vim.api.nvim_replace_termcodes('<Tab>', 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
--['<CR>'] = cmp.mapping.confirm { select = true },
--['<Tab>'] = cmp.mapping.select_next_item(),
--['<S-Tab>'] = cmp.mapping.select_prev_item(),

-- Manually trigger a completion from nvim-cmp.
-- Generally you don't need this, because nvim-cmp will display
-- completions whenever it has completion options available.
['<C-Space>'] = cmp.mapping.complete {},
['<Tab>'] = 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 <c-l> as moving to the right of your snippet expansion.
-- So if you have a snippet that's like:
-- function $name($args)
-- $body
-- end
--
-- <c-l> will move you to the right of each of the expansion locations.
-- <c-h> is similar, except moving you backwards.
['<C-l>'] = cmp.mapping(function()
if luasnip.expand_or_locally_jumpable() then
luasnip.expand_or_jump()
end
end, { 'i', 's' }),
['<C-h>'] = cmp.mapping(function()
if luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
end
end, { 'i', 's' }),

-- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see:
-- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps
},
sources = {
{
name = 'lazydev',
-- 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' },
{ name = 'nvim_lsp_signature_help' },

--
-- All presets have the following mappings:
-- <tab>/<s-tab>: move to right/left of your snippet expansion
Expand Down Expand Up @@ -857,6 +1001,7 @@ require('lazy').setup({
default = { 'lsp', 'path', 'snippets', 'lazydev' },
providers = {
lazydev = { module = 'lazydev.integrations.blink', score_offset = 100 },

},
},

Expand Down
Loading