Files
neovim-config/lua/config/settings.lua
T
2026-06-30 08:55:02 +02:00

193 lines
5.5 KiB
Lua

-----------------------------------------------------------------------
-- Line numbers
-----------------------------------------------------------------------
-- Show absolute line numbers.
vim.wo.number = true
-- Show relative line numbers for all lines except the current one.
-- Useful for relative motions (5j, 3k, etc.).
vim.wo.relativenumber = true
-----------------------------------------------------------------------
-- Search and editing behavior
-----------------------------------------------------------------------
-- Ignore case when searching.
vim.opt.ignorecase = true
-- Override ignorecase if the search pattern contains uppercase letters.
-- Example:
-- /foo -> finds foo, Foo, FOO
-- /Foo -> finds only Foo variants with capital F
vim.opt.smartcase = true
-- Enable automatic indentation based on the previous line.
vim.opt.smartindent = true
-----------------------------------------------------------------------
-- Indentation
-----------------------------------------------------------------------
-- Number of spaces used to display a tab character.
vim.opt.tabstop = 4
-- Number of spaces used for indentation commands (>>, <<).
vim.opt.shiftwidth = 4
-- Insert spaces instead of tab characters.
vim.opt.expandtab = true
-- Number of spaces inserted/deleted when pressing Tab or Backspace.
vim.opt.softtabstop = 4
-----------------------------------------------------------------------
-- File format and encoding
-----------------------------------------------------------------------
-- Use Unix-style line endings (LF instead of CRLF).
vim.opt.fileformat = "unix"
-- Use UTF-8 encoding.
vim.opt.encoding = "utf-8"
-----------------------------------------------------------------------
-- Line wrapping
-----------------------------------------------------------------------
-- Wrap long lines instead of scrolling horizontally.
vim.opt.wrap = true
-----------------------------------------------------------------------
-- Disable terminal bells
-----------------------------------------------------------------------
-- Disable audible and visual bells.
vim.opt.belloff = "all"
-----------------------------------------------------------------------
-- Split windows
-----------------------------------------------------------------------
-- Open horizontal splits below the current window.
vim.opt.splitbelow = true
-- Open vertical splits to the right of the current window.
vim.opt.splitright = true
-----------------------------------------------------------------------
-- Completion popup menu
-----------------------------------------------------------------------
-- Maximum number of entries displayed in completion popup.
vim.opt.pumheight = 15
-- Transparency level of popup menus.
-- 0 = opaque, 100 = fully transparent.
vim.opt.pumblend = 20
-----------------------------------------------------------------------
-- Temporary files
-----------------------------------------------------------------------
-- Store backup files in /tmp.
-- The // suffix preserves the original directory tree.
vim.opt.backupdir = "/tmp//"
vim.opt.swapfile = false
-- Store swap files in /tmp.
vim.opt.directory = "/tmp//"
-- Store persistent undo files in /tmp.
vim.opt.undodir = "/tmp//"
-----------------------------------------------------------------------
-- Command line
-----------------------------------------------------------------------
-- Height of the command line area.
vim.opt.cmdheight = 1
-----------------------------------------------------------------------
-- System clipboard
-----------------------------------------------------------------------
-- Use the system clipboard (+ register) for yank/paste operations.
vim.opt.clipboard = "unnamedplus"
-- Use this configuration to copy-paste when in remote server
-- vim.g.clipboard = {
-- name = 'OSC 52',
-- copy = {
-- ['+'] = require('vim.ui.clipboard.osc52').copy('+'),
-- ['*'] = require('vim.ui.clipboard.osc52').copy('*'),
-- },
-- paste = {
-- ['+'] = require('vim.ui.clipboard.osc52').paste('+'),
-- ['*'] = require('vim.ui.clipboard.osc52').paste('*'),
-- },
-- }
-----------------------------------------------------------------------
-- netrw file explorer
-----------------------------------------------------------------------
-- Use tree-style listing.
vim.g.netrw_liststyle = 3
-- netrw buffer options:
-- noma -> not modifiable
-- nomod -> not marked as modified
-- nu -> show line numbers
-- nobl -> do not add to buffer list
-- nowrap -> disable line wrapping
-- ro -> read-only
vim.g.netrw_bufsettings = "noma nomod nu nobl nowrap ro"
-- Customize netrw buffers.
vim.api.nvim_create_autocmd("FileType", {
pattern = "netrw",
callback = function()
-- Hide absolute line numbers in netrw.
vim.opt_local.number = false
-- Hide relative line numbers in netrw.
vim.opt_local.relativenumber = false
-- Disable folding in netrw.
vim.opt_local.foldenable = false
-- Keep netrw read-only.
vim.opt_local.modifiable = false
end,
})
-----------------------------------------------------------------------
-- Lua indentation
-----------------------------------------------------------------------
-- Use 2 spaces instead of 4 for Lua files.
vim.api.nvim_create_autocmd("FileType", {
pattern = "lua",
callback = function()
vim.opt_local.tabstop = 2
vim.opt_local.shiftwidth = 2
vim.opt_local.softtabstop = 2
vim.opt_local.expandtab = true
end,
})