summaryrefslogtreecommitdiffstats
path: root/lua/core/binds.lua
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lua/core/binds.lua88
1 files changed, 60 insertions, 28 deletions
diff --git a/lua/core/binds.lua b/lua/core/binds.lua
index f27c87d..02216ae 100644
--- a/lua/core/binds.lua
+++ b/lua/core/binds.lua
@@ -9,17 +9,6 @@ local function map(mode, bind, cmd, opts)
end
elseif type(bind) == 'string' then
vim.keymap.set(mode, bind, cmd, opts)
- else
- vim.notify('-- Invalid bind for keymap:\nvim.keymap.set(\''
- .. mode .. '\', ' .. bind .. ', \'' .. cmd .. '\')',
- vim.log.levels.WARN, {
- title = 'Neovim Config',
- on_open = function(win)
- local buf = vim.api.nvim_win_get_buf(win)
- vim.api.nvim_buf_set_option(buf, "filetype", "lua")
- end
- }
- )
end
end
@@ -40,7 +29,7 @@ map('n', 'N', 'Nzzzv')
map('n', '<C-d>', '<C-d>zz') -- half page jumping
map('n', '<C-u>', '<C-u>zz')
-map('n', '<leader>x', '<cmd>!chmod +x %<CR>') -- execute order 111
+map('n', '<leader>x', '<cmd>!chmod +x "%"<CR>') -- execute order 111
-- add some keybinds to the file view (netrw)
a.nvim_create_autocmd('FileType', {
@@ -51,17 +40,17 @@ a.nvim_create_autocmd('FileType', {
end
bind('h', '-^') -- Go up a directory
bind('l', '<CR>') -- Go down a directory / open a file
- bind('.', 'gh') -- Toggle dotfiles
+ bind('.', 'gh') -- Toggle hidden files
bind('P', '<C-w>z') -- Close preview window
bind('<esc>', '<cmd>q<CR>') -- Close netrw
end
})
-- tabs
-map('n', '<C-q>n', '<cmd>tabnew<CR>')
-map('n', '<C-q>w', '<cmd>tabclose<CR>')
-map('n', '<C-q>h', '<cmd>tabprev<CR>')
-map('n', '<C-q>l', '<cmd>tabnext<CR>')
+map('n', '[]', '<cmd>tabnew<CR>')
+map('n', '][', '<cmd>tabc<CR>')
+map('n', '[[', '<cmd>tabp<CR>')
+map('n', ']]', '<cmd>tabN<CR>')
-- plugin binds ---------------------------------------------------------------
@@ -78,22 +67,41 @@ end
if pcall(require, "telescope") then
local telebuilt = require('telescope.builtin') -- telescope
+ -- local telexten = require('telescope').extensions
map('n', '<leader>sf', telebuilt.find_files, { desc = 'Find files.' })
+ map('n', '<leader>so', telebuilt.oldfiles, { desc = 'Find old files.' })
map('n', '<leader>sg', telebuilt.git_files, { desc = 'Find git files.' })
+ -- search urls in buffer
+ map('n', '<leader>su', '<Cmd>UrlView<CR>', { desc = 'Find urls in buffer.' })
+ -- search lsp symbols
+ map('n', '<leader>ss', telebuilt.lsp_document_symbols,
+ { desc = 'Find LSP Symbols.' })
+ -- search for keybinds
+ map('n', '<leader>sk', telebuilt.keymaps,
+ { desc = 'Find nvim Highlights.' })
+ -- search for highlights
+ map('n', '<leader>sh', telebuilt.highlights,
+ { desc = 'Find nvim Highlights.' })
+ -- search for autocommands
+ map('n', '<leader>sa', telebuilt.autocommands,
+ { desc = 'Find nvim Autocommands.' })
+ -- search for vim options
+ map('n', '<leader>sv', telebuilt.vim_options, { desc = 'Find vim options.' })
+ -- search for string in project
map('n', '<leader>sp', function()
- telebuilt.grep_string({ search = vim.fn.input(
- 'Find string in project > '
- ) })
+ telebuilt.grep_string({ search = vim.fn.input('Find string in project > ')})
end, { desc = 'Find string in project.' })
- map('n', '<leader>so', telebuilt.oldfiles, { desc = 'Find old files.' })
+ -- Code Actions (requires telescope)
+ if pcall(require, "actions-preview") then
+ map({ "n", "v" }, "<leader>ca", require("actions-preview").code_actions, {
+ desc = 'preview code actions'
+ })
+ end
end
map('n', '<leader>u', '<cmd>UndotreeToggle<CR>', { desc = 'Open undo tree.' })
map('n', '<leader>f', '<cmd>SFMToggle<CR>', { desc = 'Open file tree view.' })
map('n', '<leader>b', '<cmd>JABSOpen<CR>', { desc = 'Switch between buffers.' })
-map('n', '<leader>tt', '<cmd>TroubleToggle<CR>', { desc = 'Diagnostic list.' })
-map('n', '<leader>tc', '<cmd>TodoTrouble<CR>', { desc = 'Comment list.' })
-map('n', '<C-e>', '<cmd>IconPickerYank<CR>', { desc = 'Icon picker list.' })
if pcall(require, "dapui") then
local dapui = require('dapui') -- dap ui
@@ -122,14 +130,38 @@ if pcall(require, "true-zen") then
})
end
--- Git
-map('n', '<leader>gph', '<cmd>Gitsigns preview_hunk_inline<CR>')
-map('n', '<leader>gsh', '<cmd>Gitsigns stage_hunk<CR>')
+-- git
+map('n', '<leader>gp', '<cmd>Gitsigns preview_hunk_inline<CR>')
+map('n', '<leader>gs', '<cmd>Gitsigns stage_hunk<CR>')
map('n', '<leader>gb', '<cmd>Gitsigns blame_line<CR>')
+map('n', '<leader>g]', '<cmd>Gitsigns next_hunk<CR>')
+map('n', '<leader>g[', '<cmd>Gitsigns prev_hunk<CR>')
-- neogen
if pcall(require, "neogen") then
map('n', '<leader>df', require("neogen").generate, {
- desc = 'Generate anootations',
+ desc = 'Generate anotations',
})
end
+
+-- venn
+function _G.Toggle_venn()
+ local venn_enabled = vim.inspect(vim.b.venn_enabled)
+ if venn_enabled == "nil" then
+ vim.b.venn_enabled = true
+ vim.cmd([[setlocal ve=all]])
+ -- draw a line on HJKL keystokes
+ vim.api.nvim_buf_set_keymap(0, "n", "J", "<C-v>j:VBox<CR>", {noremap = true})
+ vim.api.nvim_buf_set_keymap(0, "n", "K", "<C-v>k:VBox<CR>", {noremap = true})
+ vim.api.nvim_buf_set_keymap(0, "n", "L", "<C-v>l:VBox<CR>", {noremap = true})
+ vim.api.nvim_buf_set_keymap(0, "n", "H", "<C-v>h:VBox<CR>", {noremap = true})
+ -- draw a box by pressing "f" with visual selection
+ vim.api.nvim_buf_set_keymap(0, "v", "f", ":VBox<CR>", {noremap = true})
+ else
+ vim.cmd[[setlocal ve=]]
+ vim.cmd[[mapclear <buffer>]]
+ vim.b.venn_enabled = nil
+ end
+end
+-- toggle keymappings for venn using <leader>v
+vim.api.nvim_set_keymap('n', '<leader>v', ":lua Toggle_venn()<CR>", { noremap = true})