forked from pratyushmittal/kickstart.nvim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
1052 lines (972 loc) · 36 KB
/
Copy pathinit.lua
File metadata and controls
1052 lines (972 loc) · 36 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
-- Set <space> as the leader key
-- set it before plugins are loaded (otherwise wrong leader will be used)
vim.g.mapleader = ' '
local uv = vim.uv or vim.loop
local data_path = vim.fn.stdpath 'data'
local function ensure_writable_directory(path)
if vim.fn.isdirectory(path) == 1 and vim.fn.filewritable(path) == 2 then
return path
end
local ok = pcall(vim.fn.mkdir, path, 'p')
if ok and vim.fn.isdirectory(path) == 1 and vim.fn.filewritable(path) == 2 then
return path
end
end
local function resolve_treesitter_parser_dir()
local candidates = {
data_path .. '/site',
vim.fn.stdpath 'state' .. '/site',
vim.fn.stdpath 'cache' .. '/site',
}
for _, candidate in ipairs(candidates) do
local writable_dir = ensure_writable_directory(candidate)
if writable_dir then
return writable_dir
end
end
return data_path .. '/site'
end
local treesitter_parser_dir = resolve_treesitter_parser_dir()
local treesitter_parsers = {
'bash',
'c',
'comment',
'diff',
'html',
'htmldjango',
'lua',
'luap',
'luadoc',
'markdown',
'markdown_inline',
'query',
'vim',
'vimdoc',
'python',
'elixir',
}
-- Make parser installs available on the runtimepath no matter which writable
-- stdpath location was selected above.
vim.opt.runtimepath:append(treesitter_parser_dir)
-- Neovim 0.11 deprecates the table-form `vim.validate({ ... })`, but a number
-- of plugins still call it. Keep that form working without emitting warnings.
do
local validate = vim.validate
local legacy_type_aliases = {
b = 'boolean',
c = 'callable',
f = 'function',
n = 'number',
s = 'string',
t = 'table',
}
local function normalize_validator(validator)
if type(validator) == 'string' then
return legacy_type_aliases[validator] or validator
end
if type(validator) == 'table' then
return vim.tbl_map(normalize_validator, validator)
end
return validator
end
--- @diagnostic disable-next-line: duplicate-set-field
function vim.validate(name, value, validator, optional, message)
if validator ~= nil or type(name) ~= 'table' then
return validate(name, value, validator, optional, message)
end
local keys = vim.tbl_keys(name)
table.sort(keys)
for _, param_name in ipairs(keys) do
local spec = name[param_name]
if type(spec) ~= 'table' then
error(string.format('opt[%s]: expected table, got %s', param_name, type(spec)), 0)
end
local ok, err
local validator_spec = normalize_validator(spec[2])
local spec_optional = spec[3] == true
local spec_message = type(spec[3]) == 'string' and spec[3] or nil
if spec_optional then
ok, err = pcall(validate, param_name, spec[1], validator_spec, true)
elseif spec_message then
ok, err = pcall(validate, param_name, spec[1], validator_spec, spec_message)
else
ok, err = pcall(validate, param_name, spec[1], validator_spec)
end
if not ok then
error(err, 0)
end
end
end
end
-- Lazy for plugins
-- https://lazy.folke.io/installation
local lazypath = data_path .. '/lazy/lazy.nvim'
if not uv.fs_stat(lazypath) then
vim.fn.system {
'git',
'clone',
'--filter=blob:none',
'--branch=stable',
'https://github.com/folke/lazy.nvim.git',
lazypath,
}
end
vim.opt.rtp:prepend(lazypath)
-- Use Lazy
-- Setup lazy.nvim
require('lazy').setup({
-- Theme helper used by some color schemes.
'https://github.com/rktjmp/lush.nvim',
-- Primary One Dark theme.
{
'https://github.com/olimorris/onedarkpro.nvim',
opts = {
options = { cursorline = true },
},
},
-- Japanese-inspired theme with custom URL highlight tweaks.
{
'https://github.com/rebelot/kanagawa.nvim',
opts = {
dimInactive = true,
undercurl = true,
overrides = function(colors)
return {
['@string.special.url'] = { underline = true, undercurl = false },
}
end,
},
},
-- Alternate Tokyo Night theme.
'https://github.com/folke/tokyonight.nvim',
-- Alternate muted theme.
'https://github.com/vague2k/vague.nvim',
-- Alternate retro warm theme.
'https://github.com/srcery-colors/srcery-vim',
-- Alternate Catppuccin theme collection.
{ 'https://github.com/catppuccin/nvim', name = 'catppuccin', priority = 1000 },
-- Switch themes automatically based on the OS light/dark mode.
{
'f-person/auto-dark-mode.nvim',
opts = {
set_dark_mode = function()
vim.cmd 'colorscheme srcery'
end,
set_light_mode = function()
vim.cmd 'colorscheme kanagawa'
end,
},
},
{
-- Syntax-aware highlighting, indentation, textobjects and selections.
'nvim-treesitter/nvim-treesitter',
branch = 'master',
build = ':TSUpdate',
main = 'nvim-treesitter.configs',
opts = {
parser_install_dir = treesitter_parser_dir,
ensure_installed = {},
auto_install = false,
highlight = { enable = true },
indent = { enable = true },
-- https://github.com/RRethy/nvim-treesitter-endwise extension
endwise = { enable = true },
-- incremental selection
incremental_selection = {
enable = true,
keymaps = {
init_selection = 's',
node_incremental = 's',
node_decremental = 'S',
},
},
textobjects = {
move = {
enable = true,
set_jumps = true, -- whether to set jumps in the jumplist
goto_next_start = {
[']c'] = '@class.outer',
-- https://github.com/nvim-treesitter/nvim-treesitter-textobjects?tab=readme-ov-file#built-in-textobjects
-- ["]]"] = "@function.outer",
},
goto_previous_start = {
-- ["[["] = "@function.outer",
['[c'] = '@class.outer',
},
},
},
},
},
-- Keep the current function/class header visible while scrolling.
{ 'nvim-treesitter/nvim-treesitter-context', opts = { max_lines = 2 } },
-- Install and wire up language servers and external developer tools.
{
-- Mason bridges package installation with Neovim's built-in LSP client.
'mason-org/mason-lspconfig.nvim',
dependencies = {
-- Package manager UI for LSPs, linters, formatters and DAP tools.
{ 'https://github.com/mason-org/mason.nvim', opts = {} },
-- Canonical server configuration definitions for Neovim LSP.
'https://github.com/neovim/nvim-lspconfig',
-- Ensures the listed tools are installed automatically.
{
'https://github.com/WhoIsSethDaniel/mason-tool-installer.nvim',
opts = {
ensure_installed = {
'bashls',
'biome',
'cssls',
'codebook',
'djlint',
'docker_compose_language_service',
'emmet_language_server',
'harper_ls',
'lua_ls',
'ruff',
'rust_analyzer',
'stylua',
'ty',
'typescript-language-server',
'yamlls',
},
},
},
},
opts = {
-- mason-lspconfig supports ensure_installed, but it only works for LSPs, not for linters and formatters
-- hence used them via mason-tool-installer
ensure_installed = {},
},
},
-- Show background LSP progress notifications.
{ 'j-hui/fidget.nvim', opts = {} },
-- Highlight other occurrences of the symbol under the cursor.
'https://github.com/RRethy/vim-illuminate',
-- Snippet engine used by completion and manual snippet expansion.
{
'https://github.com/L3MON4D3/LuaSnip',
-- enable regex support
build = 'make install_jsregexp',
dependencies = {
-- Loads community snippets plus local snipmate-style snippets.
{
'https://github.com/rafamadriz/friendly-snippets',
config = function()
require('luasnip.loaders.from_vscode').lazy_load()
-- snipmate snippets are easier to write, hance use this for custom snippets in `snippets` folder
require('luasnip.loaders.from_snipmate').lazy_load()
end,
},
},
},
-- Main completion engine for LSP, snippets and paths.
{
'https://github.com/saghen/blink.cmp',
-- requires version setting to download pre-built fuzzy binary
-- https://cmp.saghen.dev/configuration/fuzzy#prebuilt-binaries-default-on-a-release-tag
version = '1.*',
event = 'VimEnter',
dependencies = {
-- Improves Lua completions for Neovim config/plugin development.
'https://github.com/folke/lazydev.nvim',
},
--- @module 'blink.cmp'
--- @type blink.cmp.Config
opts = {
keymap = {
-- default keymap
-- <c-y> to accept ([y]es) the completion.
-- <tab>/<s-tab>: move to right/left of your snippet expansion
-- <c-space>: Open menu or open docs if already open
-- <c-n>/<c-p> or <up>/<down>: Select next/previous item
-- <c-e>: Hide menu
-- <c-k>: Toggle signature help
-- See :h blink-cmp-config-keymap for defining your own keymap
preset = 'default',
-- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see:
-- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps
},
completion = {
-- By default, you may press `<c-space>` to show the documentation.
-- Optionally, set `auto_show = true` to show the documentation after a delay.
documentation = { auto_show = true, auto_show_delay_ms = 200 },
menu = {
-- default
-- https://cmp.saghen.dev/configuration/reference.html#completion-menu-draw
border = 'rounded',
draw = {
columns = {
{ 'label', 'label_description', gap = 1 },
{ 'kind_icon', 'kind' },
},
},
},
},
sources = {
default = { 'lsp', 'path', 'snippets', 'lazydev' },
providers = {
lazydev = { module = 'lazydev.integrations.blink', score_offset = 100 },
},
},
snippets = { preset = 'luasnip' },
-- Blink.cmp includes an optional, recommended rust fuzzy matcher,
-- which automatically downloads a prebuilt binary when enabled.
--
-- By default, we use the Lua implementation instead, but you may enable
-- the rust implementation via `'prefer_rust_with_warning'`
--
-- See :h blink-cmp-config-fuzzy for more information
fuzzy = { implementation = 'prefer_rust_with_warning' },
-- Shows a signature help window while you type arguments for a function
signature = { enabled = true },
},
},
-- Fuzzy finder for files, symbols, grep results and other pickers.
{
'nvim-telescope/telescope.nvim',
branch = 'master',
event = 'VimEnter',
dependencies = {
-- Lua utility functions used by Telescope and many other plugins.
'nvim-lua/plenary.nvim',
-- Replaces `vim.ui.select` prompts with Telescope pickers.
'nvim-telescope/telescope-ui-select.nvim',
-- Filetype icons in Telescope and the statusline.
'nvim-tree/nvim-web-devicons',
{
-- Native sorter for faster Telescope matching.
'nvim-telescope/telescope-fzf-native.nvim',
-- `build` is run only once. When the plugin is installed/updated.
build = 'make',
},
-- brew install ripgrep
},
config = function()
require('telescope').setup {
defaults = { wrap_results = true },
extensions = {
['ui-select'] = {
require('telescope.themes').get_dropdown(),
},
},
}
-- Enable extensions
require('telescope').load_extension 'fzf'
require('telescope').load_extension 'ui-select'
end,
},
-- Show git hunks in the signcolumn and expose hunk actions.
{
'https://github.com/lewis6991/gitsigns.nvim',
opts = {
signs = {
add = { text = '+' },
change = { text = '~' },
delete = { text = '_' },
topdelete = { text = '‾' },
changedelete = { text = '~' },
},
},
},
-- Auto-insert matching brackets and quotes while typing.
{ 'https://github.com/windwp/nvim-autopairs', event = 'InsertEnter', opts = { check_ts = true } },
-- Add/change/delete surrounding quotes, brackets and tags.
{ 'https://github.com/echasnovski/mini.surround', version = false, opts = {} },
-- Auto-insert `end`/language-specific closing keywords using Treesitter.
'https://github.com/RRethy/nvim-treesitter-endwise',
-- Adds syntax-aware textobjects and motions for Treesitter nodes.
'nvim-treesitter/nvim-treesitter-textobjects',
-- Auto-close and rename HTML/JSX tags.
{ 'https://github.com/windwp/nvim-ts-autotag', opts = {} },
-- Multiple cursors for editing repeated matches at once.
'mg979/vim-visual-multi',
-- Allows `:e path/to/file` to create missing files on demand.
'https://github.com/jessarcher/vim-heritage',
-- File explorer/editing interface that treats directories like buffers.
{
'https://github.com/stevearc/oil.nvim',
opts = {},
-- Lightweight icon provider used by Oil.
dependencies = { { 'https://github.com/echasnovski/mini.icons', opts = {} } },
},
-- Detect indentation settings from the current file and EditorConfig.
'https://github.com/tpope/vim-sleuth',
-- Draw indentation guides to show nesting depth.
{ 'https://github.com/lukas-reineke/indent-blankline.nvim', main = 'ibl', opts = {} },
-- Run formatters on save with LSP fallback when needed.
{
'https://github.com/stevearc/conform.nvim',
config = function()
require('conform').setup {
formatters_by_ft = {
-- we need to install these using :MasonInstall
-- we have fallback for lsp below. Hence need these only when the lsp doesn't do formatting
lua = { 'stylua' },
html = { 'djlint' },
css = { 'biome' },
htmldjango = { 'djlint' },
python = { 'ruff_fix', 'ruff_organize_imports', 'ruff_format' },
},
formatters = {
djlint = {
-- requires running djlint once from terminal to prevent timeout
-- use <c-/> to open terminal
prepend_args = { '--indent', '2', '--max-blank-lines', '2', '--profile', 'django' },
},
},
-- enable format on save
format_on_save = function(bufnr)
-- Disable with a global or buffer-local variable
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
return
end
return {
-- These options will be passed to conform.format()
timeout_ms = 500,
lsp_format = 'fallback',
}
end,
}
end,
},
-- Popup that documents available keybindings as you type prefixes.
{
'https://github.com/folke/which-key.nvim',
event = 'VimEnter', -- Sets the loading event to 'VimEnter'
opts = {
-- Document existing key chains
spec = {
{ 'gr', group = '[G]oto [R]eference' },
{ '<leader>a', group = '[A]I' },
{ '<leader>b', group = '[B]uffer' },
{ '<leader>c', group = '[C]ode', mode = { 'n', 'x' } },
{ '<leader>d', group = '[D]ocument' },
{ '<leader>r', group = '[R]ename' },
{ '<leader>s', group = '[S]earch' },
{ '<leader>w', group = '[W]orkspace' },
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
},
},
},
-- Highlight TODO/FIXME/NOTE style comments.
{ 'https://github.com/folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } },
-- Improved UI for input/select prompts.
{ 'https://github.com/stevearc/dressing.nvim', opts = {} },
-- AI assistant integration for chat, inline edits and command actions.
{
'https://github.com/pratyushmittal/codecompanion.nvim',
branch = 'tab-autocomplete',
cmd = {
'CodeCompanion',
'CodeCompanionActions',
'CodeCompanionChat',
'CodeCompanionCmd',
'CodeCompanionComplete',
},
keys = {
{ '<leader>aa', '<cmd>CodeCompanionActions<cr>', mode = { 'n', 'v' }, desc = '[A]ctions' },
{ '<leader>ac', '<cmd>CodeCompanionChat<cr>', mode = { 'n', 'v' }, desc = '[C]hat' },
{ '<leader>at', '<cmd>CodeCompanionChat Toggle<cr>', mode = { 'n', 'v' }, desc = '[T]oggle' },
{ '<C-f>', '<cmd>CodeCompanionComplete<cr>', mode = 'i', desc = 'Complete [F]orward' },
{ '<leader>ae', ":'<,'>CodeCompanion #buffer ", mode = 'v', desc = '[E]dit' },
},
opts = {
prompt_library = require 'prompts',
strategies = {
chat = {
adapter = 'openai',
model = 'gpt-5-2025-08-07',
tools = {
opts = {
auto_submit_errors = false, -- Send any errors to the LLM automatically?
auto_submit_success = false, -- Send any successful output to the LLM automatically?
},
},
},
inline = {
adapter = 'openai',
model = 'gpt-5-2025-08-07',
},
cmd = {
adapter = 'openai',
model = 'gpt-5-2025-08-07',
},
},
opts = {
log_level = 'ERROR',
},
},
dependencies = {
-- Shared Lua helpers used by CodeCompanion.
'nvim-lua/plenary.nvim',
-- Syntax tree support for buffer-aware AI actions.
'nvim-treesitter/nvim-treesitter',
},
},
-- Statusline showing filename, diff, diagnostics and filetype.
{
'https://github.com/nvim-lualine/lualine.nvim',
-- Optional filetype icons in the statusline.
dependencies = { 'nvim-tree/nvim-web-devicons' },
opts = {
sections = {
-- https://github.com/nvim-lualine/lualine.nvim?tab=readme-ov-file#filename-component-options
lualine_b = { { 'filename', path = 1 } },
lualine_c = { 'diff', 'diagnostics' },
lualine_x = { 'filetype' },
},
},
},
-- Toggleable floating terminal for shell commands and tools.
{
'https://github.com/akinsho/toggleterm.nvim',
version = '*',
opts = {
size = 20,
open_mapping = [[<c-\>]],
hide_numbers = true,
shade_filetypes = {},
shade_terminals = true,
shading_factor = 2,
start_in_insert = true,
insert_mappings = true,
persist_size = true,
direction = 'float',
close_on_exit = true,
shell = vim.o.shell,
float_opts = {
border = 'curved',
winblend = 0,
highlights = {
border = 'Normal',
background = 'Normal',
},
},
},
},
-- Disables expensive features automatically for very large files.
{ 'https://github.com/LunarVim/bigfile.nvim', opts = {} },
-- Delete buffers without breaking the current window layout.
'https://github.com/famiu/bufdelete.nvim',
-- Run project tests from inside Neovim.
'https://github.com/vim-test/vim-test',
-- Execute code snippets or the current file and show the output inline.
{
'https://github.com/michaelb/sniprun',
branch = 'master',
build = 'sh install.sh',
-- do 'sh install.sh 1' if you want to force compile locally
-- (instead of fetching a binary from the github release). Requires Rust >= 1.65
opts = {},
},
-- Generate language-aware log statements quickly.
{
'https://github.com/Goose97/timber.nvim',
version = '*', -- Use for stability; omit to use `main` branch for the latest features
event = 'VeryLazy',
opts = {},
},
-- Search cheat sheets and available command references.
{ 'https://github.com/doctorfree/cheatsheet.nvim', opts = { bundled_cheatsheets = { disabled = { 'nerd-fonts' } } } },
-- Enable LSP/completion inside fenced code blocks in markdown-like files.
{ 'https://github.com/jmbuhr/otter.nvim', opts = {} },
-- Navigate between neighboring syntax tree nodes instead of plain text.
{
'https://github.com/aaronik/treewalker.nvim',
-- The following options are the defaults.
-- Treewalker aims for sane defaults, so these are each individually optional,
-- and setup() does not need to be called, so the whole opts block is optional as well.
opts = {
-- Whether to briefly highlight the node after jumping to it
highlight = true,
-- How long should above highlight last (in ms)
highlight_duration = 250,
-- The color of the above highlight. Must be a valid vim highlight group.
-- (see :h highlight-group for options)
highlight_group = 'CursorLine',
},
},
-- Another indentation detector; useful when heuristics differ from sleuth.
'https://github.com/NMAC427/guess-indent.nvim',
-- Lua development helpers for editing your Neovim config itself.
{
-- Adds Neovim runtime/library types so `lua_ls` understands `vim.*`.
'https://github.com/folke/lazydev.nvim',
ft = 'lua',
opts = {
library = {
-- Load luvit types when the `vim.uv` word is found
{ path = '${3rd}/luv/library', words = { 'vim%.uv' } },
},
},
},
}, {
rocks = {
enabled = false,
hererocks = false,
},
})
-- Share completion capabilities with all language servers.
-- LSP for linting, definition, references, symbols
-- local capabilities = vim.lsp.protocol.make_client_capabilities()
local capabilities = require('blink.cmp').get_lsp_capabilities()
-- Python linter/fixer server.
vim.lsp.config('ruff', { capabilities = capabilities, offset_encoding = 'utf-8' })
-- Rust language server with proc-macro exclusions for specific macros.
vim.lsp.config('rust_analyzer', {
capabilities = capabilities,
settings = {
['rust-analyzer'] = {
procMacro = {
ignored = {
leptos_macro = {
-- optional: --
-- "component",
'server',
},
},
},
},
},
})
-- CSS language server with stricter duplicate property warnings.
vim.lsp.config('cssls', {
capabilities = capabilities,
settings = {
-- we can check all properties by doing :Mason, select tool, "LSP server configuration schema"
css = {
lint = { duplicateProperties = 'warning' },
},
},
})
-- YAML language server.
vim.lsp.config('yamlls', { capabilities = capabilities })
-- Biome language server for JS/CSS/web tooling.
vim.lsp.config('biome', { capabilities = capabilities })
-- TypeScript language server.
vim.lsp.config('ts_ls', { capabilities = capabilities })
-- Emmet abbreviations for HTML/CSS-like filetypes.
vim.lsp.config('emmet_language_server', { capabilities = capabilities })
-- Astro framework language server.
vim.lsp.config('astro', { capabilities = capabilities })
-- Lua language server tuned for Neovim config development.
vim.lsp.config('lua_ls', {
capabilities = capabilities,
completion = {
callSnippet = 'Replace',
},
settings = {
Lua = {
diagnostics = { globals = { 'vim' } },
},
},
})
-- Docker Compose language server.
vim.lsp.config('docker_compose_language_service', { capabilities = capabilities })
-- Python type checker / analyzer with auto-import support.
vim.lsp.config(
'ty',
{ capabilities = capabilities, offset_encoding = 'utf-8', settings = {
ty = {
experimental = {
autoImport = true,
},
},
} }
)
-- Prose and grammar checker for text-heavy filetypes.
vim.lsp.config('harper_ls', {
capabilities = capabilities,
filetypes = {
'gitcommit',
'html',
'htmldjango',
'markdown',
'rust',
'swift',
'toml',
'php',
'dart',
},
settings = {
['harper-ls'] = {
userDictPath = '~/dict.txt',
linters = {
SentenceCapitalization = false,
},
},
},
})
-- show diagnostic errors inline
vim.diagnostic.config {
virtual_lines = {
-- Only show virtual line diagnostics for the current cursor line
current_line = true,
},
-- severity_sort = true,
-- float = { border = 'rounded', source = 'if_many' },
-- underline = { severity = vim.diagnostic.severity.ERROR },
-- signs = vim.g.have_nerd_font and {
-- text = {
-- [vim.diagnostic.severity.ERROR] = ' ',
-- [vim.diagnostic.severity.WARN] = ' ',
-- [vim.diagnostic.severity.INFO] = ' ',
-- [vim.diagnostic.severity.HINT] = ' ',
-- },
-- } or {},
-- virtual_text = {
-- source = 'if_many',
-- spacing = 2,
-- format = function(diagnostic)
-- local diagnostic_message = {
-- [vim.diagnostic.severity.ERROR] = diagnostic.message,
-- [vim.diagnostic.severity.WARN] = diagnostic.message,
-- [vim.diagnostic.severity.INFO] = diagnostic.message,
-- [vim.diagnostic.severity.HINT] = diagnostic.message,
-- }
-- return diagnostic_message[diagnostic.severity]
-- end,
-- },
}
-- configure otter for markdown and codecompanion
-- https://github.com/olimorris/codecompanion.nvim/discussions/1284
-- vim.api.nvim_create_autocmd("FileType", {
-- pattern = { '*.md' },
-- callback = function(args)
-- require("otter").activate()
-- local bufnr = args.buf
-- vim.api.nvim_create_autocmd("BufWritePost", {
-- buffer = bufnr,
-- callback = function()
-- require("otter").activate()
-- end
-- })
-- end
-- })
-- VIM OPTIONS
-- we can see all options using `:help option-list`
-- set theme
vim.o.termguicolors = true -- enable true colors
-- vim.cmd 'colorscheme onelight'
-- Use rounded borders for all floating windows (new in Neovim 0.11)
vim.o.winborder = 'rounded'
-- disable autoinsert of first option in menus
vim.o.completeopt = 'menuone,popup,noinsert'
vim.cmd 'colorscheme onedark_dark'
-- Make line numbers default
vim.o.number = true
vim.o.relativenumber = true
-- hide mode as already shown in lualine
vim.o.showmode = false
-- Sync clipboard between OS and Neovim.
-- Schedule the setting after `UiEnter` because it can increase startup-time.
vim.schedule(function()
vim.o.clipboard = 'unnamedplus'
end)
-- wrapped lines have same indent
vim.o.breakindent = true
-- Save undo history
vim.o.undofile = true
-- Case-insensitive searching UNLESS \C or one or more capital letters in the search term
vim.o.ignorecase = true
vim.o.smartcase = true
-- show signcolumn only when there are changes default
-- vim.o.signcolumn = 'yes'
-- Decrease the auto-save time
vim.o.updatetime = 250
-- Decrease mapped sequence wait time
vim.o.timeoutlen = 300
-- Configure how new splits should be opened
-- :vsplit should open split on right
vim.o.splitright = true
vim.o.splitbelow = true
-- Sets how neovim will display certain whitespace characters in the editor.
-- See `:help 'list'`
-- and `:help 'listchars'`
--
-- Notice listchars is set using `vim.opt` instead of `vim.o`.
-- It is very similar to `vim.o` but offers an interface for conveniently interacting with tables.
-- See `:help lua-options`
-- and `:help lua-options-guide`
vim.o.list = true
vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' }
-- Preview substitutions live, as you type!
vim.o.inccommand = 'split'
-- Show which line your cursor is on
vim.o.cursorline = true
-- Minimal number of screen lines to keep above and below the cursor.
vim.o.scrolloff = 7
-- if performing an operation that would fail due to unsaved changes in the buffer (like `:q`),
-- instead raise a dialog asking if you wish to save the current file(s)
-- See `:help 'confirm'`
vim.o.confirm = true
-- Use treesitter for folding
vim.o.foldmethod = 'expr'
vim.o.foldexpr = 'v:lua.vim.treesitter.foldexpr()'
vim.o.foldlevelstart = 99
-- KEY BINDINGS
-- Clear highlights on search when pressing <Esc> in normal mode
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
-- changing buffers
vim.keymap.set('n', '<leader>bp', ':bp<CR>', { desc = '[B]uffer [P]revious' })
vim.keymap.set('n', '<leader>bn', ':bn<CR>', { desc = '[B]uffer [N]ext' })
vim.keymap.set('n', '<leader>bd', ':Bdelete<CR>', { desc = '[B]uffer [D]elete' })
-- CoffeeShop mode
-- use CoffeeShop mode to hide what we type in public places
-- we can use it using these commands
vim.api.nvim_create_user_command('CoffeeShopModeOn', function()
-- Conceal lowercase letters with a bullet in all contexts
vim.cmd 'syntax match CoffeeShop /[a-z]/ conceal cchar=• contains=NONE containedin=ALL'
-- Keep default highlight so colors don't change
vim.cmd 'highlight default link CoffeeShop Normal'
-- Enable conceal in normal and insert modes
vim.wo.conceallevel = 2
vim.wo.concealcursor = 'ni'
end, { desc = 'Enable CoffeeShop mode: conceal lowercase letters with a bullet' })
-- run replt
vim.api.nvim_set_keymap('v', '<leader>x', '<Plug>SnipRun', { silent = true })
vim.api.nvim_set_keymap('n', '<leader>x', '<Plug>SnipRun', { silent = true })
-- LSP keymaps
vim.api.nvim_create_autocmd('LspAttach', {
callback = function()
-- -- new lsp autocompletion supported natively in neovim
-- local client = vim.lsp.get_client_by_id(ev.data.client_id)
-- if client:supports_method('textDocument/completion') then
-- vim.lsp.completion.enable(true, client.id, ev.buf, { autotrigger = true })
-- end
-- Jump to the definition of the word under your cursor.
-- To jump back, press <C-t>.
vim.keymap.set('n', 'gd', require('telescope.builtin').lsp_definitions, { desc = '[G]oto [D]efinition' })
-- Find references for the word under your cursor.
vim.keymap.set('n', 'grr', require('telescope.builtin').lsp_references, { desc = '[G]oto [R]eferences' })
-- Rename the variable under your cursor.
-- Most Language Servers support renaming across files, etc.
vim.keymap.set('n', 'grn', vim.lsp.buf.rename, { desc = '[R]e[n]ame' })
-- Execute a code action, usually your cursor needs to be on top of an error
-- or a suggestion from your LSP for this to activate.
vim.keymap.set({ 'n', 'x' }, 'gra', vim.lsp.buf.code_action, { desc = '[G]oto Code [A]ction' })
end,
})
-- Git keymaps
-- :help gitsigns
vim.keymap.set('n', ']e', ':Gitsigns next_hunk<CR>', { desc = 'Jump to next git [e]dit' })
vim.keymap.set('n', '[e', ':Gitsigns prev_hunk<CR>', { desc = 'Jump to prev git [e]dit' })
vim.keymap.set({ 'n', 'v' }, '<leader>hs', ':Gitsigns stage_hunk<CR>', { desc = 'git [s]tage hunk' })
vim.keymap.set({ 'n', 'v' }, '<leader>hr', ':Gitsigns reset_hunk<CR>', { desc = 'git [r]eset hunk' })
vim.keymap.set({ 'n', 'v' }, '<leader>hu', ':Gitsigns undo_stage_hunk<CR>', { desc = 'git [u]nstage hunk' })
vim.keymap.set({ 'n', 'v' }, '<leader>hd', ':Gitsigns diffthis<CR>', { desc = 'git [d]iff against index' })
vim.keymap.set({ 'n', 'v' }, '<leader>hp', ':Gitsigns preview_hunk<CR>', { desc = 'git [p]review hunk' })
vim.keymap.set({ 'n', 'v' }, '<leader>hb', ':Gitsigns blame_line<CR>', { desc = 'git [b]lame line' })
vim.keymap.set({ 'n', 'v' }, '<leader>hB', ':Gitsigns blame<CR>', { desc = 'git [B]lame file' })
-- edit file under cursor
vim.keymap.set('n', 'gf', ':edit <cfile><cr>', { desc = '[g]oto [f]ile' })
-- open oil folder for current file
vim.keymap.set('n', '-', '<CMD>Oil<CR>', { desc = 'Open parent directory' })
-- Diagnostic keymaps
vim.keymap.set('n', '<leader>q', function()
local win = vim.fn.getloclist(0, { winid = 0 })
if win.winid == 0 then
vim.diagnostic.setloclist()
else
vim.cmd.lclose()
end
end, { desc = 'Toggle diagnostic [Q]uickfix list' })
-- telescope keymaps `:help telescope.builtin`
-- Most important Telescope keymapping is <C-leader>
-- This allows you to filter existing results
-- We can use !foo to exclude results without foo (negative search)
local builtin = require 'telescope.builtin'
vim.keymap.set('n', '<leader>sc', builtin.git_status, { desc = '[S]earch [C]hanges' })
vim.keymap.set('n', '<leader>sh', builtin.help_tags, { desc = '[S]earch [H]elp' })
vim.keymap.set('n', '<leader>sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' })
vim.keymap.set('n', '<leader>sl', builtin.lsp_dynamic_workspace_symbols, { desc = '[S]earch [L]SP' })
vim.keymap.set('n', '<leader>sf', builtin.find_files, { desc = '[S]earch [F]iles' })
vim.keymap.set('n', '<leader>ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' })
vim.keymap.set({ 'n', 'v' }, '<leader>sw', builtin.grep_string, { desc = '[S]earch current [W]ord' })
vim.keymap.set('n', '<leader>sg', builtin.live_grep, { desc = '[S]earch by [G]rep' })
vim.keymap.set('n', '<leader>sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' })
vim.keymap.set('n', '<leader>sr', builtin.resume, { desc = '[S]earch [R]esume' })
vim.keymap.set('n', '<leader>s.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
vim.keymap.set('n', '<leader><leader>', builtin.buffers, { desc = '[ ] Find existing buffers' })
-- Shortcut for searching your Neovim configuration files
vim.keymap.set('n', '<leader>sn', function()
builtin.find_files { cwd = vim.fn.stdpath 'config' }
end, { desc = '[S]earch [N]eovim files' })
-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier
-- for people to discover. Otherwise, you normally need to press <C-\><C-n>, which
-- is not what someone will guess without a bit more experience.
vim.keymap.set('t', '<Esc><Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' })
-- Keybinds to make split navigation easier.
-- Use CTRL+<hjkl> to switch between windows
-- `:help wincmd` for a list of all window commands
vim.keymap.set('n', '<C-h>', '<C-w><C-h>', { desc = 'Move focus to the left window' })
vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right window' })
vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' })
vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' })
-- NOTE: Some terminals have colliding keymaps or are not able to send distinct keycodes
vim.keymap.set('n', '<C-S-h>', '<C-w>H', { desc = 'Move window to the left' })
vim.keymap.set('n', '<C-S-l>', '<C-w>L', { desc = 'Move window to the right' })
vim.keymap.set('n', '<C-S-j>', '<C-w>J', { desc = 'Move window to the lower' })
vim.keymap.set('n', '<C-S-k>', '<C-w>K', { desc = 'Move window to the upper' })
vim.keymap.set('n', '<leader>f', function()
-- If there is only one window, open a vertical split
if vim.fn.winnr() < 2 then
vim.cmd 'vsp'
else
vim.cmd 'only'
end
end, { desc = 'Make current window [F]ull (close others, or vsp if only one)' })
-- treewalker movement
-- https://github.com/aaronik/treewalker.nvim?tab=readme-ov-file#mapping
vim.keymap.set({ 'n', 'v' }, '[[', '<cmd>Treewalker Up<cr>', { silent = true })
vim.keymap.set({ 'n', 'v' }, ']]', '<cmd>Treewalker Down<cr>', { silent = true })
vim.keymap.set({ 'n', 'v' }, '[a', '<cmd>Treewalker Left<cr>', { silent = true })
vim.keymap.set({ 'n', 'v' }, ']a', '<cmd>Treewalker Right<cr>', { silent = true })
-- treewalker swapping
-- vim.keymap.set('n', '{{', '<cmd>Treewalker SwapUp<cr>', { silent = true })
-- vim.keymap.set('n', '}}', '<cmd>Treewalker SwapDown<cr>', { silent = true })