nvim: set color columns and moved filetypes into autocmd

master
tiyn 1 year ago
parent 7d0168ff4e
commit 933819855f

@ -56,14 +56,11 @@ vim.g.python_host_prog = '/usr/bin/python2'
vim.g.python3_host_prog = '/usr/bin/python3'
-- set filetypes correctly by extension
require('filetype')
require('autocmd')
-- load plugins (autoload all files in plugin folder)
require('loadplugins')
-- load filetype specific mappings and commands
require('autocmd')
-- load general mapped keys
require('keymap')

@ -1,4 +1,17 @@
-- autocmd
-- read files correctly
vim.filetype.add({
extension = {
c = 'c',
h = 'c',
html = 'html',
java = 'java',
js = 'javascript',
lua = 'lua',
md = 'markdown',
nim = 'nim',
py = 'python',
tex = 'tex',
}})
-- delete trailing whitespaces on save
vim.api.nvim_create_autocmd({'BufWritePre'},
@ -6,67 +19,88 @@ vim.api.nvim_create_autocmd({'BufWritePre'},
command = [[%s/\s\+$//e]],
})
-- formatting options
vim.api.nvim_create_autocmd({'FileType'},
{pattern = {'markdown'},
command = 'setlocal shiftwidth=2 softtabstop=2',
-- c
vim.api.nvim_create_autocmd({'VimLeave'},
{pattern = {'c'},
command = '!cclear'
})
vim.api.nvim_create_autocmd({'BufEnter', 'FileType'},
{pattern = {'c'},
command = 'set colorcolumn=80'
})
-- java
vim.api.nvim_create_autocmd({'FileType'},
{pattern = {'java'},
command = 'setlocal shiftwidth=2 softtabstop=2',
})
vim.api.nvim_create_autocmd({'BufEnter', 'FileType'},
{pattern = {'java'},
command = 'set colorcolumn=100'
})
-- javascript
vim.api.nvim_create_autocmd({'FileType'},
{pattern = {'javascript'},
command = 'setlocal shiftwidth=2 softtabstop=2',
})
-- cleanup certain files after leaving the editor
vim.api.nvim_create_autocmd({'VimLeave'},
{pattern = {'c'},
command = '!cclear'
})
-- lua
vim.api.nvim_create_autocmd({'VimLeave'},
{pattern = {'tex'},
command = '!texclear %'
vim.api.nvim_create_autocmd({'FileType'},
{pattern = {'lua'},
command = 'setlocal shiftwidth=2 softtabstop=2',
})
-- highlighting break line
vim.api.nvim_create_autocmd({'BufEnter', 'FileType'},
{pattern = {'c'},
command = 'set colorcolumn=80'
{pattern = {'lua'},
command = 'set colorcolumn=100'
})
-- markdown
vim.api.nvim_create_autocmd({'FileType'},
{pattern = {'markdown'},
command = 'setlocal shiftwidth=2 softtabstop=2',
})
vim.api.nvim_create_autocmd({'BufEnter', 'FileType'},
{pattern = {'java'},
{pattern = {'markdown'},
command = 'set colorcolumn=100'
})
vim.api.nvim_create_autocmd({'BufEnter', 'FileType'},
{pattern = {'markdown'},
command = 'set colorcolumn=80'
command = 'set conceallevel=2'
})
-- nim
vim.api.nvim_create_autocmd({'BufEnter', 'FileType'},
{pattern = {'nim'},
command = 'set colorcolumn=80'
})
-- python
vim.api.nvim_create_autocmd({'BufEnter', 'FileType'},
{pattern = {'python'},
command = 'set colorcolumn=80'
})
vim.api.nvim_create_autocmd({'BufEnter', 'FileType'},
-- tex
vim.api.nvim_create_autocmd({'VimLeave'},
{pattern = {'tex'},
command = 'set colorcolumn=80'
command = '!texclear %'
})
-- conceallevel
vim.api.nvim_create_autocmd({'BufEnter', 'FileType'},
{pattern = {'markdown'},
command = 'set conceallevel=2'
{pattern = {'tex'},
command = 'set colorcolumn=80'
})

@ -1,12 +0,0 @@
-- read files correctly
vim.filetype.add({
extension = {
h = 'c',
html = 'html',
java = 'java',
js = 'javascript',
md = 'markdown',
nim = 'nim',
py = 'python',
tex = 'tex',
}})
Loading…
Cancel
Save