neovim-confs/lua/custom/init.lua

186 lines
5.6 KiB
Lua
Raw Normal View History

2024-01-19 22:34:37 +01:00
local opt = vim.opt
local g = vim.g
g.maplocalleader = ";"
2024-01-20 01:42:31 +01:00
2024-03-01 16:41:14 +01:00
opt.mouse = "a" -- mouse does annoying things for me if it's not 'a'
2024-01-19 22:34:37 +01:00
opt.signcolumn = "yes"
2024-01-20 01:03:01 +01:00
opt.clipboard = "" -- don't just use the system clipboard
2024-01-19 23:44:07 +01:00
opt.wrap = false
opt.breakindent = false
2024-01-20 17:26:50 +01:00
opt.spell = false
2024-01-20 01:03:01 +01:00
opt.list = true
2024-01-20 01:42:31 +01:00
opt.conceallevel = 2
opt.undofile = true
opt.undolevels = 10000
opt.writebackup = false
opt.history = 5000
opt.shada = { "'1000", "<50", "s10", "h" }
-- Tabs and Indents
-- ===
2024-03-01 16:41:14 +01:00
opt.textwidth = 80 -- Text width maximum chars before wrapping
opt.tabstop = 4 -- The number of spaces a tab is
opt.shiftwidth = 4 -- Number of spaces to use in auto(indent)
opt.smarttab = true -- Tab insert blanks according to 'shiftwidth'
opt.autoindent = true -- Use same indenting on new lines
2024-01-20 01:42:31 +01:00
opt.smartindent = true -- Smart autoindenting on new lines
2024-03-01 16:41:14 +01:00
opt.shiftround = true -- Round indent to multiple of 'shiftwidth'
2024-01-20 01:42:31 +01:00
-- Timing
-- ===
opt.ttimeout = true
2024-01-20 03:03:39 +01:00
opt.timeoutlen = 500 -- Time out on mappings
opt.ttimeoutlen = 10 -- Time out on key codes
opt.updatetime = 500 -- Idle time to write swap and trigger CursorHold
2024-01-20 01:42:31 +01:00
-- Searching
-- ===
opt.ignorecase = true -- Search ignoring case
2024-03-01 16:41:14 +01:00
opt.smartcase = true -- Keep case when searching with *
opt.infercase = true -- Adjust case in insert completion mode
opt.incsearch = true -- Incremental search
2024-01-20 01:42:31 +01:00
-- Formatting
-- ===
2024-03-01 16:41:14 +01:00
opt.wrap = false -- No wrap by default
opt.linebreak = true -- Break long lines at 'breakat'
2024-01-20 14:22:03 +01:00
opt.breakat = "\\ \\ ;:,!?" -- Long lines break chars
2024-03-01 16:41:14 +01:00
opt.startofline = false -- Cursor in same column for few commands
opt.splitbelow = true -- Splits open bottom right
2024-01-20 01:42:31 +01:00
opt.splitright = true
opt.breakindentopt = { shift = 2, min = 20 }
2024-01-20 03:03:39 +01:00
opt.formatoptions = "qnlmBjp" -- see :h fo-table & :h formatoptions
2024-01-20 01:42:31 +01:00
-- Diff
-- ===
2024-01-20 14:22:03 +01:00
opt.diffopt:append { "iwhite", "indent-heuristic", "algorithm:patience" }
opt.wildmode = "longest:full,full" -- Command-line completion mode
2024-01-20 01:42:31 +01:00
2024-01-20 16:05:24 +01:00
-- Folds
-- ===
2024-01-21 23:58:09 +01:00
opt.foldlevel = 10 -- start with all folds open
2024-01-20 16:05:24 +01:00
2024-01-20 01:42:31 +01:00
-- Editor UI
-- ===
2024-03-01 13:54:24 +01:00
vim.o.guifont = "FiraCode Nerd Font:h15"
2024-01-20 01:42:31 +01:00
opt.termguicolors = true
opt.shortmess = "xsTOInfFitloCaAs"
2024-03-01 16:41:14 +01:00
opt.showmode = true -- Show mode in cmd window
opt.scrolloff = 2 -- Keep at least n lines above/below
opt.sidescrolloff = 0 -- Keep at least n lines left/right
opt.numberwidth = 2 -- Minimum number of columns to use for the line number
opt.number = true -- Show line numbers
opt.relativenumber = true -- Show relative line numbers
opt.ruler = true -- Default status ruler
opt.list = true -- Show hidden characters
opt.showtabline = 1 -- Don't change this, goes back to a vanilla vim default
opt.laststatus = 3 -- Always show laststatus
2024-01-20 01:42:31 +01:00
2024-01-20 16:47:00 +01:00
if vim.g.started_by_firenvim == true then
2024-03-01 16:41:14 +01:00
opt.showtabline = 1 -- Don't show tabline in firenvim, unless multitab
opt.laststatus = 1 -- Don't show laststatus in firenvim
opt.wrap = true
2024-01-20 01:42:31 +01:00
end
2024-01-20 16:47:00 +01:00
2024-03-01 16:41:14 +01:00
if vim.g.neovide == true then
-- fulscreen with F11
vim.api.nvim_set_keymap("n", "<F11>", ":let g:neovide_fullscreen = !g:neovide_fullscreen<CR>", {})
2024-01-20 01:42:31 +01:00
2024-03-01 16:41:14 +01:00
vim.g.neovide_underline_automatic_scaling = true
-- vim.g.neovide_floating_blur_amount_x = 2.0
-- vim.g.neovide_floating_blur_amount_y = 2.0
vim.g.neovide_scroll_animation_length = 0.1
-- vim.g.neovide_cursor_animation_length = 0
-- vim.g.neovide_cursor_trail_size = 0
vim.g.neovide_hide_mouse_when_typing = true
vim.g.neovide_fullscreen = true
end
opt.helpheight = 0 -- Disable help window resizing
opt.winwidth = 30 -- Minimum width for active window
opt.winminwidth = 1 -- Minimum width for inactive windows
opt.winheight = 1 -- Minimum height for active window
opt.winminheight = 1 -- Minimum height for inactive window
opt.showcmd = false -- show command in status line
2024-01-20 01:42:31 +01:00
opt.cmdheight = 0
2024-03-01 16:41:14 +01:00
opt.cmdwinheight = 5 -- Command-line lines
2024-01-20 03:03:39 +01:00
opt.equalalways = true -- Resize windows on split or close
2024-01-20 14:22:03 +01:00
opt.colorcolumn = "+0" -- Column highlight at textwidth's max character-limit
2024-01-20 01:42:31 +01:00
opt.cursorline = true
2024-01-20 14:22:03 +01:00
opt.cursorlineopt = { "number", "screenline" }
2024-01-20 01:42:31 +01:00
2024-01-20 03:03:39 +01:00
opt.pumheight = 10 -- Maximum number of items to show in the popup menu
2024-03-01 16:41:14 +01:00
opt.pumwidth = 10 -- Minimum width for the popup menu
opt.pumblend = 10 -- Popup blend
2024-01-20 01:42:31 +01:00
2024-01-31 15:44:47 +01:00
-- Spelling correction
-- ===
opt.spell = false -- manually enable spell with `set spell` or `<leader>ts`
opt.spelllang = "en,de_de,"
opt.spellsuggest = "double,50,timeout:5000"
2024-01-20 03:03:39 +01:00
-- autocommands
2024-01-20 01:42:31 +01:00
-- ===
local function augroup(name)
2024-03-01 16:41:14 +01:00
return vim.api.nvim_create_augroup("plex_" .. name, {})
2024-01-20 01:42:31 +01:00
end
-- highlight on yank
vim.api.nvim_create_autocmd("TextYankPost", {
2024-03-01 16:41:14 +01:00
group = augroup "highlight_yank",
callback = function()
vim.highlight.on_yank()
end,
2024-01-20 01:42:31 +01:00
})
-- Disable conceallevel for specific file-types.
2024-01-20 14:22:03 +01:00
vim.api.nvim_create_autocmd("FileType", {
2024-03-01 16:41:14 +01:00
group = augroup "fix_conceallevel",
pattern = { "latex", "tex" },
callback = function()
vim.opt_local.conceallevel = 0
end,
2024-01-20 01:42:31 +01:00
})
-- Resize splits if window got resized
2024-01-20 14:22:03 +01:00
vim.api.nvim_create_autocmd("VimResized", {
2024-03-01 16:41:14 +01:00
group = augroup "resize_splits",
callback = function()
vim.cmd "wincmd ="
end,
2024-01-20 01:42:31 +01:00
})
2024-01-20 03:03:39 +01:00
-- Wrap and enable spell-checker in text filetypes
2024-01-20 14:22:03 +01:00
vim.api.nvim_create_autocmd("FileType", {
2024-03-01 16:41:14 +01:00
group = augroup "spell_conceal",
pattern = { "gitcommit", "markdown", "tex", "latex", "norg" },
callback = function()
vim.opt_local.spell = true
vim.opt_local.conceallevel = 0
end,
2024-01-20 03:03:39 +01:00
})
2024-01-20 14:22:03 +01:00
-- map resizing for firenvim
if vim.g.started_by_firenvim == true then
2024-03-01 16:41:14 +01:00
vim.keymap.set("n", "<leader><C-DOWN>", function()
vim.o.lines = vim.o.lines + 1
end, { expr = true, desc = "Make Display bigger" })
vim.keymap.set("n", "<leader><C-UP>", function()
vim.o.lines = vim.o.lines - 1
end, { expr = true, desc = "Make Display smaller" })
2024-01-20 14:22:03 +01:00
end
2024-02-09 18:49:07 +01:00
-- alias filetypes
2024-03-01 16:41:14 +01:00
vim.filetype.add { extension = { tera = "html" } }