This repository has been archived by the owner on Apr 10, 2024. It is now read-only.
generated from AstroNvim/user_example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmappings.lua
146 lines (140 loc) · 5.42 KB
/
mappings.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
local utils = require "astronvim.utils"
local is_available = utils.is_available
-- Mapping data with "desc" stored directly by vim.keymap.set().
--
-- Please use this mappings table to set keyboard mapping since this is the
-- lower level configuration and more robust one. (which-key will
-- automatically pick-up stored data by this setting.)
local maps = {
-- first key is the mode
n = {
-- second key is the lefthand side of the map
-- mappings seen under group name "Buffer"
["]g"] = false,
["[g"] = false,
["<leader>/"] = false,
["<leader>bd"] = { function() require("astronvim.utils.buffer").close(0) end, desc = "Close current buffer" },
["<leader>bD"] = {
function()
require("astronvim.utils.status").heirline.buffer_picker(
function(bufnr) require("astronvim.utils.buffer").close(bufnr) end
)
end,
desc = "Pick to close",
},
["<leader>c"] = false,
["<leader>C"] = false,
["<leader>fl"] = { "<cmd>Neotree reveal reveal_force_cwd<cr>", desc = "Explorer Find File Location" },
["<leader>fa"] = { function() require("telescope.builtin").grep_string() end, desc = "Find word under cursor" },
["<leader>fc"] = {
function()
local cwd = vim.fn.stdpath "config" .. "/.."
local search_dirs = {}
for _, dir in ipairs(astronvim.supported_configs) do -- search all supported config locations
if dir == astronvim.install.home then dir = dir .. "/lua/user" end -- don't search the astronvim core files
if vim.fn.isdirectory(dir) == 1 then table.insert(search_dirs, dir) end -- add directory to search if exists
end
if vim.tbl_isempty(search_dirs) then -- if no config folders found, show warning
utils.notify("No user configuration files found", vim.log.levels.WARN)
else
if #search_dirs == 1 then cwd = search_dirs[1] end -- if only one directory, focus cwd
require("telescope.builtin").find_files {
prompt_title = "Config Files",
search_dirs = search_dirs,
cwd = cwd,
} -- call telescope
end
end,
desc = "Find AstroNvim config files",
},
["<leader>fN"] = { "<cmd>Telescope noice<cr>", desc = "Find noice" },
["<leader>fp"] = { function() require("telescope").extensions.projects.projects {} end, desc = "Find projects" },
["<leader>fs"] = { function() require('sg.extensions.telescope').fuzzy_search_results() end, desc = "Find SourceGraph" },
["<leader>fT"] = { "<cmd>TodoTelescope<cr>", desc = "Find TODOs" },
["<leader>fw"] = {
function() require("telescope").extensions.live_grep_args.live_grep_args() end,
desc = "Find words",
},
["<leader>fW"] = false,
["<leader>gj"] = { function() require("gitsigns").next_hunk() end, desc = "Next Git hunk" },
["<leader>gk"] = { function() require("gitsigns").previous_hunk() end, desc = "Previous Git hunk" },
["<leader>tu"] = false,
["<leader>U"] = { "<cmd>Telescope undo<cr>", desc = "Undo" },
["<TAB>"] = {
function() require("astronvim.utils.buffer").nav(vim.v.count > 0 and vim.v.count or 1) end,
desc = "Next buffer",
},
["<S-TAB>"] = {
function() require("astronvim.utils.buffer").nav(-(vim.v.count > 0 and vim.v.count or 1)) end,
desc = "Previous buffer",
},
-- quick save
-- ["<C-s>"] = { ":w!<cr>", desc = "Save File" }, -- change description but the same command
},
t = {},
x = {},
o = {},
v = {
["<leader>/"] = false,
["<leader>fr"] = {
"<Esc><cmd>lua require('telescope').extensions.refactoring.refactors()<CR>",
desc = "Find code refactors",
},
},
}
if is_available "vim-visual-multi" then
-- visual multi
vim.g.VM_mouse_mappings = 0
vim.g.VM_theme = "iceblue"
vim.g.VM_maps = {
["Find Under"] = "<C-n>",
["Find Subword Under"] = "<C-n>",
["Add Cursor Up"] = "<C-S-k>",
["Add Cursor Down"] = "<C-S-j>",
["Select All"] = "<C-S-n>",
["Skip Region"] = "<C-x>",
Exit = "<C-c>",
}
end
-- refactoring
if is_available "refactoring.nvim" then
maps.n["<leader>r"] = { desc = " Refactor" }
maps.v["<leader>r"] = { desc = " Refactor" }
end
-- trouble
if is_available "trouble.nvim" then
maps.n["<leader>x"] = { desc = " Trouble" }
maps.n["<leader>xx"] = { "<cmd>TroubleToggle document_diagnostics<cr>", desc = "Document Diagnostics (Trouble)" }
maps.n["<leader>xX"] = { "<cmd>TroubleToggle workspace_diagnostics<cr>", desc = "Workspace Diagnostics (Trouble)" }
maps.n["<leader>xl"] = { "<cmd>TroubleToggle loclist<cr>", desc = "Location List (Trouble)" }
maps.n["<leader>xq"] = { "<cmd>TroubleToggle quickfix<cr>", desc = "Quickfix List (Trouble)" }
maps.n["<leader>xT"] = { "<cmd>TodoTrouble<cr>", desc = "TODOs (Trouble)" }
end
-- flash
if is_available "flash.nvim" then
maps.n["<leader>s"] = {
function() require("flash").jump() end,
desc = "Flash",
}
maps.x["<leader>s"] = {
function() require("flash").jump() end,
desc = "Flash",
}
maps.o["<leader>s"] = {
function() require("flash").jump() end,
desc = "Flash",
}
maps.n["<leader><leader>s"] = {
function() require("flash").treesitter() end,
desc = "Flash Treesitter",
}
maps.x["<leader><leader>s"] = {
function() require("flash").treesitter() end,
desc = "Flash Treesitter",
}
maps.o["<leader><leader>s"] = {
function() require("flash").treesitter() end,
desc = "Flash Treesitter",
}
end
return maps