-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
364 lines (285 loc) · 9.26 KB
/
.vimrc
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
filetype off
set nocompatible
filetype plugin indent on
" vim-plug
call plug#begin('~/.vim/plugged-in')
Plug 'tpope/vim-sensible'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-commentary'
"Plug 'tpope/vim-sleuth'
Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim'
Plug 'editorconfig/editorconfig-vim'
Plug 'rhysd/committia.vim'
Plug 'mbbill/undotree'
Plug 'ludovicchabant/vim-gutentags'
Plug 'nathanaelkane/vim-indent-guides'
Plug 'janko/vim-test'
Plug 'Roguelazer/variables_file.vim'
"Plug 'vimwiki/vimwiki'
"Plug 'sheerun/vim-polyglot'
"Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plug 'lanej/vim-phabricator'
Plug 'ojroques/nvim-osc52'
"lsp plugins
Plug 'neovim/nvim-lspconfig'
"Plug 'palantir/python-language-server'
"colorschemes
Plug 'chriskempson/base16-vim'
Plug 'morhetz/gruvbox'
call plug#end()
" Basic Settings
set encoding=utf-8 nobomb " don't preprend Byte Order Mark
set nomodeline " don't honor modelines in files that are being edited
set showmode
set showcmd
set hidden
set novb
set noeb
set ttyfast
set undofile
set undoreload=10000
set nofoldenable " turn off folds
set autoread
set cursorline
set magic
set nobackup
set noswapfile
set lazyredraw " don't redraw while running macros, registers, commands, etc.
set splitbelow
set splitright
set shiftround " always indent in multiple of `shiftwidth`
set title " set window title
set listchars=tab:▸·,eol:¬,trail:∆
set list
set linebreak " wrap lines more intelligently (at specific chars)
set colorcolumn=+1 " highlight 1 column after `textwidth`
set nu
set ignorecase " ignore case for search
set smartcase " ignore casing for search unless there are caps
set showmatch " blink the matching paren/bracket when closing
set matchtime=2
set hlsearch " highlight search matches
set gdefault " sets 'g' flag automatically for substitutions
set wildchar=<TAB>
set wildmode=longest,list " display a nice list in wildmenu
set wildignore+=*.DS_STORE,*.db,node_modules/**,*.jpg,*.png,*.gif
set pastetoggle=<leader>p
set tabpagemax=20
let mapleader = ","
let maplocalleader = "\\"
" status line
" TODO replace with a plugin
set statusline=%!BuildStatusLine()
" Tabs, spaces, wrapping
set softtabstop=2 " how many spaces a literal tab character is
set wrap
set textwidth=120
" mappings
nnoremap <C-h> :tabp<CR>
nnoremap <C-l> :tabn<CR>
nnoremap <C-j> :tabm-1<CR>
nnoremap <C-k> :tabm+1<CR>
nnoremap <C-t> :tabe<space>
nnoremap <tab> %
vnoremap <tab> %
nnoremap Q !!sh<CR> "execute current line in shell, replace with results
nnoremap <leader>ev :vsplit $MYVIMRC<cr>
nnoremap <leader>sv :source $MYVIMRC<cr>
" format json
nnoremap <leader>fj :'<,'>!python3 -m json.tool<cr>
nnoremap <leader>ffj :%!python3 -m json.tool<cr>
" format xml
nnoremap <leader>fx :'<,'>!xmllint --format -<cr>
nnoremap <leader>ffx :%!xmllint --format -<cr>
" base64 decode
nnoremap <leader>db :'<,'>!base64 -d<cr>
nnoremap <leader>fdb :%!base64 -d<cr>
" backward incompatible change in neovim v0.5 necessitates this, see https://github.com/neovim/neovim/issues/14978
if has('nvim-0.5') " read: version >= 0.5
set undodir=~/.nvim/tmp/undo//
set backupdir=~/.nvim/tmp/backup//
set directory=~/.nvim/tmp/swap//
else
set undodir=~/.vim/tmp/undo//
set backupdir=~/.vim/tmp/backup//
set directory=~/.vim/tmp/swap//
endif
" Make those folders automatically if they don't already exist.
if !isdirectory(expand(&undodir))
call mkdir(expand(&undodir), "p")
endif
if !isdirectory(expand(&backupdir))
call mkdir(expand(&backupdir), "p")
endif
if !isdirectory(expand(&directory))
call mkdir(expand(&directory), "p")
endif
" Color scheme
set termguicolors "added for nvim color support
set background=dark
let g:gruvbox_contrast_dark = 'hard'
colorscheme gruvbox
" vim-indent-guides settings
let g:indent_guides_enable_on_vim_startup = 1
let g:indent_guides_start_level = 2
let g:indent_guides_guide_size = 1
let g:indent_guides_color_change_percent = 70
"
"fzf + fzf.vim settings
let $FZF_DEFAULT_COMMAND = "rg --files --hidden --follow --glob '!vendor/cache'" "use rg instead of fzf
" bindings for opening files
" https://github.com/junegunn/fzf.vim/issues/435#issuecomment-511044747
let g:fzf_action = {
\ 'ctrl-t': 'tab drop',
\ 'ctrl-x': 'split',
\ 'ctrl-v': 'vsplit' }
let g:fzf_layout = { 'down': '~40%' }
let g:fzf_preview_window = [] "Empty value to disable preview window altogether
let g:fzf_buffers_jump = 1 "[Buffers] Jump to the existing window if possible
" #################
" vim-test settings
" #################
" terminal position
let test#neovim#term_position = "botright"
let test#vim#term_position = "botright"
" python specific
let test#strategy = 'neovim'
let test#python#runner = 'pytest'
let test#python#pytest#executable = 'withenv venv/bin/pytest'
let test#ruby#runner = 'rspec'
let test#ruby#rspec#executable = 'withenv vendor/bundle/bundle exec rspec'
" mappings
nnoremap <leader>tn :TestNearest<CR>
nnoremap <leader>tf :TestFile<CR>
nnoremap <leader>ts :TestSuite<CR>
nnoremap <leader>tl :TestLast<CR>
nnoremap <leader>tv :TestVisit<CR>
" better regex support for search
nnoremap / /\v
vnoremap / /\v
" vim-wiki settings
"NOTE: not currently used
let g:vimwiki_list = [{ 'path': '~/vimwiki/', 'syntax': 'markdown', 'ext': '.md' }]
" mappings
" I cant quit you :(
nnoremap <C-p> :Files<CR>
"nnoremap <leader>f :Files<CR> " conflicts with my formatting mappings (<leader>fx)
nnoremap <leader>t :Tags<CR>
" nvim-osc52 settings
lua << EOF
local function copy(lines, _)
require('osc52').copy(table.concat(lines, '\n'))
end
local function paste()
return {vim.fn.split(vim.fn.getreg(''), '\n'), vim.fn.getregtype('')}
end
vim.g.clipboard = {
name = 'osc52',
copy = {['+'] = copy, ['*'] = copy},
-- not sure if I need this paste part...
paste = {['+'] = paste, ['*'] = paste},
}
-- Now the '+' register will copy to system clipboard using OSC52
vim.keymap.set('n', '<leader>c', '"+y')
vim.keymap.set('v', '<leader>c', '"+y')
vim.keymap.set('n', '<leader>cc', '"+yy')
EOF
" status line
" (https://github.com/mcantor/dotfiles/blob/master/vim/.vimrc)
function! BuildStatusLine()
let statusline = ""
let statusline .= "%f" "Filename (F -> full, f -> relative)
let statusline .= "%( %h%1*%m%*%r%w%) " "Buffer flags
let statusline .= "(%{&ff}%(\/%Y%))" "File format and type
" syntastic error messages
"let statusline .= "%#warningmsg#"
"let statusline .= "%{SyntasticStatuslineFlag()}"
"let statusline .= "%*"
let statusline .= "%=" "Left/right separator
let statusline .= "%{gutentags#statusline('', ' | ')}" "Gutentags status indicator
let statusline .= "(%l,%c%V) " "Line & column
let statusline .= "%03.3b " "Character under cursor (decimal)
let statusline .= "0x%02.2B " "Character under cursor (hexadecimal)
let statusline .= "| %P/%L" "File progress
return statusline
endfunction
"fugitive settings
nnoremap <leader>gb :Git blame<CR>
nnoremap <leader>gl :Git log<CR>
"nvim-lspconfig settings
lua << EOF
local lsp_config = require 'lspconfig'
local home_dir = vim.loop.os_homedir()
vim.lsp.set_log_level("debug")
lsp_config.pylsp.setup{
cmd = { home_dir .. "/global_venv/bin/pylsp" },
settings = {
pylsp = {
plugins = {
-- TODO: most likely can change what's installed with pylsp to not have to disable all of this.
configurationSources = { 'flake8', 'mypy' },
flake8 = { enabled = true },
mypy = { enabled = true },
pycodestyle = { enabled = false },
}
}
}
}
-- lsp_config.vimls.setup{
-- cmd = { home_dir .. '/global_node_modules/node_modules/.bin/vim-language-server', '--stdio' }
-- }
EOF
"vim-phabricator settings
let g:phabricator_hosts = ["phab.easypo.net"]
lua << EOF
-- NOTE: relies on nvim-osc52 clipboard override; GBrowse! sets the '+' reg.
local opts = { noremap = true, silent = true }
vim.keymap.set('n', '<leader>br', function() vim.cmd('GBrowse!') end, opts)
-- this format bc using vim.cmd didn't get selection correctly nor deselect/exit visual mode
vim.keymap.set('v', '<leader>br', ':GBrowse!<CR>', opts)
EOF
"treesitter settings
" lua <<EOF
" require'nvim-treesitter.configs'.setup {
" -- One of "all", "maintained" (parsers with maintainers), or a list of languages
" -- ensure_installed = "maintained",
" -- ensure_installed = {
" -- "python",
" -- "ruby",
" -- "json",
" -- "markdown",
" -- "make",
" -- "go",
" -- "bash" ,
" -- "yaml",
" -- "vim",
" -- "lua",
" -- "c",
" -- "cpp",
" -- "javascript",
" -- "html",
" -- "comment",
" -- "php",
" -- "css",
" -- },
" -- Install languages synchronously (only applied to `ensure_installed`)
" sync_install = false,
" -- List of parsers to ignore installing
" -- ignore_install = { "javascript" },
" highlight = {
" -- `false` will disable the whole extension
" enable = true,
" -- list of language that will be disabled
" -- disable = { "c", "rust" },
" -- Setting this to true will run `:h syntax` and tree-sitter at the same time.
" -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
" -- Using this option may slow down your editor, and you may see some duplicate highlights.
" -- Instead of true it can also be a list of languages
" additional_vim_regex_highlighting = false,
" },
" indent = {
" enable = true,
" }
" }
" EOF