Files
nvim-config/lua/keybinds.lua
T
guy176251 68d9b480f6 new file: after/plugin/codex_unmap.lua
modified:   ftplugin/html.lua
      new file:   ftplugin/text.lua
      modified:   ftplugin/yaml.lua
      modified:   lua/config.lua
      modified:   lua/functions.lua
      modified:   lua/keybinds.lua
      modified:   lua/lsp.lua
      modified:   lua/plugins.lua
2021-12-18 15:37:19 -06:00

189 lines
6.1 KiB
Lua

-- these are my custom functions
require("functions")
--local fn = vim.fn -- to call Vim functions e.g. fn.bufnr()
local function map(mode, lhs, rhs, opts)
local options = {noremap = true}
if opts then
options = vim.tbl_extend("force", options, opts)
end
vim.api.nvim_set_keymap(mode, lhs, rhs, options)
end
vim.g.mapleader = ","
map("v", "<C-C>", '"+y')
--map("n", "<Tab>", ":bnext<CR>")
--map("n", "<S-Tab>", ":bprevious<CR>")
map("n", "<Tab>", ":lua harpoon_bnext()<CR>")
map("n", "<S-Tab>", ":lua harpoon_bprevious()<CR>")
map("n", "<esc>", ":noh<cr><esc>", {silent = true}) --After searching, pressing escape stops the highlight
map("n", "<Leader>w", [[:%s/\s\+$//e<CR>]])
--map("n", "<Leader>x", ":Bclose <CR>")
map("n", "<Leader>t", ":tabnew<CR>")
-- Move split
map("n", "<A-Right>", "<C-W><S-L>")
map("n", "<A-Left>", "<C-W><S-H>")
map("n", "<A-Up>", "<C-W><S-K>")
map("n", "<A-Down>", "<C-W><S-J>")
-- Split navigations
map("n", "<C-Right>", "<C-W><C-L>")
map("n", "<C-Left>", "<C-W><C-H>")
map("n", "<C-Up>", "<C-W><C-K>")
map("n", "<C-Down>", "<C-W><C-J>")
-- Resize split
--map("n", "<A-j>", "<C-W>-")
--map("n", "<A-k>", "<C-W>+")
--map("n", "<A-h>", "<C-W><")
--map("n", "<A-l>", "<C-W>>")
-- Scroll viewport
map("n", "<S-Up>", "<C-Y>")
map("n", "<S-Down>", "<C-E>")
map("v", "<S-Up>", "<C-Y>")
map("v", "<S-Down>", "<C-E>")
map("i", "<S-Up>", "<C-X><C-Y>")
map("i", "<S-Down>", "<C-X><C-E>")
--map("n", "<PageUp>", "<C-Y>")
--map("n", "<PageDown>", "<C-E>")
--map("v", "<PageUp>", "<C-Y>")
--map("v", "<PageDown>", "<C-E>")
--map("i", "<PageUp>", "<C-X><C-Y>")
--map("i", "<PageDown>", "<C-X><C-E>")
-- Make visual yanks place the cursor back where started
map("v", "y", "ygv<Esc>")
-- map Enter to switch tabs
--map("n", "<Enter>", ":tabnext<CR>")
--map("n", "<Backspace>", ":tabprevious<CR>")
---------
-- HOP --
---------
local hop_opts = "{ create_hl_autocmd = true }"
local hopword = [[<cmd>lua require'hop'.hint_words(]] .. hop_opts .. [[)<cr>]]
local hopline = [[<cmd>lua require'hop'.hint_lines_skip_whitespace(]] .. hop_opts .. [[)<cr>]]
--map("n", "<m-l>", hopline, {silent = true})
--map("v", "<m-l>", hopline, {silent = true})
--map("n", "<m-w>", hopword, {silent = true})
--map("v", "<m-w>", hopword, {silent = true})
map("n", "W", hopline, {silent = true})
map("v", "W", hopline, {silent = true})
map("n", "w", hopword, {silent = true})
map("v", "w", hopword, {silent = true})
-- args: direction: bool, inclusive: bool
-- inclusive is broken in hop as of this comment
local hop_hint_char1 = function(args)
local direction = args.forward and "AFTER_CURSOR" or "BEFORE_CURSOR"
local inclusive = args.inclusive and "true" or "false"
return ("<cmd>lua require'hop'.hint_char1({ direction = require'hop.hint'.HintDirection." ..
direction .. ", current_line_only = true, inclusive_jump = " .. inclusive .. " })<cr>")
end
vim.api.nvim_set_keymap("", "f", hop_hint_char1({forward = true, inclusive = false}), {})
vim.api.nvim_set_keymap("", "F", hop_hint_char1({forward = false, inclusive = false}), {})
vim.api.nvim_set_keymap("", "t", hop_hint_char1({forward = true, inclusive = false}), {})
vim.api.nvim_set_keymap("", "T", hop_hint_char1({forward = false, inclusive = false}), {})
-- place this in one of your configuration file(s)
--vim.api.nvim_set_keymap(
-- "n",
-- "f",
-- "<cmd>lua require'hop'.hint_char1({ direction = require'hop.hint'.HintDirection.AFTER_CURSOR, current_line_only = true })<cr>",
-- {}
--)
--vim.api.nvim_set_keymap(
-- "n",
-- "F",
-- "<cmd>lua require'hop'.hint_char1({ direction = require'hop.hint'.HintDirection.BEFORE_CURSOR, current_line_only = true })<cr>",
-- {}
--)
--vim.api.nvim_set_keymap(
-- "",
-- "f",
-- "<cmd>lua require'hop'.hint_char1({ direction = require'hop.hint'.HintDirection.AFTER_CURSOR, current_line_only = true, inclusive_jump = true })<cr>",
-- {}
--)
--vim.api.nvim_set_keymap(
-- "",
-- "F",
-- "<cmd>lua require'hop'.hint_char1({ direction = require'hop.hint'.HintDirection.BEFORE_CURSOR, current_line_only = true, inclusive_jump = true })<cr>",
-- {}
--)
--vim.api.nvim_set_keymap(
-- "",
-- "t",
-- "<cmd>lua require'hop'.hint_char1({ direction = require'hop.hint'.HintDirection.AFTER_CURSOR, current_line_only = true })<cr>",
-- {}
--)
--vim.api.nvim_set_keymap(
-- "",
-- "T",
-- "<cmd>lua require'hop'.hint_char1({ direction = require'hop.hint'.HintDirection.BEFORE_CURSOR, current_line_only = true })<cr>",
-- {}
--)
---------
-- FZF --
---------
map("n", "<Leader>o", ":Files<CR>")
--map("n", "<Leader>O", [[:lua vim.fn['fzf#vim#files']('~/')<CR>]])
map("n", "<Leader>O", ":Files ~/<CR>")
map("n", "<Leader>b", ":Buffers<CR>")
map("n", "<Leader>h", ":Helptags<CR>")
map("n", "<Leader>;", ":History:<CR>")
map("n", "<Leader>c", ":Commands<CR>")
map("n", "<Leader>r", ":Rg<CR>")
map("n", "<Leader>s", ":Lines<CR>")
--map("n", "<Leader>[", ":Windows <CR>")
map("n", "<Leader>gf", ":GFiles<CR>")
map("n", "<Leader>gn", ":GFiles?<CR>")
map("n", "<Leader>gc", ":Commits<CR>")
------------------
-- FZF-CHECKOUT --
------------------
map("n", "<Leader>gb", ":GBranches<CR>")
---------
-- ALE --
---------
--map("n", "<c-k>", ":ALEPreviousWrap <CR>", {silent = true})
--map("n", "<c-j>", ":ALENextWrap <CR>", {silent = true})
-------------
-- HARPOON --
-------------
--map("n", "<Leader>m", [[:lua require("harpoon.mark").add_file() <CR>]])
map("n", "<Leader>x", ":lua harpoon_rm_file()<CR>")
--map("n", "<Leader>m", [[:lua harpoon_toggle_file()<CR>]])
map("n", "<Leader>M", [[:lua harpoon_clear_all()<CR>]])
map("n", "<Leader>l", [[:lua require("harpoon.ui").toggle_quick_menu()<CR>]])
--map("n", "<Leader>n", [[:lua require("harpoon.ui").nav_next() <CR>]])
--map("n", "<Leader>N", [[:lua require("harpoon.ui").nav_prev() <CR>]])
-----------
-- CODEX --
-----------
local create_completion = ":lua vim.fn.CreateCompletion(200)<CR>"
map("n", "<C-x>", create_completion)
map("i", "<C-x>", ("<C-o>" .. create_completion))
--map("i", "<C-x>", "<Esc>li<C-g>u<Esc>l:CreateCompletion<CR>")
--------------
-- NVIM FZF --
--------------
map("n", "<Leader>m", [[:lua fzf_buffer_add_to_harpoon()<CR>]])