-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
269 lines (239 loc) · 6.65 KB
/
init.lua
File metadata and controls
269 lines (239 loc) · 6.65 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
require("plugins")
require("tree-sitter-config")
vim.cmd("source ~/.config/nvim/keybindings.vim")
vim.lsp.set_log_level("off")
local set = vim.opt
set.cursorline = true
set.tabstop = 4
set.softtabstop = 4
set.incsearch = true
set.hlsearch = true
set.colorcolumn = "80"
set.autoindent = true
set.ignorecase = true
set.expandtab = true
set.relativenumber = true
set.clipboard = "unnamed,unnamedplus"
set.ttyfast = true
set.syntax = "true"
set.showmatch = true
set.shiftwidth = 4
set.nu = true
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
vim.opt.termguicolors = true
vim.opt.swapfile = false
-- vim.cmd("colorscheme catpuccin")
vim.g.gruvbox_material_background = "hard"
vim.g.gruvbox_material_foreground = "original"
vim.g.gruvbox_material_transparent_background = 2
-- vim.g.gruvbox_material_background('hard')
vim.cmd.colorscheme("gruvbox-material")
-- setup plugins
require("hop").setup()
require("Comment").setup()
require("toggleterm").setup()
require("gitsigns").setup()
require("dapui").setup()
require("hardline").setup({
bufferline = false, -- disable bufferline
bufferline_settings = {
exclude_terminal = false, -- don't show terminal buffers in bufferline
show_index = false, -- show buffer indexes (not the actual buffer numbers) in bufferline
},
theme = "default", -- change theme
sections = { -- define sections
{ class = "mode", item = require("hardline.parts.mode").get_item },
{ class = "high", item = require("hardline.parts.git").get_item, hide = 100 },
{ class = "med", item = require("hardline.parts.filename").get_item },
"%<",
{ class = "med", item = "%=" },
{ class = "low", item = require("hardline.parts.wordcount").get_item, hide = 100 },
{ class = "error", item = require("hardline.parts.lsp").get_error },
{ class = "warning", item = require("hardline.parts.lsp").get_warning },
{ class = "warning", item = require("hardline.parts.whitespace").get_item },
{ class = "high", item = require("hardline.parts.filetype").get_item, hide = 60 },
{ class = "mode", item = require("hardline.parts.line").get_item },
},
})
vim.diagnostic.config({
virtual_text = true,
})
local lsps = {
{ "rust_analyzer" },
{ "gopls" },
{ "ts_ls" },
{ "cssls" },
{ "lua_ls" },
{ "hls" },
{
"clangd",
{
init_options = {
fallbackFlags = { "--std=c23" },
},
},
},
{"cmake-language-server"}
}
for _, lsp in pairs(lsps) do
local name, config = lsp[1], lsp[2]
vim.lsp.enable(name)
if config then
vim.lsp.config(name, config)
end
end
local cmp = require("cmp")
cmp.setup({
mapping = cmp.mapping.preset.insert({
["<C-d>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(),
["<CR>"] = cmp.mapping.confirm({ select = true }),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
return
end
fallback()
end),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
return
end
fallback()
end),
}),
sources = {
{ name = "nvim_lsp_signature_help" },
{ name = "buffer" },
{ name = "nvim_lsp" },
{ name = "ultisnips" },
{ name = "nvim_lua" },
{ name = "look" },
{ name = "path" },
},
})
local rt = require("rust-tools")
rt.setup({
server = {
on_attach = function(_, bufnr)
-- Hover actions
vim.keymap.set("n", "<C-space>", rt.hover_actions.hover_actions, { buffer = bufnr })
-- Code action groups
vim.keymap.set("n", "<Leader>a", rt.code_action_group.code_action_group, { buffer = bufnr })
end,
},
})
-- Utilities for creating configurations
local util = require("formatter.util")
require("nvim-autopairs").setup({})
-- Provides the Format, FormatWrite, FormatLock, and FormatWriteLock commands
require("formatter").setup({
-- Enable or disable logging
logging = true,
-- Set the log level
log_level = vim.log.levels.WARN,
-- All formatter configurations are opt-in
filetype = {
-- Formatter configurations for filetype "lua" go here
-- and will be executed in order
lua = {
-- "formatter.filetypes.lua" defines default configurations for the
-- "lua" filetype
require("formatter.filetypes.lua").stylua,
-- You can also define your own configuration
function()
-- Supports conditional formatting
if util.get_current_buffer_file_name() == "special.lua" then
return nil
end
-- Full specification of configurations is down below and in Vim help
-- files
return {
exe = "stylua",
args = {
"--search-parent-directories",
"--stdin-filepath",
util.escape_path(util.get_current_buffer_file_path()),
"--",
"-",
},
stdin = true,
}
end,
},
cpp = {
require("formatter.filetypes.cpp").clangformat,
},
c = {
require("formatter.filetypes.c").clangFormat,
},
typescript = {
require("formatter.filetypes.typescript").prettier,
},
-- Use the special "*" filetype for defining formatter configurations on
-- any filetype
["*"] = {
-- "formatter.filetypes.any" defines default configurations for any
-- filetype
-- require("formatter.filetypes.any").remove_trailing_whitespace,
function()
vim.lsp.buf.format()
end,
},
},
})
-- debugger
local dap = require("dap")
dap.adapters.lldb = {
type = "executable",
command = "/usr/local/Cellar/llvm@17/17.0.6/bin/lldb-vscode", -- adjust as needed, must be absolute path
name = "lldb",
}
dap.configurations.cpp = {
{
name = "Launch",
type = "lldb",
request = "launch",
program = function()
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
end,
cwd = "${workspaceFolder}",
stopOnEntry = false,
args = { "${workspaceFolder}/configuration.hora" },
-- 💀
-- if you change `runInTerminal` to true, you might need to change the yama/ptrace_scope setting:
--
-- echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
--
-- Otherwise you might get the following error:
--
-- Error on launch: Failed to attach to the target process
--
-- But you should be aware of the implications:
-- https://www.kernel.org/doc/html/latest/admin-guide/LSM/Yama.html
-- runInTerminal = false,
},
}
require("numb").setup()
function PopulateArgs(text)
local command = string.format("args `rg -l %s`", text)
vim.cmd(command)
end
function Replace(pattern, text)
local command = "argdo %s/" .. pattern .. "/" .. text .. "/gc"
vim.cmd(command)
end
function SaveFiles()
local command = "argdo update"
vim.cmd(command)
end
vim.keymap.set("n", "<Space>rtp", function()
local pattern = vim.fn.input("Enter pattern to search: ")
local replacement = vim.fn.input("Enter replacement for pattern: ")
PopulateArgs(pattern)
Replace(pattern, replacement)
SaveFiles()
end)