From 97faf55d75674c5a51777d2b433e601e07845bb7 Mon Sep 17 00:00:00 2001 From: Alex Karle Date: Sun, 27 Feb 2022 11:32:54 -0500 Subject: [PATCH] nvim: Add space/tab/wrap settings for common filetypes Unlike my previoius vim config, which was 4-spaces by default, I'm piloting "TAB as TAB" by default, unless I'm in one of the filetypes I usually work in (all of which use spaces). With this, I like using linebreak and showing space via listchars (super helpful with python!) --- .config/nvim/init.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index ce1d5ca..59ad020 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -4,6 +4,18 @@ vim.cmd [[colorscheme acme]] -- Persistent undo files in ~/.local/share/nvim/undo vim.opt.undofile = true +-- Characters to show non-visible whitespace via `:set list` +vim.opt.listchars = "tab:>-,trail:~,eol:$,space:." + +-- In general, softwrap at word boundaries +vim.opt.linebreak = true + +-- Space and Tab settings for various filetypes +vim.cmd [[autocmd FileType markdown setlocal et sw=4 sts=4 tw=80 ]] +vim.cmd [[autocmd FileType python setlocal et sw=4 sts=4]] +vim.cmd [[autocmd FileType javascript setlocal et sw=2 sts=2]] +vim.cmd [[autocmd FileType typescriptreact setlocal et sw=2 sts=2]] + -- Switch between windows with Ctrl-h/j/k/l vim.api.nvim_set_keymap("n", "", "h", { noremap = true }) vim.api.nvim_set_keymap("n", "", "j", { noremap = true }) -- libgit2 1.1.1