init.vim.tmpl

  1let mapleader =","
  2
  3if ! filereadable(expand('~/.config/nvim/autoload/plug.vim'))
  4	echo "Downloading junegunn/vim-plug to manage plugins..."
  5	silent !mkdir -p ~/.config/nvim/autoload/
  6	silent !curl "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" > ~/.config/nvim/autoload/plug.vim
  7endif
  8
  9call plug#begin()
 10Plug 'ap/vim-css-color'                 " highlight css colour codes with that color
 11Plug 'tpope/vim-surround'               " highlight open/close characters like [], {}, ()
 12Plug 'wakatime/vim-wakatime'            " Aggregate editor stats and metrics
 13Plug 'catppuccin/vim', { 'as': 'catppuccin' }
 14Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
 15Plug 'github/copilot.vim'
 16call plug#end()
 17
 18{{- if eq .theme_variant "dark"}}
 19colorscheme catppuccin_macchiato
 20{{- end }}
 21{{- if eq .theme_variant "light"}}
 22colorscheme catppuccin_latte
 23{{- end }}
 24
 25" LaTeX config
 26let g:livepreview_previewer = 'zathura'
 27let g:livepreview_use_biber = 1
 28
 29" Grammorous config
 30let g:grammarous#languagetool_cmd = 'java -cp ~/languagetool/languagetool-server.jar org.languagetool.server.HTTPServer --port 8081 --allow-origin "*"'
 31syntax enable
 32
 33""
 34" Some basics
 35""
 36" Make ctags for supported languages
 37command! MakeTags !ctags -R .
 38" Add all subdirs to working path so :find works well
 39set path+=**
 40" Status line completion menu
 41set wildmenu
 42" Set above menu to a vertical instead of horizontal list
 43set wildmode=full,list,full
 44" Wrap long lines that continue past the viewport
 45set linebreak
 46" Highlight the column the cursor is on
 47set cursorcolumn
 48" Highlight the line the cursor is on
 49set cursorline
 50" Enables more colors
 51set termguicolors
 52" If there are folds, close some of them on startup
 53set foldlevelstart=99
 54" Use system clipboard for all yanking/pasting
 55set clipboard+=unnamedplus
 56" Use tabs but display them as 4 spaces instead of 8
 57set ts=4 sts=4 sw=4 expandtab
 58" Round the indent to a multiple of sw
 59set shiftround
 60" Set hidden character characters
 61set listchars=tab:▸\ ,eol:¬,nbsp:␣,trail:•,space:.,extends:→,precedes:←
 62set backspace=indent,eol,start
 63" Keep 12 lines above and below the cursor when scrolling
 64set scrolloff=12
 65" Disable mouse support
 66set mouse=
 67" Use indents to determine folds
 68set foldmethod=indent
 69" Set line numbers relative to current line
 70set number nu
 71" Show partial commands in the bottom right
 72set showcmd
 73" Show which mode you're in
 74set showmode
 75" Display partial matches when searching
 76set incsearch
 77" Highlight search results—hide with :noh
 78set hlsearch
 79" Wrap searches around the end of the file
 80set wrapscan
 81" Tell Vim to be more liberal with creating hidden buffers
 82set hidden
 83" Case-insensitive search unless term contains uppercase chars
 84set smartcase
 85
 86" Statusbar theme
 87let g:airline_powerline_fonts = 1
 88let g:airline_theme='bubblegum'
 89if !exists('g:airline_symbols')
 90	let g:airline_symbols = {}
 91endif
 92
 93""
 94" Keybindings
 95""
 96" Insert timestamp at the end of the line in this format: 20200527T113245
 97nnoremap <C-t><C-s> m'A<C-R>=strftime('%Y%m%dT%H%M%S')<CR>
 98" Open a new tab
 99nnoremap <C-t>t :tabnew<CR>
100" Toggle hidden characters
101nnoremap <C-l> :set list!<CR>
102
103" Window management
104map <C-h> <C-w>h
105map <C-j> <C-w>j
106map <C-k> <C-w>k
107map <C-l> <C-w>l
108
109" only enable persistent undo if vim supports
110if has('persistent_undo')
111	set undodir=$HOME/.config/nvim/undofile
112	set undofile
113endif
114
115" Only enable autocommands when Vim supports them
116if has("autocmd")
117	" Disables automatic commenting on newline:
118	autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
119
120	""
121	" File-specific indentation settings
122	""
123	autocmd FileType make setlocal ts=8 sts=8 sw=8 noexpandtab
124	autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
125
126	""
127	" Markdown Configuration
128	""
129	" Treat all .md files as markdown
130	autocmd BufNewFile,BufRead *.md set filetype=markdown
131	" Spellcheck in British English
132	autocmd FileType markdown setlocal spell spelllang=en_gb
133
134	""
135	" Working with LaTeX
136	""
137	" Reduce udpatetime for faster previews
138	autocmd BufNewFile,BufRead *.tex setfiletype tex
139	autocmd FileType tex set ut=250
140	autocmd FileType tex set colorcolumn=72
141
142endif