-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
299 lines (275 loc) · 7.12 KB
/
init.lua
File metadata and controls
299 lines (275 loc) · 7.12 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
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
vim.g.mapleader = " "
vim.g.maplocalleader = " "
vim.opt.termguicolors = true
-- close buffer
vim.keymap.set("n", "<leader>x", "<cmd>bdelete<cr>", { desc = "Close buffer" })
-- tabs
vim.keymap.set("n", "<Tab>", "<cmd>bnext<CR>", { desc = "Next buffer" })
vim.keymap.set("n", "<S-Tab>", "<cmd>bprevious<CR>", { desc = "Previous buffer" })
-- Indentation
vim.opt.tabstop = 2
vim.opt.shiftwidth = 2
vim.opt.expandtab = true
vim.opt.softtabstop = 2
-- Disable line wrapping
vim.opt.wrap = false
-- Line numbers
vim.opt.number = true
-- Centered search navigation
vim.keymap.set("n", "n", "nzz")
vim.keymap.set("n", "N", "Nzz")
vim.keymap.set("n", "<Esc>", "<cmd>nohlsearch<CR>")
-- Disable diagnostics
vim.diagnostic.enable(false)
-- R directive highlighting (#> comments)
vim.api.nvim_set_hl(0, "@keyword.directive.r", { fg = "#7A7A7A", bold = true })
if not vim.uv.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable",
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
-- Setup lazy.nvim with plugins
require("lazy").setup({
{
"nvim-treesitter/nvim-treesitter",
build = ":TSUpdate",
opts = {
ensure_installed = { "vim", "lua", "vimdoc", "html", "css", "go", "javascript", "r", "c" },
highlight = { enable = true },
},
},
{
"devOpifex/veem",
lazy = false,
priority = 1000,
config = function()
vim.cmd.colorscheme("veem")
end,
},
{
"nvim-telescope/telescope.nvim",
version = "*",
config = function()
require("telescope").setup({
defaults = {
layout_config = {
prompt_position = "top",
},
sorting_strategy = "ascending",
},
})
require("telescope").load_extension("fzf")
local builtin = require("telescope.builtin")
vim.keymap.set("n", "<leader>ff", builtin.find_files, { desc = "Telescope find files" })
vim.keymap.set("n", "<leader>fw", builtin.live_grep, { desc = "Telescope live grep" })
vim.keymap.set("n", "<leader>fb", builtin.buffers, { desc = "Telescope buffers" })
end,
dependencies = {
"nvim-lua/plenary.nvim",
-- optional but recommended
{ "nvim-telescope/telescope-fzf-native.nvim", build = "make" },
},
},
-- File tree
{
"nvim-tree/nvim-tree.lua",
dependencies = { "nvim-tree/nvim-web-devicons" },
keys = {
{ "<leader>e", "<cmd>NvimTreeToggle<cr>", desc = "Toggle file tree" },
},
opts = {
view = {
width = 30,
},
filters = {
dotfiles = false,
custom = {},
git_ignored = false,
},
renderer = {
icons = {
show = {
file = true,
folder = true,
folder_arrow = false,
git = false,
},
},
},
git = {
enable = false,
},
},
},
-- Mason: LSP server installer
{
"williamboman/mason.nvim",
opts = {},
},
{
"williamboman/mason-lspconfig.nvim",
dependencies = { "mason.nvim" },
opts = {
ensure_installed = { "gopls", "ts_ls" },
},
},
{
"WhoIsSethDaniel/mason-tool-installer.nvim",
dependencies = { "mason.nvim" },
opts = {
ensure_installed = { "eslint_d", "prettier", "goimports" },
},
},
-- LSP configuration (nvim 0.11+ native API)
{
"neovim/nvim-lspconfig",
dependencies = { "mason-lspconfig.nvim", "blink.cmp" },
config = function()
local capabilities = require("blink.cmp").get_lsp_capabilities()
vim.lsp.config("gopls", { capabilities = capabilities })
vim.lsp.config("ts_ls", { capabilities = capabilities })
-- R language server (formatting disabled, air handles it)
vim.lsp.config("r_language_server", {
capabilities = capabilities,
on_attach = function(client, _)
client.server_capabilities.documentFormattingProvider = false
client.server_capabilities.documentRangeFormattingProvider = false
end,
})
-- Air formatter for R (with 3s timeout for format-on-save)
vim.lsp.config("air", {
capabilities = capabilities,
on_attach = function(_, bufnr)
vim.api.nvim_create_autocmd("BufWritePre", {
buffer = bufnr,
callback = function()
vim.lsp.buf.format({ timeout_ms = 3000 })
end,
})
end,
})
-- LSP keymaps (only active when LSP is attached)
vim.api.nvim_create_autocmd("LspAttach", {
callback = function(args)
local opts = { buffer = args.buf }
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
vim.keymap.set("i", "<C-k>", vim.lsp.buf.signature_help, opts)
end,
})
vim.lsp.enable({ "gopls", "ts_ls", "r_language_server", "air" })
end,
},
-- Supermaven: AI code completion
{
"supermaven-inc/supermaven-nvim",
config = function()
require("supermaven-nvim").setup({
keymaps = {
accept_suggestion = "<M-x>",
},
})
end,
},
-- Completion
{
"saghen/blink.cmp",
version = "*",
opts = {
keymap = {
preset = "none",
["<Tab>"] = { "select_next", "fallback" },
["<S-Tab>"] = { "select_prev", "fallback" },
["<CR>"] = { "accept", "fallback" },
["<C-Space>"] = { "show" },
["<C-e>"] = { "hide" },
},
completion = {
list = {
selection = { preselect = true, auto_insert = false },
},
},
sources = {
default = { "lsp", "path", "buffer" },
},
signature = { enabled = true },
},
},
-- Formatting
{
"stevearc/conform.nvim",
event = "BufWritePre",
opts = {
formatters_by_ft = {
lua = { "stylua" },
javascript = { "eslint_d" },
css = { "prettier" },
go = { "goimports" },
},
format_on_save = {
timeout_ms = 2000,
lsp_fallback = false,
},
},
},
{
"lewis6991/gitsigns.nvim",
config = function()
require("gitsigns").setup({
signs = {
add = { text = "┃" },
change = { text = "┃" },
delete = { text = "_" },
topdelete = { text = "‾" },
changedelete = { text = "~" },
untracked = { text = "┆" },
},
signs_staged = {
add = { text = "┃" },
change = { text = "┃" },
delete = { text = "_" },
topdelete = { text = "‾" },
changedelete = { text = "~" },
untracked = { text = "┆" },
},
signs_staged_enable = true,
signcolumn = true, -- Toggle with `:Gitsigns toggle_signs`
numhl = false, -- Toggle with `:Gitsigns toggle_numhl`
linehl = false, -- Toggle with `:Gitsigns toggle_linehl`
word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff`
watch_gitdir = {
follow_files = true,
},
auto_attach = true,
attach_to_untracked = false,
current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame`
current_line_blame_opts = {
virt_text = true,
virt_text_pos = "eol", -- 'eol' | 'overlay' | 'right_align'
delay = 1000,
ignore_whitespace = false,
virt_text_priority = 100,
use_focus = true,
},
current_line_blame_formatter = "<author>, <author_time:%R> - <summary>",
sign_priority = 6,
update_debounce = 100,
status_formatter = nil, -- Use default
max_file_length = 40000, -- Disable if file is longer than this (in lines)
preview_config = {
-- Options passed to nvim_open_win
style = "minimal",
relative = "cursor",
row = 0,
col = 1,
},
})
end,
},
})