repositories / dotfiles
dotfiles
bugabingas dorkfiles
owned by bugabinga
neovim/lua/bugabinga/options/init.lua
Rawlocal const = require 'std.const'
local icon = require 'std.icon'
-- disable some runtime providers that i will not use.
-- keeps checkhealth clean
-- pls stop haunting me python...
vim.g.loaded_python3_provider = 0
vim.g.loaded_ruby_provider = 0
vim.g.loaded_node_provider = 0
vim.g.loaded_perl_provider = 0
-- add new filetypes rearly on
require 'bugabinga.options.filetypes'
-- NEOVIM EDITOR OPTIONS
-- Keep track of file changes outside of vim
vim.opt.autoread = true
-- encode files in UTF-8
vim.opt.fileencoding = 'utf-8'
-- do not create local backup files
vim.opt.backup = true
-- by default backups are created next to the edited file.
-- that tends to pollute the workspace.
-- instead, backup to the second default directory only.
-- neovim should create it if it does not exist.
-- the double slash at the end means something important...
-- i think it means to use full path as name for backup files to avoid
-- collisions.
vim.opt.backupdir = vim.fn.stdpath 'state' .. '/backup//'
-- do not make a backup before writing to a file
vim.opt.writebackup = true
-- save a swap file after every 100 typed characters.
vim.opt.swapfile = true
vim.opt.updatecount = 100
-- enable persistent undo. save undo history across neovim instances
vim.opt.undofile = true
-- How many milliseconds must pass before neovim decides I was "idle"
vim.opt.updatetime = 50
-- How long to wait between key sequences in order to chain them. e.g. <LEADER>b
vim.opt.timeoutlen = 250
-- allow commands like find, grep, ... to search for files recursively
vim.opt.path:append '**'
-- wrap line movements, when start/end is reached
vim.opt.whichwrap:append '<'
vim.opt.whichwrap:append '>'
vim.opt.whichwrap:append '['
vim.opt.whichwrap:append ']'
vim.opt.whichwrap:append 'h'
vim.opt.whichwrap:append 'l'
-- treat words separated by a dash as one word. used in snail-case-convention
vim.opt.iskeyword:append '-'
-- Tabs and Spaces, i like 'em 2 spaces wide
-- only insert spaces for tabs if language configuration explicitly declares so
vim.opt.expandtab = false
local tab_size = 2
vim.opt.tabstop = tab_size
vim.opt.shiftwidth = tab_size
vim.opt.softtabstop = tab_size
vim.opt.shiftround = true
-- insert whitespace type based on whitespace on previous line
vim.opt.smarttab = true
vim.opt.wrap = false
-- wrapped lines will continue on indentation
vim.opt.breakindent = true
-- do not keep distance to borders while scrolling
vim.opt.scrolloff = 0
vim.opt.sidescrolloff = 0
-- try to guess indentation based on context
vim.opt.smartindent = true
-- Keep indentation of new lines in line with previous lines
vim.opt.autoindent = true
vim.opt.copyindent = true
-- open splits to the right and below
vim.opt.splitbelow = true
vim.opt.splitright = true
vim.opt.splitkeep = 'screen'
-- enable mouse
vim.opt.mouse = 'a'
-- disable popup menu on right click
vim.opt.mousemodel = 'extend'
-- if vim.fn.executable 'nu' then
-- -- integrate Nushell with nvim
-- vim.opt.shell = 'nu'
-- -- flags for nu:
-- -- * `--stdin` redirect all input to -c
-- -- * `--no-newline` do not append `\n` to stdout
-- -- * `--commands` execute a command
-- vim.opt.shellcmdflag = '--stdin --no-newline --commands'
-- -- string to be used to put the output of shell commands in a temp file
-- -- 1. when 'shelltemp' is `true`
-- -- 2. in the `diff-mode` (`nvim -d file1 file2`) when `diffopt` is set
-- -- to use an external diff command: `set diffopt-=internal`
-- vim.opt.shellredir = 'out+err> "%s"'
-- -- string to be used with `:make` command to:
-- -- 1. save the stderr of `makeprg` in the temp file which Neovim reads using `errorformat` to populate the `quickfix` buffer
-- -- 2. show the stdout, stderr on the screen
-- -- NOTE: `ansi strip` removes all ansi coloring from nushell errors
-- vim.opt.shellpipe =
-- '| complete | get stderr stdout | str join (char nl) | ansi strip | tee { save --force --raw "%s" }'
-- -- WARN: disable the usage of temp files for shell commands
-- -- because Nu doesn't support `input redirection` which Neovim uses to send buffer content to a command:
-- -- `{shell_command} < {temp_file_with_selected_buffer_content}`
-- -- When set to `false` the stdin pipe will be used instead.
-- -- NOTE: some info about `shelltemp`: https://github.com/neovim/neovim/issues/1008
-- vim.opt.shelltemp = false
-- vim.opt.shellxquote = ''
-- vim.opt.shellxescape = ''
-- vim.opt.shellquote = ''
-- end
-- require 'bugabinga.health'.add_dependency
-- {
-- name = 'Nushell',
-- name_of_executable = 'nu',
-- }
-- highlight all search matches
vim.opt.hlsearch = true
-- enable smart case in searches
vim.opt.ignorecase = true
vim.opt.smartcase = true
vim.opt.incsearch = true
vim.opt.showmatch = true
vim.opt.hidden = true
-- Show the effects of substitutions incrementally
vim.opt.inccommand = 'nosplit'
if vim.fn.executable 'rg' then
-- use ripgrep instead of grep
vim.opt.grepprg = 'rg --hidden --vimgrep --no-heading --smart-case -- '
vim.opt.grepformat = '%f:%l:%c:%m'
end
require 'bugabinga.health'.add_dependency
{
name = 'Ripgrep',
name_of_executable = 'rg',
}
-- ask me to force failed commands
vim.opt.confirm = true
if const.wsl or const.win32 then
require 'bugabinga.health'.add_dependency
{
name = 'win32yank',
name_of_executable = 'win32yank.exe',
}
vim.g.clipboard = {
name = 'win32yank-wsl',
copy = {
['+'] = 'win32yank.exe -i --crlf',
['*'] = 'win32yank.exe -i --crlf',
},
paste = {
['+'] = 'win32yank.exe -o --lf',
['*'] = 'win32yank.exe -o --lf',
},
cache_enabled = true,
}
end
-- show trailing whitespace
vim.opt.list = true
vim.opt.listchars = {
-- space = icon.space,
-- eol = icon.eol,
-- tab = icon.tab .. icon.middle_ellipsis,
tab = ' ',
trail = icon.trail,
extends = icon.extends,
precedes = icon.precedes,
nbsp = icon.nbsp,
}
-- force English messages
vim.cmd [[ language en_US.utf8 ]]
-- keeps title in terminal uptodate
vim.cmd [[ set title ]]
-- do not spam the cmdline with every little input
vim.opt.showcmd = false
-- autocomplete menu in command buffer
vim.opt.wildmode = 'list:longest'
vim.opt.wildignorecase = true
-- virtually break lines on border
-- always display the signcolumn to avoid jitter
vim.opt.signcolumn = 'yes:2'
-- what is a ruler? me?
vim.opt.ruler = false
-- avoid jitter by keeping status area big
vim.opt.laststatus = 3
-- hide weird symbol at end of buffer
vim.opt.fillchars = {
eob = ' ',
lastline = ' ',
diff = '╱',
wbr = ' ',
horiz = '─',
horizup = '┴',
horizdown = '┬',
vert = '│',
vertleft = '┤',
vertright = '├',
verthoriz = '┼',
}
-- better have no syntax highlighting than regex based, treesitter will take over later
vim.opt.syntax = 'off'
-- hide output of insert completion popup in status
-- vim.opt.shortmess:append 'c'
-- hide vim intro screen
vim.opt.shortmess:append 'I'
-- truncate messages at end
-- vim.opt.shortmess:append 't'
-- show cmd window to prevent jitter UI
vim.opt.cmdheight = 1
-- do not conceal special characters by default. ftplugin can enable this on demand.
vim.opt.conceallevel = 0
-- I do not care for folding
vim.opt.foldenable = false
-- show visual indicators for lines too long
vim.opt.colorcolumn = { '80', '120', '140' }
-- highlight the current line
vim.opt.cursorline = false
-- pop up menu height
vim.opt.pumheight = 10
-- no transparent popups and floating windows
vim.opt.pumblend = 0
vim.opt.winblend = 0
-- use this in various places for consistent border style
vim.g.border_style = 'single'
-- hide the mode indicator in status
vim.opt.showmode = false
-- always show tabs, to avoid jitter UI
vim.opt.showtabline = 2
local is_tty = vim.env.XDG_SESSION_TYPE == 'tty' and vim.env.SSH_TTY == ''
if is_tty then
vim.opt.termguicolors = false
vim.g.nerdfont = false
vim.opt.lazyredraw = true
else
vim.opt.termguicolors = true
vim.g.nerdfont = true
vim.opt.lazyredraw = false
end
-- scroll by screen lines if buffer is wrapped
vim.opt.smoothscroll = true
-- cursor
-- vim.opt.guicursor = 'n-v-c-sm:block-Cursor,i-ci-ve:ver25-blinkon250,r-cr:hor20,o:hor50'
-- font
-- vim.opt.guifont = 'Cousine,Symbols Nerd Font Mono:h15:#e-subpixelantialias:#h-none'
-- neovide only options
if vim.g.neovide then
vim.g.neovide_profiler = false
-- interpret all touch events as scroll events
vim.g.neovide_touch_deadzone = 0.0
-- after this timeout, start a visual selection
vim.g.neovide_underline_stroke_scale = 2.5
vim.g.neovide_touch_drag_timeout = 0.69
vim.g.neovide_padding_top = 8
vim.g.neovide_padding_left = 8
vim.g.neovide_padding_bottom = 0
vim.g.neovide_padding_right = 0
vim.g.neovide_hide_mouse_when_typing = true
vim.g.neovide_refresh_rate_idle = 5
vim.g.neovide_theme = 'auto'
vim.g.experimental_layer_grouping = true
end
require 'bugabinga.options.behaviour'
require 'bugabinga.options.keymaps'
require 'bugabinga.options.spelling'
require 'bugabinga.options.commands'