diff --git a/.config/nvim/lua/filetype.lua b/.config/nvim/lua/filetype.lua index 2709f94..19110fe 100644 --- a/.config/nvim/lua/filetype.lua +++ b/.config/nvim/lua/filetype.lua @@ -2,13 +2,14 @@ -- read files correctly vim.filetype.add({ -pattern = { - ['.*.lua'] = 'lua', - ['.*.h'] = 'c', - ['.*.html'] = 'html', - ['.*.nim'] = 'nim', - ['.*.py'] = 'python', - ['.*.tex'] = 'tex', +extension = { + h = 'c', + html = 'html', + java = 'java', + md = 'markdown', + nim = 'nim', + py = 'python', + tex = 'tex', }}) -- formatting options @@ -27,67 +28,6 @@ vim.api.nvim_create_autocmd({'FileType'}, command = 'setlocal shiftwidth=2 softtabstop=2', }) --- formatting programs -vim.api.nvim_create_autocmd({'FileType'}, -{pattern = {'c'}, -command = 'setlocal formatprg=astyle --mode=c --style=ansi', -}) - -vim.api.nvim_create_autocmd({'FileType'}, -{pattern = {'c'}, -command = 'noremap gggqG', -}) - -vim.api.nvim_create_autocmd({'FileType'}, -{pattern = {'html'}, -command = 'noremap :silent %!tidy -q -i --show-errors 0 ', -}) - -vim.api.nvim_create_autocmd({'FileType'}, -{pattern = {'java'}, -command = 'setlocal formatprg=astyle --indent=spaces=2 --style=google', -}) - -vim.api.nvim_create_autocmd({'FileType'}, -{pattern = {'java'}, -command = 'noremap gggqG', -}) - -vim.api.nvim_create_autocmd({'FileType'}, -{pattern = {'markdown'}, -command = 'noremap :silent %!prettier --stdin-filepath % ', -}) - -vim.api.nvim_create_autocmd({'FileType'}, -{pattern = {'nim'}, -command = 'noremap :silent !nimpretty %', -}) - -vim.api.nvim_create_autocmd({'FileType'}, -{pattern = {'nim'}, -command = 'noremap gggqG', -}) - -vim.api.nvim_create_autocmd({'FileType'}, -{pattern = {'python'}, -command = 'setlocal formatprg=autopep8 "%"', -}) - -vim.api.nvim_create_autocmd({'FileType'}, -{pattern = {'python'}, -command = 'noremap gggqG', -}) - -vim.api.nvim_create_autocmd({'FileType'}, -{pattern = {'tex', 'latex'}, -command = 'setlocal formatprg=latexindent', -}) - -vim.api.nvim_create_autocmd({'FileType'}, -{pattern = {'tex', 'latex'}, -command = 'noremap gggqG', -}) - -- cleanup certain files after leaving the editor vim.api.nvim_create_autocmd({'VimLeave'}, {pattern = {'*.c'},