mirror of
https://github.com/nmasur/dotfiles
synced 2024-12-24 16:34:53 +00:00
change vimrc to individual files
This commit is contained in:
parent
511f0b808a
commit
67bba74816
@ -1,319 +1,14 @@
|
||||
" Vim Config
|
||||
|
||||
" Plugins
|
||||
"--------
|
||||
|
||||
" Install vim-plugged if not installed
|
||||
if empty(glob('~/.config/nvim/autoload/plug.vim'))
|
||||
silent !curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs
|
||||
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
||||
autocmd VimEnter * PlugInstall --sync | source ~/.config/nvim/init.vim
|
||||
endif
|
||||
|
||||
" All plugins
|
||||
call plug#begin('~/.config/nvim/plugged')
|
||||
|
||||
" Core plugins
|
||||
Plug 'morhetz/gruvbox' " Colorscheme
|
||||
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } " Required for fuzzyfinder
|
||||
Plug 'junegunn/fzf.vim' " Actual fuzzyfinder
|
||||
Plug 'tpope/vim-surround' " Enables paren editing
|
||||
Plug 'sheerun/vim-polyglot' " Syntax for every language
|
||||
Plug 'airblade/vim-gitgutter' " Git next to line numbers
|
||||
Plug 'tpope/vim-commentary' " Use gc or gcc to comment
|
||||
Plug 'godlygeek/tabular' " Spacing and alignment
|
||||
|
||||
" Ancillary plugins
|
||||
Plug 'unblevable/quick-scope' " Hints for f and t
|
||||
Plug 'vimwiki/vimwiki' " Wiki Markdown System
|
||||
Plug 'jreybert/vimagit' " Git 'gui' buffer
|
||||
Plug 'airblade/vim-rooter' " Change directory to git route
|
||||
Plug 'tpope/vim-fugitive' " Other git commands
|
||||
Plug 'machakann/vim-highlightedyank' " Highlight text when copied
|
||||
Plug 'itchyny/lightline.vim' " Status bar
|
||||
Plug 'tpope/vim-vinegar' " Fixes netrw file explorer
|
||||
Plug 'lambdalisue/fern.vim' " File explorer / project drawer
|
||||
Plug 'christoomey/vim-tmux-navigator' " Hotkeys for tmux panes
|
||||
|
||||
" CoC (Language Server Protocol, requires NodeJS)
|
||||
Plug 'neoclide/coc.nvim', {'branch': 'release'} " Code completion
|
||||
|
||||
call plug#end()
|
||||
|
||||
" Basic Settings
|
||||
filetype plugin on " Load the plugin for current filetype (vimwiki)
|
||||
syntax enable " Syntax highlighting
|
||||
set termguicolors " Set to truecolor
|
||||
colorscheme gruvbox " Installed in autoload/ and colors/
|
||||
|
||||
" Options
|
||||
set hidden " Don't unload buffers when leaving them
|
||||
set number " Show line numbers
|
||||
set relativenumber " Relative numbers instead of absolute
|
||||
set list " Reveal whitespace with ---
|
||||
set expandtab " Tabs into spaces
|
||||
set shiftwidth=4 " Amount to shift with > key
|
||||
set softtabstop=4 " Amount to shift with <TAB> key
|
||||
set ignorecase " Ignore case when searching
|
||||
set smartcase " Check case when using capitals in search
|
||||
set infercase " Don't match cases when completing suggestions
|
||||
set incsearch " Search while typing
|
||||
set visualbell " No sounds
|
||||
set scrolljump=1 " Scroll more than one line (or 1 line)
|
||||
set scrolloff=3 " Margin of lines when to start scrolling
|
||||
set splitright " Vertical splits on the right side
|
||||
set splitbelow " Horizontal splits on the lower side
|
||||
set pastetoggle=<F3> " Use F3 to enter raw paste mode
|
||||
set clipboard+=unnamedplus " Uses system clipboard for yanking
|
||||
set updatetime=300 " Faster diagnostics
|
||||
set mouse=nv " Mouse interaction / scrolling
|
||||
|
||||
" Neovim only
|
||||
set inccommand=split " Live preview search and replace
|
||||
|
||||
" Remember last position when reopening file
|
||||
if has("autocmd")
|
||||
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
|
||||
endif
|
||||
|
||||
" Better backup, swap and undo storage
|
||||
set noswapfile " Instead of swaps, create backups (less annoying)
|
||||
set backup " Easier to recover and more secure
|
||||
set undofile " Keeps undos after quit
|
||||
set backupdir=~/.config/nvim/dirs/backup
|
||||
set undodir=~/.config/nvim/dirs/undo
|
||||
|
||||
" Keep selection when tabbing
|
||||
vnoremap < <gv
|
||||
vnoremap > >gv
|
||||
|
||||
" Create backup directories if they don't exist
|
||||
if !isdirectory(&backupdir)
|
||||
call mkdir(&backupdir, "p")
|
||||
endif
|
||||
if !isdirectory(&undodir)
|
||||
call mkdir(&undodir, "p")
|
||||
endif
|
||||
|
||||
" Custom Commands
|
||||
"----------------
|
||||
|
||||
command! Vimrc edit $MYVIMRC " Edit .vimrc (this file)
|
||||
command! Refresh source $MYVIMRC " Refresh from .vimrc (this file)
|
||||
|
||||
" Custom Keybinds
|
||||
"----------------
|
||||
|
||||
" Map the leader key
|
||||
map <Space> <Leader>
|
||||
|
||||
"This unsets the `last search pattern` register by hitting return
|
||||
nnoremap <silent> <CR> :noh<CR><CR>
|
||||
|
||||
" Replace all
|
||||
nnoremap <Leader>S :%s//g<Left><Left>
|
||||
|
||||
" Jump to text in this directory
|
||||
nnoremap <Leader>/ :Rg<CR>
|
||||
|
||||
" Quit vim
|
||||
nnoremap <Leader>q :quit<cr>
|
||||
nnoremap <Leader>Q :quitall<cr>
|
||||
|
||||
" Save file
|
||||
nnoremap <Leader>fs :write<cr>
|
||||
|
||||
" Make file executable
|
||||
nnoremap <silent> <Leader>fe :!chmod 755 %<cr><cr>
|
||||
|
||||
" Make file normal permissions
|
||||
nnoremap <silent> <Leader>fn :!chmod 644 %<cr><cr>
|
||||
|
||||
" Open file in this directory
|
||||
nnoremap <Leader>ff :Files<cr>
|
||||
|
||||
" Change directory to this file
|
||||
nnoremap <silent> <Leader>fd :lcd %:p:h<cr>
|
||||
|
||||
" Back up directory
|
||||
nnoremap <silent> <Leader>fu :lcd ..<cr>
|
||||
|
||||
" Open a recent file
|
||||
nnoremap <Leader>fr :History<cr>
|
||||
|
||||
" Switch between multiple open files
|
||||
nnoremap <Leader>bb :Buffers<cr>
|
||||
|
||||
" Jump to text in this file
|
||||
nnoremap <Leader>s :BLines<cr>
|
||||
|
||||
" Start Magit buffer
|
||||
nnoremap <Leader>gs :Magit<cr>
|
||||
|
||||
" Toggle Git gutter (by line numbers)
|
||||
nnoremap <Leader>` :GitGutterToggle<cr>
|
||||
|
||||
" Git push
|
||||
nnoremap <Leader>gp :Git push<cr>
|
||||
|
||||
" Split window
|
||||
nnoremap <Leader>ws :vsplit<cr>
|
||||
|
||||
" Close all other splits
|
||||
nnoremap <Leader>wm :only<cr>
|
||||
|
||||
" Exit terminal mode (requires Alacritty escape)
|
||||
tnoremap <S-CR> <C-\><C-n>
|
||||
|
||||
" Reload Vimrc settings
|
||||
nnoremap <Leader>rr :Refresh<cr>
|
||||
nnoremap <Leader>rp :Refresh<cr> :PlugInstall<cr>
|
||||
|
||||
" Open file tree
|
||||
noremap <silent> <Leader>ft :Fern . -drawer -width=35 -toggle<CR><C-w>=
|
||||
|
||||
" Tabularize
|
||||
nnoremap <Leader>ta :Tabularize /
|
||||
nnoremap <Leader>t# :Tabularize /#<CR>
|
||||
nnoremap <Leader>t" :Tabularize /"<CR>
|
||||
|
||||
" Snippets
|
||||
"---------
|
||||
|
||||
" Basic programming files
|
||||
nnoremap ,sh :-1read $DOTS/shell/templates/skeleton.sh<CR>Gdd03kC
|
||||
nnoremap ,py :-1read $DOTS/shell/templates/skeleton.py<CR>Gdd08kC
|
||||
|
||||
" Kubernetes
|
||||
nnoremap ,cm :-1read $DOTS/shell/templates/configmap.yaml<CR>Gdd0gg
|
||||
nnoremap ,sec :-1read $DOTS/shell/templates/secret.yaml<CR>Gdd0gg
|
||||
nnoremap ,dep :-1read $DOTS/shell/templates/deployment.yaml<CR>Gdd0gg
|
||||
nnoremap ,svc :-1read $DOTS/shell/templates/service.yaml<CR>Gdd0gg
|
||||
nnoremap ,cro :-1read $DOTS/shell/templates/clusterrole.yaml<CR>Gdd0gg
|
||||
nnoremap ,crb :-1read $DOTS/shell/templates/clusterrolebinding.yaml<CR>Gdd0gg
|
||||
nnoremap ,ro :-1read $DOTS/shell/templates/role.yaml<CR>Gdd0gg
|
||||
nnoremap ,rb :-1read $DOTS/shell/templates/rolebinding.yaml<CR>Gdd0gg
|
||||
nnoremap ,sa :-1read $DOTS/shell/templates/serviceaccount.yaml<CR>Gdd0gg
|
||||
|
||||
" LaTeX Settings
|
||||
"---------------
|
||||
|
||||
" LaTeX Hotkeys
|
||||
autocmd FileType tex inoremap ;bf \textbf{}<Esc>i
|
||||
" Jump to the next occurence of <> and replace it with insert mode
|
||||
autocmd FileType tex nnoremap <Leader><Space> /<><Esc>:noh<CR>c2l
|
||||
|
||||
" Autocompile LaTeX on save
|
||||
autocmd BufWritePost *.tex silent! execute "!pdflatex -output-directory=%:p:h % >/dev/null 2>&1" | redraw!
|
||||
|
||||
" Plugin Settings
|
||||
"----------------
|
||||
|
||||
" Built-in file explorer plugin
|
||||
let g:netrw_liststyle = 3 " Change style to 'tree' view
|
||||
let g:netrw_banner = 0 " Remove useless banner
|
||||
let g:netrw_winsize = 15 " Explore window takes % of page
|
||||
let g:netrw_browse_split = 4 " Open in previous window
|
||||
let g:netrw_altv = 1 " Always split left
|
||||
|
||||
" Gitgutter plugin
|
||||
let g:gitgutter_enabled = 1 " Enabled on start
|
||||
|
||||
" Polyglot syntax plugin
|
||||
let g:terraform_fmt_on_save=1 " Formats with terraform plugin
|
||||
let g:rustfmt_autosave = 1 " Formats with rust plugin
|
||||
|
||||
" VimWiki plugin
|
||||
let g:vimwiki_list = [
|
||||
\ {
|
||||
\ 'path': $NOTES_PATH,
|
||||
\ 'syntax': 'markdown',
|
||||
\ 'index': 'home',
|
||||
\ 'ext': '.md'
|
||||
\ }
|
||||
\ ]
|
||||
let g:vimwiki_key_mappings =
|
||||
\ {
|
||||
\ 'all_maps': 1,
|
||||
\ 'mouse': 1,
|
||||
\ }
|
||||
let g:vimwiki_auto_chdir = 1
|
||||
|
||||
" Quickscope only highlight on keypress
|
||||
let g:qs_highlight_on_keys = ['f', 'F', 't', 'T']
|
||||
|
||||
" Lightline status bar plugin
|
||||
let g:lightline = {
|
||||
\ 'colorscheme': 'jellybeans',
|
||||
\ 'active': {
|
||||
\ 'right': [[ 'lineinfo' ]],
|
||||
\ 'left': [[ 'mode', 'paste' ],
|
||||
\ [ 'cocstatus', 'readonly', 'relativepath', 'gitbranch', 'modified' ]]
|
||||
\ },
|
||||
\ 'component_function': {
|
||||
\ 'gitbranch': 'fugitive#head',
|
||||
\ 'cocstatus': 'coc#status'
|
||||
\ },
|
||||
\ }
|
||||
|
||||
" CoC Settings
|
||||
"-------------
|
||||
|
||||
" Extensions to auto-install and enable
|
||||
let g:coc_global_extensions = [
|
||||
\ 'coc-rust-analyzer',
|
||||
\ 'coc-pairs',
|
||||
\ 'coc-diagnostic',
|
||||
\ ]
|
||||
|
||||
" Set tab to completion
|
||||
inoremap <silent><expr> <TAB>
|
||||
\ pumvisible() ? "\<C-n>" :
|
||||
\ <SID>check_back_space() ? "\<TAB>" :
|
||||
\ coc#refresh()
|
||||
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
|
||||
|
||||
function! s:check_back_space() abort
|
||||
let col = col('.') - 1
|
||||
return !col || getline('.')[col - 1] =~# '\s'
|
||||
endfunction
|
||||
|
||||
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
|
||||
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
|
||||
|
||||
" Use `[g` and `]g` to navigate diagnostics
|
||||
" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list.
|
||||
nmap <silent> [g <Plug>(coc-diagnostic-prev)
|
||||
nmap <silent> ]g <Plug>(coc-diagnostic-next)
|
||||
|
||||
" GoTo code navigation.
|
||||
nmap <silent> gd <Plug>(coc-definition)
|
||||
nmap <silent> gy <Plug>(coc-type-definition)
|
||||
nmap <silent> gi <Plug>(coc-implementation)
|
||||
nmap <silent> gr <Plug>(coc-references)
|
||||
|
||||
" Use K to show documentation in preview window.
|
||||
nnoremap <silent> K :call <SID>show_documentation()<CR>
|
||||
|
||||
function! s:show_documentation()
|
||||
if (index(['vim','help'], &filetype) >= 0)
|
||||
execute 'h '.expand('<cword>')
|
||||
else
|
||||
call CocAction('doHover')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Highlight the symbol and its references when holding the cursor.
|
||||
" Uses updatetime for delay before showing info.
|
||||
autocmd CursorHold * silent call CocActionAsync('highlight')
|
||||
|
||||
" Symbol renaming.
|
||||
nmap <leader>rn <Plug>(coc-rename)
|
||||
|
||||
" Use CTRL-S for selections ranges.
|
||||
" Requires 'textDocument/selectionRange' support of LS, ex: coc-tsserver
|
||||
nmap <silent> <C-s> <Plug>(coc-range-select)
|
||||
xmap <silent> <C-s> <Plug>(coc-range-select)
|
||||
|
||||
" Use autocmd to force lightline update.
|
||||
autocmd User CocStatusChange,CocDiagnosticChange call lightline#update()
|
||||
source $HOME/.config/nvim/settings/plugins.vim " Plugins from vim-plug
|
||||
source $HOME/.config/nvim/settings/general.vim " General settings
|
||||
source $HOME/.config/nvim/settings/custom.vim " Custom commands and binds
|
||||
source $HOME/.config/nvim/settings/snippets.vim " Handwritten snippets
|
||||
source $HOME/.config/nvim/settings/latex.vim " LaTeX settings
|
||||
source $HOME/.config/nvim/settings/netrw.vim " File explorer settings
|
||||
source $HOME/.config/nvim/settings/gitgutter.vim " Gitgutter plugin settings
|
||||
source $HOME/.config/nvim/settings/polyglot.vim " Polyglot plugin settings
|
||||
source $HOME/.config/nvim/settings/vimwiki.vim " VimWiki plugin settings
|
||||
source $HOME/.config/nvim/settings/quickscope.vim " Quickscope plugin settings
|
||||
source $HOME/.config/nvim/settings/lightline.vim " Lightline plugin settings
|
||||
source $HOME/.config/nvim/settings/coc.vim " CoC plugins settings
|
||||
|
61
nvim.configlink/settings/coc.vim
Normal file
61
nvim.configlink/settings/coc.vim
Normal file
@ -0,0 +1,61 @@
|
||||
" CoC Settings
|
||||
"-------------
|
||||
|
||||
" Extensions to auto-install and enable
|
||||
let g:coc_global_extensions = [
|
||||
\ 'coc-rust-analyzer',
|
||||
\ 'coc-pairs',
|
||||
\ 'coc-diagnostic',
|
||||
\ ]
|
||||
|
||||
" Set tab to completion
|
||||
inoremap <silent><expr> <TAB>
|
||||
\ pumvisible() ? "\<C-n>" :
|
||||
\ <SID>check_back_space() ? "\<TAB>" :
|
||||
\ coc#refresh()
|
||||
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
|
||||
|
||||
function! s:check_back_space() abort
|
||||
let col = col('.') - 1
|
||||
return !col || getline('.')[col - 1] =~# '\s'
|
||||
endfunction
|
||||
|
||||
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
|
||||
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
|
||||
|
||||
" Use `[g` and `]g` to navigate diagnostics
|
||||
" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list.
|
||||
nmap <silent> [g <Plug>(coc-diagnostic-prev)
|
||||
nmap <silent> ]g <Plug>(coc-diagnostic-next)
|
||||
|
||||
" GoTo code navigation.
|
||||
nmap <silent> gd <Plug>(coc-definition)
|
||||
nmap <silent> gy <Plug>(coc-type-definition)
|
||||
nmap <silent> gi <Plug>(coc-implementation)
|
||||
nmap <silent> gr <Plug>(coc-references)
|
||||
|
||||
" Use K to show documentation in preview window.
|
||||
nnoremap <silent> K :call <SID>show_documentation()<CR>
|
||||
|
||||
function! s:show_documentation()
|
||||
if (index(['vim','help'], &filetype) >= 0)
|
||||
execute 'h '.expand('<cword>')
|
||||
else
|
||||
call CocAction('doHover')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Highlight the symbol and its references when holding the cursor.
|
||||
" Uses updatetime for delay before showing info.
|
||||
autocmd CursorHold * silent call CocActionAsync('highlight')
|
||||
|
||||
" Symbol renaming.
|
||||
nmap <leader>rn <Plug>(coc-rename)
|
||||
|
||||
" Use CTRL-S for selections ranges.
|
||||
" Requires 'textDocument/selectionRange' support of LS, ex: coc-tsserver
|
||||
nmap <silent> <C-s> <Plug>(coc-range-select)
|
||||
xmap <silent> <C-s> <Plug>(coc-range-select)
|
||||
|
||||
" Use autocmd to force lightline update.
|
||||
autocmd User CocStatusChange,CocDiagnosticChange call lightline#update()
|
84
nvim.configlink/settings/custom.vim
Normal file
84
nvim.configlink/settings/custom.vim
Normal file
@ -0,0 +1,84 @@
|
||||
" Custom Commands
|
||||
"----------------
|
||||
|
||||
command! Vimrc edit $MYVIMRC " Edit .vimrc (this file)
|
||||
command! Refresh source $MYVIMRC " Refresh from .vimrc (this file)
|
||||
|
||||
" Custom Keybinds
|
||||
"----------------
|
||||
|
||||
" Map the leader key
|
||||
map <Space> <Leader>
|
||||
|
||||
"This unsets the `last search pattern` register by hitting return
|
||||
nnoremap <silent> <CR> :noh<CR><CR>
|
||||
|
||||
" Replace all
|
||||
nnoremap <Leader>S :%s//g<Left><Left>
|
||||
|
||||
" Jump to text in this directory
|
||||
nnoremap <Leader>/ :Rg<CR>
|
||||
|
||||
" Quit vim
|
||||
nnoremap <Leader>q :quit<cr>
|
||||
nnoremap <Leader>Q :quitall<cr>
|
||||
|
||||
" Save file
|
||||
nnoremap <Leader>fs :write<cr>
|
||||
|
||||
" Make file executable
|
||||
nnoremap <silent> <Leader>fe :!chmod 755 %<cr><cr>
|
||||
|
||||
" Make file normal permissions
|
||||
nnoremap <silent> <Leader>fn :!chmod 644 %<cr><cr>
|
||||
|
||||
" Open file in this directory
|
||||
nnoremap <Leader>ff :Files<cr>
|
||||
|
||||
" Change directory to this file
|
||||
nnoremap <silent> <Leader>fd :lcd %:p:h<cr>
|
||||
|
||||
" Back up directory
|
||||
nnoremap <silent> <Leader>fu :lcd ..<cr>
|
||||
|
||||
" Open a recent file
|
||||
nnoremap <Leader>fr :History<cr>
|
||||
|
||||
" Switch between multiple open files
|
||||
nnoremap <Leader>b :Buffers<cr>
|
||||
|
||||
" Switch between two open files
|
||||
nnoremap <Leader><Tab> :b#<cr>
|
||||
|
||||
" Jump to text in this file
|
||||
nnoremap <Leader>s :BLines<cr>
|
||||
|
||||
" Start Magit buffer
|
||||
nnoremap <Leader>gs :Magit<cr>
|
||||
|
||||
" Toggle Git gutter (by line numbers)
|
||||
nnoremap <Leader>` :GitGutterToggle<cr>
|
||||
|
||||
" Git push
|
||||
nnoremap <Leader>gp :Git push<cr>
|
||||
|
||||
" Split window
|
||||
nnoremap <Leader>ws :vsplit<cr>
|
||||
|
||||
" Close all other splits
|
||||
nnoremap <Leader>wm :only<cr>
|
||||
|
||||
" Exit terminal mode (requires Alacritty escape)
|
||||
tnoremap <S-CR> <C-\><C-n>
|
||||
|
||||
" Reload Vimrc settings
|
||||
nnoremap <Leader>rr :Refresh<cr>
|
||||
nnoremap <Leader>rp :Refresh<cr> :PlugInstall<cr>
|
||||
|
||||
" Open file tree
|
||||
noremap <silent> <Leader>ft :Fern . -drawer -width=35 -toggle<CR><C-w>=
|
||||
|
||||
" Tabularize
|
||||
nnoremap <Leader>ta :Tabularize /
|
||||
nnoremap <Leader>t# :Tabularize /#<CR>
|
||||
nnoremap <Leader>t" :Tabularize /"<CR>
|
57
nvim.configlink/settings/general.vim
Normal file
57
nvim.configlink/settings/general.vim
Normal file
@ -0,0 +1,57 @@
|
||||
" General
|
||||
"--------
|
||||
|
||||
" Basic Settings
|
||||
filetype plugin on " Load the plugin for current filetype (vimwiki)
|
||||
syntax enable " Syntax highlighting
|
||||
set termguicolors " Set to truecolor
|
||||
colorscheme gruvbox " Installed in autoload/ and colors/
|
||||
|
||||
" Options
|
||||
set hidden " Don't unload buffers when leaving them
|
||||
set number " Show line numbers
|
||||
set relativenumber " Relative numbers instead of absolute
|
||||
set list " Reveal whitespace with ---
|
||||
set expandtab " Tabs into spaces
|
||||
set shiftwidth=4 " Amount to shift with > key
|
||||
set softtabstop=4 " Amount to shift with <TAB> key
|
||||
set ignorecase " Ignore case when searching
|
||||
set smartcase " Check case when using capitals in search
|
||||
set infercase " Don't match cases when completing suggestions
|
||||
set incsearch " Search while typing
|
||||
set visualbell " No sounds
|
||||
set scrolljump=1 " Scroll more than one line (or 1 line)
|
||||
set scrolloff=3 " Margin of lines when to start scrolling
|
||||
set splitright " Vertical splits on the right side
|
||||
set splitbelow " Horizontal splits on the lower side
|
||||
set pastetoggle=<F3> " Use F3 to enter raw paste mode
|
||||
set clipboard+=unnamedplus " Uses system clipboard for yanking
|
||||
set updatetime=300 " Faster diagnostics
|
||||
set mouse=nv " Mouse interaction / scrolling
|
||||
|
||||
" Neovim only
|
||||
set inccommand=split " Live preview search and replace
|
||||
|
||||
" Remember last position when reopening file
|
||||
if has("autocmd")
|
||||
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
|
||||
endif
|
||||
|
||||
" Better backup, swap and undo storage
|
||||
set noswapfile " Instead of swaps, create backups (less annoying)
|
||||
set backup " Easier to recover and more secure
|
||||
set undofile " Keeps undos after quit
|
||||
set backupdir=~/.config/nvim/dirs/backup
|
||||
set undodir=~/.config/nvim/dirs/undo
|
||||
|
||||
" Keep selection when tabbing
|
||||
vnoremap < <gv
|
||||
vnoremap > >gv
|
||||
|
||||
" Create backup directories if they don't exist
|
||||
if !isdirectory(&backupdir)
|
||||
call mkdir(&backupdir, "p")
|
||||
endif
|
||||
if !isdirectory(&undodir)
|
||||
call mkdir(&undodir, "p")
|
||||
endif
|
4
nvim.configlink/settings/gitgutter.vim
Normal file
4
nvim.configlink/settings/gitgutter.vim
Normal file
@ -0,0 +1,4 @@
|
||||
" Gitgutter plugin
|
||||
"----------------
|
||||
|
||||
let g:gitgutter_enabled = 1 " Enabled on start
|
10
nvim.configlink/settings/latex.vim
Normal file
10
nvim.configlink/settings/latex.vim
Normal file
@ -0,0 +1,10 @@
|
||||
" LaTeX Settings
|
||||
"---------------
|
||||
|
||||
" LaTeX Hotkeys
|
||||
autocmd FileType tex inoremap ;bf \textbf{}<Esc>i
|
||||
" Jump to the next occurence of <> and replace it with insert mode
|
||||
autocmd FileType tex nnoremap <Leader><Space> /<><Esc>:noh<CR>c2l
|
||||
|
||||
" Autocompile LaTeX on save
|
||||
autocmd BufWritePost *.tex silent! execute "!pdflatex -output-directory=%:p:h % >/dev/null 2>&1" | redraw!
|
15
nvim.configlink/settings/lightline.vim
Normal file
15
nvim.configlink/settings/lightline.vim
Normal file
@ -0,0 +1,15 @@
|
||||
" Lightline Status Bar
|
||||
"---------------------
|
||||
|
||||
let g:lightline = {
|
||||
\ 'colorscheme': 'jellybeans',
|
||||
\ 'active': {
|
||||
\ 'right': [[ 'lineinfo' ]],
|
||||
\ 'left': [[ 'mode', 'paste' ],
|
||||
\ [ 'cocstatus', 'readonly', 'relativepath', 'gitbranch', 'modified' ]]
|
||||
\ },
|
||||
\ 'component_function': {
|
||||
\ 'gitbranch': 'fugitive#head',
|
||||
\ 'cocstatus': 'coc#status'
|
||||
\ },
|
||||
\ }
|
9
nvim.configlink/settings/netrw.vim
Normal file
9
nvim.configlink/settings/netrw.vim
Normal file
@ -0,0 +1,9 @@
|
||||
" Plugin Settings
|
||||
"----------------
|
||||
|
||||
" Built-in file explorer plugin
|
||||
let g:netrw_liststyle = 3 " Change style to 'tree' view
|
||||
let g:netrw_banner = 0 " Remove useless banner
|
||||
let g:netrw_winsize = 15 " Explore window takes % of page
|
||||
let g:netrw_browse_split = 4 " Open in previous window
|
||||
let g:netrw_altv = 1 " Always split left
|
39
nvim.configlink/settings/plugins.vim
Normal file
39
nvim.configlink/settings/plugins.vim
Normal file
@ -0,0 +1,39 @@
|
||||
" Plugins
|
||||
"--------
|
||||
|
||||
" Install vim-plugged if not installed
|
||||
if empty(glob('$HOME/.config/nvim/autoload/plug.vim'))
|
||||
silent !curl -fLo $HOME/.config/nvim/autoload/plug.vim --create-dirs
|
||||
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
||||
autocmd VimEnter * PlugInstall --sync | source $HOME/.config/nvim/init.vim
|
||||
endif
|
||||
|
||||
" All plugins
|
||||
call plug#begin('$HOME/.config/nvim/plugged')
|
||||
|
||||
" Core plugins
|
||||
Plug 'morhetz/gruvbox' " Colorscheme
|
||||
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } " Required for fuzzyfinder
|
||||
Plug 'junegunn/fzf.vim' " Actual fuzzyfinder
|
||||
Plug 'tpope/vim-surround' " Enables paren editing
|
||||
Plug 'sheerun/vim-polyglot' " Syntax for every language
|
||||
Plug 'airblade/vim-gitgutter' " Git next to line numbers
|
||||
Plug 'tpope/vim-commentary' " Use gc or gcc to comment
|
||||
Plug 'godlygeek/tabular' " Spacing and alignment
|
||||
|
||||
" Ancillary plugins
|
||||
Plug 'unblevable/quick-scope' " Hints for f and t
|
||||
Plug 'vimwiki/vimwiki' " Wiki Markdown System
|
||||
Plug 'jreybert/vimagit' " Git 'gui' buffer
|
||||
Plug 'airblade/vim-rooter' " Change directory to git route
|
||||
Plug 'tpope/vim-fugitive' " Other git commands
|
||||
Plug 'machakann/vim-highlightedyank' " Highlight text when copied
|
||||
Plug 'itchyny/lightline.vim' " Status bar
|
||||
Plug 'tpope/vim-vinegar' " Fixes netrw file explorer
|
||||
Plug 'lambdalisue/fern.vim' " File explorer / project drawer
|
||||
Plug 'christoomey/vim-tmux-navigator' " Hotkeys for tmux panes
|
||||
|
||||
" CoC (Language Server Protocol, requires NodeJS)
|
||||
Plug 'neoclide/coc.nvim', {'branch': 'release'} " Code completion
|
||||
|
||||
call plug#end()
|
5
nvim.configlink/settings/polyglot.vim
Normal file
5
nvim.configlink/settings/polyglot.vim
Normal file
@ -0,0 +1,5 @@
|
||||
" Polyglot Syntax
|
||||
"----------------
|
||||
|
||||
let g:terraform_fmt_on_save=1 " Formats with terraform plugin
|
||||
let g:rustfmt_autosave = 1 " Formats with rust plugin
|
5
nvim.configlink/settings/quickscope.vim
Normal file
5
nvim.configlink/settings/quickscope.vim
Normal file
@ -0,0 +1,5 @@
|
||||
" Quickscope
|
||||
"-----------
|
||||
|
||||
" Only highlight on keypress
|
||||
let g:qs_highlight_on_keys = ['f', 'F', 't', 'T']
|
17
nvim.configlink/settings/snippets.vim
Normal file
17
nvim.configlink/settings/snippets.vim
Normal file
@ -0,0 +1,17 @@
|
||||
" Snippets
|
||||
"---------
|
||||
|
||||
" Basic programming files
|
||||
nnoremap ,sh :-1read $DOTS/shell/templates/skeleton.sh<CR>Gdd03kC
|
||||
nnoremap ,py :-1read $DOTS/shell/templates/skeleton.py<CR>Gdd08kC
|
||||
|
||||
" Kubernetes
|
||||
nnoremap ,cm :-1read $DOTS/shell/templates/configmap.yaml<CR>Gdd0gg
|
||||
nnoremap ,sec :-1read $DOTS/shell/templates/secret.yaml<CR>Gdd0gg
|
||||
nnoremap ,dep :-1read $DOTS/shell/templates/deployment.yaml<CR>Gdd0gg
|
||||
nnoremap ,svc :-1read $DOTS/shell/templates/service.yaml<CR>Gdd0gg
|
||||
nnoremap ,cro :-1read $DOTS/shell/templates/clusterrole.yaml<CR>Gdd0gg
|
||||
nnoremap ,crb :-1read $DOTS/shell/templates/clusterrolebinding.yaml<CR>Gdd0gg
|
||||
nnoremap ,ro :-1read $DOTS/shell/templates/role.yaml<CR>Gdd0gg
|
||||
nnoremap ,rb :-1read $DOTS/shell/templates/rolebinding.yaml<CR>Gdd0gg
|
||||
nnoremap ,sa :-1read $DOTS/shell/templates/serviceaccount.yaml<CR>Gdd0gg
|
17
nvim.configlink/settings/vimwiki.vim
Normal file
17
nvim.configlink/settings/vimwiki.vim
Normal file
@ -0,0 +1,17 @@
|
||||
" VimWiki
|
||||
"--------
|
||||
|
||||
let g:vimwiki_list = [
|
||||
\ {
|
||||
\ 'path': $NOTES_PATH,
|
||||
\ 'syntax': 'markdown',
|
||||
\ 'index': 'home',
|
||||
\ 'ext': '.md'
|
||||
\ }
|
||||
\ ]
|
||||
let g:vimwiki_key_mappings =
|
||||
\ {
|
||||
\ 'all_maps': 1,
|
||||
\ 'mouse': 1,
|
||||
\ }
|
||||
let g:vimwiki_auto_chdir = 1
|
Loading…
Reference in New Issue
Block a user