From 12ffabc6ff6f7ef8ee1bf423042119bbb231eea0 Mon Sep 17 00:00:00 2001 From: Felix Wittwer Date: Mon, 25 Jul 2022 22:24:06 +0200 Subject: [PATCH] Add neovim config --- tycho/create_home.sh | 8 +++ tycho/nvim/init.vim | 131 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 139 insertions(+) create mode 100644 tycho/nvim/init.vim diff --git a/tycho/create_home.sh b/tycho/create_home.sh index 8bcc1c1..78cd5a8 100755 --- a/tycho/create_home.sh +++ b/tycho/create_home.sh @@ -121,3 +121,11 @@ curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.c ln -s $PWD/.vimrc ~/.vimrc vim -c "PlugInstall" + +printf "\033[33m[info] Setting up vim\033[39m" +sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \ + https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' +ln -s $PWD/nvim ~/.config/nvim +nvim -c "PlugInstall" + + diff --git a/tycho/nvim/init.vim b/tycho/nvim/init.vim new file mode 100644 index 0000000..9b53879 --- /dev/null +++ b/tycho/nvim/init.vim @@ -0,0 +1,131 @@ +" this is enabled by default in nvim +" filetype plugin indent on +" syntax on + +" enable autocompletion of ale +let g:ale_completion_enabled = 1 +" disable latex linting from ale as i've got my own plugin for that +let g:ale_linters = {'rust': ['analyzer'], 'tex': []} +let g:ale_fixers = {'c': ['clang-format']} + + +" Initialize plugin system +call plug#begin(stdpath('data') . '/plugged') + +" Make sure you use single quotes + +" Shorthand notation; fetches https://github.com/morhetz/gruvbox +" Plug 'morhetz/gruvbox' +Plug 'drewtempelmeyer/palenight.vim' + +" Any valid git URL is allowed +Plug 'https://github.com/scrooloose/nerdcommenter.git' + +" On-demand loading for languages +Plug 'rust-lang/rust.vim', { 'for': 'rust' } +Plug 'cespare/vim-toml', { 'for': 'toml' } +Plug 'keith/swift.vim', { 'for': 'swift' } +" Plug 'neovimhaskell/haskell-vim', { 'for': 'haskell' } + +Plug 'vim-syntastic/syntastic' +Plug 'vim-airline/vim-airline' +Plug 'tpope/vim-fugitive' +Plug 'airblade/vim-gitgutter' +Plug 'justinmk/vim-sneak' +Plug 'lervag/vimtex' +Plug 'editorconfig/editorconfig-vim' +Plug 'LnL7/vim-nix' +Plug 'xevz/vim-squirrel' +Plug 'preservim/nerdtree' + +" Plugin outside ~/.vim/plugged with post-update hook +Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } +Plug 'junegunn/fzf.vim' + +" ale language server client +Plug 'dense-analysis/ale' + +" Initialize plugin system +call plug#end() + +" open fzf files in new tab instead of new buffer +"command! -bang -nargs=? -complete=dir Files + "\ call fzf#vim#files(, {'sink': 'tabedit', 'options': ['--info=inline', '--preview', '~/.vim/plugged/fzf.vim/bin/preview.sh {}']}, 0) + +set laststatus=2 +let g:airline#extensions#tabline#enabled = 1 +"let g:airline_powerline_fonts = 1 + +" window switching by # +let g:airline_section_c = '[%{winnr()}] %t' +nnoremap 1 1w +nnoremap 2 2w +nnoremap 3 3w +nnoremap 4 4w +nnoremap 5 5w +nnoremap 6 6w +nnoremap 7 7w +nnoremap 8 8w +nnoremap 9 9w +nnoremap 0 10w + +" possible setting as alternative for easymotion +" let g:sneak#label = 1 + +set backspace=indent,eol,start + +" map the leader key to , +let mapleader="," + +" set filetypes +au BufRead,BufNewFile *.ohuac setfiletype rust +au BufRead,BufNewFile *.ohuao setfiletype json + +" Cycling through windows and tabs -- made by Pius :D +" nnoremap j +" nnoremap k +" nnoremap l +" nnoremap h +" nnoremap _ +" nnoremap _ +" nnoremap \| +" nnoremap \| +map h :tabp +map l :tabn +map :bprevious +map :bnext +map f :Files +map bl :Buffers + +" fix auto-completion +set wildmenu " show a completion menu +set wildignorecase +set wildignore=*.o,*~,*.pyc,*.aux,*.bbl,*.blg,*-blx.bib,*.log,*.out,*.run.xml, + \*.toc,*.nav,*.snm " ignore auxiliary files +" set completeopt-=preview + +" automatically reload files changed on disk but not in buffer +set autoread +" hide buffers on switch +set hidden + +" tex configuration +let g:tex_flavor='latex' +" Optics +colorscheme palenight "gruvbox +set background=dark " Setting dark mode + +set number +set relativenumber +set tabstop=4 +set shiftwidth=4 +set expandtab + +" keep 5 lines of context above/below the cursor (if possible) +set scrolloff=5 + +" Search +set hlsearch " Highlight all search results +set smartcase " Enable smart-case search +set ignorecase " Always case-insensitive +set incsearch " Searches for strings incrementally