-
Notifications
You must be signed in to change notification settings - Fork 6
/
init.lua
544 lines (474 loc) · 17.3 KB
/
init.lua
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
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
require('adaptive')
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup{
'nvim-lua/plenary.nvim',
'https://github.com/nvim-lualine/lualine.nvim',
--'https://github.com/vale1410/vim-minizinc',
'https://github.com/numToStr/Comment.nvim',
'https://github.com/kylechui/nvim-surround',
'norcalli/nvim-colorizer.lua',
'https://github.com/neovim/nvim-lspconfig',
'https://github.com/romainl/vim-cool',
{ dir = '~/Repositories/iswap.nvim' },
'https://github.com/nvim-treesitter/nvim-treesitter',
'https://github.com/nvim-telescope/telescope.nvim',
'https://github.com/tpope/vim-fugitive',
'https://github.com/nvim-treesitter/nvim-treesitter-context',
'https://github.com/lewis6991/gitsigns.nvim',
--'https://github.com/glepnir/lspsaga.nvim',
'https://github.com/pechorin/any-jump.vim',
{ dir = '~/Code/longbow.nvim' },
'https://github.com/nvim-treesitter/playground',
'https://github.com/folke/neodev.nvim',
'https://github.com/rose-pine/neovim',
'https://github.com/stevearc/dressing.nvim',
'https://github.com/hrsh7th/nvim-cmp',
'hrsh7th/cmp-nvim-lsp',
'https://github.com/hrsh7th/cmp-nvim-lsp-signature-help',
'nvim-telescope/telescope-frecency.nvim',
'tami5/sqlite.lua',
--'https://github.com/JuliaEditorSupport/julia-vim',
--'https://github.com/Nymphium/vim-koka',
'lervag/vimtex',
'https://github.com/folke/zen-mode.nvim',
'https://github.com/MrcJkb/haskell-tools.nvim',
'https://github.com/itchyny/vim-haskell-indent',
'https://github.com/L3MON4D3/LuaSnip',
--'https://github.com/vim-scripts/alex.vim',
--'https://github.com/romgrk/kirby.nvim',
'romgrk/fzy-lua-native', -- needs 'make install'
'nvim-tree/nvim-web-devicons',
--'romgrk/kui.nvim',
'kevinhwang91/nvim-ufo',
'kevinhwang91/promise-async',
'https://github.com/hrsh7th/cmp-buffer',
'https://github.com/stevearc/oil.nvim',
'https://github.com/nvim-telescope/telescope-file-browser.nvim',
'https://github.com/junegunn/vim-easy-align',
'ruifm/gitlinker.nvim',
'kaarmu/typst.vim',
-- 'icedman/nvim-textmate',
'https://github.com/ziglang/zig.vim',
'https://github.com/dhruvasagar/vim-table-mode',
'https://github.com/smjonas/inc-rename.nvim',
'https://github.com/natecraddock/telescope-zf-native.nvim',
'https://github.com/ii14/neorepl.nvim',
'goolord/alpha-nvim',
}
vim.cmd [[
xmap ga <Plug>(EasyAlign)
nmap ga <Plug>(EasyAlign)
]]
vim.g.cursorhold_updatetime = 1000
vim.g.vimtex_view_method = 'sioyek'
vim.g.vimtex_view_sioyek_exe = '/Applications/sioyek.app/Contents/MacOS/sioyek'
vim.g.mapleader = ' '
vim.opt.cmdheight = 1
vim.opt.laststatus = 3
vim.opt.cmdheight = 0
vim.opt.splitright = true
vim.opt.splitbelow = true
local cmp = require 'cmp'
cmp.setup({
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body)
end
},
mapping = cmp.mapping.preset.insert({
['<C-b>'] = cmp.mapping.scroll_docs(-1),
['<C-f>'] = cmp.mapping.scroll_docs(1),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(),
['<C-y>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
}),
sources = cmp.config.sources({
{ name = 'luasnip' },
{ name = 'nvim_lsp' },
{ name = 'nvim_lsp_signature_help' },
{ name = 'buffer' },
})
})
vim.opt.termguicolors = true
require('rose-pine').setup({
dark_variant = 'moon',
})
vim.cmd [[colorscheme rose-pine]]
require('lualine').setup {
options = {
theme = 'rose-pine',
section_separators = { left = '', right = '' },
component_separators = ''
}
}
vim.cmd [[set ts=2 sw=2 sts=2 et]]
require('Comment').setup()
require('colorizer').setup {
css = { rgb_fn = true, }
}
require('iswap').setup {
debug = true,
move_cursor = true
}
vim.opt.ignorecase = true
vim.opt.wrap = false
vim.o.completeopt = 'menuone,noinsert,noselect'
vim.o.shortmess = vim.o.shortmess .. 'c'
local opts = { noremap = true, silent = true }
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
local on_attach = function(client, bufnr)
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
local bufopts = { noremap = true, silent = true, buffer = bufnr }
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
vim.keymap.set('n', '<leader>sig', vim.lsp.buf.signature_help, bufopts)
vim.keymap.set('n', '<leader>aws', vim.lsp.buf.add_workspace_folder, bufopts)
vim.keymap.set('n', '<leader>rws', vim.lsp.buf.remove_workspace_folder, bufopts)
vim.keymap.set('n', '<leader>lws', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, bufopts)
vim.keymap.set('n', '<leader>D', vim.lsp.buf.type_definition, bufopts)
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, bufopts)
vim.keymap.set('n', '<leader>ca', vim.lsp.buf.code_action, bufopts)
vim.keymap.set('n', '<leader>gr', vim.lsp.buf.references, bufopts)
vim.keymap.set('n', '<leader>f', function() vim.lsp.buf.format { async = true } end, bufopts)
end
require('lspconfig')['ocamllsp'].setup {
on_attach = on_attach
}
local capabilities = require('cmp_nvim_lsp').default_capabilities()
capabilities.textDocument.foldingRange = {
dynamicRegistration = false,
lineFoldingOnly = true
}
require('lspconfig')['clangd'].setup {
on_attach = on_attach,
capabilities = capabilities
}
require('lspconfig')['julials'].setup {
on_attach = on_attach
}
require('lspconfig')['tsserver'].setup {
on_attach = on_attach
}
require('lspconfig')['pyright'].setup {
on_attach = on_attach,
cmd = { "pyright-langserver", "--stdio", "-v", "/Users/ml/GlobalVenv" }
}
require('lspconfig')['lua_ls'].setup {
on_attach = on_attach,
settings = {
Lua = {
runtime = {
-- Tell the language server which version of Lua you're using
-- (most likely LuaJIT in the case of Neovim)
version = 'LuaJIT',
},
diagnostics = {
-- Get the language server to recognize the `vim` global
globals = {
'vim',
'require'
},
},
workspace = {
-- Make the server aware of Neovim runtime files
library = vim.api.nvim_get_runtime_file("", true),
},
-- Do not send telemetry data containing a randomized but unique identifier
telemetry = {
enable = false,
},
},
},
}
require('lspconfig')['gopls'].setup {
on_attach = on_attach
}
local capabilities = require('cmp_nvim_lsp').default_capabilities()
capabilities.textDocument.foldingRange = {
dynamicRegistration = false,
lineFoldingOnly = true
}
require('lspconfig')['cssls'].setup {
on_attach = on_attach,
capabilities = capabilities,
}
require('lspconfig')['typst_lsp'].setup {
on_attach = on_attach,
settings = {
exportPdf = "onSave",
}
}
require('lspconfig')['zls'].setup {
on_attach = on_attach,
}
require("neodev").setup()
vim.opt.signcolumn = 'yes'
vim.g.python3_host_prog = '~/GlobalVenv/bin/python3.9'
require('nvim-treesitter.configs').setup {
highlight = { enable = true }
}
local function nc(keys, cmd)
vim.keymap.set("n", "<leader>" .. keys, "<cmd>" .. cmd .. "<cr>")
end
local function nl(keys, func)
vim.keymap.set("n", "<leader>" .. keys, func)
end
require('gitsigns').setup {
on_attach = function()
nc("sh", "Gitsigns stage_hunk")
nc("sb", "Gitsigns stage_buffer")
nc("rh", "Gitsigns reset_hunk")
vim.keymap.set("n", "]h", "<cmd>Gitsigns next_hunk<cr>")
vim.keymap.set("n", "[h", "<cmd>Gitsigns prev_hunk<cr>")
nc("pvh", "Gitsigns preview_hunk")
end
}
vim.g.filetype_pl = 'perl'
vim.opt.showmode = false
vim.cmd [[au BufRead,BufNewFile *.pl setf perl]]
vim.g.neovide_cursor_vfx_mode = 'railgun'
vim.opt.guifont = 'JetBrainsMono Nerd Font Mono:h18'
vim.cmd [[
command! -range=% SP <line1>,<line2>w !curl -F 'sprunge=<-' http://sprunge.us | tr -d '\n' | pbcopy
command! -range=% CL <line1>,<line2>w !curl -F 'clbin=<-' https://clbin.com | tr -d '\n' | pbcopy
command! -range=% VP <line1>,<line2>w !curl -F 'text=<-' http://vpaste.net | tr -d '\n' | pbcopy
command! -range=% PB <line1>,<line2>w !curl -F 'c=@-' https://ptpb.pw/?u=1 | tr -d '\n' | pbcopy
command! -range=% IX <line1>,<line2>w !curl -F 'f:1=<-' http://ix.io | tr -d '\n' | pbcopy
command! -range=% EN <line1>,<line2>w !curl -F 'file=@-;' https://envs.sh | tr -d '\n' | pbcopy
command! -range=% TB <line1>,<line2>w !nc termbin.com 9999 | tr -d '\n' | pbcopy
]]
vim.cmd [[set formatoptions-=cro]]
require("zen-mode").setup {
window = {
backdrop = 0.95,
width = 80,
height = 1,
options = {
},
},
plugins = {
options = {
enabled = true,
ruler = false,
showcmd = false,
},
twilight = { enabled = true },
gitsigns = { enabled = false },
tmux = { enabled = false },
kitty = {
enabled = true,
font = "+4", -- font size increment
},
},
on_open = function(win)
end,
on_close = function()
end,
}
require('nvim-surround').setup {
indent_lines = false
}
local ht = require('haskell-tools')
local def_opts = { noremap = true, silent = true, }
ht.setup {
tools = {
hover = {
disable = true
}
},
hls = {
filetypes = { 'haskell', 'lhaskell', 'cabal' },
on_attach = function(client, bufnr)
on_attach(client, bufnr)
local opts = vim.tbl_extend('keep', def_opts, { buffer = bufnr, })
vim.keymap.set('n', '<leader>cll', vim.lsp.codelens.run, opts)
vim.keymap.set('n', '<leader>hs', ht.hoogle.hoogle_signature, opts)
end,
},
}
-- -- Suggested keymaps that do not depend on haskell-language-server
-- -- Toggle a GHCi repl for the current package
-- vim.keymap.set('n', '<leader>rr', ht.repl.toggle, def_opts)
-- -- Toggle a GHCi repl for the current buffer
-- vim.keymap.set('n', '<leader>rf', function()
-- ht.repl.toggle(vim.api.nvim_buf_get_name(0))
-- end, def_opts)
-- vim.keymap.set('n', '<leader>rq', ht.repl.quit, def_opts)
require("telescope").setup {
defaults = {
path_display = { absolute = true }
},
extensions = {
file_browser = {
theme = "ivy",
hijack_netrw = true,
},
frecency = {
show_scores = true,
auto_validate = false
}
},
}
nc("of", "Telescope frecency theme=dropdown")
nc("oo", "Telescope oldfiles theme=dropdown")
nc(",", "Telescope buffers theme=dropdown")
nc(".", "Telescope file_browser")
nc("im", "Telescope lsp_document_symbols")
nc("rg", "Telescope live_grep")
nc("nt", "tabnew")
nc("dt", "tabclose")
nc("gg", "tab Git")
nc("hc", "!cabal run")
vim.cmd [[au FileType tex iabbrev Vr \vec{r}]]
vim.cmd [[au FileType tex iabbrev Vs \vec{s}]]
vim.cmd [[au FileType tex iabbrev Va \vec{a}]]
vim.cmd [[au FileType tex iabbrev Vb \vec{b}]]
vim.cmd [[au FileType tex iabbrev Vv \vec{v}]]
vim.cmd [[au FileType tex iabbrev Vu \vec{u}]]
vim.cmd [[au FileType tex iabbrev Vw \vec{w}]]
vim.cmd [[au FileType tex iabbrev V0 \vec{0}]]
vim.cmd [[au FileType tex iabbrev R2 $\RR^2$]]
vim.cmd [[au FileType tex iabbrev R3 $\RR^3$]]
vim.cmd [[au FileType tex imap <> \tuple*{}<Left>]]
vim.cmd [[au FileType tex imap () \parens*{}<Left>]]
vim.opt.list = true
vim.opt.listchars = "tab:··"
vim.cmd [[
nn <Leader>s<Right> <cmd>ISwapNodeWithRight<CR>
nn <Leader>s<Left> <cmd>ISwapNodeWithLeft<CR>
nn <Leader>ss <cmd>ISwap<CR>
]]
require('ufo').setup()
vim.cmd [[
" press <Tab> to expand or jump in a snippet. These can also be mapped separately
" via <Plug>luasnip-expand-snippet and <Plug>luasnip-jump-next.
imap <silent><expr> <Tab> luasnip#expand_or_jumpable() ? '<Plug>luasnip-expand-or-jump' : '<Tab>'
" -1 for jumping backwards.
inoremap <silent> <S-Tab> <cmd>lua require'luasnip'.jump(-1)<Cr>
snoremap <silent> <Tab> <cmd>lua require('luasnip').jump(1)<Cr>
snoremap <silent> <S-Tab> <cmd>lua require('luasnip').jump(-1)<Cr>
" For changing choices in choiceNodes (not strictly necessary for a basic setup).
imap <silent><expr> <C-E> luasnip#choice_active() ? '<Plug>luasnip-next-choice' : '<C-E>'
smap <silent><expr> <C-E> luasnip#choice_active() ? '<Plug>luasnip-next-choice' : '<C-E>'
]]
require("luasnip.loaders.from_snipmate").lazy_load()
vim.o.foldlevel = 10
vim.o.cursorline = true
require("oil").setup()
vim.cmd [[
au ColorScheme * hi! link NonText WinSeparator
]]
require "telescope".load_extension("frecency")
require("telescope").load_extension("zf-native")
local themes = require('telescope.themes')
vim.api.nvim_create_user_command('Recent', function()
local Path = require "plenary.path"
local os_home = vim.loop.os_homedir()
require 'telescope'.extensions.frecency.frecency(themes.get_dropdown({
path_display = function(path_opts, filename)
if vim.startswith(filename, os_home) then
filename = "~/" .. Path:new(filename):make_relative(os_home)
end
return filename
end,
sorter = require 'telescope.config'.values.file_sorter(),
}))
end, {})
require("telescope").load_extension "file_browser"
local alpha = require("alpha")
local dashboard = require("alpha.themes.dashboard")
-- Set header
dashboard.section.header.val = {
[[ ]],
[[ ]],
[[ ████ ██████ █████ ██ ]],
[[ ███████████ █████ ]],
[[ █████████ ███████████████████ ███ ███████████ ]],
[[ █████████ ███ █████████████ █████ ██████████████ ]],
[[ █████████ ██████████ █████████ █████ █████ ████ █████ ]],
[[ ███████████ ███ ███ █████████ █████ █████ ████ █████ ]],
[[ ██████ █████████████████████ ████ █████ █████ ████ ██████ ]],
[[ ]],
}
dashboard.section.header.val = {
" ",
" ⣴⣶⣤⡤⠦⣤⣀⣤⠆ ⣈⣭⣿⣶⣿⣦⣼⣆ ",
" ⠉⠻⢿⣿⠿⣿⣿⣶⣦⠤⠄⡠⢾⣿⣿⡿⠋⠉⠉⠻⣿⣿⡛⣦ ",
" ⠈⢿⣿⣟⠦ ⣾⣿⣿⣷ ⠻⠿⢿⣿⣧⣄ ",
" ⣸⣿⣿⢧ ⢻⠻⣿⣿⣷⣄⣀⠄⠢⣀⡀⠈⠙⠿⠄ ",
" ⢠⣿⣿⣿⠈ ⣻⣿⣿⣿⣿⣿⣿⣿⣛⣳⣤⣀⣀ ",
" ⢠⣧⣶⣥⡤⢄ ⣸⣿⣿⠘ ⢀⣴⣿⣿⡿⠛⣿⣿⣧⠈⢿⠿⠟⠛⠻⠿⠄ ",
" ⣰⣿⣿⠛⠻⣿⣿⡦⢹⣿⣷ ⢊⣿⣿⡏ ⢸⣿⣿⡇ ⢀⣠⣄⣾⠄ ",
" ⣠⣿⠿⠛ ⢀⣿⣿⣷⠘⢿⣿⣦⡀ ⢸⢿⣿⣿⣄ ⣸⣿⣿⡇⣪⣿⡿⠿⣿⣷⡄ ",
" ⠙⠃ ⣼⣿⡟ ⠈⠻⣿⣿⣦⣌⡇⠻⣿⣿⣷⣿⣿⣿ ⣿⣿⡇ ⠛⠻⢷⣄ ",
" ⢻⣿⣿⣄ ⠈⠻⣿⣿⣿⣷⣿⣿⣿⣿⣿⡟ ⠫⢿⣿⡆ ",
" ⠻⣿⣿⣿⣿⣶⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⡟⢀⣀⣤⣾⡿⠃ ",
}
dashboard.section.header.opts.hl = 'Tag'
local leader = "SPC"
local function button(sc, txt, keybind, keybind_opts)
local sc_ = sc:gsub("%s", ""):gsub(leader, "<leader>")
local opts = {
position = "center",
shortcut = sc,
cursor = 4,
width = 30,
align_shortcut = "right",
hl_shortcut = "WinSeparator",
hl = {
{ 'Boolean', 0, 5 }, -- highlight the icon glyph
{ 'LineNr', 6, 17 }, -- highlight the part after the icon glyph
},
}
if keybind then
keybind_opts = keybind_opts or { noremap = true, silent = true, nowait = true }
opts.keymap = { "n", sc_, keybind, keybind_opts }
end
local function on_press()
local key = vim.api.nvim_replace_termcodes(keybind or sc_ .. "<Ignore>", true, false, true)
vim.api.nvim_feedkeys(key, "t", false)
end
return {
type = "button",
val = txt,
on_press = on_press,
opts = opts,
}
end
-- Set menu
dashboard.section.buttons.val = {
button("SPC o f", " recents", ":Recent<CR>"),
button("SPC . ", " browse", ":Telescope file_browser<CR>"),
button("SPC g g", " git", ":tab Git<CR>"),
button("e ", " new-file", ":ene <BAR> startinsert <CR>"),
button("SPC o o", " oldfiles", ":Telescope oldfiles theme=dropdown<CR>"),
}
dashboard.section.buttons.opts = {
spacing = 0,
}
alpha.setup(dashboard.opts)
vim.cmd([[
autocmd FileType alpha setlocal nofoldenable
]])
vim.cmd[[
augroup highlight_yank
autocmd!
autocmd TextYankPost * silent! lua require'vim.highlight'.on_yank("IncSearch", 1000)
augroup END
]]