neovim-confs/lua/custom/autocmds.lua

107 lines
2.3 KiB
Lua
Raw Normal View History

2024-07-08 10:32:51 +02:00
local augroup = vim.api.nvim_create_augroup('plex_generic_autocmds', {})
2024-07-09 01:25:42 +02:00
-- enable text wrapping for text filetypes
vim.api.nvim_create_autocmd('FileType', {
group = augroup,
pattern = {
'tex',
'text',
'markdown',
'help',
2024-07-19 11:09:09 +02:00
'typst',
2024-07-09 01:25:42 +02:00
},
callback = function()
vim.opt_local.wrap = true
end,
})
2024-09-11 21:52:49 +02:00
-- use html for htmldjango
vim.api.nvim_create_autocmd('FileType', {
group = augroup,
pattern = {
'html',
},
callback = function()
vim.bo.filetype = 'html'
end,
})
2024-07-08 10:32:51 +02:00
-- always use the tex filetype for latex things, as those are most supported by
-- latex language servers.
vim.api.nvim_create_autocmd('FileType', {
group = augroup,
pattern = {
'latex',
'plaintex',
},
callback = function()
vim.bo.filetype = 'tex'
end,
})
-- conceallevel is what converts things like **bold** to be displayed as bold
-- without the stars. This is useful, but we might not want it for some
-- filetypes.
vim.api.nvim_create_autocmd('FileType', {
group = augroup,
pattern = {
'latex',
2024-07-15 09:47:40 +02:00
'markdown',
2024-07-08 10:32:51 +02:00
'plaintex',
'tex',
2024-07-19 11:09:09 +02:00
'typst',
2024-07-08 10:32:51 +02:00
},
callback = function()
vim.opt_local.conceallevel = 0
2024-07-09 01:51:49 +02:00
vim.opt_local.concealcursor = ''
2024-07-08 10:32:51 +02:00
end,
})
-- Enable spellcheck for some types
vim.api.nvim_create_autocmd('FileType', {
group = augroup,
pattern = {
'latex',
'markdown',
2024-07-19 11:09:09 +02:00
'typst',
'plaintex',
'tex',
},
callback = function()
vim.cmd [[set spell]]
end,
})
-- disable auto formatting for some filetypes
vim.api.nvim_create_autocmd('FileType', {
group = augroup,
pattern = {
'TelescopePrompt',
},
callback = function()
vim.opt_local.formatoptions = ''
end,
})
2024-07-10 17:06:49 +02:00
-- tweak colorschemes and highlights after loading a new colorscheme
vim.api.nvim_create_autocmd('ColorScheme', {
group = augroup,
callback = function()
vim.cmd [[highlight Comment gui=NONE]] -- no italics for comments
end,
})
2024-09-04 10:12:12 +02:00
-- pin main.typ for typst projects
vim.api.nvim_create_autocmd('FileType', {
group = augroup,
pattern = {
'typst',
},
callback = function()
-- pin the main file
vim.lsp.buf.execute_command { command = 'tinymist.pinMain', arguments = { vim.api.nvim_buf_get_name(0) } }
-- -- unpin the main file
-- vim.lsp.buf.execute_command { command = 'tinymist.pinMain', arguments = { nil } }
end,
})