-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.lua
736 lines (628 loc) · 22.5 KB
/
config.lua
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
--[[
THESE ARE EXAMPLE CONFIGS FEEL FREE TO CHANGE TO WHATEVER YOU WANT
`lvim` is the global options object
]]
-- general
lvim.log.level = "info"
lvim.format_on_save = {
enabled = true,
-- pattern = "*.lua",
pattern = "*",
timeout = 1000,
}
-- to disable icons and use a minimalist setup, uncomment the following
-- lvim.use_icons = false
-- keymappings <https://www.lunarvim.org/docs/configuration/keybindings>
-- vim.cmd("unmap ,")
lvim.leader = ","
vim.g.mapleader = "," --without this, the which-key breaks
-- add your own keymapping
lvim.keys.normal_mode["<C-s>"] = ":w<cr>"
lvim.keys.normal_mode["<Tab>"] = ":BufferLineCycleNext<CR>"
lvim.keys.normal_mode["<S-Tab>"] = ":BufferLineCyclePrev<CR>"
-- Use which-key to add extra bindings with the leader-key prefix
-- lvim.builtin.which_key.mappings["n"] = { "<cmd>Telescope find_files<cr>", "Find File" }
-- lvim.builtin.which_key.mappings["t"] = { "<cmd>Telescope oldfiles<cr>", "Open Recent File" }
-- lvim.builtin.which_key.mappings["g"] = { "<cmd>Telescope live_grep<cr>", "Text" }
-- lvim.builtin.which_key.mappings = {
-- ['p'] = {},
-- ['c'] = {},
-- }
lvim.builtin.which_key.mappings["p"] = {}
lvim.builtin.which_key.mappings["c"] = {}
lvim.builtin.which_key.mappings["b"] = {}
lvim.builtin.which_key.setup.triggers_blacklist.n = { "p" }
-- lvim.builtin.which_key.mappings["P"] = { "<cmd>Telescope pq:rojects<CR>", "Projects" }
-- -- Change theme settings
lvim.builtin.alpha.active = true
lvim.builtin.alpha.mode = "dashboard"
lvim.builtin.terminal.active = true
-- Show the mappings= g?
lvim.builtin.nvimtree.setup.view.side = "left"
lvim.builtin.nvimtree.setup.view.relativenumber = true
lvim.builtin.nvimtree.setup.renderer.icons.show.git = false
-- Automatically install missing parsers when entering buffer
lvim.builtin.treesitter.auto_install = true
-- lvim.builtin.treesitter.ignore_install = { "haskell" }
-- -- always installed on startup, useful for parsers without a strict filetype
lvim.builtin.treesitter.ensure_installed = { "comment", "markdown_inline", "regex" }
-- -- generic LSP settings <https://www.lunarvim.org/docs/languages#lsp-support>
-- --- disable automatic installation of servers
-- lvim.lsp.installer.setup.automatic_installation = false
-- ---configure a server manually. IMPORTANT: Requires `:LvimCacheReset` to take effect
-- ---see the full default list `:lua =lvim.lsp.automatic_configuration.skipped_servers`
-- vim.list_extend(lvim.lsp.automatic_configuration.skipped_servers, { "pyright" })
-- local opts = {} -- check the lspconfig documentation for a list of all possible options
-- require("lvim.lsp.manager").setup("pyright", opts)
-- list of language servers - https://github.com/pwntester/nvim-lsp/blob/master/lua/nvim_lsp/bashls.lua
lvim.lsp.installer.setup.ensure_installed = {
"powershell_es",
"lua_ls",
"pyright",
"jsonls",
"yamlls",
"bashls",
"csharp_ls",
}
-- ---remove a server from the skipped list, e.g. eslint, or emmet_ls. IMPORTANT: Requires `:LvimCacheReset` to take effect
-- ---`:LvimInfo` lists which server(s) are skipped for the current filetype
-- lvim.lsp.automatic_configuration.skipped_servers = vim.tbl_filter(function(server)
-- return server ~= "emmet_ls"
-- end, lvim.lsp.automatic_configuration.skipped_servers)
-- -- you can set a custom on_attach function that will be used for all the language servers
-- -- See <https://github.com/neovim/nvim-lspconfig#keybindings-and-completion>
-- lvim.lsp.on_attach_callback = function(client, bufnr)
-- 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")
-- end
-- -- linters and formatters <https://www.lunarvim.org/docs/languages#lintingformatting>
local formatters = require("lvim.lsp.null-ls.formatters")
formatters.setup({
{ command = "stylua" },
{
command = "prettier",
extra_args = { "--print-width", "100" },
filetypes = { "javascript", "javascriptreact", "typescript", "typescriptreact", "html", "css" },
},
{ command = "prettier", filetypes = { "markdown" } },
{ command = "shfmt", filetypes = { "sh" } },
})
local linters = require("lvim.lsp.null-ls.linters")
linters.setup({
{ command = "eslint", filetypes = { "typescript", "typescriptreact" } },
{ command = "flake8", filetypes = { "python" } },
{
command = "shellcheck",
args = { "--severity", "warning" },
},
})
if
package.config:sub(1, 1) == "\\" --if OS is Windows
then
-- Enable powershell as your default shell
vim.opt.shell = "pwsh.exe -NoLogo"
vim.opt.shellcmdflag =
"-NoLogo -ExecutionPolicy RemoteSigned -Command [Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.Encoding]::UTF8;"
vim.cmd([[
let &shellredir = '2>&1 | Out-File -Encoding UTF8 %s; exit $LastExitCode'
let &shellpipe = '2>&1 | Out-File -Encoding UTF8 %s; exit $LastExitCode'
set shellquote= shellxquote=
nnoremap <leader>c :e ~/AppData/Local/lvim/config.lua<cr>
let g:clipboard = {
\ 'name': 'WslClipboard',
\ 'copy': {
\ '+': 'clip.exe',
\ '*': 'clip.exe',
\ },
\ 'paste': {
\ '+': 'powershell.exe -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))',
\ '*': 'powershell.exe -c [Console]::Out.Write($(Get-Clipboard -Raw).tostring().replace("`r", ""))',
\ },
\ 'cache_enabled': 0,
\ }
]])
else
vim.cmd([[
nnoremap <leader>c :e ~/.config/lvim/config.lua<cr>
command! FormatJson :%!jq .
]])
end
-- vim options
vim.opt.shiftwidth = 2
vim.opt.tabstop = 2
vim.opt.relativenumber = true
vim.cmd([[
au BufReadPost *.notes set filetype=txt
autocmd BufEnter * if &filetype == "" | setlocal ft=text | endif
autocmd VimEnter * set autochdir
" Tmux auto dir change
autocmd DirChanged * call chansend(v:stderr, printf("\033]7;file://%s\033\\", v:event.cwd))
autocmd VimLeave * call chansend(v:stderr, "\033]7;\033\\")
function! UpdateLvim()
:LvimUpdate
:Lazy sync
endfunction
nmap <leader>pu :call UpdateLvim()<cr>
" disable folding of sections like JS functions
set foldmethod=indent " manual fold
set foldnestmax=3 " deepest fold is 3 levels
set nofoldenable " don't fold by default
set wrap
set scrolloff=2
""""""""""""""""""""""""""""""
" => notes section
""""""""""""""""""""""""""""""
autocmd FileType notes :setlocal spell
" automatically uppercase the first letter of the sentence
augroup AUTOCAPITALISE
au!
autocmd InsertCharPre *.notes,*.txt,*.md if search('\v(^|[-.!?:]\_s)\_s*%#', 'bcnw') != 0 | let v:char = toupper(v:char) | endif
augroup END
autocmd VimLeavePre *.notes call GitCommitPush('cleanup')
]])
vim.cmd([[
nnoremap <space> :
" Smart way to move between windows
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
" Opens a new tab with the current buffer's path
" Super useful when editing files in the same directory
map <leader>te :tabedit <c-r>=expand("%:p:h")<cr>/
nmap <leader>tn :tabnew<cr>
" Switch CWD to the directory of the open buffer
map <leader>cd :cd %:p:h<cr>:pwd<cr>
command! BufOnly silent! execute "%bd|e#|bd#"
map <leader>bo BufOnly
" Switch to home directory
map <leader>ch :cd ~<cr>
nmap <leader>ro :e ~/.nb/home/rough.notes<cr>
" Copies current buffer into a new tab
map <leader>co ggVGy:tabnew<cr>:set syntax=qf<cr>pgg
"Closing/saving files
nnoremap <leader>x :x!<CR>
nnoremap <leader>q :q!<CR>
"Map go to declaration for ctags
noremap <F12> <C-]>
"Repeat last Ex mode command
nnoremap \ @:
vnoremap \ @:
"Delete all the content of the file/buffer
nnoremap daf :%d<CR>
" Increase/decrease numbers
nnoremap <A-a> <C-a>
nnoremap <A-x> <C-x>
"Indentation
nnoremap > >>
nnoremap < <<
"Copying the word under cursor to clipboard
nnoremap <C-C> viw"+y
"Select all
nnoremap <C-A> ggVG
"Yanking the file contents to clipboard
nnoremap <F6> gg"+yG
"Putting from clipboard
noremap <C-P> "+p
inoremap <C-P> <C-R>+
cnoremap <C-P> <C-R>+<space>
" => Add linebreak without entering insert mode
nnoremap <F9> o<Esc>
nnoremap <F8> O<Esc>
" Opening files
command! Vconf :e ~/.vimrc
command! Zc :e ~/.zshrc
command! Gconf :e ~/.gitconfig
command! Gignore :e ~/.gitignore
command! Bconf :e ~/.bashrc
command! Tconf :e ~/.tmux.conf
]])
vim.cmd([[
" This section contains custom methods
function! Push_Config()
if has("win32")
exec ":! push_lvim_config"
else
exec ":! source ~/.bashrc; push_lvim_config"
endif
endfunction
function! Pull_Config()
if has("win32")
exec ":! pull_lvim_config"
else
exec ":! source ~/.bashrc; pull_lvim_config"
endif
endfunction
nmap cpl :call Pull_Config()<CR>
nmap cps :call Push_Config()<CR>
function! GitCommitPush(commit_message)
Gw
exec "Git commit -m \"". a:commit_message. "\""
Git push
endfunction
command! -nargs=1 Gap call GitCommitPush(<f-args>)
nnoremap gap :Gap<space>
nnoremap gcl :Gap cleanup<CR>
nnoremap gnw :Gap new words<CR>
function! ModifyInsideBrackets(commandType) abort
let curr_line=getline('.')
let cursor_pos=col('.')
let brackets = ["[", "]", "(", ")", "{", "}", "\"", "'", "<", ">"]
let str_till_cursor_pos=strpart(curr_line,0,cursor_pos)
let reversed_str=join(reverse(split(str_till_cursor_pos, '.\zs')), '')
for char in split(reversed_str, '\zs')
let value_found_at = index(brackets, char)
if(value_found_at >= 0)
if(a:commandType ==? 'change')
execute "normal! ci".char
:normal! l
:startinsert
elseif(a:commandType==?'delete')
execute "normal! ci".char
elseif(a:commandType==? 'select')
execute "normal! vi".char
elseif(a:commandType==? 'yank')
execute "normal! yi".char
endif
break
endif
endfor
endfunction
" command! ModifyInsideBrackets call ModifyInsideBrackets()
nmap dib :call ModifyInsideBrackets("delete")<CR>
nmap cib :call ModifyInsideBrackets("change")<CR>
nmap vib :call ModifyInsideBrackets("select")<CR>
nmap yib :call ModifyInsideBrackets("yank")<CR>
function! JsonFormat()
if(&ft=='json')
:%!jq .
endif
endfunction
command! JsonFormat call JsonFormat()
function! ModifyAroundBrackets(commandType) abort
let curr_line=getline('.')
let cursor_pos=col('.')
let brackets = ["[", "]", "(", ")", "{", "}", "\"", "'", "<", ">"]
let str_till_cursor_pos=strpart(curr_line,0,cursor_pos)
let reversed_str=join(reverse(split(str_till_cursor_pos, '.\zs')), '')
for char in split(reversed_str, '\zs')
let value_found_at = index(brackets, char)
if(value_found_at >= 0)
if(a:commandType ==? 'change')
execute "normal! ca".char
:normal! l
:startinsert
elseif(a:commandType==?'delete')
execute "normal! ca".char
elseif(a:commandType==? 'select')
execute "normal! va".char
elseif(a:commandType==? 'yank')
execute "normal! ya".char
endif
break
endif
endfor
endfunction
nmap dab :call ModifyAroundBrackets("delete")<CR>
nmap cab :call ModifyAroundBrackets("change")<CR>
nmap vab :call ModifyAroundBrackets("select")<CR>
nmap yab :call ModifyAroundBrackets("yank")<CR>
]])
-- -- Additional Plugins <https://www.lunarvim.org/docs/plugins#user-plugins>
--
local function get_tabnine_build_string()
if vim.fn.has("win32") == 1 then
-- use special windows path
return "pwsh.exe -file .\\install.ps1"
else
-- unix path
return "./install.sh"
end
end
lvim.plugins = {
{
"folke/trouble.nvim",
cmd = "TroubleToggle",
},
-- {
-- "github/copilot.vim",
-- build = function()
-- vim.cmd 'Copilot setup'
-- vim.cmd 'Copilot run'
-- end
-- },
{ "marko-cerovac/material.nvim" }, --colorscheme
{ "Pocco81/auto-save.nvim" },
{ "tpope/vim-abolish" },
{ "tpope/vim-repeat" },
{ "tpope/vim-surround", keys = { "c", "d", "y" } },
-- { "kshenoy/vim-signature", keys = { "m" } }, -- mx - Toggle mark 'x' and display it in the leftmost column
{ "godlygeek/tabular" },
{ "preservim/vim-markdown", name = "vim-markdown", ft = "md" },
{ "tpope/vim-markdown", name = "tpope-markdown", ft = "md" },
{ "tpope/vim-fugitive" },
-- { "tpope/vim-rhubarb" },
{ "christoomey/vim-tmux-navigator" },
{ "editorconfig/editorconfig-vim" },
{ "ggandor/lightspeed.nvim" },
{ "mg979/vim-visual-multi" },
{ "elzr/vim-json", ft = "json" },
{ "justinmk/vim-gtfo" }, --Go to Terminal or File manager
{ "chrisbra/csv.vim", ft = "csv" },
{ "psliwka/vim-smoothie" }, --Smooth scrolling
{ "lambdalisue/suda.vim" },
-- { "tyru/open-browser.vim" }, --Open URLs; gx
-- { "tyru/open-browser-github.vim", dependencies = { 'tyru/open-browser.vim' } }, --:OpenGithubFile
{ "Almo7aya/openingh.nvim" },
{
"linrongbin16/gitlinker.nvim",
cmd = "GitLink",
opts = {},
keys = {
{ "<leader>gy", "<cmd>GitLink<cr>", mode = { "n", "v" }, desc = "Yank git permalink" },
{ "<leader>gY", "<cmd>GitLink!<cr>", mode = { "n", "v" }, desc = "Open git permalink" },
},
-- config = function()
-- vim.cmd([[
-- " command! Gblame :GitLink!<cr>
-- ]])
-- end,
},
{
"panozzaj/vim-autocorrect",
config = function()
vim.cmd([[
autocmd filetype * call AutoCorrect()
]])
end,
},
{
"ethanholz/nvim-lastplace", --Return to last edit position when opening files (You want this!)
config = function()
require("nvim-lastplace").setup({})
end,
},
{ "uga-rosa/cmp-dictionary", dependencies = { "hrsh7th/nvim-cmp" } },
{ "monaqa/dial.nvim" },
{
"tzachar/cmp-tabnine",
after = "nvim-cmp",
-- build = function()
-- if jit.os == "Linux" then
-- print("Executing install.sh...")
-- vim.cmd [[execute ":! ~/.local/share/lunarvim/site/pack/lazy/opt/cmp-tabnine/install.sh"]]
-- else
-- print("Executing install.ps1...")
-- EXECUTE BELOW...
-- pwsh "$HOME\AppData\Roaming\lunarvim\site\pack\lazy\opt\cmp-tabnine\install.ps1"
-- vim.cmd [[execute ":! pwsh -File $HOME\\AppData\\Roaming\\lunarvim\\site\\pack\\packer\\start\\cmp-tabnine\\install.ps1"]]
-- -- vim.cmd [[execute ":! pwsh -Command pwd"]]
-- print("Executed install.ps1...")
-- end
-- end,
build = get_tabnine_build_string(),
dependencies = "hrsh7th/nvim-cmp",
},
{
"lukas-reineke/headlines.nvim",
dependencies = "nvim-treesitter/nvim-treesitter",
config = true, -- or `opts = {}`
},
{
"AckslD/nvim-neoclip.lua", --Clipboard manager neovim plugin with telescope integration
dependencies = {
{ "kkharji/sqlite.lua", module = "sqlite" },
{ "nvim-telescope/telescope.nvim" },
},
after = "telescope",
config = function()
require("neoclip").setup({ default_register = { '"', "+", "*" } })
end,
},
{
"airblade/vim-rooter",
after = "telescope",
config = function()
vim.cmd([[
let g:rooter_patterns = ['.git', '.svn', 'package.json', '!node_modules']
]])
end,
},
{
"nvim-treesitter/nvim-treesitter-textobjects",
after = "nvim-treesitter",
dependencies = "nvim-treesitter/nvim-treesitter",
},
{
"kiyoon/treesitter-indent-object.nvim",
keys = {
{
"ai",
"<Cmd>lua require'treesitter_indent_object.textobj'.select_indent_outer()<CR>",
mode = { "x", "o" },
desc = "Select context-aware indent (outer)",
},
{
"aI",
"<Cmd>lua require'treesitter_indent_object.textobj'.select_indent_outer(true)<CR>",
mode = { "x", "o" },
desc = "Select context-aware indent (outer, line-wise)",
},
{
"ii",
"<Cmd>lua require'treesitter_indent_object.textobj'.select_indent_inner()<CR>",
mode = { "x", "o" },
desc = "Select context-aware indent (inner, partial range)",
},
{
"iI",
"<Cmd>lua require'treesitter_indent_object.textobj'.select_indent_inner(true)<CR>",
mode = { "x", "o" },
desc = "Select context-aware indent (inner, entire range)",
},
},
},
-- {
-- "gaoDean/autolist.nvim",
-- ft = {
-- "markdown",
-- "text",
-- "txt",
-- "tex",
-- "plaintex",
-- "norg",
-- },
-- config = function()
-- require("autolist").setup()
-- -- vim.keymap.set("i", "<tab>", "<cmd>AutolistTab<cr>")
-- -- vim.keymap.set("i", "<s-tab>", "<cmd>AutolistShiftTab<cr>")
-- -- vim.keymap.set("i", "<c-t>", "<c-t><cmd>AutolistRecalculate<cr>") -- an example of using <c-t> to indent
-- vim.keymap.set("i", "<CR>", "<CR><cmd>AutolistNewBullet<cr>")
-- vim.keymap.set("n", "o", "o<cmd>AutolistNewBullet<cr>")
-- vim.keymap.set("n", "O", "O<cmd>AutolistNewBulletBefore<cr>")
-- vim.keymap.set("n", "<CR>", "<cmd>AutolistToggleCheckbox<cr><CR>")
-- vim.keymap.set("n", "<C-r>", "<cmd>AutolistRecalculate<cr>")
-- -- cycle list types with dot-repeat
-- vim.keymap.set("n", "<leader>cn", require("autolist").cycle_next_dr, { expr = true })
-- vim.keymap.set("n", "<leader>cp", require("autolist").cycle_prev_dr, { expr = true })
-- -- if you don't want dot-repeat
-- -- vim.keymap.set("n", "<leader>cn", "<cmd>AutolistCycleNext<cr>")
-- -- vim.keymap.set("n", "<leader>cp", "<cmd>AutolistCycleNext<cr>")
-- -- functions to recalculate list on edit
-- vim.keymap.set("n", ">>", ">><cmd>AutolistRecalculate<cr>")
-- vim.keymap.set("n", "<<", "<<<cmd>AutolistRecalculate<cr>")
-- vim.keymap.set("n", "dd", "dd<cmd>AutolistRecalculate<cr>")
-- vim.keymap.set("v", "d", "d<cmd>AutolistRecalculate<cr>")
-- end,
-- },
}
-- Plugin config
-- vim.cmd('colorscheme material')
lvim.colorscheme = "material"
vim.g.material_style = "deep ocean"
require("lspconfig").lua_ls.setup({
settings = {
workspace = { checkThirdParty = false },
},
})
-- require "gitlinker".setup()
require("nvim-treesitter.install").prefer_git = true
require("nvim-treesitter.configs").setup({
textobjects = {
select = {
enable = true,
-- Automatically jump forward to textobj, similar to targets.vim
lookahead = true,
keymaps = {
-- You can use the capture groups defined in textobjects.scm
["af"] = "@function.outer",
["if"] = "@function.inner",
["ac"] = "@class.outer",
-- You can optionally set descriptions to the mappings (used in the desc parameter of
-- nvim_buf_set_keymap) which plugins like which-key display
["ic"] = { query = "@class.inner", desc = "Select inner part of a class region" },
-- ["ab"] = "@block.outer",
-- ["ib"] = "@block.inner",
-- You can also use captures from other query groups like `locals.scm`
["as"] = { query = "@scope", query_group = "locals", desc = "Select language scope" },
},
-- You can choose the select mode (default is charwise 'v')
--
-- Can also be a function which gets passed a table with the keys
-- * query_string: eg '@function.inner'
-- * method: eg 'v' or 'o'
-- and should return the mode ('v', 'V', or '<c-v>') or a table
-- mapping query_strings to modes.
selection_modes = {
["@parameter.outer"] = "v", -- charwise
["@function.outer"] = "V", -- linewise
["@class.outer"] = "<c-v>", -- blockwise
},
-- If you set this to `true` (default is `false`) then any textobject is
-- extended to include preceding or succeeding whitespace. Succeeding
-- whitespace has priority in order to act similarly to eg the built-in
-- `ap`.
--
-- Can also be a function which gets passed a table with the keys
-- * query_string: eg '@function.inner'
-- * selection_mode: eg 'v'
-- and should return true of false
include_surrounding_whitespace = true,
},
},
})
local ok, actions = pcall(require, "telescope.actions")
if not ok then
return
end
lvim.builtin.telescope.defaults.mappings = {
i = {
["<Esc>"] = "close",
["<C-c>"] = false,
-- ["<C-j>"] = actions.move_selection_next,
-- ["<C-k>"] = actions.move_selection_previous,
-- ["<C-n>"] = actions.cycle_history_next,
-- ["<C-p>"] = actions.cycle_history_prev,
},
}
require("telescope").load_extension("neoclip")
-- Autocommands (`:help autocmd`) <https://neovim.io/doc/user/autocmd.html>
vim.api.nvim_create_autocmd("FileType", {
pattern = "zsh",
callback = function()
-- let treesitter use bash highlight for zsh files as well
require("nvim-treesitter.highlight").attach(0, "bash")
end,
})
lvim.lsp.buffer_mappings.normal_mode["gs"] = nil
lvim.lsp.buffer_mappings.normal_mode["gp"] = nil
lvim.lsp.buffer_mappings.normal_mode["gr"] = nil
lvim.lsp.buffer_mappings.normal_mode["gw"] = nil
lvim.lsp.buffer_mappings.normal_mode["gd"] = nil
vim.cmd([[
""""""Plugins""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Fugitive
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
nnoremap gs :Git status<CR>
nnoremap gp :Git pull<CR>
nnoremap gps :Git push<CR>
nnoremap gpf :Git push --force<CR>
nnoremap gr :Gread<CR>
nnoremap gw :Gwrite<CR>
nnoremap gcm :Git commit --m ""
nnoremap gco :Git commit<CR>
nnoremap gca :Gwrite<CR>:Git commit --amend<CR>
nnoremap gbl :Git blame<CR>
nnoremap gd :Gvdiff<CR>
let g:gtfo#terminals = { 'win': 'pwsh.exe -NoLogo -NoExit -Command' }
" imap <silent><script><expr> <C-J> copilot#Accept("\<CR>")
" let g:copilot_no_tab_map = v:true
let g:vim_json_syntax_conceal = 0
" => lightspeed settings
nmap <leader>o <Plug>Lightspeed_s
" => dial settings
nmap <M-a> <Plug>(dial-increment)
nmap <M-x> <Plug>(dial-decrement)
nmap g<M-a> g<Plug>(dial-increment)
nmap g<M-x> g<Plug>(dial-decrement)
vmap <M-a> <Plug>(dial-increment)
vmap <M-x> <Plug>(dial-decrement)
vmap g<M-a> g<Plug>(dial-increment)
vmap g<M-x> g<Plug>(dial-decrement)
" => telescope settings
nmap <expr> <leader>n ':Telescope find_files cwd='.FindRootDirectory().'/<cr>'
nmap <leader>t :Telescope oldfiles<cr>
nmap <leader>g :Telescope live_grep<cr>
"search word under the cursor
nmap <expr> <leader>cf ':Telescope grep_string cwd='.FindRootDirectory().'/<cr>'
" nnoremap p "0p
nnoremap pl :Telescope neoclip<cr>
" => nvim-tree settings
nmap <leader>e :NvimTreeToggle<cr>
" => gitlinker settings
command! Gblame :GitLink!
]])