-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.lua
439 lines (382 loc) Β· 11.7 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
if vim.g.shadowvim then
return
end
local config_path = vim.fn.stdpath("config")
local vim_config
if config_path:find("/") then
vim_config = config_path .. "/config.vim"
else
vim_config = config_path .. "\\config.vim"
end
vim.api.nvim_command("source " .. vim_config)
--require("catppuccin").setup({
--integrations = {
--treesitter = true,
--rainbow_delimiters = true,
--gitgutter = true,
--lsp_trouble = true,
--markdown = true,
--},
--background = {
--light = "latte",
--dark = "frappe",
--},
--styles = {
--comments = { "italic" },
--conditionals = { "italic" },
--functions = { "italic" },
--types = { "bold" },
--},
--})
vim.cmd.colorscheme("wildcharm")
local telescope = require("telescope")
telescope.setup({
defaults = {
layout_config = {
horizontal = {
height = { padding = 1 },
width = { padding = 18 },
prompt_position = "top",
},
vertical = {
height = { padding = 1 },
width = { padding = 18 },
prompt_position = "top",
},
},
wrap_results = true,
mappings = {
i = {
["<C-h>"] = "which_key",
["<C-j>"] = "move_selection_next",
["<C-k>"] = "move_selection_previous",
},
},
file_ignore_patterns = { "project/target", "project/project", "target" },
path_display = { "smart" },
borderchars = { "β", "β", "β", "β", "β", "β", "β", "β" },
sorting_strategy = "ascending",
},
pickers = {
find_files = {},
buffers = {
sort_mru = true,
ignore_current_buffer = true,
},
},
extensions = {
["ui-select"] = {
require("telescope.themes").get_dropdown({
-- even more opts
}),
-- pseudo code / specification for writing custom displays, like the one
-- for "codeactions"
-- specific_opts = {
-- [kind] = {
-- make_indexed = function(items) -> indexed_items, width,
-- make_displayer = function(widths) -> displayer
-- make_display = function(displayer) -> function(e)
-- make_ordinal = function(e) -> string
-- },
-- -- for example to disable the custom builtin "codeactions" display
-- do the following
-- codeactions = false,
-- }
},
live_grep_args = {
auto_quoting = true, -- enable/disable auto-quoting
},
},
})
telescope.load_extension("smart_open")
require("lualine").setup({
options = {
icons_enabled = true,
theme = "catppuccin",
globalstatus = true,
},
sections = {
lualine_a = { "mode" },
lualine_b = {
"branch",
"diff",
{
"diagnostics",
sources = {
--"nvim_lsp",
--"nvim_diagnostic",
"nvim_workspace_diagnostic",
},
},
},
lualine_c = { "filename" },
lualine_x = {},
lualine_y = { "encoding", "fileformat", "filetype",
--"%{CodeStatsXp()}"
},
lualine_z = { "progress", "location" },
},
extensions = { "quickfix" },
})
local lsp = require("lspconfig")
local cmp = require("cmp")
local has_words_before = function()
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end
local feedkey = function(key, mode)
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
end
cmp.setup({
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body)
end,
},
mapping = {
["<C-b>"] = cmp.mapping(cmp.mapping.scroll_docs(-4), { "i", "c" }),
["<C-f>"] = cmp.mapping(cmp.mapping.scroll_docs(4), { "i", "c" }),
["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
["<C-y>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
["<C-e>"] = cmp.mapping({
i = cmp.mapping.abort(),
c = cmp.mapping.close(),
}),
["<CR>"] = cmp.mapping.confirm({ select = true }),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif vim.fn["vsnip#available"](1) == 1 then
feedkey("<Plug>(vsnip-expand-or-jump)", "")
elseif has_words_before() then
cmp.complete()
else
fallback() -- The fallback function sends a already mapped key. In this case, it's probably `<Tab>`.
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function()
if cmp.visible() then
cmp.select_prev_item()
elseif vim.fn["vsnip#jumpable"](-1) == 1 then
feedkey("<Plug>(vsnip-jump-prev)", "")
end
end, { "i", "s" }),
},
sources = cmp.config.sources({ { name = "nvim_lsp" }, { name = "vsnip" } }, { { name = "buffer" } }),
})
cmp.setup.cmdline("/", { sources = { { name = "buffer" } } })
cmp.setup.cmdline(":", {
sources = cmp.config.sources({ { name = "path" } }, { { name = "cmdline" } }),
})
-- local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp
-- .protocol
-- .make_client_capabilities())
-- require('lspconfig')['gopls'].setup {capabilities = capabilities}
--
local keymap_opts = { noremap = true, silent = true }
local on_attach = function(_, bufnr)
-- Mappings
vim.api.nvim_buf_set_keymap(bufnr, "n", "gD", "<Cmd>lua vim.lsp.buf.declaration()<CR>", keymap_opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "gd", "<Cmd>lua vim.lsp.buf.definition()<CR>", keymap_opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "K", "<Cmd>lua vim.lsp.buf.hover()<CR>", keymap_opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", keymap_opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>D", "<cmd>lua vim.lsp.buf.type_definition()<CR>", keymap_opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>rr", "<cmd>lua vim.lsp.buf.rename()<CR>", keymap_opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>e", "<cmd>lua vim.diagnostic.open_float()<CR>", keymap_opts)
vim.api.nvim_buf_set_keymap(
bufnr,
"n",
"<leader>ca",
'<cmd>lua require("actions-preview").code_actions()<CR>',
keymap_opts
)
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>cd", "<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>", keymap_opts)
-- LSP-based omnifunc.
vim.cmd("setlocal omnifunc=v:lua.vim.lsp.omnifunc")
end
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = false
lsp.gopls.setup({
cmd = { "gopls", "--remote=auto" },
filetypes = { "go", "gomod" },
on_attach = on_attach,
capabilities = capabilities,
init_options = { analyses = { composite = false, composites = false } },
settings = { gopls = { usePlaceholders = true, completeUnimported = true } },
})
--lsp.ccls.setup({ on_attach = on_attach })
require("neodev").setup({
-- add any options here, or leave empty to use the default settings
})
lsp.lua_ls.setup({
on_attach = on_attach,
cmd = {
"/Users/fperson/Applications/lua-language-server/bin/lua-language-server",
"-E",
"/Users/fperson/Applications/lua-language-server/main.lua",
},
settings = {
Lua = {
completion = {
callSnippet = "Replace",
},
},
},
})
lsp.jsonls.setup({ on_attach = on_attach })
require("flutter-tools").setup({
ui = {
notifications = "native",
},
lsp = {
on_attach = on_attach,
color = {
enabled = true, -- whether or not to highlight color variables at all, only supported on flutter >= 2.10
background = true, -- highlight the background
},
settings = {
--lineLength = 80,
--lineLength = 100,
lineLength = 120,
analysisExcludedFolders = { vim.fn.expand("$HOME/.pub-cache/"), vim.fn.expand("$HOME/fvm/versions/") },
},
},
})
lsp.pylsp.setup({ on_attach = on_attach })
lsp.vimls.setup({ on_attach = on_attach })
lsp.gdscript.setup({ on_attach = on_attach })
lsp.kotlin_language_server.setup({ on_attach = on_attach })
lsp.vuels.setup({
on_attach = on_attach,
init_options = {
config = {
vetur = { experimental = { templateInterpolationService = true } },
},
},
})
lsp.rust_analyzer.setup({
cmd = { "rustup", "run", "stable", "rust-analyzer" },
on_attach = on_attach,
})
vim.lsp.handlers["textDocument/codeAction"] = require("lsputil.codeAction").code_action_handler
vim.lsp.handlers["textDocument/references"] = require("lsputil.locations").references_handler
vim.lsp.handlers["textDocument/definition"] = require("lsputil.locations").definition_handler
vim.lsp.handlers["textDocument/declaration"] = require("lsputil.locations").declaration_handler
vim.lsp.handlers["textDocument/typeDefinition"] = require("lsputil.locations").typeDefinition_handler
vim.lsp.handlers["textDocument/implementation"] = require("lsputil.locations").implementation_handler
vim.lsp.handlers["textDocument/documentSymbol"] = require("lsputil.symbols").document_handler
vim.lsp.handlers["workspace/symbol"] = require("lsputil.symbols").workspace_handler
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
vim.lsp.diagnostic.on_publish_diagnostics,
{ virtual_text = false, signs = true, update_in_insert = false }
)
-- Telescope mappings
vim.api.nvim_set_keymap(
"n",
"gr",
"<cmd>lua require'telescope.builtin'.lsp_references(require('telescope.themes').get_dropdown({}))<CR>",
keymap_opts
)
vim.api.nvim_set_keymap("n", "<leader>rg", "<cmd>lua require'telescope.builtin'.live_grep()<CR>", keymap_opts)
vim.api.nvim_set_keymap(
"n",
"<C-p>",
"<cmd>lua require'telescope.builtin'.git_files(require('telescope.themes').get_dropdown({}))<CR>",
keymap_opts
)
vim.api.nvim_set_keymap(
"n",
"<leader>pf",
"<cmd>lua require('telescope').extensions.smart_open.smart_open()<CR>",
keymap_opts
)
vim.api.nvim_set_keymap(
"n",
"<leader>ws",
"<cmd>lua require'telescope.builtin'.lsp_workspace_symbols(require('telescope.themes').get_dropdown({}))<CR>",
keymap_opts
)
vim.api.nvim_set_keymap("n", "tt", "<cmd>:Trouble diagnostics toggle<CR>", keymap_opts)
vim.api.nvim_set_keymap(
"n",
"<leader>bb",
"<cmd>lua require'telescope.builtin'.buffers(require('telescope.themes').get_dropdown({}))<CR>",
keymap_opts
)
--require("formatter").setup({
--logging = false,
--filetype = {
--cpp = {
--function()
--return {
--exe = "clang-format",
--args = {
--"--assume-filename",
--vim.api.nvim_buf_get_name(0),
--"--style",
--"Google",
--},
--stdin = true,
--cwd = vim.fn.expand("%:p:h"), -- Run clang-format in cwd of the file.
--}
--end,
--},
--},
--})
--require("null-ls").setup({
--sources = {
----require("null-ls").builtins.formatting.stylua,
---- require("null-ls").builtins.diagnostics.eslint,
----require("null-ls").builtins.completion.spell,
--},
--})
--lsp.tsserver.setup({ on_attach = on_attach })
require("auto-dark-mode").setup({ update_interval = 5000 })
--require("nvim-treesitter.configs").setup({
--ensure_installed = { "lua", "dart" },
--sync_install = false,
--auto_install = false,
--indent = {
--enable = true,
--},
--highlight = {
--enable = true,
--additional_vim_regex_highlighting = false,
--},
--})
require("block").setup()
require("gitblame").setup({
message_template = " <author> β’ <date> β’ <summary> β’ <sha>",
message_when_not_committed = " <author>, <date> β’ <summary>",
date_format = "%r",
set_extmark_options = {
priority = 13,
},
})
local setup, nvimtree = pcall(require, "nvim-tree")
if not setup then
return
end
vim.cmd([[
nnoremap - :NvimTreeToggle<CR>
]])
-- local keymap = vim.keymap -- for conciseness
-- keymap.set("n", "<leader>e", ":NvimTreeToggle<CR>") -- toggle file explorer
-- vim.opt.foldmethod = "expr"
-- vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
-- vim.opt.foldenable = false -- " Disable folding at startup.
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
vim.opt.termguicolors = true
nvimtree.setup({
disable_netrw = true,
hijack_netrw = true,
respect_buf_cwd = true,
sync_root_with_cwd = true,
view = { relativenumber = true },
})
vim.api.nvim_set_keymap("n", "<leader>ff", "<cmd>:NvimTreeToggle<CR>", keymap_opts)
vim.api.nvim_set_keymap("n", "<leader>fc", "<cmd>:NvimTreeFindFile<CR>40<C-w>>", keymap_opts)
require("barbecue").setup({
theme = "catppuccin",
})