-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
273 lines (230 loc) · 7.59 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
call plug#begin()
Plug 'gmarik/Vundle.vim'
" Plug 'gruvbox-community/gruvbox'
Plug 'chriskempson/base16-vim'
" LSP
Plug 'neovim/nvim-lspconfig'
Plug 'hrsh7th/nvim-compe'
Plug 'hrsh7th/vim-vsnip'
" Utility
Plug 'nvim-lua/plenary.nvim' " Required for telescope
Plug 'nvim-telescope/telescope.nvim'
Plug 'kien/ctrlp.vim' " Maybe remove if telescope is better
Plug 'tomtom/tcomment_vim'
Plug 'godlygeek/tabular'
Plug 'vim-syntastic/syntastic'
Plug 'w0rp/ale'
" Ruby
Plug 'vim-ruby/vim-ruby'
Plug 'skalnik/vim-vroom'
" Rails
Plug 'tpope/vim-rails'
" Rust
Plug 'rust-lang/rust.vim'
" Python
Plug 'vim-python/python-syntax'
" Javascript
Plug 'pangloss/vim-javascript'
" JSX
Plug 'mxw/vim-jsx'
" Elixir
Plug 'elixir-lang/vim-elixir'
" Solidity
Plug 'tomlion/vim-solidity'
" Go
Plug 'fatih/vim-go'
call plug#end()
let mapleader = ','
:imap jj <ESC>
map <Leader>rn :call RenameFile()<cr>
map <Leader>ac :sp app/controllers/application_controller.rb<cr>
map <Leader>vc :Vcontroller<cr>
map <Leader>vm :Vmodel<cr>
map <Leader>vv :Vview<cr>
map <Leader>vu :AV<CR> " view unit test
map <Leader>vf :Vfunctional<cr>
map <Leader>bi :!bundle install<cr>
map <Leader>w <C-w>w " move vim window
map <Leader>sa mmggVG"*y`m " select all
map <Leader>f :call OpenFactoryFile()<CR>
map <Leader>i mmgg=G`m " indent, wow
map <Leader>sc :sp db/schema.rb<cr>
map <Leader>cb :!cargo build<cr>
map <Leader>cr :!cargo run<cr>
map <Leader>mr :!mocha<cr>
map <leader>rb :!ruby %<cr>
nnoremap <leader>t <cmd>Telescope find_files<CR>
nnoremap <leader>tg <cmd>Telescope live_grep<cr>
nmap <Leader>s :source ~/.vimrc<cr>
function! RenameFile()
let old_name = expand('%')
let new_name = input('New file name: ', expand('%'), 'file')
if new_name != '' && new_name != old_name
exec ':saveas ' . new_name
exec ':silent !rm ' . old_name
redraw!
endif
endfunction
hi MatchParen cterm=none ctermbg=black ctermfg=yellow
" colorscheme base16-default-dark
" Basic visual settings
syntax on
set autoindent
set background=dark
set backspace=2
set colorcolumn=100
set expandtab
set hlsearch
set number
set shiftwidth=2
set smartindent
set t_Co=256
set tabstop=2
set noeb vb t_vb=
" Bars
highlight clear SignColumn
highlight VertSplit ctermbg=236
highlight ColorColumn ctermbg=237
highlight LineNr ctermbg=236 ctermfg=240
highlight StatusLineNC ctermbg=238 ctermfg=0
highlight StatusLine ctermbg=240 ctermfg=232
highlight Visual ctermbg=240 ctermfg=0
highlight Pmenu ctermbg=240 ctermfg=12
highlight PmenuSel ctermbg=3 ctermfg=1
highlight SpellBad ctermbg=0 ctermfg=1
" Cursor
set guicursor=n-v-c:block-Cursor
set guicursor+=i:ver100-iCursor
set guicursor+=n-v-c:blinkon0
set guicursor+=i:blinkwait10
" enable status line always
set laststatus=2
if version >= 700
au InsertEnter * hi StatusLine ctermfg=226 ctermbg=232
au InsertLeave * hi StatusLine ctermbg=240 ctermfg=232
endif
" The Silver Searcher
if executable('ag')
" Use ag over grep
set grepprg=ag\ --nogroup\ --nocolor
" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
" ag is fast enough that CtrlP doesn't need to cache
let g:ctrlp_use_caching = 0
endif
lua << EOF
require'lspconfig'.solargraph.setup{}
local nvim_lsp = require('lspconfig')
-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local on_attach = function(client, bufnr)
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
--Enable completion triggered by <c-x><c-o>
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Mappings.
local opts = { noremap=true, silent=true }
-- See `:help vim.lsp.*` for documentation on any of the below functions
buf_set_keymap('n', 'gD', '<Cmd>lua vim.lsp.buf.declaration()<CR>', opts)
buf_set_keymap('n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>', opts)
buf_set_keymap('n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts)
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
buf_set_keymap('n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
buf_set_keymap('n', '<space>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
buf_set_keymap("n", "<space>f", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts)
end
-- Use a loop to conveniently call 'setup' on multiple servers and
-- map buffer local keybindings when the language server attaches
local servers = { "solargraph" }
for _, lsp in ipairs(servers) do
nvim_lsp[lsp].setup {
on_attach = on_attach,
flags = {
debounce_text_changes = 150,
}
}
end
EOF
lua << EOF
vim.o.completeopt = "menuone,noselect"
require'compe'.setup {
enabled = true;
autocomplete = true;
debug = false;
min_length = 1;
preselect = 'enable';
throttle_time = 80;
source_timeout = 200;
incomplete_delay = 400;
max_abbr_width = 100;
max_kind_width = 100;
max_menu_width = 100;
documentation = false;
source = {
path = true;
buffer = true;
calc = true;
vsnip = true;
nvim_lsp = true;
nvim_lua = true;
spell = true;
tags = true;
snippets_nvim = true;
treesitter = true;
};
}
local t = function(str)
return vim.api.nvim_replace_termcodes(str, true, true, true)
end
local check_back_space = function()
local col = vim.fn.col('.') - 1
if col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then
return true
else
return false
end
end
-- Use (s-)tab to:
--- move to prev/next item in completion menuone
--- jump to prev/next snippet's placeholder
_G.tab_complete = function()
if vim.fn.pumvisible() == 1 then
return t "<C-n>"
elseif vim.fn.call("vsnip#available", {1}) == 1 then
return t "<Plug>(vsnip-expand-or-jump)"
elseif check_back_space() then
return t "<Tab>"
else
return vim.fn['compe#complete']()
end
end
_G.s_tab_complete = function()
if vim.fn.pumvisible() == 1 then
return t "<C-p>"
elseif vim.fn.call("vsnip#jumpable", {-1}) == 1 then
return t "<Plug>(vsnip-jump-prev)"
else
-- If <S-Tab> is not working in your terminal, change it to <C-h>
return t "<S-Tab>"
end
end
vim.api.nvim_set_keymap("i", "<Tab>", "v:lua.tab_complete()", {expr = true})
vim.api.nvim_set_keymap("s", "<Tab>", "v:lua.tab_complete()", {expr = true})
vim.api.nvim_set_keymap("i", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})
vim.api.nvim_set_keymap("s", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})
-- vim.api.nvim_set_keymap("n", "<C-t>", "<cmd>lua require('telescope.builtin').git_files()<cr>", { noremap = true })
require'telescope'.setup({
defaults = {
file_ignore_patterns = { "^./.git/", "^node_modules/", "^vendor/" },
}
})