-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspacevim
More file actions
342 lines (286 loc) · 11.8 KB
/
Copy pathspacevim
File metadata and controls
342 lines (286 loc) · 11.8 KB
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
" vim: set syntax=vim ft=vim :
" You can enable the existing layers in space-vim and
" exclude the partial plugins in a certain layer.
" Use exclude option if you don't want the full Layer
let g:spacevim_layers = [
\ 'fzf',
\ 'better-defaults',
\ 'editing',
\ 'markdown',
\ 'tmux',
\ 'airline',
\ 'git',
\ 'programming',
\ 'python',
\ 'scala',
\ 'text-align',
\ 'javascript',
\ 'typescript',
\ 'which-key',
\ 'formatting',
\ ]
let g:spacevim_excluded = [
\ 'dominikduda/vim_current_word',
\ 'tpope/vim-rsi',
\ 'junegunn/rainbow_parentheses.vim',
\ 'luochen1990/rainbow',
\ 'matze/vim-move',
\ 'pelodelfuego/vim-swoop',
\ 'terryma/vim-multiple-cursors',
\ 'autozimu/LanguageClient-neovim',
\ ]
" Put your private plugins here.
function! UserInit()
" Space has been set as the default leader key,
" if you want to change it, uncomment and set it here.
" let g:spacevim_leader = "<\Space>"
" let g:spacevim_localleader = ','
" Install private plugins
Plug 'NLKNguyen/papercolor-theme'
Plug 'reedes/vim-colors-pencil'
Plug 'ryanoasis/vim-devicons'
Plug 'kana/vim-textobj-user'
Plug 'Julian/vim-textobj-variable-segment'
Plug 'junegunn/vim-easy-align'
Plug 'guns/xterm-color-table.vim'
Plug 'rudism/deoplete-tsuquyomi'
Plug 'fszymanski/deoplete-emoji', { 'do': ':UpdateRemotePlugins' }
Plug 'alvan/vim-closetag'
Plug 'neoclide/coc.nvim', { 'branch': 'release' } " { 'do': { -> coc#util#install() } }
Plug 'tpope/vim-dadbod'
Plug 'kristijanhusak/vim-dadbod-ui'
Plug 'scalameta/nvim-metals'
Plug 'hrsh7th/vim-vsnip'
Plug 'hrsh7th/nvim-compe'
endfunction
" Put your costom configurations here, e.g., change the colorscheme.
function! UserConfig()
if has('termguicolors')
set termguicolors
if g:spacevim.tmux
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
endif
endif
Layer 'scala-extra'
" let g:spacevim_lsp_engine = 'coc'
let g:scala_sort_across_groups=1
" If you enable airline layer and have installed the powerline fonts, set it here.
let g:airline_powerline_fonts=1
let g:airline_theme = 'pencil'
let g:airline#extensions#hunks#enabled = 0
let g:airline#extensions#tabline#enabled = 1
let g:airline_skip_empty_sections = 1
let g:airline#extensions#tagbar#enabled = 0
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:airline_symbols.notexists = '★'
nnoremap <leader>ta :AirlineToggle<CR>
let g:airline#extensions#coc#enabled = 1
nnoremap <leader>ff :Files<CR>
nnoremap <leader>f~ :Files ~<CR>
let g:PaperColor_Theme_Options = {
\ 'theme': {
\ 'default.light': {
\ 'override': {
\ 'linenumber_bg': ['#dadada', '253']
\ }
\ }
\ }
\}
set background=light
colorscheme PaperColor
highlight SignColumn ctermbg=253 guibg=#dadada
highlight! link SignifySignAdd DiffAdd
highlight! link SignifySignChange DiffChange
highlight! link SignifySignDelete DiffDelete
highlight! link SignifySignChangeDelete SignifySignChange
highlight! link SignifySignDeleteFirstLine SignifySignDelete
set expandtab
set tabstop=2
set softtabstop=2
set timeoutlen=500 ttimeoutlen=10
set colorcolumn=120
let g:pymode_options_max_line_length = 120
let g:pymode_breakpoint_bind = "<leader>pb"
let g:pymode_doc_bind = "<leader>pk"
nnoremap <leader>wz <C-w>z
autocmd FileType python setlocal textwidth=119
let g:AutoPairsMultilineClose = 0
" Allow mouse in all modes
set mouse=a
let $FZF_DEFAULT_COMMAND = 'rg -l ""'
if !exists('g:fzf_colors')
let g:fzf_colors = {
\ 'fg': ['fg', 'Comment'],
\ 'bg': ['bg', 'CursorLine', 'CursorColumn'],
\ 'hl': ['fg', 'Comment'],
\ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
\ 'bg+': ['bg', 'Normal'],
\ 'hl+': ['fg', 'Statement'],
\ 'info': ['fg', 'PreProc'],
\ 'border': ['fg', 'Ignore'],
\ 'prompt': ['fg', 'Conditional'],
\ 'pointer': ['fg', 'Exception'],
\ 'marker': ['fg', 'Keyword'],
\ 'spinner': ['fg', 'Label'],
\ 'header': ['fg', 'Comment']
\ }
endif
nnoremap <Tab> :bn<CR>
nnoremap <S-Tab> :bp<CR>
" Close a buffer without closing the previous window
nnoremap <leader>bx :bp<bar>sp<bar>bn<bar>bd<CR>
let g:closetag_filenames = '*.html,*.xhtml,*.jsx,*.tsx'
let g:closetag_xhtml_filenames = '*.xhtml,*.jsx,*.tsx'
" Jenkinsfile syntax
autocmd BufNewFile,BufRead *.jenkins set syntax=Jenkinsfile
let g:coc_global_extensions = [
\ 'coc-json',
\ 'coc-highlight',
\ 'coc-explorer',
\ 'coc-prettier'
\ ]
nnoremap <silent> <leader>ee :CocCommand explorer<CR>
nnoremap <silent> <leader>lc :CocCommand<CR>
nnoremap <silent> <leader>ll :CocList<CR>
" nnoremap <silent> [l :CocPrev<CR>
" nnoremap <silent> ]l :CocNext<CR>
" Remap for rename current word
" nnoremap <silent> <leader>ln <Plug>(coc-rename)
" Remap keys for gotos
" nmap <silent> gy <Plug>(coc-type-definition)
" nmap <silent> gi <Plug>(coc-implementation)
" nmap <silent> gr <Plug>(coc-references)
" Use tab for trigger completion with characters ahead and navigate.
" Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
" Used in the tab autocompletion for coc
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Use <c-space> to trigger completion.
" if has('nvim')
" inoremap <silent><expr> <c-space> coc#refresh()
" else
" inoremap <silent><expr> <c-@> coc#refresh()
" endif
" Notify coc.nvim that <enter> has been pressed.
" Currently used for the formatOnType feature.
" inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
" \: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
" Organise imports
" nnoremap <silent> <space>oi :<C-u>CocCommand editor.action.organizeImport<CR>
" Toggle panel with Tree Views
" nnoremap <silent> <space>tt :<C-u>CocCommand metals.tvp<CR>
" Toggle Tree View 'metalsPackages'
" nnoremap <silent> <space>tk :<C-u>CocCommand metals.tvp metalsPackages<CR>
" Toggle Tree View 'metalsCompile'
" nnoremap <silent> <space>tc :<C-u>CocCommand metals.tvp metalsCompile<CR>
" Toggle Tree View 'metalsBuild'
" nnoremap <silent> <space>tb :<C-u>CocCommand metals.tvp metalsBuild<CR>
" Reveal current current class (trait or object) in Tree View 'metalsPackages'
" nnoremap <silent> <space>tf :<C-u>CocCommand metals.revealInTreeView metalsPackages<CR>
" Disable coc in git commits
autocmd FileType gitcommit let b:coc_enabled=0
:lua << EOF
local cmd = vim.cmd
local g = vim.g
local function map(mode, lhs, rhs, opts)
local options = { noremap = true }
if opts then
options = vim.tbl_extend("force", options, opts)
end
vim.api.nvim_set_keymap(mode, lhs, rhs, options)
end
----------------------------------
-- OPTIONS -----------------------
----------------------------------
-- global
-- vim.opt_global.completeopt = { "menu", "noinsert", "noselect" }
-- vim.opt_global.shortmess:remove("F"):append("c")
-- LSP
map("n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>")
map("n", "<leader>lgd", "<cmd>lua vim.lsp.buf.definition()<CR>")
map("n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>")
map("n", "<leader>lh", "<cmd>lua vim.lsp.buf.hover()<CR>")
map("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>")
map("n", "<leader>lgi", "<cmd>lua vim.lsp.buf.implementation()<CR>")
map("n", "<leader>lgt", "<cmd>lua vim.lsp.buf.type_definition()<CR>")
map("n", "<leader>lr", "<cmd>lua vim.lsp.buf.references()<CR>")
map("n", "<leader>ls", "<cmd>lua vim.lsp.buf.document_symbol()<CR>")
map("n", "<leader>lS", "<cmd>lua vim.lsp.buf.workspace_symbol()<CR>")
map("n", "<leader>lR", "<cmd>lua vim.lsp.buf.rename()<CR>")
map("n", "<leader>lf", "<cmd>lua vim.lsp.buf.formatting()<CR>")
map("n", "<leader>la", "<cmd>lua vim.lsp.buf.code_action()<CR>")
map("n", "<leader>mw", '<cmd>lua require"metals".worksheet_hover()<CR>')
map("n", "<leader>ma", '<cmd>lua require"metals".open_all_diagnostics()<CR>')
map("n", "<leader>ld", "<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>") -- buffer diagnostics only
map("n", "[d", "<cmd>lua vim.lsp.diagnostic.goto_prev { wrap = false }<CR>")
map("n", "]d", "<cmd>lua vim.lsp.diagnostic.goto_next { wrap = false }<CR>")
map("n", "<leader>tt", [[<cmd>lua require("metals.tvp").toggle_tree_view()<CR>]])
map("n", "<leader>tr", [[<cmd>lua require("metals.tvp").reveal_in_tree()<CR>]])
-- completion related settings
require("compe").setup({
enabled = true,
debug = false,
min_length = 1,
source = {
path = true,
buffer = true,
vsnip = {
filetypes = { "scala", "sbt", "java" },
},
nvim_lsp = {
priority = 1000,
filetypes = { "scala", "sbt", "java" },
},
},
})
map("i", "<S-Tab>", 'pumvisible() ? "\\<C-p>" : "\\<Tab>"', { expr = true })
map("i", "<Tab>", 'pumvisible() ? "\\<C-n>" : "\\<Tab>"', { expr = true })
map("i", "<CR>", 'compe#confirm("\\<CR>")', { expr = true })
----------------------------------
-- COMMANDS ----------------------
----------------------------------
-- LSP
cmd([[augroup lsp]])
cmd([[autocmd!]])
cmd([[autocmd FileType scala setlocal omnifunc=v:lua.vim.lsp.omnifunc]])
cmd([[autocmd FileType scala,sbt lua require("metals").initialize_or_attach(metals_config)]])
cmd([[augroup end]])
-- Need for symbol highlights to work correctly
vim.cmd([[hi! link LspReferenceText CursorColumn]])
vim.cmd([[hi! link LspReferenceRead CursorColumn]])
vim.cmd([[hi! link LspReferenceWrite CursorColumn]])
----------------------------------
-- LSP Setup ---------------------
----------------------------------
metals_config = require("metals").bare_config
-- Example of settings
metals_config.settings = {
showImplicitArguments = true,
excludedPackages = { "akka.actor.typed.javadsl", "com.github.swagger.akka.javadsl" },
serverProperties = { "-Dmetals.enabled=true" }
}
-- I *highly* recommend setting statusBarProvider to true, however if you do,
-- you *have* to have a setting to display this in your statusline or else
-- you'll not see any messages from metals. There is more info in the help
-- docs about this
metals_config.init_options.statusBarProvider = "on"
-- Example if you are including snippets
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true
metals_config.capabilities = capabilities
EOF
nnoremap <silent> <space>du :DBUI <CR>
let g:db_ui_use_nerd_fonts = 1
let g:db_ui_winwidth = 50
let g:db_ui_win_position = 'right'
endfunction