0
0

init.lua 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. -- === === === === === === === === Neovim Config === === === === === === === ===
  2. --
  3. -- A configuration for Neovim that aims to be beautiful, intuitive, and
  4. -- pragmatic about plugin usage, while providing a developer experience on par
  5. -- with professional IDEs. It is tuned for usage with a custom keyboard
  6. -- layout and terminal configuration, and may not be as useful in other setups.
  7. --
  8. -- This configuration leverages a combination of keymaps and omnibars to give
  9. -- quick access to a large amount of functionality in an intuitive way. Most
  10. -- keymaps are unchanged from stock Neovim, with the notable exception of
  11. -- remapping most `s<a-Z>` keymaps.
  12. --
  13. -- === === === === === === === === === === === === === === === === === === ===
  14. --
  15. -- Core Options
  16. --
  17. -- === === === === === === === === === === === === === === === === === === ===
  18. -- Incantation to render correctly in Alacritty/tmux/macOS
  19. vim.cmd([[
  20. let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
  21. let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
  22. set termguicolors
  23. ]])
  24. -- File options
  25. vim.opt.wrap = false
  26. vim.opt.encoding = "UTF-8"
  27. vim.opt.hlsearch = true
  28. vim.opt.spell = true
  29. vim.opt.spelllang = "en_us"
  30. -- Display options
  31. vim.opt.pumheight = 15
  32. vim.opt.laststatus = 2
  33. vim.opt.showtabline = 2
  34. vim.opt.showcmd = true
  35. vim.opt.cmdheight = 0
  36. vim.opt.number = true
  37. vim.opt.relativenumber = true
  38. vim.opt.splitbelow = true
  39. vim.opt.splitright = true
  40. vim.opt.expandtab = true
  41. vim.opt.tabstop = 4
  42. vim.opt.shiftwidth = 4
  43. -- === === === === === === === === === === === === === === === === === === ===
  44. --
  45. -- Lazy.nvim Configuration
  46. --
  47. -- `lazy.nvim` is a modern plugin manager for Neovim.
  48. --
  49. -- === === === === === === === === === === === === === === === === === === ===
  50. -- Bootstrapping `lazy`, as directed by GitHub docs:
  51. -- https://github.com/folke/lazy.nvim#-installation
  52. local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
  53. if not vim.loop.fs_stat(lazypath) then
  54. vim.fn.system({
  55. "git", "clone", "--filter=blob:none",
  56. "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath
  57. })
  58. end
  59. vim.opt.rtp:prepend(lazypath)
  60. -- Add custom plugins to the runtimepath via lazy.
  61. local custom_runtime_path_root = vim.fn.stdpath("config") .. "/custom"
  62. local custom_runtime_paths = {}
  63. for _, filename in pairs(vim.split(vim.fn.glob(custom_runtime_path_root .. "/*"),
  64. "\n")) do
  65. table.insert(custom_runtime_paths, filename)
  66. end
  67. -- Load plugins
  68. require("lazy").setup("plugins", {
  69. performance = { rtp = { paths = custom_runtime_paths } },
  70. change_detection = { enabled = false },
  71. defaults = { lazy = false }
  72. })
  73. -- === === === === === === === === === === === === === === === === === === ===
  74. --
  75. -- Keymaps
  76. --
  77. -- === === === === === === === === === === === === === === === === === === ===
  78. -- Use `Alt-Arrow` to navigate between panes
  79. vim.keymap.set("i", "<A-left>", "<C-\\><C-N><C-w>W")
  80. vim.keymap.set("i", "<A-right>", "<C-\\><C-N><C-w>w")
  81. vim.keymap.set("i", "<S-A-left>", "<C-\\><C-N>:tabnext<CR>")
  82. vim.keymap.set("i", "<S-A-right>", "<C-\\><C-N>:tabprevious<CR>")
  83. vim.keymap.set("n", "<A-left>", "<C-w>W")
  84. vim.keymap.set("n", "<A-right>", "<C-w>w")
  85. vim.keymap.set("n", "<S-A-left>", ":tabnext<CR>")
  86. vim.keymap.set("n", "<S-A-right>", ":tabprevious<CR>")
  87. -- Folds toggled by homerow roll
  88. vim.keymap.set("n", "sr", ": normal za<CR>")
  89. -- Buffer actions
  90. vim.keymap.set("n", "SV", ":vsp<CR>")
  91. vim.keymap.set("n", "SQ", ":q<CR>")
  92. vim.keymap.set("n", "SH", ":noh<CR>")
  93. -- Yank to system clipboard
  94. vim.keymap.set({ "n", 'v' }, "Y", "\"+y")
  95. -- Yank file properties to system clipboard
  96. local yank_filename = function(full, line)
  97. local filename = vim.fn.expand("%")
  98. if full then filename = vim.fn.expand("%:p") end
  99. if line then filename = filename .. ":" .. vim.api.nvim_win_get_cursor(0)[1] end
  100. vim.fn.setreg("+", filename)
  101. end
  102. vim.keymap.set("n", "Syan", function() yank_filename(true, false) end)
  103. vim.keymap.set("n", "Syal", function() yank_filename(true, true) end)
  104. vim.keymap.set("n", "Syrn", function() yank_filename(false, false) end)
  105. vim.keymap.set("n", "Syrl", function() yank_filename(false, true) end)
  106. vim.keymap.set("n", "Syf", function() yank_filename(false, false) end)