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 'vim-airline/vim-airline' " status bar
12Plug 'vim-airline/vim-airline-themes' " status bar themes
13Plug 'tpope/vim-surround' " highlight open/close characters like [], {}, ()
14Plug 'edkolev/tmuxline.vim' " apply vim statusbar theme to tmux
15Plug 'rhysd/vim-grammarous' " LanguageTool integration
16Plug 'wakatime/vim-wakatime' " Aggregate editor stats and metrics
17Plug 'rakr/vim-one' " Light theme
18Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
19Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
20call plug#end()
21
22lua <<EOF
23require'nvim-treesitter.configs'.setup {
24 highlight = {
25 enable = true,
26 custom_captures = {
27 -- Highlight the @foo.bar capture group with the "Identifier" highlight group.
28 ["foo.bar"] = "Identifier",
29 },
30 -- Setting this to true will run `:h syntax` and tree-sitter at the same time.
31 -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
32 -- Using this option may slow down your editor, and you may see some duplicate highlights.
33 -- Instead of true it can also be a list of languages
34 additional_vim_regex_highlighting = false,
35 },
36}
37EOF
38lua <<EOF
39require'nvim-treesitter.configs'.setup {
40 incremental_selection = {
41 enable = true,
42 keymaps = {
43 init_selection = "gnn",
44 node_incremental = "grn",
45 scope_incremental = "grc",
46 node_decremental = "grm",
47 },
48 },
49}
50EOF
51lua <<EOF
52require'nvim-treesitter.configs'.setup {
53 indent = {
54 enable = true
55 }
56}
57EOF
58
59" LaTeX config
60let g:livepreview_previewer = 'zathura'
61let g:livepreview_use_biber = 1
62
63" Grammorous config
64let g:grammarous#languagetool_cmd = 'java -cp ~/languagetool/languagetool-server.jar org.languagetool.server.HTTPServer --port 8081 --allow-origin "*"'
65syntax enable
66
67{{- if eq .theme_variant "dark"}}
68set background=dark
69packadd! dracula_pro
70let g:dracula_colorterm = 0
71colorscheme dracula_pro
72{{- end }}
73{{- if eq .theme_variant "light"}}
74let g:airline_theme='one'
75let g:one_allow_italics = 1
76set background=light
77colorscheme one
78{{- end }}
79
80if exists("g:neovide")
81 let g:neovide_cursor_antialiasing=v:true
82 let g:neovide_cursor_vfx_mode = "railgun"
83 let g:neovide_cursor_vfx_mode = "ripple"
84endif
85
86" syntastic settings
87set statusline+=%#warningmsg#
88set statusline+=%{SyntasticStatuslineFlag()}
89set statusline+=%*
90let g:syntastic_always_populate_loc_list = 1
91let g:syntastic_auto_loc_list = 1
92let g:syntastic_check_on_open = 1
93let g:syntastic_check_on_wq = 0
94
95""
96" Some basics
97""
98" Make ctags for supported languages
99command! MakeTags !ctags -R .
100" Add all subdirs to working path so :find works well
101set path+=**
102" Status line completion menu
103set wildmenu
104" Set above menu to a vertical instead of horizontal list
105set wildmode=full,list,full
106" Wrap long lines that continue past the viewport
107set linebreak
108" Highlight the column the cursor is on
109set cursorcolumn
110" Highlight the line the cursor is on
111set cursorline
112" Enables more colors
113set termguicolors
114" If there are folds, close some of them on startup
115set foldlevelstart=99
116" Use system clipboard for all yanking/pasting
117set clipboard+=unnamedplus
118" Use tabs but display them as 4 spaces instead of 8
119set ts=4 sts=4 sw=4 expandtab
120" Round the indent to a multiple of sw
121set shiftround
122" Set hidden character characters
123set listchars=tab:▸\ ,eol:¬,nbsp:␣,trail:•,space:.,extends:→,precedes:←
124set backspace=indent,eol,start
125" Keep 12 lines above and below the cursor when scrolling
126set scrolloff=12
127" Disable mouse support
128set mouse=
129" Use indents to determine folds
130set foldmethod=indent
131" Set line numbers relative to current line
132set number nu
133" Show partial commands in the bottom right
134set showcmd
135" Show which mode you're in
136set showmode
137" Display partial matches when searching
138set incsearch
139" Highlight search results—hide with :noh
140set hlsearch
141" Wrap searches around the end of the file
142set wrapscan
143" Tell Vim to be more liberal with creating hidden buffers
144set hidden
145" Case-insensitive search unless term contains uppercase chars
146set smartcase
147
148" Statusbar theme
149let g:airline_powerline_fonts = 1
150let g:airline_theme='bubblegum'
151if !exists('g:airline_symbols')
152 let g:airline_symbols = {}
153endif
154
155" Configure thesaurus
156let g:tq_mthesaur_file="~/.config/nvim/thesaurus/mthesaur.txt"
157let g:tq_enabled_backends=["datamuse_com","mthesaur_txt","openoffice_en"]
158
159""
160" Keybindings
161""
162" Insert timestamp at the end of the line in this format: 20200527T113245
163nnoremap <C-t><C-s> m'A<C-R>=strftime('%Y%m%dT%H%M%S')<CR>
164" Open a new tab
165nnoremap <C-t>t :tabnew<CR>
166" Toggle hidden characters
167nnoremap <C-l> :set list!<CR>
168
169" Window management
170map <C-h> <C-w>h
171map <C-j> <C-w>j
172map <C-k> <C-w>k
173map <C-l> <C-w>l
174
175" Snippets
176nnoremap ,nnm :read $HOME/.config/nvim/snippets/nnmail<CR>2jA
177nnoremap ,sig :read $HOME/.config/nvim/snippets/signature<CR>
178
179" only enable persistent undo if vim supports
180if has('persistent_undo')
181 set undodir=$HOME/.config/nvim/undofile
182 set undofile
183endif
184
185" Only enable autocommands when Vim supports them
186if has("autocmd")
187 " Disables automatic commenting on newline:
188 autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
189
190 ""
191 " File-specific indentation settings
192 ""
193 autocmd FileType make setlocal ts=8 sts=8 sw=8 noexpandtab
194 autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
195
196 ""
197 " Email configuration
198 ""
199 " Spellcheck in British English
200 autocmd FileType eml setlocal spell spelllang=en_gb
201 " Set lines to hard wrap at 72 chars
202 autocmd FileType eml set tw=72
203
204 ""
205 " Markdown Configuration
206 ""
207 " Treat all .md files as markdown
208 autocmd BufNewFile,BufRead *.md set filetype=markdown
209 " Spellcheck in British English
210 autocmd FileType markdown setlocal spell spelllang=en_gb
211
212 ""
213 " Working with LaTeX
214 ""
215 " Reduce udpatetime for faster previews
216 autocmd BufNewFile,BufRead *.tex setfiletype tex
217 autocmd FileType tex set ut=250
218 autocmd FileType tex set colorcolumn=72
219
220endif