neovim-confs/init.lua

187 lines
5.4 KiB
Lua
Raw Normal View History

2024-03-06 10:51:51 +01:00
local opt = vim.opt
local g = vim.g
g.maplocalleader = ";"
2024-03-06 11:21:22 +01:00
g.python3_host_prog = "/usr/bin/python3"
2024-03-06 10:51:51 +01:00
opt.mouse = "a" -- mouse does annoying things for me if it's not 'a'
opt.signcolumn = "yes"
opt.clipboard = "" -- don't just use the system clipboard
opt.wrap = false
opt.breakindent = false
opt.spell = false
opt.list = true
opt.conceallevel = 2
opt.undofile = true
opt.undolevels = 10000
opt.writebackup = false
opt.history = 5000
opt.shada = { "'1000", "<50", "s10", "h" }
2024-03-06 10:51:51 +01:00
-- Tabs and Indents
-- ===
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
opt.smartindent = true -- Smart autoindenting on new lines
opt.shiftround = true -- Round indent to multiple of 'shiftwidth'
-- Timing
-- ===
opt.ttimeout = true
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
-- Searching
-- ===
opt.ignorecase = true -- Search ignoring case
opt.smartcase = true -- Keep case when searching with *
opt.infercase = true -- Adjust case in insert completion mode
opt.incsearch = true -- Incremental search
-- Formatting
-- ===
opt.wrap = false -- No wrap by default
opt.linebreak = true -- Break long lines at 'breakat'
opt.breakat = "\\ \\ ;:,!?" -- Long lines break chars
opt.startofline = false -- Cursor in same column for few commands
opt.splitbelow = true -- Splits open bottom right
opt.splitright = true
opt.breakindentopt = { shift = 2, min = 20 }
opt.formatoptions = "" -- see :h fo-table & :h formatoptions
-- Diff
-- ===
2024-03-06 11:21:22 +01:00
opt.diffopt:append({ "iwhite", "indent-heuristic", "algorithm:patience" })
2024-03-06 10:51:51 +01:00
opt.wildmode = "longest:full,full" -- Command-line completion mode
-- Folds
-- ===
opt.foldlevel = 10 -- start with all folds open
-- Editor UI
-- ===
vim.o.guifont = "FiraCode Nerd Font:h15"
opt.termguicolors = true
opt.shortmess = "xsTOInfFitloCaAs"
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
if vim.g.started_by_firenvim == true then
2024-03-06 11:21:22 +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
end
2024-03-06 10:51:51 +01:00
if vim.g.neovide == true then
2024-03-06 11:21:22 +01:00
-- fulscreen with F11
vim.api.nvim_set_keymap("n", "<F11>", ":let g:neovide_fullscreen = !g:neovide_fullscreen<CR>", {})
2024-03-06 10:51:51 +01:00
2024-03-06 11:21:22 +01:00
vim.g.neovide_underline_automatic_scaling = true
2024-03-06 10:51:51 +01:00
2024-03-06 11:21:22 +01:00
-- vim.g.neovide_floating_blur_amount_x = 2.0
-- vim.g.neovide_floating_blur_amount_y = 2.0
2024-03-06 11:21:22 +01:00
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
2023-01-07 09:11:43 +01:00
2024-03-06 11:21:22 +01:00
vim.g.neovide_fullscreen = true
2023-01-07 09:11:43 +01:00
end
2024-03-06 10:51:51 +01:00
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
opt.cmdheight = 0
opt.cmdwinheight = 5 -- Command-line lines
opt.equalalways = true -- Resize windows on split or close
opt.colorcolumn = "+0" -- Column highlight at textwidth's max character-limit
opt.cursorline = true
opt.cursorlineopt = { "number", "screenline" }
opt.pumheight = 10 -- Maximum number of items to show in the popup menu
opt.pumwidth = 10 -- Minimum width for the popup menu
opt.pumblend = 10 -- Popup blend
-- 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"
-- autocommands
-- ===
local function augroup(name)
2024-03-06 11:21:22 +01:00
return vim.api.nvim_create_augroup("plex_" .. name, {})
2024-03-06 10:51:51 +01:00
end
2024-03-06 11:21:22 +01:00
2024-03-06 11:43:46 +01:00
-- guis
if vim.g.vscode then
require("vscode")
end
2024-03-06 11:21:22 +01:00
-- mappings
local load_mappings = function(section, mapping_opt)
vim.schedule(function()
local function set_section_map(section_values)
if section_values.plugin then
return
end
section_values.plugin = nil
local merge_tb = vim.tbl_deep_extend
for mode, mode_values in pairs(section_values) do
local default_opts = merge_tb("force", { mode = mode }, mapping_opt or {})
for keybind, mapping_info in pairs(mode_values) do
-- merge default + user opts
local opts = merge_tb("force", default_opts, mapping_info.opts or {})
mapping_info.opts, opts.mode = nil, nil
opts.desc = mapping_info[2]
vim.keymap.set(mode, keybind, mapping_info[1], opts)
end
end
end
local mappings = require("mappings")
if type(section) == "string" then
mappings[section]["plugin"] = nil
mappings = { mappings[section] }
end
for _, sect in pairs(mappings) do
set_section_map(sect)
end
end)
end
load_mappings("clipboard")
load_mappings("movements")
load_mappings("edit")
load_mappings("tabs")
load_mappings("ui")