refactor one 'term' to rule them all
This commit is contained in:
@@ -0,0 +1,172 @@
|
||||
--[[
|
||||
BASIC-SETTINGS.LUA
|
||||
|
||||
This file contains fundamental Neovim settings that don't require plugins.
|
||||
These are applied to Neovim globally and affect the core editing experience.
|
||||
|
||||
In Lua (this file), we use:
|
||||
- vim.opt.* for options that take values
|
||||
- vim.g.* for global variables
|
||||
- vim.go.* for global option shorthand
|
||||
]]
|
||||
|
||||
-- ============================================================================
|
||||
-- FOLDING SETTINGS (Code folding)
|
||||
-- ============================================================================
|
||||
-- Foldmethod determines how code blocks are detected and folded
|
||||
-- "expr" means folds are based on expressions (we use treesitter for this)
|
||||
vim.opt.foldmethod = "expr"
|
||||
|
||||
-- Foldexpr is the expression used to determine fold level
|
||||
-- v:lua.vim.treesitter.foldexpr() uses Treesitter to calculate folds
|
||||
vim.opt.foldexpr = "v:lua.vim.treesitter.foldexpr()"
|
||||
|
||||
-- Foldlevel: Higher number = more folds are open by default
|
||||
-- 99 means almost all folds are open when opening a file
|
||||
vim.opt.foldlevel = 99
|
||||
|
||||
-- ============================================================================
|
||||
-- LINE NUMBERS
|
||||
-- ============================================================================
|
||||
-- Show line numbers (absolute numbering)
|
||||
vim.opt.number = true
|
||||
|
||||
-- Show relative line numbers (helps with motions like 5j, 3k, etc.)
|
||||
-- When combined with 'number', the current line shows absolute number
|
||||
vim.opt.relativenumber = true
|
||||
|
||||
-- ============================================================================
|
||||
-- INDENTATION SETTINGS
|
||||
-- ============================================================================
|
||||
-- Tabstop: How many spaces a TAB character counts for
|
||||
-- When viewing a file, TABs appear as this many spaces
|
||||
vim.opt.tabstop = 4
|
||||
|
||||
-- Shiftwidth: How many spaces to use for auto-indentation and >> << commands
|
||||
vim.opt.shiftwidth = 4
|
||||
|
||||
-- Expandtab: Convert TABs to spaces when typing
|
||||
-- true = pressing TAB inserts spaces; false = inserts actual TAB characters
|
||||
-- Recommendation: Use true (spaces) for better portability across systems
|
||||
vim.opt.expandtab = true
|
||||
|
||||
-- Smartindent: Auto-indent based on file type and syntax
|
||||
-- Automatically adds indent after lines ending with specific characters
|
||||
vim.opt.smartindent = true
|
||||
|
||||
-- ============================================================================
|
||||
-- UI/UX SETTINGS
|
||||
-- ============================================================================
|
||||
-- Show line length marker (optional, helps keep lines under 80/120 chars)
|
||||
-- Uncomment if you want: vim.opt.colorcolumn = "80"
|
||||
|
||||
-- Enable cursor line highlighting (subtle background on current line)
|
||||
vim.opt.cursorline = true
|
||||
|
||||
-- Enable cursor column highlighting (column where cursor is)
|
||||
vim.opt.cursorcolumn = true
|
||||
|
||||
-- Better command-line completion (popup menu for completions)
|
||||
vim.opt.wildmenu = true
|
||||
|
||||
-- Ignore case when searching UNLESS you include an uppercase letter
|
||||
vim.opt.ignorecase = true
|
||||
vim.opt.smartcase = true
|
||||
|
||||
-- Highlight search matches as you type
|
||||
vim.opt.incsearch = true
|
||||
|
||||
-- When search reaches end, wrap back to beginning
|
||||
vim.opt.wrapscan = true
|
||||
|
||||
-- Show matching brackets/parentheses
|
||||
vim.opt.showmatch = true
|
||||
|
||||
-- How long (ms) to show matching bracket
|
||||
vim.opt.matchtime = 2
|
||||
|
||||
-- Show current mode in last line (like -- INSERT --)
|
||||
vim.opt.showmode = true
|
||||
|
||||
-- Show incomplete commands at bottom
|
||||
vim.opt.showcmd = true
|
||||
|
||||
-- Command line height (number of lines for command area)
|
||||
vim.opt.cmdheight = 1
|
||||
|
||||
-- Always show status line (even in single window)
|
||||
vim.opt.laststatus = 3
|
||||
|
||||
-- Don't redraw while executing macros (faster)
|
||||
vim.opt.lazyredraw = false
|
||||
|
||||
-- Don't show mode in the window title (cleaner)
|
||||
vim.opt.title = false
|
||||
|
||||
-- ============================================================================
|
||||
-- EDITING BEHAVIOR
|
||||
-- ============================================================================
|
||||
-- Enable mouse support (click to move cursor, resize splits)
|
||||
vim.opt.mouse = "a"
|
||||
|
||||
-- Allow backspace to delete indent, eol, and start of line
|
||||
vim.opt.backspace = "indent,eol,start"
|
||||
|
||||
-- Auto-read file when changed externally (e.g., by another program)
|
||||
vim.opt.autoread = true
|
||||
|
||||
-- Auto-write when switching buffers or leaving
|
||||
-- 'a' = auto-write for all buffers; uncomment if you want:
|
||||
-- vim.opt.autowrite = true
|
||||
|
||||
-- Remember moreundo for longer undo history
|
||||
vim.opt.undofile = true
|
||||
|
||||
-- ============================================================================
|
||||
-- SPLIT AND TAB SETTINGS
|
||||
-- ============================================================================
|
||||
-- Split below (instead of above) when creating horizontal splits
|
||||
vim.opt.splitbelow = true
|
||||
|
||||
-- Split right (instead of left) when creating vertical splits
|
||||
vim.opt.splitright = true
|
||||
|
||||
-- ============================================================================
|
||||
-- PERFORMANCE SETTINGS
|
||||
-- ============================================================================
|
||||
-- Faster terminal response
|
||||
vim.opt.timeout = true
|
||||
vim.opt.timeoutlen = 300 -- Time in ms to wait for a mapped sequence
|
||||
|
||||
-- Async handling for some operations
|
||||
vim.opt.ttimeoutlen = 10
|
||||
|
||||
-- ============================================================================
|
||||
-- LEADER KEY
|
||||
-- ============================================================================
|
||||
-- The <Leader> key is used as a prefix for custom keybindings
|
||||
-- By convention, space is commonly used as the leader key
|
||||
vim.g.mapleader = " "
|
||||
|
||||
-- ============================================================================
|
||||
-- TERMINAL SETTINGS
|
||||
-- ============================================================================
|
||||
-- Exit terminal mode with Escape
|
||||
vim.keymap.set("t", "<Esc>", [[<C-\><C-n>]], {
|
||||
desc = "Exit terminal mode"
|
||||
})
|
||||
|
||||
-- Alternative: Exit with Alt key combinations as well
|
||||
vim.keymap.set("t", "<A-x>", [[<C-\><C-n>]], {
|
||||
desc = "Exit terminal mode with Alt"
|
||||
})
|
||||
|
||||
-- ============================================================================
|
||||
-- CLIPBOARD (System clipboard integration)
|
||||
-- ============================================================================
|
||||
-- Use system clipboard for yank/paste
|
||||
-- Requires +clipboard feature (check with: :echo has('clipboard'))
|
||||
if vim.fn.has("clipboard") == 1 then
|
||||
-- Use system clipboard for all yank/delete/paste operations
|
||||
vim.opt.clipboard = "unnamedplus"
|
||||
end
|
||||
Reference in New Issue
Block a user