-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua.example
More file actions
1747 lines (1598 loc) · 62.7 KB
/
Copy pathinit.lua.example
File metadata and controls
1747 lines (1598 loc) · 62.7 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
-- Modern Neovim Configuration for Genero Development
-- Compatible with Neovim 0.9.x through 0.11.x
-- Copy this to ~/.config/nvim/init.lua and adjust paths as needed
-- ============================================================================
-- VERSION DETECTION
-- ============================================================================
-- Detect Neovim version once for use throughout the config
local nvim_version = vim.version()
local is_nvim_010_plus = nvim_version.major > 0 or nvim_version.minor >= 10
-- ============================================================================
-- LEADER KEY
-- ============================================================================
vim.g.mapleader = " "
vim.g.maplocalleader = " "
-- UI & Display
vim.opt.number = true
vim.opt.relativenumber = true
vim.opt.termguicolors = true
vim.opt.background = 'dark'
vim.opt.cursorline = true
vim.opt.cursorcolumn = false
vim.opt.signcolumn = "yes:2"
vim.opt.colorcolumn = "100"
vim.opt.cmdheight = 1
vim.opt.pumheight = 10
-- Indentation & Formatting
vim.opt.expandtab = false
vim.opt.shiftwidth = 4
vim.opt.tabstop = 4
vim.opt.smartindent = true -- Note: smartindent is overridden for Genero files (see indent/*.vim)
vim.opt.wrap = true
vim.opt.linebreak = true
vim.opt.breakindent = true
-- Preserve indentation when continuing comments (# in Genero)
-- r = auto-insert comment leader after Enter in insert mode
-- o = auto-insert comment leader after o/O in normal mode
-- Note: indent/*.vim files disable smartindent's # column-0 behavior for Genero files
vim.opt.formatoptions:append("ro")
-- Search & Navigation
vim.opt.ignorecase = true
vim.opt.smartcase = true
vim.opt.hlsearch = true
vim.opt.incsearch = true
-- Performance & Behavior
vim.opt.updatetime = 250
vim.opt.timeoutlen = 300
vim.opt.splitbelow = true
vim.opt.splitright = true
vim.opt.mouse = "a"
vim.opt.showcmd = false -- Disable showcmd to prevent noice "calculator" popup
-- Use system clipboard if a provider is available (xclip, xsel, wl-copy, etc.)
-- Falls back to Neovim's internal registers if no provider is found
if vim.fn.executable("xclip") == 1 or vim.fn.executable("xsel") == 1
or vim.fn.executable("wl-copy") == 1 or vim.fn.executable("pbcopy") == 1 then
vim.opt.clipboard = "unnamedplus"
end
-- Persistent Undo (Neovim only)
vim.opt.undofile = true
vim.opt.undodir = vim.fn.expand("~/.vim/undo")
vim.opt.undolevels = 1000
vim.opt.undoreload = 10000
-- ============================================================================
-- GENERO TOOLS CONFIGURATION (must be set before plugin loads)
-- ============================================================================
vim.g.genero_tools_config = {
-- Compiler settings
-- Supports .4gl, .m3, .m4 files (fglcomp) and .per files (fglform)
compiler_enabled = true,
compiler_autocompile = true,
compiler_autocompile_delay = 500,
compiler_inline_diagnostics = true, -- Show error/warning text on cursor line (Neovim only)
compiler_type_info = true, -- Show function signature on hover (Neovim only)
autoclose_blocks = true, -- Auto-insert END statements on Enter
compiler_sign_column = true,
compiler_sign_column_always_visible = true, -- Keep sign column visible
compiler_highlight_unused = true,
compiler_show_warnings = true,
compiler_show_errors = true,
compiler_command = "fglcomp", -- For .4gl, .m3, .m4 files
compiler_args = { "-M", "-W", "all" },
compiler_form_command = "fglform", -- For .per files (form compiler)
compiler_form_args = { "-M", "-W", "all" },
compiler_source_dir = ".",
compiler_version = "auto", -- Auto-detect or specify: "3.10", "3.20", etc.
-- Code hints configuration
hints_enabled = true,
hints_display = "both", -- Display mode: "signs", "virtual_text", "both"
hints_severity = "warning", -- Severity level: "info", "warning", "style"
hints_realtime = true, -- Enable real-time detection
hints_cache_enabled = true, -- Enable hint caching
hints_cache_ttl = 300, -- Cache TTL in seconds
hints_delay = 500, -- Debounce delay in milliseconds
hints_current_line_only = true, -- Only show virtual text hint on cursor line (less noisy)
auto_fix_enabled = true, -- Enable auto-fix suggestions
-- Individual hint checks (true = enabled, false = disabled)
trailing_whitespace = true, -- Detect trailing whitespace (team consistency)
mixed_indentation = true, -- Detect mixed tabs/spaces (critical for team consistency)
indentation_consistency = false, -- Detect inconsistent indentation (too noisy, covered by mixed_indentation)
multiple_blank_lines = true, -- Detect excessive blank lines (keeps code clean)
lowercase_keywords = true, -- Detect lowercase keywords (Genero convention is uppercase)
lowercase_functions = false, -- Detect lowercase functions (too opinionated, many codebases use lowercase)
keyword_consistency = true, -- Detect inconsistent casing (important for team consistency)
naming_convention = false, -- Detect naming violations (too opinionated for existing codebase)
unclosed_blocks = true, -- Detect unclosed blocks (catches real bugs)
nesting_depth = false, -- DISABLED: Depth calculation has bugs, needs refactoring
line_length = true, -- Detect long lines (readability, code review)
missing_comments = false, -- Detect missing comments (too noisy, subjective)
missing_error_handling = true, -- Detect missing error handling (catches potential bugs)
deprecated_functions = true, -- Detect deprecated functions (important for maintenance)
-- Hint thresholds
max_line_length = 120, -- Maximum line length (increased for modern screens)
max_nesting_depth = 4, -- Maximum nesting depth (stricter for better code quality)
max_blank_lines = 2, -- Maximum consecutive blank lines
naming_convention_style = "snake_case", -- Naming style: "camelCase", "snake_case"
-- Cache settings
cache_enabled = true, -- Enable result caching
cache_ttl = 3600, -- Cache time-to-live in seconds
cache_max_size = 500, -- Maximum cache entries
-- Result settings
result_limit = 1000, -- Maximum results returned
pagination_size = 50, -- Results per page
-- Codebase detection
codebase_markers = { "castle.sch", "genero.conf", ".genero", ".git" },
-- Startup behavior
startup_messages = "silent", -- Message level: "silent", "normal", "verbose"
-- Query tool path
-- Set this to the location of your genero-tools query.sh script
-- Common locations:
-- BRODIR-based: (os.getenv("BRODIR") or "/opt/brodir") .. "/etc/genero-tools/query.sh"
-- Home directory: vim.fn.expand("~/genero-tools/query.sh")
genero_tools_path = os.getenv("GENERO_TOOLS_PATH")
or (os.getenv("BRODIR") and os.getenv("BRODIR") .. "/etc/genero-tools/query.sh")
or vim.fn.expand("~/genero-tools/query.sh"),
-- Display and features
display_mode = "floating", -- Use floating windows for results (valid modes: quickfix, floating, echo)
snippets_enabled = true,
snippet_engine = "luasnip", -- Snippet engine: "luasnip", "vim-snipmate", "vim-vsnip"
snippet_smart_expansion = true, -- Enable async parameter population
snippet_custom_dir = vim.fn.expand("~/.config/nvim/genero-snippets"), -- Custom snippet directory
keybindings_enabled = true, -- Enable default keybindings
timeout = 10000, -- Command timeout in milliseconds
async_enabled = true, -- Enable async operations
-- Autocomplete configuration
autocomplete_on_pause = false, -- Disabled: nvim-cmp handles triggering (Vim still uses omnifunc)
autocomplete_delay = 500, -- Delay in ms before triggering (default: 500)
-- Format flag configuration (for optimized output from genero-tools)
format_hover_enabled = true, -- Enable hover format (--format=vim-hover) for detailed display
format_completion_enabled = true, -- Enable completion format (--format=vim-completion) for autocomplete
format_concise_enabled = true, -- Enable concise format (--format=vim) for hints and statusline
format_cache_enabled = true, -- Enable caching of formatted results
format_cache_ttl = 3600, -- Format cache time-to-live in seconds (default: 1 hour)
-- Statusline configuration
statusline_show_function = true, -- Show current function signature in statusline
statusline_function_max_length = 50, -- Maximum length of function signature in statusline
statusline_show_diagnostics = true, -- Show error/warning counts in statusline
-- Floating window configuration
floating_window_border = "rounded",
floating_window_width = 80,
floating_window_height = 20,
floating_window_position = "center",
floating_window_title = "Genero-Tools",
popup_auto_close_delay = 5000,
-- Debug streaming configuration (Neovim only)
debug_stream_enabled = true,
-- debug_stream_width = 50, -- Uncomment to set fixed width (default: 0 = auto-size to 1/3 of screen)
debug_stream_max_lines = 1000,
debug_stream_auto_scroll = true,
debug_stream_directory = (os.getenv("BRODIR") or "/opt/brodir") .. "/debug",
-- Debug mode for troubleshooting
debug_mode = false, -- Set to true to enable debug logging
-- SVN integration
svn_enabled = true,
svn_show_added = true,
svn_show_modified = true,
svn_show_deleted = true,
svn_cache_ttl = 300, -- SVN cache time-to-live in seconds
svn_auto_update = true, -- Auto-update SVN markers on save
-- Lua layer (Neovim only)
lua_enabled = true, -- Enable Lua layer features (auto-detected: true on Neovim, false on Vim)
-- Per-file configuration
-- Create .genero-hints in project root for per-file hint configuration
-- Example: { "rules": [ { "pattern": "src/**/*.4gl", "config": { "max_line_length": 120 } } ] }
}
-- ============================================================================
-- LAZY.NVIM BOOTSTRAP
-- ============================================================================
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
local uv = vim.uv or vim.loop -- vim.uv on 0.10+, vim.loop on 0.9.x
if not 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)
-- ============================================================================
-- PLUGINS
-- ============================================================================
local plugins = {
-- ============================================================================
-- THEME SELECTION
-- Uncomment ONE theme block below. Default: thorn (minimal green)
-- ============================================================================
-- Default: Thorn - Minimal dark green theme
{
"jpwol/thorn.nvim",
lazy = false,
priority = 1000,
config = function()
vim.cmd("colorscheme thorn")
end,
},
-- Alternative: Tokyonight - Popular dark blue theme
-- Uncomment this block and comment out thorn above to switch
-- {
-- "folke/tokyonight.nvim",
-- lazy = false,
-- priority = 1000,
-- config = function()
-- require("tokyonight").setup({
-- style = "night",
-- transparent = false,
-- terminal_colors = true,
-- styles = {
-- comments = { italic = true },
-- keywords = { italic = true },
-- functions = {},
-- variables = {},
-- sidebars = "dark",
-- floats = "dark",
-- },
-- lualine_bold = true,
-- })
-- vim.cmd("colorscheme tokyonight")
-- end,
-- },
-- Alternative: Catppuccin - Warm pastel theme
-- {
-- "catppuccin/nvim",
-- name = "catppuccin",
-- lazy = false,
-- priority = 1000,
-- config = function()
-- vim.cmd("colorscheme catppuccin-mocha")
-- end,
-- },
-- Alternative: Gruvbox - Retro warm theme
-- {
-- "ellisonleao/gruvbox.nvim",
-- lazy = false,
-- priority = 1000,
-- config = function()
-- vim.cmd("colorscheme gruvbox")
-- end,
-- },
-- LuaSnip - Required for Genero code snippets
-- Note: jsregexp is optional (only needed for advanced regex in snippets)
-- If you need jsregexp, install Lua dev headers: lua5.1-dev (Debian/Ubuntu) or lua-devel (RHEL/CentOS)
{
"L3MON4D3/LuaSnip",
version = "v2.*",
build = "make install_jsregexp || true", -- Continue even if jsregexp build fails
},
-- Genero Tools Plugin
{
"hdean-ssp/genero-vim",
name = "genero-tools",
branch = "main",
dependencies = { "L3MON4D3/LuaSnip" },
config = function()
-- Config is already set in vim.g.genero_tools_config above
-- Initialize snippets module if enabled
local ok_snippets, snippets = pcall(require, "genero_tools.snippets")
if ok_snippets and vim.g.genero_tools_config.snippets_enabled then
snippets.setup()
end
end,
},
-- Modern Statusline
{
"nvim-lualine/lualine.nvim",
version = "v0.9.*",
dependencies = { "genero-tools" }, -- Ensure genero-tools loads first
config = function()
-- Safely load genero-tools lualine integration
local ok, lualine_genero = pcall(require, "genero_tools.lualine")
if ok then
lualine_genero.setup() -- Initialize highlights
end
require("lualine").setup({
options = {
theme = "auto",
component_separators = { left = "│", right = "│" },
section_separators = { left = "", right = "" },
globalstatus = true,
refresh = {
statusline = 1000,
tabline = 1000,
winbar = 1000,
},
},
sections = {
lualine_a = { "mode" },
lualine_b = {},
lualine_c = ok and { "diagnostics", lualine_genero.diagnostics, lualine_genero.breadcrumb } or { "diagnostics" },
lualine_x = ok and { lualine_genero.svn_status, lualine_genero.cache_stats, "encoding", "filetype",
function() return os.getenv("DEVNAME") or "" end } or { "encoding", "filetype" },
lualine_y = { "progress" },
lualine_z = { "location" },
},
tabline = {
lualine_a = { "buffers" },
lualine_z = { "tabs" },
},
extensions = { "quickfix", "man" },
})
end,
},
-- Notification system
-- v3.13.1 is the last release compatible with Neovim 0.9.x
-- v3.14.x+ requires Neovim 0.10+ but fixes animation bugs on 0.11
{
"rcarriga/nvim-notify",
tag = not is_nvim_010_plus and "v3.13.1" or nil, -- pin on 0.9, use latest on 0.10+
config = function()
require("notify").setup({
background_colour = "#000000",
fps = 30,
icons = {
DEBUG = "",
ERROR = "",
INFO = "",
TRACE = "✎",
WARN = "",
},
level = vim.log.levels.WARN, -- Show warnings and errors
minimum_width = 50,
render = "compact", -- Compact render to reduce visual noise
stages = "static", -- "static" avoids animation math bugs across all versions
timeout = 3000, -- Auto-dismiss after 3 seconds
top_down = true,
})
vim.notify = require("notify")
end,
},
-- Floating Window UI for commands
-- noice.nvim supports Neovim 0.9+; pin to v4.5.2 on 0.9.x for stability,
-- use latest on 0.10+ to avoid deprecated API warnings
{
"folke/noice.nvim",
tag = not is_nvim_010_plus and "v4.5.2" or nil,
dependencies = {
"MunifTanjim/nui.nvim",
"rcarriga/nvim-notify",
},
config = function()
require("noice").setup({
notify = {
enabled = true, -- Re-enable notifications (we filter specific ones below)
},
messages = {
enabled = true, -- Re-enable message handling
},
cmdline = {
enabled = true,
view = "cmdline_popup",
},
popupmenu = {
enabled = true,
backend = "nui",
},
-- Position cmdline popup at top of screen
views = {
cmdline_popup = {
position = {
row = 5,
col = "50%",
},
size = {
width = 60,
height = "auto",
},
},
},
lsp = {
progress = {
enabled = false, -- Disable LSP progress for Neovim 0.9.5 compatibility
},
signature = {
enabled = false, -- Disable signature help for Neovim 0.9.5 compatibility
},
message = {
enabled = false, -- Disable LSP messages
},
override = {
["vim.lsp.util.convert_input_to_markdown_lines"] = true,
["vim.lsp.util.stylize_markdown"] = true,
["cmp.entry.get_documentation"] = true,
},
},
presets = {
bottom_search = true,
command_palette = true,
long_message_to_split = true,
inc_rename = false,
lsp_doc_border = false,
},
routes = {
-- Filter out specific noisy messages
{
filter = {
event = "msg_show",
any = {
{ find = "%d+L, %d+B" },
{ find = "; after #%d+" },
{ find = "; before #%d+" },
{ find = "lspconfig.*deprecated" }, -- Filter lspconfig deprecation
{ find = "vim%.lsp%.config" }, -- Filter vim.lsp.config mentions
{ find = "snippet" }, -- Filter snippet messages
{ find = "placeholder" }, -- Filter placeholder messages
{ find = "generotools" }, -- Filter generotools snippet messages
},
},
view = "mini",
},
{
filter = {
event = "notify",
any = {
{ find = "lspconfig.*deprecated" },
{ find = "vim%.lsp%.config" },
{ find = "snippet" },
{ find = "placeholder" },
{ find = "generotools" },
},
},
opts = { skip = true },
},
-- Skip all msg_showcmd events (these create the calculator popup)
{
filter = {
event = "msg_showcmd",
},
opts = { skip = true },
},
},
})
end,
},
-- Helpful command hints
-- v1.x uses wk.register() API; v3.x uses wk.add() API
-- Pin to v1.x on Neovim 0.9.x, use latest on 0.10+
{
"folke/which-key.nvim",
version = not is_nvim_010_plus and "v1.*" or nil,
config = function()
local wk = require("which-key")
if is_nvim_010_plus then
-- which-key v3+ API (Neovim 0.10+)
wk.setup({
preset = "classic",
icons = {
breadcrumb = "»",
separator = "➜",
group = "+",
},
win = {
border = "rounded",
padding = { 2, 2, 2, 2 },
},
layout = {
height = { min = 4, max = 25 },
width = { min = 20, max = 50 },
spacing = 3,
align = "left",
},
show_help = true,
show_keys = true,
})
else
-- which-key v1.x API (Neovim 0.9.x)
wk.setup({
plugins = {
marks = true,
registers = true,
spelling = {
enabled = true,
suggestions = 9,
},
presets = {
operators = true,
motions = true,
text_objects = true,
windows = true,
nav = true,
z = true,
g = true,
},
},
icons = {
breadcrumb = "»",
separator = "➜",
group = "+",
},
popup_mappings = {
scroll_down = "<c-d>",
scroll_up = "<c-u>",
},
window = {
border = "rounded",
position = "bottom",
margin = { 1, 0, 1, 0 },
padding = { 2, 2, 2, 2 },
winblend = 0,
},
layout = {
height = { min = 4, max = 25 },
width = { min = 20, max = 50 },
spacing = 3,
align = "left",
},
show_help = true,
show_keys = true,
})
end
end,
},
-- Indent guides
{
"lukas-reineke/indent-blankline.nvim",
main = "ibl",
config = function()
require("ibl").setup({
indent = { char = "│", highlight = "IblIndent" },
whitespace = {
highlight = "IblWhitespace",
remove_blankline_trail = false,
},
scope = { enabled = true, highlight = "IblScope" },
})
end,
},
-- Better UI for vim.ui.select and vim.ui.input
{
"stevearc/dressing.nvim",
config = function()
require("dressing").setup({
input = {
enabled = true,
default_prompt = "➜ ",
prompt_align = "left",
insert_only = true,
start_in_insert = true,
border = "rounded",
relative = "cursor",
prefer_width = 40,
width = nil,
max_width = { 140, 0.9 },
min_width = { 20, 0.2 },
buf_options = {},
win_options = {
wrap = false,
list = true,
listchars = "extends:…",
sidescrolloff = 0,
},
get_config = function(opts)
-- Disable dressing for snippet choice nodes (use default UI)
if opts and opts.kind == "luasnip" then
return { enabled = false }
end
end,
},
select = {
enabled = true,
backend = { "telescope", "fzf", "builtin" },
trim_prompt = true,
telescope = nil,
fzf = {
window = {
yoffset = -0.5,
},
},
builtin = {
border = "rounded",
relative = "editor",
buf_options = {},
win_options = {
cursorline = true,
cursorlineopt = "both",
},
width = nil,
max_width = { 80, 0.8 },
min_width = { 40, 0.2 },
height = nil,
max_height = 0.9,
mappings = {
["<Esc>"] = "Close",
["<C-c>"] = "Close",
["<CR>"] = "Confirm",
},
override = function(conf)
return conf
end,
},
format_item_override = {},
get_config = function(opts)
-- Disable dressing for snippet choice nodes (use default UI)
if opts and opts.kind == "luasnip" then
return { enabled = false }
end
end,
},
})
end,
},
-- Comment plugin for gcc/gbc keybindings
{
"numToStr/comment.nvim",
config = function()
require("Comment").setup({
padding = true,
sticky = true,
ignore = nil,
toggler = {
line = "gcc",
block = "gbc",
},
opleader = {
line = "gc",
block = "gb",
},
extra = {
above = "gcO",
below = "gco",
eol = "gcA",
},
mappings = {
basic = true,
extra = true,
},
pre_hook = nil,
post_hook = nil,
})
end,
},
-- Highlight TODO/FIX/BUG/TMP keywords in comments
-- Also registers a custom keyword for the current user's temp code tag (#TMP<initials>)
{
"folke/todo-comments.nvim",
dependencies = { "nvim-lua/plenary.nvim" },
config = function()
-- Build user-specific temp tag: hdean → TMPHD
local user = os.getenv("USER") or ""
local user_tag = "TMP" .. string.upper(string.sub(user, 1, 2))
require("todo-comments").setup({
signs = true,
sign_priority = 8,
keywords = {
FIX = { icon = " ", color = "error", alt = { "FIXME", "FIXIT", "ISSUE" } },
TODO = { icon = " ", color = "info" },
HACK = { icon = " ", color = "warning" },
WARN = { icon = " ", color = "warning", alt = { "WARNING" } },
NOTE = { icon = " ", color = "hint", alt = { "INFO" } },
BUG = { icon = " ", color = "error" },
TMP = { icon = " ", color = "warning", alt = { user_tag } },
},
merge_keywords = false,
highlight = {
multiline = false,
before = "",
keyword = "bg", -- "wide" causes end_col overflow on keywords at EOL
after = "",
pattern = [[.*<(KEYWORDS)\s*]],
comments_only = false, -- Also highlight in code, not just comments (for #TMP tags)
max_line_len = 400, -- Skip very long lines
exclude = {},
},
search = {
command = "rg",
args = {
"--color=never", "--no-heading", "--with-filename",
"--line-number", "--column", "--hidden",
},
pattern = [[\b(KEYWORDS)\b]],
},
})
end,
},
-- Toggle terminal (in-buffer terminal with hotkey)
{
"akinsho/toggleterm.nvim",
version = "*",
config = function()
require("toggleterm").setup({
size = function(term)
if term.direction == "horizontal" then
return 15
elseif term.direction == "vertical" then
return vim.o.columns * 0.4
end
end,
open_mapping = [[<C-\>]], -- Toggle terminal with Ctrl+\
hide_numbers = true,
shade_filetypes = {},
shade_terminals = true,
shading_factor = 2,
start_in_insert = true,
insert_mappings = true, -- Ctrl+\ works in insert mode too
terminal_mappings = true, -- Ctrl+\ works inside the terminal
persist_size = true,
persist_mode = true,
direction = "horizontal", -- Default: horizontal split at bottom
close_on_exit = true,
shell = "bash --login", -- Login shell: sources ~/.bash_profile for env vars
float_opts = {
border = "rounded",
winblend = 0,
},
})
-- Terminal mode mappings (escape terminal mode easily)
function _G.set_terminal_keymaps()
local topts = { buffer = 0, noremap = true, silent = true }
vim.keymap.set("t", "<Esc>", [[<C-\><C-n>]], topts)
vim.keymap.set("t", "<C-h>", [[<C-\><C-n><C-w>h]], topts)
vim.keymap.set("t", "<C-j>", [[<C-\><C-n><C-w>j]], topts)
vim.keymap.set("t", "<C-k>", [[<C-\><C-n><C-w>k]], topts)
vim.keymap.set("t", "<C-l>", [[<C-\><C-n><C-w>l]], topts)
end
vim.cmd("autocmd! TermOpen term://* lua set_terminal_keymaps()")
end,
},
-- ============================================================================
-- TREESITTER - Syntax highlighting and code understanding for all languages
-- ============================================================================
{
"nvim-treesitter/nvim-treesitter",
build = ":TSUpdate",
config = function()
-- Gracefully handle if treesitter isn't fully installed yet
local ok, treesitter = pcall(require, "nvim-treesitter.configs")
if not ok then
-- Silently skip treesitter setup if not installed
-- User can run :TSUpdate manually if they want syntax highlighting
return
end
-- Lazy-load parsers: only install when opening a file of that type
-- This avoids blocking startup with parser compilation
treesitter.setup({
-- Don't auto-install all parsers on startup (causes lag)
ensure_installed = {},
-- Install parsers on-demand when opening a file
auto_install = true,
highlight = {
enable = true,
-- Disable for very large files (>500KB) to avoid slowdown
disable = function(_, buf)
local max_filesize = 500 * 1024
local ok_stat, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
return ok_stat and stats and stats.size > max_filesize
end,
},
indent = { enable = true },
})
end,
},
-- ============================================================================
-- LSP - Language Server Protocol for Python, Java, C, Perl, Bash, etc.
-- ============================================================================
-- IMPORTANT: LSP servers are NOT auto-installed to avoid startup lag.
-- Install manually as needed:
-- :Mason (open UI, press 'i' to install)
-- :MasonInstall pyright (Python)
-- :MasonInstall jdtls (Java)
-- :MasonInstall clangd (C/C++)
-- :MasonInstall bashls (Bash)
-- :MasonInstall lua_ls (Lua)
-- :MasonInstall jsonls (JSON)
-- :MasonInstall yamlls (YAML)
-- :MasonInstall lemminx (XML)
--
-- NOTE: nvim-lspconfig is pinned to v1.0.0 for Neovim 0.9.5 compatibility.
-- v1.1+ requires Neovim 0.10+.
-- Mason: installs and manages LSP servers, linters, and formatters
{
"williamboman/mason.nvim",
build = ":MasonUpdate",
config = function()
require("mason").setup({
ui = {
border = "rounded",
icons = {
package_installed = "✓",
package_pending = "➜",
package_uninstalled = "✗",
},
},
})
end,
},
-- nvim-lspconfig: configures each language server
-- Pin to v1.0.0 for Neovim 0.9.5 compatibility (v1.1+ requires 0.10+)
{
"neovim/nvim-lspconfig",
version = "v1.0.0",
dependencies = {
"williamboman/mason.nvim",
"hrsh7th/cmp-nvim-lsp", -- feeds LSP completions into nvim-cmp
},
config = function()
local lspconfig = require("lspconfig")
local capabilities = require("cmp_nvim_lsp").default_capabilities()
-- Shared on_attach: sets LSP keybindings for any language server
local function on_attach(_, bufnr)
local bopts = { noremap = true, silent = true, buffer = bufnr }
-- Navigation (mirrors Genero-Tools bindings for non-Genero files)
vim.keymap.set("n", "K", vim.lsp.buf.hover, vim.tbl_extend("force", bopts, { desc = "Hover docs" }))
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, vim.tbl_extend("force", bopts, { desc = "Go to implementation" }))
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, vim.tbl_extend("force", bopts, { desc = "Rename symbol" }))
vim.keymap.set("n", "<leader>la", vim.lsp.buf.code_action, vim.tbl_extend("force", bopts, { desc = "Code action" }))
vim.keymap.set("n", "<leader>lf", function() vim.lsp.buf.format({ async = true }) end,
vim.tbl_extend("force", bopts, { desc = "Format file" }))
vim.keymap.set("n", "<leader>ld", vim.diagnostic.open_float, vim.tbl_extend("force", bopts, { desc = "Line diagnostics" }))
-- On non-Genero files, wire gd/gr to LSP so the same keys work everywhere
local ft = vim.bo[bufnr].filetype
local genero_fts = { ["4gl"] = true, fgl = true, per = true }
if not genero_fts[ft] then
vim.keymap.set("n", "gd", vim.lsp.buf.definition, vim.tbl_extend("force", bopts, { desc = "Go to definition" }))
vim.keymap.set("n", "gr", vim.lsp.buf.references, vim.tbl_extend("force", bopts, { desc = "Find references" }))
vim.keymap.set("n", "gp", function()
-- Peek: open definition in a floating preview
vim.lsp.buf.definition({ reuse_win = false })
end, vim.tbl_extend("force", bopts, { desc = "Peek definition" }))
end
end
-- Helper: only setup server if it's installed via Mason
local function setup_if_installed(server_name, config)
local ok_registry, mason_registry = pcall(require, "mason-registry")
if not ok_registry then
-- Mason not installed yet, skip LSP setup
return
end
if mason_registry.is_installed(server_name) then
lspconfig[server_name].setup(config)
end
end
-- Python
setup_if_installed("pyright", {
capabilities = capabilities,
on_attach = on_attach,
settings = {
python = {
analysis = {
typeCheckingMode = "basic",
autoSearchPaths = true,
useLibraryCodeForTypes = true,
},
},
},
})
-- Java (jdtls needs a workspace dir per project)
setup_if_installed("jdtls", {
capabilities = capabilities,
on_attach = on_attach,
settings = {
java = {
configuration = { updateBuildConfiguration = "interactive" },
eclipse = { downloadSources = true },
maven = { downloadSources = true },
},
},
})
-- C / C++
setup_if_installed("clangd", {
capabilities = capabilities,
on_attach = on_attach,
cmd = {
"clangd",
"--background-index",
"--clang-tidy",
"--header-insertion=iwyu",
"--completion-style=detailed",
},
})
-- Bash / shell scripts
setup_if_installed("bashls", {
capabilities = capabilities,
on_attach = on_attach,
filetypes = { "sh", "bash", "zsh" },
})
-- Lua (for editing this config file)
setup_if_installed("lua_ls", {
capabilities = capabilities,
on_attach = on_attach,
settings = {
Lua = {
runtime = { version = "LuaJIT" },
diagnostics = { globals = { "vim" } },
workspace = {
library = vim.api.nvim_get_runtime_file("", true),
checkThirdParty = false,
},
telemetry = { enable = false },
},
},
})
-- JSON
setup_if_installed("jsonls", { capabilities = capabilities, on_attach = on_attach })
-- YAML
setup_if_installed("yamlls", { capabilities = capabilities, on_attach = on_attach })
-- XML
setup_if_installed("lemminx", { capabilities = capabilities, on_attach = on_attach })
-- Diagnostic display settings (consistent with Genero-Tools style)
vim.diagnostic.config({
virtual_text = {
prefix = "●",
source = "if_many",
},
signs = true,
underline = true,
update_in_insert = false, -- Don't flicker while typing