diff --git a/nvim/autocmd.vim b/nvim/autocmd.vim new file mode 100644 index 0000000..9d11c96 --- /dev/null +++ b/nvim/autocmd.vim @@ -0,0 +1,7 @@ +" *** *** *** Autocommands *** *** *** +" ************************************ + +augroup highlight_yank + autocmd! + au TextYankPost * silent! lua vim.highlight.on_yank{higroup="IncSearch", timeout=700} +augroup END diff --git a/nvim/functions.vim b/nvim/functions.vim new file mode 100644 index 0000000..69355c2 --- /dev/null +++ b/nvim/functions.vim @@ -0,0 +1,20 @@ +" *** *** *** Functions *** *** *** +" ********************************* + +" Toggle between soft wrap and no wrap +nnoremap tw :call ToggleWrap() + +function! ToggleWrap() + if &wrap + echo "Wrap OFF" + set nowrap + set nolinebreak + set virtualedit=all + else + echo "Wrap ON" + set wrap + set linebreak + set virtualedit= + setlocal display+=lastline + endif +endfunction diff --git a/nvim/init.vim b/nvim/init.vim index 42df060..a608bfa 100644 --- a/nvim/init.vim +++ b/nvim/init.vim @@ -1,222 +1,6 @@ -" *** *** *** Global Settings *** *** *** -" *************************************** - -set expandtab -set autowrite -set showbreak=↪ -set ignorecase -set smartcase -set list -set listchars=tab:▸\ ,trail:·,nbsp:.,extends:❯,precedes:❮ -set visualbell -set termguicolors -set number -set relativenumber -set backspace=indent,eol,start " Intuitive backspacing -set hidden -set iskeyword+=- " Add dashes to words -set cpoptions+=$ " Don't delete the word, but put a $ to the end till exit the mode -set title -set shortmess=caoOtI " Welcome screen -set tabstop=2 -set shiftwidth=2 -set softtabstop=2 -set expandtab -set copyindent -set shiftround -set mouse=a -set clipboard=unnamedplus -set nowrap -set confirm -set spelllang=de_de,en_us -set timeoutlen=500 -set signcolumn=yes:2 -set foldmethod=marker -set splitbelow -set splitright -set scrolloff=8 -set sidescrolloff=8 -set virtualedit=all -set cursorline -set path+=** -set nobackup -set nowritebackup -set noswapfile -set undofile -set redrawtime=10000 " Allow more time for loading syntax on large files -set complete+=i,k,s,kspell -set wildmode=longest:full,full - -" Spell Checker -set spellfile+=~/.config/nvim/spell/de.utf-8.add " (1)zg, (1)zw -set spellfile+=~/.vim/spell/en.utf-8.add " 2zg, 2zw - -" Custom Dictionaries ( ) -set dictionary+=~/.config/nvim/dictionary/de_user.txt -set dictionary+=~/.config/nvim/dictionary/de_neu.txt -set dictionary+=~/.config/nvim/dictionary/en_us.txt - -" Custom Thesauri (Synonyms) ( ) -set thesaurus+=~/.config/nvim/thesaurus/de_user.txt -set thesaurus+=~/.config/nvim/thesaurus/de_openthesaurus.txt - -" Python paths -let g:python_host_prog=$HOME.'/.pyenv/versions/neovim2/bin/python' -let g:python3_host_prog=$HOME.'/.pyenv/versions/neovim3/bin/python' - -" Leader -let mapleader = "\" - -" *** *** *** Key Mappings *** *** *** -" ************************************ - -" Quick toggle between buffers -noremap j :b# - -" Add semicolon or comma to the end of the line -nnoremap ;; A; -nnoremap ,, A, - -" Maintain the cursor position when yanking a visual selection -vnoremap y myy`y -vnoremap Y myY`y - -" Delete last character of line -nnoremap x $x - -" Open vim config in a new buffer, reload vim config -nnoremap ve :e $MYVIMRC -nnoremap vr :source $MYVIMRC - -" Delete current buffer -nnoremap X :bd - -" Delete all buffers -nnoremap da :bufdo bdelete - -" Save current buffer -nnoremap sf :w - -" Allow gf to open non-existent files -map gf :edit - -" Reselect visual selection after indenting -vnoremap < >gv - -" Set spell checker to `s` -" zg (good), zG (good temp), zw (wrong), zW (wrong temp) -nnoremap s :set spell! - -" Switch off highlighting -nnoremap h :nohlsearch - -" Toogle list -nnoremap l :set list! - -" Indent the whole source code -nnoremap ff gg=G'' - -" Reverse the mark mapping -nnoremap ' ` -nnoremap ` ' - -" Visuall select of just pasted content -nnoremap gp `[v`] -nnoremap gy `[v`]y - -" When text is wrapped, move by terminal rows, not lines, unless a count is provided -noremap j (v:count == 0 ? 'gj' : 'j') -noremap k (v:count == 0 ? 'gk' : 'k') - -" Open a quickfix window for the last search -nnoremap ? :execute 'vimgrep /'.@/.'/g %':copen - -" Faster linewise scrolling -noremap 3 -noremap 3 - -" Keep the window centered -noremap G Gzzzv -noremap n nzzzv -noremap N Nzzzv -noremap } }zzzv -noremap { {zzzv - -" Close all buffers -nnoremap XX :qa - -" Add lines in NORMAL Mode -nnoremap gn ok -nnoremap gN Oj - -" Change to the folder of the current file -nnoremap cf :cd %:p:h:pwd - -" Quickfix Window -nnoremap qo :copen -nnoremap qc :cclose - -" Exit INSERT MODE with 'jk' -inoremap jj - -" Reformat a line into a block -nnoremap q gqip - -" Reformat a block into a line -nnoremap qq vipJ - -" Easier split navigation -nnoremap -nnoremap -nnoremap -nnoremap - - -" *** *** *** Functions *** *** *** -" ********************************* - -" Toggle between soft wrap and no wrap -nnoremap tw :call ToggleWrap() - -function! ToggleWrap() - if &wrap - echo "Wrap OFF" - set nowrap - set nolinebreak - set virtualedit=all - else - echo "Wrap ON" - set wrap - set linebreak - set virtualedit= - setlocal display+=lastline - endif -endfunction - - -" *** *** *** Plugins *** *** *** -" ******************************* - -" Automatically install vim-plug -let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim' -if empty(glob(data_dir . '/autoload/plug.vim')) - silent execute '!curl -fLo ' . data_dir . '/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' - autocmd VimEnter * PlugInstall --sync | source $MYVIMRC -endif - -call plug#begin(data_dir . '/plugins') - -source ~/.config/nvim/plugins/base16-vim.vim -source ~/.config/nvim/plugins/fzf.vim - -call plug#end() -doautocmd User PlugLoaded - -" *** *** *** Autocommands *** *** *** -" ************************************ - -augroup highlight_yank - autocmd! - au TextYankPost * silent! lua vim.highlight.on_yank{higroup="IncSearch", timeout=700} -augroup END +source ~/.config/nvim/settings.vim +source ~/.config/nvim/mappings.vim +source ~/.config/nvim/functions.vim +source ~/.config/nvim/plugins.vim +source ~/.config/nvim/plugins-config.vim +source ~/.config/nvim/autocmd.vim diff --git a/nvim/mappings.vim b/nvim/mappings.vim new file mode 100644 index 0000000..a93ff56 --- /dev/null +++ b/nvim/mappings.vim @@ -0,0 +1,104 @@ +" *** *** *** Key Mappings *** *** *** +" ************************************ + +" Quick toggle between buffers +noremap j :b# + +" Add semicolon or comma to the end of the line +nnoremap ;; A; +nnoremap ,, A, + +" Maintain the cursor position when yanking a visual selection +vnoremap y myy`y +vnoremap Y myY`y + +" Delete last character of line +nnoremap x $x + +" Open vim config in a new buffer, reload vim config +nnoremap ve :e $MYVIMRC +nnoremap vr :source $MYVIMRC + +" Delete current buffer +nnoremap X :bd + +" Delete all buffers +nnoremap da :bufdo bdelete + +" Save current buffer +nnoremap sf :w + +" Allow gf to open non-existent files +map gf :edit + +" Reselect visual selection after indenting +vnoremap < >gv + +" Set spell checker to `s` +" zg (good), zG (good temp), zw (wrong), zW (wrong temp) +nnoremap s :set spell! + +" Switch off highlighting +nnoremap h :nohlsearch + +" Toogle list +nnoremap l :set list! + +" Indent the whole source code +nnoremap ff gg=G'' + +" Reverse the mark mapping +nnoremap ' ` +nnoremap ` ' + +" Visuall select of just pasted content +nnoremap gp `[v`] +nnoremap gy `[v`]y + +" When text is wrapped, move by terminal rows, not lines, unless a count is provided +noremap j (v:count == 0 ? 'gj' : 'j') +noremap k (v:count == 0 ? 'gk' : 'k') + +" Open a quickfix window for the last search +nnoremap ? :execute 'vimgrep /'.@/.'/g %':copen + +" Faster linewise scrolling +noremap 3 +noremap 3 + +" Keep the window centered +noremap G Gzzzv +noremap n nzzzv +noremap N Nzzzv +noremap } }zzzv +noremap { {zzzv + +" Close all buffers +nnoremap XX :qa + +" Add lines in NORMAL Mode +nnoremap gn ok +nnoremap gN Oj + +" Change to the folder of the current file +nnoremap cf :cd %:p:h:pwd + +" Quickfix Window +nnoremap qo :copen +nnoremap qc :cclose + +" Exit INSERT MODE with 'jk' +inoremap jj + +" Reformat a line into a block +nnoremap q gqip + +" Reformat a block into a line +nnoremap qq vipJ + +" Easier split navigation +nnoremap +nnoremap +nnoremap +nnoremap diff --git a/nvim/plugins-config.vim b/nvim/plugins-config.vim new file mode 100644 index 0000000..2602e00 --- /dev/null +++ b/nvim/plugins-config.vim @@ -0,0 +1,5 @@ +" *** *** *** Plugins Configuration *** *** *** +" ********************************************* + +source ~/.config/nvim/plugins/base16.vim +source ~/.config/nvim/plugins/fzf.vim diff --git a/nvim/plugins.vim b/nvim/plugins.vim new file mode 100644 index 0000000..39f15b1 --- /dev/null +++ b/nvim/plugins.vim @@ -0,0 +1,21 @@ +" *** *** *** Plugins *** *** *** +" ******************************* + +" Automatically install vim-plug +let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim' +if empty(glob(data_dir . '/autoload/plug.vim')) + silent execute '!curl -fLo ' . data_dir . '/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' + autocmd VimEnter * PlugInstall --sync | source $MYVIMRC +endif + +call plug#begin(data_dir . '/plugins') + +" Base16 for Vim +Plug 'chriskempson/base16-vim' + +" A command-line fuzzy finder +Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } +Plug 'junegunn/fzf.vim' + +call plug#end() +doautocmd User PlugLoaded diff --git a/nvim/plugins/base16-vim.vim b/nvim/plugins/base16-vim.vim deleted file mode 100644 index c7acc15..0000000 --- a/nvim/plugins/base16-vim.vim +++ /dev/null @@ -1,14 +0,0 @@ -" Base16 for Vim -Plug 'chriskempson/base16-vim' - -function ActivateColorscheme() - if filereadable(expand("~/.vimrc_background")) - let base16colorspace=256 - source ~/.vimrc_background - endif -endfunction - -augroup ActivateColorscheme - autocmd! - autocmd User PlugLoaded call ActivateColorscheme() -augroup END diff --git a/nvim/plugins/base16.vim b/nvim/plugins/base16.vim new file mode 100644 index 0000000..0956ff1 --- /dev/null +++ b/nvim/plugins/base16.vim @@ -0,0 +1,5 @@ +if filereadable(expand("~/.vimrc_background")) + let base16colorspace=256 + source ~/.vimrc_background +endif + diff --git a/nvim/plugins/fzf.vim b/nvim/plugins/fzf.vim index 7093f38..902b311 100644 --- a/nvim/plugins/fzf.vim +++ b/nvim/plugins/fzf.vim @@ -1,7 +1,3 @@ -" A command-line fuzzy finder -Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } -Plug 'junegunn/fzf.vim' - " Key bindings let g:fzf_action = { \ 'ctrl-t': 'tab split', diff --git a/nvim/settings.vim b/nvim/settings.vim new file mode 100644 index 0000000..f94ecb2 --- /dev/null +++ b/nvim/settings.vim @@ -0,0 +1,68 @@ +" *** *** *** Global Settings *** *** *** +" *************************************** + +set expandtab +set autowrite +set showbreak=↪ +set ignorecase +set smartcase +set list +set listchars=tab:▸\ ,trail:·,nbsp:.,extends:❯,precedes:❮ +set visualbell +set termguicolors +set number +set relativenumber +set backspace=indent,eol,start " Intuitive backspacing +set hidden +set iskeyword+=- " Add dashes to words +set cpoptions+=$ " Don't delete the word, but put a $ to the end till exit the mode +set title +set shortmess=caoOtI " Welcome screen +set tabstop=2 +set shiftwidth=2 +set softtabstop=2 +set expandtab +set copyindent +set shiftround +set mouse=a +set clipboard=unnamedplus +set nowrap +set confirm +set spelllang=de_de,en_us +set timeoutlen=500 +set signcolumn=yes:2 +set foldmethod=marker +set splitbelow +set splitright +set scrolloff=8 +set sidescrolloff=8 +set virtualedit=all +set cursorline +set path+=** +set nobackup +set nowritebackup +set noswapfile +set undofile +set redrawtime=10000 " Allow more time for loading syntax on large files +set complete+=i,k,s,kspell +set wildmode=longest:full,full + +" Spell Checker +set spellfile+=~/.config/nvim/spell/de.utf-8.add " (1)zg, (1)zw +set spellfile+=~/.vim/spell/en.utf-8.add " 2zg, 2zw + +" Custom Dictionaries ( ) +set dictionary+=~/.config/nvim/dictionary/de_user.txt +set dictionary+=~/.config/nvim/dictionary/de_neu.txt +set dictionary+=~/.config/nvim/dictionary/en_us.txt + +" Custom Thesauri (Synonyms) ( ) +set thesaurus+=~/.config/nvim/thesaurus/de_user.txt +set thesaurus+=~/.config/nvim/thesaurus/de_openthesaurus.txt + +" Python paths +let g:python_host_prog=$HOME.'/.pyenv/versions/neovim2/bin/python' +let g:python3_host_prog=$HOME.'/.pyenv/versions/neovim3/bin/python' + +" Leader +let mapleader = "\"