Files
neovim/runtime/example_init.lua
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

108 lines
3.7 KiB
Lua
Raw Normal View History

2025-04-27 22:11:02 +07:00
-- Set <space> as the leader key
2026-03-19 17:22:32 +00:00
-- See `:h mapleader`
2025-04-27 22:11:02 +07:00
-- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used)
vim.g.mapleader = ' '
2026-02-12 14:16:47 +01:00
-- OPTIONS
--
-- See `:h vim.o`
2025-04-27 22:11:02 +07:00
-- NOTE: You can change these options as you wish!
2026-03-19 17:22:32 +00:00
-- For more options, you can see `:h option-list`
2025-04-27 22:11:02 +07:00
-- To see documentation for an option, you can use `:h 'optionname'`, for example `:h 'number'`
-- (Note the single quotes)
2026-02-12 14:16:47 +01:00
vim.o.number = true -- Show line numbers in a column.
2025-04-27 22:11:02 +07:00
2026-02-12 14:16:47 +01:00
-- Show line numbers relative to where the cursor is.
-- Affects the 'number' option above, see `:h number_relativenumber`.
2025-04-27 22:11:02 +07:00
vim.o.relativenumber = true
2026-01-27 22:18:02 +08:00
-- Sync clipboard between OS and Neovim. Schedule the setting after `UIEnter` because it can
2025-04-27 22:11:02 +07:00
-- increase startup-time. Remove this option if you want your OS clipboard to remain independent.
2026-03-19 17:22:32 +00:00
-- See `:h 'clipboard'`
2025-04-27 22:11:02 +07:00
vim.api.nvim_create_autocmd('UIEnter', {
callback = function()
vim.o.clipboard = 'unnamedplus'
end,
})
-- Case-insensitive searching UNLESS \C or one or more capital letters in the search term
vim.o.ignorecase = true
vim.o.smartcase = true
2026-02-12 14:16:47 +01:00
vim.o.cursorline = true -- Highlight the line where the cursor is on.
vim.o.scrolloff = 10 -- Keep this many screen lines above/below the cursor.
vim.o.list = true -- Show <tab> and trailing spaces.
2025-04-27 22:11:02 +07:00
2026-03-19 17:22:32 +00:00
-- 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 `:h 'confirm'`
2025-04-27 22:11:02 +07:00
vim.o.confirm = true
2026-02-12 14:16:47 +01:00
-- KEYMAPS
--
-- See `:h vim.keymap.set()`, `:h mapping`, `:h keycodes`
2025-04-27 22:11:02 +07:00
-- Use <Esc> to exit terminal mode
vim.keymap.set('t', '<Esc>', '<C-\\><C-n>')
-- Map <A-j>, <A-k>, <A-h>, <A-l> to navigate between windows in any modes
vim.keymap.set({ 't', 'i' }, '<A-h>', '<C-\\><C-n><C-w>h')
vim.keymap.set({ 't', 'i' }, '<A-j>', '<C-\\><C-n><C-w>j')
vim.keymap.set({ 't', 'i' }, '<A-k>', '<C-\\><C-n><C-w>k')
vim.keymap.set({ 't', 'i' }, '<A-l>', '<C-\\><C-n><C-w>l')
vim.keymap.set({ 'n' }, '<A-h>', '<C-w>h')
vim.keymap.set({ 'n' }, '<A-j>', '<C-w>j')
vim.keymap.set({ 'n' }, '<A-k>', '<C-w>k')
vim.keymap.set({ 'n' }, '<A-l>', '<C-w>l')
2026-02-12 14:16:47 +01:00
-- AUTOCOMMANDS (EVENT HANDLERS)
--
2025-04-27 22:11:02 +07:00
-- See `:h lua-guide-autocommands`, `:h autocmd`, `:h nvim_create_autocmd()`
-- Highlight when yanking (copying) text.
2026-05-17 13:56:37 +00:00
-- Try it with `yap` in normal mode. See `:h vim.hl.hl_op()`
2025-04-27 22:11:02 +07:00
vim.api.nvim_create_autocmd('TextYankPost', {
desc = 'Highlight when yanking (copying) text',
callback = function()
2026-05-17 13:56:37 +00:00
vim.hl.hl_op()
2025-04-27 22:11:02 +07:00
end,
})
2026-02-12 14:16:47 +01:00
-- USER COMMANDS: DEFINE CUSTOM COMMANDS
--
2025-04-27 22:11:02 +07:00
-- See `:h nvim_create_user_command()` and `:h user-commands`
-- Create a command `:GitBlameLine` that print the git blame for the current line
vim.api.nvim_create_user_command('GitBlameLine', function()
local line_number = vim.fn.line('.') -- Get the current line number. See `:h line()`
local filename = vim.api.nvim_buf_get_name(0)
2025-07-24 05:03:30 +02:00
print(vim.system({ 'git', 'blame', '-L', line_number .. ',+1', filename }):wait().stdout)
2025-04-27 22:11:02 +07:00
end, { desc = 'Print the git blame for the current line' })
2026-02-12 14:16:47 +01:00
-- PLUGINS
--
2026-03-19 17:22:32 +00:00
-- See `:h :packadd`, `:h vim.pack`
2025-04-27 22:11:02 +07:00
2026-03-19 17:22:32 +00:00
-- Add the "nohlsearch" package to automatically disable search highlighting after
2026-02-12 14:16:47 +01:00
-- 'updatetime' and when going to insert mode.
2025-04-27 22:11:02 +07:00
vim.cmd('packadd! nohlsearch')
2026-03-19 17:22:32 +00:00
-- Install third-party plugins via "vim.pack.add()".
2026-02-12 14:16:47 +01:00
vim.pack.add({
2026-03-19 17:22:32 +00:00
-- Quickstart configs for LSP
2026-02-12 14:16:47 +01:00
'https://github.com/neovim/nvim-lspconfig',
-- Fuzzy picker
'https://github.com/ibhagwan/fzf-lua',
-- Autocompletion
2026-03-19 17:22:32 +00:00
'https://github.com/nvim-mini/mini.completion',
2026-02-12 14:16:47 +01:00
-- Enhanced quickfix/loclist
'https://github.com/stevearc/quicker.nvim',
-- Git integration
'https://github.com/lewis6991/gitsigns.nvim',
})
2026-03-18 23:53:55 +01:00
2026-03-20 23:52:42 +01:00
require('fzf-lua').setup { fzf_colors = true }
2026-03-18 23:53:55 +01:00
require('mini.completion').setup {}
require('quicker').setup {}
require('gitsigns').setup {}