2023-03-07 18:24:39 +01:00
|
|
|
(local opts (. (require :mzte_nv) :utils :map_opt))
|
2023-02-18 00:35:59 +01:00
|
|
|
|
|
|
|
(macro nmap [map action]
|
2023-03-07 00:01:16 +01:00
|
|
|
`(vim.keymap.set :n ,map ,action opts))
|
2023-02-18 00:35:59 +01:00
|
|
|
|
|
|
|
(macro cmd [c]
|
|
|
|
(.. :<cmd> c :<CR>))
|
|
|
|
|
|
|
|
;; Getting stuck in ~~vim~~ terminal
|
2023-03-07 00:01:16 +01:00
|
|
|
(vim.keymap.set :t :<Esc> "<C-\\><C-n>" opts)
|
2023-02-18 00:35:59 +01:00
|
|
|
|
|
|
|
;; Quick cursor movement
|
|
|
|
(nmap :<C-Down> :5j)
|
|
|
|
(nmap :<C-Up> :5k)
|
|
|
|
|
|
|
|
;; Quick system register access
|
|
|
|
(each [_ p (ipairs ["+" "*"])]
|
|
|
|
(each [_ r (ipairs [:y :p :d])]
|
|
|
|
(nmap (.. p r) (.. "\"" p r))))
|
|
|
|
|
|
|
|
;; Vimgrep
|
|
|
|
(nmap :<F4> (cmd :cnext))
|
|
|
|
(nmap :<S-F4> (cmd :cprevious))
|
|
|
|
|
|
|
|
;; LSP
|
2023-03-07 18:24:39 +01:00
|
|
|
(nmap :-a vim.lsp.buf.code_action)
|
|
|
|
(nmap :-d vim.diagnostic.goto_next)
|
|
|
|
(nmap :-n vim.lsp.buf.rename)
|
2023-03-07 00:01:16 +01:00
|
|
|
(nmap :-r #(vim.lsp.buf.format {:async true}))
|
2023-03-07 18:24:39 +01:00
|
|
|
(nmap :<C-k> vim.lsp.buf.signature_help)
|
|
|
|
(nmap :<space>e vim.diagnostic.open_float)
|
2023-03-07 00:01:16 +01:00
|
|
|
|
|
|
|
(nmap :K (fn []
|
|
|
|
(if ((. (require :conjure.client) :get))
|
|
|
|
((. (require :conjure.eval) :doc-word))
|
|
|
|
(vim.lsp.buf.hover))))
|
2023-02-18 00:35:59 +01:00
|
|
|
|
|
|
|
;; command to stop LSPs
|
|
|
|
(vim.api.nvim_create_user_command :StopLsps
|
|
|
|
#(vim.lsp.stop_client (vim.lsp.get_active_clients))
|
|
|
|
{:nargs 0})
|