-
Notifications
You must be signed in to change notification settings - Fork 0
/
mappings.lua
181 lines (167 loc) · 6.31 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
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
-- Function that toggles (enables/disables) diagnostics inside a buffer
function _G.toggle_diagnostics()
-- _G part is important
---A global variable (not a function) that holds the global environment (see [§2.2](http://www.lua.org/manual/5.4/manual.html#2.2)). Lua itself does not use this variable; changing its value does not affect any environment, nor vice versa.
---
---[View documents](http://www.lua.org/manual/5.4/manual.html#pdf-_G)
---
---@class _G
--_G = {}
if vim.diagnostic.is_disabled() then
vim.diagnostic.enable()
else
vim.diagnostic.disable()
end
end
---@type MappingsTable
local M = {}
M.disabled = {
n = {
--["<leader>t"] = ""
-- nvterm: just use alt (toggle)
-- ["<A-h>"] = "",
["<A-i>"] = "",
-- ["<A-v>"] = "",
["<leader>v"] = "",
["<leader>h"] = "",
-- NvimTree
["<C-n>"] = "",
["<A-t>"] = "",
-- Diagnostics
["<leader>q"] = "",
["<tab>"] = "",
-- navigation
["<leader>gb"] = "",
["<leader>gn"] = "",
--["gi"] = "",
-- LaTeX
["<leader>i"] = "",
["<leader>s"] = "",
}
}
M.general = {
n = {
[";"] = { ":", "enter command mode", opts = { nowait = true } },
["<A-t>"] = { ":lua toggle_diagnostics()<CR>", "Toggle diagnostics", opts = { nowait = true } },
-- filesystem
["<F2>"] = { ":NvimTreeToggle<CR>", "NvimTreeToggle", opts = { nowait = true } },
-- buffers
["<leader>l"] = { ":bnext<CR>", "Buffer next", opts = { nowait = true } },
["<leader>h"] = { ":bprev<CR>", "Buffer prev", opts = { nowait = true } },
["<leader>d"] = { ":lua vim.diagnostic.setloclist()<CR>", "List diagnostics", opts = { nowait = true } },
["<leader><leader>"] = { "<C-^>", "Go previous", opts = { nowait = true } },
-- FZF
["<leader>;"] = { ":Telescope buffers<CR>", "Telescope buffers", opts = { nowait = true } },
-- navigation
["<leader>gb"] = { "<C-O>", "Navigation: Go back", opts = { nowait = true } },
["<leader>gn"] = { "<C-I>", "Navigation: Go next", opts = { nowait = true } },
["<tab>"] = { ":Vista!!<CR>", "LSP symbol viewer", opts = { nowait = true } },
-- Sorry lord
["<leader>1"] = { ":lua vim.api.nvim_set_current_buf(vim.t.bufs[1])<CR>", "Change to buffer 1", opts = {
nowait = true } },
["<leader>2"] = { ":lua vim.api.nvim_set_current_buf(vim.t.bufs[2])<CR>", "Change to buffer 2", opts = {
nowait = true } },
["<leader>3"] = { ":lua vim.api.nvim_set_current_buf(vim.t.bufs[3])<CR>", "Change to buffer 3", opts = {
nowait = true } },
["<leader>4"] = { ":lua vim.api.nvim_set_current_buf(vim.t.bufs[4])<CR>", "Change to buffer 4", opts = {
nowait = true } },
["<leader>5"] = { ":lua vim.api.nvim_set_current_buf(vim.t.bufs[5])<CR>", "Change to buffer 5", opts = {
nowait = true } },
["<leader>6"] = { ":lua vim.api.nvim_set_current_buf(vim.t.bufs[6])<CR>", "Change to buffer 6", opts = {
nowait = true } },
["<leader>7"] = { ":lua vim.api.nvim_set_current_buf(vim.t.bufs[7])<CR>", "Change to buffer 7", opts = {
nowait = true } },
["<leader>8"] = { ":lua vim.api.nvim_set_current_buf(vim.t.bufs[8])<CR>", "Change to buffer 8", opts = {
nowait = true } },
["<leader>9"] = { ":lua vim.api.nvim_set_current_buf(vim.t.bufs[9])<CR>", "Change to buffer 9", opts = {
nowait = true } },
["<leader>0"] = { ":lua vim.api.nvim_set_current_buf(vim.t.bufs[10])<CR>", "Change to buffer 10", opts = {
nowait = true } },
--"latex ernesto
["<leader>i"] = {
":<cmd>r!RAND=$(openssl rand -hex 8); IMAGEPATH=~/Pictures/capturaslatex/$RAND.png; spectacle -b -r -n -e -o $IMAGEPATH 2>/dev/null && latexScrot $IMAGEPATH<CR>",
"Add screenshot (shared storage)", opts = { nowait = true } },
["<leader>s"] = {
"<cmd>r!RAND=$(openssl rand -hex 8); IMAGEPATH=images/$RAND.png; spectacle -b -r -n -e -o %:p:h/$IMAGEPATH 2>/dev/null && latexScrot $IMAGEPATH<CR> ",
"Add screenshot (project storage)", opts = { nowait = true } },
["<A-l>"] = { ":lua vim.lsp.set_log_level('debug')<CR>", "LSP log debug", opts = { nowait = true } },
["<A-m>"] = { ":lua vim.lsp.set_log_level('off')<CR>", "LSP log off", opts = { nowait = true } },
["<C-t>"] = { ":TodoTelescope<CR>", "todo-comment telescope menu" },
},
}
M.gitsigns = {
n = {
-- Actions
-- map('n', '<leader>hs', gs.stage_hunk)
-- map('n', '<leader>hr', gs.reset_hunk)
-- map('v', '<leader>hs', function() gs.stage_hunk {vim.fn.line('.'), vim.fn.line('v')} end)
-- map('v', '<leader>hr', function() gs.reset_hunk {vim.fn.line('.'), vim.fn.line('v')} end)
-- map('n', '<leader>hS', gs.stage_buffer)
-- map('n', '<leader>hu', gs.undo_stage_hunk)
-- map('n', '<leader>hR', gs.reset_buffer)
-- map('n', '<leader>hp', gs.preview_hunk)
-- map('n', '<leader>hb', function() gs.blame_line{full=true} end)
-- map('n', '<leader>tb', gs.toggle_current_line_blame)
-- map('n', '<leader>hd', gs.diffthis)
-- map('n', '<leader>hD', function() gs.diffthis('~') end)
-- map('n', '<leader>td', gs.toggle_deleted)
["<leader>gs"] = {
function()
require("gitsigns").stage_hunk()
end,
"Stage hunk",
},
["<leader>gS"] = {
function()
require("gitsigns").stage_buffer()
end,
"Stage hunk",
},
["<leader>gr"] = {
function()
require("gitsigns").reset_hunk()
end,
"Reset hunk",
},
["<leader>gu"] = {
function()
require("gitsigns").undo_stage_hunk()
end,
"Reset hunk",
},
["<leader>B"] = {
function()
return require("gitsigns").blame_line({ full = true })
end,
"Reset hunk",
},
},
-- Visual mode mapping
v = {
["<leader>gs"] = {
function()
return require("gitsigns").stage_hunk({ vim.fn.line('.'), vim.fn.line('v') })
end,
"Stage hunk",
},
["<leader>gr"] = {
function()
return require("gitsigns").reset_hunk({ vim.fn.line('.'), vim.fn.line('v') })
end,
"Reset hunk",
},
},
}
--vim.lsp.set_log_level("off")
--vim.lsp.set_log_level("debug")
-- Doesnt work
-- for i = 1, 9, 1 do
-- vim.keymap.set("n", string.format("<leader>%s", i), function ()
-- vim.api.nvim_set_current_buf(vim.t.bufs[i])
-- end)
-- end
-- more keybinds!
-- luado vim.diagnostic.hide()
-- luado vim.diagnostic.hide()
--
return M