summaryrefslogtreecommitdiffstats
path: root/.config/nvim/init.old.vim
blob: 35630e8500e04ef99ad6f778b1e12acecad68089 (plain) (blame)
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
" nvim configuration ~~ rgoncalves.se

" vim-plug autoinstall
if empty(glob('~/.local/share/nvim/site/autoload/plug.vim'))
	silent !curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs
		\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
	autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif

" system agnostic detection
let uname = system('uname')[:-2]

" global configuration
set encoding=utf-8
set laststatus=2
set scrolloff=3
set viminfo=
set mouse=a
set title
set number
set noswapfile
set shell=/bin/sh
set updatetime=2500
set synmaxcol=300
set lazyredraw
set ttyfast
set wildoptions=
set autochdir
let sh_minlines=100
let sh_maxlines=600

" filetypes and colorschemes
syntax on
filetype on
filetype plugin on
filetype indent on
colorscheme base

" keybindings
noremap =j :%!python -m json.tool<CR>
noremap =k :%s/-\|-/-+-/g<CR>
noremap =l :%s/-+-/-\|-/g<CR>
noremap <F2> :NERDTreeToggle <CR>
noremap <F3> :GitGutterCustomToggle <CR>
inoremap <C-h> <Left>
inoremap <C-j> <Down>
inoremap <C-k> <Up>
inoremap <C-l> <Right>
" keybindings - omnifunc
inoremap <expr> <CR> pumvisible() ? "\<C-Y>" : "\<CR>"
inoremap <expr> <C-l> pumvisible() ? "\<CR>" : "\<CR>"
inoremap <expr> <C-n> pumvisible() ? '<C-n>' :
	\ '<C-n><C-r>=pumvisible() ? "\<lt>Down>" : ""<CR>'
inoremap <expr> <M-,> pumvisible() ? '<C-n>' :
	\ '<C-x><C-o><C-n><C-p><C-r>=pumvisible() ? "\<lt>Down>" : ""<CR>'
inoremap <expr> <C-Space> (pumvisible() ? (col('.') > 1 ? '<Esc>i<Right>' : '<Esc>i') : '') .
	\ '<C-x><C-o><C-r>=pumvisible() ? "\<lt>C-n>\<lt>C-p>\<lt>Down>" : ""<CR>'
inoremap <expr> <S-Space> (pumvisible() ? (col('.') > 1 ? '<Esc>i<Right>' : '<Esc>i') : '') .
	\ '<C-x><C-u><C-r>=pumvisible() ? "\<lt>C-n>\<lt>C-p>\<lt>Down>" : ""<CR>'

let g:polyglot_disabled = ['autoindent', 'sensible']

" PLUGINS list
if !empty(glob('~/.local/share/nvim/site/autoload/plug.vim'))
	call plug#begin('~/.nvim/plugged/')
	" core
	Plug 'scrooloose/nerdtree'
	" completion
	Plug 'w0rp/ale'
	" Plug 'davidhalter/jedi-vim'
	Plug 'maralla/completor.vim'
	" fzf
	Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
	Plug 'junegunn/fzf.vim'
	" indent
	Plug 'nathanaelkane/vim-indent-guides'
	Plug 'editorconfig/editorconfig-vim'
	Plug 'pangloss/vim-javascript'
	Plug 'pearofducks/ansible-vim'
	Plug 'sheerun/vim-polyglot'
	Plug 'dbeniamine/vim-mail'
	Plug 'ap/vim-css-color'
	" notes
	Plug 'dhruvasagar/vim-table-mode'
	Plug 'jceb/vim-orgmode'
	" headers and source
	Plug 'vim-scripts/a.vim'
	Plug 'majutsushi/tagbar'
	" git
	Plug 'airblade/vim-gitgutter'
	Plug 'tpope/vim-fugitive'
	Plug 'jreybert/vimagit'
	Plug 'junegunn/gv.vim'
	" python
	Plug 'petobens/poet-v'
	call plug#end()
endif

" indentation
set smarttab
set autoindent
set nocompatible
set tabstop=8
set shiftwidth=8
set softtabstop=8
set noexpandtab
set list lcs=tab:\|\  ".
set fillchars+=vert:\  ".
set ve+=onemore
set list
set shortmess=atToOF

" plugins settings
let g:ale_sign_error = ''
let g:ale_sign_warning = ''
let g:ale_c_clang_options='-std=gnu99 -Wall'
let g:ale_c_gcc_options='-std=gnu99 -Wall'
let g:ale_sh_shellcheck_options = '-e SC1090 SC2181 -e SC2155'
let g:ale_python_flake8_options = '--ignore=E501'
let g:ale_linters = { 'python': ['bandit', 'flake8'], }

let g:gitgutter_max_signs = 500
let g:gitgutter_sign_added = '+'
let g:gitgutter_sign_modified = '~'
let g:gitgutter_sign_removed = '-'
let g:gitgutter_sign_modified_removed = '-'

let g:indent_guides_enable_on_vim_startup = 0
let g:indent_guides_auto_colors = 0
let g:indent_cuides_exclude_filetypes = [
	\'help',
	\'terminal'
	\]
let g:poetv_executables = ['poetry']
let g:poetv_auto_activate = 1

let g:python_host_prog = system('which python2')[:-2]
let g:python3_host_prog = system('which python3')[:-2]
let g:jedi#auto_initialization = 1
let g:jedi#popup_on_dot = 0

let g:NERDTreeAutoDeleteBuffer = 1
let g:NERDTreeMinimalUI = 1
let g:NERDTreeDirArrowExpandable = '+'
let g:NERDTreeDirArrowCollapsible = '-'

let g:EditorConfig_exclude_patterns = ['fugitive://.*', 'scp://.*']
let g:fzf_layout = { 'down': '40%'}
let g:magit_default_fold_level = 2
let g:sql_type_default = 'pgsql'
let g:table_mode_always_active = 0

if uname == 'OpenBSD'
	let g:ncm2_pyclang#library_path = '/usr/local/lib/libclang.so.8.1'
	let g:completor_python_binary = '/usr/bin/python3'
endif

" netrw
let g:netrw_banner = 0
let g:netrw_browse_split = 4
let g:netrw_liststyle = 3
let g:netrw_altv = 1
let g:netrw_winsize = 25
let g:netrw_list_hide = '\(^\|\s\s\)\zs\.\S\+'

autocmd BufNewFile,BufReadPost *.{yaml,yml} set filetype=yaml
autocmd BufNewFile,BufReadPost */*ssh/config.d/* set syntax=sshconfig
autocmd BufNewFile,BufReadPost */*ansible*/**/*.yml set filetype=yaml.ansible
autocmd BufNewFile,BufRead ~/.config/i3/config set filetype=i3config
autocmd BufNewFile,BufRead ~/.config/sway/config set filetype=i3config
autocmd BufNewFile,BufRead ~/.config/polybar/config set filetype=dosini
autocmd FileType conf let b:EditorConfig_disable = 1
autocmd FileType gitcommit let b:EditorConfig_disable = 1
autocmd FileType java setlocal omnifunc=javacomplete#Complete
autocmd FileType yaml let b:EditorConfig_disable = 1

" statusline
set statusline=
set statusline+=\ %f
set statusline+=%m
set statusline+=%=
set statusline+=\ %y
set statusline+=\ %{&fileencoding?&fileencoding:&encoding}
set statusline+=\ [%{&fileformat}\]
set statusline+=\ %p%%
set statusline+=\ %l:%c
set statusline+=\ 

" completion
set omnifunc=syntaxcomplete#Complete
set completeopt=longest,menuone

" commands
command! PlugSync PlugClean |
	\ PlugInstall |
	\ UpdateRemotePlugins
command! GitGutterCustomToggle GitGutterLineHighlightsToggle |
	\ GitGutterLineNrHighlightsToggle
command! Gblame Git blame

" cnoremap <silent> <cr> <cr>:call <SID>CommandCallback()<cr>

function! s:SyncColorcolumnColorscheme()
	let l:length = '/\%' . string(&colorcolumn + 1) . 'v.\+/'
	execute 'match' 'OverLength' l:length
endfunction

function! s:CommandCallback()
	let l:last_command = @:

	if l:last_command =~ 'set colorcolumn'
		call s:SyncColorcolumnColorscheme()
	endif
endfunction

function! s:Init()
	call s:SyncColorcolumnColorscheme()
endfunction
remember that computers suck.