From bef5e0195170959aae23b2ac5465d2f1b1465ea1 Mon Sep 17 00:00:00 2001 From: Fernando Schauenburg Date: Tue, 1 Feb 2022 20:53:19 +0100 Subject: [PATCH] vim: convert lua files to tabstop = 2 --- nvim/.config/nvim/after/plugin/lualine.lua | 167 ++++++---------- nvim/.config/nvim/lua/fs/autocmds.lua | 64 +++---- nvim/.config/nvim/lua/fs/keymaps.lua | 118 ++++++------ nvim/.config/nvim/lua/fs/options.lua | 212 ++++++++++----------- 4 files changed, 257 insertions(+), 304 deletions(-) diff --git a/nvim/.config/nvim/after/plugin/lualine.lua b/nvim/.config/nvim/after/plugin/lualine.lua index 11baca3..476c047 100644 --- a/nvim/.config/nvim/after/plugin/lualine.lua +++ b/nvim/.config/nvim/after/plugin/lualine.lua @@ -1,133 +1,86 @@ local colors = {} if vim.opt.termguicolors:get() then - colors = { - base03 = '#002b36', yellow = '#b58900', - base02 = '#073642', orange = '#cb4b16', - base01 = '#586e75', red = '#dc322f', - base00 = '#657b83', magenta = '#d33682', - base0 = '#839496', violet = '#6c71c4', - base1 = '#93a1a1', blue = '#268bd2', - base2 = '#eee8d5', cyan = '#2aa198', - base3 = '#fdf6e3', green = '#859900', - } + colors = { + base03 = '#002b36', yellow = '#b58900', + base02 = '#073642', orange = '#cb4b16', + base01 = '#586e75', red = '#dc322f', + base00 = '#657b83', magenta = '#d33682', + base0 = '#839496', violet = '#6c71c4', + base1 = '#93a1a1', blue = '#268bd2', + base2 = '#eee8d5', cyan = '#2aa198', + base3 = '#fdf6e3', green = '#859900', + } else - colors = { - base03 = 8, yellow = 3, - base02 = 0, orange = 9, - base01 = 10, red = 1, - base00 = 11, magenta = 5, - base0 = 12, violet = 13, - base1 = 14, blue = 4, - base2 = 7, cyan = 6, - base3 = 15, green = 2, - } + colors = { + base03 = 8, yellow = 3, + base02 = 0, orange = 9, + base01 = 10, red = 1, + base00 = 11, magenta = 5, + base0 = 12, violet = 13, + base1 = 14, blue = 4, + base2 = 7, cyan = 6, + base3 = 15, green = 2, + } end local progress = { '%3p%%×%L %3l:%-2v', padding = { left = 0, right = 1 } } local relative_path = { 'filename', path = 1 } local encoding = function () - local fenc = vim.opt.fileencoding:get() - if fenc ~= '' then - return fenc - end - return vim.opt.encoding:get() + local fenc = vim.opt.fileencoding:get() + if fenc ~= '' then + return fenc + end + return vim.opt.encoding:get() end local fileformat = { 'fileformat', padding = { left = 0, right = 1} } require('lualine').setup { options = { - icons_enabled = true, - component_separators = { left = '', right = '' }, - section_separators = { left = '', right = '' }, - theme = { - normal = { - a = { fg = colors.base03, bg = colors.blue, gui='bold' }, - b = { fg = colors.base2, bg = colors.base00 }, - c = { fg = colors.base1, bg = colors.base02 }, - }, - insert = { a = { fg = colors.base03, bg = colors.green, gui = 'bold' } }, - visual = { a = { fg = colors.base03, bg = colors.magenta, gui = 'bold' } }, - replace = { a = { fg = colors.base03, bg = colors.red, gui = 'bold' } }, - inactive = { - a = { fg = colors.base1, bg = colors.base00 }, - b = { fg = colors.base0, bg = colors.base01 }, - c = { fg = colors.base00, bg = colors.base02 }, - }, + icons_enabled = true, + component_separators = { left = '', right = '' }, + section_separators = { left = '', right = '' }, + theme = { + normal = { + a = { fg = colors.base03, bg = colors.blue, gui='bold' }, + b = { fg = colors.base2, bg = colors.base00 }, + c = { fg = colors.base1, bg = colors.base02 }, }, + insert = { a = { fg = colors.base03, bg = colors.green, gui = 'bold' } }, + visual = { a = { fg = colors.base03, bg = colors.magenta, gui = 'bold' } }, + replace = { a = { fg = colors.base03, bg = colors.red, gui = 'bold' } }, + inactive = { + a = { fg = colors.base1, bg = colors.base00 }, + b = { fg = colors.base0, bg = colors.base01 }, + c = { fg = colors.base00, bg = colors.base02 }, + }, + }, }, sections = { - lualine_a = { - 'mode', - { - function() return 'PASTE' end, - color = { bg = colors.yellow }, - cond = function() return vim.opt.paste:get() end - }, + lualine_a = { + 'mode', + { + function() return 'PASTE' end, + color = { bg = colors.yellow }, + cond = function() return vim.opt.paste:get() end }, - lualine_b = { 'diagnostics', 'branch' }, - lualine_c = { relative_path }, - lualine_x = { 'filetype' }, - lualine_y = { encoding, fileformat }, - lualine_z = { progress }, + }, + lualine_b = { 'diagnostics', 'branch' }, + lualine_c = { relative_path }, + lualine_x = { 'filetype' }, + lualine_y = { encoding, fileformat }, + lualine_z = { progress }, }, inactive_sections = { - lualine_a = {}, - lualine_b = { 'diagnostics', 'branch' }, - lualine_c = { relative_path }, - lualine_x = { 'filetype' }, - lualine_y = { encoding, fileformat }, - lualine_z = { progress }, + lualine_a = {}, + lualine_b = { 'diagnostics', 'branch' }, + lualine_c = { relative_path }, + lualine_x = { 'filetype' }, + lualine_y = { encoding, fileformat }, + lualine_z = { progress }, }, extensions = { 'fugitive', 'quickfix' } } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/nvim/.config/nvim/lua/fs/autocmds.lua b/nvim/.config/nvim/lua/fs/autocmds.lua index ea044dd..23350ff 100644 --- a/nvim/.config/nvim/lua/fs/autocmds.lua +++ b/nvim/.config/nvim/lua/fs/autocmds.lua @@ -1,39 +1,39 @@ local function make_autocmds(groups) - for name, commands in pairs(groups) do - vim.cmd('augroup my_' .. name) - vim.cmd('autocmd!') - for _, item in ipairs(commands) do - vim.cmd('autocmd ' .. table.concat(item, ' ')) - end - vim.cmd('augroup END') + for name, commands in pairs(groups) do + vim.cmd('augroup my_' .. name) + vim.cmd('autocmd!') + for _, item in ipairs(commands) do + vim.cmd('autocmd ' .. table.concat(item, ' ')) end + vim.cmd('augroup END') + end end make_autocmds { - buffers = { - { 'BufNewFile,BufRead', 'bash_profile,bashrc,profile', 'set filetype=sh' }, - { 'BufNewFile,BufRead', 'gitconfig', 'set filetype=gitconfig' }, - { 'BufNewFile,BufRead', '*.sx,*.s19', 'set filetype=srec' }, - { 'BufNewFile,BufRead', 'Vagrantfile', 'set filetype=ruby' }, - -- Make it possible to use `gf` to jump to my configuration modules. - { 'BufNewFile,BufRead', 'init.lua', - "setlocal path+=~/.config/nvim/lua includeexpr=substitute(v:fname,'\\\\.','/','g')"}, - }, - filetypes = { - { 'FileType', 'gitcommit', 'setlocal textwidth=72' }, - { 'FileType', 'gitcommit,markdown,text', 'setlocal formatoptions+=t spell' }, - { 'FileType', 'python', 'setlocal foldmethod=indent foldignore=' }, - { 'FileType', 'vim', 'set foldmethod=marker' }, - }, - windows = { - -- Disable cursorline when entering Insert mode (but remember it)... - { 'InsertEnter', '*', 'let g:stored_cursorline=&cursorline | set nocursorline' }, - -- ...and re-enable when leaving if it had been set before. - { 'InsertLeave', '*', 'let &cursorline=g:stored_cursorline' }, - }, - yank = { - -- Briefly highlight yanked text. - { 'TextYankPost', '*', 'silent! lua vim.highlight.on_yank()' }, - }, + buffers = { + { 'BufNewFile,BufRead', 'bash_profile,bashrc,profile', 'set filetype=sh' }, + { 'BufNewFile,BufRead', 'gitconfig', 'set filetype=gitconfig' }, + { 'BufNewFile,BufRead', '*.sx,*.s19', 'set filetype=srec' }, + { 'BufNewFile,BufRead', 'Vagrantfile', 'set filetype=ruby' }, + -- Make it possible to use `gf` to jump to my configuration modules. + { 'BufNewFile,BufRead', 'init.lua', + "setlocal path+=~/.config/nvim/lua includeexpr=substitute(v:fname,'\\\\.','/','g')"}, + }, + filetypes = { + { 'FileType', 'gitcommit', 'setlocal textwidth=72' }, + { 'FileType', 'gitcommit,markdown,text', 'setlocal formatoptions+=t spell' }, + { 'FileType', 'python', 'setlocal foldmethod=indent foldignore=' }, + { 'FileType', 'vim', 'set foldmethod=marker' }, + }, + windows = { + -- Disable cursorline when entering Insert mode (but remember it)... + { 'InsertEnter', '*', 'let g:stored_cursorline=&cursorline | set nocursorline' }, + -- ...and re-enable when leaving if it had been set before. + { 'InsertLeave', '*', 'let &cursorline=g:stored_cursorline' }, + }, + yank = { + -- Briefly highlight yanked text. + { 'TextYankPost', '*', 'silent! lua vim.highlight.on_yank()' }, + }, } diff --git a/nvim/.config/nvim/lua/fs/keymaps.lua b/nvim/.config/nvim/lua/fs/keymaps.lua index b8692b7..798f793 100644 --- a/nvim/.config/nvim/lua/fs/keymaps.lua +++ b/nvim/.config/nvim/lua/fs/keymaps.lua @@ -1,83 +1,83 @@ local M = function(mode, lhs, rhs, opts) - local merged_opts = vim.tbl_extend('keep', opts or {}, { noremap = true }) - local map = { mode = mode, lhs = lhs, rhs = rhs, opts = merged_opts } - map.remap = function() map.opts.noremap = false; return map end - map.silent = function() map.opts.silent = true; return map end - map.expr = function() map.opts.expr = true; return map end - map.unique = function() map.opts.unique = true; return map end - map.nowait = function() map.opts.nowait = true; return map end - map.script = function() map.opts.script = true; return map end - return map + local merged_opts = vim.tbl_extend('keep', opts or {}, { noremap = true }) + local map = { mode = mode, lhs = lhs, rhs = rhs, opts = merged_opts } + map.remap = function() map.opts.noremap = false; return map end + map.silent = function() map.opts.silent = true; return map end + map.expr = function() map.opts.expr = true; return map end + map.unique = function() map.opts.unique = true; return map end + map.nowait = function() map.opts.nowait = true; return map end + map.script = function() map.opts.script = true; return map end + return map end local register = function(maps) - for _, m in ipairs(maps) do - vim.api.nvim_set_keymap(m.mode, m.lhs, m.rhs, m.opts) - end + for _, m in ipairs(maps) do + vim.api.nvim_set_keymap(m.mode, m.lhs, m.rhs, m.opts) + end end vim.g.mapleader = ' ' register { - -- better navigation for wrapped lines - M('n', 'j', 'gj'), - M('n', 'k', 'gk'), + -- better navigation for wrapped lines + M('n', 'j', 'gj'), + M('n', 'k', 'gk'), - -- retain selection when indenting/unindenting in visual mode - M('v', '>', '>gv'), - M('v', '<', '<gv'), + -- retain selection when indenting/unindenting in visual mode + M('v', '>', '>gv'), + M('v', '<', '<gv'), - -- easier window navigation - M('n', '', 'j'), - M('n', '', 'k'), - M('n', '', 'h'), - M('n', '', 'l'), + -- easier window navigation + M('n', '', 'j'), + M('n', '', 'k'), + M('n', '', 'h'), + M('n', '', 'l'), - -- window resizing - M('n', '', 'resize +1'), - M('n', '', 'resize -1'), - M('n', '', 'vertical resize -1'), - M('n', '', 'vertical resize +1'), + -- window resizing + M('n', '', 'resize +1'), + M('n', '', 'resize -1'), + M('n', '', 'vertical resize -1'), + M('n', '', 'vertical resize +1'), - -- easier tab navigation - M('n', '', ':tabprevious').silent(), - M('n', '', ':tabnext' ).silent(), + -- easier tab navigation + M('n', '', ':tabprevious').silent(), + M('n', '', ':tabnext' ).silent(), - -- move lines up and down - M('n', '', [[:move .+1==]] ).silent(), - M('n', '', [[:move .-2==]] ).silent(), - M('v', '', [[:move '>+1gv=gv]] ).silent(), - M('v', '', [[:move '<-2gv=gv]] ).silent(), - M('i', '', [[:move .+1==gi]] ).silent(), - M('i', '', [[:move .-2==gi]] ).silent(), + -- move lines up and down + M('n', '', [[:move .+1==]] ).silent(), + M('n', '', [[:move .-2==]] ).silent(), + M('v', '', [[:move '>+1gv=gv]] ).silent(), + M('v', '', [[:move '<-2gv=gv]] ).silent(), + M('i', '', [[:move .+1==gi]] ).silent(), + M('i', '', [[:move .-2==gi]] ).silent(), - -- cycle through line numbering modes - M('n', 'ln', ':set nonumber norelativenumber' ).silent(), - M('n', 'll', ':set number norelativenumber' ).silent(), - M('n', 'lr', ':set number relativenumber' ).silent(), + -- cycle through line numbering modes + M('n', 'ln', ':set nonumber norelativenumber' ).silent(), + M('n', 'll', ':set number norelativenumber' ).silent(), + M('n', 'lr', ':set number relativenumber' ).silent(), - -- show list of buffers and prepare to switch - M('n', 'bf', ':ls:b'), + -- show list of buffers and prepare to switch + M('n', 'bf', ':ls:b'), - -- quickly change background - M('n', 'bg', [[:let &background = &background ==? 'light' ? 'dark' : 'light']]), + -- quickly change background + M('n', 'bg', [[:let &background = &background ==? 'light' ? 'dark' : 'light']]), - -- use fugitive - M('n', 'gg', ':G'), - M('n', 'g', ':G '), + -- use fugitive + M('n', 'gg', ':G'), + M('n', 'g', ':G '), - -- disable highlight until next search - M('n', 'h', ':nohlsearch'), + -- disable highlight until next search + M('n', 'h', ':nohlsearch'), - -- toggle NERDTree - M('n', 'n', ':NERDTreeToggle'), + -- toggle NERDTree + M('n', 'n', ':NERDTreeToggle'), - -- toggle rainbow parens - M('n', 'p', ':RainbowParentheses!!'), + -- toggle rainbow parens + M('n', 'p', ':RainbowParentheses!!'), - -- edit init.lua - M('n', 'v', ':e $MYVIMRC'), + -- edit init.lua + M('n', 'v', ':e $MYVIMRC'), - -- fix whitespace - M('n', 'w', ':FixWhitespace'), + -- fix whitespace + M('n', 'w', ':FixWhitespace'), } diff --git a/nvim/.config/nvim/lua/fs/options.lua b/nvim/.config/nvim/lua/fs/options.lua index 55d089a..2a17c56 100644 --- a/nvim/.config/nvim/lua/fs/options.lua +++ b/nvim/.config/nvim/lua/fs/options.lua @@ -2,123 +2,123 @@ vim.cmd([[let &t_8f = "\[38:2:%lu:%lu:%lum"]]) vim.cmd([[let &t_8b = "\[48:2:%lu:%lu:%lum"]]) local set_options = function(options) - local opt = vim.opt - for k, v in pairs(options) do - opt[k] = v - end + local opt = vim.opt + for k, v in pairs(options) do + opt[k] = v + end end set_options { - -- General - belloff = 'all', -- never ring bells - hidden = true, -- hide abandoned buffers - clipboard = 'unnamedplus', -- synchronize with system clipboard - lazyredraw = true, -- don't redraw screen during macros - modelines = 0, -- never use modelines - fileformats = 'unix,mac,dos', -- prioritize unix format - pastetoggle = '', -- toggle paste with P on Moonlander + -- General + belloff = 'all', -- never ring bells + hidden = true, -- hide abandoned buffers + clipboard = 'unnamedplus', -- synchronize with system clipboard + lazyredraw = true, -- don't redraw screen during macros + modelines = 0, -- never use modelines + fileformats = 'unix,mac,dos', -- prioritize unix format + pastetoggle = '', -- toggle paste with P on Moonlander - swapfile = false, -- don't use swap files - writebackup = true, -- Make a backup before writing a file... - backup = false, -- ...but don't keep it around. + swapfile = false, -- don't use swap files + writebackup = true, -- Make a backup before writing a file... + backup = false, -- ...but don't keep it around. - shortmess = vim.opt.shortmess + 'I', -- no intro message when starting Vim - shada = { - "'1000", -- remember marks for this many files - "/1000", -- remember this many search patterns - ":1000", -- remember this many command line items - "<100", -- maximum number of lines to remember per register - "h", -- disable 'hlsearch' while reading shada file - "s100", -- limit size of remembered items to this many KiB - }, + shortmess = vim.opt.shortmess + 'I', -- no intro message when starting Vim + shada = { + "'1000", -- remember marks for this many files + "/1000", -- remember this many search patterns + ":1000", -- remember this many command line items + "<100", -- maximum number of lines to remember per register + "h", -- disable 'hlsearch' while reading shada file + "s100", -- limit size of remembered items to this many KiB + }, - -- Searching - ignorecase = true, -- Ignore case when searching... - smartcase = true, -- ...unless pattern contains uppercase characters. + -- Searching + ignorecase = true, -- Ignore case when searching... + smartcase = true, -- ...unless pattern contains uppercase characters. - -- Editing - expandtab = true, -- use spaces whe is inserted - tabstop = 4, -- tabs are 4 spaces - shiftwidth = 0, -- (auto)indent using 'tabstop' spaces - smartindent = true, -- use smart autoindenting - inccommand = 'split', -- preview command partial results - joinspaces = false, -- use one space after a period whe joining lines - showmatch = true, -- briefly jump to matching bracket if insert one - virtualedit = 'block', -- position the cursor anywhere in Visual Block mode - formatlistpat = [[^\s*\(\d\+[\]:.)}\t ]\|[-+*]\|[\[(][ x][\])]\)\s*]], - formatoptions = vim.opt.formatoptions - - 't' -- Don't auto-wrap on 'textwidth'... - + 'c' -- ...but do it within comment blocks... - + 'l' -- ...but not if line was already long before entering Insert mode. - + 'r' -- Insert comment leader when pressing Enter... - - 'o' -- ...but not when opening a new line with o & O. - + 'q' -- allow formatting of comments with gq - - 'a' -- don't auto-format every time text is inserted - + 'n' -- indent lists automatically acc. 'formatlistpat' - + 'j' -- remove comment leader when joining lines - + '1', -- don't break lines after a one letter word but rather before it + -- Editing + expandtab = true, -- use spaces whe is inserted + tabstop = 4, -- tabs are 4 spaces + shiftwidth = 0, -- (auto)indent using 'tabstop' spaces + smartindent = true, -- use smart autoindenting + inccommand = 'split', -- preview command partial results + joinspaces = false, -- use one space after a period whe joining lines + showmatch = true, -- briefly jump to matching bracket if insert one + virtualedit = 'block', -- position the cursor anywhere in Visual Block mode + formatlistpat = [[^\s*\(\d\+[\]:.)}\t ]\|[-+*]\|[\[(][ x][\])]\)\s*]], + formatoptions = vim.opt.formatoptions + - 't' -- Don't auto-wrap on 'textwidth'... + + 'c' -- ...but do it within comment blocks... + + 'l' -- ...but not if line was already long before entering Insert mode. + + 'r' -- Insert comment leader when pressing Enter... + - 'o' -- ...but not when opening a new line with o & O. + + 'q' -- allow formatting of comments with gq + - 'a' -- don't auto-format every time text is inserted + + 'n' -- indent lists automatically acc. 'formatlistpat' + + 'j' -- remove comment leader when joining lines + + '1', -- don't break lines after a one letter word but rather before it - -- Appearance - showmode = false, -- don't show mode (shown in statusline instead) - relativenumber = true, -- Start off with realtive line numbers... - number = true, -- ...but real number for current line. - wrap = false, -- don't wrap long lines initially - textwidth = 79, -- maximum width for text being inserted - colorcolumn = '+1', -- highlight column after 'textwidth' - cursorline = true, -- highlight the line of the cursor - showbreak = '⤷ ', -- prefix for wrapped lines - scrolloff = 3, -- min. # of lines above and below cursor - sidescrolloff = 3, -- min. # of columns to left and right of cursor - list = true, -- show invisible characters - listchars = { - tab = '» ', - extends = '…', - precedes = '…', - trail = '·', - conceal = '┊', - }, + -- Appearance + showmode = false, -- don't show mode (shown in statusline instead) + relativenumber = true, -- Start off with realtive line numbers... + number = true, -- ...but real number for current line. + wrap = false, -- don't wrap long lines initially + textwidth = 79, -- maximum width for text being inserted + colorcolumn = '+1', -- highlight column after 'textwidth' + cursorline = true, -- highlight the line of the cursor + showbreak = '⤷ ', -- prefix for wrapped lines + scrolloff = 3, -- min. # of lines above and below cursor + sidescrolloff = 3, -- min. # of columns to left and right of cursor + list = true, -- show invisible characters + listchars = { + tab = '» ', + extends = '…', + precedes = '…', + trail = '·', + conceal = '┊', + }, - -- Wildcard Expansion - wildignore = { - '.git', - '.svn', - '__pycache__', - '**/tmp/**', - '*.DS_Store', - '*.dll', - '*.egg-info', - '*.exe', - '*.gif', - '*.jpeg', - '*.jpg', - '*.o', - '*.obj', - '*.out', - '*.png', - '*.pyc', - '*.so', - '*.zip', - '*~', - }, - wildignorecase = true, -- ignore case when completing file names - wildmode = 'longest:full', -- longest common prefix first, then wildmenu + -- Wildcard Expansion + wildignore = { + '.git', + '.svn', + '__pycache__', + '**/tmp/**', + '*.DS_Store', + '*.dll', + '*.egg-info', + '*.exe', + '*.gif', + '*.jpeg', + '*.jpg', + '*.o', + '*.obj', + '*.out', + '*.png', + '*.pyc', + '*.so', + '*.zip', + '*~', + }, + wildignorecase = true, -- ignore case when completing file names + wildmode = 'longest:full', -- longest common prefix first, then wildmenu - -- Window Splitting - splitbelow = true, -- :split below current window - splitright = true, -- :vsplit to the right of current window - equalalways = false, -- don't resize all windows when splitting + -- Window Splitting + splitbelow = true, -- :split below current window + splitright = true, -- :vsplit to the right of current window + equalalways = false, -- don't resize all windows when splitting - -- Folding - foldenable = true, -- enable folding - foldlevelstart = 100, -- start with all folds open - foldmethod = 'syntax', -- fold based on syntax by default - foldnestmax = 10, -- limit nested folds to 10 levels + -- Folding + foldenable = true, -- enable folding + foldlevelstart = 100, -- start with all folds open + foldmethod = 'syntax', -- fold based on syntax by default + foldnestmax = 10, -- limit nested folds to 10 levels - -- Options for diff mode - diffopt = { -- better side-by-side diffs - 'filler', -- show filler lines (so text ins vertically synced) - 'vertical', -- use vertical splits (files side-by-side) - 'closeoff', -- disable diff mode when one window is closed - }, + -- Options for diff mode + diffopt = { -- better side-by-side diffs + 'filler', -- show filler lines (so text ins vertically synced) + 'vertical', -- use vertical splits (files side-by-side) + 'closeoff', -- disable diff mode when one window is closed + }, }