-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit_OLD.lua
More file actions
1339 lines (1225 loc) · 46.8 KB
/
init_OLD.lua
File metadata and controls
1339 lines (1225 loc) · 46.8 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
-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end
vim.opt.rtp:prepend(lazypath)
-- VSCode detection for conditional loading
local not_vscode = not vim.g.vscode
-- disable netrw file explorer (advised by nvim-tree) - only when not in VSCode
if not_vscode then
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
end
require("lazy").setup({
-- Mason package manager (disabled in VSCode)
{
'williamboman/mason.nvim',
cond = not_vscode,
build = ":MasonUpdate",
config = function()
require('mason').setup()
end,
},
-- Mason LSP config (disabled in VSCode)
{
'williamboman/mason-lspconfig.nvim',
cond = not_vscode,
dependencies = { 'williamboman/mason.nvim' },
config = function()
require('mason-lspconfig').setup {
ensure_installed = { 'pylsp', 'lua_ls' },
}
end,
},
-- Useful status updates for LSP (disabled in VSCode)
{
'j-hui/fidget.nvim',
cond = not_vscode,
tag = 'legacy',
config = function()
require("fidget").setup {}
end,
},
-- Additional lua configuration, makes nvim stuff amazing (disabled in VSCode)
{
'folke/neodev.nvim',
cond = not_vscode,
},
-- LSP Configuration & Plugins (disabled in VSCode)
{
'neovim/nvim-lspconfig',
cond = not_vscode,
dependencies = {
'williamboman/mason.nvim',
'williamboman/mason-lspconfig.nvim',
'j-hui/fidget.nvim',
'folke/neodev.nvim',
},
config = function()
-- Setup neovim lua configuration
require('neodev').setup()
-- nvim-cmp supports additional completion capabilities, so broadcast that to servers
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
-- LSP settings.
-- This function gets run when an LSP connects to a particular buffer.
local on_attach = function(_, bufnr)
local nmap = function(keys, func, desc)
if desc then
desc = 'LSP: ' .. desc
end
vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc })
end
nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
nmap('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition')
nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
nmap('gI', vim.lsp.buf.implementation, '[G]oto [I]mplementation')
nmap('<leader>D', vim.lsp.buf.type_definition, 'Type [D]efinition')
nmap('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
nmap('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
nmap('K', vim.lsp.buf.hover, 'Hover Documentation')
nmap('KK', vim.lsp.buf.signature_help, 'Signature Documentation')
nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
nmap('<leader>wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder')
nmap('<leader>wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder')
nmap('<leader>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, '[W]orkspace [L]ist Folders')
-- Create a command `:Format` local to the LSP buffer
vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
vim.lsp.buf.format()
end, { desc = 'Format current buffer with LSP' })
end
-- Manual server setup since mason-lspconfig may not be ready for setup_handlers
local lspconfig = require('lspconfig')
-- Python LSP
lspconfig.pylsp.setup {
capabilities = capabilities,
on_attach = on_attach,
settings = {
pylsp = {
plugins = {
pycodestyle = {
ignore = {'E501'},
maxLineLength = 100
},
},
},
},
}
-- Lua LSP
lspconfig.lua_ls.setup {
capabilities = capabilities,
on_attach = on_attach,
settings = {
Lua = {
workspace = { checkThirdParty = false },
telemetry = { enable = false },
},
},
}
end,
},
-- Autocompletion (disabled in VSCode)
{
'hrsh7th/nvim-cmp',
cond = not_vscode,
dependencies = {
'hrsh7th/cmp-nvim-lsp',
'L3MON4D3/LuaSnip',
'saadparwaiz1/cmp_luasnip',
'hrsh7th/cmp-buffer',
'hrsh7th/cmp-path',
},
},
-- -- Tabnine AI autocompletion
-- { 'codota/tabnine-nvim', build = "./dl_binaries.sh" },
-- {
-- 'tzachar/cmp-tabnine',
-- build = './install.sh',
-- dependencies = { 'hrsh7th/nvim-cmp' }
-- },
-- Highlight, edit, and navigate code
{
'nvim-treesitter/nvim-treesitter',
build = ':TSUpdate',
config = function()
require('nvim-treesitter.configs').setup {
-- Add languages to be installed here that you want installed for treesitter
ensure_installed = { 'c', 'cpp', 'lua', 'python', 'vim' },
-- Install parsers synchronously (only applied to `ensure_installed`)
sync_install = false,
-- Automatically install missing parsers when entering buffer
auto_install = true,
highlight = { enable = true },
indent = { enable = true, disable = { 'python' } },
incremental_selection = {
enable = true,
keymaps = {
init_selection = '<c-space>',
node_incremental = '<c-space>',
scope_incremental = '<c-s>',
node_decremental = '<c-backspace>',
},
},
textobjects = {
select = {
enable = true,
lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
keymaps = {
-- You can use the capture groups defined in textobjects.scm
['aa'] = '@parameter.outer',
['ia'] = '@parameter.inner',
['af'] = '@function.outer',
['if'] = '@function.inner',
['ac'] = '@class.outer',
['ic'] = '@class.inner',
},
},
move = {
enable = true,
set_jumps = true, -- whether to set jumps in the jumplist
goto_next_start = {
[']m'] = '@function.outer',
[']]'] = '@class.outer',
},
goto_next_end = {
[']M'] = '@function.outer',
[']['] = '@class.outer',
},
goto_previous_start = {
['[m'] = '@function.outer',
['[['] = '@class.outer',
},
goto_previous_end = {
['[M'] = '@function.outer',
['[]'] = '@class.outer',
},
},
swap = {
enable = true,
swap_next = {
['<leader>a'] = '@parameter.inner',
},
swap_previous = {
['<leader>A'] = '@parameter.inner',
},
},
},
}
end,
},
-- Additional text objects via treesitter
{
'nvim-treesitter/nvim-treesitter-textobjects',
dependencies = { 'nvim-treesitter/nvim-treesitter' },
},
-- Highlight TODO, FIX, HACK, etc.
{
"folke/todo-comments.nvim",
dependencies = { "nvim-lua/plenary.nvim" },
config = function()
require("todo-comments").setup {
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
}
end
},
-- Github Copilot (disabled in VSCode)
{
"zbirenbaum/copilot.lua",
cond = not_vscode,
cmd = "Copilot",
event = "InsertEnter",
config = function()
require("copilot").setup({
suggestion = {
enabled = false,
-- enabled = true,
keymap = {
accept = false,
accept_word = false,
accept_line = false,
next = "<M-[>",
prev = "<M-]>",
dismiss = false,
},
},
panel = { enabled = false },
})
end,
},
{
"zbirenbaum/copilot-cmp",
cond = not_vscode,
dependencies = { "zbirenbaum/copilot.lua" },
config = function ()
require("copilot_cmp").setup()
end
},
-- Github Copilot integration (disabled in VSCode)
{
"CopilotC-Nvim/CopilotChat.nvim",
cond = not_vscode,
dependencies = {
{ "github/copilot.vim" }, -- or zbirenbaum/copilot.lua
{ "nvim-lua/plenary.nvim", branch = "master" }, -- for curl, log and async functions
},
build = "make tiktoken", -- Only on MacOS or Linux
opts = {
-- See Configuration section for options
mappings = {
reset = {
normal = "<C-r>",
insert = "<C-r>",
}
}
},
-- See Commands section for default commands if you want to lazy load on them
},
-- -- Codeium (unofficial with nvim-cmp support)
-- {
-- "Exafunction/codeium.nvim",
-- dependencies = {
-- "nvim-lua/plenary.nvim",
-- "hrsh7th/nvim-cmp",
-- },
-- config = function()
-- require("codeium").setup({
-- })
-- end
-- },
-- -- Codeium (official with virtual text)
-- -- 'Exafunction/codeium.vim',
-- {
-- 'Exafunction/codeium.vim',
-- config = function ()
-- -- Change '<C-g>' here to any keycode you like.
-- vim.keymap.set('i', '<leader><Tab>', function () return vim.fn['codeium#Accept']() end, { expr = true, silent = true })
-- end
-- },
-- LLM chat suppport in a Neovim-native style (disabled in VSCode)
{
"robitx/gp.nvim",
cond = not_vscode,
config = function()
end,
},
-- Git related plugins
'tpope/vim-fugitive',
'tpope/vim-rhubarb',
{
'lewis6991/gitsigns.nvim',
cond = not_vscode,
config = function()
require('gitsigns').setup {
signs = {
add = { text = '+' },
change = { text = '~' },
delete = { text = '_' },
topdelete = { text = '‾' },
changedelete = { text = '~' },
},
}
end,
},
-- VimTex
'lervag/vimtex',
-- colorschemes
'navarasu/onedark.nvim', -- Theme inspired by Atom
'marko-cerovac/material.nvim',
'EdenEast/nightfox.nvim',
'tiagovla/tokyodark.nvim',
{ 'nvim-lualine/lualine.nvim', cond = not_vscode }, -- Fancier statusline (disabled in VSCode)
{ 'lukas-reineke/indent-blankline.nvim', cond = not_vscode }, -- Add indentation guides even on blank lines (disabled in VSCode)
'numToStr/Comment.nvim', -- "gc" to comment visual regions/lines
'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically
-- Fuzzy Finder (files, lsp, etc) (disabled in VSCode)
{
'nvim-telescope/telescope.nvim',
cond = not_vscode,
branch = '0.1.x',
dependencies = {
'nvim-lua/plenary.nvim',
-- select the agent to use gp.nvim
'undg/telescope-gp-agent-picker.nvim',
}
},
-- Fuzzy Finder Algorithm which requires local dependencies to be built. Only load if `make` is available (disabled in VSCode)
{ 'nvim-telescope/telescope-fzf-native.nvim', build = 'make', cond = not_vscode and vim.fn.executable 'make' == 1 },
-- Move seamlessly between vin and tmux panes using C+[hjkl] (disabled in VSCode)
{ 'christoomey/vim-tmux-navigator', cond = not_vscode },
-- Run selected code in neighboring tmux pane e.g. ipython
{ 'jpalardy/vim-slime', ft = 'python' },
-- Faster motions
{
'phaazon/hop.nvim',
branch = 'v2', -- optional but strongly recommended
config = function()
-- you can configure Hop the way you like here; see :h hop-config
require'hop'.setup { keys = 'etovxqpdygfblzhckisuran' }
end
},
-- Floating terminal (disabled in VSCode)
{ "numToStr/FTerm.nvim", cond = not_vscode },
-- File explorer (disabled in VSCode)
{
'nvim-tree/nvim-tree.lua',
cond = not_vscode,
dependencies = {
'nvim-tree/nvim-web-devicons', -- optional, for file icons
},
version = "*" -- Use for stability; updated every week. (see issue #1193)
},
{
"kylechui/nvim-surround",
version = "*", -- Use for stability; omit to use `main` branch for the latest features
config = function()
require("nvim-surround").setup({
-- Configuration here, or leave empty to use defaults
})
end
},
-- Debugging (disabled in VSCode)
{ 'mfussenegger/nvim-dap', cond = not_vscode },
{ 'mfussenegger/nvim-dap-python', cond = not_vscode },
{ "rcarriga/nvim-dap-ui", dependencies = {"nvim-neotest/nvim-nio"}, cond = not_vscode },
{ 'rcarriga/cmp-dap', cond = not_vscode },
-- { 'jayp0521/mason-nvim-dap.nvim', cond = not_vscode },
})
-- [[ Setting options ]]
-- See `:help vim.o`
-- Set highlight on search
-- vim.o.hlsearch = false
-- Make line numbers default
vim.wo.number = true
-- Relative line numbers
vim.wo.relativenumber = true
-- Highlight the current line
vim.o.cursorline = true
-- Enable mouse mode
vim.o.mouse = 'a'
-- Enable break indent
vim.o.breakindent = true
-- Convert tabs to spaces
vim.o.expandtab = true
-- Copy between nvim and everything else
vim.o.clipboard = 'unnamedplus'
-- Save undo history
-- vim.o.undofile = true
-- Case insensitive searching UNLESS /C or capital in search
vim.o.ignorecase = true
vim.o.smartcase = true
-- Decrease update time
vim.o.updatetime = 250
vim.wo.signcolumn = 'yes'
-- Set colorscheme
vim.o.termguicolors = true
-- vim.cmd [[colorscheme onedark]]
-- vim.g.material_style = "deep ocean"
-- vim.cmd [[colorscheme material]]
-- init.lua
vim.g.tokyodark_transparent_background = true
vim.g.tokyodark_enable_italic_comment = true
vim.g.tokyodark_enable_italic = true
vim.g.tokyodark_color_gamma = '1.0'
vim.cmd('colorscheme tokyodark')
-- Set completeopt to have a better completion experience
vim.o.completeopt = 'menuone,noselect'
-- [[ Basic Keymaps ]]
-- Set <space> as the leader key
-- See `:help mapleader`
-- NOTE: Must happen before plugins are required (otherwise wrong leader will be used)
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
-- Keymaps for better default experience
-- See `:help vim.keymap.set()`
vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true })
-- Remap for dealing with word wrap
vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })
-- [[ Highlight on yank ]]
-- See `:help vim.highlight.on_yank()`
local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true })
vim.api.nvim_create_autocmd('TextYankPost', {
callback = function()
vim.highlight.on_yank()
end,
group = highlight_group,
pattern = '*',
})
-- Set lualine as statusline (only in terminal Neovim)
-- See `:help lualine.txt`
if not_vscode then
require('lualine').setup {
options = {
icons_enabled = false,
-- theme = 'onedark',
-- theme = 'material',
theme = 'tokyodark',
component_separators = '|',
section_separators = '',
},
}
end
-- Enable Comment.nvim
require('Comment').setup {
---LHS of toggle mappings in NORMAL mode
toggler = {
---Line-comment toggle keymap
-- line = 'gcc',
line = '<leader>/',
---Block-comment toggle keymap
block = 'gbc',
},
---LHS of operator-pending mappings in NORMAL and VISUAL mode
opleader = {
---Line-comment keymap
-- line = 'gc',
line = '<leader>/',
---Block-comment keymap
block = 'gb',
},
---LHS of extra mappings
extra = {
---Add comment on the line above
above = 'gcO',
---Add comment on the line below
below = 'gco',
---Add comment at the end of line
eol = 'gcA',
},
}
-- Enable `lukas-reineke/indent-blankline.nvim` (only in terminal Neovim)
-- See `:help indent_blankline.txt`
if not_vscode then
require('ibl').setup {
indent = {
char = '┊',
}
}
end
-- [[ Configure Telescope ]] (only in terminal Neovim)
-- See `:help telescope` and `:help telescope.setup()`
if not_vscode then
require('telescope').setup {
defaults = {
mappings = {
i = {
['<C-u>'] = false,
['<C-d>'] = false,
},
n = {
['q'] = require('telescope.actions').close,
['dd'] = require('telescope.actions').delete_buffer,
},
},
},
}
-- Additional features/extensions to load post-setup
require('telescope').load_extension('gp_picker') -- Only include this if gp_picker defined as an available extension
-- Enable telescope fzf native, if installed
pcall(require('telescope').load_extension, 'fzf')
-- See `:help telescope.builtin`
vim.keymap.set('n', '<leader>?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' })
vim.keymap.set('n', '<leader><space>', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' })
vim.keymap.set('n', '<leader>l', function()
-- You can pass additional configuration to telescope to change theme, layout, etc.
require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
winblend = 10,
previewer = false,
})
end, { desc = '[/] Fuzzily search in current buffer]' })
vim.keymap.set('n', '<leader>sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' })
vim.keymap.set('n', '<leader>sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' })
vim.keymap.set('n', '<leader>sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' })
vim.keymap.set('n', '<leader>sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' })
vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' })
vim.keymap.set('n', '<leader>sc', require('telescope.builtin').commands, { desc = '[S]earch [C]ommands' })
end
-- Diagnostic keymaps
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev)
vim.keymap.set('n', ']d', vim.diagnostic.goto_next)
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float)
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist)
-- nvim-cmp setup (only in terminal Neovim)
if not_vscode then
local cmp = require 'cmp'
local luasnip = require 'luasnip'
-- Below snip, doesn't appear in my completion suggestions
-- -- Latex-specific snippet; type frac and change to \frac{}{},
-- -- moving curson inside the first bracket
-- luasnip.parser.parse_snippet("frac", "\\frac{${1:numerator}}{${2:denominator}}$0")
cmp.setup {
-- MY ADDITION
enabled = function()
return vim.api.nvim_buf_get_option(0, "buftype") ~= "prompt"
or require("cmp_dap").is_dap_buffer()
end,
-- MY ADDITION END
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert {
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<CR>'] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace,
-- select = true,
select = false,
},
['<Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end, { 'i', 's' }),
['<S-Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { 'i', 's' }),
},
sources = {
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
-- { name = 'cmp_tabnine' },
{ name = 'buffer' },
{ name = 'path' },
{ name = 'copilot' },
-- { name = "codeium" },
},
}
-- MY ADDITION
require("cmp").setup.filetype({ "dap-repl", "dapui_watches", "dapui_hover" }, {
sources = {
{ name = "dap" },
},
})
-- MY ADDITION END
end
-- The line beneath this is called `modeline`. See `:help modeline`
-- vim: ts=2 sts=2 sw=2 et
-- MY CONFIGS FISO
-- pressing <esc> disables highlights until next search
vim.keymap.set('n', '<esc>', ':noh<return><esc>', { noremap = true })
-- map 'kj' to <esc> because xps plus's touch esc is bad
vim.keymap.set('i', 'kj', '<esc>', { noremap = true })
vim.keymap.set('i', 'jk', '<esc>', { noremap = true })
-- vim.keymap.set('i', 'lk', '<esc>', { noremap = true })
vim.keymap.set('n', 'q', '<esc>', { remap = true })
vim.keymap.set('v', 'q', '<esc>', { remap = true })
-- set ctrl-d and ctrl-u to 25% of screen hight instead of the default 50%
-- Function to scroll down by 25% of the window height
vim.keymap.set('n', '<C-d>', function()
local win_height = vim.api.nvim_win_get_height(0)
local scroll_amount = math.floor(win_height / 4)
-- Move the cursor down by scroll_amount lines
vim.cmd('normal! ' .. scroll_amount .. 'j')
-- Center the screen if desired
-- vim.cmd('normal! zz')
end, { noremap = true, silent = true })
-- Function to scroll up by 25% of the window height
vim.keymap.set('n', '<C-u>', function()
local win_height = vim.api.nvim_win_get_height(0)
local scroll_amount = math.floor(win_height / 4)
-- Move the cursor up by scroll_amount lines
vim.cmd('normal! ' .. scroll_amount .. 'k')
-- Center the screen if desired
-- vim.cmd('normal! zz')
end, { noremap = true, silent = true })
--
-- vim.keymap.set('n', '<C-d>', (vim.api.nvim_win_get_height(0) / 4 - 1) .. '<C-d>')
-- vim.keymap.set('n', '<C-u>', (vim.api.nvim_win_get_height(0) / 4 - 1) .. '<C-u>')
-- VIM SLIME
vim.g.slime_target = "tmux"
vim.g.slime_python_ipython = 1
-- vim.slime_bracketed_paste = 1
function string.split(str, sep)
local fields = {}
str:gsub("([^"..sep.."]+)", function(c) fields[#fields+1] = c end)
return fields
end
local function istmux()
return os.getenv("TMUX") ~= nil
end
if istmux() then
vim.g.slime_default_config = {
socket_name = string.split(os.getenv("TMUX"), ",")[1],
target_pane = "{bottom-right}"
}
vim.g.slime_dont_ask_default = 1
end
-- Set up autocommand to set slime_python_ipython for Markdown files
vim.api.nvim_create_autocmd('FileType', {
pattern = 'markdown',
callback = function()
vim.b.slime_python_ipython = 1
-- Define an escape function for Markdown that calls the Python escape function
vim.cmd([[
function! _EscapeText_markdown(text)
return call('_EscapeText_python', [a:text])
endfunction
]])
end
})
-- HOP
require('hop').setup()
vim.keymap.set('', '<leader>h', require('hop').hint_words)
vim.keymap.set('', '<leader>H', function()
require('hop').hint_words({ current_line_only = true })
end)
vim.keymap.set('', '<leader>j', function()
require('hop').hint_char1({ current_line_only = true })
end)
vim.keymap.set('', '<leader>J', require('hop').hint_char1)
vim.keymap.set('', '<leader>k', require('hop').hint_lines)
vim.cmd("hi HopNextKey guifg=#ff9900")
vim.cmd("hi HopNextKey1 guifg=#ff9900")
vim.cmd("hi HopNextKey2 guifg=#ff9900")
-- NVIM-TREE (only in terminal Neovim)
if not_vscode then
require("nvim-tree").setup({
sort_by = "case_sensitive",
view = {
adaptive_size = true,
},
on_attach = function(bufnr)
local api = require('nvim-tree.api')
local function opts(desc)
return { desc = 'nvim-tree: ' .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true }
end
-- Use default mappings
api.config.mappings.default_on_attach(bufnr)
-- Add custom mapping
vim.keymap.set('n', 'u', api.tree.change_root_to_parent, opts('Up'))
end,
renderer = {
group_empty = true,
},
filters = {
dotfiles = true,
},
})
vim.keymap.set('n', '<leader>t', ':NvimTreeToggle<CR>')
end
-- NVIM-SURROUND
require('nvim-surround').setup()
-- NVIM-DAP-PYTHON (only in terminal Neovim)
if not_vscode then
-- the way I understand this, the line below just refers to debugpy config
-- the way init.lua dap config looks rn debugpy needs to be installed in every debugged env.
require('dap-python').setup('~/opt/miniconda3/envs/debugpy/bin/python')
-- replaced the above with
-- require("mason-nvim-dap").setup({
-- ensure_installed = { "python" }
-- })
-- NVIM-DAP
-- vim.keymap.set('n', '<F5>', ":lua require'dap'.continue()<CR>", { silent = true })
-- vim.keymap.set('n', '<leader>b', ":lua require'dap'.toggle_breakpoint()<CR>", { silent = true })
vim.keymap.set('n', '<F5>', ":lua require'dap'.continue()<CR>") -- , { silent = true })
vim.keymap.set('n', '<F6>', ":lua require'dap'.step_over()<CR>") -- , { silent = true })
vim.keymap.set('n', '<F7>', ":lua require'dap'.step_into()<CR>") -- , { silent = true })
vim.keymap.set('n', '<F8>', ":lua require'dap'.step_out()<CR>") -- , { silent = true })
vim.keymap.set('n', '<F9>', ":lua require'dap'.terminate()<CR>") -- , { silent = true })
vim.keymap.set('n', '<F10>', ":lua require'dap'.pause()<CR>") -- , { silent = true })
vim.keymap.set('n', '<leader>b', ":lua require'dap'.toggle_breakpoint()<CR>") -- , { silent = true })
vim.keymap.set('n', '<leader>B', [[:lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition: '))<CR>]]) -- , { silent = true })
vim.keymap.set('n', '<leader>dp', [[:lua require'dap'.set_breakpoint(nil, nil, vim.fn.input('Log point message: '))<CR>]]) -- , { silent = true })
vim.keymap.set('n', '<leader>dr', ":lua require'dap'.repl.open()<CR>") -- , { silent = true })
vim.keymap.set('n', '<leader>dl', ":lua require'dap'.run_last()<CR>") -- , { silent = true })
vim.keymap.set('n', '<leader>dc', ":lua require'dap'.run_to_cursor()<CR>") -- , { silent = true })
-- nvim-dap-python keymaps
vim.keymap.set('n', '<leader>dn', ":lua require('dap-python').test_method()<CR>") -- , { silent = true })
vim.keymap.set('n', '<leader>df', ":lua require('dap-python').test_class()<CR>") -- , { silent = true })
vim.keymap.set('v', '<leader>ds', [[<ESC>:lua require('dap-python').debug_selection()<CR>]]) -- , { silent = true })
end
-- NVIM-DAP-UI (only in terminal Neovim)
if not_vscode then
-- require('dapui').setup()
require("dapui").setup({
icons = { expanded = "", collapsed = "", current_frame = "" },
mappings = {
-- Use a table to apply multiple mappings
expand = { "<CR>", "<2-LeftMouse>" },
open = "o",
remove = "d",
edit = "e",
repl = "r",
toggle = "t",
},
-- Use this to override mappings for specific elements
element_mappings = {
-- Example:
-- stacks = {
-- open = "<CR>",
-- expand = "o",
-- }
},
-- Expand lines larger than the window
-- Requires >= 0.7
expand_lines = vim.fn.has("nvim-0.7") == 1,
-- Layouts define sections of the screen to place windows.
-- The position can be "left", "right", "top" or "bottom".
-- The size specifies the height/width depending on position. It can be an Int
-- or a Float. Integer specifies height/width directly (i.e. 20 lines/columns) while
-- Float value specifies percentage (i.e. 0.3 - 30% of available lines/columns)
-- Elements are the elements shown in the layout (in order).
-- Layouts are opened in order so that earlier layouts take priority in window sizing.
layouts = {
{
elements = {
-- Elements can be strings or table with id and size keys.
{ id = "scopes", size = 0.25 },
"breakpoints",
"stacks",
"watches",
},
size = 40, -- 40 columns
position = "left",
},
{
elements = {
"console",
"repl",
},
size = 0.25, -- 25% of total lines
-- position = "bottom",
position = "right",
},
},
controls = {
-- Requires Neovim nightly (or 0.8 when released)
enabled = true,
-- Display controls in this element
element = "repl",
icons = {
pause = "",
play = "",
step_into = "",
step_over = "",
step_out = "",
step_back = "",
run_last = "",
terminate = "",
},
},
floating = {
max_height = nil, -- These can be integers or a float between 0 and 1.
max_width = nil, -- Floats will be treated as percentage of your screen.
border = "single", -- Border style. Can be "single", "double" or "rounded"
mappings = {
close = { "q", "<Esc>" },
},
},
windows = { indent = 1 },
render = {
max_type_length = nil, -- Can be integer or nil.
max_value_lines = 100, -- Can be integer or nil.
}
})
vim.keymap.set('n', '<leader>du', require('dapui').toggle)
vim.keymap.set('n', '<leader>de', require('dapui').eval)
vim.keymap.set('v', '<leader>de', require('dapui').eval)
end
-- TABNINE
-- require('tabnine').setup({
-- disable_auto_comment=true,
-- accept_keymap="<Tab>",
-- dismiss_keymap = "<C-]>",
-- debounce_ms = 800,
-- suggestion_color = {gui = "#808080", cterm = 244},
-- execlude_filetypes = {"TelescopePrompt"}
-- })
--
-- local tabnine = require('cmp_tabnine.config')
--
-- tabnine:setup({
-- max_lines = 1000,
-- max_num_results = 20,
-- sort = true,
-- run_on_every_keystroke = true,
-- snippet_placeholder = '..',
-- ignored_file_types = {
-- -- default is not to ignore
-- -- uncomment to ignore in lua:
-- -- lua = true
-- },
-- show_prediction_strength = false
-- })
-- FTERM (only in terminal Neovim)
if not_vscode then
vim.keymap.set('n', '<A-\\>', '<CMD>lua require("FTerm").toggle()<CR>')
vim.keymap.set('t', '<A-\\>', '<C-\\><C-n><CMD>lua require("FTerm").toggle()<CR>')
end
-- VIMTEX
-- This is necessary for VimTeX to load properly.
vim.cmd('filetype plugin indent on')
-- This enables Vim's and neovim's syntax-related features.
vim.cmd('syntax enable')
-- Or with a generic interface.
vim.g.vimtex_view_general_viewer = 'okular'
vim.g.vimtex_view_general_options = '--unique file:@pdf\\#src:@line@tex'
-- COPY TO SYSTEM CLIPBOARD
-- vim.keymap.set('v', '<leader>y', function()
-- vim.cmd('w !wl-copy')
-- vim.api.nvim_input('<CR>')
-- end, {silent = true})
-- JUPYTER CELL EXECUTION
-- Select a jupyter cell marked with the "# %%" format
local select_jupyter_cell = function()
local current_line = vim.fn.getline('.')
-- if on marker select up to next marker
if current_line:match('^# %%') then
vim.cmd('normal! V')
vim.cmd('/# %%\\|\\%$')
-- if not on marker go to marker above and select
else
vim.cmd('?# %%')