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