Use ftplugin for indent configuration

This commit is contained in:
Sonny Bakker 2022-04-26 20:59:50 +02:00
parent e3cece6400
commit fe025d76de
12 changed files with 81 additions and 19 deletions

5
nvim/ftplugin/bash.lua Normal file
View file

@ -0,0 +1,5 @@
vim.b.tabstop = 4
vim.b.softtabstop = 4
vim.b.shiftwidth = 4
vim.b.expandtab = true
vim.b.autoindent = true

5
nvim/ftplugin/css.lua Normal file
View file

@ -0,0 +1,5 @@
vim.b.tabstop = 2
vim.b.softtabstop = 2
vim.b.shiftwidth = 2
vim.b.expandtab = true
vim.b.autoindent = true

5
nvim/ftplugin/html.lua Normal file
View file

@ -0,0 +1,5 @@
vim.b.tabstop = 2
vim.b.softtabstop = 2
vim.b.shiftwidth = 2
vim.b.expandtab = true
vim.b.autoindent = true

View file

@ -0,0 +1,5 @@
vim.b.tabstop = 2
vim.b.softtabstop = 2
vim.b.shiftwidth = 2
vim.b.expandtab = true
vim.b.autoindent = true

View file

@ -0,0 +1,5 @@
vim.b.tabstop = 2
vim.b.softtabstop = 2
vim.b.shiftwidth = 2
vim.b.expandtab = true
vim.b.autoindent = true

5
nvim/ftplugin/json.lua Normal file
View file

@ -0,0 +1,5 @@
vim.b.tabstop = 4
vim.b.softtabstop = 4
vim.b.shiftwidth = 4
vim.b.expandtab = true
vim.b.autoindent = true

5
nvim/ftplugin/lua.lua Normal file
View file

@ -0,0 +1,5 @@
vim.b.tabstop = 2
vim.b.softtabstop = 2
vim.b.shiftwidth = 2
vim.b.expandtab = true
vim.b.autoindent = true

5
nvim/ftplugin/python.lua Normal file
View file

@ -0,0 +1,5 @@
vim.b.tabstop = 4
vim.b.softtabstop = 4
vim.b.shiftwidth = 4
vim.b.expandtab = true
vim.b.autoindent = true

5
nvim/ftplugin/scss.lua Normal file
View file

@ -0,0 +1,5 @@
vim.b.tabstop = 2
vim.b.softtabstop = 2
vim.b.shiftwidth = 2
vim.b.expandtab = true
vim.b.autoindent = true

5
nvim/ftplugin/sh.lua Normal file
View file

@ -0,0 +1,5 @@
vim.b.tabstop = 4
vim.b.softtabstop = 4
vim.b.shiftwidth = 4
vim.b.expandtab = true
vim.b.autoindent = true

5
nvim/ftplugin/yaml.lua Normal file
View file

@ -0,0 +1,5 @@
vim.b.tabstop = 2
vim.b.softtabstop = 2
vim.b.shiftwidth = 2
vim.b.expandtab = true
vim.b.autoindent = true

View file

@ -1,27 +1,34 @@
--colorscheme --colorscheme
vim.cmd('colorscheme space_vim_theme') vim.cmd('colorscheme space_vim_theme')
--enable this option here as the events are used in this buffer
vim.cmd('syntax on') vim.cmd('syntax on')
--open folds by default vim.api.nvim_create_autocmd('Syntax', {
vim.cmd('autocmd Syntax * normal zR') command = [[:normal zR]],
desc = 'Open folds by default',
--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
]])
--color trailing spaces with red color --color trailing spaces with red color
vim.cmd('highlight ExtraWhitespace ctermbg=green guibg=green') vim.cmd('highlight ExtraWhitespace ctermbg=green guibg=green')
vim.cmd('match ExtraWhitespace /s+$/') vim.cmd('match ExtraWhitespace /s+$/')
vim.cmd('autocmd BufWinEnter * match ExtraWhitespace /s+$/')
vim.cmd('autocmd InsertEnter * match ExtraWhitespace /s+%#@<!$/') vim.api.nvim_create_autocmd('BufWinEnter', {
vim.cmd('autocmd InsertLeave * match ExtraWhitespace /s+$/') pattern = "*",
vim.cmd('autocmd BufWinLeave * call clearmatches()') command = [[:match ExtraWhitespace /s+$/]],
})
vim.api.nvim_create_autocmd('InsertEnter', {
pattern = "*",
command = [[:match ExtraWhitespace /s+%#@<!$/]],
})
vim.api.nvim_create_autocmd('InsertLeave', {
pattern = "*",
command = [[:match ExtraWhitespace /s+$/]],
})
vim.api.nvim_create_autocmd('BufWinLeave', {
pattern = "*",
command = [[:call clearmatches()]],
})