kickstart.nvim/lua/keymaps.lua

76 lines
3.7 KiB
Lua

-- vim.keymap.set('n', '<leader>si', ':!feh <cfile> <CR>', { desc = 'Open file under cursor with feh' })
-------------------------------------------
-- venn.nvim: enable or disable keymappings
-------------------------------------------
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.api.nvim_buf_del_keymap(0, 'n', 'J')
vim.api.nvim_buf_del_keymap(0, 'n', 'K')
vim.api.nvim_buf_del_keymap(0, 'n', 'L')
vim.api.nvim_buf_del_keymap(0, 'n', 'H')
vim.api.nvim_buf_del_keymap(0, 'v', 'f')
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 })
-- vim.keymap.set('n', '<leader>ae', ':EnableAutocorrect<CR>', { noremap = false, silent = false, desc = 'Auto[c]orrect [e]able]' })
-- vim.keymap.set('n', '<leader>ad', ':DisableAutocorrect<CR>', { noremap = false, silent = false, desc = 'Auto[c]orrect [disable]' })
vim.api.nvim_set_keymap('n', '<leader>AE', ':EnableAutocorrect<CR>', { noremap = true })
vim.keymap.set('n', '<Space>ae', ':EnableAutocorrect<CR>', { noremap = true })
vim.keymap.set('n', '<Space>ad', ':DisableAutocorrect<CR>', { noremap = true })
-- Testing out IWE
vim.keymap.set('n', '<Space>m', vim.lsp.buf.code_action, { desc = 'something with IWE?' })
vim.keymap.set('n', '<Space>gs', ':lua require("telescope.builtin").lsp_dynamic_workspace_symbols()<CR>', { desc = 'something else with IWE I guess??' })
vim.keymap.set('n', '<Space>sz', ':Telescope lsp_workspace_symbols<CR>', { desc = 'SOMETHING [z]' })
---- From https://linkarzu.com/posts/neovim/neovim-tasks/#list-pending-tasks
-- Iterate through incomplete tasks in telescope
-- You can confirm in your terminal lamw25wmal with:
-- rg "^\s*-\s\[ \]" test-markdown.md
vim.keymap.set('n', '<Space>tq', function()
require('telescope.builtin').grep_string(require('telescope.themes').get_ivy {
prompt_title = 'Incomplete Tasks',
-- search = "- \\[ \\]", -- Fixed search term for tasks
-- search = "^- \\[ \\]", -- Ensure "- [ ]" is at the beginning of the line
search = '^\\s*- \\[ \\]', -- also match blank spaces at the beginning
search_dirs = { vim.fn.getcwd() }, -- Restrict search to the current working directory
use_regex = true, -- Enable regex for the search term
initial_mode = 'normal', -- Start in normal mode
--layout_config = {
-- preview_width = 0.5, -- Adjust preview width
--},
additional_args = function()
return { '--no-ignore' } -- Include files ignored by .gitignore
end,
})
end, { desc = '[P]Search for incomplete tasks' })
vim.keymap.set('n', '<Space>qq', function()
require('telescope.builtin').grep_string {
prompt_title = 'Incomplete Tasks',
search = '^\\s*- \\[ \\]', -- also match blank spaces at the beginning
search_dirs = { vim.fn.getcwd() }, -- Restrict search to the current working directory
-- initial_mode = 'normal', -- Start in normal mode
layout_strategy = 'vertical',
-- layout_config = { width = 0.5 },
use_regex = true, -- Enable regex for the search term
}
end)