Files
dotfiles/profiles/desktop/.config/nvim/lua/config/settings.lua
2026-02-13 04:20:30 +01:00

102 lines
3.2 KiB
Lua

-- true color support
vim.o.termguicolors = true
-- fix transparency issues with alacritty
local highlights = {
'Normal',
'LineNr',
'Folded',
'NonText',
'SpecialKey',
'VertSplit',
'SignColumn',
'EndOfBuffer',
'TablineFill', -- this is specific to how I like my tabline to look like
}
for _, name in pairs(highlights) do
vim.cmd.highlight(name .. ' guibg=none ctermbg=none')
end
-- disable arrow keys
local all_modes = { 'n', 'i', 'v', 'o' }
vim.keymap.set(all_modes, '<Up>', '<Nop>', { noremap = true, silent = true })
vim.keymap.set(all_modes, '<Down>', '<Nop>', { noremap = true, silent = true })
vim.keymap.set(all_modes, '<Left>', '<Nop>', { noremap = true, silent = true })
vim.keymap.set(all_modes, '<Right>', '<Nop>', { noremap = true, silent = true })
vim.o.number = true -- display line numbers
vim.opt.clipboard:append({ 'unnamedplus', 'unnamed' }) -- always use clipboard in x11
vim.o.encoding = 'UTF-8' -- sets the character encoding used inside vim
vim.o.title = true -- when on, the title of the window will be set to the value of 'titlestring'
vim.o.signcolumn = 'yes'
-- spell checking
vim.o.spell = true
vim.opt.spelllang:append({ 'en_us', 'en_gb', 'pl' })
vim.opt.spelloptions:append({ 'camel' })
vim.o.spellcapcheck = ''
-- persistent undo
local undodir = vim.fn.stdpath('state') .. 'undo'
vim.fn.mkdir(undodir, 'p', '0700')
vim.o.undodir = undodir
vim.o.undofile = true
-- set proper file types for files in ~/ansible directory
vim.filetype.add({
pattern = {
[os.getenv('HOME') .. '/ansible/.*%.yml'] = 'yaml.ansible',
},
})
-- neovim terminal configuration
local augroup_term = vim.api.nvim_create_augroup('augroup_term', { clear = true })
vim.api.nvim_create_autocmd('TermOpen', { -- enter insert mode automatically
group = augroup_term,
pattern = '*',
callback = vim.cmd.startinsert,
})
vim.api.nvim_create_autocmd('TermOpen', { -- disable number lines on terminal buffers
group = augroup_term,
pattern = '*',
callback = function()
vim.o.number = false
vim.o.relativenumber = false
end,
})
vim.api.nvim_create_autocmd('TermOpen', { -- allow use ctrl-c on terminal windows
group = augroup_term,
pattern = '*',
callback = function(args)
vim.keymap.set('n', '<C-c>', 'i<C-c>', { buffer = args.buf })
end,
})
vim.api.nvim_create_autocmd('TermEnter', { -- no sign column
group = augroup_term,
pattern = '*',
callback = function()
vim.opt_local.signcolumn = false
end,
})
vim.keymap.set('t', '<Esc>', '<C-\\><C-n>') -- esc to exit insert mode
-- set default tab width to 4 spaces
vim.o.tabstop = 4 -- number of spaces that a tab counts for
vim.o.shiftwidth = 4 -- number of spaces that are inserted during indent operations
vim.o.softtabstop = 4 -- number of spaces that are inserted after pressing tab
vim.o.expandtab = true -- use spaces instead of tabs
-- c/c++ settings
vim.opt.cinoptions:append({ 'N-s' })
-- web dev settings
vim.g.html_indent_autotags = 'html,thead,tbody,tfoot'
vim.g.html_indent_script1 = 'auto'
vim.g.html_indent_style1 = 'auto'
-- set cursor shape to underline in the normal and command mode,
-- in the insert mode change shape to vertical bar, and disable
-- blinking in all modes
vim.opt.guicursor:append({ 'n-c:hor20', 'i:ver20', 'a:blinkon0' })