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

69 lines
1.8 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=80 " 80 characters
set noswapfile
set backupdir=~/.cache/nvim
set cursorline " Highlight current line
set mouse=a " Mouse
" Default indentation
set softtabstop=4
set tabstop=4
set shiftwidth=4
set expandtab
set autoindent
" Syntax highlighting
set syntax=on
" Show line numbers on non-toolbar buffers
fun! ShowNumberIfNecessary()
if &ft =~ 'neo-tree|toggleterm'
return
endif
setlocal nu
endfun
autocmd BufEnter * call ShowNumberIfNecessary()
autocmd TermOpen,TermEnter term://* setlocal nonumber
" 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()
" Focus moving remaps
lua << EOF
function _G.set_focus_keymaps()
vim.keymap.set('n', '<C-h>', [[<Cmd>wincmd h<CR>]], opts)
vim.keymap.set('n', '<C-j>', [[<Cmd>wincmd j<CR>]], opts)
vim.keymap.set('n', '<C-k>', [[<Cmd>wincmd k<CR>]], opts)
vim.keymap.set('n', '<C-l>', [[<Cmd>wincmd l<CR>]], opts)
end
EOF
autocmd BufEnter * lua set_focus_keymaps()
" Startup commands
autocmd UIEnter * Neotree