-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinit.lua
More file actions
305 lines (280 loc) · 8.82 KB
/
init.lua
File metadata and controls
305 lines (280 loc) · 8.82 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
require('base')
vim.api.nvim_create_autocmd({ 'BufEnter', 'BufNewFile' }, {
pattern = '*.k1',
callback = function(event)
vim.cmd [[ set filetype=k1 ]]
vim.cmd [[ set syntax=rust ]]
end,
})
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)
local plugins = {
{
"webhooked/kanso.nvim",
lazy = false,
priority = 1000,
config = function()
require("kanso").setup {
bold = true,
italics = false,
keywordStyle = { italic = false },
background = {
dark = "zen",
light = "pearl"
},
foreground = {
-- dark = "saturated",
-- light = "saturated"
}
}
vim.cmd("colorscheme kanso")
vim.defer_fn(function()
for _, group in ipairs({
"DiagnosticUnderlineError",
"DiagnosticUnderlineWarn",
"DiagnosticUnderlineInfo",
"DiagnosticUnderlineHint",
}) do
local hl = vim.api.nvim_get_hl(0, { name = group })
hl.undercurl = false
hl.underline = true
hl.bold = false
vim.api.nvim_set_hl(0, group, hl)
end
end, 50)
vim.defer_fn(function() require('knixstatusline').setup() end, 100)
end
},
{
"j-hui/fidget.nvim",
opts = {
-- options
},
},
{ 'nvim-mini/mini.nvim', version = '*' },
{
"nvim-telescope/telescope.nvim",
-- version = "0.1.8",
dependencies = {
'nvim-lua/plenary.nvim',
{ 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' },
{
"nvim-telescope/telescope-live-grep-args.nvim",
-- This will not install any breaking changes.
-- For major updates, this must be adjusted manually.
version = "^1.0.0",
},
}
},
'lewis6991/gitsigns.nvim',
{
'renerocksai/telekasten.nvim',
dependencies = { 'nvim-telescope/telescope.nvim' },
lazy = true
},
{
'stevearc/oil.nvim',
lazy = false,
enabled = true,
opts = {
columns = {
"size", "mtime"
},
delete_to_trash = true,
skip_confirm_for_simple_edits = true,
keymaps = {
["<C-s>"] = false,
["q"] = "actions.close",
["<esc>"] = "actions.close",
},
view_options = {
is_always_hidden = function(name, bufnr)
return false
end,
sort = {
{ "mtime", "desc" }
}
}
},
keys = {
{ "-", "<cmd>lua require('oil').toggle_float()<cr>", desc = "Open file browser" }
},
},
{
'neovim/nvim-lspconfig',
lazy = true,
config = function()
local format_on_save = false
if format_on_save then
vim.api.nvim_create_autocmd('LspAttach', {
callback = function(args)
local client = vim.lsp.get_client_by_id(args.data.client_id)
if not client then return end
if client.supports_method('textDocument/formatting') then
vim.api.nvim_create_autocmd('BufWritePre', {
buffer = args.buf,
callback = function()
vim.lsp.buf.format({
bufnr = args.buf,
id = client.id,
async = false
})
end
})
end
end
})
end
end
},
{
'zbirenbaum/copilot.lua',
cmd = "Copilot",
event = "InsertEnter",
config = function()
require("copilot").setup({
suggestion = {
enabled = true,
auto_trigger = false,
keymap = {
accept = "<C-CR>",
accept_word = false,
accept_line = false,
next = "<tab>",
prev = false,
dismiss = "<C-e>",
}
}
})
end,
},
{
"folke/flash.nvim",
event = "VeryLazy",
---@type Flash.Config
opts = {
highlight = {
backdrop = false,
matches = false,
},
label = {
style = "overlay"
}
},
-- stylua: ignore
keys = {
{ "s", mode = { "n", "x", "o" }, function() require("flash").jump() end, desc = "Flash" },
{ "<c-s>", mode = { "c" }, function() require("flash").toggle() end, desc = "Toggle Flash Search" },
-- { "S", mode = { "n", "x", "o" }, function() require("flash").treesitter() end, desc = "Flash Treesitter" },
-- { "r", mode = "o", function() require("flash").remote() end, desc = "Remote Flash" },
-- { "R", mode = { "o", "x" }, function() require("flash").treesitter_search() end, desc = "Treesitter Search" },
},
},
{
"scalameta/nvim-metals",
lazy = true,
ft = { "scala", "sbt", "java" },
opts = function()
local metals_config = require("metals").bare_config()
metals_config.on_attach = on_attach
return metals_config
end,
config = function(self, metals_config)
local nvim_metals_group = vim.api.nvim_create_augroup("nvim-metals", { clear = true })
vim.api.nvim_create_autocmd("FileType", {
pattern = self.ft,
callback = function()
require("metals").initialize_or_attach(metals_config)
end,
group = nvim_metals_group,
})
end
},
{
"jake-stewart/multicursor.nvim",
branch = "1.0",
config = function()
local mc = require("multicursor-nvim")
mc.setup()
local set = vim.keymap.set
-- Add or skip cursor above/below the main cursor.
set({"n", "x"}, "<leader>K", function() mc.lineAddCursor(-1) end)
set({"n", "x"}, "<leader>J", function() mc.lineAddCursor(1) end)
set({"n", "x"}, "<leader>K", function() mc.lineSkipCursor(-1) end)
set({"n", "x"}, "<leader>J", function() mc.lineSkipCursor(1) end)
-- Add or skip adding a new cursor by matching word/selection
set({"n", "x"}, "<leader>N", function() mc.matchAddCursor(1) end)
set({"n", "x"}, "<leader>s", function() mc.matchSkipCursor(1) end)
set({"n", "x"}, "<leader>N", function() mc.matchAddCursor(-1) end)
set({"n", "x"}, "<leader>S", function() mc.matchSkipCursor(-1) end)
-- Mappings defined in a keymap layer only apply when there are
-- multiple cursors. This lets you have overlapping mappings.
mc.addKeymapLayer(function(layerSet)
-- Select a different cursor as the main one.
layerSet({"n", "x"}, "<left>", mc.prevCursor)
layerSet({"n", "x"}, "<right>", mc.nextCursor)
layerSet({"n", "x"}, "<C-h>", mc.prevCursor)
layerSet({"n", "x"}, "<C-l>", mc.nextCursor)
layerSet({"n", "x"}, "<C-k>", mc.prevCursor)
layerSet({"n", "x"}, "<C-j>", mc.nextCursor)
-- Disable and enable cursors.
set({"n", "x"}, "<c-q>", mc.toggleCursor)
-- Align cursor columns.
set("n", "<leader>a", mc.alignCursors)
-- Delete the main cursor.
layerSet({"n", "x"}, "<leader>x", mc.deleteCursor)
-- Enable and clear cursors using escape.
layerSet("n", "<esc>", function()
if not mc.cursorsEnabled() then
mc.enableCursors()
else
mc.clearCursors()
end
end)
end)
-- Customize how cursors look.
local hl = vim.api.nvim_set_hl
hl(0, "MultiCursorCursor", { reverse = true })
hl(0, "MultiCursorVisual", { link = "Visual" })
hl(0, "MultiCursorSign", { link = "SignColumn"})
hl(0, "MultiCursorMatchPreview", { link = "Search" })
hl(0, "MultiCursorDisabledCursor", { reverse = true })
hl(0, "MultiCursorDisabledVisual", { link = "Visual" })
hl(0, "MultiCursorDisabledSign", { link = "SignColumn"})
end
}
}
require("lazy").setup(plugins, opts)
require('globals')
vim.lsp.enable('rust_analyzer')
vim.lsp.enable('clangd')
vim.api.nvim_create_user_command("R", function(opts)
-- Expand % and # BEFORE opening new buffer
local current = vim.fn.expand "%:p"
local alt = vim.fn.expand "#:p"
local cmd = opts.args:gsub("%%:p", current):gsub("%%", current):gsub("#", alt)
vim.cmd "new"
vim.bo.buftype = "nofile"
vim.bo.bufhidden = "hide"
vim.bo.swapfile = false
vim.b.no_auto_close = true
vim.fn.termopen(cmd, {
on_stdout = function()
vim.schedule(function()
vim.cmd [[ stopinsert ]]
vim.api.nvim_feedkeys("G", "t", false)
end)
end,
})
vim.api.nvim_buf_set_keymap(0, "n", "q", ":q!<CR>", { noremap = true, silent = true })
end, { nargs = "+", complete = "shellcmdline" })