Neovim configs for 2023. Hopefully they last.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.9 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. local function map(mode, lhs, rhs, opts)
  2. local options = { noremap = true }
  3. if opts then
  4. options = vim.tbl_extend("force", options, opts)
  5. end
  6. vim.api.nvim_set_keymap(mode, lhs, rhs, options)
  7. end
  8. vim.g.mapleader = " "
  9. map("n", "j", "gj")
  10. map("n", "k", "gk")
  11. map("n", "<C-h>", "<C-w>h")
  12. map("n", "<C-j>", "<C-w>j")
  13. map("n", "<C-k>", "<C-w>k")
  14. map("n", "<C-l>", "<C-w>l")
  15. map("i", "<A-a>", "ā")
  16. map("i", "<A-e>", "ē")
  17. map("i", "<A-i>", "ī")
  18. map("i", "<A-o>", "ō")
  19. map("i", "<A-u>", "ū")
  20. map("n", "<F12>", ":w|:!texbld run compile<CR>")
  21. map("n", "<F5>", ":w|:!./test.sh<CR>")
  22. -- hacks
  23. vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
  24. vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
  25. vim.keymap.set("n", "J", "mzJ`z")
  26. vim.keymap.set("n", "<C-d>", "<C-d>zz")
  27. vim.keymap.set("n", "<C-u>", "<C-u>zz")
  28. vim.keymap.set("n", "n", "nzzzv")
  29. vim.keymap.set("n", "N", "Nzzzv")
  30. vim.keymap.set("x", "<leader>p", [["_dP]])
  31. vim.keymap.set({ "n", "v" }, "<leader>y", [["+y]])
  32. vim.keymap.set("n", "<leader>Y", [["+Y]])
  33. vim.keymap.set("n", "<leader>x", "<cmd>!chmod +x %<CR>", { silent = true })
  34. vim.keymap.set("n", "<leader>X", "<cmd>!chmod -x %<CR>", { silent = true })
  35. -- execute file
  36. vim.keymap.set("n", "<leader>,", "<cmd>e ~/.config/nvim<CR>");
  37. vim.keymap.set("n", "<leader>r", "<cmd>so ~/.config/nvim/init.lua<CR>")
  38. vim.keymap.set("n", "<leader>e", "<cmd>!%:p<CR>", { silent = true })
  39. vim.keymap.set("n", "<leader>vz", "<cmd>e ~/.zshrc<CR>");
  40. vim.keymap.set("n", "<leader>fmt", function()
  41. vim.lsp.buf.formatting_sync()
  42. end)
  43. if os.getenv("TMUX") ~= nil then
  44. vim.keymap.set("n", "<C-f>", [[<cmd>silent !tmux neww "zsh -c '. ~/.zshenv; tmuxs'"<CR>]])
  45. vim.keymap.set("n", "<C-y>", [[<cmd>silent !tmux neww ncmpcpp<CR>]])
  46. else
  47. local function unavailable()
  48. print("Not in a tmux session")
  49. end
  50. vim.keymap.set("n", "<C-f>", unavailable)
  51. vim.keymap.set("n", "<C-y>", unavailable)
  52. end