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