dotfiles/nvim/lua/kanopo/options.lua
2025-07-29 14:24:12 +02:00

105 lines
3.9 KiB
Lua

-- options.lua
vim.opt.cmdheight = 0
-- Leader key for all the keymaps
vim.g.mapleader = " "
vim.g.maplocalleader = " "
--------------------------------------------------------------------------------
-- -- GENERAL EDITOR BEHAVIOR
--------------------------------------------------------------------------------
vim.opt.clipboard = "unnamedplus" -- Use system clipboard
vim.opt.writebackup = false -- Disable backup files
vim.opt.undofile = true -- Enable persistent undo
vim.opt.wrap = false -- Do not wrap lines
vim.opt.conceallevel = 2 -- Hide markdown syntax, etc.
vim.opt.signcolumn = "yes" -- Always show the sign column to avoid resizing
vim.opt.timeoutlen = 300 -- Time to wait for a mapped sequence to complete
vim.opt.updatetime = 250 -- Faster completion and CursorHold updates
vim.o.winborder = "rounded"
-- Disable unused built-in providers for faster startup
vim.g.loaded_perl_provider = 0
vim.g.loaded_ruby_provider = 0
vim.g.loaded_netrw = 0 -- Disable netrw, as you likely use a plugin like nvim-tree
--------------------------------------------------------------------------------
-- -- UI AND APPEARANCE
--------------------------------------------------------------------------------
vim.opt.number = true -- Show line numbers
vim.opt.relativenumber = true -- Show relative line numbers
vim.opt.cursorline = true -- Highlight the current line
vim.opt.scrolloff = 10 -- Keep 10 lines of context around the cursor
vim.opt.termguicolors = true -- Enable 24-bit RGB color in the TUI
vim.o.foldlevel = 0 -- Start with all folds closed
--------------------------------------------------------------------------------
-- -- SEARCHING
--------------------------------------------------------------------------------
vim.opt.ignorecase = true -- Case-insensitive searching
vim.opt.smartcase = true -- ...unless the query contains a capital letter
--------------------------------------------------------------------------------
-- -- SPELL CHECKING (currently disabled)
--------------------------------------------------------------------------------
-- vim.opt.spell = true
-- vim.opt.spelllang = "en,it"
-- local spell_dir = vim.fn.stdpath("data") .. "/spell"
-- vim.opt.spellfile = {
-- spell_dir .. "/en.utf-8.add",
-- spell_dir .. "/it.utf-8.add",
-- "~/.config/nvim/spell/en.proj.spl",
-- "~/.config/nvim/spell/it.proj.spl",
-- }
--------------------------------------------------------------------------------
-- -- FILETYPE-SPECIFIC SETTINGS (AUTOCOMMANDS)
--------------------------------------------------------------------------------
-- Create an autocommand group to prevent duplicate autocommands on reload
local ft_augroup = vim.api.nvim_create_augroup("FileTypeSettings", { clear = true })
-- C, C++, etc: 4-space indentation
vim.api.nvim_create_autocmd("FileType", {
group = ft_augroup,
pattern = { "c", "cpp", "objc", "objcpp", "js", "ts", "tsx", "jsx" },
callback = function()
-- Use vim.bo for buffer-local options
vim.bo.tabstop = 2
vim.bo.shiftwidth = 2
vim.bo.expandtab = true -- Use spaces instead of tabs
end,
})
-- -- Web dev, scripting, etc: 2-space indentation
-- vim.api.nvim_create_autocmd("FileType", {
-- group = ft_augroup,
-- pattern = {
-- "lua",
-- "python",
-- "javascript",
-- "typescript",
-- "html",
-- "css",
-- "json",
-- "yaml",
-- "toml",
-- "markdown",
-- },
-- callback = function()
-- vim.bo.tabstop = 2
-- vim.bo.shiftwidth = 2
-- vim.bo.expandtab = true
-- end,
-- })
--
-- -- LaTeX: 2-space indentation (example)
-- vim.api.nvim_create_autocmd("FileType", {
-- group = ft_augroup,
-- pattern = { "tex" },
-- callback = function()
-- vim.bo.tabstop = 2
-- vim.bo.shiftwidth = 2
-- vim.bo.expandtab = true
-- end,
-- })