2022-04-05 19:57:44 +00:00
|
|
|
(let [mod {}
|
|
|
|
keymap vim.keymap
|
|
|
|
legendary (require :legendary)
|
2022-04-09 23:07:36 +00:00
|
|
|
substitute (require :substitute)
|
2022-04-05 19:57:44 +00:00
|
|
|
telescope (require :telescope)
|
|
|
|
telescope-builtin (require :telescope.builtin)
|
|
|
|
telescope-themes (require :telescope.themes)
|
|
|
|
telescope-nifoc (require :nifoc.telescope)
|
|
|
|
telescope-ivy (telescope-themes.get_ivy)
|
|
|
|
telescope-dropdown (telescope-themes.get_dropdown)
|
|
|
|
npairs (require :nvim-autopairs)
|
2022-04-17 19:44:56 +00:00
|
|
|
gitsigns (require :gitsigns)]
|
2022-04-05 19:57:44 +00:00
|
|
|
(fn map-entry [key cmd opts]
|
|
|
|
(vim.tbl_extend :keep {1 key 2 cmd} opts))
|
|
|
|
|
|
|
|
(fn mod.setup []
|
|
|
|
(keymap.set :n :<space> :<nop> {:noremap true})
|
|
|
|
(set vim.g.mapleader " ")
|
|
|
|
(set vim.opt.timeoutlen 500)
|
|
|
|
(legendary.bind_keymaps [(map-entry :<leader>o
|
|
|
|
telescope-nifoc.project-files
|
|
|
|
{:description "Find Files"})
|
|
|
|
(map-entry :<leader>s
|
|
|
|
#(telescope-builtin.live_grep telescope-ivy)
|
|
|
|
{:description "Live Grep"})
|
|
|
|
(map-entry :<leader>fn :<cmd>enew<CR>
|
|
|
|
{:description "New File"})
|
|
|
|
(map-entry :<leader>ut :<cmd>UndotreeToggle<CR>
|
|
|
|
{:description "Toggle Undotree"})
|
|
|
|
;; Buffer
|
|
|
|
(map-entry :<leader>bl
|
|
|
|
#(telescope-builtin.buffers telescope-dropdown)
|
|
|
|
{:description "List Buffers"})
|
|
|
|
(map-entry :<leader>bn
|
|
|
|
:<cmd>BufferLineCycleNext<CR>
|
|
|
|
{:description "Next Buffer"})
|
|
|
|
(map-entry :<leader>bp
|
|
|
|
:<cmd>BufferLineCyclePrev<CR>
|
|
|
|
{:description "Previous Buffer"})
|
|
|
|
(map-entry :<leader>bf
|
|
|
|
#(telescope-builtin.current_buffer_fuzzy_find telescope-dropdown)
|
|
|
|
{:description "Find In Buffer"})
|
|
|
|
(map-entry :<leader>bt
|
|
|
|
#(telescope-builtin.treesitter telescope-dropdown)
|
|
|
|
{:description "Find Via Treesitter"})
|
|
|
|
;; Project
|
|
|
|
(map-entry :<leader>pt :<cmd>TodoTelescope<CR>
|
|
|
|
{:description "TODO Comments"})
|
|
|
|
;; VCS
|
|
|
|
(map-entry :<leader>vs
|
|
|
|
#(telescope-builtin.git_status telescope-ivy)
|
|
|
|
{:description "VCS Status"})
|
|
|
|
(map-entry :<leader>vb
|
|
|
|
#(telescope-builtin.git_branches telescope-dropdown)
|
|
|
|
{:description "List VCS Branches"})
|
|
|
|
(map-entry :<leader>vl gitsigns.blame_line
|
|
|
|
{:description "Blame Line"})
|
|
|
|
(map-entry :<leader>vn :<cmd>Neogit<CR>
|
|
|
|
{:description "Open Neogit"})
|
|
|
|
(map-entry :<leader>vc "<cmd>Neogit commit<CR>"
|
|
|
|
{:description "Neogit Commit"})
|
|
|
|
(map-entry :<leader>vp "<cmd>Neogit pull<CR>"
|
|
|
|
{:description "Neogit Pull"})
|
|
|
|
(map-entry :<leader>vP "<cmd>Neogit push<CR>"
|
|
|
|
{:description "Neogit Push"})
|
2022-04-06 14:32:24 +00:00
|
|
|
;; Legendary
|
|
|
|
(map-entry :<leader>lk #(legendary.find :keymaps)
|
|
|
|
{:description "Legendary Keymaps"})
|
|
|
|
(map-entry :<leader>lc #(legendary.find :commands)
|
|
|
|
{:description "Legendary Commands"})
|
|
|
|
(map-entry :<leader>la #(legendary.find :autocmds)
|
|
|
|
{:description "Legendary Autocmds"})
|
2022-04-05 19:57:44 +00:00
|
|
|
;; Debug
|
|
|
|
(map-entry :<leader>dli :<cmd>LspInfo<CR>
|
|
|
|
{:description "LSP Info"})
|
|
|
|
(map-entry :<leader>dlr :<cmd>LspRestart<CR>
|
|
|
|
{:description "LSP Restart"})
|
|
|
|
(map-entry :<leader>dt
|
|
|
|
:<cmd>TSPlaygroundToggle<CR>
|
|
|
|
{:description "Toggle Treetsitter Playground"})
|
|
|
|
(map-entry :<leader>dn
|
|
|
|
telescope.extensions.notify.notify
|
|
|
|
{:description "Display Notifications"})])
|
|
|
|
;; Other Mappings
|
|
|
|
(keymap.set :n :<CR> ":nohlsearch<CR><CR>" {:noremap true :silent true})
|
|
|
|
(keymap.set :i :<CR> npairs.autopairs_cr
|
|
|
|
{:noremap true :expr true :silent true})
|
|
|
|
(keymap.set :n :<A-Left> :b {:noremap true})
|
|
|
|
(keymap.set :n :<A-Right> :w {:noremap true})
|
|
|
|
(keymap.set :n :<S-Left> "^" {:noremap true})
|
|
|
|
(keymap.set :n :<S-Right> "$" {:noremap true})
|
|
|
|
(keymap.set :i :<A-Left> :<C-o>b {:noremap true})
|
|
|
|
(keymap.set :i :<A-Right> :<C-o>w {:noremap true})
|
|
|
|
(keymap.set :i :<S-Left> :<C-o>^ {:noremap true})
|
|
|
|
(keymap.set :i :<S-Right> :<C-o>$ {:noremap true})
|
2022-04-09 23:07:36 +00:00
|
|
|
(keymap.set :n :p "<Plug>(YankyPutAfter)")
|
|
|
|
(keymap.set :n :P "<Plug>(YankyPutBefore)")
|
|
|
|
(keymap.set :x :p substitute.visual)
|
|
|
|
(keymap.set :x :P "<Plug>(YankyPutBefore)")
|
|
|
|
(keymap.set :n :gp "<Plug>(YankyGPutAfter)")
|
|
|
|
(keymap.set :n :gP "<Plug>(YankyGPutBefore)")
|
|
|
|
(keymap.set :x :gp "<Plug>(YankyGPutAfter)")
|
|
|
|
(keymap.set :x :gP "<Plug>(YankyGPutBefore)")
|
|
|
|
(keymap.set :n :y "<Plug>(YankyYank)")
|
2022-04-17 19:44:56 +00:00
|
|
|
(keymap.set :x :y "<Plug>(YankyYank)"))
|
2022-04-05 19:57:44 +00:00
|
|
|
|
|
|
|
(fn mod.lsp-attach [client bufnr]
|
|
|
|
(legendary.bind_keymaps [(map-entry :<leader>t
|
|
|
|
#(telescope-builtin.lsp_document_symbols telescope-dropdown)
|
|
|
|
{:description "LSP Document Symbols"
|
|
|
|
:opts {:buffer bufnr}})
|
2022-04-10 21:47:39 +00:00
|
|
|
(map-entry :<leader>ld
|
|
|
|
#(telescope-builtin.diagnostics (vim.tbl_extend :keep
|
|
|
|
telescope-ivy
|
|
|
|
{:bufnr 0}))
|
2022-04-05 19:57:44 +00:00
|
|
|
{:description "LSP Document Diagnostics"
|
|
|
|
:opts {:buffer bufnr}})
|
|
|
|
(map-entry :<leader>lca
|
|
|
|
#(telescope-builtin.lsp_code_actions telescope-dropdown)
|
|
|
|
{:description "LSP Code Action"
|
|
|
|
:opts {:buffer bufnr}})
|
|
|
|
(map-entry :<leader>lfr
|
2022-04-10 21:47:39 +00:00
|
|
|
#(telescope-builtin.lsp_references telescope-dropdown)
|
2022-04-05 19:57:44 +00:00
|
|
|
{:description "Find References"
|
|
|
|
:opts {:buffer bufnr}})
|
|
|
|
(map-entry :<leader>lfd
|
2022-04-10 21:47:39 +00:00
|
|
|
#(telescope-builtin.lsp_definitions telescope-dropdown)
|
2022-04-05 19:57:44 +00:00
|
|
|
{:description "Find Definitions"
|
|
|
|
:opts {:buffer bufnr}})
|
2022-04-10 21:58:10 +00:00
|
|
|
(map-entry :<leader>lfi
|
|
|
|
#(telescope-builtin.lsp_implementations telescope-dropdown)
|
|
|
|
{:description "Find Implementations"
|
|
|
|
:opts {:buffer bufnr}})
|
2022-04-05 19:57:44 +00:00
|
|
|
(map-entry :K vim.lsp.buf.hover
|
|
|
|
{:description "Show Documentation"
|
2022-04-06 14:32:24 +00:00
|
|
|
:opts {:buffer bufnr}})
|
|
|
|
(map-entry :F :<cmd>Format<CR>
|
|
|
|
{:description "Format Buffer"
|
2022-04-05 19:57:44 +00:00
|
|
|
:opts {:buffer bufnr}})]))
|
|
|
|
|
|
|
|
mod)
|
2022-04-19 12:56:22 +00:00
|
|
|
|