80 lines
2.3 KiB
Lua
80 lines
2.3 KiB
Lua
local api = vim.api
|
|
|
|
-- Highlight on yank
|
|
local yankGrp = api.nvim_create_augroup('YankHighlight', { clear = true })
|
|
api.nvim_create_autocmd('TextYankPost', {
|
|
command = 'silent! lua vim.highlight.on_yank()',
|
|
group = yankGrp,
|
|
})
|
|
|
|
-- Filetypes
|
|
local fileGrp = api.nvim_create_augroup('file_type', { clear = true })
|
|
api.nvim_create_autocmd({ 'BufRead', 'BufNewFile' }, {
|
|
pattern = { '*.simvis', '*.manifest' },
|
|
callback = function()
|
|
vim.bo.filetype = 'xml'
|
|
end,
|
|
group = fileGrp,
|
|
})
|
|
api.nvim_create_autocmd({ 'BufRead', 'BufNewFile' }, {
|
|
pattern = { '*.simcfg', '*.simcon', '*.simudex' },
|
|
callback = function()
|
|
vim.bo.filetype = 'xml'
|
|
end,
|
|
group = fileGrp,
|
|
})
|
|
api.nvim_create_autocmd({ 'BufRead', 'BufNewFile' }, {
|
|
pattern = { 'JenkinsFile*' },
|
|
callback = function()
|
|
vim.bo.filetype = 'groovy'
|
|
end,
|
|
group = fileGrp,
|
|
})
|
|
api.nvim_create_autocmd({ 'BufRead', 'BufNewFile' }, {
|
|
pattern = { 'SConstruct', 'SConscript' },
|
|
callback = function()
|
|
vim.bo.filetype = 'python'
|
|
end,
|
|
group = fileGrp,
|
|
})
|
|
api.nvim_create_autocmd({ 'BufRead', 'BufNewFile' }, {
|
|
pattern = { 'doskey' },
|
|
callback = function()
|
|
vim.bo.filetype = 'dosini'
|
|
end,
|
|
group = fileGrp,
|
|
})
|
|
api.nvim_create_autocmd({ 'BufRead', 'BufNewFile' }, {
|
|
pattern = { '.clangd', '.clang-tidy' },
|
|
callback = function()
|
|
vim.bo.filetype = 'yaml'
|
|
end,
|
|
group = fileGrp,
|
|
})
|
|
|
|
-- Read and write shada file
|
|
api.nvim_create_autocmd({ 'FocusLost' }, { command = [[wshada]] })
|
|
|
|
-- go to last loc when opening a buffer
|
|
-- api.nvim_create_autocmd(
|
|
-- 'BufReadPost',
|
|
-- { command = [[if line("'\"") > 1 && line("'\"") <= line("$") | execute "normal! g`\"" | endif]] }
|
|
-- )
|
|
|
|
-- Check if we need to reload the file when it changed
|
|
api.nvim_create_autocmd({ 'FocusGained', 'BufEnter' },
|
|
{ command = [[if !bufexists("[Command Line]") | checktime | endif]] })
|
|
|
|
-- windows to close with "q"
|
|
api.nvim_create_autocmd(
|
|
'FileType',
|
|
{ pattern = { 'help', 'startuptime', 'qf', 'lspinfo' }, command = [[nnoremap <buffer><silent> q :close<CR>]] }
|
|
)
|
|
api.nvim_create_autocmd('FileType', { pattern = 'man', command = [[nnoremap <buffer><silent> q :quit<CR>]] })
|
|
|
|
-- don't auto comment new line
|
|
api.nvim_create_autocmd('BufEnter', { command = [[set formatoptions-=cro]] })
|
|
|
|
-- Keep window ratio when resize
|
|
api.nvim_create_autocmd('VimResized', { command = [[wincmd =]] })
|