From 6c1793d98f244f0b6fc1b9eb163647dc9032f358 Mon Sep 17 00:00:00 2001 From: Cody Hiar Date: Fri, 3 Sep 2021 22:22:12 -0600 Subject: More work on lua config --- lua/settings.lua | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) (limited to 'lua') diff --git a/lua/settings.lua b/lua/settings.lua index e0ecddb..4e0b209 100644 --- a/lua/settings.lua +++ b/lua/settings.lua @@ -1,5 +1,115 @@ +--[[ +Todo + +https://dev.to/voyeg3r/writing-useful-lua-functions-to-my-neovim-14ki +function to remove whitespace and preserve spot on save + + + + + +]]-- local o = vim.o local g = vim.g +local cmd = vim.cmd +local map = vim.api.nvim_set_keymap +-- https://old.reddit.com/r/neovim/comments/lrz18i/how_to_change_colorscheme_in_lua_without_any/ g.colors_name = "nord" +-- Set up spacebar as leader +map('n', '', '', {}) +vim.g.mapleader = ' ' + +-- Set spaces > tabs, 4 as default +o.expandtab = true +o.tabstop = 4 +o.shiftwidth = 0 + +o.wrap = false +o.history = 1000 +-- Wildmode show list, complete to first result +o.wildignore = "*/app/cache,*/vendor,*/env,*.pyc,*/venv,*/__pycache__,*/venv" +o.splitright = true +o.splitbelow = true +o.spelllang = "en_ca" + + +local highlights = { + "Search ctermfg=166", + "DiffAdd cterm=BOLD ctermfg=NONE ctermbg=22", + "DiffDelete cterm=BOLD ctermfg=NONE ctermbg=52", + "DiffChange cterm=BOLD ctermfg=NONE ctermbg=23", + "DiffText cterm=BOLD ctermfg=NONE ctermbg=23", + "Normal guibg=NONE ctermbg=NONE", + "Search ctermbg=None ctermfg=166", + "PrimaryBlock ctermfg=06 ctermbg=NONE", + "SecondaryBlock ctermfg=06 ctermbg=NONE", + "Blanks ctermfg=07 ctermbg=NONE", + "ColorColumn ctermbg=cyan", +} +for i, highlight in ipairs(highlights) do + cmd('au VimEnter * hi ' .. highlight) +end + +-- Along with the highlight definition for ColorColumn above, these options +-- will set colored marks at certain line lengths +cmd([[au BufEnter *.py let w:m1=matchadd('ColorColumn', '\%81v', 100)]]) +cmd([[au BufEnter *.py let w:m2=matchadd('Error', '\%121v', 100)]]) +cmd([[au BufLeave *.py call clearmatches()"]]) + + + +options = { noremap = true } + +map('n', 'y', ':let @+=@0', options) +map('n', '', ':noh', options) +map('i', 'jj', '', options) +map('n', 'gp', "`[v`]", options) + + + +-- Status Line +local mode_map = { + ['n'] = 'normal', + ['no'] = 'n·operator pending', + ['v'] = 'visual', + ['V'] = 'v·line', + [''] = 'v·block', + ['s'] = 'select', + ['S'] = 's·line', + [''] = 's·block', + ['i'] = 'insert', + ['R'] = 'replace', + ['Rv'] = 'v·replace', + ['c'] = 'command', + ['cv'] = 'vim ex', + ['ce'] = 'ex', + ['r'] = 'prompt', + ['rm'] = 'more', + ['r?'] = 'confirm', + ['!'] = 'shell', + ['t'] = 'terminal' +} + +local function mode() + local m = vim.api.nvim_get_mode().mode + if mode_map[m] == nil then return m end + return '[' .. mode_map[m] .. '] ' +end + +local stl = { + '%#PrimaryBlock#', + mode(), + '%#SecondaryBlock#', + '%#Blanks#', + '%f', + '%m', + '%=', + '%#SecondaryBlock#', + '%l,%c ', + '%#PrimaryBlock#', + '%{&filetype}', +} + +o.statusline = table.concat(stl) -- cgit v1.2.3