-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinit.lua
More file actions
1337 lines (1237 loc) · 45 KB
/
init.lua
File metadata and controls
1337 lines (1237 loc) · 45 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
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
-- Neovim 설정 - Mason LSP 마이그레이션
-- 기존 vimrc의 설정을 Lua로 변환
-- 기본 설정
vim.g.mapleader = ","
-- vim.opt.nocompatible = true -- Neovim에서는 필요없음
vim.opt.encoding = "UTF-8"
vim.opt.fileencodings = "UTF-8"
vim.opt.fencs = "utf8,euc-kr,cp949,cp932,euc-jp,shift-jis,big5,latin1,ucs-2le"
vim.opt.visualbell = true
vim.opt.backspace = "indent,eol,start"
vim.opt.tabstop = 4
vim.opt.shiftwidth = 4
vim.opt.cindent = true
vim.opt.autoindent = true
vim.opt.smartindent = true
vim.opt.history = 15
vim.opt.ruler = true
vim.opt.showcmd = true
vim.opt.backup = false
vim.opt.foldmethod = "marker"
vim.opt.hlsearch = true
vim.opt.background = "dark"
vim.opt.number = true
vim.opt.swapfile = false
vim.opt.wildmenu = true
vim.opt.laststatus = 3 -- 전역 상태바 (Neovim 0.7+)
vim.opt.showtabline = 2 -- 항상 탭라인 표시
vim.opt.colorcolumn = "129"
vim.opt.hidden = true
vim.opt.mouse = "a"
vim.opt.lazyredraw = true
vim.opt.synmaxcol = 256
vim.cmd("syntax sync minlines=256")
vim.opt.conceallevel = 0 -- concealing 완전 비활성화
-- conceallevel이 다른 플러그인에 의해 변경되는 것을 강력하게 방지
vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter", "FileType", "BufRead", "BufNewFile"}, {
callback = function()
vim.opt_local.conceallevel = 0
vim.opt_local.concealcursor = "" -- 커서가 있을 때도 숨기지 않음
end,
desc = "항상 conceallevel을 0으로 유지"
})
-- Markdown 파일 전용 설정
vim.api.nvim_create_autocmd("FileType", {
pattern = "markdown",
callback = function()
vim.opt_local.conceallevel = 0
vim.opt_local.concealcursor = ""
-- vim.schedule로 다른 플러그인보다 나중에 실행
vim.schedule(function()
vim.opt_local.conceallevel = 0
vim.opt_local.concealcursor = ""
end)
end,
desc = "Markdown에서 concealing 완전 비활성화"
})
-- 파일 변경 자동 감지 및 새로고침
vim.opt.autoread = true
vim.opt.updatetime = 250 -- 더 빠른 감지 (기본 4000ms → 250ms)
-- 포커스 시 자동 새로고침
vim.api.nvim_create_autocmd({"FocusGained", "BufEnter", "CursorHold", "CursorHoldI"}, {
callback = function()
if vim.fn.mode() ~= 'c' then
vim.cmd('checktime')
end
end,
})
-- Python 호스트 프로그램 설정 (Neovim용)
if vim.fn.has('nvim') == 1 then
if vim.env.CONDA_PREFIX and vim.env.CONDA_PREFIX ~= "" then
vim.g.python3_host_prog = vim.env.CONDA_PREFIX .. '/bin/python'
elseif vim.fn.has('mac') == 1 and vim.fn.isdirectory('/Users/junho/opt/anaconda3') == 1 then
vim.g.python3_host_prog = '/Users/junho/opt/anaconda3/bin/python'
end
end
-- 키 매핑
vim.keymap.set('n', 'L', 'i<CR><Esc>')
-- Clean mode 토글 (복사/붙여넣기 시 유용)
local clean_mode = false
vim.keymap.set('n', '<C-l>', function()
clean_mode = not clean_mode
if clean_mode then
-- Clean mode 활성화 - 모든 UI 요소 숨기기
-- gitsigns 끄기
pcall(function()
require('gitsigns').toggle_signs(false)
end)
-- IndentLines 끄기 (있는 경우)
pcall(function()
vim.cmd('IndentLinesDisable')
end)
vim.diagnostic.disable() -- LSP 진단 끄기 (E, W, I 등)
vim.opt.number = false -- 라인 넘버 끄기
vim.opt.relativenumber = false -- 상대 라인 넘버 끄기
vim.opt.signcolumn = 'no' -- 사인 컬럼 끄기 (Git +,~,- 표시 공간)
vim.opt.cursorline = false -- 커서 라인 끄기
vim.opt.colorcolumn = '' -- 컬러 컬럼 끄기
vim.opt.foldcolumn = '0' -- 폴드 컬럼 끄기
vim.opt.laststatus = 0 -- 상태바 끄기
vim.opt.showtabline = 0 -- 탭라인 끄기
-- nvim-tree와 other UI 숨기기
pcall(function()
if vim.fn.exists(':NvimTreeClose') == 2 then
vim.cmd('NvimTreeClose')
end
end)
print("🔄 Clean mode ON - 복사하기 편함! (라인넘버, Git표시, 진단 숨김)")
else
-- Clean mode 비활성화 - 모든 UI 요소 복원
-- gitsigns 켜기
pcall(function()
require('gitsigns').toggle_signs(true)
end)
-- IndentLines 켜기 (있는 경우)
pcall(function()
vim.cmd('IndentLinesEnable')
end)
vim.diagnostic.enable() -- LSP 진단 켜기 (E, W, I 등)
vim.opt.number = true -- 라인 넘버 켜기
vim.opt.relativenumber = true -- 상대 라인 넘버 켜기
vim.opt.signcolumn = 'yes' -- 사인 컬럼 켜기 (Git +,~,- 표시 공간)
vim.opt.cursorline = true -- 커서 라인 켜기
vim.opt.colorcolumn = '129' -- 컬러 컬럼 복원
vim.opt.laststatus = 3 -- 상태바 켜기
vim.opt.showtabline = 2 -- 탭라인 켜기
print("🔄 Clean mode OFF - 일반 모드 (모든 UI 복원)")
end
end)
vim.keymap.set('n', '<leader>s', ':update<CR>')
vim.keymap.set('n', '<F1>', ':NvimTreeToggle<CR>')
vim.keymap.set('n', '<F5>', ':NvimTreeRefresh<CR>')
vim.keymap.set('n', '<F3>', ':w<CR>')
vim.keymap.set('i', '<C-s>', '<ESC>:w<CR>')
vim.keymap.set('n', '<C-s>', '<Esc>:w<CR>')
vim.keymap.set('i', '<C-d>', '<ESC>:q<CR>')
vim.keymap.set('n', '<C-q>', '<Esc>:q<CR>')
vim.keymap.set('n', '<F4>', ':%s/\\s\\+$//e<CR>')
vim.keymap.set('n', '<F6>', ':vs<CR>')
vim.keymap.set('n', '<F7>', ':sp<CR>')
vim.keymap.set('n', '<F8>', ':SrcExplToggle<CR>')
vim.keymap.set('n', '<F9>', ':TagbarToggle<CR>')
-- 기존 터미널 키매핑은 toggleterm으로 대체됨
-- 버퍼 관련 키 매핑
vim.keymap.set('n', '<leader>T', ':enew<CR>')
vim.keymap.set('n', '<leader>bq', ':bp <BAR> bd #<CR>')
vim.keymap.set('n', '<leader>bl', ':ls<CR>')
-- 버퍼 관련 키매핑은 bufferline.nvim 설정에서 처리
-- lazy.nvim 설치
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",
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
-- 플러그인 설정
require("lazy").setup({
-- Treesitter (향상된 syntax highlighting)
{
"nvim-treesitter/nvim-treesitter",
build = ":TSUpdate",
config = function()
-- 필요한 파서 자동 설치
local ensure_installed = { "python", "lua", "vim", "vimdoc", "bash", "javascript", "typescript", "c", "cpp", "rust", "go", "java" }
local installed = require("nvim-treesitter").get_installed()
for _, lang in ipairs(ensure_installed) do
if not vim.tbl_contains(installed, lang) then
vim.cmd("TSInstall " .. lang)
end
end
-- treesitter highlight/indent는 nvim이 자동으로 처리
end,
init = function()
-- 점진적 선택 키맵
vim.keymap.set("n", "gnn", function()
require("nvim-treesitter.incremental_selection").init_selection()
end, { desc = "Init treesitter selection" })
vim.keymap.set("x", "grn", function()
require("nvim-treesitter.incremental_selection").node_incremental()
end, { desc = "Increment treesitter selection" })
vim.keymap.set("x", "grc", function()
require("nvim-treesitter.incremental_selection").scope_incremental()
end, { desc = "Increment scope selection" })
vim.keymap.set("x", "grm", function()
require("nvim-treesitter.incremental_selection").node_decremental()
end, { desc = "Decrement treesitter selection" })
end,
},
-- LSP 관련
{
"williamboman/mason.nvim",
build = ":MasonUpdate",
config = function()
require("mason").setup()
end
},
{
"williamboman/mason-lspconfig.nvim",
dependencies = { "williamboman/mason.nvim" },
config = function()
require("mason-lspconfig").setup({
ensure_installed = {
"pyright", -- Python LSP
"lua_ls", -- Lua LSP
"bashls", -- Bash LSP
"jsonls", -- JSON LSP
"yamlls", -- YAML LSP
},
automatic_installation = true,
})
end
},
{
"neovim/nvim-lspconfig",
dependencies = {
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
},
config = function()
local capabilities = require("cmp_nvim_lsp").default_capabilities()
-- 기본 서버 설정 (bashls, jsonls, yamlls)
for _, server in ipairs({ "bashls", "jsonls", "yamlls" }) do
vim.lsp.config(server, {
capabilities = capabilities,
})
end
-- lua_ls 전용 설정
vim.lsp.config("lua_ls", {
capabilities = capabilities,
settings = {
Lua = {
runtime = { version = 'LuaJIT' },
diagnostics = { globals = {'vim'} },
workspace = {
library = vim.api.nvim_get_runtime_file("", true),
checkThirdParty = false,
},
telemetry = { enable = false },
},
},
})
-- pyright 전용 설정
vim.lsp.config("pyright", {
capabilities = capabilities,
root_markers = { "pyrightconfig.json", ".git", "setup.py", "requirements.txt" },
on_init = function(client)
-- pyrightconfig.json이 있으면 그것을 사용
local workspace_path = client.config.root_dir
if workspace_path and vim.fn.filereadable(workspace_path .. "/pyrightconfig.json") == 1 then
client.config.settings = {} -- pyrightconfig.json 설정 우선
else
-- 없으면 기본 설정 사용
client.config.settings.python = {
analysis = {
typeCheckingMode = "basic",
autoSearchPaths = true,
useLibraryCodeForTypes = true,
}
}
end
return true
end,
})
-- 모든 서버 활성화
vim.lsp.enable({ "pyright", "lua_ls", "bashls", "jsonls", "yamlls" })
end
},
-- 자동완성 (completor.vim 대체)
{
"hrsh7th/nvim-cmp",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"hrsh7th/cmp-cmdline",
"L3MON4D3/LuaSnip",
"saadparwaiz1/cmp_luasnip",
},
config = function()
local cmp = require("cmp")
local luasnip = require("luasnip")
cmp.setup({
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert({
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(),
['<CR>'] = cmp.mapping.confirm({ select = true }),
['<Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end, { 'i', 's' }),
['<S-Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { 'i', 's' }),
}),
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
{ name = 'buffer' },
{ name = 'path' },
}),
})
end
},
-- 린터와 포매터 (syntastic 대체)
{
"nvimtools/none-ls.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
"williamboman/mason.nvim",
},
config = function()
local null_ls = require("null-ls")
local sources = {}
-- 사용 가능한 포매터/린터만 추가
if vim.fn.executable("black") == 1 then
table.insert(sources, null_ls.builtins.formatting.black)
end
if vim.fn.executable("isort") == 1 then
table.insert(sources, null_ls.builtins.formatting.isort)
end
if vim.fn.executable("pylint") == 1 then
table.insert(sources, null_ls.builtins.diagnostics.pylint)
end
-- flake8은 제거 (pyright로 충분)
if vim.fn.executable("stylua") == 1 then
table.insert(sources, null_ls.builtins.formatting.stylua)
end
if vim.fn.executable("prettier") == 1 then
table.insert(sources, null_ls.builtins.formatting.prettier)
end
null_ls.setup({
sources = sources,
debug = false,
notify_format = "[null-ls] %s", -- 에러 메시지 형식
on_attach = function(client, bufnr)
-- none-ls의 진단 완전 비활성화 (pyright와 중복 방지)
client.server_capabilities.diagnosticsProvider = false
end,
})
end
},
-- Git 관련 플러그인들
{
"lewis6991/gitsigns.nvim",
config = function()
require('gitsigns').setup({
signs = {
add = { text = '+' },
change = { text = '~' },
delete = { text = '_' },
topdelete = { text = '‾' },
changedelete = { text = '~' },
untracked = { text = '┆' },
},
signcolumn = true, -- 왼쪽 컬럼에 Git 상태 표시
numhl = false, -- 줄 번호에 하이라이트
linehl = false, -- 줄 전체 하이라이트
word_diff = false, -- 단어 단위 diff
watch_gitdir = {
interval = 1000,
follow_files = true
},
attach_to_untracked = true,
current_line_blame = false, -- 현재 줄 blame 표시
current_line_blame_opts = {
virt_text = true,
virt_text_pos = 'eol', -- end of line
delay = 1000,
ignore_whitespace = false,
},
current_line_blame_formatter = '<author>, <author_time:%Y-%m-%d> - <summary>',
sign_priority = 6,
update_debounce = 100,
status_formatter = nil, -- Use default
max_file_length = 40000, -- 큰 파일에서는 비활성화
preview_config = {
-- 미리보기 창 설정
border = 'single',
style = 'minimal',
relative = 'cursor',
row = 0,
col = 1
},
on_attach = function(bufnr)
local gs = package.loaded.gitsigns
local function map(mode, l, r, opts)
opts = opts or {}
opts.buffer = bufnr
vim.keymap.set(mode, l, r, opts)
end
-- Git 탐색
map('n', '<leader>gn', function()
if vim.wo.diff then return ']c' end
vim.schedule(function() gs.next_hunk() end)
return '<Ignore>'
end, {expr=true, desc="다음 Git 변경사항"})
map('n', '<leader>gp', function()
if vim.wo.diff then return '[c' end
vim.schedule(function() gs.prev_hunk() end)
return '<Ignore>'
end, {expr=true, desc="이전 Git 변경사항"})
-- Git 액션 (자주 쓰는 것들)
map('n', '<leader>gh', gs.preview_hunk, {desc="변경사항 미리보기"})
map('n', '<leader>gs', gs.stage_hunk, {desc="변경사항 스테이징"})
map('n', '<leader>gr', gs.reset_hunk, {desc="변경사항 되돌리기"})
map('n', '<leader>gu', gs.undo_stage_hunk, {desc="스테이징 취소"})
-- 파일 전체 액션
map('n', '<leader>gS', gs.stage_buffer, {desc="파일 전체 스테이징"})
map('n', '<leader>gR', gs.reset_buffer, {desc="파일 전체 되돌리기"})
-- Blame 정보
map('n', '<leader>gb', function() gs.blame_line{full=true} end, {desc="현재 줄 blame"})
map('n', '<leader>gB', gs.toggle_current_line_blame, {desc="blame 토글"})
-- diff 보기
map('n', '<leader>gd', gs.diffthis, {desc="현재 파일 diff"})
map('n', '<leader>gD', function() gs.diffthis('~') end, {desc="HEAD와 diff"})
-- 비주얼 모드에서 선택 영역 스테이징/리셋
map('v', '<leader>gs', function() gs.stage_hunk {vim.fn.line('.'), vim.fn.line('v')} end, {desc="선택 영역 스테이징"})
map('v', '<leader>gr', function() gs.reset_hunk {vim.fn.line('.'), vim.fn.line('v')} end, {desc="선택 영역 되돌리기"})
end
})
end
},
{ "tpope/vim-fugitive" },
-- nvim-tree (NERDTree 대체)
{
"nvim-tree/nvim-tree.lua",
dependencies = { "nvim-tree/nvim-web-devicons" },
config = function()
-- 터미널 환경 감지 (스마트한 아이콘 활성화)
local has_icons = true
-- SSH 환경에서는 아이콘 비활성화 (폰트 문제 방지)
if vim.env.SSH_CLIENT or vim.env.SSH_TTY then
has_icons = false
end
-- nvim-tree 설정
require("nvim-tree").setup({
-- 기본 설정
sort_by = "case_sensitive",
view = {
width = 30,
side = "left",
preserve_window_proportions = false,
number = false,
relativenumber = false,
signcolumn = "no",
},
filters = {
dotfiles = false,
custom = { "^.git$" },
},
git = {
enable = true,
ignore = false,
timeout = 500,
},
actions = {
open_file = {
quit_on_open = false,
resize_window = true,
},
},
-- sign 관련 설정 추가
renderer = {
add_trailing = false,
group_empty = true,
highlight_git = true,
highlight_opened_files = "none",
root_folder_modifier = ":~",
indent_markers = {
enable = false,
},
icons = {
show = {
file = has_icons,
folder = has_icons,
folder_arrow = has_icons,
git = true,
},
glyphs = has_icons and {
default = "",
symlink = "",
bookmark = "",
modified = "●",
folder = {
arrow_closed = "",
arrow_open = "",
default = "",
open = "",
empty = "",
empty_open = "",
symlink = "",
symlink_open = "",
},
git = {
unstaged = "✗",
staged = "✓",
unmerged = "",
renamed = "➜",
untracked = "★",
deleted = "",
ignored = "◌",
},
} or {
default = "",
symlink = "",
bookmark = "m",
modified = "●",
folder = {
arrow_closed = ">",
arrow_open = "v",
default = "[D]",
open = "[O]",
empty = "[E]",
empty_open = "[EO]",
symlink = "[L]",
symlink_open = "[LO]",
},
git = {
unstaged = "M",
staged = "S",
unmerged = "U",
renamed = "R",
untracked = "?",
deleted = "D",
ignored = "I",
},
},
},
},
-- 자동 리프레시 설정
filesystem_watchers = {
enable = true,
debounce_delay = 50,
},
-- 프로젝트 루트 자동 감지
update_focused_file = {
enable = true,
update_root = true,
ignore_list = {},
},
-- 시스템 열기 설정
system_open = {
cmd = "open", -- macOS용
},
})
-- nvim-tree 추가 키매핑
vim.keymap.set('n', '<leader>e', ':NvimTreeFocus<CR>', { desc = "파일 트리에 포커스" })
vim.keymap.set('n', '<leader>fc', ':NvimTreeFindFile<CR>', { desc = "현재 파일을 트리에서 찾기" })
end,
},
{ "wesleyche/SrcExpl" },
{ "majutsushi/tagbar" },
-- Telescope (CtrlP 대체)
{
"nvim-telescope/telescope.nvim",
tag = "0.1.8",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons", -- 아이콘 지원
-- fzf 네이티브 성능 향상
{
"nvim-telescope/telescope-fzf-native.nvim",
build = "make",
},
},
config = function()
local telescope = require("telescope")
local actions = require("telescope.actions")
-- 터미널 환경 감지하여 아이콘 지원 여부 확인 (스마트한 아이콘 활성화)
local has_icons = true
-- SSH 환경에서는 아이콘 비활성화 (폰트 문제 방지)
if vim.env.SSH_CLIENT or vim.env.SSH_TTY then
has_icons = false
end
-- 아이콘 설정
if has_icons then
require("nvim-web-devicons").setup({
default = true,
})
print("아이콘 모드 활성화 (터미널: " .. (vim.env.TERM_PROGRAM or vim.env.TERM or "unknown") .. ")")
else
print("텍스트 모드 활성화 (터미널: " .. (vim.env.TERM_PROGRAM or vim.env.TERM or "unknown") .. ")")
end
telescope.setup({
defaults = {
-- 성능 최적화
file_ignore_patterns = {
"node_modules/.*",
"%.git/.*",
"%.DS_Store",
"%.png",
"%.jpg",
"%.jpeg",
"%.gif",
"%.pdf",
"%.exe",
"%.so",
"%.dll",
},
-- UI 설정 (조건부 아이콘)
prompt_prefix = has_icons and "🔍 " or "> ",
selection_caret = has_icons and "➤ " or "> ",
entry_prefix = " ",
borderchars = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" },
initial_mode = "insert",
selection_strategy = "reset",
sorting_strategy = "ascending",
layout_strategy = "horizontal",
layout_config = {
horizontal = {
mirror = false,
preview_width = 0.6,
},
vertical = {
mirror = false,
},
},
-- 미리보기 설정
preview = {
treesitter = true,
},
-- 키매핑
mappings = {
i = {
["<C-n>"] = actions.cycle_history_next,
["<C-p>"] = actions.cycle_history_prev,
["<C-j>"] = actions.move_selection_next,
["<C-k>"] = actions.move_selection_previous,
["<C-c>"] = actions.close,
["<Down>"] = actions.move_selection_next,
["<Up>"] = actions.move_selection_previous,
["<CR>"] = actions.select_default,
["<C-s>"] = actions.select_horizontal,
["<C-v>"] = actions.select_vertical,
["<C-t>"] = actions.select_tab,
["<C-u>"] = actions.preview_scrolling_up,
["<C-d>"] = actions.preview_scrolling_down,
},
n = {
["<esc>"] = actions.close,
["<CR>"] = actions.select_default,
["<C-s>"] = actions.select_horizontal,
["<C-v>"] = actions.select_vertical,
["<C-t>"] = actions.select_tab,
["j"] = actions.move_selection_next,
["k"] = actions.move_selection_previous,
["H"] = actions.move_to_top,
["M"] = actions.move_to_middle,
["L"] = actions.move_to_bottom,
["<C-u>"] = actions.preview_scrolling_up,
["<C-d>"] = actions.preview_scrolling_down,
["gg"] = actions.move_to_top,
["G"] = actions.move_to_bottom,
},
},
},
pickers = {
-- 파일 찾기 설정
find_files = {
theme = "dropdown",
previewer = false,
hidden = false,
follow = true,
disable_devicons = not has_icons,
},
-- 라이브 그렙 설정
live_grep = {
theme = "ivy",
disable_devicons = not has_icons,
},
-- 버퍼 설정
buffers = {
theme = "dropdown",
previewer = false,
sort_lastused = true,
disable_devicons = not has_icons,
},
},
extensions = {
fzf = {
fuzzy = true,
override_generic_sorter = true,
override_file_sorter = true,
case_mode = "smart_case",
},
},
})
-- fzf extension 로드
telescope.load_extension("fzf")
-- 키매핑 설정
local builtin = require("telescope.builtin")
-- 기본 파일 찾기 (CtrlP 대체)
vim.keymap.set("n", "<C-p>", builtin.find_files, { desc = "파일 찾기" })
-- 추가 유용한 키매핑들
vim.keymap.set("n", "<leader>ff", builtin.find_files, { desc = "파일 찾기" })
vim.keymap.set("n", "<leader>fg", builtin.live_grep, { desc = "텍스트 검색" })
vim.keymap.set("n", "<leader>fb", builtin.buffers, { desc = "버퍼 찾기" })
vim.keymap.set("n", "<leader>fh", builtin.help_tags, { desc = "도움말 검색" })
vim.keymap.set("n", "<leader>fr", builtin.oldfiles, { desc = "최근 파일" })
vim.keymap.set("n", "<leader>fc", builtin.commands, { desc = "명령어 검색" })
vim.keymap.set("n", "<leader>fk", builtin.keymaps, { desc = "키맵 검색" })
vim.keymap.set("n", "<leader>fs", builtin.grep_string, { desc = "현재 단어 검색" })
-- Git 파일 검색 관련 (대문자로 변경하여 gitsigns와 충돌 방지)
vim.keymap.set("n", "<leader>Gf", builtin.git_files, { desc = "Git 파일 검색" })
vim.keymap.set("n", "<leader>Gc", builtin.git_commits, { desc = "Git 커밋 검색" })
vim.keymap.set("n", "<leader>Gb", builtin.git_branches, { desc = "Git 브랜치 검색" })
vim.keymap.set("n", "<leader>Gs", builtin.git_status, { desc = "Git 상태 검색" })
-- LSP 관련 (LSP가 활성화된 경우에만)
vim.keymap.set("n", "<leader>ld", builtin.lsp_definitions, { desc = "정의로 이동" })
vim.keymap.set("n", "<leader>lr", builtin.lsp_references, { desc = "참조 찾기" })
vim.keymap.set("n", "<leader>ls", builtin.lsp_document_symbols, { desc = "문서 심볼" })
vim.keymap.set("n", "<leader>lw", builtin.lsp_workspace_symbols, { desc = "작업공간 심볼" })
vim.keymap.set("n", "<leader>le", builtin.diagnostics, { desc = "진단 정보" })
-- Python 함수 검색을 위한 대체 방법들
-- 1. 현재 파일의 함수 목록 (document symbols는 pyright가 지원함)
vim.keymap.set("n", "<leader>lf", builtin.lsp_document_symbols, { desc = "현재 파일의 함수/클래스 목록" })
-- 2. grep으로 함수 정의 검색 (def/class 키워드 활용)
vim.keymap.set("n", "<leader>pf", function()
local func_name = vim.fn.input("함수명: ")
if func_name ~= "" then
builtin.grep_string({
search = "(def|class)\\s+" .. func_name,
use_regex = true,
file_pattern = "*.py",
})
end
end, { desc = "Python 함수/클래스 정의 검색" })
-- 3. 현재 단어로 정의 검색
vim.keymap.set("n", "<leader>pF", function()
local word = vim.fn.expand("<cword>")
builtin.grep_string({
search = "(def|class)\\s+" .. word,
use_regex = true,
file_pattern = "*.py",
})
end, { desc = "현재 단어로 Python 정의 검색" })
end,
},
{ "tpope/vim-obsession" },
{
"dhruvasagar/vim-prosession",
dependencies = { "tpope/vim-obsession" },
},
{ "nathanaelkane/vim-indent-guides" },
{ "jiangmiao/auto-pairs" },
{ "mbbill/undotree" },
{ "tpope/vim-commentary" },
{ "Yggdroot/indentLine" },
{ "jacquesbh/vim-showmarks" },
{ "junegunn/seoul256.vim" },
-- 버퍼라인 추가
{
'akinsho/bufferline.nvim',
version = "*",
config = function()
require("bufferline").setup({
options = {
mode = "buffers",
numbers = "ordinal",
close_command = "bdelete! %d",
right_mouse_command = "bdelete! %d",
left_mouse_command = "buffer %d",
middle_mouse_command = nil,
indicator = {
icon = '▎',
style = 'icon',
},
buffer_close_icon = '×',
modified_icon = '●',
close_icon = '×',
left_trunc_marker = '←',
right_trunc_marker = '→',
diagnostics = "nvim_lsp",
diagnostics_update_in_insert = false,
separator_style = "thin",
enforce_regular_tabs = false,
always_show_bufferline = true,
show_buffer_icons = false, -- 아이콘 비활성화
show_buffer_close_icons = true,
show_close_icon = true,
show_tab_indicators = true,
persist_buffer_sort = true,
move_wraps_at_ends = false,
max_name_length = 18,
max_prefix_length = 15,
truncate_names = true,
tab_size = 18,
color_icons = false,
},
highlights = {
-- 활성 버퍼 (현재 포커스된 버퍼)
buffer_selected = {
fg = '#ffffff',
bg = '#3a3a3a',
bold = true,
italic = false,
},
numbers_selected = {
fg = '#ffaf00',
bg = '#3a3a3a',
bold = true,
},
-- 비활성 창에 보이는 버퍼
buffer_visible = {
fg = '#888888',
bg = '#262626',
bold = false,
italic = false,
},
numbers_visible = {
fg = '#666666',
bg = '#262626',
},
-- 배경 버퍼 (열려있지만 보이지 않는 버퍼)
background = {
fg = '#666666',
bg = '#1c1c1c',
bold = false,
italic = false,
},
numbers = {
fg = '#444444',
bg = '#1c1c1c',
},
-- 인디케이터
indicator_selected = {
fg = '#ff5f00', -- 주황색 인디케이터
bg = '#3a3a3a',
},
indicator_visible = {
fg = '#444444',
bg = '#262626',
},
-- 구분선
separator = {
fg = '#1c1c1c',
bg = '#1c1c1c',
},
separator_selected = {
fg = '#1c1c1c',
bg = '#3a3a3a',
},
separator_visible = {
fg = '#1c1c1c',
bg = '#262626',
},
-- 수정된 파일 표시
modified_selected = {
fg = '#ff5f00',
bg = '#3a3a3a',
},
modified_visible = {
fg = '#888888',
bg = '#262626',
},
modified = {
fg = '#666666',
bg = '#1c1c1c',
},
}
})
-- 버퍼 이동 (표시된 순서대로)
vim.keymap.set('n', "<leader>'", ':BufferLineCycleNext<CR>', { silent = true })
vim.keymap.set('n', '<leader>;', ':BufferLineCyclePrev<CR>', { silent = true })
-- 버퍼 순서 변경 키매핑
vim.keymap.set('n', '<leader><', ':BufferLineMovePrev<CR>', { silent = true })
vim.keymap.set('n', '<leader>>', ':BufferLineMoveNext<CR>', { silent = true })
-- 버퍼 직접 선택
vim.keymap.set('n', '<leader>1', ':BufferLineGoToBuffer 1<CR>', { silent = true })
vim.keymap.set('n', '<leader>2', ':BufferLineGoToBuffer 2<CR>', { silent = true })
vim.keymap.set('n', '<leader>3', ':BufferLineGoToBuffer 3<CR>', { silent = true })
vim.keymap.set('n', '<leader>4', ':BufferLineGoToBuffer 4<CR>', { silent = true })
vim.keymap.set('n', '<leader>5', ':BufferLineGoToBuffer 5<CR>', { silent = true })
vim.keymap.set('n', '<leader>6', ':BufferLineGoToBuffer 6<CR>', { silent = true })
vim.keymap.set('n', '<leader>7', ':BufferLineGoToBuffer 7<CR>', { silent = true })
vim.keymap.set('n', '<leader>8', ':BufferLineGoToBuffer 8<CR>', { silent = true })
vim.keymap.set('n', '<leader>9', ':BufferLineGoToBuffer 9<CR>', { silent = true })
end
},
{
"nvim-lualine/lualine.nvim",
dependencies = { 'nvim-tree/nvim-web-devicons', opt = true },
config = function()
require('lualine').setup({
options = {
theme = 'seoul256',
icons_enabled = false, -- 아이콘 비활성화 (네모 박스 제거)
component_separators = { left = '|', right = '|'},
section_separators = { left = '', right = ''},
disabled_filetypes = {
statusline = {},
winbar = {},
},
always_divide_middle = true,
globalstatus = true, -- 전역 상태바 사용 (창 분할 시 하나만 표시)
},
sections = {
lualine_a = {'mode'},
lualine_b = {'branch', 'diff', 'diagnostics'},
lualine_c = {
{
'filename',
file_status = true, -- 수정 상태 표시
path = 1, -- 상대 경로 표시
}
},
lualine_x = {'encoding', 'fileformat', 'filetype'},
lualine_y = {'progress'},
lualine_z = {'location'}