diff options
author | Cody Hiar <cody@hiar.ca> | 2021-09-03 22:22:12 -0600 |
---|---|---|
committer | Cody Hiar <cody@hiar.ca> | 2021-09-03 22:22:12 -0600 |
commit | 6c1793d98f244f0b6fc1b9eb163647dc9032f358 (patch) | |
tree | 7cbd2adaf8da86d17b8251938bf71a2fdf224f7f /lua/settings.lua | |
parent | 227899a5a0edf9e449d0697eb5e387dd5ea942ed (diff) |
More work on lua config
Diffstat (limited to 'lua/settings.lua')
-rw-r--r-- | lua/settings.lua | 110 |
1 files changed, 110 insertions, 0 deletions
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', '<Space>', '', {}) +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', '<leader>y', ':let @+=@0<cr>', options) +map('n', '<leader><leader>', ':noh<cr>', options) +map('i', 'jj', '<esc>', 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) |