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