81 lines
2.1 KiB
Lua
81 lines
2.1 KiB
Lua
-- vim.api.nvim_set_hl(0, 'NormalFloat', { bg = '#282828' })
|
|
-- vim.api.nvim_set_hl(0, 'FloatBorder', { bg = 'NONE' }) vim.api.nvim_set_hl(0, 'Pmenu', { bg = 'NONE' })
|
|
-- vim.api.nvim_set_hl(0, 'StatusLine', { bg = 'NONE' })
|
|
local function augroup(name)
|
|
return vim.api.nvim_create_augroup('neo_' .. name, { clear = true })
|
|
end
|
|
|
|
-- Use 'q' to quit from common plugins
|
|
vim.api.nvim_create_autocmd({ 'FileType' }, {
|
|
pattern = { 'qf', 'help', 'man', 'lspinfo', 'spectre_panel', 'lir' },
|
|
callback = function()
|
|
vim.cmd [[
|
|
nnoremap <silent> <buffer> q :close<CR>
|
|
set nobuflisted
|
|
]]
|
|
end,
|
|
})
|
|
|
|
-- use 2 spaces for cpp
|
|
vim.api.nvim_create_autocmd({ 'FileType' }, {
|
|
pattern = { 'cpp', 'cc', 'hpp', 'hh', 'md', 'markdown', 'java' },
|
|
callback = function()
|
|
vim.opt.ts = 4
|
|
vim.opt.sw = 4
|
|
vim.opt.expandtab = true
|
|
end,
|
|
})
|
|
|
|
-- Fixes Autocomment
|
|
vim.api.nvim_create_autocmd({ 'BufWinEnter' }, {
|
|
callback = function()
|
|
vim.cmd 'set formatoptions-=cro'
|
|
end,
|
|
})
|
|
|
|
-- Highlight Yanked Text
|
|
vim.api.nvim_create_autocmd({ 'TextYankPost' }, {
|
|
callback = function()
|
|
vim.highlight.on_yank { higroup = 'Visual', timeout = 200 }
|
|
end,
|
|
})
|
|
|
|
vim.api.nvim_create_augroup('diagnostics', { clear = true })
|
|
|
|
vim.api.nvim_create_autocmd({ 'DiagnosticChanged' }, {
|
|
group = 'diagnostics',
|
|
callback = function()
|
|
vim.diagnostic.setloclist { open = false }
|
|
end,
|
|
})
|
|
|
|
-- resize splits if window got resized
|
|
vim.api.nvim_create_autocmd({ 'VimResized' }, {
|
|
group = augroup 'resize_splits',
|
|
callback = function()
|
|
vim.cmd 'tabdo wincmd ='
|
|
end,
|
|
})
|
|
|
|
-- wrap and check for spell in text filetypes
|
|
vim.api.nvim_create_autocmd('FileType', {
|
|
group = augroup 'wrap_spell',
|
|
pattern = { 'gitcommit', 'markdown' },
|
|
callback = function()
|
|
vim.opt_local.wrap = true
|
|
vim.opt_local.spell = true
|
|
end,
|
|
})
|
|
function ToggleTroubleAuto()
|
|
local ok, trouble = pcall(require, 'trouble')
|
|
if ok then
|
|
vim.defer_fn(function()
|
|
vim.cmd 'cclose'
|
|
trouble.open 'quickfix'
|
|
end, 0)
|
|
end
|
|
end
|
|
|
|
-- vim.cmd "autocmd VimLeave * call os.execute("mkdir /tmp/nvim"), writefile([getcwd()], expand('/tmp/nvim/cwd'))"
|
|
vim.cmd [[autocmd BufWinEnter quickfix silent :lua ToggleTroubleAuto()]]
|