Skip to content
Merged
Show file tree
Hide file tree
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
1,029 changes: 8 additions & 1,021 deletions init.lua

Large diffs are not rendered by default.

13 changes: 0 additions & 13 deletions lua/custom/plugins/init.lua

This file was deleted.

File renamed without changes.
5 changes: 5 additions & 0 deletions lua/helpers.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---Because most plugins are hosted on GitHub, you can use the helper
---function to have less repetition in the following sections.
---@param repo string
---@return string
return function (repo) return 'https://github.com/' .. repo end
83 changes: 83 additions & 0 deletions lua/keymaps.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
-- See `:help vim.keymap.set()`

-- Clear highlights on search when pressing <Esc> in normal mode
-- See `:help hlsearch`
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')

local function expand_diagnostic(_, bufnr)
vim.diagnostic.open_float {
bufnr = bufnr,
scope = 'cursor',
focus = false,
}
end

-- Diagnostic Config & Keymaps
-- See `:help vim.diagnostic.Opts`
vim.diagnostic.config {
update_in_insert = false,
severity_sort = true,
float = { border = 'rounded', source = 'if_many' },
underline = { severity = { min = vim.diagnostic.severity.WARN } },

-- Can switch between these as you prefer
virtual_text = true, -- Text shows up at the end of the line
virtual_lines = false, -- Text shows up underneath the line, with virtual lines

-- Auto open the float, so you can easily read the errors when jumping with `[d` and `]d`
jump = { on_jump = expand_diagnostic },
}

vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })
vim.keymap.set('n', '<leader>e', expand_diagnostic, { desc = '[E]xpand diagnostic message' })

-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier
-- for people to discover. Otherwise, you normally need to press <C-\><C-n>, which
-- is not what someone will guess without a bit more experience.
--
-- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping
-- or just use <C-\><C-n> to exit terminal mode
vim.keymap.set('t', '<Esc><Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' })

-- TIP: Disable arrow keys in normal mode
-- vim.keymap.set('n', '<left>', '<cmd>echo "Use h to move!!"<CR>')
-- vim.keymap.set('n', '<right>', '<cmd>echo "Use l to move!!"<CR>')
-- vim.keymap.set('n', '<up>', '<cmd>echo "Use k to move!!"<CR>')
-- vim.keymap.set('n', '<down>', '<cmd>echo "Use j to move!!"<CR>')

-- Keybinds to make split navigation easier.
-- Use CTRL+<hjkl> to switch between windows
--
-- See `:help wincmd` for a list of all window commands
vim.keymap.set('n', '<C-h>', '<C-w><C-h>', { desc = 'Move focus to the left window' })
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' })

-- 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" })
-- vim.keymap.set("n", "<C-S-l>", "<C-w>L", { desc = "Move window to the right" })
-- vim.keymap.set("n", "<C-S-j>", "<C-w>J", { desc = "Move window to the lower" })
-- vim.keymap.set("n", "<C-S-k>", "<C-w>K", { desc = "Move window to the upper" })

-- Additional keybinds
vim.keymap.set('n', '<leader>w', '<cmd>write<CR>', { desc = '[W]rite to the current file' })
vim.keymap.set('n', '<leader>pv', vim.cmd.Ex, { desc = '[P]roject [V]iew' })
vim.keymap.set('n', '<leader>lsp', '<cmd>LspRestart<CR>', { desc = 'Restart LSP' })
vim.keymap.set('n', '<C-d>', '<C-d>zz', { desc = 'Center window on cursor on jump' })
vim.keymap.set('n', '<C-u>', '<C-u>zz', { desc = 'Center window on cursor on jump' })
vim.keymap.set('x', '<leader>p', [["_dP]], { desc = '[P]aste without register override' })
vim.keymap.set({ 'n', 'v' }, '<leader>y', [["+y]], { desc = '[Y]ank to system clipboard' })
vim.keymap.set('n', '<leader>Y', [["+Y]], { desc = '[Y]ank line to system clipboard' })

-- [[ Basic Autocommands ]]
-- See `:help lua-guide-autocommands`

-- Highlight when yanking (copying) text
-- Try it with `yap` in normal mode
-- See `:help vim.hl.on_yank()`
vim.api.nvim_create_autocmd('TextYankPost', {
desc = 'Highlight when yanking (copying) text',
group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }),
callback = function() vim.hl.on_yank() end,
})
107 changes: 107 additions & 0 deletions lua/options.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
-- Enable faster startup by caching compiled Lua modules
vim.loader.enable()

-- Set <space> as the leader key
-- See `:help mapleader`
-- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used)
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '

-- Set to true if you have a Nerd Font installed and selected in the terminal
vim.g.have_nerd_font = true

-- See `:help vim.o`
-- For more options, you can see `:help option-list`

-- Set default terminal emulator to pwsh on Windows
if vim.fn.has 'win32' == 1 then
vim.g.terminal_emulator = 'pwsh'
vim.o.shell = 'pwsh'
vim.o.shellcmdflag = '-Command'
vim.o.shellquote = '"'
vim.o.shellxquote = ''
end

-- Set indentation behavior according to :help usr_30 section 5
-- NMAC427/guess-indent.nvim plugin add automatic detection
vim.o.shiftwidth = 4
vim.o.softtabstop = 4
vim.o.expandtab = true
-- vim.o.smarttab = true

-- Make line numbers default
vim.o.number = true
vim.o.relativenumber = true

-- Enable mouse mode, can be useful for resizing splits for example!
vim.o.mouse = 'a'

-- Don't show the mode, since it's already in the status line
vim.o.showmode = false

-- Sync clipboard between OS and Neovim.
-- Schedule the setting after `UiEnter` because it can increase startup-time.
-- Remove this option if you want your OS clipboard to remain independent.
-- See `:help 'clipboard'`
-- vim.schedule(function() vim.o.clipboard = 'unnamedplus' end)

-- Enable break indent
vim.o.breakindent = true

-- Enable undo/redo changes even after closing and reopening a file
vim.o.undofile = true

-- Case-insensitive searching UNLESS \C or one or more capital letters in the search term
vim.o.ignorecase = true
vim.o.smartcase = true

-- Keep signcolumn on by default
vim.o.signcolumn = 'yes'

-- Decrease update time
vim.o.updatetime = 250

-- Decrease mapped sequence wait time
vim.o.timeoutlen = 300

-- Configure how new splits should be opened
vim.o.splitright = true
vim.o.splitbelow = true

-- Sets how neovim will display certain whitespace characters in the editor.
-- See `:help 'list'`
-- and `:help 'listchars'`
--
-- Notice listchars is set using `vim.opt` instead of `vim.o`.
-- It is very similar to `vim.o` but offers an interface for conveniently interacting with tables.
-- See `:help lua-options`
-- and `:help lua-guide-options`
vim.o.list = true
vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' }

-- Preview substitutions live, as you type!
vim.o.inccommand = 'split'

-- Show which line your cursor is on
vim.o.cursorline = true

-- Minimal number of screen lines to keep above and below the cursor.
vim.o.scrolloff = 8

-- if performing an operation that would fail due to unsaved changes in the buffer (like `:q`),
-- instead raise a dialog asking if you wish to save the current file(s)
-- See `:help 'confirm'`
vim.o.confirm = true

-- Adapt to local EditorConfig
vim.api.nvim_create_autocmd('BufEnter', {
callback = function()
local editorconfig = vim.b.editorconfig
if editorconfig and editorconfig.max_line_length then
vim.opt_local.colorcolumn = editorconfig.max_line_length
else
vim.o.textwidth = 120
vim.opt_local.colorcolumn = '120'
end
end,
})
59 changes: 59 additions & 0 deletions lua/pack.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
-- [[ Intro to `vim.pack` ]]
-- `vim.pack` is a new plugin manager built into Neovim,
-- which provides a Lua interface for installing and managing plugins.
--
-- See `:help vim.pack`, `:help vim.pack-examples` or the
-- excellent blog post from the creator of vim.pack and mini.nvim:
-- https://echasnovski.com/blog/2026-03-13-a-guide-to-vim-pack
--
-- To inspect plugin state and pending updates, run
-- :lua vim.pack.update(nil, { offline = true })
--
-- To update plugins, run
-- :lua vim.pack.update()
--
--
-- Throughout the rest of the config there will be examples
-- of how to install and configure plugins using `vim.pack`.
--
-- In this section we set up some autocommands to run build
-- steps for certain plugins after they are installed or updated.

local function run_build(name, cmd, cwd)
local result = vim.system(cmd, { cwd = cwd }):wait()
if result.code ~= 0 then
local stderr = result.stderr or ''
local stdout = result.stdout or ''
local output = stderr ~= '' and stderr or stdout
if output == '' then output = 'No output from build command.' end
vim.notify(('Build failed for %s:\n%s'):format(name, output), vim.log.levels.ERROR)
end
end

-- This autocommand runs after a plugin is installed or updated and
-- runs the appropriate build command for that plugin if necessary.
--
-- See `:help vim.pack-events`
vim.api.nvim_create_autocmd('PackChanged', {
callback = function(ev)
local name = ev.data.spec.name
local kind = ev.data.kind
if kind ~= 'install' and kind ~= 'update' then return end

if name == 'telescope-fzf-native.nvim' and vim.fn.executable 'make' == 1 then
run_build(name, { 'make' }, ev.data.path)
return
end

if name == 'LuaSnip' then
if vim.fn.has 'win32' ~= 1 and vim.fn.executable 'make' == 1 then run_build(name, { 'make', 'install_jsregexp' }, ev.data.path) end
return
end

if name == 'nvim-treesitter' then
if not ev.data.active then vim.cmd.packadd 'nvim-treesitter' end
vim.cmd 'TSUpdate'
return
end
end,
})
36 changes: 36 additions & 0 deletions lua/plugins.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
-- [[ Installing and Configuring Plugins ]]
--
-- To install a plugin simply call `vim.pack.add` with its git url.
-- This will download the default branch of the plugin, which will usually be `main` or `master`
-- You can also have more advanced specs, which we will talk about later.
--
-- For most plugins it's not enough to install them, you also need to call their `.setup()` to start them.
--
-- For example, lets say we want to install `guess-indent.nvim` - a plugin for
-- automatically detecting and setting the indentation.
--
-- We first install it from https://github.com/NMAC427/guess-indent.nvim
-- and then call its `setup()` function to start it with default settings.

-- Load order matters
require 'plugins.guess-indent'
require 'plugins.gitsigns'
require 'plugins.which-key'
require 'plugins.colorscheme'
require 'plugins.todo-comments'
require 'plugins.mini'
require 'plugins.telescope'
require 'plugins.lspconfig'
require 'plugins.conform'
require 'plugins.autocomplete'
require 'plugins.treesitter'
require 'plugins.harpoon'
require 'plugins.copilot'
require 'plugins.colorizer'
require 'plugins.debug'
require 'plugins.indent_line'
-- require 'plugins.lint'
require 'plugins.autopairs'
-- require 'plugins.neo-tree'

-- vim: ts=2 sts=2 sw=2 et
78 changes: 78 additions & 0 deletions lua/plugins/autocomplete.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
-- [[ Snippet Engine ]]

local gh = require 'helpers'

-- NOTE: You can also specify plugin using a version range for its git tag.
-- See `:help vim.version.range()` for more info
vim.pack.add { { src = gh 'L3MON4D3/LuaSnip', version = vim.version.range '2.*' } }
require('luasnip').setup {}

-- `friendly-snippets` contains a variety of premade snippets.
-- See the README about individual language/framework/plugin snippets:
-- https://github.com/rafamadriz/friendly-snippets

vim.pack.add { gh 'rafamadriz/friendly-snippets' }
require('luasnip.loaders.from_vscode').lazy_load()

-- [[ Autocomplete Engine ]]
-- V2 will reportedly have breaking changes
vim.pack.add { { src = gh 'saghen/blink.cmp', version = vim.version.range '1.*' } }
require('blink.cmp').setup {
keymap = {
-- 'default' (recommended) for mappings similar to built-in completions
-- <c-y> to accept ([y]es) the completion.
-- This will auto-import if your LSP supports it.
-- This will expand snippets if the LSP sent a snippet.
-- 'super-tab' for tab to accept
-- 'enter' for enter to accept
-- 'none' for no mappings
--
-- For an understanding of why the 'default' preset is recommended,
-- you will need to read `:help ins-completion`
--
-- No, but seriously. Please read `:help ins-completion`, it is really good!
--
-- All presets have the following mappings:
-- <tab>/<s-tab>: move to right/left of your snippet expansion
-- <c-space>: Open menu or open docs if already open
-- <c-n>/<c-p> or <up>/<down>: Select next/previous item
-- <c-e>: Hide menu
-- <c-k>: Toggle signature help
--
-- See `:help blink-cmp-config-keymap` for defining your own keymap
preset = 'default',

-- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see:
-- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps
},

appearance = {
-- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
-- Adjusts spacing to ensure icons are aligned
nerd_font_variant = 'mono',
},

completion = {
-- By default, you may press `<c-space>` to show the documentation.
-- Optionally, set `auto_show = true` to show the documentation after a delay.
documentation = { auto_show = false, auto_show_delay_ms = 500 },
},

sources = {
default = { 'lsp', 'path', 'snippets' },
},

snippets = { preset = 'luasnip' },

-- Blink.cmp includes an optional, recommended rust fuzzy matcher,
-- which automatically downloads a prebuilt binary when enabled.
--
-- By default, we use the Lua implementation instead, but you may enable
-- the rust implementation via `'prefer_rust_with_warning'`
--
-- See `:help blink-cmp-config-fuzzy` for more information
fuzzy = { implementation = 'prefer_rust_with_warning' },

-- Shows a signature help window while you type arguments for a function
signature = { enabled = true },
}
File renamed without changes.
3 changes: 3 additions & 0 deletions lua/plugins/colorizer.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
local gh = require 'helpers'
vim.pack.add { gh 'catgoose/nvim-colorizer.lua' }
require('colorizer').setup {}
Loading