Initial commit

This commit is contained in:
jef 2020-08-08 20:27:01 +02:00
commit 864a4a2f08
18 changed files with 3585 additions and 0 deletions

19
init/coc.vim Normal file
View file

@ -0,0 +1,19 @@
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>"

8
init/ctrlp.vim Normal file
View file

@ -0,0 +1,8 @@
" Remap CtrlP shortcut
let g:ctrlp_map = '<leader>t'
" Disable caching
let g:ctrlp_use_caching = 0
" Only show files in git repo, ignoring .gitignore content
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files -co --exclude-standard']

9
init/git-fugitive.vim Normal file
View file

@ -0,0 +1,9 @@
" Key bindings for quicker Git work
" Status
nnoremap <silent> <leader>gg :Git<CR>
" Commit
nnoremap <silent> <leader>gc :Gcommit<CR>
" Push
nnoremap <silent> <leader>gp :Gpush<CR>
" Show diffs
nnoremap <silent> <leader>gd :Gdiffsplit<CR>

2
init/gitgutter.vim Normal file
View file

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

2
init/gutentags.vim Normal file
View file

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

2
init/indentline.vim Normal file
View file

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

75
init/keys.vim Normal file
View file

@ -0,0 +1,75 @@
" Keep cursor centered as much as possible
nnoremap j jzz
nnoremap k kzz
nnoremap gg ggzz
nnoremap G Gzz
" Navigate between ctags
" Jump to definition
nnoremap gd <C-]>
" Go back up stack
nnoremap gb <C-t>
" Remap split navigation keybindings
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>
" Write using <leader>+w
nnoremap <silent> <leader>w :w<CR>
" Quit using <leader>+q
nnoremap <silent> <leader>q :q<CR>
" Use arrow keys for split resizing in normal mode
nnoremap <silent> <Up> :resize +3<CR>
nnoremap <silent> <Down> :resize -3<CR>
nnoremap <silent> <Right> :vertical resize +3<CR>
nnoremap <silent> <Left> :vertical resize -3<CR>
" Disable arrow keys in editing & visual mode
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
" 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>
" Make commands
nnoremap <silent> <leader>mr :make! run<CR>
nnoremap <silent> <leader>mt :make! test<CR>
" Built-in Terminal
" Remap <Esc> in terminal
tnoremap <silent> <Esc> <C-\><C-n>
" Open terminal in horizontal split
nnoremap <silent> <leader>s :split<CR>:terminal<CR>
" Keybinding for switching between light/dark colorschemes
function! ColorschemeToggle()
if g:colors_name == 'flattened_dark'
colorscheme flattened_light
else
colorscheme flattened_dark
endif
endfunction
nnoremap <silent> <leader>c :call ColorschemeToggle()<CR>
" Quick config editing
" Re-source vimrc/init.vim
nnoremap <silent> <leader>vs :source $MYVIMRC<CR>
" Open CtrlP in config directory
nnoremap <silent> <leader>ve :split<CR>:exec 'CtrlP ' . fnamemodify($MYVIMRC, ':h')<CR>

35
init/plugins.vim Normal file
View file

@ -0,0 +1,35 @@
" =====PLUGINS=====
" Load the plugins
call plug#begin('~/.config/nvim/plugged')
" Create ctags file asynchonously
Plug 'ludovicchabant/vim-gutentags', { 'commit': '31c0ead' }
" Fuzzy file 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'
" Powerful auto-complete engine
Plug 'neoclide/coc.nvim', {'branch': 'release'}
" 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'
call plug#end()

60
init/settings.vim Normal file
View file

@ -0,0 +1,60 @@
" Colorscheme
" Tell Neovim to use 256 colors
set termguicolors
" Set colorscheme
colorscheme flattened_dark
" Line numbers
" Show absolute line number on current line
set number
" Show relative line number on all other lines
set relativenumber
" Splits
" Make horizontal splits appear below active window
set splitbelow
" Same for vertical splits, but to the right of active window
set splitright
" Indentation
" Replace tabs with spaces
set expandtab
" Width of a tab; with expandtab on, this sets by how many spaces it should be
" replaced
set tabstop=4
" Number of spaces that should be used for auto indentation
set 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
function SetDirs()
let filedir = expand('%:h')
let &l:directory = filedir . '/.vim/swap'
let &l:undodir = filedir . '/.vim/undo'
endfunction
" 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//
" Detect comments in json
autocmd FileType json syntax match Comment +\/\/.\+$+
" Increases speed of CoC and Gitgutter
set updatetime=250

13
init/tagbar.vim Normal file
View file

@ -0,0 +1,13 @@
" Navigating between tags
" Go to next one
let g:tagbar_map_nexttag = 'j'
" Go to previous one
let g:tagbar_map_prevtag = 'k'
" Show prototype of current tag
let g:tagbar_map_showproto = 'u'
" Open tagbar when opening certain language types
autocmd BufNewFile,BufReadPre *.py,*.java,*.rs,*.cpp,*.c TagbarOpen
" Explicitly close tagbar for these types
autocmd BufNewFile,BufReadPre *.md,*.vim,*.txt TagbarClose