dotfiles/.config/nvim/lua/general.lua

112 lines
4 KiB
Lua

local g = vim.g -- Global variables
local opt = vim.opt -- Set options (global/buffer/windows-scoped)
-----------------------------------------------------------
-- General
-----------------------------------------------------------
opt.mouse = '' -- Disable mouse support
opt.swapfile = false -- Don't use swapfile
opt.modelines = 0 -- Disable modelines
opt.encoding = 'utf-8' -- Set default encoding to UTF-8
opt.termguicolors = true
-- Note that this setting is important for which-key. Also don't reduce it too
-- low, or the behavior will start getting wonky and always show which-key.
opt.timeout = true
opt.timeoutlen = 300 -- Time in ms to wait for a sequnece to complete
opt.shortmess:remove("F")
vim.opt_global.shortmess:remove("F")
opt.shortmess:append("c")
opt.wildignore = {
'*.class', '*.pyc', '*.swp', '*.o', '*.jar', '*/tmp/*', '*.zip',
'*.tar', '*.gz', '*.bz2', '*.xz', '*/.git/*', '*/.metals/*',
'*/.bloop/*', '*/.bsp/*', '*/node_modules/*'
}
-- Disable netrw in favor of nvim-tree
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
-----------------------------------------------------------
-- Completion
-----------------------------------------------------------
-- menu = use a popup menu to show possible completions
-- menuone = show a menu even if there is only one match
-- noinsert = do not insert text for a match until user selects one
-- noselect = do not select a match from the menu automatically
opt.completeopt = 'menu,menuone,noinsert,noselect'
g.completion_enable_auto_popup = 1 -- Enable completions while typing
-----------------------------------------------------------
-- Neovim UI
-----------------------------------------------------------
opt.number = true -- Show line number
opt.cursorline = true -- Highlight the current line
opt.showcmd = true -- Show incomplete commands at the bottom
opt.ttyfast = true -- Rendering optimizations
opt.showmatch = true -- Highlight matching parenthesis
opt.colorcolumn = '80' -- Line length marker at 80 columns
opt.ruler = true -- Show row and column number
opt.signcolumn = 'yes' -- Always show the sign column
opt.foldmethod = 'marker' -- Enable folding (default 'foldmarker')
opt.splitright = true -- Vertical split to the right
opt.splitbelow = true -- Horizontal split to the bottom
opt.linebreak = true -- Wrap on word boundary
opt.termguicolors = true -- Enable 24-bit RGB colors
opt.laststatus = 3 -- Set global statusline
-----------------------------------------------------------
-- Tabs, indent
-----------------------------------------------------------
opt.tabstop = 4
opt.shiftwidth = 4
opt.softtabstop = 4
opt.expandtab = true
opt.smarttab = true
opt.autoindent = true
-- I don't use indentation when writing HTML, and autoindentation makes any form
-- of editing flat out painful.
vim.api.nvim_create_autocmd("FileType", {
pattern = { "*.html" },
callback = function()
vim.opt_local.autoindent = false
vim.opt_local.smarttab = false
vim.opt_local.indentexpr = ''
end,
})
-----------------------------------------------------------
-- Memory, CPU
-----------------------------------------------------------
opt.hidden = true -- Enable background buffers
opt.lazyredraw = true -- Faster scrolling
opt.synmaxcol = 240 -- Max column for syntax highlight
opt.updatetime = 500 -- ms to wait for trigger an event
-----------------------------------------------------------
-- History
-----------------------------------------------------------
opt.history = 512
opt.undolevels = 128
opt.undofile = true
-----------------------------------------------------------
-- Search
-----------------------------------------------------------
opt.ignorecase = true
opt.smartcase = true
opt.incsearch = true
opt.showmatch = true
opt.hlsearch = true
-----------------------------------------------------------
-- Startup
-----------------------------------------------------------
-- Disable nvim intro
opt.shortmess:append("sI")