-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.norg
More file actions
3789 lines (3508 loc) · 142 KB
/
config.norg
File metadata and controls
3789 lines (3508 loc) · 142 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
@document.meta
title: Neovim Config
description: My personal neovim config
authors: Simon H Moore
categories: [
config
neovim
lua
]
tangle: {
languages: {
lua: ./lua/config.lua
}
}
created: 2024-03-06T23:01:44+0100
updated: 2025-11-24T14:19:44+0100
version: 1.1.1
@end
.toc TABLE OF CONTENTS
* INSTALL INSTRUCTIONS
All of my main config is contained in this file `config.norg`, to be able to use this config you have to first `tangle` the file to generate the `config.lua` file.
___
1. Create `lua` directory.
A `lua` directory is needed so that the `config.lua` file can be crated inside of it.
Run the below command inside of your shell at the root of this config:
@code sh
mkdir lua
@end
2. Open Neovim to bootstrap the config.
A. Because the Lazy.nvim package manager and Neorg plugin is required to `tangle` the config, you have to bootstrap the config for the first time.
Don't worry this happens automatically, you just have to open Neovim by running:
@code sh
nvim
@end
You will see some errors pop up, don't worry about them this just happens because Neovim expects there to be a config which is not there yet.
B. After this is done, close Neovim again by running the below command:
@code vim
:qa
@end
4. Tangle the `config.norg` file.
A. Last, we need to `tangle` the config.norg file, to do so open the file with Neovim by running the following command:
@code sh
nvim config.norg
@end
B. After the `config.norg` file is opened in Neovim, run the following command inside Neovim:
@code vim
:Neorg tangle
@end
Neovim will ask you which file to tangle, select `config.norg`
5. Reopen Neovim and enjoy
Close and reopen Neovim and the `Lazy` plugin manager will install everything needed.
You might have to reopen Neovim a few times to make sure everything is installed.
* SETUP VARIABLES AND FUNCTIONS
** Leader keys
Used by many plugins for keybindings, need to be set early as plugins can be dependant on it.
___
@code lua
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
@end
** API Variables
Declare common API variables, will be used throughout the config.
___
@table
| Variable | Value | Descriptions |
|----------+---------+------------------------|
| o | vim.opt | Inbuilt vim options |
| g | vim.g | Inbuilt global options |
| cmd | vim.cmd | Run vim ex commands |
@end
@code lua
local o = vim.opt
local g = vim.g
local cmd = vim.cmd
@end
** Global Print Table Function
The `P()` function can be used globally to print a lua table for inspection.
___
@code lua
P = function(v)
print(vim.inspect(v))
return v
end
B = function(v)
vim.cmd("new")
vim.api.nvim_buf_set_lines(0, 0, -1, false, vim.split(vim.inspect(v), "\n"))
return v
end
@end
** Lazy Helper Function
The `plug()` function is used to add plugins to the `plugins` table.
The `plugins` table will be used by lazy to install and load plugins.
___
@code lua
local plugins = {}
local function wrap_config(plugin)
local user_config = plugin.config
-- handle `true` or `{}` (empty table)
if user_config == true or (type(user_config) == "table" and vim.tbl_isempty(user_config)) then
-- Lazy automatically does `require(MAIN).setup(opts)`
-- so we build that manually here
-- strip the .nvim if it exists also to try and guess the name
local main = plugin.main or plugin.name or (plugin[1] and plugin[1]:match(".*/(.*)"))
if main then
main = main:gsub("%.nvim$", "") -- strip .nvim suffix
end
user_config = function(_, opts)
require(main).setup(opts)
end
end
-- wrap function (if it’s a function now)
if type(user_config) == "function" then
plugin.config = function(...)
local ok, err = pcall(user_config, ...)
if not ok then
vim.notify(("Plugin '%s' setup failed:\n%s"):format(plugin.name or plugin[1], err), vim.log.levels.ERROR)
end
end
end
end
function plug(plugin)
if plugin.config ~= nil then
wrap_config(plugin)
end
plugins[#plugins +1] = plugin
end
@end
* OPTIONS
Configure inbuilt Neovim options.
___
@code lua
o.autowrite = true -- Enable auto write
o.clipboard = "unnamedplus" -- Sync with system clipboard
o.completeopt = "menu,menuone,noselect" -- Completion options for better experience
o.conceallevel = 3 -- Hide * markup for bold and italic
o.confirm = true -- Confirm to save changes before exiting modified buffer
o.cursorline = true -- Enable highlighting of the current line
o.breakindent = true -- Every wrapped line will honor indent
o.expandtab = true -- Use spaces instead of tabs
o.formatoptions = "jcroqlnt" -- Format options for automatic formatting
o.grepformat = "%f:%l:%c:%m" -- Format for grep output
o.grepprg = "rg --vimgrep" -- Use ripgrep for grep command
o.ignorecase = true -- Ignore case in search patterns
o.inccommand = "nosplit" -- Preview incremental substitute
o.laststatus = 0 -- Never show status line
o.list = true -- Show some invisible characters (tabs, trailing spaces)
o.mouse = "a" -- Enable mouse mode
o.number = true -- Print line number
o.pumblend = 10 -- Popup blend transparency
o.pumheight = 10 -- Maximum number of entries in a popup
o.relativenumber = true -- Relative line numbers
o.scrolloff = 4 -- Lines of context around cursor
o.sessionoptions = { "buffers", "curdir", "tabpages", "winsize" } -- Session save options
o.shiftround = true -- Round indent to multiple of shiftwidth
o.shiftwidth = 2 -- Size of an indent
o.shortmess:append({ W = true, I = true, c = true }) -- Reduce message verbosity
o.showmode = false -- Don't show mode since we have a statusline
o.sidescrolloff = 8 -- Columns of context around cursor
o.signcolumn = "yes" -- Always show the signcolumn, otherwise it would shift the text each time
o.smartcase = true -- Don't ignore case with capitals
o.smartindent = true -- Insert indents automatically
o.spelllang = { "en" } -- Spell checking language
o.splitbelow = true -- Put new windows below current
o.splitright = true -- Put new windows right of current
o.tabstop = 2 -- Number of spaces tabs count for
o.termguicolors = true -- True color support
o.timeoutlen = 300 -- Time to wait for a mapped sequence to complete
o.undofile = true -- Save undo history to file
o.undolevels = 10000 -- Maximum number of changes that can be undone
o.updatetime = 200 -- Save swap file and trigger CursorHold
o.wildmode = "longest:full,full" -- Command-line completion mode
o.winminwidth = 5 -- Minimum window width
o.wrap = false -- Disable line wrap
-- o.foldlevelstart = 0 -- Enable foldlevel when opening file
-- o.foldnestmax = 2 -- Set max nested foldlevel
-- vim.opt.foldenable = true -- Enable folding
-- vim.opt.foldmethod = "expr" -- Use expression for folding
-- vim.opt.foldexpr = "v:lua.vim.treesitter.foldexpr()" -- Use treesitter for fold expression
-- vim.o.foldtext = '' -- Use default fold text
-- vim.o.fillchars = 'fold: ' -- Characters to fill folds
if vim.fn.has("nvim-0.9.0") == 1 then
o.splitkeep = "screen"
o.shortmess:append({ C = true })
end
-- use powershell on windows
if vim.fn.has("win32") == 1 then
o.shell = vim.fn.executable "pwsh" == 1 and "pwsh" or "powershell"
o.shellcmdflag =
"-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command [Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.Encoding]::UTF8;"
o.shellredir = "-RedirectStandardOutput %s -NoNewWindow -Wait"
o.shellpipe = "2>&1 | Out-File -Encoding UTF8 %s; exit LastExitCode"
o.shellquote = ""
o.shellxquote = ""
end
-- if in a wsl environment WSL_DISTRO_NAME should be set
local in_wsl = os.getenv('WSL_DISTRO_NAME') ~= nil
if in_wsl then
-- Need to install win32yank in windows
-- see https://mitchellt.com/2022/05/15/WSL-Neovim-Lua-and-the-Windows-Clipboard.html
vim.g.clipboard = {
name = "win32yank-wsl",
copy = {
["+"] = "win32yank.exe -i --crlf",
["*"] = "win32yank.exe -i --crlf",
},
paste = {
["+"] = "win32yank.exe -o --lf",
["*"] = "win32yank.exe -o --lf",
},
cache_enabled = true,
}
end
@end
* SYNTAX HIGHLIGHTS & COLOR
Here I set up the color and syntax used in Neovim buffers.
___
** Options
Enable true color support:
___
@code lua
o.termguicolors = true
@end
** Gruvebox Colorscheme
A retro groove color scheme with warm, earthy tones designed for comfortable long coding sessions. Gruvbox provides excellent contrast and readability while being easy on the eyes.
This colorscheme implementation offers:
- **Warm color palette**: Carefully selected browns, oranges, and muted colors that reduce eye strain
- **Treesitter integration**: Full support for modern syntax highlighting with semantic tokens
- **Transparency support**: Optional transparent background for terminal integration
- **Comprehensive language support**: Optimized colors for all major programming languages
- **Dark and light variants**: Multiple contrast levels to suit different lighting conditions
- **Accessibility focused**: High contrast ratios and colorblind-friendly palette choices
**Usage**: The colorscheme is automatically applied on startup. The configuration includes transparency mode and custom overrides for better markdown and code block visibility.
**Help**: The theme provides consistent highlighting across all file types while maintaining the distinctive Gruvbox aesthetic that has made it popular among developers worldwide.
For example, comments appear in a muted gray-brown, strings in warm green, and keywords in bright orange, creating a cohesive and pleasant coding environment.
___
[GitHub]{https://github.com/ellisonleao/gruvbox.nvim}
@code lua
plug({
"ellisonleao/gruvbox.nvim",
enabled = true,
lazy = false,
priority = 10000,
config = function()
require("gruvbox").setup({
transparent_mode = true,
terminal_colors = false, -- disable gruvbox in terminal
overrides = {
Folded = { bg = "#202020" },
-- fix markdown todo colors
["@lsp.type.class.markdown"] = { fg = "#000000" },
["@neorg.tags.ranged_verbatim.code_block"] = { bg = "#222222" },
}
})
o.background = "dark"
g.gruvbox_italic = true
g.gruvbox_bold = false
g.gruvbox_transparent_bg = true
g.gruvbox_constrast_dark = "hard"
g.gruvbox_improved_strings = false
cmd([[colorscheme gruvbox]])
end,
})
@end
** Colorizer
A high-performance color highlighter that displays colors directly in your code for better visual feedback. Colorizer automatically detects and highlights color codes, making it easier to work with CSS, web development, and any files containing color values.
This plugin provides:
- **Real-time color preview**: See actual colors rendered inline for hex codes, RGB values, and named colors
- **Multiple format support**: Handles #RGB, #RRGGBB, #RRGGBBAA, rgb(), hsl(), and CSS color names
- **Performance optimized**: Fast highlighting that doesn't slow down your editor
- **Customizable display**: Choose between background highlighting, foreground text, or virtual text display
- **Wide language support**: Works with CSS, HTML, JavaScript, Lua, and many other file types
- **Non-intrusive**: Only highlights valid color codes without interfering with syntax highlighting
**Usage**: Colors are automatically highlighted when you open supported files. The plugin runs in the background and updates highlights as you type.
**Help**: The colorizer makes it instantly clear what colors your code represents, eliminating guesswork when working with color values in web development, theming, or configuration files.
For example, `#ff0000` will show with a red background, `rgb(0, 255, 0)` with green, and `blue` with the corresponding blue color.
___
[GitHub]{https://github.com/norcalli/nvim-colorizer.lua}
@code lua
plug({
"norcalli/nvim-colorizer.lua",
enabled = true,
event = { "BufReadPost", "BufNewFile" },
opts = {
default_options = {
RGB = true,
RRGGBB = true,
names = true,
RRGGBBAA = true,
rgb_fn = true,
hsl_fn = true,
css = true,
css_fn = true,
mode = "background",
},
"*", -- highlight all files
},
})
@end
** Rainbow
A Neovim plugin that provides rainbow parentheses highlighting using Tree-sitter for enhanced code readability. Rainbow colorizes matching brackets, parentheses, and delimiters with different colors to make nested code structures easier to navigate and understand.
This plugin offers:
- **Tree-sitter integration**: Uses modern Tree-sitter parsing for accurate bracket detection and highlighting
- **Multiple delimiter support**: Highlights parentheses, brackets, braces, and other delimiters with distinct colors
- **Extended mode**: Optional highlighting of non-bracket delimiters like HTML tags and language-specific constructs
- **Performance optimized**: Efficient highlighting that works smoothly even with large files
- **Customizable colors**: Configure your own color schemes or use the default rainbow palette
- **Language awareness**: Intelligent highlighting that respects language syntax and context
**Usage**: Rainbow highlighting is automatically applied when you open supported files. The plugin cycles through colors for each nesting level, making it easy to match opening and closing delimiters.
**Help**: The rainbow colors help reduce visual confusion when working with deeply nested code structures, making it easier to spot mismatched brackets and understand code hierarchy at a glance.
For example, in nested function calls like `func(array[index(key)])`, each level of brackets will appear in a different color, making the structure immediately clear.
___
[GitHub]{https://github.com/HiPhish/rainbow-delimiters.nvim}
@code lua
plug({
"HiPhish/rainbow-delimiters.nvim",
event = { "BufReadPost", "BufNewFile" },
config = function()
local rainbow_delimiters = require('rainbow-delimiters')
vim.g.rainbow_delimiters = {
strategy = {
[''] = rainbow_delimiters.strategy['global'],
vim = rainbow_delimiters.strategy['local'],
},
query = {
[''] = 'rainbow-delimiters',
lua = 'rainbow-delimiters',
},
priority = {
[''] = 110,
lua = 210,
},
highlight = {
'RainbowDelimiterRed',
'RainbowDelimiterYellow',
'RainbowDelimiterBlue',
'RainbowDelimiterOrange',
'RainbowDelimiterGreen',
'RainbowDelimiterViolet',
'RainbowDelimiterCyan',
},
}
end,
})
@end
** Sentiment
A modern and enhanced replacement for Neovim's built-in matchparen functionality that provides intelligent bracket and delimiter highlighting. Sentiment offers superior performance and visual feedback for matching pairs in your code.
This plugin enhances code navigation by:
- **Smart pair detection**: Accurately highlights matching brackets, parentheses, braces, and other delimiters
- **Performance optimized**: Faster and more efficient than the default matchparen plugin
- **Visual clarity**: Clear highlighting that makes it easy to identify matching pairs at a glance
- **Customizable appearance**: Configure colors and styles to match your preferred theme
- **Language awareness**: Intelligent handling of different programming language syntaxes
- **Non-intrusive design**: Subtle highlighting that doesn't interfere with your workflow
**Usage**: Matching pairs are automatically highlighted when your cursor is positioned on or near brackets, parentheses, or other delimiters. The plugin works seamlessly in the background.
**Help**: The highlighting helps you quickly identify the scope of code blocks, function calls, and nested structures, reducing errors and improving code comprehension.
For example, when your cursor is on an opening `{`, the corresponding closing `}` will be highlighted, making it easy to see the extent of code blocks and nested structures.
___
[GitHub]{https://github.com/utilyre/sentiment.nvim}
@code lua
plug({
"utilyre/sentiment.nvim",
version = "*",
event = "VeryLazy", -- keep for lazy loading
opts = {
-- config
},
init = function()
-- `matchparen.vim` needs to be disabled manually in case of lazy loading
vim.g.loaded_matchparen = 1
end,
})
@end
** Headlines
This plugin adds highlights for text filetypes, like markdown, orgmode, and neorg.
___
[GitHub]{https://github.com/lukas-reineke/headlines.nvim}
@code lua
plug({
"lukas-reineke/headlines.nvim",
dependencies = "nvim-treesitter/nvim-treesitter",
config = function()
vim.cmd [[highlight Headline1 guibg=#1e2718]]
vim.cmd [[highlight Headline2 guibg=#21262d]]
vim.cmd [[highlight CodeBlock guibg=#1c1c1c]]
vim.cmd [[highlight Dash guibg=#D19A66 gui=bold]]
require("headlines").setup {
norg = {
query = vim.treesitter.query.parse(
"norg",
[[
[
(heading1_prefix)
(heading2_prefix)
(heading3_prefix)
(heading4_prefix)
(heading5_prefix)
(heading6_prefix)
] @headline
(weak_paragraph_delimiter) @dash
(strong_paragraph_delimiter) @doubledash
([(ranged_tag
name: (tag_name) @_name
(#eq? @_name "code")
)
(ranged_verbatim_tag
name: (tag_name) @_name
(#eq? @_name "code")
)] @codeblock (#offset! @codeblock 0 0 1 0))
(quote1_prefix) @quote
]]
),
headline_highlights = { "Headline1", "Headline2" },
bullet_highlights = {
"@neorg.headings.1.prefix",
"@neorg.headings.2.prefix",
"@neorg.headings.3.prefix",
"@neorg.headings.4.prefix",
"@neorg.headings.5.prefix",
"@neorg.headings.6.prefix",
},
bullets = { "◉", "○", "✸", "✿" },
codeblock_highlight = false,
dash_highlight = "Dash",
dash_string = "-",
doubledash_highlight = "DoubleDash",
doubledash_string = "=",
quote_highlight = "Quote",
quote_string = "┃",
fat_headlines = true,
fat_headline_upper_string = "▄",
fat_headline_lower_string = "▀",
},
}
end,
})
@end
* UI
Here we configure the user interface for Neovim.
___
** Lualine
A blazing fast and highly customizable statusline plugin for Neovim written in pure Lua. Lualine provides a beautiful and informative status bar that displays essential information about your editing session while maintaining excellent performance.
This statusline implementation offers:
- **Lightning-fast performance**: Written in Lua with minimal overhead, ensuring your editor stays responsive
- **Extensive customization**: Configure colors, components, separators, and layout to match your workflow
- **Rich component library**: Display mode, branch, diagnostics, file info, LSP status, and much more
- **Theme integration**: Seamlessly integrates with your colorscheme or use custom themes
- **Extension support**: Built-in support for popular plugins like fugitive, fzf, and nvim-tree
- **Winbar support**: Optional window-local statuslines for better file navigation
- **Tabline functionality**: Replace Neovim's default tabline with a customizable alternative
**Usage**: The statusline is automatically displayed and updates in real-time. The configuration includes custom themes, component positioning, and integration with LSP diagnostics and Git information.
**Help**: Run `:help lualine` for comprehensive documentation. The plugin displays current mode, Git branch, file path, diagnostics, and cursor position by default.
For example, the statusline shows your current Vim mode (Normal, Insert, Visual), Git branch with diff statistics, file encoding, and line/column position, all with color-coded indicators for quick visual reference.
___
[GitHub]{https://github.com/nvim-lualine/lualine.nvim}
@code lua
local colors = {
black = "#000000",
white = "#ffffff",
gray = "#444444",
light_gray = "#666666",
background = "#0c0c0c",
green = "#005000",
yellow = "#706000",
blue = "#004090",
paste = "#5518ab",
red = "#800000",
}
local lualine_theme = {
normal = {
a = { fg = colors.white, bg = colors.green },
b = { fg = colors.white, bg = colors.grey },
c = { fg = colors.white, bg = colors.black },
},
insert = { a = { fg = colors.white, bg = colors.blue } },
command = { a = { fg = colors.white, bg = colors.red } },
visual = { a = { fg = colors.white, bg = colors.yellow } },
replace = { a = { fg = colors.white, bg = colors.red } },
inactive = {
a = { fg = colors.white, bg = colors.black },
b = { fg = colors.white, bg = colors.black },
c = { fg = colors.light_gray, bg = colors.black },
},
}
plug({
{
"nvim-lualine/lualine.nvim",
event = "VeryLazy",
opts = function()
return {
options = {
theme = lualine_theme,
component_separators = { left = "", right = "" },
section_separators = { left = "", right = "" },
},
sections = {
lualine_a = { "mode" },
lualine_b = { "branch", "diff", "diagnostics" },
lualine_c = {
{
"filename",
path = 4
},
},
lualine_x = { "encoding", "fileformat", "filetype" },
lualine_y = { "progress" },
lualine_z = { "location" },
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = {
{
"filename",
path = 4
},
},
lualine_x = { "location" },
lualine_y = {},
lualine_z = {},
},
tabline = {},
winbar = {
lualine_c = {
{
"filename",
path = 4,
},
"navic"
},
},
inactive_winbar = {
lualine_c = {
{
"filename",
path = 3
}
},
},
extensions = {},
}
end,
},
})
@end
@end
** ufo
@code lua
plug({
'kevinhwang91/nvim-ufo',
dependencies = 'kevinhwang91/promise-async',
config = function()
local ufo = require("ufo")
vim.o.foldcolumn = "0" -- show fold column
vim.o.foldlevel = 99 -- start unfolded
vim.o.foldlevelstart = 99
vim.o.foldenable = true
-- vim.o.foldlevelstart = 0 -- 0 means all folds start closed
-- vim.o.foldlevel = 0 -- current fold level
-- Set up keymaps
vim.keymap.set("n", "zR", ufo.openAllFolds)
vim.keymap.set("n", "zM", ufo.closeAllFolds)
vim.keymap.set("n", "zr", ufo.openFoldsExceptKinds) -- open more folds selectively
vim.keymap.set("n", "zm", ufo.closeFoldsWith) -- close folds selectively
vim.keymap.set('n', 'K', function()
local ok, ufo = pcall(require, 'ufo')
local line = vim.fn.line('.')
if vim.fn.foldclosed(line) ~= -1 and ok then
-- Cursor is on a folded line
local winid = ufo.peekFoldedLinesUnderCursor()
if not winid then
print("No folded lines to peek")
end
else
pcall(vim.lsp.buf.hover)
end
end)
-- Function to pick the right provider for UFO
local function provider_selector(bufnr)
-- Get all active LSP clients for this buffer
local clients = vim.lsp.get_active_clients({bufnr = bufnr})
for _, client in ipairs(clients) do
-- Check if this client supports folding
if client.server_capabilities.foldingRangeProvider then
return "lsp"
end
end
-- Fallback to treesitter if no LSP supports folding
return "treesitter"
end
-- local capabilities = vim.lsp.protocol.make_client_capabilities()
-- capabilities.textDocument.foldingRange = {
-- dynamicRegistration = false,
-- lineFoldingOnly = true
-- }
-- local language_servers = vim.lsp.get_clients() -- or list servers manually like {'gopls', 'clangd'}
-- for _, ls in ipairs(language_servers) do
-- require('lspconfig')[ls].setup({
-- capabilities = capabilities
-- -- you can add other fields for setting up lsp server in this table
-- })
-- end
-- Set provider selector
ufo.setup({
close_fold_kinds_for_ft = {
-- Python
python = {
"class_definition",
"function_definition",
"if_statement",
"for_statement",
"while_statement",
"try_statement",
"with_statement",
"import_statement",
"import_from_statement",
"decorated_definition",
"string",
"argument_list",
"parenthesized_expression",
"dictionary",
-- "parameters",
},
-- Lua
lua = {
"function_definition",
"if_statement",
"for_statement",
"while_statement",
"repeat_statement",
"table_constructor",
"do_statement",
},
-- Bash / Shell
bash = {
"function_definition",
"if_statement",
"for_statement",
"while_statement",
"until_statement",
"case_statement",
"compound_command",
},
-- C / C++ / Objective-C
c = {
"function_definition",
"if_statement",
"for_statement",
"while_statement",
"switch_statement",
"struct_definition",
"enum_definition",
"compound_statement",
},
cpp = {
"function_definition",
"if_statement",
"for_statement",
"while_statement",
"switch_statement",
"class_definition",
"struct_definition",
"enum_definition",
"compound_statement",
},
-- JavaScript / TypeScript
javascript = {
"function",
"method_definition",
"class_declaration",
"if_statement",
"for_statement",
"while_statement",
"switch_statement",
"try_statement",
"block",
},
typescript = {
"function",
"method_definition",
"class_declaration",
"if_statement",
"for_statement",
"while_statement",
"switch_statement",
"try_statement",
"block",
},
-- Rust
rust = {
"function_item",
"impl_item",
"struct_item",
"enum_item",
"trait_item",
"mod_item",
"if_expression",
"for_expression",
"while_expression",
"loop_expression",
"block",
},
-- Go
go = {
"function_declaration",
"method_declaration",
"type_spec",
"if_statement",
"for_statement",
"switch_statement",
"select_statement",
"block",
},
-- Markdown
markdown = {
"atx_heading",
"setext_heading",
"fenced_code_block",
"list_item",
"blockquote",
},
-- Neorg
norg = {
"heading1",
"heading2",
},
},
provider_selector = function(bufnr, filetype, buftype)
return {provider_selector(), "indent"}
end,
fold_virt_text_handler = function(virtText, lnum, endLnum, width, truncate)
local newVirtText = {}
local suffix = (' %d '):format(endLnum - lnum)
local sufWidth = vim.fn.strdisplaywidth(suffix)
local targetWidth = width - sufWidth
local curWidth = 0
for _, chunk in ipairs(virtText) do
local chunkText = chunk[1]
local chunkWidth = vim.fn.strdisplaywidth(chunkText)
if targetWidth > curWidth + chunkWidth then
table.insert(newVirtText, chunk)
else
chunkText = truncate(chunkText, targetWidth - curWidth)
local hlGroup = chunk[2]
table.insert(newVirtText, {chunkText, hlGroup})
chunkWidth = vim.fn.strdisplaywidth(chunkText)
-- str width returned from truncate() may less than 2nd argument, need padding
if curWidth + chunkWidth < targetWidth then
suffix = suffix .. (' '):rep(targetWidth - curWidth - chunkWidth)
end
break
end
curWidth = curWidth + chunkWidth
end
table.insert(newVirtText, {suffix, 'MoreMsg'})
return newVirtText
end,
})
end
})
@end
* NEORG
An all-encompassing tool based around structured note taking, project and task management, time tracking, slideshows, writing typeset documents and much more.
___
[GitHub]{https://github.com/nvim-neorg/neorg}
[Spec]{https://github.com/nvim-neorg/norg-specs/blob/main/1.0-specification.norg}
@code lua
plug({
"nvim-neorg/neorg",
lazy = false, -- Neorg does not like lazy loading
build = ":Neorg sync-parsers",
dependencies = {
"nvim-lua/plenary.nvim",
"Pocco81/true-zen.nvim",
"nvim-treesitter/nvim-treesitter",
"nvim-treesitter/nvim-treesitter-textobjects",
"hrsh7th/nvim-cmp",
'jmbuhr/otter.nvim',
},
-- ft = "norg",
-- cmd = "Neorg",
config = function()
require("neorg").setup({
load = {
["core.defaults"] = {}, -- Loads default behaviour
["core.concealer"] = { -- Adds pretty icons to your documents
config = {
foldlevelstart = "99",
icon_preset = "diamond",
icons = {
code_block = {
width = "content",
min_width = 85,
conceal = true,
},
},
},
},
["core.dirman"] = { -- Manages Neorg workspaces
config = {
workspaces = {
documents = "~/Documents",
notes = "~/Documents/Notes",
career = "~/Documents/Career",
profiles = "~/Documents/Profiles",
},
default_workspace = "documents",
},
},
["core.completion"] = {
config = {
engine = 'nvim-cmp',
name = "[Norg]",
}
},
["core.integrations.nvim-cmp"] = {},
["core.qol.toc"] = {
config = {
close_split_on_jump = true,
toc_split_placement = "right",
}
},
["core.export"] = {},
["core.export.markdown"] = {
config = {
extensions = "all",
}
},
["core.presenter"] = {
config = {
zen_mode = "truezen",
}
},
["core.journal"] = {
config = {
workspace = "journal",
strategy = "flat",
}
},
["core.summary"] = {},
["core.esupports.metagen"] = {
config = {
type = "auto",
author = "Simon H Moore <simon@simonhugh.xyz>",
update_date = true
}
},
["core.ui.calendar"] = {},
["core.integrations.otter"] = {},
}
})
local neorg_callbacks = require("neorg.core.callbacks")
neorg_callbacks.on_event("core.keybinds.events.enable_keybinds", function(_, keybinds)
-- Map all the below keybinds only when the "norg" mode is active
keybinds.map_event_to_mode("norg", {
n = { -- Bind keys in normal mode
{ "<localleader>ff", function() Snacks.picker.files({ cwd = vim.fn.getcwd() }) end, opts = { desc = 'Find Norg Files' } },
{ "<localleader>sh", function() Snacks.picker.grep({ cwd = vim.fn.getcwd() }) end, opts = { desc = 'Search Headings' } },
{ "<localleader>cg", "core.looking-glass.magnify-code-block", opts = { desc = 'Looking Glass' } },
},
i = { -- Bind in insert mode
{ "<C-l>", function() print("Link insertion not available with snacks") end, opts = { desc = 'Insert Link (unavailable)' } },
{ "<C-L>", function() print("File link insertion not available with snacks") end, opts = { desc = 'Insert File Link (unavailable)' } },
},
}, {
silent = true,
noremap = true,
})
end)
end,
})
@end
* SNACKS
A collection of small QoL plugins for Neovim.
___
@code lua
plug({
"folke/snacks.nvim",
priority = 1000,
lazy = false,
---@type snacks.Config
opts = {
-- Keep only the useful non-picker modules
bigfile = { enabled = true },
indent = {
indent = {
enabled = true,
priority = 1,
char = "▎",
},
animate = { enabled = false },
scope = {
enabled = true, -- enable highlighting the current scope
priority = 200,
char = "▎",
},
},
-- Enable snacks notify
notifier = {
enabled = true,
timeout = 1000,
width = { min = 20, max = 50 },
height = { max = 50 },
style = "compact",
top_down = true,
},
-- Enable snacks input to replace dressing.nvim
input = { enabled = true },
-- Enable snacks words for navigation (]] [[)
words = {
enabled = true,
debounce = 200,
},
-- Enable quickfile for better performance
quickfile = { enabled = true },
-- Enable picker instead of telescope
picker = { enabled = true },
-- Keep disabled
dashboard = { enabled = false },
explorer = { enabled = false },
scope = { enabled = false },
scroll = { enabled = false },
statuscolumn = { enabled = false },
scratch = {
enabled = true,
ft = "norg",
root = "~/Documents/Notes/scratch",
filekey = {
id = nil, ---@type string? unique id used instead of name for the filename hash