dotfiles/.config/nvim/lua/settings.lua

58 lines
1.7 KiB
Lua
Raw Normal View History

2022-08-08 11:07:10 +02:00
vim.o.number = true -- line numbers
vim.o.list = true -- show whitespace
2022-08-08 23:11:28 +02:00
vim.o.textwidth = 80 -- default text width
vim.o.colorcolumn = tostring(vim.o.textwidth)
vim.o.wrap = false
2022-08-08 01:41:01 +02:00
2022-08-08 11:07:10 +02:00
vim.o.expandtab = true -- indent using spaces
vim.o.tabstop = 4 -- 1 tab = 4 spaces
vim.o.shiftwidth = 4 -- 1 indentation = 4 spaces
vim.o.completeopt = 'menu,menuone,noselect' -- completion popup
2022-08-08 21:42:21 +02:00
vim.o.autochdir = true -- change workir to current file dir
vim.o.clipboard = 'unnamedplus' -- use sytem clipboard
2022-08-08 01:41:01 +02:00
-- theme
2022-08-08 11:07:10 +02:00
vim.o.termguicolors = true -- 24 bit colours
2022-08-08 01:41:01 +02:00
vim.o.background = 'dark'
2022-08-08 13:57:38 +02:00
packer.use {
'https://github.com/owozsh/amora',
config = function()
vim.cmd('colorscheme amora')
end
}
-- remove trailing whitespace
function my_remove_trailing_whitespace()
local curpos = vim.api.nvim_win_get_cursor(0)
vim.cmd([[keeppatterns %s/\s\+$//e]])
vim.api.nvim_win_set_cursor(0, curpos)
end
vim.api.nvim_create_autocmd(
{ 'BufWritePre' },
{
pattern = {
'*.lua', '*.cpp', '*.hpp'
},
callback = my_remove_trailing_whitespace
}
)
2022-08-08 21:42:35 +02:00
packer.use 'https://github.com/editorconfig/editorconfig-vim'
2022-08-08 23:11:28 +02:00
-- set colorcolumn to textwidth after buffer is displayed or option is changed
vim.api.nvim_create_autocmd(
{ 'BufWinEnter', 'OptionSet' },
{
pattern = { 'textwidth' },
callback = function()
if vim.o.textwidth > 0 then
vim.wo.colorcolumn = tostring(vim.o.textwidth)
else
vim.wo.colorcolumn = ''
end
end
}
)