1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
|
let g:loaded_netrw = 1
let g:loaded_netrwPlugin = 1
if filereadable('/etc/hostname')
let hostname=join(readfile('/etc/hostname'))
else
let hostname='unknown'
endif
let g:vsnip_snippet_dir = "~/.config/nvim/snippets"
let g:vsnip_snippet_dirs = ["~/.config/nvim/local/snippets"]
call plug#begin()
if filereadable(printf('%s/.config/nvim/local-plug.vim', $HOME))
exec "source " . printf('%s/.config/nvim/local-plug.vim', $HOME)
endif
Plug 'dylnmc/synstack.vim'
Plug 'folke/trouble.nvim'
Plug 'google/vim-codefmt'
Plug 'google/vim-glaive'
Plug 'google/vim-maktaba'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/cmp-nvim-lua'
Plug 'hrsh7th/cmp-path'
Plug 'hrsh7th/cmp-vsnip'
Plug 'hrsh7th/nvim-cmp'
Plug 'hrsh7th/vim-vsnip'
Plug 'kyazdani42/nvim-web-devicons'
Plug 'neovim/nvim-lspconfig'
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plug 'nvim-treesitter/playground'
Plug 'onsails/lspkind.nvim'
Plug 'nvim-tree/nvim-tree.lua'
Plug 'vim-airline/vim-airline'
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim'
Plug 'nvim-treesitter/nvim-treesitter-textobjects'
Plug 'stevearc/aerial.nvim'
Plug 'tpope/vim-surround'
Plug 'lukas-reineke/indent-blankline.nvim'
Plug 'git://git.josher.dev/fieldmarshal.vim.git'
if has('rneovim')
Plug 'git://git.josher.dev/rneovim-userregs.git'
endif
Plug 'git@git.josher.dev:config.vim.git',
\ { 'dir': g:plug_home . '/config.vim',
\ 'do': ':UpdateInitVimHook' }
call plug#end()
command! UpdateInitVimHook source ~/.config/nvim/init.vim <bar> PlugInstall
set termguicolors
set shiftwidth=2
set tabstop=2
set expandtab
set nowrap
set splitright
set splitbelow
set wildmode=longest,list,full
set scrolloff=8
set number
set relativenumber
let mapleader=" "
" Make splitting more congruent with how Tmux does it.
noremap <C-w>% <C-w>v
noremap <C-w>" <C-w>s
" Open a terminal in a split below the current file.
noremap <C-w><C-t> <C-w>s<cmd>term<cr>
" Opens a terminal in the directory the current file is in.
noremap <C-w><C-S-t> <C-w>s<cmd>TERM<cr>
" Fix the yank behavior.
noremap Y y$
" Format code. This is <AltGr-u>
noremap ú <cmd>FormatCode<cr>
" Synstack to help profile syntax highlighting issues.
noremap <leader>p <plug>(SynStack)
" Way to find files.
noremap <leader>ff <cmd>Telescope find_files<cr>
inoremap <C-+> <Plug>(vsnip-expand)
" When navigating to the beginning of a line, I want to always reset the screen
" to the leftmost position.
noremap ^ ^zH
noremap <leader>t <cmd>TroubleToggle<cr>
augroup InitVim
au!
autocmd BufRead *.java,*.c,*.cpp,*.cxx,*.hs TSBufEnable highlight
" Automatically start insert mode when opening a new terminal.
autocmd TermOpen * startinsert
" When entering a terminal, automatically start "insert" and feed the escape
" key. This ensures the ZSH line-reader is in "normal" mode. I have
" integration with zsh to navigate vim panes from the zsh line editor.
autocmd BufEnter term://* startinsert | call feedkeys("\x1b")
autocmd TextYankPost *
\ lua require'vim.highlight'.on_yank(
\ { higroup = "IncSearch", timeout = 100 });
augroup END
" Local configuration that can be set by hostname or just a local configuration.
" Local files are ignored by .gitignore so they won't be added to the repo,
" allowing local (*cough* work) configuration to be separate from general
" configuration.
if isdirectory(printf('%s/.config/nvim/%s', $HOME, hostname))
exec "set rtp+=" . printf('%s/.config/nvim/%s', $HOME, hostname)
endif
if isdirectory(printf('%s/.config/nvim/local', $HOME))
exec "set rtp+=" . printf('%s/.config/nvim/local', $HOME)
endif
if filereadable(printf('%s/.config/nvim/%s.vim', $HOME, hostname))
exec "source " . printf('%s/.config/nvim/%s.vim', $HOME, hostname)
endif
if filereadable(printf('%s/.config/nvim/local.vim', $HOME))
exec "source " . printf('%s/.config/nvim/local.vim', $HOME)
endif
if isdirectory(printf('%s/.config/nvim/after', $HOME))
exec "set rtp+=" . printf('%s/.config/nvim/after', $HOME)
endif
noremap <leader>nt <cmd>NvimTreeToggle<cr>
noremap <C-n><C-e> :<C-u>e <C-r>=expand('%:h')<cr>/
noremap <C-w>. <cmd>lua require('windownav').goto_terminal()<cr>
noremap <C-w>I <cmd>lua require('windownav').goto_initvim()<cr>
noremap <C-w>' <cmd>lua require('windownav').goto_lastwin()<cr>
set textwidth=80
set colorcolumn=+1
if has('rneovim')
function! HighlightColorColumns() abort
hi MyColorColumn guifg=#3a3a3a guibg=none gui=None
hi MyRedColorColumn guifg=#5a1a1a guibg=none gui=None
endfunction
call HighlightColorColumns()
" This is my patched version of neovim.
if has('fancycolorcol')
set colorcolumn=+1/│/MyColorColumn/b,+20/│/MyRedColorColumn/
else
hi! link ColorColumn MyColorColumn
set fillchars+=colorcol:│
endif
augroup InitVim
au ColorScheme * call HighlightColorColumns()
augroup END
endif
" Opens a terminal in the directory of the current file.
command! TERM exec "term sh -c 'cd " . expand('%:p:h') . " && exec $SHELL'"
" W = w. I often click when typing :w
command! W w
let g:indentLine_char = '┆'
lua << EOF
function remove_package(str)
for k, v in pairs(package.loaded) do
if string.match(k, "^" .. str) then
package.loaded[k] = nil
end
end
end
-- CiderLSP
vim.opt.completeopt = { "menu", "menuone", "noselect" }
require("lsp")
require("lspconfig")
-- Diagnostics
require("diagnostics")
require("nvim-tree").setup()
require("treesitter-textobjects-setup")
require('telescope').setup({
defaults = {
layout_strategy = "center",
results_title = false,
sorting_strategy = "ascending",
layout_config = {
center = {
width = 0.5,
height = 0.5,
},
-- other layout configuration here
},
-- other defaults configuration here
},
-- other configuration values here
})
require("indent_blankline").setup {
-- for example, context is off by default, use this to turn it on
show_current_context = true,
show_current_context_start = faels,
char_highlight_list = { "MyColorColumn" }
}
require('aerial').setup({
-- optionally use on_attach to set keymaps when aerial has attached to a buffer
on_attach = function(bufnr)
-- Jump forwards/backwards with '{' and '}'
vim.keymap.set('n', '{', '<cmd>AerialPrev<CR>', {buffer = bufnr})
vim.keymap.set('n', '}', '<cmd>AerialNext<CR>', {buffer = bufnr})
end
})
-- You probably also want to set a keymap to toggle aerial
vim.keymap.set('n', '<leader>a', '<cmd>AerialToggle!<CR>')
EOF
|