-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.lua
143 lines (121 loc) · 4.37 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
setmetatable(_G, { __index = vim })
-- Load basic configuration
cmd.runtime 'vimrc'
-- NOTE: UI config is in plugin/ui.lua
cmd.colorscheme 'melange'
opt.statusline = '%2{mode()} | %f %m %r %= %{&spelllang} %y #%{bufnr()} %8(%l,%c%) %8p%%'
do -- Spelling
-- NOTE: Use i_CTRL-X_s to correct spelling of previous misspelled word
keymap.set('n', '<leader>l', function()
ui.select({ 'en', 'es', 'de' }, {}, function(lang)
opt.spell = lang ~= nil
opt.spelllang = lang
end)
end)
end
----- Plugins ------------------------------------------------------------------
do -- Paq
keymap.set('n', '<leader>pq', function()
package.loaded.paq = nil
package.loaded.plugins = nil
require('plugins').sync_all()
end)
keymap.set('n', '<leader>pg', function() cmd.edit(fn.stdpath 'config' .. '/lua/plugins.lua') end)
end
do -- Markup
g.disable_rainbow_hover = true
g.latex_to_unicode_file_types = { 'julia', 'typst' }
g.markdown_enable_conceal = true
g.markdown_enable_insert_mode_mappings = false
g.wiki_root = '~/Documents/wiki'
g.wiki_link_creation = {
md = {
url_transform = function(txt) return txt:lower():gsub('%s+', '-') end,
},
}
--- TODO: Refactor
api.nvim_create_user_command('WikiPick', function()
MiniPick.builtin.grep_live(nil, { source = { cwd = g.wiki_root } })
end, {})
end
do -- Tree-sitter
opt.foldmethod = 'expr'
opt.foldexpr = 'nvim_treesitter#foldexpr()'
require('nvim-treesitter.configs').setup {
-- ensure_installed = { 'c', 'html', 'julia', 'lua', 'python', 'query', 'rust', 'typescript', 'markdown', 'markdown_inline' },
highlight = { enable = true },
indent = { enable = true },
incremental_selection = {
enable = true,
keymaps = { init_selection = '+', node_incremental = '+', node_decremental = '_' },
},
textobjects = {
select = {
enable = true,
keymaps = {
['ac'] = '@call.outer',
['af'] = '@function.outer',
['if'] = '@function.inner',
['ak'] = '@conditional.outer',
['at'] = '@class.outer',
},
},
},
}
end
do -- LSP & Diagnostics
local lspconfig = require 'lspconfig'
for _, ls in ipairs {
'clangd',
'rust_analyzer',
'denols',
-- 'ocamllsp',
-- 'svelte',
-- 'ts_ls',
} do
lspconfig[ls].setup {}
end
api.nvim_create_autocmd('LspAttach', {
group = api.nvim_create_augroup('LspConfig', {}),
callback = function(args)
-- Disable virtual text
diagnostic.config {
float = { focus = false },
virtual_text = false,
}
-- stylua: ignore
for name, fn in pairs {
DxList = diagnostic.setloclist,
DxShow = diagnostic.show,
LspAction = lsp.buf.code_action,
LspSymbols = lsp.buf.document_symbol,
LspFormat = lsp.buf.format,
LspImpl = lsp.buf.implementation,
LspRefs = lsp.buf.references,
LspRename = lsp.buf.rename,
LspTypeDef = lsp.buf.type_definition,
} do
api.nvim_create_user_command(name, function(_) fn() end, {})
end
-- NOTE: By default: ]d -> goto_next, [d -> goto_prev, K -> hover
keymap.set('n', 'gd', lsp.buf.definition)
local gr = api.nvim_create_augroup('Lsp', {})
api.nvim_create_autocmd(
'BufWritePre',
{ buffer = args.buf, callback = function(_) lsp.buf.format() end, group = gr }
)
api.nvim_create_autocmd(
'CursorHold',
{ buffer = args.buf, callback = function(_) diagnostic.open_float() end, group = gr }
)
end,
})
end
do -- Auto-completion
require('mini.completion').setup()
keymap.set('i', '<Tab>', [[pumvisible() ? "\<C-n>" : "\<Tab>"]], { expr = true })
keymap.set('i', '<S-Tab>', [[pumvisible() ? "\<C-p>" : "\<S-Tab>"]], { expr = true })
end
require('mini.diff').setup()
require('mini.pick').setup()
require('mini.trailspace').setup()