.dotfiles/nvim/lua/generic.lua

151 lines
4.4 KiB
Lua
Raw Normal View History

2023-01-07 17:03:31 +00:00
-- Variables
HOME = os.getenv("HOME")
-- Basic Functions/Settings
vim.o.backspace = "indent,eol,start" -- backspace works on every char in insert mode
vim.o.completeopt = 'menuone,noselect'
vim.o.history = 1000
vim.o.startofline = true
-- UI
vim.o.background= 'dark'
vim.o.termguicolors = true
vim.o.ttyfast = true
vim.o.autoread = true
vim.o.hlsearch = true
vim.o.number = true
vim.o.title = true
vim.o.scrolloff = 1000 -- center current line in screen
vim.o.synmaxcol = 300 -- stop syntax highlight after x lines for performance
vim.o.laststatus = 2 -- always show status line
-- Styleguide/Preferences
vim.o.autoindent = true
-- Localization
vim.o.encoding = "utf-8"
vim.o.dictionary = '/usr/share/dict/words'
vim.o.spelllang = 'en_ca'
-- Define files to spellcheck
vim.api.nvim_create_autocmd(
{
"BufRead",
"BufNewFile"
},{
pattern = {
"gitcommit",
"gitrebase",
"*.txt",
"*.md",
"*.tex"
},
command = "setlocal spell"
}
)
-- Mapping Timeouts
vim.o.timeout = false
vim.o.ttimeout = true
vim.o.ttimeoutlen = 100
-- Display Hints/Highlights
vim.o.colorcolumn=101
vim.highlight.create('ColorColumn', {ctermbg=lightred, guibg=lightred}, false)
vim.highlight.create('ExtraWhitespace', {ctermbg=lightred, guibg=lightred}, false)
vim.o.showmatch = true -- show matching brackets
vim.o.list = 'listchars=tab:»\ ,trail:·'
vim.o.foldenable = false
vim.o.foldlevel = 4 -- limit folding to 4 levels
vim.o.foldmethod = 'syntax' -- use language syntax to generate folds
vim.o.wrap = true --do not wrap lines even if very long
vim.o.eol = false -- show if there's no eol char
vim.o.showbreak= '' -- character to show when line is broken
-- Remove trailing whitespace
vim.api.nvim_create_autocmd(
{
"BufWritePre",
"BufWinEnter",
"InsertEnter",
"InsertLeave"
},{
pattern = { "*" },
command = [[%s/\s\+$//e]]
}
)
-- Sidebar
vim.o.number = true -- line number on the left
vim.o.numberwidth = 4 -- always reserve 4 spaces for line number
vim.o.signcolumn = 'yes' -- keep 1 column for coc.vim check
vim.o.modelines = 0
vim.o.showcmd = true -- display command in bottom bar
-- Search
vim.o.incsearch = true -- starts searching as soon as typing, without enter needed
vim.o.ignorecase = true -- ignore letter case when searching
vim.o.smartcase = true -- case insentive unless capitals used in search
vim.o.matchtime = 2 -- delay before showing matching paren
vim.o.mps = vim.o.mps .. ",<:>"
-- White characters
vim.o.autoindent = true
vim.o.smartindent = true
vim.o.tabstop = 4 -- 1 tab = 2 spaces
vim.o.shiftwidth = 4 -- indentation rule
vim.o.formatoptions = 'qnj1' -- q - comment formatting; n - numbered lists; j - remove comment when joining lines; 1 - don't break after one-letter word
vim.o.expandtab = true -- expand tab to spaces
-- Backup files
vim.o.undodir = HOME .. '/.spool/nvim/tmp/undo//' -- undo files
vim.o.backup = true -- use backup files
vim.o.writebackup = true -- use temporary backup during write
vim.o.backupdir = HOME .. '/.spool/nvim/tmp/backup//' -- backups
vim.o.swapfile = false -- don't use swap file
--vim.o.directory = HOME .. '/.spool/nvim/tmp/swap//' -- swap files
-- Commands mode
vim.o.wildmenu = true -- on TAB, complete options for system command
vim.o.wildignore = 'deps,.svn,CVS,.git,.hg,*.o,*.a,*.class,*.mo,*.la,*.so,*.obj,*.swp,*.jpg,*.png,*.xpm,*.gif,.DS_Store,*.aux,*.out,*.toc'
-- Executables
vim.g.python3_host_prog = "/var/home/jpm/.pyenv/shims/python3"
vim.g.python_host_prog = "/var/home/jpm/.pyenv/shims/python2"
-- Theme
vim.o.background = 'dark'
vim.colorscheme = 'gruvbox'
vim.o.t_Co = 16
vim.cmd([[
let g:gruvbox_contrast_dark="hard"
let g:gruvbox_italic=1
let g:gruvbox_bold=1
let g:gruvbox_underline=1
let g:gruvbox_undercurl=1
let g:gruvbox_termcolors=256
syn on se title
]])
-- Abbreviations
vim.cmd([[
source ${HOME}/.dotfiles/vim/abbreviations/personalAbbreviations.vim
source ${HOME}/.dotfiles/vim/abbreviations/codingAbbreviations.vim
]])
-- Fix indentation in file
--viml: map <leader>i mmgg=G`m<CR>
vim.g.mapleader = ','
vim.g.maplocalleader = '\\'
vim.keymap.set("i", "kj", "<esc>", { silent = true })
-- Configure tabline
vim.cmd([[
set showtabline=2
let g:tablabel = "%N%{flagship#tabmodified()} %{flagship#tabcwds('shorten',',')}"
]])
-- 100 characters line
--"execute "set colorcolumn=" . join(range(101,335), ',')
--highlight ColorColumn ctermbg=Black ctermfg=DarkRed