dotfiles/nvim/.config/nvim/init.vim

92 lines
2.1 KiB
VimL

" Packer plugins
lua require('plugins')
" Gruvbox Theme (colorscheme applied from plugins.lua)
if has('termguicolors')
set termguicolors
endif
" For dark version.
set background=dark
" We need to apply this here too to make sure the startup components work
colorscheme gruvbox
" Miscellaneous boilerplate
set nocompatible " Disable vi compatibility
set ignorecase
set cc=128 " 128 characters
set noswapfile
set backupdir=~/.cache/nvim
set cursorline " Highlight current line
set mouse=a " Mouse
set nofixendofline
" Default indentation
set softtabstop=4
set tabstop=4
set shiftwidth=4
set expandtab
set autoindent
" Syntax highlighting
set syntax=on
let g:special_filetype_pattern = 'neo-tree\|toggleterm\|minimap'
" Show line numbers on non-toolbar buffers
fun! ShowNumberIfNecessary()
if &ft =~ g:special_filetype_pattern
return
endif
setlocal nu
endfun
autocmd BufEnter * call ShowNumberIfNecessary()
" Minimap
fun! ResizeMinimap()
if &ft =~ g:special_filetype_pattern
return
endif
if index(g:minimap_block_filetypes, &ft) >= 0
return
endif
if index(g:minimap_block_buftypes, &bt) >= 0
return
endif
MinimapClose
Minimap
endfun
let g:minimap_git_colors = 1
let g:minimap_width = 16
autocmd VimResized * call ResizeMinimap()
" Prevent Minimap from being focused
lua << EOF
function _G.reject_minimap_focus()
local mmwinnr = vim.fn.bufwinnr("-MINIMAP-")
if mmwinnr == -1 then
return
end
if vim.fn.winnr() == mmwinnr then
-- Go to the other window.
vim.api.nvim_command("wincmd t")
end
end
EOF
autocmd WinEnter * lua reject_minimap_focus()
" Terminal remapping
lua << EOF
function _G.set_terminal_keymaps()
local opts = {buffer = 0}
vim.keymap.set('t', '<esc>', [[<C-\><C-n>]], opts)
vim.keymap.set('t', 'jk', [[<C-\><C-n>]], opts)
vim.keymap.set('t', '<C-h>', [[<Cmd>wincmd h<CR>]], opts)
vim.keymap.set('t', '<C-j>', [[<Cmd>wincmd j<CR>]], opts)
vim.keymap.set('t', '<C-k>', [[<Cmd>wincmd k<CR>]], opts)
vim.keymap.set('t', '<C-l>', [[<Cmd>wincmd l<CR>]], opts)
end
EOF
autocmd TermOpen term://* lua set_terminal_keymaps()