-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugins-config.vim
More file actions
1610 lines (1413 loc) · 52.8 KB
/
plugins-config.vim
File metadata and controls
1610 lines (1413 loc) · 52.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
"" Fcitx
"" Bookmark
highlight BookmarkSign ctermbg=NONE ctermfg=160
highlight BookmarkLine ctermbg=194 ctermfg=NONE
let g:bookmark_sign = '⚑'
let g:bookmark_highlight_lines = 1
let g:bookmark_auto_save_file = $HOME .'/.config/nvim/bookmarks'
"" Bufferline
lua << EOF
require('bufferline').setup {
options = {
numbers = "ordinal",
close_command = "bdelete! %d", -- can be a string | function, see "Mouse actions"
right_mouse_command = "bdelete! %d", -- can be a string | function, see "Mouse actions"
left_mouse_command = "buffer %d", -- can be a string | function, see "Mouse actions"
middle_mouse_command = nil, -- can be a string | function, see "Mouse actions"
-- NOTE: this plugin is designed with this icon in mind,
-- and so changing this is NOT recommended, this is intended
-- as an escape hatch for people who cannot bear it for whatever reason
indicator_icon = '▎',
buffer_close_icon = '',
modified_icon = '●',
close_icon = '',
left_trunc_marker = '',
right_trunc_marker = '',
--- name_formatter can be used to change the buffer's label in the bufferline.
--- Please note some names can/will break the
--- bufferline so use this at your discretion knowing that it has
--- some limitations that will *NOT* be fixed.
name_formatter = function(buf) -- buf contains a "name", "path" and "bufnr"
-- remove extension from markdown files for example
if buf.name:match('%.md') then
return vim.fn.fnamemodify(buf.name, ':t:r')
end
end,
max_name_length = 18,
max_prefix_length = 15, -- prefix used when a buffer is de-duplicated
tab_size = 18,
diagnostics = "nvim_lsp" ,
diagnostics_update_in_insert = false,
diagnostics_indicator = function(count, level, diagnostics_dict, context)
return "("..count..")"
end,
-- NOTE: this will be called a lot so don't do any heavy processing here
custom_filter = function(buf_number)
-- filter out filetypes you don't want to see
if vim.bo[buf_number].filetype ~= "<i-dont-want-to-see-this>" then
return true
end
-- filter out by buffer name
if vim.fn.bufname(buf_number) ~= "<buffer-name-I-dont-want>" then
return true
end
-- filter out based on arbitrary rules
-- e.g. filter out vim wiki buffer from tabline in your work repo
if vim.fn.getcwd() == "<work-repo>" and vim.bo[buf_number].filetype ~= "wiki" then
return true
end
end,
-- offsets = {{filetype = "NvimTree", text = "File Explorer" | function , text_align = "left" | "center" | "right"}},
show_buffer_icons = true ,
show_buffer_close_icons = true,
show_close_icon = true ,
show_tab_indicators = true ,
persist_buffer_sort = true, -- whether or not custom sorted buffers should persist
-- can also be a table containing 2 custom separators
-- [focused and unfocused]. eg: { '|', '|' }
separator_style = "thin",
enforce_regular_tabs = true,
always_show_bufferline = true ,
sort_by = 'relative_directory'
}
}
EOF
"" ##################################################################
"" Lsp-status
lua << END
local lsp_status = require('lsp-status')
lsp_status.register_progress()
local lspconfig = require('lspconfig')
lsp_status.config {
select_symbol = function(cursor_pos, symbol)
if symbol.valueRange then
local value_range = {
["start"] = {
character = 0,
line = vim.fn.byte2line(symbol.valueRange[1])
},
["end"] = {
character = 0,
line = vim.fn.byte2line(symbol.valueRange[2])
}
}
return require("lsp-status.util").in_range(cursor_pos, value_range)
end
end
}
-- Some arbitrary servers
lspconfig.clangd.setup({
handlers = lsp_status.extensions.clangd.setup(),
init_options = {
clangdFileStatus = true
},
on_attach = lsp_status.on_attach,
capabilities = lsp_status.capabilities
})
END
"" ##################################################################
"" Line
" LuaLine
lua << EOF
require'lualine'.setup {
options = {
icons_enabled = true,
theme = 'onedark',
component_separators = {'', ''},
section_separators = {'', ''},
disabled_filetypes = {}
},
sections = {
lualine_a = {'filesize','mode'},
lualine_b = {'branch','diff'},
lualine_c = {'filename','diagnostics', "require('lsp-status').status()" },
lualine_x = {'encoding', 'fileformat', 'filetype'},
lualine_y = {'progress'},
lualine_z = {'location'}
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = {'filename'},
lualine_x = {'location'},
lualine_y = {},
lualine_z = {}
},
tabline = {},
extensions = {}
}
EOF
"" Projects
" print location: :lua print(require("project_nvim.utils.path").historyfile)
" ~/.local/share/nvim/project_nvim/project_history
lua << EOF
require("project_nvim").setup {
-- Manual mode doesn't automatically change your root directory, so you have
-- the option to manually do so using `:ProjectRoot` command.
manual_mode = false,
-- Methods of detecting the root directory. **"lsp"** uses the native neovim
-- lsp, while **"pattern"** uses vim-rooter like glob pattern matching. Here
-- order matters: if one is not detected, the other is used as fallback. You
-- can also delete or rearangne the detection methods.
detection_methods = { "pattern" },
-- detection_methods = { "lsp", "pattern" },
-- All the patterns used to detect root dir, when **"pattern"** is in
-- detection_methods
patterns = { ".git", "_darcs", ".hg", ".bzr", ".svn", "package.json", ".vimspector.json", ".nvimProj" },
-- Table of lsp clients to ignore by name
-- eg: { "efm", ... }
ignore_lsp = {"CMakeLists.txt"},
-- Don't calculate root dir on specific directories
-- Ex: { "~/.cargo/*", ... }
exclude_dirs = {"build/*"},
-- Show hidden files in telescope
show_hidden = true,
-- When set to false, you will get a message when project.nvim changes your
-- directory.
silent_chdir = true,
-- Path where project.nvim will store the project history for use in
-- telescope
-- datapath = vim.fn.stdpath("data"),
datapath = "~/.config/nvim/projects_nvim",
}
EOF
"" Dashboard
" Default value is clap
let g:dashboard_default_executive ='telescope'
let g:dashboard_custom_shortcut={
\ 'last_session' : 'SPC s l',
\ 'find_history' : 'SPC f h',
\ 'find_file' : 'SPC f f',
\ 'new_file' : 'SPC c n',
\ 'change_colorscheme' : 'SPC t c',
\ 'find_word' : 'SPC f a',
\ 'book_marks' : 'SPC f b',
\ }
"" Startify
" Read ~/.NERDTreeBookmarks file and takes its second column
"let g:startify_custom_header = [
" \ ' _ __ _ ',
" \ ' / |/ / __(_)_ _ ',
" \ ' / / |/ / / ` \ ',
" \ '/_/|_/|___/_/_/_/_/ ',
" \]
"
"function! s:nerdtreeBookmarks()
" let bookmarks = systemlist("cut -d' ' -f 2- ~/.NERDTreeBookmarks")
" let bookmarks = bookmarks[0:-2] " Slices an empty last line
" return map(bookmarks, "{'line': v:val, 'path': v:val}")
"endfunction
"
"let g:startify_lists = [
" \ { 'type': 'files', 'header': [' Files'] },
" \ { 'type': 'dir', 'header': [' Current Directory '. getcwd()] },
" \ { 'type': 'sessions', 'header': [' Sessions'] },
" \ { 'type': 'bookmarks', 'header': [' Bookmarks'] },
" \ ]
"
""" Save sessions
"let g:startify_session_dir = '~/.config/nvim/session'
"
""let g:startify_session_autoload = 1
"""If this option is enabled and you start Vim in a directory that contains a Session.vim, that session will be loaded automatically. Otherwise it will be shown as the top entry in the Startify buffer."
"
"""" Debug
"" Vimspector
" let g:vimspector_enable_mappings = 'HUMAN'
" let g:vimspector_install_gadgets = [ 'debugpy', 'vscode-cpptools', 'CodeLLDB' ]
" let g:vimspector_base_dir = expand('$HOME/.config/nvim/vimspector_config')
"" Dap, Dapui
lua << EOF
local dap = require'dap'
vim.fn.sign_define('DapBreakpoint', {text='', texthl='', linehl='', numhl=''})
vim.fn.sign_define('DapBreakpointCondition', {text='', texthl='', linehl='', numhl=''})
vim.fn.sign_define('DapLogPoint', {text='ﱴ', texthl='', linehl='', numhl=''})
vim.fn.sign_define('DapStopped', {text='', texthl='', linehl='', numhl=''})
vim.fn.sign_define('DapBreakpointRejected', {text='', texthl='', linehl='', numhl=''})
-- local widgets = require('dap.ui.widgets')
-- local my_sidebar = widgets.sidebar(widgets.scopes)
-- my_sidebar.open()
-- local my_sidebar = widgets.sidebar(widgets.frames)
-- my_sidebar.open()
-- widgets.centered_float(widgets.scopes)
-- require('dap.ui.widgets').hover()
dap.adapters.lldb = {
type = 'executable',
command = '/usr/bin/lldb-vscode-12', -- adjust as needed
name = "lldb"
}
dap.adapters.cppdbg = {
type = 'executable',
command = '/home/cris/.CppTools/cpptools-linux-1.7.1/extension/debugAdapters/bin/OpenDebugAD7',
name = "cppdbg"
}
-- CPP
dap.configurations.cpp = {
{
name = "Launch file",
type = "cppdbg",
request = "launch",
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
cwd = '${workspaceFolder}',
stopOnEntry = true,
-- externalTerminal = true,
},
{
name = 'Attach to gdbserver :1234',
type = 'cppdbg',
request = 'launch',
MIMode = 'gdb',
miDebuggerServerAddress = 'localhost:1234',
miDebuggerPath = '/usr/bin/gdb',
cwd = '${workspaceFolder}',
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
},
}
-- dap.configurations.c = dap.configurations.cpp
-- dap.configurations.rust = dap.configurations.cpp
-- To load launch.json files
require('dap.ext.vscode').load_launchjs()
-- dap.defaults.fallback.force_external_terminal = true
dap.defaults.fallback.external_terminal = {
command = '/usr/bin/terminator';
args = {'-e'};
}
-- Split terminal Vertical
dap.defaults.fallback.terminal_win_cmd = '30vsplit new'
-- Split terminal
dap.defaults.fallback.terminal_win_cmd = '5split new'
-- ##################################################################################
-- DAP UI
require("dapui").setup({
icons = { expanded = "▾", collapsed = "▸" },
mappings = {
-- Use a table to apply multiple mappings
expand = {"<Tab>", "<CR>", "<2-LeftMouse>" },
open = "o",
remove = "d",
edit = "e",
repl = "r",
},
sidebar = {
-- You can change the order of elements in the sidebar
elements = {
-- Provide as ID strings or tables with "id" and "size" keys
{
id = "scopes",
size = 0.25, -- Can be float or integer > 1
},
{ id = "breakpoints", size = 0.25 },
{ id = "stacks", size = 0.25 },
{ id = "watches", size = 00.25 },
},
size = 40,
position = "left", -- Can be "left", "right", "top", "bottom"
},
tray = {
elements = { "repl" },
size = 10,
position = "bottom", -- Can be "left", "right", "top", "bottom"
},
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.
mappings = {
close = { "q", "<Esc>" },
},
},
windows = { indent = 1 },
})
require'nvim-dap-virtual-text'
-- virtual text deactivated (default)
vim.g.dap_virtual_text = true
-- show virtual text for current frame (recommended)
vim.g.dap_virtual_text = true
-- request variable values for all frames (experimental)
-- vim.g.dap_virtual_text = 'all frames'
EOF
"" ####################################################################################
"" Nvim-dap-virtual-text
let g:dap_virtual_text = v:true
let g:dap_virtual_text_commented = v:true
"" ####################################################################################
"" LSP
lua << EOF
-- Emulating Saga
-- ###########################################
vim.cmd [[autocmd ColorScheme * highlight NormalFloat guibg=#1f2335]]
vim.cmd [[autocmd ColorScheme * highlight FloatBorder guifg=white guibg=#1f2335]]
local border = {
{"🭽", "FloatBorder"},
{"▔", "FloatBorder"},
{"🭾", "FloatBorder"},
{"▕", "FloatBorder"},
{"🭿", "FloatBorder"},
{"▁", "FloatBorder"},
{"🭼", "FloatBorder"},
{"▏", "FloatBorder"},
}
-- ###########################################
local nvim_lsp = require('lspconfig')
local protocol = require('vim.lsp.protocol')
-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local on_attach = function(client, bufnr)
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
-- Enable completion triggered by <c-x><c-o>
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Mappings.
local opts = { noremap=true, silent=true }
-- See `:help vim.lsp.*` for documentation on any of the below functions
buf_set_keymap('n', '<leader>lD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
buf_set_keymap('n', '<leader>ld', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
buf_set_keymap('n', '<leader>li', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
buf_set_keymap('n', '<leader>lwa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
buf_set_keymap('n', '<leader>lwr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
buf_set_keymap('n', '<leader>lwl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
buf_set_keymap('n', '<leader>ly', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
buf_set_keymap('n', '<leader>ln', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
buf_set_keymap('n', '<leader>la', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
buf_set_keymap('n', '<leader>lr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
buf_set_keymap('n', '<leader>le', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
buf_set_keymap('n', '<leader>lgp', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
buf_set_keymap('n', '<leader>lgn', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
buf_set_keymap('n', '<leader>lq', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
buf_set_keymap('n', '<leader>lf', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
-- Format on save, Also solves: When save, LSP check works
if client.resolved_capabilities.document_formatting then
vim.api.nvim_command [[augroup Format]]
vim.api.nvim_command [[autocmd! * <buffer>]]
vim.api.nvim_command [[autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_seq_sync()]]
vim.api.nvim_command [[augroup END]]
end -- Format
-- Emulating Saga
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {border = border})
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {border = border})
end -- Attach
-- Use a loop to conveniently call 'setup' on multiple servers and
-- map buffer local keybindings when the language server attaches
local servers = { 'clangd', 'bashls' }
for _, lsp in ipairs(servers) do
nvim_lsp[lsp].setup {
on_attach = on_attach,
flags = {
debounce_text_changes = 150,
},
-- cmd = { "clangd", "--background-index", "--all-scopes-completion", "--clang-tidy", "-log=verbose", "-pretty" , "--header-insertion=never" },
-- filetypes = { "c", "cpp", "objc", "objcpp" }
}
end
-- require'lspconfig'.clangd.setup{
nvim_lsp.clangd.setup{
on_attach = on_attach,
cmd = {
"clangd",
"--background-index",
"--pch-storage=memory",
"--clang-tidy",
"--suggest-missing-includes",
"--all-scopes-completion",
"--log=verbose",
"--pretty",
"--header-insertion=never"
},
filetypes = {"c", "cpp", "objc", "objcpp"},
-- root_dir = utils.root_pattern("compile_commands.json", "compile_flags.txt", ".git")
init_option = { fallbackFlags = { "-std=c++2a" } }
}
require'lspconfig'.cmake.setup{
-- filetypes = { 'cmake' },
init_options = {
buildDirectory = "build"
}
}
require'lspconfig'.gdscript.setup{}
require "lsp_signature".setup({
always_trigger = true,
transpancy = 30,
})
-- Emulating Saga
-- -- Icons
local M = {}
M.icons = {
Class = " ",
Color = " ",
Constant = " ",
Constructor = " ",
Enum = "了 ",
EnumMember = " ",
Field = " ",
File = " ",
Folder = " ",
Function = " ",
Interface = "ﰮ ",
Keyword = " ",
Method = "ƒ ",
Module = " ",
Property = " ",
Snippet = " ",
Struct = " ",
Text = " ",
Unit = " ",
Value = " ",
Variable = " ",
}
function M.setup()
local kinds = vim.lsp.protocol.CompletionItemKind
for i, kind in ipairs(kinds) do
kinds[i] = M.icons[kind] or kind
end
end
-- -- Customizing how diagnostics are displayed
vim.lsp.handlers['textDocument/publishDiagnostics'] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
virtual_text = true,
signs = true,
underline = true,
update_in_insert = false,
})
-- -- Change diagnostic symbols in the sign column (gutter)
local signs = { Error = " ", Warning = " ", Hint = " ", Information = " " }
for type, icon in pairs(signs) do
local hl = "LspDiagnosticsSign" .. type
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
end
-- -- Print diagnostic in status line
function PrintDiagnostics(opts, bufnr, line_nr, client_id)
opts = opts or {}
bufnr = bufnr or 0
line_nr = line_nr or (vim.api.nvim_win_get_cursor(0)[1] - 1)
local line_diagnostics = vim.lsp.diagnostic.get_line_diagnostics(bufnr, line_nr, opts, client_id)
if vim.tbl_isempty(line_diagnostics) then return end
local diagnostic_message = ""
for i, diagnostic in ipairs(line_diagnostics) do
diagnostic_message = diagnostic_message .. string.format("%d: %s", i, diagnostic.message or "")
print(diagnostic_message)
if i ~= #line_diagnostics then
diagnostic_message = diagnostic_message .. "\n"
end
end
vim.api.nvim_echo({{diagnostic_message, "Normal"}}, false, {})
end
vim.cmd [[ autocmd CursorHold * lua PrintDiagnostics() ]]
-- You will likely want to reduce updatetime which affects CursorHold
-- note: this setting is global and should be set only once
vim.o.updatetime = 250
vim.cmd [[autocmd CursorHold,CursorHoldI * lua vim.lsp.diagnostic.show_line_diagnostics({focusable=false})]]
-- -- Only in Nvim 0.6
-- vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
-- virtual_text = {
-- source = "always", -- Or "if_many"
-- }
-- })
-- --
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
virtual_text = {
prefix = '■', -- Could be '●', '▎', 'x'
}
})
-- -- Highlight line number instead of having icons in sign column
vim.cmd [[
highlight LspDiagnosticsLineNrError guibg=#51202A guifg=#FF0000 gui=bold
highlight LspDiagnosticsLineNrWarning guibg=#51412A guifg=#FFA500 gui=bold
highlight LspDiagnosticsLineNrInformation guibg=#1E535D guifg=#00FFFF gui=bold
highlight LspDiagnosticsLineNrHint guibg=#1E205D guifg=#0000FF gui=bold
sign define DiagnosticSignError text= texthl=LspDiagnosticsSignError linehl= numhl=LspDiagnosticsLineNrError
sign define DiagnosticSignWarn text= texthl=LspDiagnosticsSignWarning linehl= numhl=LspDiagnosticsLineNrWarning
sign define DiagnosticSignInfo text= texthl=LspDiagnosticsSignInformation linehl= numhl=LspDiagnosticsLineNrInformation
sign define DiagnosticSignHint text= texthl=LspDiagnosticsSignHint linehl= numhl=LspDiagnosticsLineNrHint
]]
EOF
"" ############################################
"" LSP Saga
lua <<EOF
-- local saga = require 'lspsaga'
--
-- saga.init_lsp_saga {
-- error_sign = '',
-- warn_sign = '',
-- hint_sign = '',
-- infor_sign = '',
-- border_style = "round",
--
-- code_action_icon = ' ',
-- finder_definition_icon = ' ',
-- finder_reference_icon = ' ',
-- definition_preview_icon = ' ',
-- rename_prompt_prefix = '➤',
--
-- }
--
EOF
"" ############################################
"" Treesitter
lua << EOF
require'nvim-treesitter.configs'.setup {
highlight = {
enable = true,
disable = {"javascript","json"},
},
indent = {
enable = true,
disable = {},
},
incremental_selection = {
enable = true,
keymaps = {
init_selection = "<leader>gti",
node_incremental = "<leader>gtf",
scope_incremental = "<leader>gts",
node_decremental = "<leader>gtd",
},
},
refactor = {
highlight_definitions = { enable = true },
highlight_current_scope = { enable = false },
smart_rename = {
enable = true,
keymaps = {
smart_rename = "<leader>gtr",
},
},
navigation = {
enable = true,
keymaps = {
goto_definition = "<leader>gtD",
list_definitions = "<leader>gtl",
list_definitions_toc = "<leader>gtt",
goto_next_usage = "<a-*>",
goto_previous_usage = "<a-#>",
},
},
},
ensure_installed = {
"cpp",
"llvm",
"cmake",
"glsl",
"lua",
"bash",
"comment",
"vim"
},
}
local parser_config = require "nvim-treesitter.parsers".get_parser_configs()
-- parser_config.tsx.used_by = { "javascript", "typescript.tsx" }
--parser_config.cpp.used_by = "clangd"
local ts_utils = require 'nvim-treesitter.ts_utils'
EOF
"" ############################################
"" Cmake Neovim-cmake
"" https://github.com/Shatur/neovim-cmake
"" ############################################
"" Telescope
lua << EOF
require('telescope').setup{
defaults = {
-- Default configuration for telescope goes here:
-- config_key = value,
mappings = {
i = {
-- map actions.which_key to <C-h> (default: <C-/>)
-- actions.which_key shows the mappings for your picker,
-- e.g. git_{create, delete, ...}_branch for the git_branches picker
["<C-h>"] = "which_key"
}
}
},
pickers = {
-- Default configuration for builtin pickers goes here:
-- picker_name = {
-- picker_config_key = value,
-- ...
-- }
-- Now the picker_config_key will be applied every time you call this
-- builtin picker
find_files = {
theme = "dropdown",
hidden = true,
-- file_ignore_patterns = {"build", ".cache"}
},
quickfix = { theme = "dropdown" },
marks = {theme = "dropdown"},
live_grep = { theme = "dropdown" },
buffers = { theme = "dropdown"},
file_browser = { theme = "dropdown", hidden = true },
grep_string = { theme = "dropdown"},
lsp_references = {theme = "dropdown"},
lsp_workspace_symbols = { theme = "dropdown"},
lsp_workspace_diagnostics = { theme = "dropdown"},
},
extensions = {
-- Your extension configuration goes here:
-- extension_name = {
-- extension_config_key = value,
-- }
-- please take a look at the readme of the extension you want to configure
-- Web Bookmarks Extension ---------------------------
bookmarks = {
-- Available: 'brave', 'google_chrome', 'safari', 'firefox', 'firefox_dev'
selected_browser = 'google_chrome',
-- Either provide a shell command to open the URL
url_open_command = 'open',
-- Or provide the plugin name which is already installed
-- Available: 'vim_external', 'open_browser'
url_open_plugin = open_browser,
firefox_profile_name = nil,
},
-- fzy_native ------------------------------------------
fzy_native = {
override_generic_sorter = false,
override_file_sorter = true,
},
-- Media -----------------------------------------------
media_files = {
-- filetypes whitelist
-- defaults to {"png", "jpg", "mp4", "webm", "pdf"}
filetypes = {"png", "webp", "jpg", "jpeg"},
find_cmd = "rg" -- find command (defaults to `fd`)
}
}
}
-- Telescope for Web Bookmarks
require('telescope').load_extension('bookmarks')
require('telescope').load_extension('fzy_native')
require('telescope').load_extension('projects')
require('telescope').load_extension('cmake')
require('telescope').load_extension('media_files')
-- require('telescope').load_extension('dap')
EOF
"" ############################################
"" lspkind
lua << EOF
require('lspkind').init({
-- enables text annotations
--
-- default: true
with_text = true,
-- default symbol map
-- can be either 'default' (requires nerd-fonts font) or
-- 'codicons' for codicon preset (requires vscode-codicons font)
--
-- default: 'default'
preset = 'codicons',
-- override preset symbols
--
-- default: {}
symbol_map = {
Text = "",
Method = "",
Function = "",
Constructor = "",
Field = "ﰠ",
Variable = "",
Class = "ﴯ",
Interface = "",
Module = "",
Property = "ﰠ",
Unit = "塞",
Value = "",
Enum = "",
Keyword = "",
Snippet = "",
Color = "",
File = "",
Reference = "",
Folder = "",
EnumMember = "",
Constant = "",
Struct = "פּ",
Event = "",
Operator = "",
TypeParameter = ""
},
})
EOF
"" ############################################
"" Completion
set completeopt=menu,menuone,noselect
let g:vsnip_snippet_dir="~/.config/nvim/snippets/"
lua <<EOF
-- Setup nvim-cmp.
local cmp = require'cmp'
local lspkind = require('lspkind')
cmp.setup({
formatting = {
format = require("lspkind").cmp_format({with_text = false, maxwidth = 50, menu = ({
buffer = "[Buffer]",
nvim_lsp = "[LSP]",
luasnip = "[LuaSnip]",
nvim_lua = "[Lua]",
latex_symbols = "[Latex]",
})}),
},
snippet = {
expand = function(args)
-- For `vsnip` user.
vim.fn["vsnip#anonymous"](args.body)
-- For `luasnip` user.
-- require('luasnip').lsp_expand(args.body)
-- For `ultisnips` user.
-- vim.fn["UltiSnips#Anon"](args.body)
end,
},
mapping = {
['<C-n>'] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
['<C-p>'] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
-- ['<Down>'] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }),
-- ['<Up>'] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }),
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.close(),
['<Tab>'] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 's' }),
-- ['<CR>'] = cmp.mapping.confirm({
-- behavior = cmp.ConfirmBehavior.Replace,
-- select = true
-- }),
},
sources = {
{ name = 'nvim_lsp' },
-- For vsnip user.
{ name = 'vsnip' },
-- For luasnip user.
-- { name = 'luasnip' },
-- For ultisnips user.
-- { name = 'ultisnips' },
{ name = 'buffer' },
{ name = 'path' },
{ name = 'calc' },
{ name = 'nvim_lua' },
{ name = 'latex_symbols' },
},
completion = {
keyword_length = 3,
}
})
-- -- For Snippets
-- require'cmp'.setup { sources = { { name = 'vsnip' } } }
--
-- -- For path
-- require'cmp'.setup { sources = { { name = 'path' } } }
--
-- -- LSP
-- require'cmp'.setup { sources = { { name = 'nvim_lsp' } } }
--
-- -- Calc
-- require'cmp'.setup { sources = { { name = 'calc' } } }
--
-- -- LUA
-- require'cmp'.setup { sources = { { name = 'nvim_lua' } } }
--
-- -- Latex
-- require'cmp'.setup { sources = { { name = 'latex_symbols' } } }
--
-- Setup lspconfig.
--require('lspconfig')[nvim_lsp].setup {
-- capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
--}
EOF
"" ###########################################
"" nvim-lsputils
lua <<EOF
if vim.fn.has('nvim-0.5.1') == 1 then
vim.lsp.handlers['textDocument/codeAction'] = require'lsputil.codeAction'.code_action_handler
vim.lsp.handlers['textDocument/references'] = require'lsputil.locations'.references_handler
vim.lsp.handlers['textDocument/definition'] = require'lsputil.locations'.definition_handler
vim.lsp.handlers['textDocument/declaration'] = require'lsputil.locations'.declaration_handler
vim.lsp.handlers['textDocument/typeDefinition'] = require'lsputil.locations'.typeDefinition_handler
vim.lsp.handlers['textDocument/implementation'] = require'lsputil.locations'.implementation_handler
vim.lsp.handlers['textDocument/documentSymbol'] = require'lsputil.symbols'.document_handler
vim.lsp.handlers['workspace/symbol'] = require'lsputil.symbols'.workspace_handler
else
local bufnr = vim.api.nvim_buf_get_number(0)
vim.lsp.handlers['textDocument/codeAction'] = function(_, _, actions)
require('lsputil.codeAction').code_action_handler(nil, actions, nil, nil, nil)
end
vim.lsp.handlers['textDocument/references'] = function(_, _, result)
require('lsputil.locations').references_handler(nil, result, { bufnr = bufnr }, nil)
end
vim.lsp.handlers['textDocument/definition'] = function(_, method, result)
require('lsputil.locations').definition_handler(nil, result, { bufnr = bufnr, method = method }, nil)
end
vim.lsp.handlers['textDocument/declaration'] = function(_, method, result)
require('lsputil.locations').declaration_handler(nil, result, { bufnr = bufnr, method = method }, nil)
end
vim.lsp.handlers['textDocument/typeDefinition'] = function(_, method, result)
require('lsputil.locations').typeDefinition_handler(nil, result, { bufnr = bufnr, method = method }, nil)
end
vim.lsp.handlers['textDocument/implementation'] = function(_, method, result)
require('lsputil.locations').implementation_handler(nil, result, { bufnr = bufnr, method = method }, nil)
end
vim.lsp.handlers['textDocument/documentSymbol'] = function(_, _, result, _, bufn)
require('lsputil.symbols').document_handler(nil, result, { bufnr = bufn }, nil)
end
vim.lsp.handlers['textDocument/symbol'] = function(_, _, result, _, bufn)
require('lsputil.symbols').workspace_handler(nil, result, { bufnr = bufn }, nil)
end
end
EOF
"" ########################################################
"" Outline
lua << EOF
-- init.lua
vim.g.symbols_outline = {
highlight_hovered_item = true,
show_guides = true,