Added cenny dotfiles

This commit is contained in:
Jef Roosens 2021-04-21 14:52:27 +02:00
parent 20ab00736c
commit 885ecb33d0
Signed by: Jef Roosens
GPG key ID: B580B976584B5F30
57 changed files with 7714 additions and 0 deletions

View file

@ -0,0 +1,12 @@
function! OverwriteBackground()
" We only want a transparent background if we're using the dark theme
if g:colors_name == 'flattened_dark'
highlight Normal guibg=NONE ctermbg=NONE
highlight LineNr ctermfg=NONE ctermbg=NONE
endif
endfunction
augroup ColorschemeOverwrite
autocmd!
autocmd ColorScheme * call OverwriteBackground()
augroup END

View file

@ -0,0 +1,94 @@
" zz centers the cursor, so combining this with navigation commands keeps my
" cursor centered
" nnoremap j jzz
" nnoremap k kzz
" nnoremap gg ggzz
" nnoremap G Gzz
" I navigate my splits using <leader>hjkl. This setup allows for fast
" switching, which is important as I often end up with 3-4 splits after a while
nnoremap <silent> <leader>h :wincmd h<CR>
nnoremap <silent> <leader>j :wincmd j<CR>
nnoremap <silent> <leader>k :wincmd k<CR>
nnoremap <silent> <leader>l :wincmd l<CR>
" These mappings just exist because I'm lazy, and they only really work in
" QWERTY
nnoremap <silent> <leader>w :w<CR>
nnoremap <silent> <leader>q :q<CR>
" As I don't use the arrow keys for navigation, I remapped them to allow for
" resizing of my splits. If you hold down shift, you can control the size of
" the splits more precisely
nnoremap <silent> <Up> :resize +5<CR>
nnoremap <silent> <Down> :resize -5<CR>
nnoremap <silent> <Right> :vertical resize +5<CR>
nnoremap <silent> <Left> :vertical resize -5<CR>
nnoremap <silent> <S-Up> :resize +1<CR>
nnoremap <silent> <S-Down> :resize -1<CR>
nnoremap <silent> <S-Right> :vertical resize +1<CR>
nnoremap <silent> <S-Left> :vertical resize -1<CR>
" Disable arrow keys in editing & visual mode, as I have no need for them
inoremap <Right> <nop>
inoremap <Left> <nop>
inoremap <Up> <nop>
inoremap <Down> <nop>
vnoremap <Right> <nop>
vnoremap <Left> <nop>
vnoremap <Up> <nop>
vnoremap <Down> <nop>
" Tabs bindings
" TODO improve on these
" Create tab
nnoremap <silent> <leader>o :tabnew<CR>
" Close current tab
nnoremap <silent> <leader>p :tabclose<CR>
" Go to next tab
nnoremap <silent> <leader>i :tabnext<CR>
" Go to previous tab
nnoremap <silent> <leader>u :tabprevious<CR>
" This function allows me to switch between a dark & light theme. I mainly use
" the dark theme, but when I'm sitting outside, the light theme can be much
" more readable
function! ColorschemeToggle()
if g:colors_name == 'flattened_dark'
colorscheme flattened_light
else
colorscheme flattened_dark
endif
endfunction
nnoremap <silent> <leader>c :call ColorschemeToggle()<CR>
" As I'm constantly tweaking my config, I use keybindings to easily open &
" source it without leaving my session
nnoremap <silent> <leader>vs :source $MYVIMRC<CR>
" Opens CtrlP in my config directory
nnoremap <silent> <leader>ve :split<CR>:exec 'CtrlP ' . fnamemodify($MYVIMRC, ':h')<CR>
" This was probably one of the best ideas I found (it wasn't my original idea).
" By remapping Esc to jk, I could switch between modes without moving my hands.
" This improved my speed by much more than I was expecting, and helped with not
" straining my hands as much.
inoremap jk <Esc>
inoremap <Esc> <nop>
" I use this binding to quickly switch between two files.
nnoremap <leader>a <C-^>
" Terminal keybindings
" I use the terminal inside Neovim a lot, so I have some keybindings to easily
" open one
" Use jk in terminal as well
tnoremap <silent> jk <C-\><C-n>
" I explicitely use $SHELL, because my main shell is not necessarily Bash, and
" I want to use my main shell inside Vim as well
nnoremap <silent> <leader>rr :e term://$SHELL<CR>
nnoremap <silent> <leader>rh :vsp<CR>:wincmd h<CR>:e term://$SHELL<CR>
nnoremap <silent> <leader>rl :vsp<CR>:e term://$SHELL<CR>
nnoremap <silent> <leader>rk :sp<CR>:wincmd k<CR>:e term://$SHELL<CR>
nnoremap <silent> <leader>rj :sp<CR>:e term://$SHELL<CR>

View file

@ -0,0 +1,20 @@
" Open in tree view by default
let g:netrw_liststyle = 3
" Hide banner at the top
let g:netrw_banner = 0
" Change how netrc opens files
" 1 - horizontal split
" 2 - vertical split
" 3 - new tab
" 4 - previous window
let g:netrw_browse_split = 4
" Width of the view
let g:netrw_winsize = 15
" Start netrc on startup
augroup netrc
autocmd!
augroup END

View file

@ -0,0 +1,46 @@
# Plugins
I use quite a lot of plugins, as they greatly improve my workflow or just add
features that you most definitely need if you want to use Vim as your main
editor.
## List of plugins
* [CoC](https://github.com/neoclide/coc.nvim): my autocomplete plugin of
choice. It provide full LSP support, so many of its plugins use the exact
same setup as a VSCode plugin.
* [CtrlP](https://github.com/ctrlpvim/ctrlp.vim): a fuzzy search tool which I
use for most navigation.
* [vim-fugitive](https://github.com/tpope/vim-fugitive): an amazing Git client
for Vim. It has support for all the usual stuff (commits, adding/removing
files etc.), as well as a merge conflict resolver using Vim's built-in diff
view.
* [vim-surround](https://github.com/tpope/vim-surround): adds mappings to
change/remove surrounding characters (e.g. (), "", '' etc.). It integrates
really well with already existing bindings, making it feel like it's a
built-in feature.
* [vim-commentary](https://github.com/tpope/vim-commentary): adds mappings for
commenting/uncommenting lines easily. It has support for basically all
languages I ever use.
* [tagbar](https://github.com/preservim/tagbar): a sidebar chowing you the
layout of the current file. It helps me orient myself within the file/class
I'm currently working on, as well as easing the movement between
classes, functions etc...
* [vim-gitgutter](https://github.com/airblade/vim-gitgutter): shows Git
diff markers in the sidebar.
* [indentline](https://github.com/Yggdroot/indentLine): shows a visual line to
indicate which lines are on the same indentation level.
* vim-python-pep8-indent: makes Vim properly indent Python according to PEP8
* [vim-indent-object](https://github.com/michaeljsmith/vim-indent-object):
allows you to select the current indentation block using the same bindings as
paragraphs, inner brackets, etc...
* NERDTree: file browser, useful for getting your bearings in a large project.
* [vim-toml](https://github.com/cespare/vim-toml): syntax highlighting for toml
files
* [auto-pairs](https://github.com/jiangmiao/auto-pairs): auto-insert matching
pairs
* [Tabular](https://github.com/godlygeek/tabular): useful plugin for aligning
text
* [haskell-vim](https://github.com/neovimhaskell/haskell-vim): indentation for
Haskell
* [ion-vim](https://github.com/vmchale/ion-vim): syntax highlighting for the
[ion shell](https://github.com/redox-os/ion) (my current shell).

View file

@ -0,0 +1,38 @@
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~ '\s'
endfunction
inoremap <silent><expr> <Tab>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<Tab>" :
\ coc#refresh()
" Navigating through results list
" Tab to select next result
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
" Shift+Tab to select previous
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
" Use enter to confirm completion
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
" Select first option if no option is selected on enter
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm() : "\<C-g>u\<CR>"
" Project refactoring keybinding
nnoremap <silent> <leader>pwr :CocSearch <C-R>=expand("<cword>")<CR><CR>
" Go to definition
nmap gd <Plug>(coc-definition)
nmap gb <C-o>
nmap gi <Plug>(coc-implementation)
nmap gr <Plug>(coc-references)
" Jump between diagnostic positions
nmap <silent> <leader>dk <Plug>(coc-diagnostic-prev)
nmap <silent> <leader>dK <Plug>(coc-diagnostic-prev-error)
nmap <silent> <leader>dj <Plug>(coc-diagnostic-next)
nmap <silent> <leader>dJ <Plug>(coc-diagnostic-next-error)
" Show full diagnostics list
nmap <silent> <leader>dd :CocDiagnostics<CR>

View file

@ -0,0 +1,28 @@
" Remap CtrlP shortcut
let g:ctrlp_map = '<leader>t'
" Enable caching
" I think this'll make it run just a bit faster
let g:ctrlp_use_caching = 1
" Don't clear the cache on exit, so it won't re-index every time we open the
" project
let g:ctrlp_clear_cache_on_exit = 0
" Cache inside the project's .vim directory to keep things tidy
let g:ctrlp_cache_dir = './.vim/cache/ctrlp'
" You can define different listing commands for different version controls
" systems etc.
" I currently only have experience with Git, but I've written the config like
" this to allow for easy expansion if needed.
let g:ctrlp_user_command = {
\ 'types': {
\ 1: ['.git', 'git --git-dir=%s/.git ls-files -oc --exclude-standard']
\ },
\ 'fallback': 'find %s -type f'
\ }
" Limit max number of files
" This prevents me from indexing my entire HOME by accident
let g:ctrlp_max_files = 10000
" Also limit recursion depth
let g:ctrlp_max_depth = 40

View file

@ -0,0 +1,12 @@
" Key bindings for quicker Git work
" Status
nnoremap <silent> <leader>gg :Git<CR>
" Commit
nnoremap <silent> <leader>gc :Git commit<CR>
" Push
nnoremap <silent> <leader>gp :Git push<CR>
" Show diffs
nnoremap <silent> <leader>gd :Gvdiffsplit!<CR>
" Easily resolve merges
nnoremap <silent> <leader>gh :diffget //2<CR>
nnoremap <silent> <leader>gl :diffget //3<CR>

View file

@ -0,0 +1,2 @@
" Disable key mappings
let g:gitgutter_map_keys = 0

View file

@ -0,0 +1,2 @@
" Set name of tags file; should put it inside .vim directory
let g:gutentags_ctags_tagfile='.vim/tags'

View file

@ -0,0 +1,2 @@
" Make each indent level have a specific character
let g:indentLine_char_list = ['|', '¦', '┆', '┊']

View file

@ -0,0 +1,47 @@
" Listing of paths to ignore. I think I could use something similar to CtrlP
" here as well, but I want NERDTree to also show some non-version
" controlled files. It ignores the following files:
" Vim
" Other IDEs
" Python
" Java
" Git
" Stack & Haskell
" CMake
" Non-text files
let NERDTreeIgnore = [
\ '^\.vim$[[dir]]',
\ '^\.vscode$[[dir]]', '.*\.code-workspace$[[file]]', '^\.idea$[[dir]]',
\ '^__pycache__$[[dir]]', '^\.pytest_cache$[[dir]]', '^venv$[[dir]]',
\ '\.egg-info$[[dir]]', '^dist$[[dir]]', '^build$[[dir]]',
\ '^\.eggs$[[dir]]',
\ '^out$[[dir]]',
\ '^\.git$[[dir]]',
\ '^\.stack-work$[[dir]]', '\.lock$',
\ '^CMakeFiles$[[dir]]', '^CMakeCache.txt$[[file]]',
\ '.pdf$[[file]]']
" Show files starting with .
let NERDTreeShowHidden = 1
" Hide 'Press ? for help'
let NERDTreeMinimalUI = 1
let NERDTreeDirArrows = 1
" Close NERDTree after opening a file
let NERDTreeQuitOnOpen = 1
" Explicitely tell NERDTree to never change my current working directory
let NERDTreeChDirMode = 0
" Sort naturally, e.g. z10.txt comes after z1.txt
let NERDTreeNaturalSort = 1
" Show files, not only directories
let NERDTreeShowFiles = 1
" Don't show line numbers
let NERDTreeShowLineNumbers = 0
" Show NERDTree on the left side
let NERDTreeWinPos = 'left'
" Use the minimal menu system
let NERDTreeMinimalMenu = 1
" Always delete the buffer when you rename the file
let NERDTreeAutoDeleteBuffer = 1
" Open NERDTree on the current file
nnoremap <silent> tt :NERDTreeFind<CR>

View file

@ -0,0 +1,68 @@
" See README.md for more information about the plugins
"
" Load the plugins
call plug#begin('~/.config/nvim/plugged')
" Powerful auto-complete engine
" TODO switch to coc-jedi for Python stuff
Plug 'neoclide/coc.nvim', {'branch': 'release'}
" Fast file navigation using fuzzy search
Plug 'ctrlpvim/ctrlp.vim'
" Git client within Vim
Plug 'tpope/vim-fugitive'
" Change surrounding quotes, brackets...
Plug 'tpope/vim-surround'
" Comment out lines easily
Plug 'tpope/vim-commentary'
" Show ctags in sidebar, useful for navigation
Plug 'majutsushi/tagbar'
" Show Git diffs in sidebar
Plug 'airblade/vim-gitgutter'
" Show indentation using thin lines
Plug 'yggdroot/indentline'
" Auto-indent according to PEP8 rules
Plug 'hynek/vim-python-pep8-indent'
" Text object based on current indent level (e.g. Python)
Plug 'michaeljsmith/vim-indent-object'
" Sidebar showing file structure
Plug 'scrooloose/nerdtree'
" Toml syntax highlighting
Plug 'cespare/vim-toml'
" Auto-bracket pairs
Plug 'jiangmiao/auto-pairs'
" This plugin allows you to align text according to specified delimiters
" e.g. this:
" x = 5
" alongname = 15
" can become this:
" x = 15
" alongname = 15
Plug 'godlygeek/tabular'
" Some auto-complete for haskell
Plug 'neovimhaskell/haskell-vim'
Plug 'vmchale/ion-vim'
Plug 'Chiel92/vim-autoformat'
Plug 'leafoftree/vim-vue-plugin'
Plug 'othree/javascript-libraries-syntax.vim'
Plug 'udalov/kotlin-vim'
call plug#end()

View file

@ -0,0 +1,25 @@
" Navigating between tags
" Go to next top-level tag
let g:tagbar_map_nexttag = 'J'
" Same, but previous
let g:tagbar_map_prevtag = 'K'
" Show prototype of current tag
let g:tagbar_map_showproto = 'u'
" Use order from source file
let g:tagbar_sort = 0
" Don't show help tip at the top
let g:tagbar_compact = 1
" Auto-open folds while following cursor
let g:tagbar_autoshowtag = 1
" Don't show status line
let g:no_status_line = 1
" Close tagbar when a tag is selected
let g:tagbar_autoclose = 1
" Open tagbar when opening certain language types
" autocmd BufNewFile,BufReadPre *.py,*.java,*.rs,*.cpp,*.c,*.r TagbarOpen
" Explicitly close tagbar for these types
" autocmd BufNewFile,BufReadPre *.txt,*.rst TagbarClose
nnoremap <silent> tr :TagbarToggle<CR>

View file

@ -0,0 +1,63 @@
" Terminal
" As I often use non-standard shells, certain things can break if this isn't
" explicitely set
" TODO maybe use which to find the executable?
set shell=/bin/bash
" Makes your cursor centered whenever possible. 999 is just a large number,
" making it always centered
set scrolloff=999
" Colorscheme
" This forces (Neo)Vim to assume the terminal supports 256 colors.
" Without this, some colorschemes (including mine) don't work properly.
set termguicolors
" Set colorscheme
colorscheme flattened_dark
hi Normal guibg=NONE ctermbg=NONE
hi LineNr ctermfg=NONE ctermbg=NONE
" Line numbers
" I use the combination of absolute and relative line numbers. On the
" current line, it shows the absolute; on all the others, the relative.
set number relativenumber
" Splits
" I prefer the logic of 'open your main window first, and all other
" afterwards', so this makes a new file open below or to the right of the
" current one.
set splitbelow splitright
" Indentation
" I only use four spaces as indentation. This configures Vim to always use four
" spaces, for both manual tabs and automatic indentation.
set expandtab tabstop=4 shiftwidth=4
" Search functionality
" Show matches as pattern is being typed
set incsearch
" Ignore case as long as there are no capital letters in the pattern
set smartcase
" Don't hightlight search results after search is finished
set nohlsearch
" autocmd BufReadPre * call SetDirs()
" Turn on swap files
set swapfile
set directory=./.vim/swap//
" Create file backups
" set backup
" Store backups in .vim directory, next to swap files
" set backupdir=./.vim/backup/,
" Temporary, until I've found a fix
set nobackup
" Create an undo file for each file; this makes undo persistent
set undofile
set undodir=./.vim/undo//
" Increases speed of CoC and Gitgutter
set updatetime=250
" Make Vim use pipes instead of temp files when running commands
set noshelltemp