commit ef0869be1c9364f9c0993389f4c44c453fd52536
parent 8d68b8c12253cc673adf11b2163469a4ef5958aa
Author: Markus Hanetzok <markus@hanetzok.net>
Date: Sun, 5 Oct 2025 23:47:05 +0200
add neovim config
Diffstat:
A | .config/nvim/init.vim | | | 112 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1 file changed, 112 insertions(+), 0 deletions(-)
diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim
@@ -0,0 +1,112 @@
+let mapleader =" "
+
+if ! filereadable(system('echo -n "${XDG_CONFIG_HOME:-$HOME/.config}/nvim/autoload/plug.vim"'))
+ echo "Downloading junegunn/vim-plug to manage plugins..."
+ silent !mkdir -p ${XDG_CONFIG_HOME:-$HOME/.config}/nvim/autoload/
+ silent !curl "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" > ${XDG_CONFIG_HOME:-$HOME/.config}/nvim/autoload/plug.vim
+ autocmd VimEnter * PlugInstall
+endif
+
+call plug#begin(system('echo -n "${XDG_CONFIG_HOME:-$HOME/.config}/nvim/plugged"'))
+Plug 'preservim/nerdtree'
+Plug 'vimwiki/vimwiki'
+Plug 'vim-airline/vim-airline'
+Plug 'ap/vim-css-color'
+Plug 'dracula/vim', { 'as': 'dracula' }
+call plug#end()
+
+set title
+set bg=light
+set mouse=a
+set nohlsearch
+set clipboard+=unnamedplus
+set noshowmode
+set noruler
+set laststatus=0
+set noshowcmd
+colorscheme dracula
+
+" Some basics:
+ nnoremap c "_c
+ filetype plugin on
+ syntax on
+ set encoding=utf-8
+ set number relativenumber
+" Enable autocompletion:
+ set wildmode=longest,list,full
+" Disables automatic commenting on newline:
+ autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
+" Perform dot commands over visual blocks:
+ vnoremap . :normal .<CR>
+" Spell-check set to <leader>o, 'o' for 'orthography':
+ map <leader>o :setlocal spell! spelllang=en_us<CR>
+" Splits open at the bottom and right:
+ set splitbelow splitright
+
+" Nerd tree
+ map <leader>q :NERDTreeToggle<CR>
+ autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
+ let NERDTreeBookmarksFile = stdpath('data') . '/NERDTreeBookmarks'
+
+" vim-airline
+ if !exists('g:airline_symbols')
+ let g:airline_symbols = {}
+ endif
+ let g:airline_symbols.colnr = ' C:'
+ let g:airline_symbols.linenr = ' L:'
+ let g:airline_symbols.maxlinenr = ' '
+ let g:airline#extensions#whitespace#symbol = '!'
+
+" Shortcutting split navigation, saving a keypress:
+ map <C-h> <C-w>h
+ map <C-j> <C-w>j
+ map <C-k> <C-w>k
+ map <C-l> <C-w>l
+
+" Replace ex mode with gq
+ map Q gq
+
+" Check file in shellcheck:
+ map <leader>s :!clear && shellcheck -x %<CR>
+
+" Open my bibliography file in split
+ map <leader>b :vsp<space>$BIB<CR>
+ map <leader>r :vsp<space>$REFER<CR>
+
+" Replace all is aliased to S.
+ nnoremap S :%s//g<Left><Left>
+
+" Save file as sudo on files that require root permission
+ cabbrev w!! execute 'silent! write !sudo tee % >/dev/null' <bar> edit!
+
+" Automatically deletes all trailing whitespace and newlines at end of file on save. & reset cursor position
+ autocmd BufWritePre * let currPos = getpos(".")
+ autocmd BufWritePre * %s/\s\+$//e
+ autocmd BufWritePre * %s/\n\+\%$//e
+ autocmd BufWritePre *.[ch] %s/\%$/\r/e " add trailing newline for ANSI C standard
+ autocmd BufWritePre *neomutt* %s/^--$/-- /e " dash-dash-space signature delimiter in emails
+ autocmd BufWritePre * cal cursor(currPos[1], currPos[2])
+
+" Turns off highlighting on the bits of code that are changed, so the line that is changed is highlighted but the actual text that has changed stands out on the line and is readable.
+if &diff
+ highlight! link DiffText MatchParen
+endif
+
+" Function for toggling the bottom statusbar:
+let s:hidden_all = 0
+function! ToggleHiddenAll()
+ if s:hidden_all == 0
+ let s:hidden_all = 1
+ set noshowmode
+ set noruler
+ set laststatus=0
+ set noshowcmd
+ else
+ let s:hidden_all = 0
+ set showmode
+ set ruler
+ set laststatus=2
+ set showcmd
+ endif
+endfunction
+nnoremap <leader>h :call ToggleHiddenAll()<CR>