hosts/base/neovim-init.vim

133 lines
3 KiB
VimL

set nocompatible
set backspace=indent,eol,start
syntax enable
set mouse=a
set mousemodel=extend
set title
let g:airline_theme='term_light'
filetype plugin on
filetype indent on
" Enable spell check for commit messages
autocmd FileType gitcommit setlocal spell spelllang=en_gb
" Use spaces instead of tabs
set expandtab
" Be smart when using tabs ;)
set smarttab
" 1 tab == 4 spaces
set shiftwidth=4
set tabstop=4
set wrap "Wrap lines
set nobackup
set nowb
set noswapfile
" Set to auto read when a file is changed from the outside
set autoread
" Leader
let mapleader = ","
let g:mapleader = ","
" Fast saving
nmap <leader>w :w!<cr>
" Save and start shell
nmap <leader># :w!<cr>:te<cr>i
"tnoremap <ESC> <C-\><C-n>:buffer #<CR>
tnoremap <C-c> <C-\><C-n>:buffer #<CR>
"autocmd TermClose * bd! " quit when a terminal closes instead of showing exit code and waiting
" Highlight search results
set hlsearch
" Makes search act like search in modern browsers
set incsearch
" Smart case when searching
set ignorecase
set smartcase
" Show results of pattern matching/replacing while typing
set inccommand=split
" When you press <leader>r you can search and replace the selected text
vnoremap <silent> <leader>r :call VisualSelection('replace')<CR>
" Disable highlight when <leader><cr> is pressed
map <silent> <leader><cr> :noh<cr>
" For regular expressions turn magic on
set magic
" Visual mode pressing * or # searches for the current selection
" Super useful! From an idea by Michael Naumann
vnoremap <silent> * :call VisualSelection('f')<CR>
vnoremap <silent> # :call VisualSelection('b')<CR>
" Show matching brackets when text indicator is over them
set showmatch
" How many tenths of a second to blink when matching brackets
set mat=2
" Spell checking
map <leader>ss :setlocal spell! spelllang=de_20<cr>
map <leader>se :setlocal spell! spelllang=en-curly_gb<cr>
map <leader>su :setlocal spell! spelllang=en-curly_us<cr>
" Treat long lines as break lines (useful when moving around in them)
map j gj
map k gk
" Smart way to move between windows
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
" More natural behaviour when splitting
set splitbelow
set splitright
" Useful mappings for managing tabs
map <leader>tn :tabnew<cr>
map <leader>to :tabonly<cr>
map <leader>tc :tabclose<cr>
map <leader>tm :tabmove
" Jump to particular tab directly
noremap <leader>1 1gt
noremap <leader>2 2gt
noremap <leader>3 3gt
noremap <leader>4 4gt
noremap <leader>5 5gt
noremap <leader>6 6gt
noremap <leader>7 7gt
noremap <leader>8 8gt
noremap <leader>9 9gt
noremap <leader>0 :tablast<cr>
" Switch CWD to the directory of the open buffer
map <leader>cd :cd %:p:h<cr>:pwd<cr>
" Remember info about open buffers on close
set viminfo^=%
" Toggle paste mode on and off
map <leader>pp :setlocal paste!<cr>
" Save and make
nnoremap <leader>m :wa <BAR> :Make<CR>
hi ColorColumn ctermbg=47
let g:vimtex_compiler_enabled = 0
let g:local_vimrc = {'names': ['.local.vimrc'], 'hash_fun': 'LVRHashOfFile'}