-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinit.lua
More file actions
799 lines (728 loc) · 32.5 KB
/
Copy pathinit.lua
File metadata and controls
799 lines (728 loc) · 32.5 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
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
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
-- ============================================
-- MİNİMAL NEOVİM KURULUMU (GELİŞMİŞ LSP)
-- ============================================
-- KULLANILMAYAN PROVIDER'LARI DEVRE DIŞI BIRAK (checkhealth uyarılarını giderir)
vim.g.loaded_perl_provider = 0
vim.g.loaded_ruby_provider = 0
vim.g.loaded_node_provider = 0
-- TEMEL AYARLAR
vim.g.mapleader = " "
vim.opt.clipboard = "unnamedplus"
-- tmux/SSH oturumlarında yank'ı OSC 52 ile karşı makineye taşır (yereldeyken no-op)
require("config.remote_clipboard").setup()
vim.opt.number = true
vim.opt.relativenumber = true
vim.opt.mouse = "a"
vim.opt.ignorecase = true
vim.opt.smartcase = true
vim.opt.hlsearch = false
vim.opt.wrap = false
vim.opt.breakindent = true
vim.opt.tabstop = 2
vim.opt.shiftwidth = 2
vim.opt.expandtab = true
vim.opt.termguicolors = true
vim.opt.signcolumn = "yes"
vim.opt.updatetime = 250
vim.opt.timeoutlen = 300
vim.opt.splitright = true
vim.opt.splitbelow = true
vim.opt.undofile = true
vim.opt.cursorline = true
vim.opt.scrolloff = 8 -- imleç kenara 8 satırdan fazla yaklaşmasın
vim.opt.confirm = true -- kaydedilmemiş dosyada :q -> hata yerine soru
vim.opt.inccommand = "split" -- :%s/ yazarken canlı önizleme (ayrı pencerede)
vim.o.winborder = "rounded" -- TÜM float pencereler yuvarlak kenarlı (hover, diagnostic, vs.)
-- KATLAMA (treesitter tabanlı; LSP destekliyorsa LspAttach'te ona geçilir)
vim.opt.foldmethod = "expr"
vim.opt.foldexpr = "v:lua.vim.treesitter.foldexpr()"
vim.opt.foldlevel = 99 -- dosyalar katlanmış değil, açık açılsın
vim.opt.foldlevelstart = 99
-- TAMAMLAMA (yerleşik autocompletion, Neovim 0.12+)
vim.o.autocomplete = true
vim.opt.complete = { "o", ".^5", "w^5", "b^5" } -- önce LSP (omnifunc), sonra buffer kaynakları (5'er aday)
vim.opt.completeopt = { "menuone", "noselect", "popup", "fuzzy" }
-- Telescope prompt'unda otomatik tamamlama menüsü açılmasın
vim.api.nvim_create_autocmd("FileType", {
pattern = "TelescopePrompt",
callback = function() vim.opt_local.autocomplete = false end,
})
-- TEMEL KISA TUŞLAR
vim.keymap.set("n", "<Esc>", "<cmd>nohlsearch<CR>")
vim.keymap.set("n", "<leader>w", "<cmd>w<CR>", { desc = "Kaydet" })
vim.keymap.set("n", "<leader>q", "<cmd>q<CR>", { desc = "Çık" })
vim.keymap.set("n", "<S-h>", "<cmd>bprevious<CR>", { desc = "Önceki Buffer" })
vim.keymap.set("n", "<S-l>", "<cmd>bnext<CR>", { desc = "Sonraki Buffer" })
vim.keymap.set("n", "<leader>x", "<cmd>bdelete<CR>", { desc = "Buffer Kapat" })
-- Quickfix listesinde gezin (Telescope sonuçlarını <C-q> ile quickfix'e gönderebilirsin)
vim.keymap.set("n", "]q", "<cmd>cnext<CR>", { desc = "Sonraki Quickfix" })
vim.keymap.set("n", "[q", "<cmd>cprevious<CR>", { desc = "Önceki Quickfix" })
-- Terminal modundan normal moda çık (float terminal içinde gezinmek/kopyalamak için)
vim.keymap.set("t", "<Esc><Esc>", "<C-\\><C-n>", { desc = "Terminal: Normal Mod" })
-- TAMAMLAMA TUŞLARI (popup menü + snippet durakları)
vim.keymap.set({ "i", "s" }, "<Tab>", function()
if vim.fn.pumvisible() == 1 then return "<C-n>" end
if vim.snippet.active({ direction = 1 }) then return "<Cmd>lua vim.snippet.jump(1)<CR>" end
return "<Tab>"
end, { expr = true, silent = true })
vim.keymap.set({ "i", "s" }, "<S-Tab>", function()
if vim.fn.pumvisible() == 1 then return "<C-p>" end
if vim.snippet.active({ direction = -1 }) then return "<Cmd>lua vim.snippet.jump(-1)<CR>" end
return "<S-Tab>"
end, { expr = true, silent = true })
vim.keymap.set("i", "<C-Space>", function() vim.lsp.completion.get() end, { desc = "LSP Tamamlama Tetikle" })
-- YARDIMCI AUTOCMD'LER (plugin gerektirmez)
local misc = vim.api.nvim_create_augroup("UserMisc", {})
-- Yank'lanan bölgeyi kısaca vurgula (ne kopyaladığını gör)
vim.api.nvim_create_autocmd("TextYankPost", {
group = misc,
callback = function() vim.hl.on_yank({ timeout = 150 }) end,
})
-- Dosyayı açınca en son bırakılan imleç konumuna dön
vim.api.nvim_create_autocmd("BufReadPost", {
group = misc,
callback = function(ev)
if vim.bo[ev.buf].filetype:match("commit") then return end
local mark = vim.api.nvim_buf_get_mark(ev.buf, '"')
if mark[1] > 0 and mark[1] <= vim.api.nvim_buf_line_count(ev.buf) then
pcall(vim.api.nvim_win_set_cursor, 0, mark)
end
end,
})
-- ============================================
-- LSP KONFİGÜRASYONU VE KISAYOLLAR
-- ============================================
-- Hata mesajlarının görünümü
vim.diagnostic.config({
-- imleçteki satır DIŞINDAKİ satırlar: kısa satır sonu metni
virtual_text = { current_line = false, spacing = 2 },
-- imleçteki satır: mesajın tamamı altta, kesilmeden
virtual_lines = { current_line = true },
signs = {
text = {
[vim.diagnostic.severity.ERROR] = "E",
[vim.diagnostic.severity.WARN] = "W",
[vim.diagnostic.severity.INFO] = "I",
[vim.diagnostic.severity.HINT] = "H",
},
},
update_in_insert = false,
underline = true,
severity_sort = true,
float = {
focusable = false,
style = "minimal",
source = true,
header = "",
prefix = "",
},
})
-- LSP Bağlandığında Çalışacak Tuşlar
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("UserLspConfig", {}),
callback = function(ev)
local opts = { buffer = ev.buf }
local client = vim.lsp.get_client_by_id(ev.data.client_id)
-- Yerleşik LSP tamamlama (snippet açma, auto-import gibi yan etkiler için)
vim.lsp.completion.enable(true, ev.data.client_id, ev.buf)
-- EN ÖNEMLİ TUŞLAR:
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts) -- Dökümantasyonu Görüntüle (Hover)
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts) -- Tanıma Git (Go Definition)
vim.keymap.set("n", "<leader>d", vim.diagnostic.open_float, opts) -- Hata Detayını Gör
vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action, opts) -- Otomatik Düzeltme (Code Action)
vim.keymap.set("n", "]d", function() vim.diagnostic.jump({ count = 1 }) end, opts) -- Sonraki Hataya Git
vim.keymap.set("n", "[d", function() vim.diagnostic.jump({ count = -1 }) end, opts) -- Önceki Hataya Git
vim.keymap.set("n", "<leader>r", vim.lsp.buf.rename, opts) -- Yeniden Adlandır (Rename)
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts) -- Referansları Bul (References)
if not client then return end
-- INLAY HINT: parametre adları ve çıkarılan tipler satır içinde (varsayılan KAPALI, <leader>th ile aç)
if client:supports_method("textDocument/inlayHint") then
vim.keymap.set("n", "<leader>th", function()
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({ bufnr = ev.buf }), { bufnr = ev.buf })
end, { buffer = ev.buf, desc = "Inlay Hint Aç/Kapat" })
end
-- RENK ÖNİZLEME: CSS/Tailwind renk değerlerinin arkası gerçek rengiyle boyanır (nvim-colorizer gerekmez)
if client:supports_method("textDocument/documentColor") then
vim.lsp.document_color.enable(true, { bufnr = ev.buf }, { style = "background" })
end
-- BAĞLI DÜZENLEME: <div> açılışını değiştirince kapanış etiketi kendiliğinden düzelir (nvim-ts-autotag gerekmez)
if client:supports_method("textDocument/linkedEditingRange") then
vim.lsp.linked_editing_range.enable(true, { bufnr = ev.buf })
end
-- LSP tabanlı katlama (treesitter'dan daha isabetli); desteklemiyorsa treesitter'da kalır
if client:supports_method("textDocument/foldingRange") then
vim.wo[vim.api.nvim_get_current_win()][0].foldexpr = "v:lua.vim.lsp.foldexpr()"
end
-- İmleçteki sembolün dosyadaki diğer geçişlerini vurgula
if client:supports_method("textDocument/documentHighlight") then
local hl_group = vim.api.nvim_create_augroup("UserLspHighlight" .. ev.buf, { clear = true })
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
group = hl_group,
buffer = ev.buf,
callback = vim.lsp.buf.document_highlight,
})
vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, {
group = hl_group,
buffer = ev.buf,
callback = vim.lsp.buf.clear_references,
})
end
end,
})
-- LSP SUNUCULARI (Native API — plugin gerektirmez)
-- Lua Language Server
-- settings: bu config'i düzenlerken "Undefined global `vim`" uyarısı çıkmasın ve
-- nvim runtime'ındaki API'ler (vim.lsp.*, vim.pack.*) tamamlanabilsin diye.
vim.lsp.config.lua_ls = {
cmd = { "lua-language-server" },
filetypes = { "lua" },
root_markers = { ".luarc.json", ".luarc.jsonc", ".luacheckrc", ".stylua.toml", "stylua.toml", ".git" },
settings = {
Lua = {
runtime = { version = "LuaJIT" },
diagnostics = { globals = { "vim" } },
workspace = {
library = vim.api.nvim_get_runtime_file("", true),
checkThirdParty = false, -- "bu bir Luassert projesi mi?" pop-up'ını kapatır
},
telemetry = { enable = false },
},
},
}
-- TypeScript Language Server
-- NOT: filetypes'ta "vue" VAR ve @vue/typescript-plugin yüklü — Volar 3.x "hybrid mode" ile çalışır:
-- .vue dosyasındaki <script> bloğunun TypeScript'ini ts_ls yapar, Volar sadece template'i üstlenir.
-- Bu ikisi olmadan SFC içinde hover/gd/tip hatası çalışmaz.
-- Plugin yolu makineye göre değişir (bun global / npm global / Windows APPDATA).
-- Bulunan ilki kullanılır; hiçbiri yoksa plugin listesi boş kalır ve ts_ls normal TS/JS için çalışmaya devam eder.
local function find_vue_ts_plugin()
local candidates = {
vim.fn.expand("~/.bun/install/global/node_modules/@vue/typescript-plugin"),
vim.fn.expand("~/.npm-global/lib/node_modules/@vue/typescript-plugin"),
"/opt/homebrew/lib/node_modules/@vue/typescript-plugin",
"/usr/local/lib/node_modules/@vue/typescript-plugin",
vim.fn.expand("$APPDATA/npm/node_modules/@vue/typescript-plugin"), -- Windows
}
for _, p in ipairs(candidates) do
if vim.uv.fs_stat(p) then return p end
end
end
local vue_ts_plugin = find_vue_ts_plugin()
vim.lsp.config.ts_ls = {
cmd = { "typescript-language-server", "--stdio" },
-- "vue" buradaysa ts_ls SFC'lerin <script> bloğunu üstlenir; plugin yoksa Volar tek başına kalsın diye
-- vue filetype'ı sadece plugin bulunduğunda ekleniyor.
filetypes = vue_ts_plugin
and { "javascript", "javascriptreact", "typescript", "typescriptreact", "vue" }
or { "javascript", "javascriptreact", "typescript", "typescriptreact" },
root_markers = { "package.json", "tsconfig.json", "jsconfig.json", ".git" },
init_options = {
plugins = vue_ts_plugin
and { { name = "@vue/typescript-plugin", location = vue_ts_plugin, languages = { "vue" } } }
or {},
},
}
-- Vue Language Server (Volar)
vim.lsp.config.volar = {
cmd = { "vue-language-server", "--stdio" },
filetypes = { "vue" },
root_markers = { "package.json", ".git" },
}
-- Python: Pyright (tip denetimi) + Ruff (lint + format + import sıralama)
-- Ruff çok daha hızlı lint ettiği için pyright'ın lint'i kapatılıp sadece tip denetimine bırakıldı.
vim.lsp.config.pyright = {
cmd = { "pyright-langserver", "--stdio" },
filetypes = { "python" },
root_markers = { "pyproject.toml", "setup.py", "setup.cfg", "requirements.txt", ".git" },
settings = {
pyright = { disableOrganizeImports = true }, -- import sıralamasını ruff yapıyor
python = { analysis = { ignore = { "*" } } }, -- teşhisleri ruff'a bırak, tip bilgisi kalsın
},
}
vim.lsp.config.ruff = {
cmd = { "ruff", "server" },
filetypes = { "python" },
root_markers = { "pyproject.toml", "ruff.toml", ".ruff.toml", ".git" },
}
-- Go Language Server (gopls)
vim.lsp.config.gopls = {
cmd = { "gopls" },
filetypes = { "go", "gomod", "gowork", "gotmpl" },
root_markers = { "go.mod", "go.work", ".git" },
}
-- Astro Language Server
vim.lsp.config.astro = {
cmd = { "astro-ls", "--stdio" },
filetypes = { "astro" },
root_markers = { "package.json", "astro.config.mjs", "astro.config.ts", ".git" },
}
-- Svelte Language Server
vim.lsp.config.svelte = {
cmd = { "svelteserver", "--stdio" },
filetypes = { "svelte" },
root_markers = { "package.json", "svelte.config.js", "svelte.config.ts", ".git" },
}
-- Tailwind CSS: class tamamlama + renk önizleme + geçersiz class uyarısı
-- root_markers'ta package.json var çünkü Tailwind v4'te config CSS içinde (@import "tailwindcss"),
-- ayrı bir tailwind.config.* dosyası olmayabiliyor.
vim.lsp.config.tailwindcss = {
cmd = { "tailwindcss-language-server", "--stdio" },
filetypes = {
"html", "css", "scss", "javascript", "javascriptreact", "typescript", "typescriptreact",
"vue", "svelte", "astro", "php", "twig", "markdown",
},
root_markers = {
"tailwind.config.js", "tailwind.config.cjs", "tailwind.config.mjs", "tailwind.config.ts",
"postcss.config.js", "postcss.config.mjs", "package.json", ".git",
},
settings = {
tailwindCSS = {
validate = true,
classAttributes = { "class", "className", "classList", "ngClass" },
-- NativeWind / cva / clsx / tailwind-merge içindeki string'ler de tamamlansın
experimental = {
classRegex = {
{ "cva\\(([^)]*)\\)", "[\"'`]([^\"'`]*).*?[\"'`]" },
{ "cx\\(([^)]*)\\)", "(?:'|\"|`)([^']*)(?:'|\"|`)" },
"tw`([^`]*)",
"tw\\.[^`]+`([^`]*)`",
},
},
},
},
}
-- HTML / CSS / JSON (vscode-langservers-extracted)
vim.lsp.config.html = {
cmd = { "vscode-html-language-server", "--stdio" },
filetypes = { "html", "templ" },
root_markers = { "package.json", ".git" },
}
vim.lsp.config.cssls = {
cmd = { "vscode-css-language-server", "--stdio" },
filetypes = { "css", "scss", "less" },
root_markers = { "package.json", ".git" },
settings = {
-- Tailwind direktiflerini "bilinmeyen @kuralı" diye işaretlemesin
css = { lint = { unknownAtRules = "ignore" } },
scss = { lint = { unknownAtRules = "ignore" } },
less = { lint = { unknownAtRules = "ignore" } },
},
}
vim.lsp.config.jsonls = {
cmd = { "vscode-json-language-server", "--stdio" },
filetypes = { "json", "jsonc" },
root_markers = { ".git" },
settings = {
json = {
validate = { enable = true },
-- SchemaStore plugini yerine sık kullanılan şemalar elle bağlandı.
-- Dosyada zaten "$schema" anahtarı varsa (biome.json gibi) o kazanır.
schemas = {
{ fileMatch = { "package.json" }, url = "https://json.schemastore.org/package.json" },
{ fileMatch = { "tsconfig*.json" }, url = "https://json.schemastore.org/tsconfig.json" },
{ fileMatch = { ".eslintrc.json", ".eslintrc" }, url = "https://json.schemastore.org/eslintrc.json" },
{ fileMatch = { "app.json", "app.config.json" }, url = "https://json.schemastore.org/expo-46.0.0.json" },
{ fileMatch = { ".prettierrc", ".prettierrc.json" }, url = "https://json.schemastore.org/prettierrc.json" },
{ fileMatch = { "*.code-workspace" }, url = "https://json.schemastore.org/vscode-workspace.json" },
},
},
},
}
-- ESLint: SADECE eslint config'i olan projelerde açılsın (biome kullanan repolarda hiç bağlanmaz)
vim.lsp.config.eslint = {
cmd = { "vscode-eslint-language-server", "--stdio" },
filetypes = {
"javascript", "javascriptreact", "typescript", "typescriptreact", "vue", "svelte", "astro",
},
-- root_markers YETMEZ: marker bulunamazsa nvim sunucuyu yine de "tek dosya" modunda başlatır.
-- on_dir'i sadece gerçekten eslint config'i varsa çağırarak sunucunun hiç açılmamasını sağlıyoruz.
root_dir = function(bufnr, on_dir)
local found = vim.fs.find({
"eslint.config.js", "eslint.config.mjs", "eslint.config.cjs", "eslint.config.ts",
".eslintrc.js", ".eslintrc.cjs", ".eslintrc.json", ".eslintrc.yaml", ".eslintrc.yml",
}, { path = vim.api.nvim_buf_get_name(bufnr), upward = true })[1]
if found then on_dir(vim.fs.dirname(found)) end
end,
settings = {
validate = "on",
useESLintClass = false,
problems = { shortenToSingleLine = false },
codeAction = {
disableRuleComment = { enable = true, location = "separateLine" },
showDocumentation = { enable = true },
},
},
}
-- YAML (zaten kuruluydu, bağlı değildi). GitHub Actions / docker-compose şemaları dahil.
vim.lsp.config.yamlls = {
cmd = { "yaml-language-server", "--stdio" },
filetypes = { "yaml" },
root_markers = { ".git" },
settings = {
yaml = {
keyOrdering = false, -- alfabetik sıra dayatmasın
schemaStore = { enable = true, url = "https://www.schemastore.org/api/json/catalog.json" },
},
},
}
-- TOML (taplo)
vim.lsp.config.taplo = {
cmd = { "taplo", "lsp", "stdio" },
filetypes = { "toml" },
root_markers = { ".taplo.toml", "taplo.toml", ".git" },
}
-- Bash / sh (shellcheck kurulu olduğu için lint de gelir)
vim.lsp.config.bashls = {
cmd = { "bash-language-server", "start" },
filetypes = { "sh", "bash" },
root_markers = { ".git" },
}
-- Markdown (marksman): başlıklar arası gezinme, [[wiki link]] ve referans tamamlama
vim.lsp.config.marksman = {
cmd = { "marksman", "server" },
filetypes = { "markdown" },
root_markers = { ".marksman.toml", ".git" },
}
vim.lsp.enable({
"lua_ls", "ts_ls", "volar", "pyright", "ruff", "gopls", "astro", "svelte",
"tailwindcss", "html", "cssls", "jsonls", "eslint", "yamlls", "taplo", "bashls", "marksman",
})
-- ============================================
-- YÜZEN TERMİNAL (lazygit & lazydocker — yerleşik API, plugin gerektirmez)
-- ============================================
local float_terms = {}
local function toggle_float_term(cmd)
local t = float_terms[cmd] or {}
float_terms[cmd] = t
if t.win and vim.api.nvim_win_is_valid(t.win) then
vim.api.nvim_win_close(t.win, true)
t.win = nil
return
end
if not (t.buf and vim.api.nvim_buf_is_valid(t.buf)) then
t.buf = vim.api.nvim_create_buf(false, true)
end
local width = math.min(130, vim.o.columns - 4)
local height = math.min(30, vim.o.lines - 4)
t.win = vim.api.nvim_open_win(t.buf, true, {
relative = "editor",
border = "rounded",
width = width,
height = height,
row = math.floor((vim.o.lines - height) / 2) - 1,
col = math.floor((vim.o.columns - width) / 2),
})
if vim.bo[t.buf].buftype ~= "terminal" then
vim.fn.jobstart(cmd, {
term = true,
on_exit = function()
vim.schedule(function()
local cur = float_terms[cmd]
float_terms[cmd] = nil
if cur and cur.win and vim.api.nvim_win_is_valid(cur.win) then
vim.api.nvim_win_close(cur.win, true)
end
end)
end,
})
end
vim.cmd.startinsert()
end
vim.keymap.set("n", "<leader>lg", function() toggle_float_term("lazygit") end, { desc = "Lazygit" })
vim.keymap.set("n", "<leader>ld", function() toggle_float_term("lazydocker") end, { desc = "Lazydocker" })
vim.keymap.set("n", "<leader>tt", function() toggle_float_term(vim.o.shell) end, { desc = "Yüzen Terminal" })
-- ============================================
-- PLUGINLER (yerleşik vim.pack — Neovim 0.12+)
-- ============================================
vim.api.nvim_create_autocmd("PackChanged", {
callback = function(ev)
local name, kind = ev.data.spec.name, ev.data.kind
-- Treesitter güncellenince parser'ları da güncelle (lazy'deki build = ":TSUpdate" karşılığı)
if name == "nvim-treesitter" and kind == "update" then
vim.schedule(function() require("nvim-treesitter").update() end)
end
-- fzf-native bir C kütüphanesi; kurulum/güncelleme sonrası derlenmesi gerekiyor
if name == "telescope-fzf-native.nvim" and (kind == "install" or kind == "update") then
vim.notify("telescope-fzf-native derleniyor...", vim.log.levels.INFO)
vim.system({ "make" }, { cwd = ev.data.path }, function(out)
vim.schedule(function()
if out.code == 0 then
vim.notify("telescope-fzf-native derlendi", vim.log.levels.INFO)
else
vim.notify("telescope-fzf-native derlenemedi: " .. (out.stderr or ""), vim.log.levels.ERROR)
end
end)
end)
end
end,
})
vim.pack.add({
"https://github.com/projekt0n/github-nvim-theme",
"https://github.com/nvim-lua/plenary.nvim", -- bağımlılık: telescope, neo-tree
"https://github.com/nvim-telescope/telescope.nvim",
"https://github.com/nvim-telescope/telescope-fzf-native.nvim", -- C tabanlı fuzzy eşleme (hız)
{ src = "https://github.com/nvim-treesitter/nvim-treesitter", version = "main" },
-- textobjects nvim-treesitter ile AYNI branch'te olmalı (main), yoksa API uyuşmaz
{ src = "https://github.com/nvim-treesitter/nvim-treesitter-textobjects", version = "main" },
"https://github.com/nvim-tree/nvim-web-devicons", -- bağımlılık: neo-tree
"https://github.com/MunifTanjim/nui.nvim", -- bağımlılık: neo-tree
"https://github.com/nvim-neo-tree/neo-tree.nvim",
"https://github.com/lewis6991/gitsigns.nvim",
"https://github.com/stevearc/conform.nvim",
"https://github.com/windwp/nvim-autopairs",
"https://github.com/kylechui/nvim-surround", -- cs"' / ysiw) / ds" (native karşılığı yok)
"https://github.com/ThePrimeagen/vim-be-good",
"https://github.com/aburakt/gobag.nvim", -- offline/çapraz-platform config paketleyici (:Bundle)
}, { confirm = false })
-- gobag: kurulu config'i offline kurulabilir pakete çevirir (intranet Windows için)
require("gobag").setup({
targets = { "windows-x64" }, -- :Bundle -> Windows paketi. Başka hedef: :Bundle macos-arm64 vb.
})
-- :Vimpack = plugin güncellemelerini denetle (onaylamak için :w, vazgeçmek için :q, sonra :restart)
vim.api.nvim_create_user_command("Vimpack", function()
vim.pack.update()
end, { desc = "Pluginleri Güncelle" })
-- TEMA
require("github-theme").setup({
options = {
transparent = true,
styles = { sidebars = "transparent", floats = "transparent" },
},
})
vim.cmd([[colorscheme github_dark_default]])
-- TELESCOPE
require("telescope").setup({
defaults = {
file_ignore_patterns = { "%.git/", "node_modules/" },
},
pickers = {
find_files = {
hidden = true,
},
live_grep = {
additional_args = { "--hidden" },
},
},
extensions = {
fzf = {
fuzzy = true,
override_generic_sorter = true,
override_file_sorter = true,
case_mode = "smart_case",
},
},
})
pcall(require("telescope").load_extension, "fzf")
local tb = require("telescope.builtin")
vim.keymap.set("n", "<leader>f", "<cmd>Telescope find_files hidden=true<cr>", { desc = "Dosya Bul" })
vim.keymap.set("n", "<leader>g", "<cmd>Telescope live_grep additional_args={'--hidden'}<cr>", { desc = "Metin Ara" })
vim.keymap.set("n", "<leader>b", "<cmd>Telescope buffers<cr>", { desc = "Açık Dosyalar" })
vim.keymap.set("n", "<leader>fd", tb.diagnostics, { desc = "Tüm Hatalar (Proje)" })
vim.keymap.set("n", "<leader>fr", tb.resume, { desc = "Son Aramaya Dön" })
vim.keymap.set("n", "<leader>fo", tb.oldfiles, { desc = "Son Açılan Dosyalar" })
vim.keymap.set("n", "<leader>fg", tb.git_status, { desc = "Git Değişiklikleri" })
vim.keymap.set("n", "<leader>fs", tb.lsp_document_symbols, { desc = "Dosyadaki Semboller" })
vim.keymap.set("n", "<leader>fw", tb.lsp_dynamic_workspace_symbols, { desc = "Projedeki Semboller" })
vim.keymap.set("n", "<leader>fh", tb.help_tags, { desc = "Yardım Ara" })
vim.keymap.set("n", "<leader>fk", tb.keymaps, { desc = "Kısayolları Listele" })
-- DOSYA TİPİ DÜZELTMELERİ
-- .m: varsayılan MATLAB olarak algılanır; iOS projelerinde Objective-C'dir
-- .mdx: nvim algılamaz; markdown parser'ıyla renklensin (mdx için ayrı parser yok)
vim.filetype.add({
extension = {
m = "objc",
mdx = "markdown",
},
})
-- TREESITTER (main branch - Neovim 0.11+ uyumlu API)
local langs = {
"lua", "javascript", "typescript", "tsx", "python", "html", "css", "vue", "go", "astro", "svelte",
-- config / veri dosyaları (json = biome.json; bun.lock -> jsonc filetype'ı json parser'ını kullanır)
"json", "json5", "yaml", "toml", "markdown", "markdown_inline", "bash",
-- diğer diller (php, java, scss, sql, c/c++, xml/svg, objc, docker, graphql, prisma)
"php", "java", "scss", "sql", "c", "cpp", "xml", "objc", "dockerfile", "graphql", "prisma", "gitignore",
"properties", "swift", "c_sharp", "twig",
}
require("nvim-treesitter").install(langs)
-- Highlight'ı dosya tipi açıldığında başlat
vim.api.nvim_create_autocmd("FileType", {
callback = function(args)
local ok = pcall(vim.treesitter.start, args.buf)
if ok then
vim.bo[args.buf].indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
end
end,
})
-- TREESITTER TEXTOBJECTS (main branch: modül yok, keymap'ler elle bağlanır)
require("nvim-treesitter-textobjects").setup({
select = {
lookahead = true, -- imleç henüz fonksiyonun içinde değilse öndeki en yakınına atla
include_surrounding_whitespace = false,
},
move = { set_jumps = true }, -- <C-o> ile geri dönebilmek için jumplist'e yaz
})
local ts_select = require("nvim-treesitter-textobjects.select")
local ts_move = require("nvim-treesitter-textobjects.move")
-- af/if = fonksiyon, ac/ic = sınıf, aa/ia = parametre, ai/ii = koşul-döngü gövdesi
local textobjects = {
["af"] = "@function.outer", ["if"] = "@function.inner",
["ac"] = "@class.outer", ["ic"] = "@class.inner",
["aa"] = "@parameter.outer", ["ia"] = "@parameter.inner",
["ai"] = "@conditional.outer",["ii"] = "@conditional.inner",
["al"] = "@loop.outer", ["il"] = "@loop.inner",
["a/"] = "@comment.outer", ["i/"] = "@comment.inner",
}
for key, query in pairs(textobjects) do
vim.keymap.set({ "x", "o" }, key, function()
ts_select.select_textobject(query, "textobjects")
end, { desc = "Textobject " .. query })
end
-- ]f / [f = sonraki/önceki fonksiyon, ]c* çakışmasın diye sınıf için ]m kullanıldı
vim.keymap.set({ "n", "x", "o" }, "]f", function() ts_move.goto_next_start("@function.outer", "textobjects") end, { desc = "Sonraki Fonksiyon" })
vim.keymap.set({ "n", "x", "o" }, "[f", function() ts_move.goto_previous_start("@function.outer", "textobjects") end, { desc = "Önceki Fonksiyon" })
vim.keymap.set({ "n", "x", "o" }, "]m", function() ts_move.goto_next_start("@class.outer", "textobjects") end, { desc = "Sonraki Sınıf" })
vim.keymap.set({ "n", "x", "o" }, "[m", function() ts_move.goto_previous_start("@class.outer", "textobjects") end, { desc = "Önceki Sınıf" })
-- NEO-TREE
require("neo-tree").setup({
filesystem = {
follow_current_file = { enabled = true },
filtered_items = {
visible = true,
hide_dotfiles = false,
hide_gitignored = false,
},
},
})
vim.keymap.set("n", "<leader>e", "<cmd>Neotree toggle<cr>", { desc = "Dosya Ağacı" })
-- GITSIGNS
require("gitsigns").setup({
signs = {
add = { text = "│" },
change = { text = "│" },
delete = { text = "_" },
topdelete = { text = "‾" },
changedelete = { text = "~" },
},
on_attach = function(bufnr)
local gs = package.loaded.gitsigns
local opts = { buffer = bufnr }
vim.keymap.set("n", "]c", function() gs.nav_hunk("next") end, opts)
vim.keymap.set("n", "[c", function() gs.nav_hunk("prev") end, opts)
vim.keymap.set("n", "<leader>hp", gs.preview_hunk, { buffer = bufnr, desc = "Hunk Önizle" })
vim.keymap.set("n", "<leader>hr", gs.reset_hunk, { buffer = bufnr, desc = "Hunk Geri Al" })
vim.keymap.set("n", "<leader>hb", gs.blame_line, { buffer = bufnr, desc = "Satır Blame" })
vim.keymap.set("n", "<leader>hs", gs.stage_hunk, { buffer = bufnr, desc = "Hunk Stage" })
vim.keymap.set("v", "<leader>hs", function()
gs.stage_hunk({ vim.fn.line("."), vim.fn.line("v") })
end, { buffer = bufnr, desc = "Seçimi Stage" })
vim.keymap.set("n", "<leader>hS", gs.stage_buffer, { buffer = bufnr, desc = "Dosyayı Stage" })
vim.keymap.set("n", "<leader>hu", gs.undo_stage_hunk, { buffer = bufnr, desc = "Stage Geri Al" })
vim.keymap.set("n", "<leader>hd", gs.diffthis, { buffer = bufnr, desc = "Dosya Diff" })
end,
})
-- CONFORM (Formatter)
require("conform").setup({
formatters_by_ft = {
lua = { "stylua" },
javascript = { "biome", "prettier", stop_after_first = true },
javascriptreact = { "biome", "prettier", stop_after_first = true },
typescript = { "biome", "prettier", stop_after_first = true },
typescriptreact = { "biome", "prettier", stop_after_first = true },
json = { "biome", "prettier", stop_after_first = true },
jsonc = { "biome", "prettier", stop_after_first = true },
css = { "biome", "prettier", stop_after_first = true },
scss = { "prettier" },
vue = { "prettier" },
astro = { "prettier" },
svelte = { "prettier" },
html = { "prettier" },
yaml = { "prettier" },
markdown = { "prettier" },
python = { "ruff_organize_imports", "ruff_format" }, -- black'ten hızlı, import sıralamayı da yapar
go = { "gofmt" },
toml = { "taplo" },
sh = { "shfmt" },
bash = { "shfmt" },
},
format_on_save = function(bufnr)
-- KAÇIŞ KAPISI: başkasının repo'sunda stili ezmemek için kapatılabilir.
-- :FormatDisable (bu buffer) / :FormatDisable! (global) / :FormatEnable
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
return nil
end
return { timeout_ms = 1000, lsp_format = "fallback" }
end,
})
vim.api.nvim_create_user_command("FormatDisable", function(args)
if args.bang then
vim.b.disable_autoformat = true
vim.notify("Kaydederken format: bu dosyada KAPALI")
else
vim.g.disable_autoformat = true
vim.notify("Kaydederken format: her yerde KAPALI")
end
end, { desc = "Kaydederken formatı kapat", bang = true })
vim.api.nvim_create_user_command("FormatEnable", function()
vim.b.disable_autoformat = false
vim.g.disable_autoformat = false
vim.notify("Kaydederken format: AÇIK")
end, { desc = "Kaydederken formatı aç" })
vim.keymap.set({ "n", "v" }, "<leader>cf", function()
require("conform").format({ async = true, lsp_format = "fallback" })
end, { desc = "Format" })
vim.keymap.set("n", "<leader>tF", function()
vim.g.disable_autoformat = not vim.g.disable_autoformat
vim.notify("Kaydederken format: " .. (vim.g.disable_autoformat and "KAPALI" or "AÇIK"))
end, { desc = "Otomatik Format Aç/Kapat" })
-- AUTOPAIRS
require("nvim-autopairs").setup({})
-- SURROUND: ysiw" = kelimeyi tırnakla sar, cs"' = tırnağı değiştir, ds" = tırnağı kaldır
require("nvim-surround").setup({})
-- VIM-BE-GOOD: setup gerektirmiyor, :VimBeGood komutu kendiliğinden gelir
-- ============================================
-- KISAYOL ÖZETİ
-- ============================================
-- --- LSP ---
-- K = İmleçteki kodun dökümanını oku (Hover)
-- Tab / S-Tab = Tamamlama menüsünde gezin (snippet içinde: durak atla)
-- Enter = Seçili tamamlamayı kabul et
-- Ctrl+Space = LSP tamamlamayı elle tetikle
-- Space + d = Hata detayını pencerede gör
-- ]d / [d = Sonraki / Önceki hata
-- gd = Tanıma git (Go Definition)
-- gr = Referansları bul (References)
-- Space + ca = Hata düzeltme önerileri (Code Action)
-- Space + r = Değişken adını her yerde değiştir (Rename)
-- Space + th = Inlay hint (tip ipuçları) aç/kapat
-- --- ARAMA (Telescope) ---
-- Space + f = Dosya bul Space + fd = Projedeki tüm hatalar
-- Space + g = Metin ara Space + fr = Son aramaya dön
-- Space + b = Açık dosyalar Space + fo = Son açılan dosyalar
-- Space + fs = Dosya sembolleri Space + fw = Proje sembolleri
-- Space + fg = Git değişiklikleri Space + fh = Yardım ara
-- Space + fk = Kısayolları listele
-- --- DÜZENLEME ---
-- ysiw" / cs"' / ds" = Sar / Değiştir / Kaldır (surround)
-- af / if = Fonksiyonun tamamı / gövdesi (daf = fonksiyonu sil)
-- ac / ic = Sınıfın tamamı / gövdesi
-- aa / ia = Parametre ai / ii = Koşul al / il = Döngü
-- ]f / [f = Sonraki / Önceki fonksiyon
-- ]m / [m = Sonraki / Önceki sınıf
-- gc / gcc = Yorum satırı yap (yerleşik)
-- --- FORMAT ---
-- Space + cf = Manuel format
-- Space + tF = Kaydederken formatı aç/kapat
-- :FormatDisable! = Sadece bu dosyada kapat :FormatEnable = Geri aç
-- --- GIT ---
-- ]c / [c = Sonraki / Önceki git hunk
-- Space + hp = Hunk önizle Space + hs = Hunk stage
-- Space + hr = Hunk geri al Space + hS = Dosyayı stage
-- Space + hb = Satır blame Space + hu = Stage geri al
-- Space + hd = Dosya diff
-- --- DİĞER ---
-- Shift + H/L = Önceki / Sonraki buffer Space + x = Buffer kapat
-- ]q / [q = Quickfix listesinde gezin
-- Space + e = Dosya ağacı
-- Space + lg = Lazygit Space + ld = Lazydocker
-- Space + tt = Yüzen terminal Esc Esc = Terminalden normal moda
-- ============================================