From fe025d76de2649df4b960babe368e0ad3c20e011 Mon Sep 17 00:00:00 2001 From: Sonny Bakker Date: Tue, 26 Apr 2022 20:59:50 +0200 Subject: [PATCH] Use ftplugin for indent configuration --- nvim/ftplugin/bash.lua | 5 ++++ nvim/ftplugin/css.lua | 5 ++++ nvim/ftplugin/html.lua | 5 ++++ nvim/ftplugin/htmldjango.lua | 5 ++++ nvim/ftplugin/javascript.lua | 5 ++++ nvim/ftplugin/json.lua | 5 ++++ nvim/ftplugin/lua.lua | 5 ++++ nvim/ftplugin/python.lua | 5 ++++ nvim/ftplugin/scss.lua | 5 ++++ nvim/ftplugin/sh.lua | 5 ++++ nvim/ftplugin/yaml.lua | 5 ++++ nvim/lua/auto-commands.lua | 45 +++++++++++++++++++++--------------- 12 files changed, 81 insertions(+), 19 deletions(-) create mode 100644 nvim/ftplugin/bash.lua create mode 100644 nvim/ftplugin/css.lua create mode 100644 nvim/ftplugin/html.lua create mode 100644 nvim/ftplugin/htmldjango.lua create mode 100644 nvim/ftplugin/javascript.lua create mode 100644 nvim/ftplugin/json.lua create mode 100644 nvim/ftplugin/lua.lua create mode 100644 nvim/ftplugin/python.lua create mode 100644 nvim/ftplugin/scss.lua create mode 100644 nvim/ftplugin/sh.lua create mode 100644 nvim/ftplugin/yaml.lua diff --git a/nvim/ftplugin/bash.lua b/nvim/ftplugin/bash.lua new file mode 100644 index 0000000..332f079 --- /dev/null +++ b/nvim/ftplugin/bash.lua @@ -0,0 +1,5 @@ +vim.b.tabstop = 4 +vim.b.softtabstop = 4 +vim.b.shiftwidth = 4 +vim.b.expandtab = true +vim.b.autoindent = true diff --git a/nvim/ftplugin/css.lua b/nvim/ftplugin/css.lua new file mode 100644 index 0000000..ed1fb11 --- /dev/null +++ b/nvim/ftplugin/css.lua @@ -0,0 +1,5 @@ +vim.b.tabstop = 2 +vim.b.softtabstop = 2 +vim.b.shiftwidth = 2 +vim.b.expandtab = true +vim.b.autoindent = true diff --git a/nvim/ftplugin/html.lua b/nvim/ftplugin/html.lua new file mode 100644 index 0000000..ed1fb11 --- /dev/null +++ b/nvim/ftplugin/html.lua @@ -0,0 +1,5 @@ +vim.b.tabstop = 2 +vim.b.softtabstop = 2 +vim.b.shiftwidth = 2 +vim.b.expandtab = true +vim.b.autoindent = true diff --git a/nvim/ftplugin/htmldjango.lua b/nvim/ftplugin/htmldjango.lua new file mode 100644 index 0000000..ed1fb11 --- /dev/null +++ b/nvim/ftplugin/htmldjango.lua @@ -0,0 +1,5 @@ +vim.b.tabstop = 2 +vim.b.softtabstop = 2 +vim.b.shiftwidth = 2 +vim.b.expandtab = true +vim.b.autoindent = true diff --git a/nvim/ftplugin/javascript.lua b/nvim/ftplugin/javascript.lua new file mode 100644 index 0000000..ed1fb11 --- /dev/null +++ b/nvim/ftplugin/javascript.lua @@ -0,0 +1,5 @@ +vim.b.tabstop = 2 +vim.b.softtabstop = 2 +vim.b.shiftwidth = 2 +vim.b.expandtab = true +vim.b.autoindent = true diff --git a/nvim/ftplugin/json.lua b/nvim/ftplugin/json.lua new file mode 100644 index 0000000..332f079 --- /dev/null +++ b/nvim/ftplugin/json.lua @@ -0,0 +1,5 @@ +vim.b.tabstop = 4 +vim.b.softtabstop = 4 +vim.b.shiftwidth = 4 +vim.b.expandtab = true +vim.b.autoindent = true diff --git a/nvim/ftplugin/lua.lua b/nvim/ftplugin/lua.lua new file mode 100644 index 0000000..ed1fb11 --- /dev/null +++ b/nvim/ftplugin/lua.lua @@ -0,0 +1,5 @@ +vim.b.tabstop = 2 +vim.b.softtabstop = 2 +vim.b.shiftwidth = 2 +vim.b.expandtab = true +vim.b.autoindent = true diff --git a/nvim/ftplugin/python.lua b/nvim/ftplugin/python.lua new file mode 100644 index 0000000..332f079 --- /dev/null +++ b/nvim/ftplugin/python.lua @@ -0,0 +1,5 @@ +vim.b.tabstop = 4 +vim.b.softtabstop = 4 +vim.b.shiftwidth = 4 +vim.b.expandtab = true +vim.b.autoindent = true diff --git a/nvim/ftplugin/scss.lua b/nvim/ftplugin/scss.lua new file mode 100644 index 0000000..ed1fb11 --- /dev/null +++ b/nvim/ftplugin/scss.lua @@ -0,0 +1,5 @@ +vim.b.tabstop = 2 +vim.b.softtabstop = 2 +vim.b.shiftwidth = 2 +vim.b.expandtab = true +vim.b.autoindent = true diff --git a/nvim/ftplugin/sh.lua b/nvim/ftplugin/sh.lua new file mode 100644 index 0000000..332f079 --- /dev/null +++ b/nvim/ftplugin/sh.lua @@ -0,0 +1,5 @@ +vim.b.tabstop = 4 +vim.b.softtabstop = 4 +vim.b.shiftwidth = 4 +vim.b.expandtab = true +vim.b.autoindent = true diff --git a/nvim/ftplugin/yaml.lua b/nvim/ftplugin/yaml.lua new file mode 100644 index 0000000..ed1fb11 --- /dev/null +++ b/nvim/ftplugin/yaml.lua @@ -0,0 +1,5 @@ +vim.b.tabstop = 2 +vim.b.softtabstop = 2 +vim.b.shiftwidth = 2 +vim.b.expandtab = true +vim.b.autoindent = true diff --git a/nvim/lua/auto-commands.lua b/nvim/lua/auto-commands.lua index 0daf807..90c9b84 100644 --- a/nvim/lua/auto-commands.lua +++ b/nvim/lua/auto-commands.lua @@ -1,27 +1,34 @@ --colorscheme vim.cmd('colorscheme space_vim_theme') + +--enable this option here as the events are used in this buffer vim.cmd('syntax on') ---open folds by default -vim.cmd('autocmd Syntax * normal zR') - ---file specific formatting -vim.cmd([[ - autocmd Filetype python,bash,sh,java,php,json - \ setlocal tabstop=4 softtabstop=4 shiftwidth=4 - \ expandtab autoindent fileformat=unix -]]) - -vim.cmd([[ - autocmd Filetype css,scss,html,htmldjango,javascript,yaml - \ setlocal tabstop=2 softtabstop=2 shiftwidth=2 - \ expandtab autoindent -]]) +vim.api.nvim_create_autocmd('Syntax', { + command = [[:normal zR]], + desc = 'Open folds by default', +}) --color trailing spaces with red color vim.cmd('highlight ExtraWhitespace ctermbg=green guibg=green') vim.cmd('match ExtraWhitespace /s+$/') -vim.cmd('autocmd BufWinEnter * match ExtraWhitespace /s+$/') -vim.cmd('autocmd InsertEnter * match ExtraWhitespace /s+%#@