vimrc/init.lua

140 lines
4.2 KiB
Lua
Raw Normal View History

2022-10-30 17:27:18 +00:00
local vimrc_git = os.getenv("HOME") .. "/src/vimrc"
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 = ' '
2022-10-30 17:27:18 +00:00
vim.cmd("source " .. vimrc_git .. "/plug.vim")
vim.cmd("source " .. vimrc_git .. "/airline.vim")
vim.cmd("source " .. vimrc_git .. "/syntastic.vim")
vim.cmd("source " .. vimrc_git .. "/fzf.vim")
vim.cmd("source " .. vimrc_git .. "/lsp.vim")
vim.cmd("source " .. vimrc_git .. "/mapping.vim")
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
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
-- e.g. place .nvim.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"
-- make pastemode more accessible
vim.opt.pastetoggle = "<F2>"
-- 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.cmd("colorscheme breezy")
vim.opt.background = "dark"
2022-10-30 17:27:18 +00:00
vim.opt.termguicolors = true
-- 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-04-18 21:21:36 +00:00
if vim.fn.has('macunix') then
vim.opt.gfn = "FiraCode Nerd Font Mono:h16"
else
vim.opt.gfn = "FiraCode Nerd Font Mono:h12"
end
2022-10-30 17:27:18 +00:00
2024-04-18 21:21:36 +00:00
if not vim.fn.has('macunix') then
require('nvim-projectconfig').setup({autocmd=true})
end
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
}