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