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