vimrc/init.lua

142 lines
4.3 KiB
Lua
Raw Normal View History

2022-10-30 17:27:18 +00:00
local vimrc_git = os.getenv("HOME") .. "/src/vimrc"
-- add to package path to allow use of require() for lua modules
package.path = string.format("%s;%s?.lua", package.path, vimrc_git.."/")
2022-10-30 17:27:18 +00:00
2022-10-31 14:59:04 +00:00
-- it is a big fat key, after all
-- N.B. should come before plugins and plugin specific settings
vim.g.mapleader = ' '
require("plug")
--vim.cmd("source " .. vimrc_git .. "/plug.lua")
2022-10-30 17:27:18 +00:00
vim.cmd("source " .. vimrc_git .. "/airline.vim")
vim.cmd("source " .. vimrc_git .. "/lsp.vim")
require("mapping")
--vim.cmd("source " .. vimrc_git .. "/mapping.lua")
vim.cmd("source " .. vimrc_git .. "/fzf.vim")
2022-10-30 17:27:18 +00:00
vim.cmd("source " .. vimrc_git .. "/jsonnet.vim")
vim.cmd("source " .. vimrc_git .. "/nerdtree.vim")
vim.cmd("source " .. vimrc_git .. "/wiki.vim")
2022-10-31 14:59:04 +00:00
if vim.g.neovide then
require("size-matters")
end
2022-10-30 17:27:18 +00:00
-- set up a line number on the current line but relative above and below to
-- help with motion commands
vim.opt.number = true
2024-06-27 20:35:56 +00:00
vim.opt.numberwidth = 2
2022-10-30 17:27:18 +00:00
vim.opt.relativenumber = true
-- even with the nice space/tab autodetect, prefer 4 for tab stops but let file
-- type specifics override (for instance a setting of 2 for markdown
vim.opt.tabstop = 4
-- default to folding on syntax
vim.opt.foldmethod = "syntax"
-- disable automatic line breaks, rely on visual wrapping instead
vim.opt.textwidth = 0
-- make white space visible, where that matters
vim.opt.list = true
local function nolist()
vim.opt.list = false
end
-- make white space invisible only in help text
vim.api.nvim_create_autocmd("FileType", {
pattern = "help",
callback = nolist,
})
-- set up folding preferences
vim.opt.fde = "1"
-- vim's spelling is smart enough for code, to only check comments
vim.opt.spell = true
-- add a hint for long lines
vim.opt.colorcolumn = "120"
-- default to expanding tabs, I'm not insane
vim.opt.expandtab = true
-- change buffer behaviors to no longer require changes when hiding a buffer
vim.opt.hidden = true
-- look for vimrc in the current directory as well as $MYVIMRC
2024-06-27 20:35:56 +00:00
-- e.g. place .init.lua at the root of a project directory for project specific settings
2022-10-30 17:27:18 +00:00
vim.opt.exrc = true
-- make looking for local changes secure
vim.opt.secure = true
-- more secure
vim.opt.modelines = 0
-- preserve some context
vim.opt.scrolloff = 3
-- make the cursor a bit easier to follows
vim.opt.cursorline = true
-- make search work a bit more like tab completion in bash
vim.opt.incsearch = true
vim.opt.wildmode = "longest:full"
vim.opt. wildmenu = true
-- line break handling
vim.opt.linebreak = true
vim.opt.showbreak = "+"
-- always on status line
vim.opt.laststatus = 2
-- let backspace work more naturally
vim.opt.backspace = "start,indent,eol"
-- favor modern encoding
vim.opt.enc = "utf-8"
-- more readable config for list mode
vim.opt.listchars = {nbsp = '¬', tab = '»·', trail = '·'}
-- smarter handling of case during search
vim.opt.ignorecase = true
vim.opt.smartcase = true
-- centralize swap to have backup without clutter
vim.opt.directory = os.getenv("HOME") .. "/.var/nvim/swp//"
-- and undo
vim.opt.undofile = true
vim.opt.undodir = os.getenv("HOME") .. "/.nvim/undodir"
-- save when moving away
2022-10-31 14:59:04 +00:00
vim.api.nvim_create_autocmd("FocusLost", {pattern = "*", command = "wa"})
2022-10-30 17:27:18 +00:00
-- make sure to set TERM to xterm-256color in terminal program or app
vim.opt.background = "dark"
2022-10-30 17:27:18 +00:00
vim.opt.termguicolors = true
2024-06-23 15:10:23 +00:00
vim.cmd("colorscheme breezy")
vim.g.airline_theme = "breezy"
2022-10-30 17:27:18 +00:00
-- ensure autoread works, to detect file changes outside the editor
vim.opt.autoread = true
2022-10-31 14:59:04 +00:00
vim.api.nvim_create_autocmd("CursorHold", {pattern = "*", command = "checktime"})
2022-10-30 17:27:18 +00:00
-- for gui, make it easier to tell different instances apart
vim.opt.title = true
-- keep nvim from resetting font back to default from terminal config
vim.opt.guicursor = nil
2022-10-31 14:59:04 +00:00
local guiopts = vim.g.guioptions
if guiopts == nil then
guiopts = ""
end
2022-10-30 17:27:18 +00:00
guiopts = guiopts:gsub("r", "")
guiopts = guiopts:gsub("b", "")
guiopts = guiopts:gsub("T", "")
guiopts = guiopts:gsub("m", "")
2022-10-31 14:59:04 +00:00
vim.g.guioptions = guiopts
2022-10-30 17:27:18 +00:00
vim.opt.mouse = "nv"
2024-06-23 14:35:09 +00:00
if vim.loop.os_uname().sysname == 'Linux' then
2024-04-18 21:21:36 +00:00
vim.opt.gfn = "FiraCode Nerd Font Mono:h12"
require('nvim-projectconfig').setup({autocmd=true})
2024-06-23 14:35:09 +00:00
else
vim.opt.gfn = "FiraCode Nerd Font Mono:h16"
require('nvim-projectconfig').setup()
2024-04-18 21:21:36 +00:00
end
2024-06-23 14:35:09 +00:00
2022-10-30 17:27:18 +00:00
require("trouble").setup {
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
}